cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatic creation of a process and using activiti XSD entries

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

I'd like to programmatically setup my process flows, for a number of reasons the XML files don't work for what I'm trying to do.

I'd like to be able to set the attributes like activiti:expression in my process, however I don't see an appropriate setter in BPMN's ServiceTask to properly point to an UEL expression for my beans.  I'm planning to use CDI based services for most of the work.

Is there a subclass of ServiceTask ( org.activiti.bpmn.model.ServiceTask ) that allows me to populate the custom attributes?  Thanks in advanced!
3 REPLIES 3

johnament1
Champ in-the-making
Champ in-the-making
A little more info.

so, digging through your code I found these validation rules: https://github.com/Activiti/Activiti/blob/master/modules/activiti-process-validation/src/main/java/o...

Which is why I'm getting this: One of the attributes 'class', 'delegateExpression', 'type', 'operation', or 'expression' is mandatory on serviceTask.

In my case, I want to use an expression, but I don't want to use camel or mule; and shell and mail don't fit my purposes either.  When I look at the user guide, I see that this is what the XML would look like:

<java>
<serviceTask id='approveOrDissaprove' name='Store decision'
      activiti:expression="${loanRequest.setApproved(approvedByManager)}" />
</java>
Which doesn't have a type either.

johnament1
Champ in-the-making
Champ in-the-making
I decided to try verifying my problem.  I copied the validation logic in to my test class, just to see if it passes.

<java>
        ServiceTask foobar = new ServiceTask();
        foobar.setName("foobar");
        foobar.setId("foobar");
        foobar.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);

        if (!ImplementationType.IMPLEMENTATION_TYPE_CLASS.equalsIgnoreCase(foobar.getImplementationType())
                && !ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equalsIgnoreCase(foobar.getImplementationType())
                && !ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equalsIgnoreCase(foobar.getImplementationType())
                && !ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.equalsIgnoreCase(foobar.getImplementationType())
                && StringUtils.isEmpty(foobar.getType())) {
            System.out.println("Type was "+foobar.getType()+" and impl type was "+foobar.getImplementationType());
        }
        else {
            System.out.println("Not Type was "+foobar.getType()+" and impl type was "+foobar.getImplementationType());
        }
</java>

Turns out that I'm getting in to the "else" block of the code in my case, which doesn't match what is happening in the validator.  I'm on activiti 5.15.1.  Is it possible that there's a bug?

jbarrez
Star Contributor
Star Contributor
If you are working around the defaults of the engine, another route might be simply to disable that specific rule. The validator is pluggable and you can remove rules from the ValidatorSet on the ProcessEngineConfiguratiomImpl.