Search in sources :

Example 1 with BusinessRuleTaskActivityBehavior

use of org.activiti.engine.impl.bpmn.behavior.BusinessRuleTaskActivityBehavior in project Activiti by Activiti.

the class DefaultActivityBehaviorFactory method createBusinessRuleTaskActivityBehavior.

public ActivityBehavior createBusinessRuleTaskActivityBehavior(BusinessRuleTask businessRuleTask) {
    BusinessRuleTaskDelegate ruleActivity = null;
    if (StringUtils.isNotEmpty(businessRuleTask.getClassName())) {
        try {
            Class<?> clazz = Class.forName(businessRuleTask.getClassName());
            ruleActivity = (BusinessRuleTaskDelegate) clazz.newInstance();
        } catch (Exception e) {
            throw new ActivitiException("Could not instantiate businessRuleTask (id:" + businessRuleTask.getId() + ") class: " + businessRuleTask.getClassName(), e);
        }
    } else {
        ruleActivity = new BusinessRuleTaskActivityBehavior();
    }
    for (String ruleVariableInputObject : businessRuleTask.getInputVariables()) {
        ruleActivity.addRuleVariableInputIdExpression(expressionManager.createExpression(ruleVariableInputObject.trim()));
    }
    for (String rule : businessRuleTask.getRuleNames()) {
        ruleActivity.addRuleIdExpression(expressionManager.createExpression(rule.trim()));
    }
    ruleActivity.setExclude(businessRuleTask.isExclude());
    if (businessRuleTask.getResultVariableName() != null && businessRuleTask.getResultVariableName().length() > 0) {
        ruleActivity.setResultVariable(businessRuleTask.getResultVariableName());
    } else {
        ruleActivity.setResultVariable("org.activiti.engine.rules.OUTPUT");
    }
    return ruleActivity;
}
Also used : BusinessRuleTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BusinessRuleTaskActivityBehavior) ActivitiException(org.activiti.engine.ActivitiException) ActivitiException(org.activiti.engine.ActivitiException) BusinessRuleTaskDelegate(org.activiti.engine.delegate.BusinessRuleTaskDelegate)

Aggregations

ActivitiException (org.activiti.engine.ActivitiException)1 BusinessRuleTaskDelegate (org.activiti.engine.delegate.BusinessRuleTaskDelegate)1 BusinessRuleTaskActivityBehavior (org.activiti.engine.impl.bpmn.behavior.BusinessRuleTaskActivityBehavior)1