use of org.kie.dmn.model.api.ItemDefinition in project drools by kiegroup.
the class DefinitionsConverter method writeChildren.
@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
super.writeChildren(writer, context, parent);
Definitions def = (Definitions) parent;
for (Import i : def.getImport()) {
writeChildrenNode(writer, context, i, IMPORT);
}
for (ItemDefinition id : def.getItemDefinition()) {
writeChildrenNode(writer, context, id, ITEM_DEFINITION);
}
for (DRGElement e : def.getDrgElement()) {
String nodeName = DRG_ELEMENT;
if (e instanceof BusinessKnowledgeModel) {
nodeName = "businessKnowledgeModel";
} else if (e instanceof Decision) {
nodeName = "decision";
} else if (e instanceof InputData) {
nodeName = "inputData";
} else if (e instanceof KnowledgeSource) {
nodeName = "knowledgeSource";
} else if (e instanceof DecisionService) {
nodeName = "decisionService";
}
writeChildrenNode(writer, context, e, nodeName);
}
for (Artifact a : def.getArtifact()) {
String nodeName = ARTIFACT;
if (a instanceof Association) {
nodeName = "association";
} else if (a instanceof TextAnnotation) {
nodeName = "textAnnotation";
}
writeChildrenNode(writer, context, a, nodeName);
}
for (ElementCollection ec : def.getElementCollection()) {
writeChildrenNode(writer, context, ec, ELEMENT_COLLECTION);
}
for (BusinessContextElement bce : def.getBusinessContextElement()) {
String nodeName = BUSINESS_CONTEXT_ELEMENT;
if (bce instanceof OrganizationUnit) {
nodeName = "organizationUnit";
} else if (bce instanceof PerformanceIndicator) {
nodeName = "performanceIndicator";
}
writeChildrenNode(writer, context, bce, nodeName);
}
if (def.getDMNDI() != null) {
writeChildrenNode(writer, context, def.getDMNDI(), "DMNDI");
}
}
use of org.kie.dmn.model.api.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);
}
}
use of org.kie.dmn.model.api.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.kie.dmn.model.api.ItemDefinition in project drools by kiegroup.
the class ItemDefinitionDependenciesGeneratedTest method addDepsToItemDefinition.
private static void addDepsToItemDefinition(final ItemDefinition itemDefinition, final List<ItemDefinition> dependencies, final int numberOfDeps, final Set<String> usedNames) {
int addedDepsCount = 0;
for (final ItemDefinition dependency : dependencies) {
if (!usedNames.contains(dependency.getName())) {
createAndAddDependency(itemDefinition, dependency);
usedNames.add(dependency.getName());
addedDepsCount++;
if (addedDepsCount == numberOfDeps) {
return;
}
}
}
}
use of org.kie.dmn.model.api.ItemDefinition in project drools by kiegroup.
the class ItemDefinitionDependenciesGeneratedTest method createItemDefinitionWithDeps.
private static ItemDefinition createItemDefinitionWithDeps(final ItemDefinition itemDefinitionTemplate, final List<ItemDefinition> dependencies, final int maxNumberOfDepsPerItemDefinition, final Set<String> usedNames) {
// New ItemDefinition is created, so the original one stays untouched.
final ItemDefinition it = new TItemDefinition();
it.setName(itemDefinitionTemplate.getName());
final List<ItemDefinition> possibleDependencies = dependencies.stream().filter(item -> !item.getName().equals(it.getName())).collect(Collectors.toList());
addDepsToItemDefinition(it, possibleDependencies, maxNumberOfDepsPerItemDefinition, usedNames);
return it;
}
Aggregations