Search in sources :

Example 36 with DataOutput

use of org.eclipse.bpmn2.DataOutput in project kie-wb-common by kiegroup.

the class MultipleInstanceActivityPropertyWriter method setCollectionOutput.

public void setCollectionOutput(String collectionOutput) {
    if (isEmpty(collectionOutput)) {
        return;
    }
    setUpLoopCharacteristics();
    String suffix = "OUT_COLLECTION";
    String id = Ids.dataOutput(activity.getId(), suffix);
    DataOutput dataOutputElement = createDataOutput(id, suffix);
    addSafe(ioSpec.getDataOutputs(), dataOutputElement);
    Optional<Property> property = findPropertyById(collectionOutput);
    Optional<DataObject> dataObject = findDataObjectById(collectionOutput);
    if (property.isPresent()) {
        processDataOutput(dataOutputElement, property.get());
    } else if (dataObject.isPresent()) {
        processDataOutput(dataOutputElement, dataObject.get());
    }
}
Also used : DataOutput(org.eclipse.bpmn2.DataOutput) DataObject(org.eclipse.bpmn2.DataObject) Property(org.eclipse.bpmn2.Property)

Example 37 with DataOutput

use of org.eclipse.bpmn2.DataOutput in project kie-wb-common by kiegroup.

the class MultipleInstanceActivityPropertyWriter method processDataOutput.

private void processDataOutput(DataOutput dataOutputElement, ItemAwareElement prop) {
    dataOutputElement.setItemSubjectRef(prop.getItemSubjectRef());
    miloop.setLoopDataOutputRef(dataOutputElement);
    addSafe(outputSet.getDataOutputRefs(), dataOutputElement);
    DataOutputAssociation doa = Bpmn2Factory.eINSTANCE.createDataOutputAssociation();
    doa.getSourceRef().add(dataOutputElement);
    doa.setTargetRef(prop);
    addSafe(activity.getDataOutputAssociations(), doa);
}
Also used : DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation)

Example 38 with DataOutput

use of org.eclipse.bpmn2.DataOutput in project kie-wb-common by kiegroup.

the class MultipleInstanceActivityPropertyReader method getDataOutputIdForDataOutputVariable.

protected String getDataOutputIdForDataOutputVariable() {
    String dataOutputVariableId = null;
    DataOutput variableDataOutput = getMultiInstanceLoopCharacteristics().map(MultiInstanceLoopCharacteristics::getOutputDataItem).orElse(null);
    if (variableDataOutput != null) {
        String itemSubjectRef = getItemSubjectRef(variableDataOutput);
        String variableId = ItemNameReader.from(variableDataOutput).getName();
        dataOutputVariableId = super.getDataOutputs().stream().filter(output -> Objects.equals(variableId, output.getName())).filter(output -> hasItemSubjectRef(output, itemSubjectRef)).map(BaseElement::getId).findFirst().orElse(null);
    }
    return dataOutputVariableId;
}
Also used : BaseElement(org.eclipse.bpmn2.BaseElement) FormalExpression(org.eclipse.bpmn2.FormalExpression) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) BPMNDiagram(org.eclipse.bpmn2.di.BPMNDiagram) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) Activity(org.eclipse.bpmn2.Activity) DefinitionResolver(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) List(java.util.List) DataInput(org.eclipse.bpmn2.DataInput) MultiInstanceLoopCharacteristics(org.eclipse.bpmn2.MultiInstanceLoopCharacteristics) DataOutput(org.eclipse.bpmn2.DataOutput) Optional(java.util.Optional) DataAssociation(org.eclipse.bpmn2.DataAssociation) StringUtils(org.kie.workbench.common.stunner.core.util.StringUtils) DataOutput(org.eclipse.bpmn2.DataOutput)

Example 39 with DataOutput

use of org.eclipse.bpmn2.DataOutput in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshallerTest method testMarshallUserTaskAssignments.

