Search in sources :

Example 76 with Id

use of org.kie.workbench.common.dmn.api.property.dmn.Id in project kie-wb-common by kiegroup.

the class DecisionNavigatorObserverTest method testSelectItemWhenExpressionIsNotNull.

@Test
public void testSelectItemWhenExpressionIsNotNull() {
    final EditExpressionEvent event = makeEditExpressionEvent();
    final Expression expression = mock(Expression.class);
    final Id id = mock(Id.class);
    when(hasExpression.getExpression()).thenReturn(expression);
    when(expression.getId()).thenReturn(id);
    when(id.getValue()).thenReturn(uuid);
    observer.init(presenter);
    observer.selectItem(event.getHasExpression());
    verify(treePresenter).selectItem(uuid);
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) EditExpressionEvent(org.kie.workbench.common.dmn.client.events.EditExpressionEvent) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) Test(org.junit.Test)

Example 77 with Id

use of org.kie.workbench.common.dmn.api.property.dmn.Id in project kie-wb-common by kiegroup.

the class DMNDiagramsSessionTest method testIsGlobalGraphWhenItReturnsFalse.

@Test
public void testIsGlobalGraphWhenItReturnsFalse() {
    final DMNDiagramElement diagramElement = new DMNDiagramElement(new Id(), new Name("None"));
    final Diagram stunnerDiagram = mock(Diagram.class);
    dmnDiagramsSession.add(diagramElement, stunnerDiagram);
    dmnDiagramsSession.onDMNDiagramSelected(new DMNDiagramSelected(diagramElement));
    assertFalse(dmnDiagramsSession.isGlobalGraphSelected());
}
Also used : Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Test(org.junit.Test)

Example 78 with Id

use of org.kie.workbench.common.dmn.api.property.dmn.Id in project kie-wb-common by kiegroup.

the class DMNDiagramsSessionTest method testClear.

@Test
public void testClear() {
    final DMNDiagramElement dmnDiagram = mock(DMNDiagramElement.class);
    final Diagram stunnerDiagram = mock(Diagram.class);
    final String diagramId = "0000";
    when(dmnDiagram.getId()).thenReturn(new Id(diagramId));
    dmnDiagramsSession.add(dmnDiagram, stunnerDiagram);
    assertEquals(dmnDiagram, dmnDiagramsSession.getDMNDiagramElement(diagramId));
    assertEquals(stunnerDiagram, dmnDiagramsSession.getDiagram(diagramId));
    assertEquals(dmnDiagram, dmnDiagramsSession.getDiagramTuple(diagramId).getDMNDiagram());
    assertEquals(stunnerDiagram, dmnDiagramsSession.getDiagramTuple(diagramId).getStunnerDiagram());
    dmnDiagramsSession.clear();
    assertNull(dmnDiagramsSession.getDMNDiagramElement(diagramId));
    assertNull(dmnDiagramsSession.getDiagram(diagramId));
    assertNull(dmnDiagramsSession.getDiagramTuple(diagramId).getDMNDiagram());
    assertNull(dmnDiagramsSession.getDiagramTuple(diagramId).getStunnerDiagram());
}
Also used : Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Test(org.junit.Test)

Example 79 with Id

use of org.kie.workbench.common.dmn.api.property.dmn.Id in project kie-wb-common by kiegroup.

the class DMNDeepCloneProcess method cloneDRGElementBasicInfo.

private void cloneDRGElementBasicInfo(final DRGElement source, final DRGElement target) {
    final String uniqueNodeName = composeUniqueNodeName(source.getName().getValue());
    target.setId(new Id());
    target.setNameHolder(new NameHolder(new Name(uniqueNodeName)));
    target.setDescription(source.getDescription().copy());
    target.setParent(source.getParent());
    target.getLinksHolder().getValue().getLinks().addAll(cloneExternalLinkList(source));
}
Also used : NameHolder(org.kie.workbench.common.dmn.api.property.dmn.NameHolder) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) Name(org.kie.workbench.common.dmn.api.property.dmn.Name)

Example 80 with Id

use of org.kie.workbench.common.dmn.api.property.dmn.Id in project kie-wb-common by kiegroup.

the class NodeConnector method connect.

