use of org.kie.workbench.common.stunner.core.graph.Edge in project kie-wb-common by kiegroup.
the class BusinessKnowledgeModelConverter method dmnFromNode.
@Override
public org.kie.dmn.model.v1_1.BusinessKnowledgeModel dmnFromNode(final Node<View<BusinessKnowledgeModel>, ?> node) {
BusinessKnowledgeModel source = node.getContent().getDefinition();
org.kie.dmn.model.v1_1.BusinessKnowledgeModel result = new org.kie.dmn.model.v1_1.BusinessKnowledgeModel();
result.setId(source.getId().getValue());
result.setDescription(DescriptionPropertyConverter.dmnFromWB(source.getDescription()));
result.setName(source.getName().getValue());
result.setVariable(InformationItemPropertyConverter.dmnFromWB(source.getVariable()));
result.setEncapsulatedLogic(FunctionDefinitionPropertyConverter.dmnFromWB(source.getEncapsulatedLogic()));
// 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 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);
result.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);
result.getAuthorityRequirement().add(iReq);
} else {
throw new UnsupportedOperationException("wrong model definition.");
}
}
}
}
return result;
}
use of org.kie.workbench.common.stunner.core.graph.Edge 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.Edge 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.Edge 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);
}
use of org.kie.workbench.common.stunner.core.graph.Edge in project kie-wb-common by kiegroup.
the class EndEventConverter method messageEventDefinition.
private BpmnNode messageEventDefinition(EndEvent event, MessageEventDefinition e) {
Node<View<EndMessageEvent>, Edge> node = factoryManager.newNode(event.getId(), EndMessageEvent.class);
EndMessageEvent definition = node.getContent().getDefinition();
EventPropertyReader p = propertyReaderFactory.of(event);
definition.setGeneral(new BPMNGeneralSet(new Name(p.getName()), new Documentation(p.getDocumentation())));
definition.setDataIOSet(new DataIOSet(p.getAssignmentsInfo()));
definition.setExecutionSet(new MessageEventExecutionSet(new MessageRef(e.getMessageRef().getName())));
node.getContent().setBounds(p.getBounds());
definition.setDimensionsSet(p.getCircleDimensionSet());
definition.setFontSet(p.getFontSet());
definition.setBackgroundSet(p.getBackgroundSet());
return BpmnNode.of(node);
}
Aggregations