use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.
the class DefaultActivityBehaviorFactory method createCamelActivityBehavior.
protected ActivityBehavior createCamelActivityBehavior(TaskWithFieldExtensions task, List<FieldExtension> fieldExtensions, BpmnModel bpmnModel) {
try {
Class<?> theClass = null;
FieldExtension behaviorExtension = null;
for (FieldExtension fieldExtension : fieldExtensions) {
if ("camelBehaviorClass".equals(fieldExtension.getFieldName()) && StringUtils.isNotEmpty(fieldExtension.getStringValue())) {
theClass = Class.forName(fieldExtension.getStringValue());
behaviorExtension = fieldExtension;
break;
}
}
if (behaviorExtension != null) {
fieldExtensions.remove(behaviorExtension);
}
if (theClass == null) {
// Default Camel behavior class
theClass = Class.forName("org.activiti.camel.impl.CamelBehaviorDefaultImpl");
}
List<FieldDeclaration> fieldDeclarations = createFieldDeclarations(fieldExtensions);
addExceptionMapAsFieldDeclaraion(fieldDeclarations, task.getMapExceptions());
return (ActivityBehavior) ClassDelegate.defaultInstantiateDelegate(theClass, fieldDeclarations);
} catch (ClassNotFoundException e) {
throw new ActivitiException("Could not find org.activiti.camel.CamelBehavior: ", e);
}
}
use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.
the class InitializeAlfrescoModelsConversionListener method resolvePropertyRefrencesInServiceTask.
protected void resolvePropertyRefrencesInServiceTask(ServiceTask serviceTask, M2Namespace modelNamespace, List<PropertyReference> references) {
if (serviceTask.getFieldExtensions() != null && !serviceTask.getFieldExtensions().isEmpty()) {
for (FieldExtension extension : serviceTask.getFieldExtensions()) {
String value = extension.getExpression();
if (value != null && !value.isEmpty() && PropertyReference.containsPropertyReference(value)) {
value = PropertyReference.replaceAllPropertyReferencesInString(value, modelNamespace.getPrefix(), references, true);
extension.setExpression(value);
}
}
}
}
use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.
the class ScriptServiceTaskBuilder method build.
public ServiceTask build() {
if (serviceTask == null) {
FieldExtension scriptFieldElement = new FieldExtension();
scriptFieldElement.setFieldName(AlfrescoConversionConstants.SCRIPT_DELEGATE_SCRIPT_FIELD_NAME);
scriptFieldElement.setExpression(finalScript.toString());
serviceTask = new ServiceTask();
serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
serviceTask.setImplementation(AlfrescoConversionConstants.CLASSNAME_SCRIPT_DELEGATE);
serviceTask.getFieldExtensions().add(scriptFieldElement);
if (runAs != null) {
scriptFieldElement = new FieldExtension();
scriptFieldElement.setFieldName(AlfrescoConversionConstants.SCRIPT_DELEGATE_RUN_AS_FIELD_NAME);
scriptFieldElement.setExpression(runAs);
serviceTask.getFieldExtensions().add(scriptFieldElement);
}
}
return serviceTask;
}
use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.
the class ScriptTaskListenerBuilder method build.
public ActivitiListener build() {
if (listener == null) {
listener = new ActivitiListener();
listener.setEvent(event);
listener.setImplementationType(BpmnXMLConstants.ATTRIBUTE_LISTENER_CLASS);
listener.setImplementation(AlfrescoConversionConstants.CLASSNAME_SCRIPT_TASK_LISTENER);
FieldExtension scriptFieldElement = new FieldExtension();
scriptFieldElement.setFieldName(AlfrescoConversionConstants.SCRIPT_TASK_LISTENER_SCRIPT_FIELD_NAME);
scriptFieldElement.setStringValue(finalScript.toString());
listener.getFieldExtensions().add(scriptFieldElement);
}
return listener;
}
use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.
the class FeedbackStepDefinitionConverter method createSelectPeopleUserTask.
protected UserTask createSelectPeopleUserTask(FeedbackStepDefinition feedbackStepDefinition, WorkflowDefinitionConversion conversion, Map<String, BaseElement> processElements) {
UserTask selectPeopleUserTask = new UserTask();
selectPeopleUserTask.setId(conversion.getUniqueNumberedId(ConversionConstants.USER_TASK_ID_PREFIX));
selectPeopleUserTask.setName(getSelectPeopleTaskName());
selectPeopleUserTask.setAssignee(feedbackStepDefinition.getFeedbackInitiator());
addFlowElement(conversion, selectPeopleUserTask, true);
processElements.put(SELECT_PEOPLE_USER_TASK, selectPeopleUserTask);
// TODO: work out form such that it can be used in Activiti Explorer, ie. add correct form properties
// The following is just a a bit of a dummy form property
FormProperty feedbackProvidersProperty = new FormProperty();
feedbackProvidersProperty.setId(VARIABLE_FEEDBACK_PROVIDERS);
feedbackProvidersProperty.setName("Who needs to provide feedback?");
feedbackProvidersProperty.setRequired(true);
// TODO: we need some kind of 'people' property type here
feedbackProvidersProperty.setType("string");
selectPeopleUserTask.setFormProperties(Arrays.asList(feedbackProvidersProperty));
// that injects these variables into the process (instead of having it provided by the end user in a form)
if (feedbackStepDefinition.getFeedbackProviders() != null && !feedbackStepDefinition.getFeedbackProviders().isEmpty()) {
if (selectPeopleUserTask.getTaskListeners() == null) {
selectPeopleUserTask.setTaskListeners(new ArrayList<ActivitiListener>());
}
ActivitiListener taskListener = new ActivitiListener();
taskListener.setEvent("complete");
taskListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
taskListener.setImplementation("org.activiti.engine.impl.bpmn.listener.ScriptTaskListener");
FieldExtension languageField = new FieldExtension();
languageField.setFieldName("language");
languageField.setStringValue("JavaScript");
FieldExtension scriptField = new FieldExtension();
scriptField.setFieldName("script");
StringBuilder script = new StringBuilder();
if (JvmUtil.isJDK8()) {
script.append("load(\"nashorn:mozilla_compat.js\");");
}
script.append("importPackage (java.util); var feedbackProviders = new ArrayList();" + System.getProperty("line.separator"));
for (String feedbackProvider : feedbackStepDefinition.getFeedbackProviders()) {
script.append("feedbackProviders.add('" + feedbackProvider + "');" + System.getProperty("line.separator"));
}
script.append("task.getExecution().setVariable('" + VARIABLE_FEEDBACK_PROVIDERS + "', feedbackProviders);" + System.getProperty("line.separator"));
scriptField.setStringValue(script.toString());
taskListener.setFieldExtensions(Arrays.asList(languageField, scriptField));
selectPeopleUserTask.getTaskListeners().add(taskListener);
}
return selectPeopleUserTask;
}
Aggregations