public Simulation cloneSimulation() { Simulation toReturn = new Simulation(); toReturn.getSimulationDescriptor().setType(simulationDescriptor.getType()); toReturn.getSimulationDescriptor().setDmnFilePath(simulationDescriptor.getDmnFilePath()); toReturn.getSimulationDescriptor().setDmoSession(simulationDescriptor.getDmoSession()); final List<FactMapping> originalFactMappings = this.simulationDescriptor.getUnmodifiableFactMappings(); for (int i = 0; i < originalFactMappings.size(); i++) { final FactMapping originalFactMapping = originalFactMappings.get(i); toReturn.simulationDescriptor.addFactMapping(i, originalFactMapping); } this.scenarios.forEach(scenario -> toReturn.scenarios.add(scenario.cloneScenario())); return toReturn; }
public Simulation cloneSimulation() { Simulation toReturn = new Simulation(); toReturn.getSimulationDescriptor().setType(simulationDescriptor.getType()); toReturn.getSimulationDescriptor().setDmnFilePath(simulationDescriptor.getDmnFilePath()); toReturn.getSimulationDescriptor().setDmoSession(simulationDescriptor.getDmoSession()); final List<FactMapping> originalFactMappings = this.simulationDescriptor.getUnmodifiableFactMappings(); for (int i = 0; i < originalFactMappings.size(); i++) { final FactMapping originalFactMapping = originalFactMappings.get(i); toReturn.simulationDescriptor.addFactMapping(i, originalFactMapping); } this.scenarios.forEach(scenario -> toReturn.scenarios.add(scenario.cloneScenario())); return toReturn; }
@Override public Simulation createSimulation(Path context, String dmnFilePath) throws Exception { final FactModelTuple factModelTuple = getFactModelTuple(context, dmnFilePath); Simulation toReturn = new Simulation(); SimulationDescriptor simulationDescriptor = toReturn.getSimulationDescriptor(); simulationDescriptor.setType(ScenarioSimulationModel.Type.DMN); simulationDescriptor.setDmnFilePath(dmnFilePath); Scenario scenario = createScenario(toReturn, simulationDescriptor); int row = toReturn.getUnmodifiableScenarios().indexOf(scenario); 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(); return aType.equals(bType) ? 0 : (Type.INPUT.equals(aType) ? -1 : 1); }).forEach(factModelTree -> { FactIdentifier factIdentifier = new FactIdentifier(factModelTree.getFactName(), factModelTree.getFactName()); FactMappingExtractor factMappingExtractor = new FactMappingExtractor(factIdentifier, row, id, convert(factModelTree.getType()), simulationDescriptor, scenario); addToScenario(factMappingExtractor, factModelTree, new ArrayList<>(), hiddenValues); }); return toReturn; }
switch (selectedType) { case DMN: simulationDescriptor.setDmnFilePath(value); break; case RULE: