org.activiti.bpmn.model.BaseElement Java Examples

The following examples show how to use org.activiti.bpmn.model.BaseElement. 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: CatchEventJsonConverter.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected String getStencilId(BaseElement baseElement) {
  IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) baseElement;
  List<EventDefinition> eventDefinitions = catchEvent.getEventDefinitions();
  if (eventDefinitions.size() != 1) {
    // return timer event as default;
    return STENCIL_EVENT_CATCH_TIMER;
  }

  EventDefinition eventDefinition = eventDefinitions.get(0);
  if (eventDefinition instanceof MessageEventDefinition) {
    return STENCIL_EVENT_CATCH_MESSAGE;
  } else if (eventDefinition instanceof SignalEventDefinition) {
    return STENCIL_EVENT_CATCH_SIGNAL;
  } else {
    return STENCIL_EVENT_CATCH_TIMER;
  }
}
 
Example #2
Source File: StartEventJsonConverter.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void convertElementToJson(ObjectNode propertiesNode, BaseElement baseElement) {
  StartEvent startEvent = (StartEvent) baseElement;
  if (StringUtils.isNotEmpty(startEvent.getInitiator())) {
    propertiesNode.put(PROPERTY_NONE_STARTEVENT_INITIATOR, startEvent.getInitiator());
  }

  if (StringUtils.isNotEmpty(startEvent.getFormKey())) {
    if (formKeyMap != null && formKeyMap.containsKey(startEvent.getFormKey())) {
      ObjectNode formRefNode = objectMapper.createObjectNode();
      ModelInfo modelInfo = formKeyMap.get(startEvent.getFormKey());
      formRefNode.put("id", modelInfo.getId());
      formRefNode.put("name", modelInfo.getName());
      formRefNode.put("key", modelInfo.getKey());
      propertiesNode.set(PROPERTY_FORM_REFERENCE, formRefNode);

    } else {
      setPropertyValue(PROPERTY_FORMKEY, startEvent.getFormKey(), propertiesNode);
    }
  }

  addFormProperties(startEvent.getFormProperties(), propertiesNode);
  addEventProperties(startEvent, propertiesNode);
}
 
Example #3
Source File: BpmnParseHandlers.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void parseElement(BpmnParse bpmnParse, BaseElement element) {

    if (element instanceof DataObject) {
      // ignore DataObject elements because they are processed on Process
      // and Sub process level
      return;
    }

    if (element instanceof FlowElement) {
      bpmnParse.setCurrentFlowElement((FlowElement) element);
    }

    // Execute parse handlers
    List<BpmnParseHandler> handlers = parseHandlers.get(element.getClass());

    if (handlers == null) {
      LOGGER.warn("Could not find matching parse handler for + " + element.getId() + " this is likely a bug.");
    } else {
      for (BpmnParseHandler handler : handlers) {
        handler.parse(bpmnParse, element);
      }
    }
  }
 
Example #4
Source File: SubProcessJsonConverter.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void convertElementToJson(ObjectNode propertiesNode, BaseElement baseElement) {
  SubProcess subProcess = (SubProcess) baseElement;

  propertiesNode.put("activitytype", "Sub-Process");
  propertiesNode.put("subprocesstype", "Embedded");
  ArrayNode subProcessShapesArrayNode = objectMapper.createArrayNode();
  GraphicInfo graphicInfo = model.getGraphicInfo(subProcess.getId());
  processor.processFlowElements(subProcess, model, subProcessShapesArrayNode, formKeyMap,
      decisionTableKeyMap, graphicInfo.getX(), graphicInfo.getY());
  flowElementNode.set("childShapes", subProcessShapesArrayNode);
  
  if (subProcess instanceof Transaction) {
    propertiesNode.put("istransaction", true);
  }
  
  BpmnJsonConverterUtil.convertDataPropertiesToJson(subProcess.getDataObjects(), propertiesNode);
}
 
