use of org.kie.workbench.common.dmn.api.definition.model.DMNElementReference in project kie-wb-common by kiegroup.
the class DecisionServiceParametersListWidgetTest method createListOfDMNElementReferenceWithIds.
private List<DMNElementReference> createListOfDMNElementReferenceWithIds(final String... ids) {
final List<DMNElementReference> list = new ArrayList<>();
for (final String id : ids) {
final DMNElementReference reference = new DMNElementReference();
reference.setHref("#" + id);
list.add(reference);
}
return list;
}
use of org.kie.workbench.common.dmn.api.definition.model.DMNElementReference in project kie-wb-common by kiegroup.
the class DecisionServiceParametersListWidgetTest method testGetSortedInputs.
@Test
public void testGetSortedInputs() {
final DecisionServiceParametersList value = mock(DecisionServiceParametersList.class);
final DecisionService decisionService = mock(DecisionService.class);
final String id1 = "id1";
final String id2 = "id2";
final String id3 = "id3";
final String newId1 = "newId1";
final String newId2 = "newId2";
final List<DMNElementReference> list = createListOfDMNElementReferenceWithIds(id1, id2, id3);
final List<InputData> unsortedInputs = Arrays.asList(createInputDataWithId(id2), createInputDataWithId(id3), createInputDataWithId(newId2), createInputDataWithId(id1), createInputDataWithId(newId1));
doReturn(value).when(widget).getValue();
when(value.getDecisionService()).thenReturn(decisionService);
when(decisionService.getInputData()).thenReturn(list);
final List<InputData> sorted = widget.getSortedInputs(unsortedInputs);
assertThat(sorted).extracting(inputData -> inputData.getId().getValue()).containsExactly(id1, id2, id3, newId1, newId2);
}
use of org.kie.workbench.common.dmn.api.definition.model.DMNElementReference in project kie-wb-common by kiegroup.
the class DecisionServiceConverter method nodeFromDMN.
@Override
public Node<View<DecisionService>, ?> nodeFromDMN(final NodeEntry nodeEntry) {
final JSITDecisionService dmn = Js.uncheckedCast(nodeEntry.getDmnElement());
@SuppressWarnings("unchecked") final Node<View<DecisionService>, ?> node = (Node<View<DecisionService>, ?>) factoryManager.newElement(nodeEntry.getId(), getDefinitionId(DecisionService.class)).asNode();
final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final Name name = new Name(dmn.getName());
final InformationItemPrimary informationItem = InformationItemPrimaryPropertyConverter.wbFromDMN(dmn.getVariable(), dmn);
final List<DMNElementReference> outputDecision = new ArrayList<>();
final List<DMNElementReference> encapsulatedDecision = new ArrayList<>();
final List<DMNElementReference> inputDecision = new ArrayList<>();
final List<DMNElementReference> inputData = new ArrayList<>();
final List<JSITDMNElementReference> jsiOutputDecisions = dmn.getOutputDecision();
if (Objects.nonNull(jsiOutputDecisions)) {
for (int i = 0; i < jsiOutputDecisions.size(); i++) {
final JSITDMNElementReference jsiOutputDecision = Js.uncheckedCast(jsiOutputDecisions.get(i));
outputDecision.add(DMNElementReferenceConverter.wbFromDMN(jsiOutputDecision));
}
}
final List<JSITDMNElementReference> jsiEncapsulatedDecisions = dmn.getEncapsulatedDecision();
if (Objects.nonNull(jsiEncapsulatedDecisions)) {
for (int i = 0; i < jsiEncapsulatedDecisions.size(); i++) {
final JSITDMNElementReference jsiEncapsulatedDecision = Js.uncheckedCast(jsiEncapsulatedDecisions.get(i));
encapsulatedDecision.add(DMNElementReferenceConverter.wbFromDMN(jsiEncapsulatedDecision));
}
}
final List<JSITDMNElementReference> jsiInputDecisions = dmn.getInputDecision();
if (Objects.nonNull(jsiInputDecisions)) {
for (int i = 0; i < jsiInputDecisions.size(); i++) {
final JSITDMNElementReference jsiInputDecision = Js.uncheckedCast(jsiInputDecisions.get(i));
inputDecision.add(DMNElementReferenceConverter.wbFromDMN(jsiInputDecision));
}
}
final List<JSITDMNElementReference> jsiInputDatas = dmn.getInputData();
if (Objects.nonNull(jsiInputDatas)) {
for (int i = 0; i < jsiInputDatas.size(); i++) {
final JSITDMNElementReference jsiInputData = Js.uncheckedCast(jsiInputDatas.get(i));
inputData.add(DMNElementReferenceConverter.wbFromDMN(jsiInputData));
}
}
final DecisionService decisionService = new DecisionService(id, description, name, informationItem, outputDecision, encapsulatedDecision, inputDecision, inputData, new StylingSet(), new DecisionServiceRectangleDimensionsSet(), new DecisionServiceDividerLineY());
decisionService.setDiagramId(nodeEntry.getDiagramId());
node.getContent().setDefinition(decisionService);
if (Objects.nonNull(informationItem)) {
informationItem.setParent(decisionService);
}
DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, decisionService);
return node;
}
Aggregations