Hi Alfie,
Please refer http://docs.jboss.org/jbpm/v5.4/userguide/ch.core-basics.html#d0e1307
section 6.1.3. Defining Processes Using the Process API.
This will become complex based on the requirement but is very useful if you have your own UI for creating process and can not use JBPM designer.
Thanks,
Ashish