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 value) throws Exception { Simulation toReturn = new Simulation(); SimulationDescriptor simulationDescriptor = toReturn.getSimulationDescriptor(); simulationDescriptor.setType(ScenarioSimulationModel.Type.RULE); simulationDescriptor.setDmoSession(value); Scenario scenario = createScenario(toReturn, simulationDescriptor); int row = toReturn.getUnmodifiableScenarios().indexOf(scenario); // Add GIVEN Fact int id = 1; ExpressionIdentifier givenExpression = ExpressionIdentifier.create(row + "|" + id, FactMappingType.GIVEN); final FactMapping givenFactMapping = simulationDescriptor.addFactMapping(FactMapping.getInstancePlaceHolder(id), FactIdentifier.EMPTY, givenExpression); givenFactMapping.setExpressionAlias(FactMapping.getPropertyPlaceHolder(id)); scenario.addMappingValue(FactIdentifier.EMPTY, givenExpression, null); // Add EXPECT Fact id = 2; ExpressionIdentifier expectedExpression = ExpressionIdentifier.create(row + "|" + id, FactMappingType.EXPECT); final FactMapping expectedFactMapping = simulationDescriptor.addFactMapping(FactMapping.getInstancePlaceHolder(id), FactIdentifier.EMPTY, expectedExpression); expectedFactMapping.setExpressionAlias(FactMapping.getPropertyPlaceHolder(id)); scenario.addMappingValue(FactIdentifier.EMPTY, expectedExpression, null); return toReturn; } }
case RULE: default: simulationDescriptor.setDmoSession(value);