Example #5
Source File: ValuedDataObjectWithExtensionsConverterTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected Map<String, String> getDataObjectAttributes(BaseElement dObj) {
  Map<String, String> attributes = null;

  if (null != dObj) {
    List<ExtensionElement> attributesExtension = dObj.getExtensionElements().get(ELEMENT_DATA_ATTRIBUTES);

    if (null != attributesExtension && !attributesExtension.isEmpty()) {
      attributes = new HashMap<String, String>();
      List<ExtensionElement> attributeExtensions = attributesExtension.get(0).getChildElements().get(ELEMENT_DATA_ATTRIBUTE);

      for (ExtensionElement attributeExtension : attributeExtensions) {
        attributes.put(attributeExtension.getAttributeValue(YOURCO_EXTENSIONS_NAMESPACE, ATTRIBUTE_NAME), attributeExtension.getAttributeValue(YOURCO_EXTENSIONS_NAMESPACE, ATTRIBUTE_VALUE));
      }
    }
  }
  return attributes;
}
 
Example #6
Source File: BpmnXMLUtil.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
/**
 * add all attributes from XML to element extensionAttributes (except blackListed).
 * 
 * @param xtr
 * @param element
 * @param blackList
 */
public static void addCustomAttributes(XMLStreamReader xtr, BaseElement element, List<ExtensionAttribute>... blackLists) {
  for (int i = 0; i < xtr.getAttributeCount(); i++) {
    ExtensionAttribute extensionAttribute = new ExtensionAttribute();
    extensionAttribute.setName(xtr.getAttributeLocalName(i));
    extensionAttribute.setValue(xtr.getAttributeValue(i));
    if (StringUtils.isNotEmpty(xtr.getAttributeNamespace(i))) {
      extensionAttribute.setNamespace(xtr.getAttributeNamespace(i));
    }
    if (StringUtils.isNotEmpty(xtr.getAttributePrefix(i))) {
      extensionAttribute.setNamespacePrefix(xtr.getAttributePrefix(i));
    }
    if (!isBlacklisted(extensionAttribute, blackLists)) {
      element.addAttribute(extensionAttribute);
    }
  }
}
 
Example #7
Source File: CallActivityXMLConverter.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
  String source = xtr.getAttributeValue(null, ATTRIBUTE_IOPARAMETER_SOURCE);
  String sourceExpression = xtr.getAttributeValue(null, ATTRIBUTE_IOPARAMETER_SOURCE_EXPRESSION);
  String target = xtr.getAttributeValue(null, ATTRIBUTE_IOPARAMETER_TARGET);
  if ((StringUtils.isNotEmpty(source) || StringUtils.isNotEmpty(sourceExpression)) && StringUtils.isNotEmpty(target)) {

    IOParameter parameter = new IOParameter();
    if (StringUtils.isNotEmpty(sourceExpression)) {
      parameter.setSourceExpression(sourceExpression);
    } else {
      parameter.setSource(source);
    }

    parameter.setTarget(target);

    ((CallActivity) parentElement).getOutParameters().add(parameter);
  }
}
 
Example #8
Source File: BpmnParseHandlers.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void parseElement(BpmnParse bpmnParse, BaseElement element) {
  
  if (element instanceof DataObject) {
    // ignore DataObject elements because they are processed on Process and Sub process level
    return;
  }
  
  if (element instanceof FlowElement) {
    bpmnParse.setCurrentFlowElement((FlowElement) element);
  }
  
  // Execute parse handlers
  List<BpmnParseHandler> handlers = parseHandlers.get(element.getClass());
  
  if (handlers == null) {
    LOGGER.warn("Could not find matching parse handler for + " + element.getId() + " this is likely a bug.");
  } else {
    for (BpmnParseHandler handler : handlers) {
      handler.parse(bpmnParse, element);
    }
  }
}
 
Example #9
Source File: DataStoreReferenceXMLConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void writeAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception {
  DataStoreReference dataStoreRef = (DataStoreReference) element;
  if (StringUtils.isNotEmpty(dataStoreRef.getDataState())) {
    xtw.writeStartElement(ELEMENT_DATA_STATE);
    xtw.writeCharacters(dataStoreRef.getDataState());
    xtw.writeEndElement();
  }
}
 
Example #10
Source File: ExecutionListenerValidator.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void validateListeners(Process process, BaseElement baseElement, List<ActivitiListener> listeners, List<ValidationError> errors) {
  if (listeners != null) {
    for (ActivitiListener listener : listeners) {
      if (listener.getImplementation() == null || listener.getImplementationType() == null) {
        addError(errors, Problems.EXECUTION_LISTENER_IMPLEMENTATION_MISSING, process, baseElement, "Element 'class' or 'expression' is mandatory on executionListener");
      }
      if (listener.getOnTransaction() != null && ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(listener.getImplementationType())) {
        addError(errors, Problems.EXECUTION_LISTENER_INVALID_IMPLEMENTATION_TYPE, process, baseElement, "Expression cannot be used when using 'onTransaction'");
      }
    }
  }
}
 
