Search in sources :

Example 31 with DataOutput

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

the class OutputAssignmentReaderTest method mockDataOutputAssociation.

private static DataOutputAssociation mockDataOutputAssociation(String dataOutputName, ItemAwareElement targetRef) {
    DataOutputAssociation outputAssociation = mock(DataOutputAssociation.class);
    DataOutput dataOutput = mock(DataOutput.class);
    when(dataOutput.getName()).thenReturn(dataOutputName);
    List<ItemAwareElement> sourceRefs = Collections.singletonList(dataOutput);
    when(outputAssociation.getSourceRef()).thenReturn(sourceRefs);
    when(outputAssociation.getTargetRef()).thenReturn(targetRef);
    return outputAssociation;
}
Also used : DataOutput(org.eclipse.bpmn2.DataOutput) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation)

Example 32 with DataOutput

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

the class OutputAssignmentReaderTest method testFromAssociationWithExpression.

@Test
public void testFromAssociationWithExpression() {
    DataOutput output = spy(DataOutput.class);
    when(output.getName()).thenReturn(TARGET_NAME);
    Assignment assignment = spy(Assignment.class);
    FormalExpression to = mock(FormalExpression.class);
    when(assignment.getTo()).thenReturn(to);
    when(to.getBody()).thenReturn(SOURCE_NAME);
    List<Assignment> assignments = new ArrayList<Assignment>();
    assignments.add(assignment);
    DataOutputAssociationImpl out = spy(DataOutputAssociationImpl.class);
    when(out.getAssignment()).thenReturn(assignments);
    OutputAssignmentReader outputReader = OutputAssignmentReader.fromAssociation(out);
    assertNull(outputReader);
    List<ItemAwareElement> outputs = new ArrayList<>();
    outputs.add(output);
    when(out.getSourceRef()).thenReturn(outputs);
    outputReader = OutputAssignmentReader.fromAssociation(out);
    assertResult(TARGET_NAME, SOURCE_NAME, AssociationDeclaration.Type.FromTo, outputReader.getAssociationDeclaration());
    when(to.getBody()).thenReturn("null");
    outputReader = OutputAssignmentReader.fromAssociation(out);
    assertResult(TARGET_NAME, "", AssociationDeclaration.Type.FromTo, outputReader.getAssociationDeclaration());
}
Also used : Assignment(org.eclipse.bpmn2.Assignment) DataOutput(org.eclipse.bpmn2.DataOutput) DataOutputAssociationImpl(org.eclipse.bpmn2.impl.DataOutputAssociationImpl) ArrayList(java.util.ArrayList) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) FormalExpression(org.eclipse.bpmn2.FormalExpression) Test(org.junit.Test)

Example 33 with DataOutput

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

the class AssignmentsInfosTest method JBPM_7447_shouldNotFilterOutDataOutputsWithEmptyType.

@Test
public void JBPM_7447_shouldNotFilterOutDataOutputsWithEmptyType() {
    DataInput dataInput = bpmn2.createDataInput();
    dataInput.setName("InputName");
    dataInput.setId("InputID");
    DataOutput dataOutput = bpmn2.createDataOutput();
    dataOutput.setName("OutputName");
    dataOutput.setId("OutputID");
    ParsedAssignmentsInfo result = AssignmentsInfos.parsed(Collections.singletonList(dataInput), Collections.emptyList(), Collections.singletonList(dataOutput), Collections.emptyList(), false);
    assertThat(result.getOutputs().getDeclarations()).isNotEmpty();
}
Also used : DataInput(org.eclipse.bpmn2.DataInput) DataOutput(org.eclipse.bpmn2.DataOutput) ParsedAssignmentsInfo(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.ParsedAssignmentsInfo) Test(org.junit.Test)

Example 34 with DataOutput

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

the class ActivityPropertyWriter method setAssignmentsInfo.

public void setAssignmentsInfo(AssignmentsInfo info) {
    final ParsedAssignmentsInfo assignmentsInfo = ParsedAssignmentsInfo.of(info);
    final List<InitializedInputVariable> inputs = assignmentsInfo.createInitializedInputVariables(getId(), variableScope, dataObjects);
    if (!inputs.isEmpty()) {
        final InputOutputSpecification ioSpec = getIoSpecification();
        for (InitializedInputVariable input : inputs) {
            if (isReservedIdentifier(input.getIdentifier())) {
                continue;
            }
            DataInput dataInput = input.getDataInput();
            getInputSet(ioSpec).getDataInputRefs().add(dataInput);
            ioSpec.getDataInputs().add(dataInput);
            this.addItemDefinition(input.getItemDefinition());
            DataInputAssociation dataInputAssociation = input.getDataInputAssociation();
            if (dataInputAssociation != null) {
                activity.getDataInputAssociations().add(dataInputAssociation);
            }
        }
    }
    final List<InitializedOutputVariable> outputs = assignmentsInfo.createInitializedOutputVariables(getId(), variableScope, dataObjects);
    if (!outputs.isEmpty()) {
        final InputOutputSpecification ioSpec = getIoSpecification();
        for (InitializedOutputVariable output : outputs) {
            DataOutput dataOutput = output.getDataOutput();
            getOutputSet(ioSpec).getDataOutputRefs().add(dataOutput);
            ioSpec.getDataOutputs().add(dataOutput);
            this.addItemDefinition(output.getItemDefinition());
            DataOutputAssociation dataOutputAssociation = output.getDataOutputAssociation();
            if (dataOutputAssociation != null) {
                activity.getDataOutputAssociations().add(dataOutputAssociation);
            }
        }
    }
}
Also used : DataInput(org.eclipse.bpmn2.DataInput) InitializedOutputVariable(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable.InitializedOutputVariable) DataOutput(org.eclipse.bpmn2.DataOutput) InputOutputSpecification(org.eclipse.bpmn2.InputOutputSpecification) ParsedAssignmentsInfo(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.ParsedAssignmentsInfo) InitializedInputVariable(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable.InitializedInputVariable) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation)

Example 35 with DataOutput

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

the class CatchEventPropertyWriter method setAssignmentsInfo.

public void setAssignmentsInfo(AssignmentsInfo info) {
    ParsedAssignmentsInfo assignmentsInfo = ParsedAssignmentsInfo.of(info);
    List<InitializedOutputVariable> outputs = assignmentsInfo.createInitializedOutputVariables(getId(), variableScope, dataObjects);
    if (outputs.isEmpty()) {
        return;
    }
    if (outputs.size() > 1) {
        throw new IllegalArgumentException("Output Associations should be at most 1 in Catch Events");
    }
    InitializedOutputVariable output = outputs.get(0);
    DataOutput dataOutput = output.getDataOutput();
    event.getDataOutputs().add(dataOutput);
    getOutputSet().getDataOutputRefs().add(dataOutput);
    this.addItemDefinition(dataOutput.getItemSubjectRef());
    DataOutputAssociation dataOutputAssociation = output.getDataOutputAssociation();
    if (dataOutputAssociation != null) {
        event.getDataOutputAssociation().add(dataOutputAssociation);
    }
}
Also used : InitializedOutputVariable(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable.InitializedOutputVariable) DataOutput(org.eclipse.bpmn2.DataOutput) ParsedAssignmentsInfo(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.ParsedAssignmentsInfo) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation)

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