Search in sources :

Example 6 with Edge

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;
}
Also used : View(org.kie.workbench.common.stunner.core.graph.content.view.View) KnowledgeSource(org.kie.workbench.common.dmn.api.definition.v1_1.KnowledgeSource) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.v1_1.BusinessKnowledgeModel) List(java.util.List) Edge(org.kie.workbench.common.stunner.core.graph.Edge) DRGElement(org.kie.workbench.common.dmn.api.definition.v1_1.DRGElement)

Example 7 with Edge

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;
}
Also used : KnowledgeSource(org.kie.workbench.common.dmn.api.definition.v1_1.KnowledgeSource) List(java.util.List) InputData(org.kie.workbench.common.dmn.api.definition.v1_1.InputData) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.v1_1.BusinessKnowledgeModel) Edge(org.kie.workbench.common.stunner.core.graph.Edge) DRGElement(org.kie.workbench.common.dmn.api.definition.v1_1.DRGElement)

Example 8 with Edge

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);
}
Also used : Documentation(org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name) WaitForCompletion(org.kie.workbench.common.stunner.bpmn.definition.property.task.WaitForCompletion) DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) Independent(org.kie.workbench.common.stunner.bpmn.definition.property.task.Independent) ReusableSubprocess(org.kie.workbench.common.stunner.bpmn.definition.ReusableSubprocess) ActivityPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.ActivityPropertyReader) IsAsync(org.kie.workbench.common.stunner.bpmn.definition.property.task.IsAsync) Edge(org.kie.workbench.common.stunner.core.graph.Edge) ReusableSubprocessTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.ReusableSubprocessTaskExecutionSet) CalledElement(org.kie.workbench.common.stunner.bpmn.definition.property.task.CalledElement)

Example 9 with Edge

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);
}
Also used : Documentation(org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) EndTerminateEvent(org.kie.workbench.common.stunner.bpmn.definition.EndTerminateEvent) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) EventPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.EventPropertyReader) ThrowEventPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.ThrowEventPropertyReader) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)

Example 10 with Edge

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);
}
Also used : DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) Documentation(org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation) MessageRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef) EndMessageEvent(org.kie.workbench.common.stunner.bpmn.definition.EndMessageEvent) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) MessageEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageEventExecutionSet) EventPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.EventPropertyReader) ThrowEventPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.ThrowEventPropertyReader) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)

Aggregations

Edge (org.kie.workbench.common.stunner.core.graph.Edge)154 View (org.kie.workbench.common.stunner.core.graph.content.view.View)101 Node (org.kie.workbench.common.stunner.core.graph.Node)84 Test (org.junit.Test)45 Documentation (org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation)30 Name (org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)30 Graph (org.kie.workbench.common.stunner.core.graph.Graph)28 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)25 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)25 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)19 ViewConnector (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector)19 List (java.util.List)17 EventPropertyReader (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.EventPropertyReader)16 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)16 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)15 Element (org.kie.workbench.common.stunner.core.graph.Element)14 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)13 Child (org.kie.workbench.common.stunner.core.graph.content.relationship.Child)12 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)12 ArrayList (java.util.ArrayList)11