Search in sources :

Example 11 with Association

use of org.kie.workbench.common.dmn.api.definition.v1_1.Association in project kie-wb-common by kiegroup.

the class DMNMarshaller method marshall.

@Override
public String marshall(final Diagram<Graph, Metadata> diagram) throws IOException {
    Graph<?, Node<View, ?>> g = diagram.getGraph();
    Map<String, org.kie.dmn.model.v1_1.DRGElement> nodes = new HashMap<>();
    Map<String, org.kie.dmn.model.v1_1.TextAnnotation> textAnnotations = new HashMap<>();
    @SuppressWarnings("unchecked") Node<View<DMNDiagram>, ?> dmnDiagramRoot = (Node<View<DMNDiagram>, ?>) findDMNDiagramRoot(g);
    Definitions definitionsStunnerPojo = dmnDiagramRoot.getContent().getDefinition().getDefinitions();
    org.kie.dmn.model.v1_1.Definitions definitions = DefinitionsConverter.dmnFromWB(definitionsStunnerPojo);
    if (definitions.getExtensionElements() == null) {
        definitions.setExtensionElements(new org.kie.dmn.model.v1_1.Definitions.ExtensionElements());
    }
    org.kie.workbench.common.dmn.backend.definition.v1_1.dd.DMNDiagram dmnDDDMNDiagram = new org.kie.workbench.common.dmn.backend.definition.v1_1.dd.DMNDiagram();
    definitions.getExtensionElements().getAny().add(dmnDDDMNDiagram);
    for (Node<?, ?> node : g.nodes()) {
        if (node.getContent() instanceof View<?>) {
            View<?> view = (View<?>) node.getContent();
            if (view.getDefinition() instanceof DRGElement) {
                DRGElement n = (org.kie.workbench.common.dmn.api.definition.v1_1.DRGElement) view.getDefinition();
                nodes.put(n.getId().getValue(), stunnerToDMN(node));
                dmnDDDMNDiagram.getAny().add(stunnerToDDExt((View<? extends DMNElement>) view));
            } else if (view.getDefinition() instanceof TextAnnotation) {
                TextAnnotation textAnnotation = (TextAnnotation) view.getDefinition();
                textAnnotations.put(textAnnotation.getId().getValue(), textAnnotationConverter.dmnFromNode((Node<View<TextAnnotation>, ?>) node));
                dmnDDDMNDiagram.getAny().add(stunnerToDDExt((View<? extends DMNElement>) view));
                List<org.kie.dmn.model.v1_1.Association> associations = AssociationConverter.dmnFromWB((Node<View<TextAnnotation>, ?>) node);
                definitions.getArtifact().addAll(associations);
            }
        }
    }
    nodes.values().forEach(definitions.getDrgElement()::add);
    textAnnotations.values().forEach(definitions.getArtifact()::add);
    String marshalled = marshaller.marshal(definitions);
    return marshalled;
}
Also used : HashMap(java.util.HashMap) Node(org.kie.workbench.common.stunner.core.graph.Node) DMNElement(org.kie.workbench.common.dmn.api.definition.v1_1.DMNElement) List(java.util.List) TextAnnotation(org.kie.workbench.common.dmn.api.definition.v1_1.TextAnnotation) DMNDiagram(org.kie.workbench.common.dmn.api.definition.v1_1.DMNDiagram) Definitions(org.kie.workbench.common.dmn.api.definition.v1_1.Definitions) View(org.kie.workbench.common.stunner.core.graph.content.view.View) DRGElement(org.kie.workbench.common.dmn.api.definition.v1_1.DRGElement)

Example 12 with Association

use of org.kie.workbench.common.dmn.api.definition.v1_1.Association in project drools by kiegroup.

the class AssociationConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    Association a = (Association) parent;
    writeChildrenNode(writer, context, a.getSourceRef(), SOURCE_REF);
    writeChildrenNode(writer, context, a.getTargetRef(), TARGET_REF);
}
Also used : Association(org.kie.dmn.model.v1_1.Association)

