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);
}
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());
}
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;
}
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;
}
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;
}
Aggregations