protected void handleBPMNModelConstraints(BpmnModel bpmnModel, List<ValidationError> errors) { if (bpmnModel.getTargetNamespace() != null && bpmnModel.getTargetNamespace().length() > Constraints.BPMN_MODEL_TARGET_NAMESPACE_MAX_LENGTH) { addError(errors, Problems.BPMN_MODEL_TARGET_NAMESPACE_TOO_LONG, "The targetNamespace of the bpmn model must not contain more than " + Constraints.BPMN_MODEL_TARGET_NAMESPACE_MAX_LENGTH + " characters"); } }
public Message getMessage(String id) { Message result = messageMap.get(id); if (result == null) { int indexOfNS = id.indexOf(':'); if (indexOfNS > 0) { String idNamespace = id.substring(0, indexOfNS); if (idNamespace.equalsIgnoreCase(this.getTargetNamespace())) { id = id.substring(indexOfNS + 1); } result = messageMap.get(id); } } return result; }
public Message getMessage(String id) { Message result = messageMap.get(id); if (result == null) { int indexOfNS = id.indexOf(':'); if (indexOfNS > 0) { String idNamespace = id.substring(0, indexOfNS); if (idNamespace.equalsIgnoreCase(this.getTargetNamespace())) { id = id.substring(indexOfNS + 1); } result = messageMap.get(id); } } return result; }
protected String parseOperationRef(String operationRef, BpmnModel model) { String result = null; if (StringUtils.isNotEmpty(operationRef)) { int indexOfP = operationRef.indexOf(':'); if (indexOfP != -1) { String prefix = operationRef.substring(0, indexOfP); String resolvedNamespace = model.getNamespace(prefix); result = resolvedNamespace + ":" + operationRef.substring(indexOfP + 1); } else { result = model.getTargetNamespace() + ":" + operationRef; } } return result; }
protected String parseItemSubjectRef(String itemSubjectRef, BpmnModel model) { String result = null; if (StringUtils.isNotEmpty(itemSubjectRef)) { int indexOfP = itemSubjectRef.indexOf(':'); if (indexOfP != -1) { String prefix = itemSubjectRef.substring(0, indexOfP); String resolvedNamespace = model.getNamespace(prefix); result = resolvedNamespace + ":" + itemSubjectRef.substring(indexOfP + 1); } else { result = model.getTargetNamespace() + ":" + itemSubjectRef; } } return result; } }
protected String parseOperationRef(String operationRef, BpmnModel model) { String result = null; if (StringUtils.isNotEmpty(operationRef)) { int indexOfP = operationRef.indexOf(':'); if (indexOfP != -1) { String prefix = operationRef.substring(0, indexOfP); String resolvedNamespace = model.getNamespace(prefix); result = resolvedNamespace + ":" + operationRef.substring(indexOfP + 1); } else { result = model.getTargetNamespace() + ":" + operationRef; } } return result; } }
protected String parseMessageRef(String messageRef, BpmnModel model) { String result = null; if (StringUtils.isNotEmpty(messageRef)) { int indexOfP = messageRef.indexOf(':'); if (indexOfP != -1) { String prefix = messageRef.substring(0, indexOfP); String resolvedNamespace = model.getNamespace(prefix); messageRef = messageRef.substring(indexOfP + 1); if (resolvedNamespace == null) { // if it's an invalid prefix will consider this is not a // namespace prefix so will be used as part of the // stringReference messageRef = prefix + ":" + messageRef; } else if (!resolvedNamespace.equalsIgnoreCase(model.getTargetNamespace())) { // if it's a valid namespace prefix but it's not the // targetNamespace then we'll use it as a valid namespace // (even out editor does not support defining namespaces it // is still a valid xml file) messageRef = resolvedNamespace + ":" + messageRef; } } result = messageRef; } return result; } }
protected void writeMessageDefinition(Event parentEvent, MessageEventDefinition messageDefinition, BpmnModel model, XMLStreamWriter xtw) throws Exception { xtw.writeStartElement(ELEMENT_EVENT_MESSAGEDEFINITION); String messageRef = messageDefinition.getMessageRef(); if (StringUtils.isNotEmpty(messageRef)) { // remove the namespace from the message id if set if (messageRef.startsWith(model.getTargetNamespace())) { messageRef = messageRef.replace(model.getTargetNamespace(), ""); messageRef = messageRef.replaceFirst(":", ""); } else { for (String prefix : model.getNamespaces().keySet()) { String namespace = model.getNamespace(prefix); if (messageRef.startsWith(namespace)) { messageRef = messageRef.replace(model.getTargetNamespace(), ""); messageRef = prefix + messageRef; } } } } writeDefaultAttribute(ATTRIBUTE_MESSAGE_REF, messageRef, xtw); boolean didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(messageDefinition, false, xtw); if (didWriteExtensionStartElement) { xtw.writeEndElement(); } xtw.writeEndElement(); }
@SuppressWarnings("unchecked") public static void writeRootElement(BpmnModel model, XMLStreamWriter xtw, String encoding) throws Exception { xtw.writeStartDocument(encoding, "1.0"); // start definitions root element xtw.writeStartElement(ELEMENT_DEFINITIONS); xtw.setDefaultNamespace(BPMN2_NAMESPACE); xtw.writeDefaultNamespace(BPMN2_NAMESPACE); xtw.writeNamespace(XSI_PREFIX, XSI_NAMESPACE); xtw.writeNamespace(XSD_PREFIX, SCHEMA_NAMESPACE); xtw.writeNamespace(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE); xtw.writeNamespace(BPMNDI_PREFIX, BPMNDI_NAMESPACE); xtw.writeNamespace(OMGDC_PREFIX, OMGDC_NAMESPACE); xtw.writeNamespace(OMGDI_PREFIX, OMGDI_NAMESPACE); for (String prefix : model.getNamespaces().keySet()) { if (!defaultNamespaces.contains(prefix) && StringUtils.isNotEmpty(prefix)) xtw.writeNamespace(prefix, model.getNamespaces().get(prefix)); } xtw.writeAttribute(TYPE_LANGUAGE_ATTRIBUTE, SCHEMA_NAMESPACE); xtw.writeAttribute(EXPRESSION_LANGUAGE_ATTRIBUTE, XPATH_NAMESPACE); if (StringUtils.isNotEmpty(model.getTargetNamespace())) { xtw.writeAttribute(TARGET_NAMESPACE_ATTRIBUTE, model.getTargetNamespace()); } else { xtw.writeAttribute(TARGET_NAMESPACE_ATTRIBUTE, PROCESS_NAMESPACE); } BpmnXMLUtil.writeCustomAttributes(model.getDefinitionsAttributes().values(), xtw, model.getNamespaces(), defaultAttributes); } }
public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception { if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) { String itemDefinitionId = model.getTargetNamespace() + ":" + xtr.getAttributeValue(null, ATTRIBUTE_ID); String structureRef = xtr.getAttributeValue(null, ATTRIBUTE_STRUCTURE_REF); if (StringUtils.isNotEmpty(structureRef)) { ItemDefinition item = new ItemDefinition(); item.setId(itemDefinitionId); BpmnXMLUtil.addXMLLocation(item, xtr); int indexOfP = structureRef.indexOf(':'); if (indexOfP != -1) { String prefix = structureRef.substring(0, indexOfP); String resolvedNamespace = model.getNamespace(prefix); structureRef = resolvedNamespace + ":" + structureRef.substring(indexOfP + 1); } else { structureRef = model.getTargetNamespace() + ":" + structureRef; } item.setStructureRef(structureRef); item.setItemKind(xtr.getAttributeValue(null, ATTRIBUTE_ITEM_KIND)); BpmnXMLUtil.parseChildElements(ELEMENT_ITEM_DEFINITION, item, xtr, model); model.addItemDefinition(itemDefinitionId, item); } } } }
interfaceObject.setId(model.getTargetNamespace() + ":" + xtr.getAttributeValue(null, ATTRIBUTE_ID)); interfaceObject.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME)); interfaceObject.setImplementationRef(parseMessageRef(xtr.getAttributeValue(null, ATTRIBUTE_IMPLEMENTATION_REF), model)); operation = new Operation(); BpmnXMLUtil.addXMLLocation(operation, xtr); operation.setId(model.getTargetNamespace() + ":" + xtr.getAttributeValue(null, ATTRIBUTE_ID)); operation.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME)); operation.setImplementationRef(parseMessageRef(xtr.getAttributeValue(null, ATTRIBUTE_IMPLEMENTATION_REF), model));
String messageId = message.getId(); if (model.getTargetNamespace() != null && messageId.startsWith(model.getTargetNamespace())) { messageId = messageId.replace(model.getTargetNamespace(), ""); messageId = messageId.replaceFirst(":", ""); } else { String namespace = model.getNamespace(prefix); if (messageId.startsWith(namespace)) { messageId = messageId.replace(model.getTargetNamespace(), ""); messageId = prefix + messageId;
} else if (!resolvedNamespace.equalsIgnoreCase(model.getTargetNamespace())) {
propertiesNode.put(PROPERTY_IS_EXECUTABLE, "false"); if (StringUtils.isNoneEmpty(model.getTargetNamespace())) { propertiesNode.put(PROPERTY_PROCESS_NAMESPACE, model.getTargetNamespace());
protected ProcessDefinitionEntity transformProcess(BpmnParse bpmnParse, Process process) { ProcessDefinitionEntity currentProcessDefinition = CommandContextUtil.getProcessDefinitionEntityManager().create(); bpmnParse.setCurrentProcessDefinition(currentProcessDefinition); /* * Mapping object model - bpmn xml: processDefinition.id -> generated by activiti engine processDefinition.key -> bpmn id (required) processDefinition.name -> bpmn name (optional) */ currentProcessDefinition.setKey(process.getId()); currentProcessDefinition.setName(process.getName()); currentProcessDefinition.setCategory(bpmnParse.getBpmnModel().getTargetNamespace()); currentProcessDefinition.setDescription(process.getDocumentation()); currentProcessDefinition.setDeploymentId(bpmnParse.getDeployment().getId()); if (bpmnParse.getDeployment().getEngineVersion() != null) { currentProcessDefinition.setEngineVersion(bpmnParse.getDeployment().getEngineVersion()); } createEventListeners(bpmnParse, process.getEventListeners()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Parsing process {}", currentProcessDefinition.getKey()); } bpmnParse.processFlowElements(process.getFlowElements()); processArtifacts(bpmnParse, process.getArtifacts()); return currentProcessDefinition; }
currentProcessDefinition.setCategory(bpmnParse.getBpmnModel().getTargetNamespace()); currentProcessDefinition.setDescription(process.getDocumentation());