Search in sources :

Example 6 with MultiInstanceLoopCharacteristics

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

the class BPMNFormModelGeneratorImpl method isMIInputCollection.

private static boolean isMIInputCollection(UserTask userTask, DataInputAssociation inputAssociation) {
    MultiInstanceLoopCharacteristics loopCharacteristics = (MultiInstanceLoopCharacteristics) userTask.getLoopCharacteristics();
    String inputCollectionRef = loopCharacteristics != null ? getId(loopCharacteristics.getLoopDataInputRef()) : null;
    if (StringUtils.isEmpty(inputCollectionRef)) {
        return false;
    }
    String associationTargetRef = getId(inputAssociation.getTargetRef());
    return inputCollectionRef.equals(associationTargetRef);
}
Also used : MultiInstanceLoopCharacteristics(org.eclipse.bpmn2.MultiInstanceLoopCharacteristics)

Example 7 with MultiInstanceLoopCharacteristics

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

the class BPMNFormModelGeneratorImpl method isMIOutputCollection.

private static boolean isMIOutputCollection(UserTask userTask, DataOutputAssociation outputAssociation) {
    MultiInstanceLoopCharacteristics loopCharacteristics = (MultiInstanceLoopCharacteristics) userTask.getLoopCharacteristics();
    String outputCollectionRef = loopCharacteristics != null ? getId(loopCharacteristics.getLoopDataOutputRef()) : null;
    if (StringUtils.isEmpty(outputCollectionRef)) {
        return false;
    }
    String associationSourceRef = outputAssociation.getSourceRef() != null && !outputAssociation.getSourceRef().isEmpty() ? outputAssociation.getSourceRef().get(0).getId() : null;
    return outputCollectionRef.equals(associationSourceRef);
}
Also used : MultiInstanceLoopCharacteristics(org.eclipse.bpmn2.MultiInstanceLoopCharacteristics)

Example 8 with MultiInstanceLoopCharacteristics

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

the class MultipleInstanceActivityPropertyWriterTest method testSetCollectionOutput.

@Test
public void testSetCollectionOutput() {
    writer.setCollectionOutput(PROPERTY_ID);
    assertOutputsInitialized();
    String outputId = ACTIVITY_ID + "_" + OUT_COLLECTION + "OutputX";
    assertHasDataOutput(activity.getIoSpecification(), outputId, ITEM_ID, OUT_COLLECTION);
    assertHasDataOutputAssociation(activity, outputId, PROPERTY_ID);
    assertEquals(outputId, ((MultiInstanceLoopCharacteristics) activity.getLoopCharacteristics()).getLoopDataOutputRef().getId());
    // Test with Data Objects
    when(variableScope.lookup(PROPERTY_ID)).thenReturn(Optional.empty());
    Set<DataObject> dataObjects = new HashSet<>();
    DataObject dataObject = mockDataObject(PROPERTY_ID);
    dataObjects.add(dataObject);
    writer = new MultipleInstanceActivityPropertyWriter(activity, variableScope, dataObjects);
    writer.setCollectionOutput(PROPERTY_ID);
    assertOutputsInitialized();
    outputId = ACTIVITY_ID + "_" + OUT_COLLECTION + "OutputX";
    assertHasDataOutputAssociation(activity, outputId, PROPERTY_ID);
    // Test with Data Objects
    when(variableScope.lookup(PROPERTY_ID)).thenReturn(Optional.empty());
    dataObject = mockDataObject(PROPERTY_ID);
    dataObjects.add(dataObject);
    writer = new MultipleInstanceActivityPropertyWriter(activity, variableScope, dataObjects);
    writer.setCollectionOutput(PROPERTY_ID);
    assertOutputsInitialized();
    outputId = ACTIVITY_ID + "_" + OUT_COLLECTION + "OutputX";
    assertHasDataOutputAssociation(activity, outputId, PROPERTY_ID);
    // Test no option
    when(variableScope.lookup(PROPERTY_ID)).thenReturn(Optional.empty());
    dataObjects.clear();
    dataObject = mockDataObject("SomeOtherId");
    dataObjects.add(dataObject);
    writer = new MultipleInstanceActivityPropertyWriter(activity, variableScope, dataObjects);
    writer.setCollectionOutput(PROPERTY_ID);
    assertOutputsInitialized();
    outputId = ACTIVITY_ID + "_" + OUT_COLLECTION + "OutputX";
    assertHasDataOutputAssociation(activity, outputId, PROPERTY_ID);
}
Also used : DataObject(org.eclipse.bpmn2.DataObject) MultiInstanceLoopCharacteristics(org.eclipse.bpmn2.MultiInstanceLoopCharacteristics) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 9 with MultiInstanceLoopCharacteristics

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

