diff options
-rw-r--r-- | p2pvr/lib/dbClient.h | 18 | ||||
-rw-r--r-- | p2pvr/lib/maintenance/programMap.cpp | 4 | ||||
-rw-r--r-- | p2pvr/lib/recordings.cpp | 12 | ||||
-rw-r--r-- | p2pvr/lib/schedules.cpp | 10 | ||||
-rw-r--r-- | p2pvr/lib/si.cpp | 26 |
5 files changed, 35 insertions, 35 deletions
diff --git a/p2pvr/lib/dbClient.h b/p2pvr/lib/dbClient.h index 78a2651..58cce0a 100644 --- a/p2pvr/lib/dbClient.h +++ b/p2pvr/lib/dbClient.h @@ -30,21 +30,21 @@ class DatabaseClient : public virtual CommonObjects { }; template <typename... Args> - ModifyPtr Modify(const std::string & sql, const Args & ... args) const + std::pair<RdbmsDataSource::ConnectionRef, ModifyPtr> Modify(const std::string & sql, const Args & ... args) const { - auto db = dataSource<RdbmsDataSource>("postgres"); - auto cmd = ModifyPtr(db->getWritable().newModifyCommand(sql)); + auto db = dataSource<RdbmsDataSource>("postgres")->getWritable(); + auto cmd = ModifyPtr(db->newModifyCommand(sql)); Bind(cmd.get(), 0, args...); - return cmd; + return {db, cmd}; } template <typename... Args> - SelectPtr Select(const std::string & sql, const Args & ... args) const + std::pair<RdbmsDataSource::ConnectionRef, SelectPtr> Select(const std::string & sql, const Args & ... args) const { - auto db = dataSource<RdbmsDataSource>("postgres"); - auto cmd = SelectPtr(db->getReadonly().newSelectCommand(sql)); + auto db = dataSource<RdbmsDataSource>("postgres")->getReadonly(); + auto cmd = SelectPtr(db->newSelectCommand(sql)); Bind(cmd.get(), 0, args...); - return cmd; + return {db, cmd}; } class NoRowsFoundException : public std::runtime_error { @@ -56,7 +56,7 @@ class DatabaseClient : public virtual CommonObjects { Rtn SelectScalar(const std::string & sql, const Args & ... args) const { auto db = dataSource<RdbmsDataSource>("postgres"); - auto cmd = SelectPtr(db->getReadonly().newSelectCommand(sql)); + auto cmd = SelectPtr(db->getReadonly()->newSelectCommand(sql)); Bind(cmd.get(), 0, args...); while (cmd->fetch()) { HandleAsVariableType h; diff --git a/p2pvr/lib/maintenance/programMap.cpp b/p2pvr/lib/maintenance/programMap.cpp index 75e5ce8..f219e28 100644 --- a/p2pvr/lib/maintenance/programMap.cpp +++ b/p2pvr/lib/maintenance/programMap.cpp @@ -74,8 +74,8 @@ class SiProgramMapMerger : public IHaveSubTasks { throw std::runtime_error("no delivery methods"); } - auto db = commonObjects->dataSource<RdbmsDataSource>("postgres"); - SelectPtr sel = SelectPtr(db->getReadonly().newSelectCommand("select d.frequency, s.programid \ + auto db = commonObjects->dataSource<RdbmsDataSource>("postgres")->getReadonly(); + SelectPtr sel = SelectPtr(db->newSelectCommand("select d.frequency, s.programid \ from delivery_dvbt d, services s \ where d.transportstreamid = s.transportstreamid \ and s.programid is not null \ diff --git a/p2pvr/lib/recordings.cpp b/p2pvr/lib/recordings.cpp index 1200d76..d2c9658 100644 --- a/p2pvr/lib/recordings.cpp +++ b/p2pvr/lib/recordings.cpp @@ -48,7 +48,7 @@ Recordings::NewRecording(const P2PVR::RecordingPtr & r, const Ice::Current &) TxHelper tx(this); auto insert = Modify(Recording_Insert, r->StorageAddress, r->Guid, r->ScheduleId, r->Title, r->Subtitle, r->Description, r->StartTime, r->Duration); - insert->execute(); + insert.second->execute(); r->RecordingId = SelectScalar<int>(Recording_InsertNewId); Logger()->messagebf(LOG_INFO, "%s: Created recording Id: %d", __PRETTY_FUNCTION__, r->RecordingId); return r->RecordingId; @@ -61,14 +61,14 @@ Recordings::DeleteRecording(int id, const Ice::Current & ice) auto ic = ice.adapter->getCommunicator(); TxHelper tx(this); auto recordingStorages = Select(Recording_GetStorage, id); - while (recordingStorages->fetch()) { - std::string addr = recordingStorages / "storageaddress"; - std::string guid = recordingStorages / "guid"; + while (recordingStorages.second->fetch()) { + std::string addr = recordingStorages.second / "storageaddress"; + std::string guid = recordingStorages.second / "guid"; auto storage = P2PVR::StoragePrx::checkedCast(ic->stringToProxy(addr)); storage->Delete(guid); Logger()->messagebf(LOG_DEBUG, "%s: Delete %s from StorageAddress %s", __PRETTY_FUNCTION__, guid, addr); } - Modify(Recording_Delete, id)->execute(); + Modify(Recording_Delete, id).second->execute(); } P2PVR::RecordingList @@ -76,7 +76,7 @@ Recordings::GetRecordings(const Ice::Current &) { P2PVR::RecordingList rtn; SqlContainerCreator<P2PVR::RecordingList, P2PVR::Recording> cc(rtn); - cc.populate(Select(Recording_GetAll)); + cc.populate(Select(Recording_GetAll).second); return rtn; } diff --git a/p2pvr/lib/schedules.cpp b/p2pvr/lib/schedules.cpp index f36cade..31d5788 100644 --- a/p2pvr/lib/schedules.cpp +++ b/p2pvr/lib/schedules.cpp @@ -298,7 +298,7 @@ Schedules::DoReschedule(const Ice::Current & ice) // Load list from database ScheduleCandidates episodes; SqlContainerCreator<ScheduleCandidates, ScheduleCandidate, ScheduleCandidatePtr> cct(episodes); - cct.populate(Select(Schedules_GetCandidates)); + cct.populate(Select(Schedules_GetCandidates).second); Episodes scheduleList; Showings allShowings; @@ -400,7 +400,7 @@ void Schedules::DeleteSchedule(int id, const Ice::Current & ice) { TxHelper tx(this); - Modify(Schedules_delete, id)->execute(); + Modify(Schedules_delete, id).second->execute(); DoReschedule(ice); } @@ -409,7 +409,7 @@ Schedules::GetSchedules(const Ice::Current &) { P2PVR::ScheduleList schedules; SqlContainerCreator<P2PVR::ScheduleList, P2PVR::Schedule> cct(schedules); - cct.populate(Select(Schedules_selectAll)); + cct.populate(Select(Schedules_selectAll).second); return schedules; } @@ -418,11 +418,11 @@ Schedules::UpdateSchedule(const P2PVR::SchedulePtr & s, const Ice::Current & ice { TxHelper tx(this); if (s->ScheduleId == 0) { - Modify(Schedules_insert, s->ServiceId, s->EventId, s->Title, s->Search, s->Priority, s->Early, s->Late, s->Repeats)->execute(); + Modify(Schedules_insert, s->ServiceId, s->EventId, s->Title, s->Search, s->Priority, s->Early, s->Late, s->Repeats).second->execute(); s->ScheduleId = SelectScalar<int>(Schedules_insertNewId); } else { - Modify(Schedules_update, s->ServiceId, s->EventId, s->Title, s->Search, s->Priority, s->Early, s->Late, s->Repeats, s->ScheduleId)->execute(); + Modify(Schedules_update, s->ServiceId, s->EventId, s->Title, s->Search, s->Priority, s->Early, s->Late, s->Repeats, s->ScheduleId).second->execute(); } DoReschedule(ice); return s->ScheduleId; diff --git a/p2pvr/lib/si.cpp b/p2pvr/lib/si.cpp index 7c76ef4..131cf69 100644 --- a/p2pvr/lib/si.cpp +++ b/p2pvr/lib/si.cpp @@ -21,19 +21,19 @@ SI::GetAllDeliveries(short type, const Ice::Current &) case FE_OFDM: { SqlContainerCreator<P2PVR::Deliveries, DVBSI::TerrestrialDelivery> cc(rtn); - cc.populate(Select("SELECT * FROM delivery_dvbt")); + cc.populate(Select("SELECT * FROM delivery_dvbt").second); break; } case FE_QAM: { SqlContainerCreator<P2PVR::Deliveries, DVBSI::CableDelivery> cc(rtn); - cc.populate(Select("SELECT * FROM delivery_dvbc")); + cc.populate(Select("SELECT * FROM delivery_dvbc").second); break; } case FE_QPSK: { SqlContainerCreator<P2PVR::Deliveries, DVBSI::SatelliteDelivery> cc(rtn); - cc.populate(Select("SELECT * FROM delivery_dvbs")); + cc.populate(Select("SELECT * FROM delivery_dvbs").second); break; } } @@ -46,11 +46,11 @@ SI::GetDeliveryForTransport(int id, const Ice::Current&) { P2PVR::Deliveries rtn; SqlContainerCreator<P2PVR::Deliveries, DVBSI::TerrestrialDelivery> cct(rtn); - cct.populate(Select("SELECT * FROM delivery_dvbt WHERE transportStreamId = ?", id)); + cct.populate(Select("SELECT * FROM delivery_dvbt WHERE transportStreamId = ?", id).second); SqlContainerCreator<P2PVR::Deliveries, DVBSI::CableDelivery> ccc(rtn); - ccc.populate(Select("SELECT * FROM delivery_dvbc WHERE transportStreamId = ?", id)); + ccc.populate(Select("SELECT * FROM delivery_dvbc WHERE transportStreamId = ?", id).second); SqlContainerCreator<P2PVR::Deliveries, DVBSI::SatelliteDelivery> ccs(rtn); - ccs.populate(Select("SELECT * FROM delivery_dvbs WHERE transportStreamId = ?", id)); + ccs.populate(Select("SELECT * FROM delivery_dvbs WHERE transportStreamId = ?", id).second); return rtn.front(); } @@ -59,11 +59,11 @@ SI::GetDeliveryForService(int id, const Ice::Current&) { P2PVR::Deliveries rtn; SqlContainerCreator<P2PVR::Deliveries, DVBSI::TerrestrialDelivery> cct(rtn); - cct.populate(Select("SELECT d.* FROM services s, delivery_dvbt d WHERE serviceid = ? AND s.transportstreamid = d.transportstreamid", id)); + cct.populate(Select("SELECT d.* FROM services s, delivery_dvbt d WHERE serviceid = ? AND s.transportstreamid = d.transportstreamid", id).second); SqlContainerCreator<P2PVR::Deliveries, DVBSI::CableDelivery> ccc(rtn); - ccc.populate(Select("SELECT d.* FROM services s, delivery_dvbc d WHERE serviceid = ? AND s.transportstreamid = d.transportstreamid", id)); + ccc.populate(Select("SELECT d.* FROM services s, delivery_dvbc d WHERE serviceid = ? AND s.transportstreamid = d.transportstreamid", id).second); SqlContainerCreator<P2PVR::Deliveries, DVBSI::SatelliteDelivery> ccs(rtn); - ccs.populate(Select("SELECT d.* FROM services s, delivery_dvbs d WHERE serviceid = ? AND s.transportstreamid = d.transportstreamid", id)); + ccs.populate(Select("SELECT d.* FROM services s, delivery_dvbs d WHERE serviceid = ? AND s.transportstreamid = d.transportstreamid", id).second); return rtn.front(); } @@ -72,7 +72,7 @@ SI::GetServices(const Ice::Current&) { DVBSI::ServiceList rtn; SqlContainerCreator<DVBSI::ServiceList, DVBSI::Service> cc(rtn); - cc.populate(Select(SI_servicesSelectAll)); + cc.populate(Select(SI_servicesSelectAll).second); return rtn; } @@ -81,7 +81,7 @@ SI::GetService(int id, const Ice::Current&) { DVBSI::ServiceList rtn; SqlContainerCreator<DVBSI::ServiceList, DVBSI::Service> cc(rtn); - cc.populate(Select(SI_servicesSelectById, id)); + cc.populate(Select(SI_servicesSelectById, id).second); return rtn.front(); } @@ -90,7 +90,7 @@ SI::EventsOnNow(const Ice::Current &) { DVBSI::Events rtn; SqlContainerCreator<DVBSI::Events, DVBSI::Event> cc(rtn); - cc.populate(Select(SI_eventsOnNow)); + cc.populate(Select(SI_eventsOnNow).second); return rtn; } @@ -99,7 +99,7 @@ SI::EventsInRange(const Common::DateTime & from, const Common::DateTime & to, co { DVBSI::Events rtn; SqlContainerCreator<DVBSI::Events, DVBSI::Event> cc(rtn); - cc.populate(Select(SI_eventsInRange, from, to)); + cc.populate(Select(SI_eventsInRange, from, to).second); return rtn; } |