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 org.kie.dmn.model.api.DecisionService dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
@SuppressWarnings("unchecked") final Node<View<DecisionService>, ?> node = (Node<View<DecisionService>, ?>) factoryManager.newElement(dmn.getId(), getDefinitionId(DecisionService.class)).asNode();
final Id id = new Id(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 = dmn.getOutputDecision().stream().map(DMNElementReferenceConverter::wbFromDMN).collect(Collectors.toList());
final List<DMNElementReference> encapsulatedDecision = dmn.getEncapsulatedDecision().stream().map(DMNElementReferenceConverter::wbFromDMN).collect(Collectors.toList());
final List<DMNElementReference> inputDecision = dmn.getInputDecision().stream().map(DMNElementReferenceConverter::wbFromDMN).collect(Collectors.toList());
final List<DMNElementReference> inputData = dmn.getInputData().stream().map(DMNElementReferenceConverter::wbFromDMN).collect(Collectors.toList());
final DecisionService decisionService = new DecisionService(id, description, name, informationItem, outputDecision, encapsulatedDecision, inputDecision, inputData, new StylingSet(), new DecisionServiceRectangleDimensionsSet(), new DecisionServiceDividerLineY());
node.getContent().setDefinition(decisionService);
if (informationItem != null) {
informationItem.setParent(decisionService);
}
DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, decisionService);
return node;
}
use of org.kie.workbench.common.dmn.api.definition.model.DMNElementReference in project kie-wb-common by kiegroup.
the class DMNElementReferenceConverter method wbFromDMN.
public static DMNElementReference wbFromDMN(final org.kie.dmn.model.api.DMNElementReference dmn) {
final DMNElementReference result = new DMNElementReference();
result.setHref(dmn.getHref());
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.DMNElementReference in project kie-wb-common by kiegroup.
the class DMNElementReferenceConverter method wbFromDMN.
public static DMNElementReference wbFromDMN(final JSITDMNElementReference dmn) {
final DMNElementReference result = new DMNElementReference();
result.setHref(dmn.getHref());
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.DMNElementReference in project kie-wb-common by kiegroup.
the class DecisionServiceParametersListWidgetTest method testGetCurrentItems.
@Test
public void testGetCurrentItems() {
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 List<DMNElementReference> list = createListOfDMNElementReferenceWithIds(id1, id2, id3);
final List<InputData> unsortedInputs = Arrays.asList(createInputDataWithId(id2), createInputDataWithId(id3), createInputDataWithId(id1));
doReturn(value).when(widget).getValue();
when(value.getDecisionService()).thenReturn(decisionService);
when(decisionService.getInputData()).thenReturn(list);
final List<InputData> sorted = widget.getCurrentItems(unsortedInputs);
assertThat(sorted).extracting(inputData -> inputData.getId().getValue()).containsExactly(id1, id2, id3);
}
use of org.kie.workbench.common.dmn.api.definition.model.DMNElementReference in project kie-wb-common by kiegroup.
the class DecisionServiceParametersListWidgetTest method testGetNewItems.
@Test
public void testGetNewItems() {
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 newItem1 = "aaa";
final String newItem2 = "bbb";
final String newItem3 = "ccc";
final String newItem4 = "ddd";
final List<DMNElementReference> list = createListOfDMNElementReferenceWithIds(id1, id2, id3);
final List<InputData> currentItems = Arrays.asList(createInputDataWithId(id2), createInputDataWithId(id3), createInputDataWithId(id1));
final List<InputData> inputs = Arrays.asList(createInputDataWithId(newItem3), createInputDataWithId(newItem2), createInputDataWithId(newItem4), createInputDataWithId(newItem1));
doReturn(value).when(widget).getValue();
when(value.getDecisionService()).thenReturn(decisionService);
when(decisionService.getInputData()).thenReturn(list);
final List<InputData> result = widget.getNewItems(inputs, currentItems);
assertThat(result).extracting(inputData -> inputData.getId().getValue()).containsExactly(newItem1, newItem2, newItem3, newItem4);
}
Aggregations