use of org.kie.workbench.common.dmn.api.definition.v1_1.ItemDefinition in project drools by kiegroup.
the class DMNCompilerImpl method processItemDefinitions.
private void processItemDefinitions(DMNCompilerContext ctx, DMNFEELHelper feel, DMNModelImpl model, Definitions dmndefs) {
Definitions.normalize(dmndefs);
List<ItemDefinition> ordered = new ItemDefinitionDependenciesSorter(model.getNamespace()).sort(dmndefs.getItemDefinition());
for (ItemDefinition id : ordered) {
ItemDefNodeImpl idn = new ItemDefNodeImpl(id);
DMNType type = buildTypeDef(ctx, feel, model, idn, id, true);
idn.setType(type);
model.addItemDefinition(idn);
}
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.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 (ItemDefinition dependency : dependencies) {
if (!usedNames.contains(dependency.getName())) {
createAndAddDependency(itemDefinition, dependency);
usedNames.add(dependency.getName());
addedDepsCount++;
if (addedDepsCount == numberOfDeps) {
return;
}
}
}
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.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 ItemDefinition();
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;
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.ItemDefinition in project drools by kiegroup.
the class ItemDefinitionDependenciesTest method build.
private ItemDefinition build(String name, ItemDefinition... components) {
ItemDefinition res = new ItemDefinition();
res.setName(name);
for (ItemDefinition ic : components) {
ItemDefinition c = new ItemDefinition();
c.setName("_" + name + "-" + ic.getName());
c.setTypeRef(new QName(TEST_NS, ic.getName()));
res.getItemComponent().add(c);
}
return res;
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.ItemDefinition in project drools by kiegroup.
the class ItemDefinitionDependenciesTest method testOrdering1.
@Test
public void testOrdering1() {
ItemDefinition tCollateralRiskCategory = build("tCollateralRiskCategory");
ItemDefinition tCreditRiskCategory = build("tCreditRiskCategory");
ItemDefinition tAffordabilityCategory = build("tAffordabilityCategory");
ItemDefinition tLoanRecommendation = build("tLoanRecommendation");
ItemDefinition tLoan = build("tLoan");
ItemDefinition tAge = build("tAge");
ItemDefinition temploementStatus = build("temploementStatus");
ItemDefinition tCreditScore = build("tCreditScore");
ItemDefinition tRiskCategory = build("tRiskCategory");
ItemDefinition tIncomeRisk = build("tIncomeRisk");
ItemDefinition tBorrowe = build("tBorrowe", tAge, temploementStatus);
ItemDefinition tPrequalification = build("tPrequalification");
List<ItemDefinition> originalList = Arrays.asList(new ItemDefinition[] { tCollateralRiskCategory, tCreditRiskCategory, tAffordabilityCategory, tLoanRecommendation, tLoan, tAge, temploementStatus, tCreditScore, tRiskCategory, tIncomeRisk, tBorrowe, tPrequalification });
List<ItemDefinition> orderedList = orderingStrategy(originalList);
assertTrue("Index of tAge < tBorrowe", orderedList.indexOf(tAge) < orderedList.indexOf(tBorrowe));
assertTrue("Index of temploementStatus < tBorrowe", orderedList.indexOf(temploementStatus) < orderedList.indexOf(tBorrowe));
}
Aggregations