void connect(final JSIDMNDiagram dmnDiagram, final List<JSIDMNEdge> edges, final List<JSITAssociation> associations, final List<NodeEntry> nodeEntries, final boolean isDMNDIPresent) {
    final Map<String, List<NodeEntry>> entriesById = makeNodeIndex(nodeEntries);
    final String diagramId = dmnDiagram.getId();
    for (final NodeEntry nodeEntry : nodeEntries) {
        final JSITDMNElement element = nodeEntry.getDmnElement();
        final Node node = nodeEntry.getNode();
        // For imported nodes, we don't have its connections
        if (nodeEntry.isIncluded()) {
            continue;
        }
        // DMN spec table 2: Requirements
        if (JSITDecision.instanceOf(element)) {
            final JSITDecision decision = Js.uncheckedCast(element);
            final List<JSITInformationRequirement> jsiInformationRequirements = decision.getInformationRequirement();
            for (int i = 0; i < jsiInformationRequirements.size(); i++) {
                final JSITInformationRequirement ir = Js.uncheckedCast(jsiInformationRequirements.get(i));
                connectEdgeToNodes(INFO_REQ_ID, ir, ir.getRequiredInput(), entriesById, diagramId, edges, isDMNDIPresent, node);
                connectEdgeToNodes(INFO_REQ_ID, ir, ir.getRequiredDecision(), entriesById, diagramId, edges, isDMNDIPresent, node);
            }
            final List<JSITKnowledgeRequirement> jsiKnowledgeRequirements = decision.getKnowledgeRequirement();
            for (int i = 0; i < jsiKnowledgeRequirements.size(); i++) {
                final JSITKnowledgeRequirement kr = Js.uncheckedCast(jsiKnowledgeRequirements.get(i));
                connectEdgeToNodes(KNOWLEDGE_REQ_ID, kr, kr.getRequiredKnowledge(), entriesById, diagramId, edges, isDMNDIPresent, node);
            }
            final List<JSITAuthorityRequirement> jsiAuthorityRequirements = decision.getAuthorityRequirement();
            for (int i = 0; i < jsiAuthorityRequirements.size(); i++) {
                final JSITAuthorityRequirement ar = Js.uncheckedCast(jsiAuthorityRequirements.get(i));
                connectEdgeToNodes(AUTH_REQ_ID, ar, ar.getRequiredAuthority(), entriesById, diagramId, edges, isDMNDIPresent, node);
            }
            continue;
        }
        if (JSITBusinessKnowledgeModel.instanceOf(element)) {
            final JSITBusinessKnowledgeModel bkm = Js.uncheckedCast(element);
            final List<JSITKnowledgeRequirement> jsiKnowledgeRequirements = bkm.getKnowledgeRequirement();
            for (int i = 0; i < jsiKnowledgeRequirements.size(); i++) {
                final JSITKnowledgeRequirement kr = Js.uncheckedCast(jsiKnowledgeRequirements.get(i));
                connectEdgeToNodes(KNOWLEDGE_REQ_ID, kr, kr.getRequiredKnowledge(), entriesById, diagramId, edges, isDMNDIPresent, node);
            }
            final List<JSITAuthorityRequirement> jsiAuthorityRequirements = bkm.getAuthorityRequirement();
            for (int i = 0; i < jsiAuthorityRequirements.size(); i++) {
                final JSITAuthorityRequirement ar = Js.uncheckedCast(jsiAuthorityRequirements.get(i));
                connectEdgeToNodes(AUTH_REQ_ID, ar, ar.getRequiredAuthority(), entriesById, diagramId, edges, isDMNDIPresent, node);
            }
            continue;
        }
        if (JSITKnowledgeSource.instanceOf(element)) {
            final JSITKnowledgeSource ks = Js.uncheckedCast(element);
            final List<JSITAuthorityRequirement> jsiAuthorityRequirements = ks.getAuthorityRequirement();
            for (int i = 0; i < jsiAuthorityRequirements.size(); i++) {
                final JSITAuthorityRequirement ar = Js.uncheckedCast(jsiAuthorityRequirements.get(i));
                connectEdgeToNodes(AUTH_REQ_ID, ar, ar.getRequiredInput(), entriesById, diagramId, edges, isDMNDIPresent, node);
                connectEdgeToNodes(AUTH_REQ_ID, ar, ar.getRequiredDecision(), entriesById, diagramId, edges, isDMNDIPresent, node);
                connectEdgeToNodes(AUTH_REQ_ID, ar, ar.getRequiredAuthority(), entriesById, diagramId, edges, isDMNDIPresent, node);
            }
            continue;
        }
        if (JSITDecisionService.instanceOf(element)) {
            final JSITDecisionService ds = Js.uncheckedCast(element);
            final List<JSITDMNElementReference> encapsulatedDecisions = ds.getEncapsulatedDecision();
            forEach(encapsulatedDecisions, er -> {
                final String reqInputID = getId(er);
                getNode(nodeEntry, reqInputID, entriesById).ifPresent(requiredNode -> {
                    connectDSChildEdge(node, requiredNode);
                });
            });
            final List<JSITDMNElementReference> outputDecisions = ds.getOutputDecision();
            forEach(outputDecisions, er -> {
                final String reqInputID = getId(er);
                getNode(nodeEntry, reqInputID, entriesById).ifPresent(requiredNode -> {
                    connectDSChildEdge(node, requiredNode);
                });
            });
        }
    }
    forEach(associations, association -> {
        final String sourceId = getId(association.getSourceRef());
        final String targetId = getId(association.getTargetRef());
        final List<NodeEntry> source = entriesById.get(sourceId);
        final List<NodeEntry> target = entriesById.get(targetId);
        final boolean sourcePresent = source != null && source.size() > 0;
        final boolean targetPresent = target != null && target.size() > 0;
        if (sourcePresent && targetPresent) {
            final NodeEntry sourceEntry = source.get(0);
            final NodeEntry targetEntry = target.get(0);
            final Node sourceNode = sourceEntry.getNode();
            final Node targetNode = targetEntry.getNode();
            @SuppressWarnings("unchecked") final Edge<View<Association>, ?> myEdge = (Edge<View<Association>, ?>) factoryManager.newElement(diagramId + "#" + association.getId(), ASSOCIATION_ID).asEdge();
            final ViewConnector connectionContent = (ViewConnector) myEdge.getContent();
            final Id id = new Id(association.getId());
            final Description description = new Description(association.getDescription());
            final Association definition = new Association(id, description);
            connectEdge(myEdge, sourceNode, targetNode);
            connectionContent.setDefinition(definition);
            connectionContent.setTargetConnection(MagnetConnection.Builder.atCenter(targetNode));
            connectionContent.setSourceConnection(MagnetConnection.Builder.atCenter(sourceNode));
        }
    });
}
Also used : JSITKnowledgeSource(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITKnowledgeSource) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) Node(org.kie.workbench.common.stunner.core.graph.Node) JSITDecision(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecision) JSITBusinessKnowledgeModel(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITBusinessKnowledgeModel) JSITDMNElement(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDMNElement) JSITAssociation(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITAssociation) Association(org.kie.workbench.common.dmn.api.definition.model.Association) JSITDecisionService(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionService) JSITAuthorityRequirement(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITAuthorityRequirement) List(java.util.List) ArrayList(java.util.ArrayList) JSITInformationRequirement(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationRequirement) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) JSITDMNElementReference(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDMNElementReference) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ControlPoint(org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint) JSIPoint(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint) JSITKnowledgeRequirement(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITKnowledgeRequirement) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) BindableAdapterUtils.getDefinitionId(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId) Edge(org.kie.workbench.common.stunner.core.graph.Edge) JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge)

Aggregations

Id (org.kie.workbench.common.dmn.api.property.dmn.Id)173 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)102 Test (org.junit.Test)78 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)74 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)59 Text (org.kie.workbench.common.dmn.api.property.dmn.Text)30 Node (org.kie.workbench.common.stunner.core.graph.Node)29 View (org.kie.workbench.common.stunner.core.graph.content.view.View)29 StylingSet (org.kie.workbench.common.dmn.api.property.styling.StylingSet)23 QName (javax.xml.namespace.QName)20 GeneralRectangleDimensionsSet (org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet)18 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)17 ArrayList (java.util.ArrayList)16 DMNDiagramElement (org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement)15 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)15 BindableAdapterUtils.getDefinitionId (org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId)15 InformationItemPrimary (org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary)14 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)14 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)13 List (java.util.List)11