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); } } }
private com.relteq.sirius.jaxb.VehicleType restoreVehicleType(VehicleTypes db_vt) { com.relteq.sirius.jaxb.VehicleType vt = factory.createVehicleType(); vt.setName(db_vt.getName()); vt.setWeight(db_vt.getWeight()); return vt; }