Search in sources :

Example 86 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.

the class ServiceTaskConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("servicetask", true);
    assertThat(flowElement).isNotNull();
    assertThat(flowElement).isInstanceOf(ServiceTask.class);
    assertThat(flowElement.getId()).isEqualTo("servicetask");
    ServiceTask serviceTask = (ServiceTask) flowElement;
    assertThat(serviceTask.getId()).isEqualTo("servicetask");
    assertThat(serviceTask.getName()).isEqualTo("Service task");
    List<FieldExtension> fields = serviceTask.getFieldExtensions();
    assertThat(fields).hasSize(2);
    FieldExtension field = (FieldExtension) fields.get(0);
    assertThat(field.getFieldName()).isEqualTo("testField");
    assertThat(field.getStringValue()).isEqualTo("test");
    field = (FieldExtension) fields.get(1);
    assertThat(field.getFieldName()).isEqualTo("testField2");
    assertThat(field.getExpression()).isEqualTo("${test}");
    List<ActivitiListener> listeners = serviceTask.getExecutionListeners();
    assertThat(listeners).hasSize(3);
    ActivitiListener listener = (ActivitiListener) listeners.get(0);
    assertThat(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType())).isTrue();
    assertThat(listener.getImplementation()).isEqualTo("org.test.TestClass");
    assertThat(listener.getEvent()).isEqualTo("start");
    listener = (ActivitiListener) listeners.get(1);
    assertThat(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(listener.getImplementationType())).isTrue();
    assertThat(listener.getImplementation()).isEqualTo("${testExpression}");
    assertThat(listener.getEvent()).isEqualTo("end");
    listener = (ActivitiListener) listeners.get(2);
    assertThat(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(listener.getImplementationType())).isTrue();
    assertThat(listener.getImplementation()).isEqualTo("${delegateExpression}");
    assertThat(listener.getEvent()).isEqualTo("start");
}
Also used : ServiceTask(org.activiti.bpmn.model.ServiceTask) FlowElement(org.activiti.bpmn.model.FlowElement) FieldExtension(org.activiti.bpmn.model.FieldExtension) ActivitiListener(org.activiti.bpmn.model.ActivitiListener)

Example 87 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.

the class ServiceTaskJsonConverter method convertJsonToElement.

protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) {
    ServiceTask task = new ServiceTask();
    if (StringUtils.isNotEmpty(getPropertyValueAsString(PROPERTY_SERVICETASK_CLASS, elementNode))) {
        task.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
        task.setImplementation(getPropertyValueAsString(PROPERTY_SERVICETASK_CLASS, elementNode));
    } else if (StringUtils.isNotEmpty(getPropertyValueAsString(PROPERTY_SERVICETASK_EXPRESSION, elementNode))) {
        task.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
        task.setImplementation(getPropertyValueAsString(PROPERTY_SERVICETASK_EXPRESSION, elementNode));
    } else if (StringUtils.isNotEmpty(getPropertyValueAsString(PROPERTY_SERVICETASK_DELEGATE_EXPRESSION, elementNode))) {
        task.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
        task.setImplementation(getPropertyValueAsString(PROPERTY_SERVICETASK_DELEGATE_EXPRESSION, elementNode));
    }
    if (StringUtils.isNotEmpty(getPropertyValueAsString(PROPERTY_SERVICETASK_RESULT_VARIABLE, elementNode))) {
        task.setResultVariableName(getPropertyValueAsString(PROPERTY_SERVICETASK_RESULT_VARIABLE, elementNode));
    }
    JsonNode fieldsNode = getProperty(PROPERTY_SERVICETASK_FIELDS, elementNode);
    if (fieldsNode != null) {
        JsonNode itemsArrayNode = fieldsNode.get("fields");
        if (itemsArrayNode != null) {
            for (JsonNode itemNode : itemsArrayNode) {
                JsonNode nameNode = itemNode.get(PROPERTY_SERVICETASK_FIELD_NAME);
                if (nameNode != null && StringUtils.isNotEmpty(nameNode.asText())) {
                    FieldExtension field = new FieldExtension();
                    field.setFieldName(nameNode.asText());
                    if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_SERVICETASK_FIELD_STRING_VALUE, itemNode))) {
                        field.setStringValue(getValueAsString(PROPERTY_SERVICETASK_FIELD_STRING_VALUE, itemNode));
                    } else if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_SERVICETASK_FIELD_STRING, itemNode))) {
                        field.setStringValue(getValueAsString(PROPERTY_SERVICETASK_FIELD_STRING, itemNode));
                    } else if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_SERVICETASK_FIELD_EXPRESSION, itemNode))) {
                        field.setExpression(getValueAsString(PROPERTY_SERVICETASK_FIELD_EXPRESSION, itemNode));
                    }
                    task.getFieldExtensions().add(field);
                }
            }
        }
    }
    return task;
}
Also used : ServiceTask(org.activiti.bpmn.model.ServiceTask) FieldExtension(org.activiti.bpmn.model.FieldExtension) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 88 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.

the class ServiceTaskJsonConverter method convertElementToJson.

