cancel
Showing results for 
Search instead for 
Did you mean: 

Object in workflow

alexskinner
Champ in-the-making
Champ in-the-making
Hi all,

Apologies in advanced as I am a complete newbie to activiti. I have been trying to read through the user guide over the last few weeks trying to teach myself how it works etc. I'd previously only really done some java programming so forgive me if my questions seem really easy to you. Smiley Tongue

Basically I have created an object called request with the relevant methods. Here is a snippet:

@Entity(name="request")
public class Request {

   @Id
   @GeneratedValue(strategy=GenerationType.IDENTITY)
   private Long id;   
   
   @OneToOne(cascade={CascadeType.DETACH})
   @JoinColumn(name="softwareapplicationid", nullable=false)
   private Application softwareApplication;
   
   public Long getId() {
      return id;
   }

   public void setId(Long id) {
      this.id = id;
   }

   public Application getSoftwareApplication() {
      return softwareApplication;
   }

   public void setSoftwareApplication(Application softwareApplication) {
      this.softwareApplication = softwareApplication;
   }

I have also created a workflow. I would like to be able to call certain request fields into the workflow.

For example, within the request object, there is a pointer to another object (softwareApplication) which contains a getter 'isRequiresApproval', returning a boolean and I would like to be able to use the value in an exclusive gateway.

Is it easier to pass in a request object when the workflow is started or just reference the request class.

Eventually an instance of the request object will be created by reading the data from a postgresql database.

I hope I've given enough information but please let me know if I can help any more. As I said I am a very new to this. I'm in my 2nd year of Comp Sci degree but currently on an internship over the summer and trying to impress the guys in the office so any help will be greatly appreciated! Smiley Happy

Thank you in advanced for taking the time to read this!
2 REPLIES 2

frederikherema1
Star Contributor
Star Contributor
You're lucky, activiti supports JPA-entities to be used as "process variables", so you can use expressions to evaluate properties of those entities inside your process (or properties of referenced entities,e g ${request.softwareApplication.requiresApproval}".

Check out http://activiti.org/userguide/index.html#N11F6A, there is a short example of JPA hooked in into process. This is also pin our codebase, try checking it out and look for *JPA*.java Smiley Wink

alexskinner
Champ in-the-making
Champ in-the-making
Thank you very much for your reply! Smiley Happy