Search in sources :

Example 1 with DataStoreReference

use of org.activiti.bpmn.model.DataStoreReference in project Activiti by Activiti.

the class DataStoreReferenceXMLConverter method convertXMLToElement.

@Override
protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
    DataStoreReference dataStoreRef = new DataStoreReference();
    BpmnXMLUtil.addXMLLocation(dataStoreRef, xtr);
    parseChildElements(getXMLElementName(), dataStoreRef, model, xtr);
    return dataStoreRef;
}
Also used : DataStoreReference(org.activiti.bpmn.model.DataStoreReference)

Example 2 with DataStoreReference

use of org.activiti.bpmn.model.DataStoreReference in project Activiti by Activiti.

the class DataStoreReferenceXMLConverter method writeAdditionalChildElements.

@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();
    }
}
Also used : DataStoreReference(org.activiti.bpmn.model.DataStoreReference)

Example 3 with DataStoreReference

use of org.activiti.bpmn.model.DataStoreReference in project Activiti by Activiti.

the class DataStoreConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    assertEquals(1, model.getDataStores().size());
    DataStore dataStore = model.getDataStore("DataStore_1");
    assertNotNull(dataStore);
    assertEquals("DataStore_1", dataStore.getId());
    assertEquals("test", dataStore.getDataState());
    assertEquals("Test Database", dataStore.getName());
    assertEquals("test", dataStore.getItemSubjectRef());
    FlowElement refElement = model.getFlowElement("DataStoreReference_1");
    assertNotNull(refElement);
    assertTrue(refElement instanceof DataStoreReference);
    assertEquals(1, model.getPools().size());
    Pool pool = model.getPools().get(0);
    assertEquals("pool1", pool.getId());
}
Also used : DataStoreReference(org.activiti.bpmn.model.DataStoreReference) FlowElement(org.activiti.bpmn.model.FlowElement) DataStore(org.activiti.bpmn.model.DataStore) Pool(org.activiti.bpmn.model.Pool)

Example 4 with DataStoreReference

use of org.activiti.bpmn.model.DataStoreReference in project Activiti by Activiti.

the class BaseBpmnJsonConverter method convertToJson.

