Java Code Examples for org.activiti.bpmn.model.BpmnModel#getNamespace()

The following examples show how to use org.activiti.bpmn.model.BpmnModel#getNamespace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemDefinitionParser.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
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);
    }
  }
}
 
Example 2
Source File: InterfaceParser.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: BaseBpmnXMLConverter.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 4
Source File: ServiceTaskXMLConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 5
Source File: MessageParser.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected String parseItemRef(String itemRef, BpmnModel model) {
  String result = null;
  if (StringUtils.isNotEmpty(itemRef)) {
    int indexOfP = itemRef.indexOf(':');
    if (indexOfP != -1) {
      String prefix = itemRef.substring(0, indexOfP);
      String resolvedNamespace = model.getNamespace(prefix);
      result = resolvedNamespace + ":" + itemRef.substring(indexOfP + 1);
    } else {
      result = itemRef;
    }
  }
  return result;
}
 
Example 6
Source File: SendTaskXMLConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 7
Source File: MessageEventDefinitionParser.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
  if (parentElement instanceof Event == false)
    return;

  MessageEventDefinition eventDefinition = new MessageEventDefinition();
  BpmnXMLUtil.addXMLLocation(eventDefinition, xtr);
  eventDefinition.setMessageRef(xtr.getAttributeValue(null, ATTRIBUTE_MESSAGE_REF));
  eventDefinition.setMessageExpression(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_MESSAGE_EXPRESSION));

  if (!StringUtils.isEmpty(eventDefinition.getMessageRef())) {

    int indexOfP = eventDefinition.getMessageRef().indexOf(':');
    if (indexOfP != -1) {
      String prefix = eventDefinition.getMessageRef().substring(0, indexOfP);
      String resolvedNamespace = model.getNamespace(prefix);
      String messageRef = eventDefinition.getMessageRef().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;
      }
      eventDefinition.setMessageRef(messageRef);
    } else {
      eventDefinition.setMessageRef(eventDefinition.getMessageRef());
    }
  }

  BpmnXMLUtil.parseChildElements(ELEMENT_EVENT_MESSAGEDEFINITION, eventDefinition, xtr, model);

  ((Event) parentElement).getEventDefinitions().add(eventDefinition);
}
 
Example 8
Source File: IOSpecificationParser.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
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;
}