cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti Modeler - custom components

racadent
Champ in-the-making
Champ in-the-making
Is it possible to have combobox with predifined variables in the Service Task component instead of Complex type (list of values) for Class field (Field extension) in the Activiti Modeler 5.11.

What I want to do is to create custom component with predefined java class that implements the service task logic and only one variable (class field) which has several predefined values and represent it as a combo box. The same logic as we have with Activiti designer extension (AbstractCustomServiceTask) in Eclipse:

@Property(type = PropertyType.COMBOBOX_CHOICE, displayName = "Account type", required = true)
@Help(displayHelpShort = "The type of account", displayHelpLong = "Choose a type of account from the list of options")
@PropertyItems({ ACCOUNT_TYPE_SAVINGS_LABEL, ACCOUNT_TYPE_SAVINGS_VALUE, ACCOUNT_TYPE_JUNIOR_LABEL, ACCOUNT_TYPE_JUNIOR_VALUE, ACCOUNT_TYPE_JOINT_LABEL,
  ACCOUNT_TYPE_JOINT_VALUE, ACCOUNT_TYPE_TRANSACTIONAL_LABEL, ACCOUNT_TYPE_TRANSACTIONAL_VALUE, ACCOUNT_TYPE_STUDENT_LABEL, ACCOUNT_TYPE_STUDENT_VALUE,
  ACCOUNT_TYPE_SENIOR_LABEL, ACCOUNT_TYPE_SENIOR_VALUE })
private String accountType;

Currently, json for service task fields looks like this:

{
      "id" : "servicetaskfields",
      "type" : "Complex",
      "title" : "Class fields",
      "value" : "",
      "description" : "Field extensions",
      "popular" : true,
      "complexItems" : [ {
        "id" : "servicetask_field_name",
        "name" : "Name",
        "type" : "String",
        "value" : "",
        "width" : 200,
        "optional" : false
      }, {
        "id" : "servicetask_field_value",
        "name" : "String value",
        "type" : "String",
        "value" : "",
        "width" : 200,
        "optional" : false
      }, {
        "id" : "servicetask_field_expression",
        "name" : "Expression",
        "type" : "String",
        "value" : "",
        "width" : 200,
        "optional" : false
      } ]
    }

and I want to replace:
"type" : "Complex"

with:
"type" : "Choice"

and to add predefined values for the related variable.
5 REPLIES 5

trademak
Star Contributor
Star Contributor
Sure, that's perfectly possible.

Best regards,

racadent
Champ in-the-making
Champ in-the-making
Sure, that's perfectly possible.

Do you have any example, demo that can be helpful, because I already try it on my way but without success?

trademak
Star Contributor
Star Contributor
No there's no example yet. The best way is to look at the other attribute definitions at the moment.

Best regards,

racadent
Champ in-the-making
Champ in-the-making
The problem is when I replace above json "Complex type" code with "Choice":

{
      "id" : "servicetaskfields",
      "type" : "Choice",
      "title" : "Class fields",
      "value" : "action",
      "description" : "Field extensions",
      "popular" : true,
      "items" : [ {
        "id" : "v1",
        "title" : "Value1",
        "value" : "0"
      }, {
        "id" : "v2",
        "title" : "Value2",
        "value" : "1",
      } ]
    }

I get regular combo box with values in the properties panel and after I select value and generate bpmn20.xml I get:

    <serviceTask id="sid-682459E4-9AE5-49A1-8EBB-CE0584676771" name="TestService" activiti:class="de.pickert.bpmn.services.ActionService"></serviceTask>
Instead of:

     <serviceTask id="sid-682459E4-9AE5-49A1-8EBB-CE0584676771" name="TestService" activiti:class="de.pickert.bpmn.services.ActionService">
      <extensionElements>
        <activiti:field name="action" stringValue="0"></activiti:field>
      </extensionElements>
    </serviceTask>


which I get with Complex type. Am I missing something?

trademak
Star Contributor
Star Contributor
That's because the transformation from the field extensions attribute expects a complex type and not a choice.
For this to work you would have to implement the right transformation logic in the activiti-json-converter project.

Best regards,