@Test
public void testMarshallUserTaskAssignments() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_USERTASKASSIGNMENTS);
    // JBPMBpmn2ResourceImpl resource = tested.marshallToBpmn2Resource(diagram);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 7, 7);
    DefinitionsConverter definitionsConverter = new DefinitionsConverter(diagram.getGraph());
    Definitions definitions = definitionsConverter.toDefinitions();
    assertNotNull(definitions);
    Process process = getProcess(definitions);
    assertNotNull(process);
    org.eclipse.bpmn2.UserTask userTask = (org.eclipse.bpmn2.UserTask) getNamedFlowElement(process, org.eclipse.bpmn2.UserTask.class, "Self Evaluation");
    assertNotNull(userTask);
    DataInput dataInput = getDataInput(userTask, "reason");
    // this fails because of type
    validateDataInputOrOutput(dataInput, "_reasonInputX", "com.test.Reason", "_reasonInputXItem");
    DataOutput dataOutput = getDataOutput(userTask, "performance");
    validateDataInputOrOutput(dataOutput, "_performanceOutputX", "Object", "_performanceOutputXItem");
    ItemAwareElement sourceRef = getDataInputAssociationSourceRef(userTask, "reason");
    assertNotNull(sourceRef);
    ItemAwareElement targetRef = getDataInputAssociationTargetRef(userTask, "_reasonInputX");
    assertNotNull(targetRef);
    sourceRef = getDataOutputAssociationSourceRef(userTask, "_performanceOutputX");
    assertNotNull(sourceRef);
    targetRef = getDataOutputAssociationTargetRef(userTask, "performance");
    assertNotNull(targetRef);
}
Also used : DataOutput(org.eclipse.bpmn2.DataOutput) Definitions(org.eclipse.bpmn2.Definitions) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) Process(org.eclipse.bpmn2.Process) DefinitionsConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter) DataInput(org.eclipse.bpmn2.DataInput) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Test(org.junit.Test)

Example 40 with DataOutput

use of org.eclipse.bpmn2.DataOutput in project kie-wb-common by kiegroup.

the class ParsedAssignmentsInfoTest method testCreateInitializedOutputVariables.

@Test
public void testCreateInitializedOutputVariables() {
    final String DATA_OUTPUT_ID = "_Data-TestOutputX";
    final String DATA_OUTPUT_NAME = "Data Test";
    final String DATA_OUTPUT_ASSOCIATION_ID = "Data Test";
    final String DATA_OUTPUT_ASSOCIATION_VALUE = "BooleanTest";
    final String INIT_OUTPUT_VAR_ID = "Data-Test";
    final String INIT_OUTPUT_VAR_TYPE = "Boolean";
    VariableScope variableScope = new FlatVariableScope();
    variableScope.declare("", "BooleanTest", "Boolean");
    List<InitializedVariable.InitializedOutputVariable> initializedOutputVariables = tested.createInitializedOutputVariables("", variableScope, new HashSet<>());
    assertEquals(1, initializedOutputVariables.size());
    InitializedVariable.InitializedOutputVariable initializedOutputVariable = initializedOutputVariables.get(0);
    DataOutput dataOutput = initializedOutputVariable.getDataOutput();
    DataOutputAssociation dataOutputAssociation = initializedOutputVariable.getDataOutputAssociation();
    List<ItemAwareElement> sourceRef = dataOutputAssociation.getSourceRef();
    DataOutput source = (DataOutput) sourceRef.get(0);
    PropertyImpl target = (PropertyImpl) dataOutputAssociation.getTargetRef();
    String dataOutputID = dataOutput.getId();
    String dataOutputName = dataOutput.getName();
    String dataOutputAssociationID = source.getName();
    String dataOutputAssociationValue = target.getId();
    String initVarID = initializedOutputVariable.getIdentifier();
    String initVarType = initializedOutputVariable.getType();
    assertEquals(dataOutputID, DATA_OUTPUT_ID);
    assertEquals(dataOutputName, DATA_OUTPUT_NAME);
    assertEquals(dataOutputAssociationID, DATA_OUTPUT_ASSOCIATION_ID);
    assertEquals(dataOutputAssociationValue, DATA_OUTPUT_ASSOCIATION_VALUE);
    assertEquals(initVarID, INIT_OUTPUT_VAR_ID);
    assertEquals(initVarType, INIT_OUTPUT_VAR_TYPE);
}
Also used : DataOutput(org.eclipse.bpmn2.DataOutput) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) PropertyImpl(org.eclipse.bpmn2.impl.PropertyImpl) InitializedVariable(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) VariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.VariableScope) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) Test(org.junit.Test)

Aggregations

DataOutput (org.eclipse.bpmn2.DataOutput)39 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)24 DataInput (org.eclipse.bpmn2.DataInput)17 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)15 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)12 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)12 FormalExpression (org.eclipse.bpmn2.FormalExpression)9 List (java.util.List)7 InputOutputSpecification (org.eclipse.bpmn2.InputOutputSpecification)7 ItemDefinition (org.eclipse.bpmn2.ItemDefinition)7 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)7 OutputSet (org.eclipse.bpmn2.OutputSet)6 Assignment (org.eclipse.bpmn2.Assignment)5 InputSet (org.eclipse.bpmn2.InputSet)5 MultiInstanceLoopCharacteristics (org.eclipse.bpmn2.MultiInstanceLoopCharacteristics)5 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)5 FlowElement (org.eclipse.bpmn2.FlowElement)4 Process (org.eclipse.bpmn2.Process)4 RootElement (org.eclipse.bpmn2.RootElement)4