use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.
the class DecisionConverter method dmnFromNode.
@Override
public org.kie.dmn.model.v1_1.Decision dmnFromNode(final Node<View<Decision>, ?> node) {
Decision source = node.getContent().getDefinition();
org.kie.dmn.model.v1_1.Decision d = new org.kie.dmn.model.v1_1.Decision();
d.setId(source.getId().getValue());
d.setDescription(DescriptionPropertyConverter.dmnFromWB(source.getDescription()));
d.setName(source.getName().getValue());
d.setVariable(InformationItemPropertyConverter.dmnFromWB(source.getVariable()));
d.setExpression(ExpressionPropertyConverter.dmnFromWB(source.getExpression()));
// DMN spec table 2: Requirements connection rules
List<Edge<?, ?>> inEdges = (List<Edge<?, ?>>) node.getInEdges();
for (Edge<?, ?> e : inEdges) {
Node<?, ?> sourceNode = e.getSourceNode();
if (sourceNode.getContent() instanceof View<?>) {
View<?> view = (View<?>) sourceNode.getContent();
if (view.getDefinition() instanceof DRGElement) {
DRGElement drgElement = (DRGElement) view.getDefinition();
if (drgElement instanceof Decision) {
org.kie.dmn.model.v1_1.InformationRequirement iReq = new org.kie.dmn.model.v1_1.InformationRequirement();
org.kie.dmn.model.v1_1.DMNElementReference ri = new org.kie.dmn.model.v1_1.DMNElementReference();
ri.setHref(new StringBuilder("#").append(drgElement.getId().getValue()).toString());
iReq.setRequiredDecision(ri);
d.getInformationRequirement().add(iReq);
} else if (drgElement instanceof BusinessKnowledgeModel) {
org.kie.dmn.model.v1_1.KnowledgeRequirement iReq = new org.kie.dmn.model.v1_1.KnowledgeRequirement();
org.kie.dmn.model.v1_1.DMNElementReference ri = new org.kie.dmn.model.v1_1.DMNElementReference();
ri.setHref(new StringBuilder("#").append(drgElement.getId().getValue()).toString());
iReq.setRequiredKnowledge(ri);
d.getKnowledgeRequirement().add(iReq);
} else if (drgElement instanceof KnowledgeSource) {
org.kie.dmn.model.v1_1.AuthorityRequirement iReq = new org.kie.dmn.model.v1_1.AuthorityRequirement();
org.kie.dmn.model.v1_1.DMNElementReference ri = new org.kie.dmn.model.v1_1.DMNElementReference();
ri.setHref(new StringBuilder("#").append(drgElement.getId().getValue()).toString());
iReq.setRequiredAuthority(ri);
d.getAuthorityRequirement().add(iReq);
} else if (drgElement instanceof InputData) {
org.kie.dmn.model.v1_1.InformationRequirement iReq = new org.kie.dmn.model.v1_1.InformationRequirement();
org.kie.dmn.model.v1_1.DMNElementReference ri = new org.kie.dmn.model.v1_1.DMNElementReference();
ri.setHref(new StringBuilder("#").append(drgElement.getId().getValue()).toString());
iReq.setRequiredInput(ri);
d.getInformationRequirement().add(iReq);
} else {
throw new UnsupportedOperationException("wrong model definition.");
}
}
}
}
return d;
}
use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.
the class DecisionConverter method nodeFromDMN.
@Override
public Node<View<Decision>, ?> nodeFromDMN(final org.kie.dmn.model.v1_1.Decision dmn) {
@SuppressWarnings("unchecked") Node<View<Decision>, ?> node = (Node<View<Decision>, ?>) factoryManager.newElement(dmn.getId(), Decision.class).asNode();
Id id = new Id(dmn.getId());
Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
Name name = new Name(dmn.getName());
InformationItem informationItem = InformationItemPropertyConverter.wbFromDMN(dmn.getVariable());
Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression());
Decision decision = new Decision(id, description, name, new Question(), new AllowedAnswers(), informationItem, expression, new BackgroundSet(), new FontSet(), new RectangleDimensionsSet());
node.getContent().setDefinition(decision);
return node;
}
use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.
the class InputDataConverter method nodeFromDMN.
@Override
public Node<View<InputData>, ?> nodeFromDMN(final org.kie.dmn.model.v1_1.InputData dmn) {
@SuppressWarnings("unchecked") Node<View<InputData>, ?> node = (Node<View<InputData>, ?>) factoryManager.newElement(dmn.getId(), InputData.class).asNode();
Id id = new Id(dmn.getId());
Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
Name name = new Name(dmn.getName());
InformationItem informationItem = InformationItemPropertyConverter.wbFromDMN(dmn.getVariable());
InputData inputData = new InputData(id, description, name, informationItem, new BackgroundSet(), new FontSet(), new RectangleDimensionsSet());
node.getContent().setDefinition(inputData);
return node;
}
use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.
the class CallActivityConverter method convert.
public BpmnNode convert(CallActivity activity) {
Node<View<ReusableSubprocess>, Edge> node = factoryManager.newNode(activity.getId(), ReusableSubprocess.class);
ReusableSubprocess definition = node.getContent().getDefinition();
ActivityPropertyReader p = propertyReaderFactory.of(activity);
definition.setGeneral(new BPMNGeneralSet(new Name(p.getName()), new Documentation(p.getDocumentation())));
definition.setExecutionSet(new ReusableSubprocessTaskExecutionSet(new CalledElement(activity.getCalledElement()), new Independent(p.isIndependent()), new WaitForCompletion(p.isWaitForCompletion()), new IsAsync(p.isAsync())));
definition.setDataIOSet(new DataIOSet(p.getAssignmentsInfo()));
node.getContent().setBounds(p.getBounds());
definition.setSimulationSet(p.getSimulationSet());
definition.setDimensionsSet(p.getRectangleDimensionsSet());
definition.setFontSet(p.getFontSet());
definition.setBackgroundSet(p.getBackgroundSet());
return BpmnNode.of(node);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.
the class EndEventConverter method terminateEndEvent.
private BpmnNode terminateEndEvent(EndEvent event, TerminateEventDefinition e) {
Node<View<EndTerminateEvent>, Edge> node = factoryManager.newNode(event.getId(), EndTerminateEvent.class);
EndTerminateEvent definition = node.getContent().getDefinition();
EventPropertyReader p = propertyReaderFactory.of(event);
definition.setGeneral(new BPMNGeneralSet(new Name(p.getName()), new Documentation(p.getDocumentation())));
node.getContent().setBounds(p.getBounds());
definition.setDimensionsSet(p.getCircleDimensionSet());
definition.setFontSet(p.getFontSet());
definition.setBackgroundSet(p.getBackgroundSet());
return BpmnNode.of(node);
}
Aggregations