use of org.camunda.bpm.model.cmmn.instance.camunda.CamundaField in project camunda-bpm-platform by camunda.
the class ItemHandler method initializeFieldDeclarations.
protected List<FieldDeclaration> initializeFieldDeclarations(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, Collection<CamundaField> fields) {
List<FieldDeclaration> fieldDeclarations = new ArrayList<FieldDeclaration>();
for (CamundaField field : fields) {
FieldDeclaration fieldDeclaration = initializeFieldDeclaration(element, activity, context, field);
fieldDeclarations.add(fieldDeclaration);
}
return fieldDeclarations;
}
use of org.camunda.bpm.model.cmmn.instance.camunda.CamundaField in project camunda-bpm-platform by camunda.
the class HumanTaskItemHandler method initializeTaskListener.
protected TaskListener initializeTaskListener(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, CamundaTaskListener listener) {
Collection<CamundaField> fields = listener.getCamundaFields();
List<FieldDeclaration> fieldDeclarations = initializeFieldDeclarations(element, activity, context, fields);
ExpressionManager expressionManager = context.getExpressionManager();
TaskListener taskListener = null;
String className = listener.getCamundaClass();
String expression = listener.getCamundaExpression();
String delegateExpression = listener.getCamundaDelegateExpression();
CamundaScript scriptElement = listener.getCamundaScript();
if (className != null) {
taskListener = new ClassDelegateTaskListener(className, fieldDeclarations);
} else if (expression != null) {
Expression expressionExp = expressionManager.createExpression(expression);
taskListener = new ExpressionTaskListener(expressionExp);
} else if (delegateExpression != null) {
Expression delegateExp = expressionManager.createExpression(delegateExpression);
taskListener = new DelegateExpressionTaskListener(delegateExp, fieldDeclarations);
} else if (scriptElement != null) {
ExecutableScript executableScript = initializeScript(element, activity, context, scriptElement);
if (executableScript != null) {
taskListener = new ScriptTaskListener(executableScript);
}
}
return taskListener;
}
use of org.camunda.bpm.model.cmmn.instance.camunda.CamundaField in project camunda-bpm-platform by camunda.
the class CaseVariableListenerHandlerTest method testClassDelegateHandling.
@Test
public void testClassDelegateHandling() {
ExtensionElements extensionElements = SpecUtil.createElement(modelInstance, caseTask, null, ExtensionElements.class);
CamundaVariableListener variableListener = SpecUtil.createElement(modelInstance, extensionElements, null, CamundaVariableListener.class);
CamundaField field = SpecUtil.createElement(modelInstance, variableListener, null, CamundaField.class);
field.setCamundaName("fieldName");
field.setCamundaStringValue("a string value");
variableListener.setCamundaClass("a.class.Name");
// when
CmmnActivity activity = handler.handleElement(planItem, context);
List<VariableListener<?>> listeners = activity.getVariableListenersLocal(CaseVariableListener.CREATE);
Assert.assertEquals(1, listeners.size());
ClassDelegateCaseVariableListener listener = (ClassDelegateCaseVariableListener) listeners.get(0);
Assert.assertEquals("a.class.Name", listener.getClassName());
Assert.assertEquals(1, listener.getFieldDeclarations().size());
Assert.assertEquals("fieldName", listener.getFieldDeclarations().get(0).getName());
Object fieldValue = listener.getFieldDeclarations().get(0).getValue();
assertTrue(fieldValue instanceof Expression);
Expression expressionValue = (Expression) fieldValue;
assertEquals("a string value", expressionValue.getExpressionText());
Assert.assertEquals(listener, activity.getVariableListenersLocal(CaseVariableListener.UPDATE).get(0));
Assert.assertEquals(listener, activity.getVariableListenersLocal(CaseVariableListener.DELETE).get(0));
}
use of org.camunda.bpm.model.cmmn.instance.camunda.CamundaField in project camunda-bpm-platform by camunda.
the class ItemHandler method initializeVariableListener.
protected CaseVariableListener initializeVariableListener(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, CamundaVariableListener listener) {
Collection<CamundaField> fields = listener.getCamundaFields();
List<FieldDeclaration> fieldDeclarations = initializeFieldDeclarations(element, activity, context, fields);
ExpressionManager expressionManager = context.getExpressionManager();
String className = listener.getCamundaClass();
String expression = listener.getCamundaExpression();
String delegateExpression = listener.getCamundaDelegateExpression();
CamundaScript scriptElement = listener.getCamundaScript();
CaseVariableListener variableListener = null;
if (className != null) {
variableListener = new ClassDelegateCaseVariableListener(className, fieldDeclarations);
} else if (expression != null) {
Expression expressionExp = expressionManager.createExpression(expression);
variableListener = new ExpressionCaseVariableListener(expressionExp);
} else if (delegateExpression != null) {
Expression delegateExp = expressionManager.createExpression(delegateExpression);
variableListener = new DelegateExpressionCaseVariableListener(delegateExp, fieldDeclarations);
} else if (scriptElement != null) {
ExecutableScript executableScript = initializeScript(element, activity, context, scriptElement);
if (executableScript != null) {
variableListener = new ScriptCaseVariableListener(executableScript);
}
}
return variableListener;
}
use of org.camunda.bpm.model.cmmn.instance.camunda.CamundaField in project camunda-bpm-platform by camunda.
the class ItemHandler method initializeCaseExecutionListener.
protected CaseExecutionListener initializeCaseExecutionListener(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, CamundaCaseExecutionListener listener) {
Collection<CamundaField> fields = listener.getCamundaFields();
List<FieldDeclaration> fieldDeclarations = initializeFieldDeclarations(element, activity, context, fields);
ExpressionManager expressionManager = context.getExpressionManager();
CaseExecutionListener caseExecutionListener = null;
String className = listener.getCamundaClass();
String expression = listener.getCamundaExpression();
String delegateExpression = listener.getCamundaDelegateExpression();
CamundaScript scriptElement = listener.getCamundaScript();
if (className != null) {
caseExecutionListener = new ClassDelegateCaseExecutionListener(className, fieldDeclarations);
} else if (expression != null) {
Expression expressionExp = expressionManager.createExpression(expression);
caseExecutionListener = new ExpressionCaseExecutionListener(expressionExp);
} else if (delegateExpression != null) {
Expression delegateExp = expressionManager.createExpression(delegateExpression);
caseExecutionListener = new DelegateExpressionCaseExecutionListener(delegateExp, fieldDeclarations);
} else if (scriptElement != null) {
ExecutableScript executableScript = initializeScript(element, activity, context, scriptElement);
if (executableScript != null) {
caseExecutionListener = new ScriptCaseExecutionListener(executableScript);
}
}
return caseExecutionListener;
}
Aggregations