Example #11
Source File: InclusiveGatewayXMLConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
  InclusiveGateway gateway = new InclusiveGateway();
  BpmnXMLUtil.addXMLLocation(gateway, xtr);
  parseChildElements(getXMLElementName(), gateway, model, xtr);
  return gateway;
}
 
Example #12
Source File: BpmnXMLConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void processFlowElements(Collection<FlowElement> flowElementList, BaseElement parentScope) {
  for (FlowElement flowElement : flowElementList) {
    if (flowElement instanceof SequenceFlow) {
      SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
      FlowNode sourceNode = getFlowNodeFromScope(sequenceFlow.getSourceRef(), parentScope);
      if (sourceNode != null) {
        sourceNode.getOutgoingFlows().add(sequenceFlow);
        sequenceFlow.setSourceFlowElement(sourceNode);
      }
      
      FlowNode targetNode = getFlowNodeFromScope(sequenceFlow.getTargetRef(), parentScope);
      if (targetNode != null) {
        targetNode.getIncomingFlows().add(sequenceFlow);
        sequenceFlow.setTargetFlowElement(targetNode);
      }
      
    } else if (flowElement instanceof BoundaryEvent) {
      BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
      FlowElement attachedToElement = getFlowNodeFromScope(boundaryEvent.getAttachedToRefId(), parentScope);
      if (attachedToElement instanceof Activity) {
        Activity attachedActivity = (Activity) attachedToElement;
        boundaryEvent.setAttachedToRef(attachedActivity);
        attachedActivity.getBoundaryEvents().add(boundaryEvent);
      }
      
    } else if (flowElement instanceof SubProcess) {
      SubProcess subProcess = (SubProcess) flowElement;
      processFlowElements(subProcess.getFlowElements(), subProcess);
    }
  }
}
 
Example #13
Source File: ExtensionElementsParser.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void parse(XMLStreamReader xtr, List<SubProcess> activeSubProcessList, Process activeProcess, BpmnModel model) throws Exception {
  BaseElement parentElement = null;
  if (!activeSubProcessList.isEmpty()) {
    parentElement = activeSubProcessList.get(activeSubProcessList.size() - 1);

  } else {
    parentElement = activeProcess;
  }

  boolean readyWithChildElements = false;
  while (readyWithChildElements == false && xtr.hasNext()) {
    xtr.next();
    if (xtr.isStartElement()) {
      if (ELEMENT_EXECUTION_LISTENER.equals(xtr.getLocalName())) {
        new ExecutionListenerParser().parseChildElement(xtr, parentElement, model);
      } else if (ELEMENT_EVENT_LISTENER.equals(xtr.getLocalName())) {
        new ActivitiEventListenerParser().parseChildElement(xtr, parentElement, model);
      } else if (ELEMENT_POTENTIAL_STARTER.equals(xtr.getLocalName())) {
        new PotentialStarterParser().parse(xtr, activeProcess);
      } else {
        ExtensionElement extensionElement = BpmnXMLUtil.parseExtensionElement(xtr);
        parentElement.addExtensionElement(extensionElement);
      }

    } else if (xtr.isEndElement()) {
      if (ELEMENT_EXTENSIONS.equals(xtr.getLocalName())) {
        readyWithChildElements = true;
      }
    }
  }
}
 
Example #14
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 #15
Source File: ReceiveTaskXMLConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
  ReceiveTask receiveTask = new ReceiveTask();
  BpmnXMLUtil.addXMLLocation(receiveTask, xtr);
  parseChildElements(getXMLElementName(), receiveTask, model, xtr);
  return receiveTask;
}
 
Example #16
Source File: AssociationJsonConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected BaseElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) {
  Association association = new Association();

  String sourceRef = BpmnJsonConverterUtil.lookForSourceRef(elementNode.get(EDITOR_SHAPE_ID).asText(), modelNode.get(EDITOR_CHILD_SHAPES));

  if (sourceRef != null) {
    association.setSourceRef(sourceRef);
    String targetId = elementNode.get("target").get(EDITOR_SHAPE_ID).asText();
    association.setTargetRef(BpmnJsonConverterUtil.getElementId(shapeMap.get(targetId)));
  }

  return association;
}
 
