Search in sources :

Example 1 with IOParameter

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

the class CallActivityJsonConverter method addJsonParameters.

private void addJsonParameters(String propertyName, String valueName, List<IOParameter> parameterList, ObjectNode propertiesNode) {
    ObjectNode parametersNode = objectMapper.createObjectNode();
    ArrayNode itemsNode = objectMapper.createArrayNode();
    for (IOParameter parameter : parameterList) {
        ObjectNode parameterItemNode = objectMapper.createObjectNode();
        if (StringUtils.isNotEmpty(parameter.getSource())) {
            parameterItemNode.put(PROPERTY_IOPARAMETER_SOURCE, parameter.getSource());
        } else {
            parameterItemNode.putNull(PROPERTY_IOPARAMETER_SOURCE);
        }
        if (StringUtils.isNotEmpty(parameter.getTarget())) {
            parameterItemNode.put(PROPERTY_IOPARAMETER_TARGET, parameter.getTarget());
        } else {
            parameterItemNode.putNull(PROPERTY_IOPARAMETER_TARGET);
        }
        if (StringUtils.isNotEmpty(parameter.getSourceExpression())) {
            parameterItemNode.put(PROPERTY_IOPARAMETER_SOURCE_EXPRESSION, parameter.getSourceExpression());
        } else {
            parameterItemNode.putNull(PROPERTY_IOPARAMETER_SOURCE_EXPRESSION);
        }
        itemsNode.add(parameterItemNode);
    }
    parametersNode.put(valueName, itemsNode);
    propertiesNode.put(propertyName, parametersNode);
}
Also used : IOParameter(org.activiti.bpmn.model.IOParameter) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 2 with IOParameter

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

the class CallActivityConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("callactivity");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof CallActivity);
    CallActivity callActivity = (CallActivity) flowElement;
    assertEquals("callactivity", callActivity.getId());
    assertEquals("Call activity", callActivity.getName());
    assertEquals("processId", callActivity.getCalledElement());
    List<IOParameter> parameters = callActivity.getInParameters();
    assertEquals(2, parameters.size());
    IOParameter parameter = parameters.get(0);
    assertEquals("test", parameter.getSource());
    assertEquals("test", parameter.getTarget());
    parameter = parameters.get(1);
    assertEquals("${test}", parameter.getSourceExpression());
    assertEquals("test", parameter.getTarget());
    parameters = callActivity.getOutParameters();
    assertEquals(1, parameters.size());
    parameter = parameters.get(0);
    assertEquals("test", parameter.getSource());
    assertEquals("test", parameter.getTarget());
}
Also used : IOParameter(org.activiti.bpmn.model.IOParameter) FlowElement(org.activiti.bpmn.model.FlowElement) CallActivity(org.activiti.bpmn.model.CallActivity)

Example 3 with IOParameter

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

the class DefaultActivityBehaviorFactory method createCallActivityBehavior.

// Call activity
public CallActivityBehavior createCallActivityBehavior(CallActivity callActivity) {
    String expressionRegex = "\\$+\\{+.+\\}";
    CallActivityBehavior callActivityBehaviour = null;
    if (StringUtils.isNotEmpty(callActivity.getCalledElement()) && callActivity.getCalledElement().matches(expressionRegex)) {
        callActivityBehaviour = new CallActivityBehavior(expressionManager.createExpression(callActivity.getCalledElement()), callActivity.getMapExceptions());
    } else {
        callActivityBehaviour = new CallActivityBehavior(callActivity.getCalledElement(), callActivity.getMapExceptions());
    }
    callActivityBehaviour.setInheritVariables(callActivity.isInheritVariables());
    for (IOParameter ioParameter : callActivity.getInParameters()) {
        if (StringUtils.isNotEmpty(ioParameter.getSourceExpression())) {
            Expression expression = expressionManager.createExpression(ioParameter.getSourceExpression().trim());
            callActivityBehaviour.addDataInputAssociation(new SimpleDataInputAssociation(expression, ioParameter.getTarget()));
        } else {
            callActivityBehaviour.addDataInputAssociation(new SimpleDataInputAssociation(ioParameter.getSource(), ioParameter.getTarget()));
        }
    }
    for (IOParameter ioParameter : callActivity.getOutParameters()) {
        if (StringUtils.isNotEmpty(ioParameter.getSourceExpression())) {
            Expression expression = expressionManager.createExpression(ioParameter.getSourceExpression().trim());
            callActivityBehaviour.addDataOutputAssociation(new MessageImplicitDataOutputAssociation(ioParameter.getTarget(), expression));
        } else {
            callActivityBehaviour.addDataOutputAssociation(new MessageImplicitDataOutputAssociation(ioParameter.getTarget(), ioParameter.getSource()));
        }
    }
    return callActivityBehaviour;
}
Also used : MessageImplicitDataOutputAssociation(org.activiti.engine.impl.bpmn.webservice.MessageImplicitDataOutputAssociation) IOParameter(org.activiti.bpmn.model.IOParameter) Expression(org.activiti.engine.delegate.Expression) SimpleDataInputAssociation(org.activiti.engine.impl.bpmn.data.SimpleDataInputAssociation) CallActivityBehavior(org.activiti.engine.impl.bpmn.behavior.CallActivityBehavior)