protected void convertElementToJson(ObjectNode propertiesNode, BaseElement baseElement) {
    ServiceTask serviceTask = (ServiceTask) baseElement;
    if ("mail".equalsIgnoreCase(serviceTask.getType())) {
        setPropertyFieldValue(PROPERTY_MAILTASK_TO, serviceTask, propertiesNode);
        setPropertyFieldValue(PROPERTY_MAILTASK_FROM, serviceTask, propertiesNode);
        setPropertyFieldValue(PROPERTY_MAILTASK_SUBJECT, serviceTask, propertiesNode);
        setPropertyFieldValue(PROPERTY_MAILTASK_CC, serviceTask, propertiesNode);
        setPropertyFieldValue(PROPERTY_MAILTASK_BCC, serviceTask, propertiesNode);
        setPropertyFieldValue(PROPERTY_MAILTASK_TEXT, serviceTask, propertiesNode);
        setPropertyFieldValue(PROPERTY_MAILTASK_HTML, serviceTask, propertiesNode);
        setPropertyFieldValue(PROPERTY_MAILTASK_CHARSET, serviceTask, propertiesNode);
    } else if ("camel".equalsIgnoreCase(serviceTask.getType())) {
        setPropertyFieldValue(PROPERTY_CAMELTASK_CAMELCONTEXT, "camelContext", serviceTask, propertiesNode);
    } else if ("mule".equalsIgnoreCase(serviceTask.getType())) {
        setPropertyFieldValue(PROPERTY_MULETASK_ENDPOINT_URL, "endpointUrl", serviceTask, propertiesNode);
        setPropertyFieldValue(PROPERTY_MULETASK_LANGUAGE, "language", serviceTask, propertiesNode);
        setPropertyFieldValue(PROPERTY_MULETASK_PAYLOAD_EXPRESSION, "payloadExpression", serviceTask, propertiesNode);
        setPropertyFieldValue(PROPERTY_MULETASK_RESULT_VARIABLE, "resultVariable", serviceTask, propertiesNode);
    } else if ("dmn".equalsIgnoreCase(serviceTask.getType())) {
        for (FieldExtension fieldExtension : serviceTask.getFieldExtensions()) {
            if (PROPERTY_DECISIONTABLE_REFERENCE_KEY.equals(fieldExtension.getFieldName()) && decisionTableKeyMap != null && decisionTableKeyMap.containsKey(fieldExtension.getStringValue())) {
                ObjectNode decisionReferenceNode = objectMapper.createObjectNode();
                propertiesNode.set(PROPERTY_DECISIONTABLE_REFERENCE, decisionReferenceNode);
                ModelInfo modelInfo = decisionTableKeyMap.get(fieldExtension.getStringValue());
                decisionReferenceNode.put("id", modelInfo.getId());
                decisionReferenceNode.put("name", modelInfo.getName());
                decisionReferenceNode.put("key", modelInfo.getKey());
            }
        }
    } else {
        if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(serviceTask.getImplementationType())) {
            propertiesNode.put(PROPERTY_SERVICETASK_CLASS, serviceTask.getImplementation());
        } else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(serviceTask.getImplementationType())) {
            propertiesNode.put(PROPERTY_SERVICETASK_EXPRESSION, serviceTask.getImplementation());
        } else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(serviceTask.getImplementationType())) {
            propertiesNode.put(PROPERTY_SERVICETASK_DELEGATE_EXPRESSION, serviceTask.getImplementation());
        }
        if (StringUtils.isNotEmpty(serviceTask.getResultVariableName())) {
            propertiesNode.put(PROPERTY_SERVICETASK_RESULT_VARIABLE, serviceTask.getResultVariableName());
        }
        addFieldExtensions(serviceTask.getFieldExtensions(), propertiesNode);
    }
}
Also used : ServiceTask(org.activiti.bpmn.model.ServiceTask) ModelInfo(org.activiti.editor.language.json.model.ModelInfo) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) FieldExtension(org.activiti.bpmn.model.FieldExtension)

Example 89 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.

the class ExternalInvocationTaskValidator method validateFieldDeclarationsForShell.

protected void validateFieldDeclarationsForShell(org.activiti.bpmn.model.Process process, TaskWithFieldExtensions task, List<FieldExtension> fieldExtensions, List<ValidationError> errors) {
    boolean shellCommandDefined = false;
    for (FieldExtension fieldExtension : fieldExtensions) {
        String fieldName = fieldExtension.getFieldName();
        String fieldValue = fieldExtension.getStringValue();
        if (fieldName.equals("command")) {
            shellCommandDefined = true;
        }
        if ((fieldName.equals("wait") || fieldName.equals("redirectError") || fieldName.equals("cleanEnv")) && !fieldValue.toLowerCase().equals("true") && !fieldValue.toLowerCase().equals("false")) {
            addError(errors, Problems.SHELL_TASK_INVALID_PARAM, process, task, "Undefined parameter value for shell field");
        }
    }
    if (!shellCommandDefined) {
        addError(errors, Problems.SHELL_TASK_NO_COMMAND, process, task, "No shell command is defined on the shell activity");
    }
}
Also used : FieldExtension(org.activiti.bpmn.model.FieldExtension)

Example 90 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.

the class ExternalInvocationTaskValidator method validateFieldDeclarationsForDmn.

protected void validateFieldDeclarationsForDmn(org.activiti.bpmn.model.Process process, TaskWithFieldExtensions task, List<FieldExtension> fieldExtensions, List<ValidationError> errors) {
    boolean keyDefined = false;
    for (FieldExtension fieldExtension : fieldExtensions) {
        String fieldName = fieldExtension.getFieldName();
        String fieldValue = fieldExtension.getStringValue();
        if (fieldName.equals("decisionTableReferenceKey") && fieldValue != null && fieldValue.length() > 0) {
            keyDefined = true;
        }
    }
    if (!keyDefined) {
        addError(errors, Problems.DMN_TASK_NO_KEY, process, task, "No decision table reference key is defined on the dmn activity");
    }
}
Also used : FieldExtension(org.activiti.bpmn.model.FieldExtension)

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