use of org.kie.workbench.common.dmn.api.definition.model.DecisionService 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;
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionService in project kie-wb-common by kiegroup.
the class DecisionServiceMoveDividerControlTest method testRegisterDecisionServiceElement.
@Test
@SuppressWarnings("unchecked")
public void testRegisterDecisionServiceElement() {
final DecisionService decisionService = mock(DecisionService.class);
final DecisionServiceSVGShapeView decisionServiceShapeView = mock(DecisionServiceSVGShapeView.class);
when(definition.getDefinition()).thenReturn(decisionService);
when(shape.getShapeView()).thenReturn(decisionServiceShapeView);
control.register(element);
verify(control).registerHandler(Mockito.<String>any(), Mockito.<ViewHandler>any());
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionService in project kie-wb-common by kiegroup.
the class StunnerConverter method ddExtAugmentStunner.
private void ddExtAugmentStunner(final Node currentNode, final JSIDMNShape shape) {
final View content = (View) currentNode.getContent();
final Bound ulBound = upperLeftBound(content);
final Bound lrBound = lowerRightBound(content);
final Object definition = content.getDefinition();
if (definition instanceof Decision) {
final Decision decision = (Decision) definition;
internalAugment(shape, ulBound, decision.getDimensionsSet(), lrBound, decision.getStylingSet(), (line) -> {
/*NOP*/
});
} else if (definition instanceof InputData) {
final InputData inputData = (InputData) definition;
internalAugment(shape, ulBound, inputData.getDimensionsSet(), lrBound, inputData.getStylingSet(), (line) -> {
/*NOP*/
});
} else if (definition instanceof BusinessKnowledgeModel) {
final BusinessKnowledgeModel businessKnowledgeModel = (BusinessKnowledgeModel) definition;
internalAugment(shape, ulBound, businessKnowledgeModel.getDimensionsSet(), lrBound, businessKnowledgeModel.getStylingSet(), (line) -> {
/*NOP*/
});
} else if (definition instanceof KnowledgeSource) {
final KnowledgeSource knowledgeSource = (KnowledgeSource) definition;
internalAugment(shape, ulBound, knowledgeSource.getDimensionsSet(), lrBound, knowledgeSource.getStylingSet(), (line) -> {
/*NOP*/
});
} else if (definition instanceof TextAnnotation) {
final TextAnnotation textAnnotation = (TextAnnotation) definition;
internalAugment(shape, ulBound, textAnnotation.getDimensionsSet(), lrBound, textAnnotation.getStylingSet(), (line) -> {
/*NOP*/
});
} else if (definition instanceof DecisionService) {
final DecisionService decisionService = (DecisionService) definition;
internalAugment(shape, ulBound, decisionService.getDimensionsSet(), lrBound, decisionService.getStylingSet(), (dividerLineY) -> decisionService.setDividerLineY(new DecisionServiceDividerLineY(dividerLineY - ulBound.getY())));
}
}
Aggregations