Search in sources :

Example 36 with FieldExtension

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);
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) FieldExtension(org.activiti.bpmn.model.FieldExtension) BoundaryEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundaryEventActivityBehavior) UserTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior) ScriptTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ScriptTaskActivityBehavior) ErrorEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior) InclusiveGatewayActivityBehavior(org.activiti.engine.impl.bpmn.behavior.InclusiveGatewayActivityBehavior) ServiceTaskDelegateExpressionActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ServiceTaskDelegateExpressionActivityBehavior) ServiceTaskExpressionActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ServiceTaskExpressionActivityBehavior) ReceiveTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ReceiveTaskActivityBehavior) ActivityBehavior(org.activiti.engine.impl.pvm.delegate.ActivityBehavior) CallActivityBehavior(org.activiti.engine.impl.bpmn.behavior.CallActivityBehavior) ExclusiveGatewayActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ExclusiveGatewayActivityBehavior) MailActivityBehavior(org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior) TransactionActivityBehavior(org.activiti.engine.impl.bpmn.behavior.TransactionActivityBehavior) NoneStartEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.NoneStartEventActivityBehavior) ShellActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ShellActivityBehavior) IntermediateThrowNoneEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateThrowNoneEventActivityBehavior) TerminateEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior) IntermediateThrowCompensationEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateThrowCompensationEventActivityBehavior) ManualTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ManualTaskActivityBehavior) IntermediateCatchEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateCatchEventActivityBehavior) EventBasedGatewayActivityBehavior(org.activiti.engine.impl.bpmn.behavior.EventBasedGatewayActivityBehavior) IntermediateThrowSignalEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateThrowSignalEventActivityBehavior) WebServiceActivityBehavior(org.activiti.engine.impl.bpmn.behavior.WebServiceActivityBehavior) NoneEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior) CancelEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.CancelEndEventActivityBehavior) CancelBoundaryEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.CancelBoundaryEventActivityBehavior) EventSubProcessStartEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.EventSubProcessStartEventActivityBehavior) AbstractBpmnActivityBehavior(org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior) BusinessRuleTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BusinessRuleTaskActivityBehavior) SubProcessActivityBehavior(org.activiti.engine.impl.bpmn.behavior.SubProcessActivityBehavior) TaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.TaskActivityBehavior) ParallelGatewayActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ParallelGatewayActivityBehavior) FieldDeclaration(org.activiti.engine.impl.bpmn.parser.FieldDeclaration)

Example 37 with FieldExtension

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);
            }
        }
    }
}
Also used : FieldExtension(org.activiti.bpmn.model.FieldExtension)

Example 38 with FieldExtension

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;
}
Also used : ServiceTask(org.activiti.bpmn.model.ServiceTask) FieldExtension(org.activiti.bpmn.model.FieldExtension)

Example 39 with FieldExtension

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;
}
Also used : FieldExtension(org.activiti.bpmn.model.FieldExtension) ActivitiListener(org.activiti.bpmn.model.ActivitiListener)

Example 40 with FieldExtension

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;
}
Also used : FormProperty(org.activiti.bpmn.model.FormProperty) FieldExtension(org.activiti.bpmn.model.FieldExtension) UserTask(org.activiti.bpmn.model.UserTask) ActivitiListener(org.activiti.bpmn.model.ActivitiListener)

Aggregations

FieldExtension (org.activiti.bpmn.model.FieldExtension)94 ArrayList (java.util.ArrayList)68 Test (org.junit.Test)67 Parameter (org.finra.herd.model.api.xml.Parameter)64 HashMap (java.util.HashMap)55 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)24 BusinessObjectDataAttribute (org.finra.herd.model.api.xml.BusinessObjectDataAttribute)12 Job (org.finra.herd.model.api.xml.Job)11 ServiceTask (org.activiti.bpmn.model.ServiceTask)10 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)10 BusinessObjectDataAttributeEntity (org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity)9 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)9 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)8 FieldDeclaration (org.activiti.engine.impl.bpmn.parser.FieldDeclaration)4 BusinessObjectDataStorageUnitKey (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 FlowElement (org.activiti.bpmn.model.FlowElement)3 Attribute (org.finra.herd.model.api.xml.Attribute)3 BusinessObjectDataAttributeKeys (org.finra.herd.model.api.xml.BusinessObjectDataAttributeKeys)3