@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; }
@Override public Object[] create(ICreateContext context) { ServiceTask newServiceTask = new ServiceTask(); newServiceTask.setName("Service Task"); newServiceTask.setExtensionId(customServiceTaskId); newServiceTask.setAsynchronous(true); // Process custom service tasks if (newServiceTask.isExtended()) { CustomServiceTask targetTask = findCustomServiceTask(newServiceTask); if (targetTask != null) { // What should happen if the class contain more than one annotations? switch (targetTask.getDelegateType()) { case JAVA_DELEGATE_CLASS: newServiceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS); newServiceTask.setImplementation(targetTask.getDelegateSpecification()); break; case EXPRESSION: newServiceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION); newServiceTask.setImplementation(targetTask.getDelegateSpecification()); break; case JAVA_DELEGATE_EXPRESSION: newServiceTask.setImplementationType( ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION); newServiceTask.setImplementation(targetTask.getDelegateSpecification()); break; } newServiceTask.setName(targetTask.getName()); } } addObjectToContainer(context, newServiceTask, newServiceTask.getName()); return new Object[] {newServiceTask}; }