Example #17
Source File: TextAnnotationJsonConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected BaseElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) {
  TextAnnotation annotation = new TextAnnotation();
  String text = getPropertyValueAsString("text", elementNode);
  if (StringUtils.isNotEmpty(text)) {
    annotation.setText(text);
  }
  return annotation;
}
 
Example #18
Source File: CallActivityXMLConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void writeAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception {
  CallActivity callActivity = (CallActivity) element;
  if (StringUtils.isNotEmpty(callActivity.getCalledElement())) {
    xtw.writeAttribute(ATTRIBUTE_CALL_ACTIVITY_CALLEDELEMENT, callActivity.getCalledElement());
  }
  if (StringUtils.isNotEmpty(callActivity.getBusinessKey())) {
    writeQualifiedAttribute(ATTRIBUTE_CALL_ACTIVITY_BUSINESS_KEY, callActivity.getBusinessKey(), xtw);
  }
  if (callActivity.isInheritBusinessKey()) {
    writeQualifiedAttribute(ATTRIBUTE_CALL_ACTIVITY_INHERIT_BUSINESS_KEY, "true", xtw);
  }
  xtw.writeAttribute(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_CALL_ACTIVITY_INHERITVARIABLES, String.valueOf(callActivity.isInheritVariables()));
}
 
Example #19
Source File: ManualTaskXMLConverter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public Class<? extends BaseElement> getBpmnElementType() {
  return ManualTask.class;
}
 
Example #20
Source File: UserTaskParseHandler.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public Class<? extends BaseElement> getHandledType() {
  return UserTask.class;
}
 
Example #21
Source File: EndEventXMLConverter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
protected void writeAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception {
  EndEvent endEvent = (EndEvent) element;
  writeEventDefinitions(endEvent, endEvent.getEventDefinitions(), model, xtw);
}
 
Example #22
Source File: MessageFlowJsonConverter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
protected void convertElementToJson(ObjectNode propertiesNode, BaseElement baseElement) {
  // nothing to do
}
 
Example #23
Source File: BpmnParseHandlers.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public BpmnParseHandlers() {
  this.parseHandlers = new HashMap<Class<? extends BaseElement>, List<BpmnParseHandler>>();
}
 
Example #24
Source File: SequenceFlowJsonConverter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public static void fillTypes(Map<String, Class<? extends BaseBpmnJsonConverter>> convertersToBpmnMap, Map<Class<? extends BaseElement>, Class<? extends BaseBpmnJsonConverter>> convertersToJsonMap) {

    fillJsonTypes(convertersToBpmnMap);
    fillBpmnTypes(convertersToJsonMap);
  }
 
Example #25
Source File: CallActivityParseHandler.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public Class<? extends BaseElement> getHandledType() {
  return CallActivity.class;
}
 
Example #26
Source File: SubProcessJsonConverter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public static void fillBpmnTypes(Map<Class<? extends BaseElement>, Class<? extends BaseBpmnJsonConverter>> convertersToJsonMap) {
  convertersToJsonMap.put(SubProcess.class, SubProcessJsonConverter.class);
  convertersToJsonMap.put(Transaction.class, SubProcessJsonConverter.class);
}
 
Example #27
Source File: ThrowEventJsonConverter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public static void fillTypes(Map<String, Class<? extends BaseBpmnJsonConverter>> convertersToBpmnMap, Map<Class<? extends BaseElement>, Class<? extends BaseBpmnJsonConverter>> convertersToJsonMap) {

    fillJsonTypes(convertersToBpmnMap);
    fillBpmnTypes(convertersToJsonMap);
  }
 
Example #28
Source File: EventGatewayJsonConverter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public static void fillBpmnTypes(Map<Class<? extends BaseElement>, Class<? extends BaseBpmnJsonConverter>> convertersToJsonMap) {
  convertersToJsonMap.put(EventGateway.class, EventGatewayJsonConverter.class);
}
 
Example #29
Source File: CatchEventJsonConverter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
protected void convertElementToJson(ObjectNode propertiesNode, BaseElement baseElement) {
  IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) baseElement;
  addEventProperties(catchEvent, propertiesNode);
}
 
Example #30
Source File: SignalEventDefinitionParseHandler.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public Class< ? extends BaseElement> getHandledType() {
  return SignalEventDefinition.class;
}