@Override protected BaseElement convertXMLToElement(XMLStreamReader xtr) throws Exception { ServiceTask serviceTask = new ServiceTask(); BpmnXMLUtil.addXMLLocation(serviceTask, xtr); if (StringUtils.isNotEmpty( xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_CLASS))) { serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS); serviceTask.setImplementation( xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_CLASS)); } else if (StringUtils.isNotEmpty( xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_EXPRESSION))) { serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION); serviceTask.setImplementation( xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_EXPRESSION)); } else if (StringUtils.isNotEmpty( xtr.getAttributeValue( ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_DELEGATEEXPRESSION))) { serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION); serviceTask.setImplementation( xtr.getAttributeValue( ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_DELEGATEEXPRESSION)); } else if ("##WebService".equals(xtr.getAttributeValue(null, ATTRIBUTE_TASK_IMPLEMENTATION))) { serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE); serviceTask.setOperationRef( parseOperationRef(xtr.getAttributeValue(null, ATTRIBUTE_TASK_OPERATION_REF), model)); } serviceTask.setResultVariableName( xtr.getAttributeValue( ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_RESULTVARIABLE)); if (StringUtils.isEmpty(serviceTask.getResultVariableName())) { serviceTask.setResultVariableName( xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "resultVariable")); } if (StringUtils.isNotEmpty(serviceTask.getResultVariableName()) && (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(serviceTask.getImplementationType()) || ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals( serviceTask.getImplementationType()))) { model.addProblem( "'resultVariableName' not supported for service tasks using 'class' or 'delegateExpression", xtr); } serviceTask.setType(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TYPE)); serviceTask.setExtensionId( xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_EXTENSIONID)); parseChildElements(getXMLElementName(), serviceTask, xtr); return serviceTask; }
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(EDITOR_PROPERTIES_GENERAL_ITEMS); 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_VALUE, itemNode))) { field.setStringValue(getValueAsString(PROPERTY_SERVICETASK_FIELD_VALUE, 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; }