the class MultipleInstanceActivityPropertyWriterTest method testSetCollectionInput.

@Test
public void testSetCollectionInput() {
    writer.setCollectionInput(PROPERTY_ID);
    assertInputsInitialized();
    String inputId = ACTIVITY_ID + "_" + IN_COLLECTION + "InputX";
    assertHasDataInput(activity.getIoSpecification(), inputId, ITEM_ID, IN_COLLECTION);
    assertHasDataInputAssociation(activity, PROPERTY_ID, inputId);
    assertEquals(inputId, ((MultiInstanceLoopCharacteristics) activity.getLoopCharacteristics()).getLoopDataInputRef().getId());
    // Test with Data Objects
    when(variableScope.lookup(PROPERTY_ID)).thenReturn(Optional.empty());
    Set<DataObject> dataObjects = new HashSet<>();
    DataObject dataObject = mockDataObject(PROPERTY_ID);
    dataObjects.add(dataObject);
    writer = new MultipleInstanceActivityPropertyWriter(activity, variableScope, dataObjects);
    writer.setCollectionInput(PROPERTY_ID);
    assertInputsInitialized();
    inputId = ACTIVITY_ID + "_" + IN_COLLECTION + "InputX";
    assertHasDataInput(activity.getIoSpecification(), inputId, ITEM_ID, IN_COLLECTION);
    assertHasDataInputAssociation(activity, PROPERTY_ID, inputId);
    // Test no option
    when(variableScope.lookup(PROPERTY_ID)).thenReturn(Optional.empty());
    dataObjects.clear();
    dataObject = mockDataObject("SomeOtherId");
    dataObjects.add(dataObject);
    writer = new MultipleInstanceActivityPropertyWriter(activity, variableScope, dataObjects);
    writer.setCollectionInput(PROPERTY_ID);
    assertInputsInitialized();
    inputId = ACTIVITY_ID + "_" + IN_COLLECTION + "InputX";
    assertHasDataInput(activity.getIoSpecification(), inputId, ITEM_ID, IN_COLLECTION);
    assertHasDataInputAssociation(activity, PROPERTY_ID, inputId);
}
Also used : DataObject(org.eclipse.bpmn2.DataObject) MultiInstanceLoopCharacteristics(org.eclipse.bpmn2.MultiInstanceLoopCharacteristics) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 10 with MultiInstanceLoopCharacteristics

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

the class MultipleInstanceSubProcessPropertyWriterTest method completionConditionMustBeWrappedInCdata.

@Test
public void completionConditionMustBeWrappedInCdata() {
    String expression = "x<1";
    String expected = "<![CDATA[" + expression + "]]>";
    SubProcess subProcess = bpmn2.createSubProcess();
    MultipleInstanceSubProcessPropertyWriter p = new MultipleInstanceSubProcessPropertyWriter(subProcess, new FlatVariableScope(), new HashSet<>());
    p.setCompletionCondition(expression);
    MultiInstanceLoopCharacteristics loopCharacteristics = (MultiInstanceLoopCharacteristics) subProcess.getLoopCharacteristics();
    FormalExpression completionCondition = (FormalExpression) loopCharacteristics.getCompletionCondition();
    assertThat(expected).isEqualTo(completionCondition.getBody());
}
Also used : SubProcess(org.eclipse.bpmn2.SubProcess) MultiInstanceLoopCharacteristics(org.eclipse.bpmn2.MultiInstanceLoopCharacteristics) FormalExpression(org.eclipse.bpmn2.FormalExpression) Test(org.junit.Test)

Aggregations

MultiInstanceLoopCharacteristics (org.eclipse.bpmn2.MultiInstanceLoopCharacteristics)11 FormalExpression (org.eclipse.bpmn2.FormalExpression)7 DataInput (org.eclipse.bpmn2.DataInput)6 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)6 DataOutput (org.eclipse.bpmn2.DataOutput)6 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)6 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)5 DataObject (org.eclipse.bpmn2.DataObject)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 InputSet (org.eclipse.bpmn2.InputSet)3 SubProcess (org.eclipse.bpmn2.SubProcess)3 Test (org.junit.Test)3 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 Entry (java.util.Map.Entry)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 Activity (org.eclipse.bpmn2.Activity)2