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);
}
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);
}
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);
}
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);
}
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());
}
Aggregations