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 62
| /**
* Load a single calendar from the Oracle database
* @param the id of the calendar in the database
*/
void LoadCalendar(std::string name, int id, otl_connect *db, OracleCalendarRepository *calRepo) {
//LOG4CXX_DEBUG(OracleCalendarRepository::logger, _T("+LoadCalendar"));
// Bouml preserved body begin 0001FA83
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);
otl_stream selectCalendars (100, "select TO_CHAR(DATE_, \'YYYYMMDD\"T\"HH24MISS\'), EVENT_ from SORT_ADM.SORT_E_CLOSEDATE where IDCALENDAR_ = :f<int> order by DATE_ ASC", *db);
selectCalendars << id;
std::string name;
int ievent;
calendar = new Calendar(id, calRepo);
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("Oracle Error");
throw exptErr;
}
Calendar::insert(name, calendar);
// Bouml preserved body end 0001FA83
//LOG4CXX_DEBUG(OracleCalendarRepository::logger, _T("-LoadCalendar"));
}
/**
* Loads all the calendars from the Oracle database
*/
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 CALENDAR order by NAME_ ASC", *db);
int idcalendar;
std::string name;
boost::thread_group threadGroup;
while (!selectCalendars.eof()) {
selectCalendars >> name >> idcalendar;
threadGroup.create_thread(boost::bind(&LoadCalendar, name, idcalendar, db, this));
}
threadGroup.join_all();
}
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"));
} |
Partager