Search in sources :

Example 1 with DataSpec

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

the class AbstractBpmnParseHandler method createIOSpecification.

protected IOSpecification createIOSpecification(BpmnParse bpmnParse, org.activiti.bpmn.model.IOSpecification specificationModel) {
    IOSpecification ioSpecification = new IOSpecification();
    for (DataSpec dataInputElement : specificationModel.getDataInputs()) {
        ItemDefinition itemDefinition = bpmnParse.getItemDefinitions().get(dataInputElement.getItemSubjectRef());
        Data dataInput = new Data(bpmnParse.getTargetNamespace() + ":" + dataInputElement.getId(), dataInputElement.getId(), itemDefinition);
        ioSpecification.addInput(dataInput);
    }
    for (DataSpec dataOutputElement : specificationModel.getDataOutputs()) {
        ItemDefinition itemDefinition = bpmnParse.getItemDefinitions().get(dataOutputElement.getItemSubjectRef());
        Data dataOutput = new Data(bpmnParse.getTargetNamespace() + ":" + dataOutputElement.getId(), dataOutputElement.getId(), itemDefinition);
        ioSpecification.addOutput(dataOutput);
    }
    for (String dataInputRef : specificationModel.getDataInputRefs()) {
        DataRef dataRef = new DataRef(dataInputRef);
        ioSpecification.addInputRef(dataRef);
    }
    for (String dataOutputRef : specificationModel.getDataOutputRefs()) {
        DataRef dataRef = new DataRef(dataOutputRef);
        ioSpecification.addOutputRef(dataRef);
    }
    return ioSpecification;
}
Also used : DataRef(org.activiti.engine.impl.bpmn.data.DataRef) IOSpecification(org.activiti.engine.impl.bpmn.data.IOSpecification) ItemDefinition(org.activiti.engine.impl.bpmn.data.ItemDefinition) DataSpec(org.activiti.bpmn.model.DataSpec) Data(org.activiti.engine.impl.bpmn.data.Data)

Example 2 with DataSpec

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

the class IOSpecificationParser method parseChildElement.

public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
    if (!(parentElement instanceof Activity) && !(parentElement instanceof Process))
        return;
    IOSpecification ioSpecification = new IOSpecification();
    BpmnXMLUtil.addXMLLocation(ioSpecification, xtr);
    boolean readyWithIOSpecification = false;
    try {
        while (!readyWithIOSpecification && xtr.hasNext()) {
            xtr.next();
            if (xtr.isStartElement() && ELEMENT_DATA_INPUT.equalsIgnoreCase(xtr.getLocalName())) {
                DataSpec dataSpec = new DataSpec();
                BpmnXMLUtil.addXMLLocation(dataSpec, xtr);
                dataSpec.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));
                dataSpec.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
                dataSpec.setItemSubjectRef(parseItemSubjectRef(xtr.getAttributeValue(null, ATTRIBUTE_ITEM_SUBJECT_REF), model));
                ioSpecification.getDataInputs().add(dataSpec);
            } else if (xtr.isStartElement() && ELEMENT_DATA_OUTPUT.equalsIgnoreCase(xtr.getLocalName())) {
                DataSpec dataSpec = new DataSpec();
                BpmnXMLUtil.addXMLLocation(dataSpec, xtr);
                dataSpec.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));
                dataSpec.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
                dataSpec.setItemSubjectRef(parseItemSubjectRef(xtr.getAttributeValue(null, ATTRIBUTE_ITEM_SUBJECT_REF), model));
                ioSpecification.getDataOutputs().add(dataSpec);
            } else if (xtr.isStartElement() && ELEMENT_DATA_INPUT_REFS.equalsIgnoreCase(xtr.getLocalName())) {
                String dataInputRefs = xtr.getElementText();
                if (StringUtils.isNotEmpty(dataInputRefs)) {
                    ioSpecification.getDataInputRefs().add(dataInputRefs.trim());
                }
            } else if (xtr.isStartElement() && ELEMENT_DATA_OUTPUT_REFS.equalsIgnoreCase(xtr.getLocalName())) {
                String dataOutputRefs = xtr.getElementText();
                if (StringUtils.isNotEmpty(dataOutputRefs)) {
                    ioSpecification.getDataOutputRefs().add(dataOutputRefs.trim());
                }
            } else if (xtr.isEndElement() && getElementName().equalsIgnoreCase(xtr.getLocalName())) {
                readyWithIOSpecification = true;
            }
        }
    } catch (Exception e) {
        LOGGER.warn("Error parsing ioSpecification child elements", e);
    }
    if (parentElement instanceof Process) {
        ((Process) parentElement).setIoSpecification(ioSpecification);
    } else {
        ((Activity) parentElement).setIoSpecification(ioSpecification);
    }
}
Also used : IOSpecification(org.activiti.bpmn.model.IOSpecification) Activity(org.activiti.bpmn.model.Activity) DataSpec(org.activiti.bpmn.model.DataSpec) Process(org.activiti.bpmn.model.Process)

Example 3 with DataSpec

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

the class WebServiceActivityBehavior method initializeIoSpecification.

protected void initializeIoSpecification(IOSpecification activityIoSpecification, DelegateExecution execution, BpmnModel bpmnModel) {
    for (DataSpec dataSpec : activityIoSpecification.getDataInputs()) {
        ItemDefinition itemDefinition = itemDefinitionMap.get(dataSpec.getItemSubjectRef());
        execution.setVariable(dataSpec.getId(), itemDefinition.createInstance());
    }
    for (DataSpec dataSpec : activityIoSpecification.getDataOutputs()) {
        ItemDefinition itemDefinition = itemDefinitionMap.get(dataSpec.getItemSubjectRef());
        execution.setVariable(dataSpec.getId(), itemDefinition.createInstance());
    }
}
Also used : ItemDefinition(org.activiti.engine.impl.bpmn.data.ItemDefinition) DataSpec(org.activiti.bpmn.model.DataSpec)

Aggregations

DataSpec (org.activiti.bpmn.model.DataSpec)3 ItemDefinition (org.activiti.engine.impl.bpmn.data.ItemDefinition)2 Activity (org.activiti.bpmn.model.Activity)1 IOSpecification (org.activiti.bpmn.model.IOSpecification)1 Process (org.activiti.bpmn.model.Process)1 Data (org.activiti.engine.impl.bpmn.data.Data)1 DataRef (org.activiti.engine.impl.bpmn.data.DataRef)1 IOSpecification (org.activiti.engine.impl.bpmn.data.IOSpecification)1