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;
}
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());
}
}
}
}
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);
}
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));
}
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);
}
}
Aggregations