Example 4 with IOParameter

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

the class CallActivityXMLConverter method writeIOParameters.

private boolean writeIOParameters(String elementName, List<IOParameter> parameterList, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception {
    if (parameterList.isEmpty())
        return didWriteExtensionStartElement;
    for (IOParameter ioParameter : parameterList) {
        if (didWriteExtensionStartElement == false) {
            xtw.writeStartElement(ELEMENT_EXTENSIONS);
            didWriteExtensionStartElement = true;
        }
        xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, elementName, ACTIVITI_EXTENSIONS_NAMESPACE);
        if (StringUtils.isNotEmpty(ioParameter.getSource())) {
            writeDefaultAttribute(ATTRIBUTE_IOPARAMETER_SOURCE, ioParameter.getSource(), xtw);
        }
        if (StringUtils.isNotEmpty(ioParameter.getSourceExpression())) {
            writeDefaultAttribute(ATTRIBUTE_IOPARAMETER_SOURCE_EXPRESSION, ioParameter.getSourceExpression(), xtw);
        }
        if (StringUtils.isNotEmpty(ioParameter.getTarget())) {
            writeDefaultAttribute(ATTRIBUTE_IOPARAMETER_TARGET, ioParameter.getTarget(), xtw);
        }
        xtw.writeEndElement();
    }
    return didWriteExtensionStartElement;
}
Also used : IOParameter(org.activiti.bpmn.model.IOParameter)

Example 5 with IOParameter

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

the class CallActivityJsonConverter method convertToIOParameters.

private List<IOParameter> convertToIOParameters(String propertyName, String valueName, JsonNode elementNode) {
    List<IOParameter> ioParameters = new ArrayList<IOParameter>();
    JsonNode parametersNode = getProperty(propertyName, elementNode);
    if (parametersNode != null) {
        parametersNode = BpmnJsonConverterUtil.validateIfNodeIsTextual(parametersNode);
        JsonNode itemsArrayNode = parametersNode.get(valueName);
        if (itemsArrayNode != null) {
            for (JsonNode itemNode : itemsArrayNode) {
                JsonNode sourceNode = itemNode.get(PROPERTY_IOPARAMETER_SOURCE);
                JsonNode sourceExpressionNode = itemNode.get(PROPERTY_IOPARAMETER_SOURCE_EXPRESSION);
                if ((sourceNode != null && StringUtils.isNotEmpty(sourceNode.asText())) || (sourceExpressionNode != null && StringUtils.isNotEmpty(sourceExpressionNode.asText()))) {
                    IOParameter parameter = new IOParameter();
                    if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_IOPARAMETER_SOURCE, itemNode))) {
                        parameter.setSource(getValueAsString(PROPERTY_IOPARAMETER_SOURCE, itemNode));
                    } else if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_IOPARAMETER_SOURCE_EXPRESSION, itemNode))) {
                        parameter.setSourceExpression(getValueAsString(PROPERTY_IOPARAMETER_SOURCE_EXPRESSION, itemNode));
                    }
                    if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_IOPARAMETER_TARGET, itemNode))) {
                        parameter.setTarget(getValueAsString(PROPERTY_IOPARAMETER_TARGET, itemNode));
                    }
                    ioParameters.add(parameter);
                }
            }
        }
    }
    return ioParameters;
}
Also used : IOParameter(org.activiti.bpmn.model.IOParameter) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Aggregations

IOParameter (org.activiti.bpmn.model.IOParameter)6 CallActivity (org.activiti.bpmn.model.CallActivity)2 FlowElement (org.activiti.bpmn.model.FlowElement)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ArrayList (java.util.ArrayList)1 Expression (org.activiti.engine.delegate.Expression)1 CallActivityBehavior (org.activiti.engine.impl.bpmn.behavior.CallActivityBehavior)1 SimpleDataInputAssociation (org.activiti.engine.impl.bpmn.data.SimpleDataInputAssociation)1 MessageImplicitDataOutputAssociation (org.activiti.engine.impl.bpmn.webservice.MessageImplicitDataOutputAssociation)1