In PostgresqlSchedule and PostgresqlPlayLog, now we read and write UniqueId's

as string's instead of Long's (which should be == long long, but due to a bug
in libodbc++, it is in fact == long).
This commit is contained in:
fgerlits 2005-03-24 11:40:29 +00:00
parent d4aca4b759
commit 50b7537712
3 changed files with 18 additions and 16 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.8 $
Version : $Revision: 1.9 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/UniqueId.h,v $
------------------------------------------------------------------------------*/
@ -60,7 +60,7 @@ namespace Core {
* A class representing globally unique identifiers.
*
* @author $Author: fgerlits $
* @version $Revision: 1.8 $
* @version $Revision: 1.9 $
*/
class UniqueId
{
@ -131,7 +131,7 @@ class UniqueId
* @return a new UniqueId with the specified ID value.
*/
static Ptr<UniqueId>::Ref
fromDecimalString(const std::string idStr) throw ()
fromDecimalString(const std::string idStr) throw ()
{
IdType id;
// TODO: error checking
@ -148,7 +148,7 @@ class UniqueId
* @return a new string containing the value of the UniqueId.
*/
Ptr<std::string>::Ref
toDecimalString(void) throw ()
toDecimalString(void) const throw ()
{
std::stringstream idWriter;
idWriter << std::dec << id;

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlPlayLog.cxx,v $
------------------------------------------------------------------------------*/
@ -181,9 +181,9 @@ PostgresqlPlayLog :: addPlayLogEntry(
Ptr<PreparedStatement>::Ref pstmt(conn->prepareStatement(
addPlayLogEntryStmt));
id = UniqueId::generateId();
pstmt->setLong(1, id->getId());
pstmt->setString(1, *id->toDecimalString());
pstmt->setLong(2, audioClipId->getId());
pstmt->setString(2, *audioClipId->toDecimalString());
timestamp = Conversion::ptimeToTimestamp(clipTimestamp);
pstmt->setTimestamp(3, *timestamp);
@ -231,8 +231,10 @@ PostgresqlPlayLog :: getPlayLogEntries(
Ptr<ResultSet>::Ref rs(pstmt->executeQuery());
while (rs->next()) {
Ptr<UniqueId>::Ref id(new UniqueId(rs->getLong(1)));
Ptr<UniqueId>::Ref audioClipId(new UniqueId(rs->getLong(2)));
Ptr<UniqueId>::Ref id = UniqueId::fromDecimalString(
rs->getString(1));
Ptr<UniqueId>::Ref audioClipId = UniqueId::fromDecimalString(
rs->getString(2));
*timestamp = rs->getTimestamp(3);
Ptr<ptime>::Ref clipTimestamp

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.9 $
Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlSchedule.cxx,v $
------------------------------------------------------------------------------*/
@ -275,9 +275,9 @@ PostgresqlSchedule :: schedulePlaylist(
Ptr<PreparedStatement>::Ref pstmt(conn->prepareStatement(
schedulePlaylistStmt));
id = UniqueId::generateId();
pstmt->setLong(1, id->getId());
pstmt->setString(1, *id->toDecimalString());
pstmt->setLong(2, playlist->getId()->getId());
pstmt->setString(2, *playlist->getId()->toDecimalString());
timestamp = Conversion::ptimeToTimestamp(playtime);
pstmt->setTimestamp(3, *timestamp);
@ -422,7 +422,7 @@ PostgresqlSchedule :: scheduleEntryExists(
conn = cm->getConnection();
Ptr<PreparedStatement>::Ref pstmt(conn->prepareStatement(
scheduleEntryExistsStmt));
pstmt->setLong(1, entryId->getId());
pstmt->setString(1, *entryId->toDecimalString());
Ptr<ResultSet>::Ref rs(pstmt->executeQuery());
result = (rs->next()) ? (rs->getLong(1) == 1) : false;
@ -454,7 +454,7 @@ PostgresqlSchedule :: removeFromSchedule(
conn = cm->getConnection();
Ptr<PreparedStatement>::Ref pstmt(conn->prepareStatement(
removeFromScheduleStmt));
pstmt->setLong(1, entryId->getId());
pstmt->setString(1, *entryId->toDecimalString());
result = pstmt->executeUpdate() == 1;
@ -486,7 +486,7 @@ PostgresqlSchedule :: getScheduleEntry(Ptr<UniqueId>::Ref entryId)
conn = cm->getConnection();
Ptr<PreparedStatement>::Ref pstmt(conn->prepareStatement(
getScheduleEntryStmt));
pstmt->setLong(1, entryId->getId());
pstmt->setString(1, *entryId->toDecimalString());
Ptr<ResultSet>::Ref rs(pstmt->executeQuery());
if (rs->next()) {
@ -555,7 +555,7 @@ PostgresqlSchedule :: reschedule(Ptr<UniqueId>::Ref entryId,
timestamp = Conversion::ptimeToTimestamp(ends);
pstmt->setTimestamp(2, *timestamp);
pstmt->setLong(3, entryId->getId());
pstmt->setString(3, *entryId->toDecimalString());
result = pstmt->executeUpdate() == 1;