7 Replies Latest reply: Jun 17, 2013 5:56 AM by Minh Hoang TO RSS

Adding new  workitems programmatically, without repacking the application ?

Arun V G Newbie

I am working with creating domain specific processes and followed the example

 

  • Created  work definition in the MVEL format
  • Register the workdefinition in the drools.rulebase.conf
  • Creating the work item handler
  • Registering the workitem hanlder.

 

And it worked effectively.

 

Our requirment is to create new work definitions using an editor and save the attribtes of a work definition in a Database so that in future it can be edited or extended

 

So my questions are

 

  • Can I create a Work definition in any other format other than the MVEL .( I don't want to be a polyglot )
  • Can I register the Work item to the processing engine programatically rather than having the drools.rulebase.conf  file in the class path.

 

 

I am not very concerned about the eclipse/web editor as we have plans to develop it in house and we are evaluating jBPM for the processing part.

 

 

Any hints would be highly appreciated

 

Cheers

  • 1. Re: Adding new  workitems programmatically, without repacking the application ?
    Mauricio Salatino Master

    If you are not planning to use eclipse or the web designer, you can write your WorkItem definitions in the language that you want. Your tool will need to understand that language.

    And yes you can register the workitems doing:

    ksession.getWorkItemManager().registerWorkItem("name", implementation);

     

    Cheers

  • 2. Re: Adding new  workitems programmatically, without repacking the application ?
    Arun V G Newbie

    Thanks for the very quick reply.

     

    Hope you are pointing to the registerWorkItemHandler(String workItemName, WorkItemHandler handler); I am using this to register the handler.

     

    Does it mean that the workdefinitions like below  has  no meaning in the core engine part and is used only by the editor.

     

    import org.drools.process.core.datatype.impl.type.StringDataType;

    [

      // the Notification work item

      [

        "name" : "Notification",

        "parameters" : [

          "Message" : new StringDataType(),

          "From" : new StringDataType(),

          "To" : new StringDataType(),

          "Priority" : new StringDataType(),

        ],

        "displayName" : "Notification",

        "icon" : "icons/notification.gif"

      ]

     

    ]

     

    Cheers

  • 3. Re: Adding new  workitems programmatically, without repacking the application ?
    Mauricio Salatino Master

    Exactly!

    You are right with the method name.. I didn't have the code infront of me.. but you find it

  • 4. Re: Adding new  workitems programmatically, without repacking the application ?
    Arun V G Newbie

    Thank you for the reply ..

     

    I could register the  workitemhandler and the confusion was about the work item definition.

     

    So Let me confirm what I understood about the work definition.

     

    A work definition  for example ,

     

    import org.drools.process.core.datatype.impl.type.StringDataType;

    [

      // the Notification work item

      [

        "name" : "Notification",

        "parameters" : [

          "Message" : new StringDataType(),

          "From" : new StringDataType(),

          "To" : new StringDataType(),

          "Priority" : new StringDataType(),

        ],

        "displayName" : "Notification",

        "icon" : "icons/notification.gif"

      ]

     

    ]

     

    Is just a template  used by the editor to show the properties of a domain specific task. Internally workdefintion is used to map the parameters, results to the BPMN format. As BPMN format  is used by the processing engine, It doesn't want a reference to the work definition .

     

    Am I right  ?

     

    Cheers

  • 5. Re: Adding new  workitems programmatically, without repacking the application ?
    Mauricio Salatino Master

    Once again yes.. you are right!

    If you take a look at my examples in my github account you will see that none of them defines those templates, because the engine doesn't care. Those definitions are right now only used by Eclipse and the Web Designer.

     

    Cheers

  • 7. Re: Adding new  workitems programmatically, without repacking the application ?
    Minh Hoang TO Novice

    import org.drools.process.core.datatype.impl.type.StringDataType;

    [

      // the Notification work item

      [

        "name" : "Notification",

        "parameters" : [

          "Message" : new StringDataType(),

          "From" : new StringDataType(),

          "To" : new StringDataType(),

          "Priority" : new StringDataType(),

        ],

        "displayName" : "Notification",

        "icon" : "icons/notification.gif"

      ]

    ]

     

    The engine has no interests on item definitions, but the info that you passed to item definitions is available in BPMN (generated by web-based/ide-based editors). As far as i see, the key used to register WorkItemHandler must identical to the value in "name" field. In other words, to link ServiceTask named "Notification" with a NotificationWorkItemHandler via programatical registration, we have to use the code

     

    WorkItemHandler notificationHandler = ....

    ksession.getWorkItemManager().registerWorkItemHandler("Notification", notificationHandler);