use of org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree.Type in project drools-wb by kiegroup.
the class DMNSimulationSettingsCreationStrategy method createSimulation.
@Override
public Simulation createSimulation(Path context, String dmnFilePath) {
final FactModelTuple factModelTuple = getFactModelTuple(context, dmnFilePath);
Simulation toReturn = new Simulation();
ScesimModelDescriptor simulationDescriptor = toReturn.getScesimModelDescriptor();
simulationDescriptor.addFactMapping(FactIdentifier.INDEX.getName(), FactIdentifier.INDEX, ExpressionIdentifier.INDEX);
simulationDescriptor.addFactMapping(FactIdentifier.DESCRIPTION.getName(), FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION);
ScenarioWithIndex scenarioWithIndex = createScesimDataWithIndex(toReturn, simulationDescriptor, ScenarioWithIndex::new);
AtomicInteger id = new AtomicInteger(1);
final Collection<FactModelTree> visibleFactTrees = factModelTuple.getVisibleFacts().values();
final Map<String, FactModelTree> hiddenValues = factModelTuple.getHiddenFacts();
visibleFactTrees.stream().sorted((a, b) -> {
Type aType = a.getType();
Type bType = b.getType();
int inputFirstOrder = Type.INPUT.equals(aType) ? -1 : 1;
return aType.equals(bType) ? 0 : inputFirstOrder;
}).forEach(factModelTree -> {
FactIdentifier factIdentifier = FactIdentifier.create(factModelTree.getFactName(), factModelTree.getFactName(), factModelTree.getImportPrefix());
FactMappingExtractor factMappingExtractor = new FactMappingExtractor(factIdentifier, scenarioWithIndex.getIndex(), id, convert(factModelTree.getType()), simulationDescriptor, scenarioWithIndex.getScesimData());
addFactMapping(factMappingExtractor, factModelTree, new ArrayList<>(), hiddenValues);
});
addEmptyColumnsIfNeeded(toReturn, scenarioWithIndex);
return toReturn;
}
Aggregations