diff OrthancServer/DatabaseWrapper.cpp @ 198:663cc6c46d0a

before refactoring of ServerIndex::GetXXX
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 27 Nov 2012 15:49:42 +0100
parents 530a25320461
children dfa2899d9960
line wrap: on
line diff
--- a/OrthancServer/DatabaseWrapper.cpp	Tue Nov 27 14:59:55 2012 +0100
+++ b/OrthancServer/DatabaseWrapper.cpp	Tue Nov 27 15:49:42 2012 +0100
@@ -231,6 +231,43 @@
     }
   }
 
+  bool DatabaseWrapper::LookupParent(int64_t& parentId,
+                                     int64_t resourceId)
+  {
+    SQLite::Statement s(db_, SQLITE_FROM_HERE, 
+                        "SELECT parentId FROM Resources WHERE internalId=?");
+    s.BindInt(0, resourceId);
+
+    if (!s.Step())
+    {
+      throw OrthancException(ErrorCode_UnknownResource);
+    }
+
+    if (s.ColumnIsNull(0))
+    {
+      return false;
+    }
+    else
+    {
+      parentId = s.ColumnInt(0);
+      return true;
+    }
+  }
+
+  std::string DatabaseWrapper::GetPublicId(int64_t resourceId)
+  {
+    SQLite::Statement s(db_, SQLITE_FROM_HERE, 
+                        "SELECT publicId FROM Resources WHERE internalId=?");
+    s.BindInt(0, resourceId);
+    
+    if (!s.Step())
+    { 
+      throw OrthancException(ErrorCode_UnknownResource);
+    }
+
+    return s.ColumnString(0);
+  }
+
   void DatabaseWrapper::AttachChild(int64_t parent,
                                     int64_t child)
   {