Search in sources :

Example 1 with ItemDefinition

use of org.eclipse.bpmn2.ItemDefinition in project drools by kiegroup.

the class ItemDefinitionDependenciesSorter method sort.

/**
 * Return a new list of ItemDefinition sorted by dependencies (required dependencies comes first)
 */
public List<ItemDefinition> sort(List<ItemDefinition> ins) {
    // In a graph A -> B -> {C, D}
    // showing that A requires B, and B requires C,D
    // then a depth-first visit would satisfy required ordering, for example a valid depth first visit is also a valid sort here: C, D, B, A.
    Collection<ItemDefinition> visited = new ArrayList<>(ins.size());
    List<ItemDefinition> dfv = new ArrayList<>(ins.size());
    for (ItemDefinition node : ins) {
        if (!visited.contains(node)) {
            dfVisit(node, ins, visited, dfv);
        }
    }
    return dfv;
}
Also used : ItemDefinition(org.kie.dmn.model.v1_1.ItemDefinition) ArrayList(java.util.ArrayList)

Example 2 with ItemDefinition

use of org.eclipse.bpmn2.ItemDefinition in project drools by kiegroup.

the class ItemDefinitionDependenciesSorter method displayDependencies.

public static void displayDependencies(List<ItemDefinition> ins, String namespaceURI) {
    for (ItemDefinition in : ins) {
        System.out.println(in.getName());
        List<ItemDefinition> others = new ArrayList<>(ins);
        others.remove(in);
        for (ItemDefinition other : others) {
            QName otherQName = new QName(namespaceURI, other.getName());
            if (directFind(in, otherQName)) {
                System.out.println(" direct depends on: " + other.getName());
            } else if (recurseFind(in, otherQName)) {
                System.out.println(" indir. depends on: " + other.getName());
            }
        }
    }
}
Also used : QName(javax.xml.namespace.QName) ItemDefinition(org.kie.dmn.model.v1_1.ItemDefinition) ArrayList(java.util.ArrayList)

Example 3 with ItemDefinition

use of org.eclipse.bpmn2.ItemDefinition in project drools by kiegroup.

the class ItemDefinitionDependenciesSorter method dfVisit.

/**
 * Performs a depth first visit, but keeping a separate reference of visited/visiting nodes, _also_ to avoid potential issues of circularities.
 */
private void dfVisit(ItemDefinition node, List<ItemDefinition> allNodes, Collection<ItemDefinition> visited, List<ItemDefinition> dfv) {
    visited.add(node);
    List<ItemDefinition> neighbours = allNodes.stream().filter(// filter out `node`
    n -> !n.getName().equals(node.getName())).filter(// I pick from allNodes, those referenced by this `node`. Only neighbours of `node`, because N is referenced by NODE.
    n -> recurseFind(node, new QName(modelNamespace, n.getName()))).collect(Collectors.toList());
    for (ItemDefinition n : neighbours) {
        if (!visited.contains(n)) {
            dfVisit(n, allNodes, visited, dfv);
        }
    }
    dfv.add(node);
}
Also used : List(java.util.List) Collection(java.util.Collection) QName(javax.xml.namespace.QName) ItemDefinition(org.kie.dmn.model.v1_1.ItemDefinition) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) QName(javax.xml.namespace.QName) ItemDefinition(org.kie.dmn.model.v1_1.ItemDefinition)

Example 4 with ItemDefinition

use of org.eclipse.bpmn2.ItemDefinition in project drools by kiegroup.

the class ItemDefinitionConverter method assignAttributes.

@Override
protected void assignAttributes(HierarchicalStreamReader reader, Object parent) {
    super.assignAttributes(reader, parent);
    ItemDefinition id = (ItemDefinition) parent;
    String typeLanguage = reader.getAttribute(TYPE_LANGUAGE);
    String isCollectionValue = reader.getAttribute(IS_COLLECTION);
    id.setTypeLanguage(typeLanguage);
    id.setIsCollection(Boolean.valueOf(isCollectionValue));
}
Also used : ItemDefinition(org.kie.dmn.model.v1_1.ItemDefinition)

Example 5 with ItemDefinition

use of org.eclipse.bpmn2.ItemDefinition in project drools by kiegroup.

the class ItemDefinitionConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    ItemDefinition id = (ItemDefinition) parent;
    if (id.getTypeRef() != null)
        writeChildrenNode(writer, context, id.getTypeRef(), TYPE_REF);
    if (id.getAllowedValues() != null)
        writeChildrenNode(writer, context, id.getAllowedValues(), ALLOWED_VALUES);
    for (ItemDefinition ic : id.getItemComponent()) {
        writeChildrenNode(writer, context, ic, ITEM_COMPONENT);
    }
}
Also used : ItemDefinition(org.kie.dmn.model.v1_1.ItemDefinition)

Aggregations

ItemDefinition (org.kie.dmn.model.v1_1.ItemDefinition)22 ItemDefinition (org.eclipse.bpmn2.ItemDefinition)21 ArrayList (java.util.ArrayList)17 RootElement (org.eclipse.bpmn2.RootElement)17 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)13 Process (org.eclipse.bpmn2.Process)13 SubProcess (org.eclipse.bpmn2.SubProcess)13 Entry (java.util.Map.Entry)11 FlowElement (org.eclipse.bpmn2.FlowElement)11 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)11 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)11 Message (org.eclipse.bpmn2.Message)10 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)9 Test (org.junit.Test)9 List (java.util.List)8 CallActivity (org.eclipse.bpmn2.CallActivity)7 DataInput (org.eclipse.bpmn2.DataInput)7 QName (javax.xml.namespace.QName)6 Activity (org.eclipse.bpmn2.Activity)6 DataOutput (org.eclipse.bpmn2.DataOutput)6