1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
void OracleCalendarRepository::LoadCalendars() {
LOG4CXX_DEBUG(OracleCalendarRepository::logger, _T("+LoadCalendars"));
// Bouml preserved body begin 0001FA03
isDb("OracleCalendarRepository");
try {
otl_stream selectCalendars (50, "select NAME_, IDCALENDAR_ from CALENDARS order by NAME_ ASC", *db);
int idcalendar;
std::string name;
while (!selectCalendars.eof()) {
boost::mutex::scoped_lock
lock(loadCalendarsMutex);
selectCalendars >> name >> idcalendar;
Calendar* calendar = LoadCalendar(idcalendar); //Chargement de mon calendrier.
Calendar::insert(name, calendar);
}
}
catch (otl_exception& p){ // intercept OTL exceptions
std::string strErr = formatOracleError(p);
LOG4CXX_ERROR(OracleCalendarRepository::logger, strErr);
support::exception::dao::DataRetrievalFailureDaoException exptErr(strErr);
throw exptErr;
}
// Bouml preserved body end 0001FA03
LOG4CXX_DEBUG(OracleCalendarRepository::logger, _T("-LoadCalendars"));
}
/**
* Load a single calendar from the Oracle database
* @param the id of the calendar in the database
*/
void LoadCalendar(int id) {
LOG4CXX_DEBUG(OracleCalendarRepository::logger, _T("+LoadCalendar"));
// Bouml preserved body begin 0001FA83
isDb("OracleCalendarRepository");
Calendar* calendar = NULL;
try {
otl_stream selectCalendars (100, "select TO_CHAR(DATE_, \'YYYYMMDD\"T\"HH24MISS\'), EVENT_ from DATES where IDCALENDAR_ = :f<int> order by DATE_ ASC", *db);
selectCalendars << id;
std::string name;
int ievent;
calendar = new Calendar(id, this);
while (!selectCalendars.eof()) {
selectCalendars >> name >> ievent;
calendar->insertDate(boost::posix_time::from_iso_string(name.c_str()), ievent);
}
}
catch (otl_exception& p){ // intercept OTL exceptions
std::string strErr = formatOracleError(p);
LOG4CXX_ERROR(OracleCalendarRepository::logger, strErr);
support::exception::dao::DataRetrievalFailureDaoException exptErr(strErr);
throw exptErr;
}
return calendar;
// Bouml preserved body end 0001FA83
LOG4CXX_DEBUG(OracleCalendarRepository::logger, _T("-LoadCalendar"));
} |
Partager