void DisplayScreenTransferDestinationAddAction::_setFromParametersMap(const ParametersMap& map) { try { _screen = DisplayScreenTableSync::GetEditable(map.get<RegistryKeyType>(PARAMETER_DISPLAY_SCREEN_ID), *_env); _transferPlace = StopAreaTableSync::Get(map.get<RegistryKeyType>(PARAMETER_TRANSFER_PLACE_ID), *_env); } catch(ObjectNotFoundException<DisplayScreen>&) { throw ActionException("Display screen not found"); } catch(ObjectNotFoundException<StopArea>&) { throw ActionException("Transfer place not found"); } const string city(map.get<string>(PARAMETER_DESTINATION_PLACE_CITY_NAME)); GeographyModule::CityList cities(GeographyModule::GuessCity(city, 1)); if(cities.empty()) { throw ActionException("City not found"); } const string place(map.get<string>(PARAMETER_DESTINATION_PLACE_NAME)); vector<boost::shared_ptr<StopArea> > stops( cities.front()->search<StopArea>(place, 1) ); if(stops.empty()) { throw ActionException("Place not found"); } _destinationPlace = stops.front().get(); }
void StopAreaTransferAddAction::_setFromParametersMap(const ParametersMap& map) { try { _from = StopPointTableSync::Get(map.get<RegistryKeyType>(PARAMETER_FROM_ID), *_env); } catch(ObjectNotFoundException<StopPoint>&) { throw ActionException("No such from stop point"); } try { _to = StopPointTableSync::Get(map.get<RegistryKeyType>(PARAMETER_TO_ID), *_env); } catch(ObjectNotFoundException<StopPoint>&) { throw ActionException("No such to stop point"); } if(_from->getConnectionPlace() != _to->getConnectionPlace()) { throw ActionException("Internal transfers must concern two stops within the same stop area."); } if(map.get<string>(PARAMETER_DURATION) != StopAreaTableSync::FORBIDDEN_DELAY_SYMBOL) { _duration = minutes(map.get<long>(PARAMETER_DURATION)); } }
void HikingTrailStopAddAction::_setFromParametersMap(const ParametersMap& map) { try { _trail = HikingTrailTableSync::GetEditable(map.get<RegistryKeyType>(PARAMETER_TRAIL_ID), *_env); } catch(ObjectNotFoundException<HikingTrail>&) { throw ActionException("No such trail"); } const string city(map.get<string>(PARAMETER_CITY)); GeographyModule::CityList cities(GeographyModule::GuessCity(city, 1)); if(cities.empty()) { throw ActionException("City not found"); } const string place(map.get<string>(PARAMETER_NAME)); vector<boost::shared_ptr<StopArea> > stops( cities.front()->search<StopArea>(place, 1) ); if(stops.empty()) { throw ActionException("Place not found"); } _stop = StopAreaTableSync::GetEditable(stops.front()->getKey(), *_env); _rank = map.getOptional<size_t>(PARAMETER_RANK); if(_rank && *_rank > _trail->getStops().size()) { throw ActionException("Rank is too high"); } }
void ContinuousServiceUpdateAction::_setFromParametersMap(const ParametersMap& map) { try { _service = ContinuousServiceTableSync::GetEditable(map.get<RegistryKeyType>(PARAMETER_SERVICE_ID), *_env); } catch(ObjectNotFoundException<ContinuousService>&) { throw ActionException("No such service"); } _duration = minutes(map.get<int>(PARAMETER_WAITING_DURATION)); time_duration endTime(not_a_date_time); if(!map.getDefault<string>(PARAMETER_END_TIME).empty()) { try { endTime = duration_from_string(map.get<string>(PARAMETER_END_TIME)); } catch(bad_lexical_cast) { throw ActionException("Bad end time"); } } time_duration startTime(_service->getDepartureSchedule(false, 0)); _range = endTime - startTime; }
void JunctionUpdateAction::_setFromParametersMap(const ParametersMap& map) { if(map.isDefined(PARAMETER_JUNCTION_ID)) { try { _junction = JunctionTableSync::GetEditable(map.get<RegistryKeyType>(PARAMETER_JUNCTION_ID), *_env); } catch (ObjectNotFoundException<Junction>&) { throw ActionException("No such junction"); } } else { _junction = boost::shared_ptr<Junction>(new Junction); } if(map.isDefined(PARAMETER_FROM_ID)) { try { _from = StopPointTableSync::GetEditable(map.get<RegistryKeyType>(PARAMETER_FROM_ID), *_env); } catch(ObjectNotFoundException<StopPoint>&) { throw ActionException("No such from stop point"); } } if(map.isDefined(PARAMETER_TO_ID)) { try { _to = StopPointTableSync::GetEditable(map.get<RegistryKeyType>(PARAMETER_TO_ID), *_env); } catch(ObjectNotFoundException<StopPoint>&) { throw ActionException("No such to stop point"); } } if(map.isDefined(PARAMETER_LENGTH)) { _length = map.get<double>(PARAMETER_LENGTH); } if(map.isDefined(PARAMETER_TIME)) { _duration = minutes(map.get<long>(PARAMETER_TIME)); } if(map.isDefined(PARAMETER_BIDIRECTIONAL)) { _bidirectional = map.getDefault<bool>(PARAMETER_BIDIRECTIONAL); } }
void JointActionsMap::remove(unsigned int factorIndex, Action *removeAction) { if (factorIndex < 0 || factorIndex >= factoredActions.size()) { throw ActionException(); } else if (std::find(factoredActions[factorIndex].begin(), factoredActions[factorIndex].end(), removeAction) == factoredActions[factorIndex].end()) { throw ActionException(); } factoredActions[factorIndex].erase( std::remove(factoredActions[factorIndex].begin(), factoredActions[factorIndex].end(), removeAction), factoredActions[factorIndex].end()); delete removeAction; }
void ServiceTimetableUpdateAction::run( Request& request ){ size_t rank(static_cast<JourneyPattern*>(_service->getPath())->getRankInDefinedSchedulesVector(_rank)); _service->regenerateDataSchedules(); // Useful in case of corrupted data SchedulesBasedService::Schedules departureSchedules(_service->getDataDepartureSchedules()); SchedulesBasedService::Schedules arrivalSchedules(_service->getDataArrivalSchedules()); if(!_shifting_delay.is_not_a_date_time()) { for(SchedulesBasedService::Schedules::iterator it(departureSchedules.begin() + rank); it != departureSchedules.end(); ++it) { *it += _shifting_delay; } for(SchedulesBasedService::Schedules::iterator it(arrivalSchedules.begin() + rank + (_updateArrival ? 0 : 1)); it != arrivalSchedules.end(); ++it) { *it += _shifting_delay; } } else { if(_updateArrival) { if(rank >= arrivalSchedules.size()) { throw ActionException("Bad schedules size"); } arrivalSchedules[rank] = _time; } else { if(rank >= departureSchedules.size()) { throw ActionException("Bad schedules size"); } departureSchedules[rank] = _time; } } _service->setDataSchedules(departureSchedules, arrivalSchedules); DBModule::SaveObject(*_service); // Saving the rank in the session variables request.getSession()->setSessionVariable(ServiceAdmin::SESSION_VARIABLE_SERVICE_ADMIN_ID, lexical_cast<string>(_service->getKey())); request.getSession()->setSessionVariable(ServiceAdmin::SESSION_VARIABLE_SERVICE_ADMIN_SCHEDULE_RANK, lexical_cast<string>(_rank)); // ::AddUpdateEntry(*_object, text.str(), request.getUser().get()); }
void TimetableRowGroupItemAddAction::_setFromParametersMap(const ParametersMap& map) { // Rank _rank = map.get<size_t>(PARAMETER_RANK); // Place PlacesListService placesListService; placesListService.setNumber(1); placesListService.setText(map.getDefault<string>(PARAMETER_PLACE_NAME)); placesListService.setCoordinatesSystem(&CoordinatesSystem::GetInstanceCoordinatesSystem()); placesListService.setClassFilter(PlacesListService::DATA_STOP); _stopArea = dynamic_pointer_cast<StopArea, Place>( placesListService.getPlaceFromBestResult( placesListService.runWithoutOutput() ).value ); // Row group try { _rowGroup = TimetableRowGroupTableSync::GetEditable( map.get<RegistryKeyType>(PARAMETER_ROWGROUP_ID), *_env ); } catch(ObjectNotFoundException<TimetableRowGroup>&) { throw ActionException("No such row group"); } }
void JsonPlugin::ExportItem(PluginPanelItem& item, PCTSTR filename, bool bAppend) { GenericValue<DocType>::MemberIterator obj; if(_tcscmp(item.FileName, _T("..")) && curObject->IsObject()) { obj = curObject->FindMember((PCWSTR)WideFromOem(item.FileName)); if (obj == curObject->MemberEnd()) throw ActionException(); } FILE* f = _tfopen(filename, bAppend ? _T("a") : _T("w")); if(f == NULL) throw WinExcept(); char buf[1000]; FileWriteStream fstream(f, buf, sizeof buf); typedef AutoUTFOutputStream<unsigned, FileWriteStream> OutputStream; OutputStream os(fstream, sourceUTFType, /*bSourceHasBOM*/true); if(bAppend) fstream.Put('\n'); auto value = (_tcscmp(item.FileName, _T("..")) ? (curObject->IsObject() ? &obj->value : &(*curObject)[_ttoi(item.FileName)]) : curObject); if(sourceUTFType == kUTF8) value->Accept(PrettyWriter<OutputStream, DocType, UTF8 <>>(os)); else value->Accept(PrettyWriter<OutputStream, DocType, UTF16<>>(os)); fstream.Flush(); fclose(f); }
void HikingTrailStopRemoveAction::_setFromParametersMap(const ParametersMap& map) { try { _trail = HikingTrailTableSync::GetEditable(map.get<RegistryKeyType>(PARAMETER_TRAIL_ID), *_env); } catch(ObjectNotFoundException<HikingTrail>&) { throw ActionException("No such trail"); } _rank = map.get<size_t>(PARAMETER_RANK); if(_rank >= _trail->getStops().size()) { throw ActionException("Rank is too high"); } }
void JointActionsMap::add(unsigned int factorIndex, Action *newAction) { if (factorIndex < 0 || factorIndex >= factoredActions.size()) { throw ActionException(); } factoredActions[factorIndex].push_back(newAction); }
Action *JointActionsMap::get(unsigned int factorIndex, unsigned int actionIndex) { if (factorIndex < 0 || factorIndex >= factoredActions.size() || actionIndex < 0 || actionIndex >= factoredActions[factorIndex].size()) { throw ActionException(); } return factoredActions[factorIndex][actionIndex]; }
Action &IndexedAction::operator=(const Action &other) { const IndexedAction *s = dynamic_cast<const IndexedAction*>(&other); if (s == nullptr) { throw ActionException(); } index = s->get_index(); return *this; }
Action &NamedAction::operator=(const Action &other) { const NamedAction *a = dynamic_cast<const NamedAction*>(&other); if (a == nullptr) { throw ActionException(); } name = a->get_name(); return *this; }
void FreeDRTAreaUpdateAction::_setFromParametersMap(const ParametersMap& map) { if(map.getOptional<RegistryKeyType>(PARAMETER_AREA_ID)) try { _area = FreeDRTAreaTableSync::GetEditable(map.get<RegistryKeyType>(PARAMETER_AREA_ID), *_env); } catch (ObjectNotFoundException<FreeDRTArea>&) { throw ActionException("No such area"); } else { _area.reset(new FreeDRTArea); } if(map.isDefined(PARAMETER_NAME)) { _name = map.get<string>(PARAMETER_NAME); } if(map.isDefined(PARAMETER_CITIES)) { _cities = FreeDRTAreaTableSync::UnserializeCities(map.get<string>(PARAMETER_CITIES), *_env); } if(map.isDefined(PARAMETER_STOP_AREAS)) { _stopAreas = FreeDRTAreaTableSync::UnserializeStopAreas(map.get<string>(PARAMETER_STOP_AREAS), *_env); } if(map.getDefault<RegistryKeyType>(PARAMETER_COMMERCIAL_LINE_ID, 0)) { try { _line = CommercialLineTableSync::GetEditable(map.get<RegistryKeyType>(PARAMETER_COMMERCIAL_LINE_ID), *_env); } catch (ObjectNotFoundException<CommercialLine>&) { throw ActionException("No such line"); } } }
void TimetableSetPhysicalStopAction::_setFromParametersMap(const ParametersMap& map) { try { _timetable = TimetableTableSync::GetEditable(map.get<RegistryKeyType>(PARAMETER_TIMETABLE_ID), *_env); } catch(ObjectNotFoundException<Timetable>& e) { throw ActionException("No such timetable", e, *this); } try { _physicalStop = Env::GetOfficialEnv().get<StopPoint>(map.get<RegistryKeyType>(PARAMETER_PHYSICAL_STOP_ID)); } catch(ObjectNotFoundException<StopPoint>& e) { throw ActionException("No such physical stop", e, *this); } }
void AlarmAddLinkAction::setAlarmId(RegistryKeyType id) { try { _alarm = AlarmTableSync::GetEditable(id, *_env); } catch (ObjectNotFoundException<Alarm>) { throw ActionException("Specified alarm not found"); } }
void DBLogPurgeAction::setDBLog( const std::string& value ) { try { _dbLog.reset(Factory<DBLog>::create(value)); } catch(FactoryException<DBLog> e) { throw ActionException(e.getMessage()); } }
void CalendarTemplateCleanAction::_setFromParametersMap(const ParametersMap& map) { try { _calendar = CalendarTemplateTableSync::Get(map.get<RegistryKeyType>(PARAMETER_CALENDAR_ID), *_env); } catch(ObjectNotFoundException<CalendarTemplate>&) { throw ActionException("No such calendar"); } }
void DisplayScreenRemovePhysicalStopAction::setStopId( RegistryKeyType id ){ try { _stop = StopPointTableSync::Get(id, *_env, UP_LINKS_LOAD_LEVEL); } catch (ObjectNotFoundException<StopPoint>& e) { throw ActionException("Departure physical stop", e, *this); } }
void DisplayScreenAddDisplayedPlaceAction::_setFromParametersMap(const ParametersMap& map) { try { _screen = DisplayScreenTableSync::GetEditable( map.get<RegistryKeyType>(PARAMETER_SCREEN_ID), *_env ); RegistryKeyType id(map.getDefault<RegistryKeyType>(PARAMETER_PLACE, 0)); if(id > 0) { _place = StopAreaTableSync::Get(id, *_env); } else { const string city(map.get<string>(PARAMETER_CITY_NAME)); GeographyModule::CityList cities(GeographyModule::GuessCity(city, 1)); if(cities.empty()) { throw ActionException("City not found"); } const string place(map.get<string>(PARAMETER_PLACE_NAME)); vector<boost::shared_ptr<StopArea> > stops( cities.front()->search<StopArea>(place, 1) ); if(stops.empty()) { throw ActionException("Place not found"); } _place = stops.front(); } } catch (ObjectNotFoundException<DisplayScreen>&) { throw ActionException("Display screen not found"); } }
void UpdateProfileAction::_setFromParametersMap(const ParametersMap& map) { // Profile try { _profile = ProfileTableSync::GetEditable( map.get<RegistryKeyType>(PARAMETER_PROFILE_ID), *_env ); } catch (ObjectNotFoundException<Profile>& e) { throw ActionException(e.getMessage()); } // Name _name = map.get<string>(PARAMETER_NAME); Env env; ProfileTableSync::Search(env, _name, string(), 0,1); if (!env.getRegistry<Profile>().empty()) throw ActionException("Le nom choisi est déjà pris par un autre profil. Veuillez entrer un autre nom."); }
void DBLogPurgeAction::_setFromParametersMap(const ParametersMap& map) { setDBLog(map.get<string>(PARAMETER_LOG_KEY)); try { _endDate = time_from_string(map.get<string>(PARAMETER_END_DATE)); } catch (...) { throw ActionException("Bad date"); } }
void InterSYNTHESEPackageAutoLockAction::_setFromParametersMap(const ParametersMap& map) { // Package try { _package = Env::GetOfficialEnv().getEditable<InterSYNTHESEPackage>( map.get<RegistryKeyType>(PARAMETER_PACKAGE_ID) ).get(); } catch (ObjectNotFoundException<InterSYNTHESEPackage>&) { throw ActionException("Bad package"); } // Mutex _lockMutex.reset(new mutex::scoped_lock(_package->getLockMutex())); // Lock value _lock = map.get<bool>(PARAMETER_LOCK); // Check if the package status is compatible with the action if(_lock) { // Check if the package is not already locked if(!_package->get<LockTime>().is_not_a_date_time()) { throw ActionException("The package is already locked"); } } else { // Check if the package is already locked on the current server if(!_package->get<LockServerName>().empty()) { throw ActionException("The package is locked on an other server"); } } }
void UserPasswordUpdateAction::_setFromParametersMap(const ParametersMap& map) { try { _user = UserTableSync::GetEditable( map.get<RegistryKeyType>(PARAMETER_USER_ID), *_env ); _password = map.get<string>(PARAMETER_PASS1, false); string pass2(map.getDefault<string>(PARAMETER_PASS2, string(), false)); if (pass2 != _password) throw ActionException("Les mots de passe entrés ne sont pas identiques"); if(_password.empty()) throw ActionException("Le mot de passe ne peut pas être vide"); } catch (ObjectNotFoundException<User>) { throw ActionException("Utilisateur introuvable"); } }
void JointActionsMap::set(unsigned int factorIndex, const std::vector<Action *> &newActions) { if (factorIndex < 0 || factorIndex >= factoredActions.size() || newActions.size() == 0) { throw ActionException(); } // Delete the current factor's actions list. for (Action *action : factoredActions[factorIndex]) { delete action; } factoredActions[factorIndex].clear(); factoredActions[factorIndex] = newActions; }
void GenerateContinuousServiceAction::_setFromParametersMap(const ParametersMap& map) { try { _line = CommercialLineTableSync::GetEditable(map.get<RegistryKeyType>(PARAMETER_LINE), *_env); } catch(ObjectNotFoundException<CommercialLine>&) { throw ActionException("No such line"); } _waitingTime = minutes(map.get<int>(PARAMETER_WAITING_TIME)); _minNumber = map.get<size_t>(PARAMETER_MIN_NUMBER); }
void MySQLDBModifiedAction::run(Request& request) throw(ActionException) { Log::GetInstance().debug( "MySQLDBModifiedAction::run. " " table: " + _table + " type: " + lexical_cast<string>(_type) + " id: " + lexical_cast<string>(_id) ); MySQLDB* db = dynamic_cast<MySQLDB*>(DBModule::GetDB()); if (!db) { throw ActionException("No MySQL database loaded"); } try { db->addDBModifEvent(_table, _type, _id); } catch(MySQLException& e) { throw ActionException(e.getMessage()); } }
void JointActionsMap::update() { // Throw an error if one factor is not defined. for (std::vector<Action *> &factor : factoredActions) { if (factor.size() == 0) { throw ActionException(); } } actions.clear(); std::vector<Action *> create; update_step(create, 0); }
void UserPasswordRecoveryAction::_setFromParametersMap(const ParametersMap& map ) { try { _login = map.get<string>(PARAMETER_LOGIN); _mail = map.get<string>(PARAMETER_MAIL); setPasswordRecoveryEMailCMS( Env::GetOfficialEnv().get<cms::Webpage>(map.get<RegistryKeyType>(PARAMETER_CMS)) ); } catch(ParametersMap::MissingParameterException e) { throw ActionException(e, *this); } }