public void convertToJson(BaseElement baseElement, ActivityProcessor processor, BpmnModel model, FlowElementsContainer container, ArrayNode shapesArrayNode, double subProcessX, double subProcessY) {
    this.model = model;
    this.processor = processor;
    this.subProcessX = subProcessX;
    this.subProcessY = subProcessY;
    this.shapesArrayNode = shapesArrayNode;
    GraphicInfo graphicInfo = model.getGraphicInfo(baseElement.getId());
    String stencilId = null;
    if (baseElement instanceof ServiceTask) {
        ServiceTask serviceTask = (ServiceTask) baseElement;
        if ("mail".equalsIgnoreCase(serviceTask.getType())) {
            stencilId = STENCIL_TASK_MAIL;
        } else if ("camel".equalsIgnoreCase(serviceTask.getType())) {
            stencilId = STENCIL_TASK_CAMEL;
        } else if ("mule".equalsIgnoreCase(serviceTask.getType())) {
            stencilId = STENCIL_TASK_MULE;
        } else {
            stencilId = getStencilId(baseElement);
        }
    } else {
        stencilId = getStencilId(baseElement);
    }
    flowElementNode = BpmnJsonConverterUtil.createChildShape(baseElement.getId(), stencilId, graphicInfo.getX() - subProcessX + graphicInfo.getWidth(), graphicInfo.getY() - subProcessY + graphicInfo.getHeight(), graphicInfo.getX() - subProcessX, graphicInfo.getY() - subProcessY);
    shapesArrayNode.add(flowElementNode);
    ObjectNode propertiesNode = objectMapper.createObjectNode();
    propertiesNode.put(PROPERTY_OVERRIDE_ID, baseElement.getId());
    if (baseElement instanceof FlowElement) {
        FlowElement flowElement = (FlowElement) baseElement;
        if (StringUtils.isNotEmpty(flowElement.getName())) {
            propertiesNode.put(PROPERTY_NAME, flowElement.getName());
        }
        if (StringUtils.isNotEmpty(flowElement.getDocumentation())) {
            propertiesNode.put(PROPERTY_DOCUMENTATION, flowElement.getDocumentation());
        }
    }
    convertElementToJson(propertiesNode, baseElement);
    flowElementNode.put(EDITOR_SHAPE_PROPERTIES, propertiesNode);
    ArrayNode outgoingArrayNode = objectMapper.createArrayNode();
    if (baseElement instanceof FlowNode) {
        FlowNode flowNode = (FlowNode) baseElement;
        for (SequenceFlow sequenceFlow : flowNode.getOutgoingFlows()) {
            outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(sequenceFlow.getId()));
        }
        for (MessageFlow messageFlow : model.getMessageFlows().values()) {
            if (messageFlow.getSourceRef().equals(flowNode.getId())) {
                outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(messageFlow.getId()));
            }
        }
    }
    if (baseElement instanceof Activity) {
        Activity activity = (Activity) baseElement;
        for (BoundaryEvent boundaryEvent : activity.getBoundaryEvents()) {
            outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(boundaryEvent.getId()));
        }
        propertiesNode.put(PROPERTY_ASYNCHRONOUS, activity.isAsynchronous());
        propertiesNode.put(PROPERTY_EXCLUSIVE, !activity.isNotExclusive());
        if (activity.getLoopCharacteristics() != null) {
            MultiInstanceLoopCharacteristics loopDef = activity.getLoopCharacteristics();
            if (StringUtils.isNotEmpty(loopDef.getLoopCardinality()) || StringUtils.isNotEmpty(loopDef.getInputDataItem()) || StringUtils.isNotEmpty(loopDef.getCompletionCondition())) {
                if (loopDef.isSequential() == false) {
                    propertiesNode.put(PROPERTY_MULTIINSTANCE_TYPE, "Parallel");
                } else {
                    propertiesNode.put(PROPERTY_MULTIINSTANCE_TYPE, "Sequential");
                }
                if (StringUtils.isNotEmpty(loopDef.getLoopCardinality())) {
                    propertiesNode.put(PROPERTY_MULTIINSTANCE_CARDINALITY, loopDef.getLoopCardinality());
                }
                if (StringUtils.isNotEmpty(loopDef.getInputDataItem())) {
                    propertiesNode.put(PROPERTY_MULTIINSTANCE_COLLECTION, loopDef.getInputDataItem());
                }
                if (StringUtils.isNotEmpty(loopDef.getElementVariable())) {
                    propertiesNode.put(PROPERTY_MULTIINSTANCE_VARIABLE, loopDef.getElementVariable());
                }
                if (StringUtils.isNotEmpty(loopDef.getCompletionCondition())) {
                    propertiesNode.put(PROPERTY_MULTIINSTANCE_CONDITION, loopDef.getCompletionCondition());
                }
            }
        }
        if (activity instanceof UserTask) {
            BpmnJsonConverterUtil.convertListenersToJson(((UserTask) activity).getTaskListeners(), false, propertiesNode);
        }
        BpmnJsonConverterUtil.convertListenersToJson(activity.getExecutionListeners(), true, propertiesNode);
        if (CollectionUtils.isNotEmpty(activity.getDataInputAssociations())) {
            for (DataAssociation dataAssociation : activity.getDataInputAssociations()) {
                if (model.getFlowElement(dataAssociation.getSourceRef()) != null) {
                    createDataAssociation(dataAssociation, true, activity);
                }
            }
        }
        if (CollectionUtils.isNotEmpty(activity.getDataOutputAssociations())) {
            for (DataAssociation dataAssociation : activity.getDataOutputAssociations()) {
                if (model.getFlowElement(dataAssociation.getTargetRef()) != null) {
                    createDataAssociation(dataAssociation, false, activity);
                    outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(dataAssociation.getId()));
                }
            }
        }
    }
    for (Artifact artifact : container.getArtifacts()) {
        if (artifact instanceof Association) {
            Association association = (Association) artifact;
            if (StringUtils.isNotEmpty(association.getSourceRef()) && association.getSourceRef().equals(baseElement.getId())) {
                outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(association.getId()));
            }
        }
    }
    if (baseElement instanceof DataStoreReference) {
        for (Process process : model.getProcesses()) {
            processDataStoreReferences(process, baseElement.getId(), outgoingArrayNode);
        }
    }
    flowElementNode.put("outgoing", outgoingArrayNode);
}
Also used : ServiceTask(org.activiti.bpmn.model.ServiceTask) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) DataAssociation(org.activiti.bpmn.model.DataAssociation) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) GraphicInfo(org.activiti.bpmn.model.GraphicInfo) UserTask(org.activiti.bpmn.model.UserTask) Activity(org.activiti.bpmn.model.Activity) Process(org.activiti.bpmn.model.Process) SubProcess(org.activiti.bpmn.model.SubProcess) MessageFlow(org.activiti.bpmn.model.MessageFlow) Artifact(org.activiti.bpmn.model.Artifact) DataStoreReference(org.activiti.bpmn.model.DataStoreReference) DataAssociation(org.activiti.bpmn.model.DataAssociation) Association(org.activiti.bpmn.model.Association) MultiInstanceLoopCharacteristics(org.activiti.bpmn.model.MultiInstanceLoopCharacteristics) FlowElement(org.activiti.bpmn.model.FlowElement) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) FlowNode(org.activiti.bpmn.model.FlowNode)

Aggregations

DataStoreReference (org.activiti.bpmn.model.DataStoreReference)4 FlowElement (org.activiti.bpmn.model.FlowElement)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Activity (org.activiti.bpmn.model.Activity)1 Artifact (org.activiti.bpmn.model.Artifact)1 Association (org.activiti.bpmn.model.Association)1 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)1 DataAssociation (org.activiti.bpmn.model.DataAssociation)1 DataStore (org.activiti.bpmn.model.DataStore)1 FlowNode (org.activiti.bpmn.model.FlowNode)1 GraphicInfo (org.activiti.bpmn.model.GraphicInfo)1 MessageFlow (org.activiti.bpmn.model.MessageFlow)1 MultiInstanceLoopCharacteristics (org.activiti.bpmn.model.MultiInstanceLoopCharacteristics)1 Pool (org.activiti.bpmn.model.Pool)1 Process (org.activiti.bpmn.model.Process)1 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)1 ServiceTask (org.activiti.bpmn.model.ServiceTask)1 SubProcess (org.activiti.bpmn.model.SubProcess)1 UserTask (org.activiti.bpmn.model.UserTask)1