Search in sources :

Example 1 with Type

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;
}
Also used : ScesimModelDescriptor(org.drools.scenariosimulation.api.model.ScesimModelDescriptor) ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) FactModelTuple(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple) FactIdentifier(org.drools.scenariosimulation.api.model.FactIdentifier) GIVEN(org.drools.scenariosimulation.api.model.FactMappingType.GIVEN) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ExpressionIdentifier(org.drools.scenariosimulation.api.model.ExpressionIdentifier) Type(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree.Type) VALUE(org.drools.scenariosimulation.api.utils.ConstantsHolder.VALUE) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ScenarioSimulationSharedUtils(org.drools.scenariosimulation.api.utils.ScenarioSimulationSharedUtils) DMNTypeService(org.drools.workbench.screens.scenariosimulation.service.DMNTypeService) Map(java.util.Map) ScesimModelDescriptor(org.drools.scenariosimulation.api.model.ScesimModelDescriptor) Path(org.uberfire.backend.vfs.Path) ScenarioWithIndex(org.drools.scenariosimulation.api.model.ScenarioWithIndex) Collection(java.util.Collection) Settings(org.drools.scenariosimulation.api.model.Settings) Set(java.util.Set) FactMappingType(org.drools.scenariosimulation.api.model.FactMappingType) List(java.util.List) FactMapping(org.drools.scenariosimulation.api.model.FactMapping) Simulation(org.drools.scenariosimulation.api.model.Simulation) ApplicationScoped(javax.enterprise.context.ApplicationScoped) EXPECT(org.drools.scenariosimulation.api.model.FactMappingType.EXPECT) AbstractScesimData(org.drools.scenariosimulation.api.model.AbstractScesimData) FactModelTuple(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple) FactIdentifier(org.drools.scenariosimulation.api.model.FactIdentifier) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) Type(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree.Type) FactMappingType(org.drools.scenariosimulation.api.model.FactMappingType) Simulation(org.drools.scenariosimulation.api.model.Simulation) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ScenarioWithIndex(org.drools.scenariosimulation.api.model.ScenarioWithIndex)

Aggregations

ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Inject (javax.inject.Inject)1 AbstractScesimData (org.drools.scenariosimulation.api.model.AbstractScesimData)1 ExpressionIdentifier (org.drools.scenariosimulation.api.model.ExpressionIdentifier)1 FactIdentifier (org.drools.scenariosimulation.api.model.FactIdentifier)1 FactMapping (org.drools.scenariosimulation.api.model.FactMapping)1 FactMappingType (org.drools.scenariosimulation.api.model.FactMappingType)1 EXPECT (org.drools.scenariosimulation.api.model.FactMappingType.EXPECT)1 GIVEN (org.drools.scenariosimulation.api.model.FactMappingType.GIVEN)1 ScenarioSimulationModel (org.drools.scenariosimulation.api.model.ScenarioSimulationModel)1 ScenarioWithIndex (org.drools.scenariosimulation.api.model.ScenarioWithIndex)1 ScesimModelDescriptor (org.drools.scenariosimulation.api.model.ScesimModelDescriptor)1 Settings (org.drools.scenariosimulation.api.model.Settings)1