Example 13 with Association

use of org.kie.workbench.common.dmn.api.definition.v1_1.Association in project drools by kiegroup.

the class AssociationConverter method writeAttributes.

@Override
protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) {
    super.writeAttributes(writer, parent);
    Association a = (Association) parent;
    if (a.getAssociationDirection() != null)
        writer.addAttribute(ASSOCIATION_DIRECTION, a.getAssociationDirection().value());
}
Also used : Association(org.kie.dmn.model.v1_1.Association)

Example 14 with Association

use of org.kie.workbench.common.dmn.api.definition.v1_1.Association in project drools by kiegroup.

the class AssociationConverter method assignAttributes.

@Override
protected void assignAttributes(HierarchicalStreamReader reader, Object parent) {
    super.assignAttributes(reader, parent);
    Association a = (Association) parent;
    String associationDirectionValue = reader.getAttribute(ASSOCIATION_DIRECTION);
    if (associationDirectionValue != null)
        a.setAssociationDirection(AssociationDirection.fromValue(associationDirectionValue));
}
Also used : Association(org.kie.dmn.model.v1_1.Association)

Example 15 with Association

use of org.kie.workbench.common.dmn.api.definition.v1_1.Association in project polymap4-core by Polymap4.

the class ProjectNode method findUserSettings.

/**
 */
protected <N extends ProjectNode, U extends UserSettings> U findUserSettings(Class<U> userSettingsType, Association<N> backAssoc) {
    String username = SecurityContext.instance().getUser().getName();
    // give every instance its own UnitOfWork; so modifications can be
    // AutoCommit without interfering with the main UnitOfWork
    EntityRepository repo = context.getRepository();
    UnitOfWork uow = repo.newUnitOfWork();
    U template = Expressions.template(userSettingsType, repo);
    ResultSet<U> rs = uow.query(userSettingsType).where(and(is(backAssoc, (N) ProjectNode.this), eq(template.username, username))).maxResults(2).execute();
    assert rs.size() >= 0 || rs.size() <= 1 : "Illegal result set size: " + rs.size();
    // not found
    if (rs.size() == 0) {
        U result = uow.createEntity(userSettingsType, null, (U proto) -> {
            ProjectNode localNode = uow.entity(ProjectNode.this);
            ((Association) backAssoc.info().get(proto)).set(localNode);
            proto.username.set(username);
            return proto;
        });
        uow.commit();
        return uow.entity(result);
    } else // found
    {
        return rs.stream().findAny().get();
    }
}
Also used : UnitOfWork(org.polymap.model2.runtime.UnitOfWork) Association(org.polymap.model2.Association) EntityRepository(org.polymap.model2.runtime.EntityRepository)

Aggregations

Artifact (org.eclipse.bpmn2.Artifact)7 Association (org.eclipse.bpmn2.Association)7 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)7 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)7 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)6 SubProcess (org.eclipse.bpmn2.SubProcess)6 ArrayList (java.util.ArrayList)5 Process (org.eclipse.bpmn2.Process)5 List (java.util.List)4 DataObject (org.eclipse.bpmn2.DataObject)3 FlowElement (org.eclipse.bpmn2.FlowElement)3 SequenceFlow (org.eclipse.bpmn2.SequenceFlow)3 Association (org.kie.dmn.model.v1_1.Association)3 HashMap (java.util.HashMap)2 Entry (java.util.Map.Entry)2 BoundaryEvent (org.eclipse.bpmn2.BoundaryEvent)2 FlowNode (org.eclipse.bpmn2.FlowNode)2 Group (org.eclipse.bpmn2.Group)2 RootElement (org.eclipse.bpmn2.RootElement)2 Association (org.kie.workbench.common.dmn.api.definition.v1_1.Association)2