Ejemplo n.º 1
0
 public DBOutputWriter(Scenario scenario) {
   super(scenario);
   try {
     db_scenario = ScenariosPeer.retrieveByPK(str2id(scenario.getId()));
   } catch (NoRowsException exc) {
     logger.error("Scenario " + str2id(scenario.getId()) + " was not found in the database");
   } catch (TooManyRowsException exc) {
     logger.error("Data integrity violation", exc);
   } catch (TorqueException exc) {
     logger.error("Could not load scenario " + str2id(scenario.getId()), exc);
   }
   db_vehicle_type = new VehicleTypes[scenario.getNumVehicleTypes()];
   if (null != db_scenario) {
     logger.info("Loading vehicle types");
     Criteria crit = new Criteria();
     crit.addJoin(VehicleTypesPeer.VEHICLE_TYPE_ID, VehicleTypesInSetsPeer.VEHICLE_TYPE_ID);
     crit.add(VehicleTypesInSetsPeer.VEHICLE_TYPE_SET_ID, db_scenario.getVehicleTypeSetId());
     try {
       @SuppressWarnings("unchecked")
       List<VehicleTypes> db_vt_l = VehicleTypesPeer.doSelect(crit);
       for (VehicleTypes db_vt : db_vt_l)
         for (int i = 0; i < scenario.getNumVehicleTypes(); ++i)
           if (db_vt.getName().equals(scenario.getVehicleTypeNames()[i]))
             db_vehicle_type[i] = db_vt;
     } catch (TorqueException exc) {
       logger.error("Failed to load vehicle types for scenario " + db_scenario.getId(), exc);
     }
   }
 }
Ejemplo n.º 2
0
 private com.relteq.sirius.simulator.Scenario restore(long id) throws SiriusException {
   com.relteq.sirius.db.Service.ensureInit();
   Scenarios db_scenario = null;
   try {
     db_scenario = ScenariosPeer.retrieveByPK(id);
   } catch (NoRowsException exc) {
     throw new SiriusException("Scenario " + id + " does not exist", exc);
   } catch (TorqueException exc) {
     throw new SiriusException(exc);
   }
   return (com.relteq.sirius.simulator.Scenario) restoreScenario(db_scenario);
 }