summaryrefslogtreecommitdiff
path: root/p2pvr/daemon/schedules.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'p2pvr/daemon/schedules.cpp')
-rw-r--r--p2pvr/daemon/schedules.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/p2pvr/daemon/schedules.cpp b/p2pvr/daemon/schedules.cpp
index 19d277f..6a985c3 100644
--- a/p2pvr/daemon/schedules.cpp
+++ b/p2pvr/daemon/schedules.cpp
@@ -12,14 +12,13 @@
#include <boost/date_time/posix_time/posix_time.hpp>
#include <factory.impl.h>
#include <slicer/db/sqlSelectDeserializer.h>
+#include <slicer/db/sqlInsertSerializer.h>
+#include <slicer/db/sqlUpdateSerializer.h>
#include <slicer/slicer.h>
#include <p2pvr-int.h>
#include <privateExecContext.h>
ResourceString(Schedules_getCandidates, sql_Schedules_getCandidates);
-ResourceString(Schedules_insert, sql_Schedules_insert);
-ResourceString(Schedules_insertNewId, sql_Schedules_insertNewId);
-ResourceString(Schedules_update, sql_Schedules_update);
ResourceString(Schedules_delete, sql_Schedules_delete);
ResourceString(Schedules_selectAll, sql_Schedules_selectAll);
ResourceString(Schedules_selectById, sql_Schedules_selectById);
@@ -331,20 +330,24 @@ Schedules::GetScheduledToRecord(const Ice::Current &)
*Select(Schedules_scheduledToRecord).second);
}
-int
-Schedules::UpdateSchedule(const P2PVR::SchedulePtr & s, const Ice::Current & ice)
+Ice::Int
+Schedules::NewSchedule(const P2PVR::SchedulePtr & s, const Ice::Current & ice)
{
TxHelper tx(this);
- if (s->ScheduleId == 0) {
- Modify(Schedules_insert, s->ServiceId, s->EventUid, 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->EventUid, s->Title, s->Search, s->Priority, s->Early, s->Late, s->Repeats, s->ScheduleId).second->execute();
- }
+ auto db = dataSource<RdbmsDataSource>("postgres")->getWritable();
+ Slicer::SerializeAny<Slicer::SqlFetchIdInsertSerializer>(s, db.get(), "schedules");
DoReschedule(ice);
return s->ScheduleId;
}
+void
+Schedules::UpdateSchedule(const P2PVR::SchedulePtr & s, const Ice::Current & ice)
+{
+ TxHelper tx(this);
+ auto db = dataSource<RdbmsDataSource>("postgres")->getWritable();
+ Slicer::SerializeAny<Slicer::SqlUpdateSerializer>(s, db.get(), "schedules");
+ DoReschedule(ice);
+}
+
INSTANTIATEFACTORY(EpisodeGroup, const Episodes &);