Commit 5acc3454 authored by Steven Murray's avatar Steven Murray
Browse files

Split cta::catalogue into cta::catalogue and cta::rdbms

parent 51c159dc
...@@ -114,6 +114,7 @@ ELSE(DEFINED PackageOnly) ...@@ -114,6 +114,7 @@ ELSE(DEFINED PackageOnly)
add_subdirectory(cmdline) add_subdirectory(cmdline)
add_subdirectory(common) add_subdirectory(common)
add_subdirectory(objectstore) add_subdirectory(objectstore)
add_subdirectory(rdbms)
add_subdirectory(remotens) add_subdirectory(remotens)
add_subdirectory(scheduler) add_subdirectory(scheduler)
add_subdirectory(tapeserver) add_subdirectory(tapeserver)
......
...@@ -23,32 +23,14 @@ include_directories (${ORACLE-INSTANTCLIENT_INCLUDE_DIRS}) ...@@ -23,32 +23,14 @@ include_directories (${ORACLE-INSTANTCLIENT_INCLUDE_DIRS})
set (CATALOGUE_LIB_SRC_FILES set (CATALOGUE_LIB_SRC_FILES
ArchiveFileRow.cpp ArchiveFileRow.cpp
ArchiveFileItor.cpp ArchiveFileItor.cpp
AutoRollback.cpp
Catalogue.cpp Catalogue.cpp
CatalogueFactory.cpp CatalogueFactory.cpp
ColumnNameToIdx.cpp
ColumnNameToIdxAndType.cpp
DbConn.cpp
DbLogin.cpp
DbRset.cpp
DbStmt.cpp
InMemoryCatalogue.cpp InMemoryCatalogue.cpp
InMemoryCatalogueSchema.cpp InMemoryCatalogueSchema.cpp
TapeFileWritten.cpp TapeFileWritten.cpp
NullDbValue.cpp
OcciConn.cpp
OcciEnv.cpp
OcciEnvSingleton.cpp
OcciRset.cpp
OcciStmt.cpp
OracleCatalogue.cpp OracleCatalogue.cpp
ParamNameToIdx.cpp
RdbmsCatalogue.cpp RdbmsCatalogue.cpp
Sqlite.cpp
SqliteCatalogue.cpp SqliteCatalogue.cpp
SqliteConn.cpp
SqliteRset.cpp
SqliteStmt.cpp
TapeForWriting.cpp TapeForWriting.cpp
UserError.cpp) UserError.cpp)
...@@ -59,6 +41,7 @@ install (TARGETS ctacatalogue DESTINATION usr/${CMAKE_INSTALL_LIBDIR}) ...@@ -59,6 +41,7 @@ install (TARGETS ctacatalogue DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
target_link_libraries (ctacatalogue target_link_libraries (ctacatalogue
ctacommon ctacommon
ctardbms
${ORACLE-INSTANTCLIENT_LIBRARIES} ${ORACLE-INSTANTCLIENT_LIBRARIES}
${SQLITE_LIBRARIES}) ${SQLITE_LIBRARIES})
...@@ -91,11 +74,11 @@ add_custom_command(OUTPUT InMemoryCatalogueSchema.cpp ...@@ -91,11 +74,11 @@ add_custom_command(OUTPUT InMemoryCatalogueSchema.cpp
set(IN_MEMORY_CATALOGUE_UNIT_TESTS_LIB_SRC_FILES set(IN_MEMORY_CATALOGUE_UNIT_TESTS_LIB_SRC_FILES
CatalogueTest.cpp CatalogueTest.cpp
CatalogueFactoryTest.cpp CatalogueFactoryTest.cpp
DbLoginFactory.cpp ../rdbms/DbLoginFactory.cpp
DbLoginTest.cpp ../rdbms/DbLoginTest.cpp
ParamNameToIdxTest.cpp ../rdbms/ParamNameToIdxTest.cpp
InMemoryCatalogueTest.cpp InMemoryCatalogueTest.cpp
SqliteStmtTest.cpp) ../rdbms/SqliteStmtTest.cpp)
add_library (ctainmemorycatalogueunittests SHARED add_library (ctainmemorycatalogueunittests SHARED
${IN_MEMORY_CATALOGUE_UNIT_TESTS_LIB_SRC_FILES}) ${IN_MEMORY_CATALOGUE_UNIT_TESTS_LIB_SRC_FILES})
...@@ -108,7 +91,7 @@ install(TARGETS ctainmemorycatalogueunittests DESTINATION usr/${CMAKE_INSTALL_LI ...@@ -108,7 +91,7 @@ install(TARGETS ctainmemorycatalogueunittests DESTINATION usr/${CMAKE_INSTALL_LI
set (CATALOGUE_UNIT_TESTS_LIB_SRC_FILES set (CATALOGUE_UNIT_TESTS_LIB_SRC_FILES
CatalogueTest.cpp CatalogueTest.cpp
DbConfigCatalogueTest.cpp DbConfigCatalogueTest.cpp
DbLoginFactory.cpp) ../rdbms/DbLoginFactory.cpp)
add_library (ctacatalogueunittests SHARED add_library (ctacatalogueunittests SHARED
${CATALOGUE_UNIT_TESTS_LIB_SRC_FILES}) ${CATALOGUE_UNIT_TESTS_LIB_SRC_FILES})
......
...@@ -28,16 +28,16 @@ namespace catalogue { ...@@ -28,16 +28,16 @@ namespace catalogue {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// create // create
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Catalogue *CatalogueFactory::create(const DbLogin &dbLogin) { Catalogue *CatalogueFactory::create(const rdbms::DbLogin &dbLogin) {
try { try {
switch(dbLogin.dbType) { switch(dbLogin.dbType) {
case DbLogin::DBTYPE_IN_MEMORY: case rdbms::DbLogin::DBTYPE_IN_MEMORY:
return new InMemoryCatalogue(); return new InMemoryCatalogue();
case DbLogin::DBTYPE_ORACLE: case rdbms::DbLogin::DBTYPE_ORACLE:
return new OracleCatalogue(dbLogin.username, dbLogin.password, dbLogin.database); return new OracleCatalogue(dbLogin.username, dbLogin.password, dbLogin.database);
case DbLogin::DBTYPE_SQLITE: case rdbms::DbLogin::DBTYPE_SQLITE:
return new SqliteCatalogue(dbLogin.database); return new SqliteCatalogue(dbLogin.database);
case DbLogin::DBTYPE_NONE: case rdbms::DbLogin::DBTYPE_NONE:
throw exception::Exception("Cannot create a catalogue without a database type"); throw exception::Exception("Cannot create a catalogue without a database type");
default: default:
{ {
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#pragma once #pragma once
#include "catalogue/Catalogue.hpp" #include "catalogue/Catalogue.hpp"
#include "catalogue/DbLogin.hpp" #include "rdbms/DbLogin.hpp"
#include <memory> #include <memory>
#include <mutex> #include <mutex>
...@@ -46,7 +46,7 @@ public: ...@@ -46,7 +46,7 @@ public:
* @return The newly created CTA catalogue object. Please note that it is the * @return The newly created CTA catalogue object. Please note that it is the
* responsibility of the caller to delete the returned CTA catalogue object. * responsibility of the caller to delete the returned CTA catalogue object.
*/ */
static Catalogue *create(const DbLogin &dbLogin); static Catalogue *create(const rdbms::DbLogin &dbLogin);
}; // class CatalogueFactory }; // class CatalogueFactory
......
...@@ -58,7 +58,7 @@ TEST_F(cta_catalogue_CatalogueFactoryTest, instance_in_memory) { ...@@ -58,7 +58,7 @@ TEST_F(cta_catalogue_CatalogueFactoryTest, instance_in_memory) {
using namespace cta; using namespace cta;
using namespace cta::catalogue; using namespace cta::catalogue;
DbLogin dbLogin(DbLogin::DBTYPE_IN_MEMORY, "", "", ""); rdbms::DbLogin dbLogin(rdbms::DbLogin::DBTYPE_IN_MEMORY, "", "", "");
std::unique_ptr<Catalogue> catalogue(CatalogueFactory::create(dbLogin)); std::unique_ptr<Catalogue> catalogue(CatalogueFactory::create(dbLogin));
ASSERT_TRUE(NULL != catalogue.get()); ASSERT_TRUE(NULL != catalogue.get());
......
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
#include "catalogue/ArchiveFileRow.hpp" #include "catalogue/ArchiveFileRow.hpp"
#include "catalogue/CatalogueFactory.hpp" #include "catalogue/CatalogueFactory.hpp"
#include "catalogue/DbLoginFactory.hpp"
#include "catalogue/UserError.hpp" #include "catalogue/UserError.hpp"
#include "common/exception/Exception.hpp" #include "common/exception/Exception.hpp"
#include "rdbms/DbLoginFactory.hpp"
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <map> #include <map>
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
namespace unitTests { namespace unitTests {
class cta_catalogue_CatalogueTest : public ::testing::TestWithParam<cta::catalogue::DbLoginFactory*> { class cta_catalogue_CatalogueTest : public ::testing::TestWithParam<cta::rdbms::DbLoginFactory*> {
public: public:
/** /**
......
...@@ -26,7 +26,7 @@ namespace { ...@@ -26,7 +26,7 @@ namespace {
* details are specified in a database configuration file passed on the * details are specified in a database configuration file passed on the
* command-line to the catalogue unit-tests program. * command-line to the catalogue unit-tests program.
*/ */
class DbConfigFileLoginFactory: public cta::catalogue::DbLoginFactory { class DbConfigFileLoginFactory: public cta::rdbms::DbLoginFactory {
public: public:
/** /**
...@@ -40,9 +40,9 @@ public: ...@@ -40,9 +40,9 @@ public:
* *
* @return A newly created DbLogin object. * @return A newly created DbLogin object.
*/ */
virtual cta::catalogue::DbLogin create() { virtual cta::rdbms::DbLogin create() {
using namespace cta::catalogue; using namespace cta::catalogue;
return DbLogin::parseFile(g_cmdLineArgs.dbConfigPath); return cta::rdbms::DbLogin::parseFile(g_cmdLineArgs.dbConfigPath);
} }
}; // class OracleDbLoginFactory }; // class OracleDbLoginFactory
...@@ -53,6 +53,6 @@ DbConfigFileLoginFactory g_dbConfigLoginFactory; ...@@ -53,6 +53,6 @@ DbConfigFileLoginFactory g_dbConfigLoginFactory;
namespace unitTests { namespace unitTests {
INSTANTIATE_TEST_CASE_P(DbConfigFile, cta_catalogue_CatalogueTest, INSTANTIATE_TEST_CASE_P(DbConfigFile, cta_catalogue_CatalogueTest,
::testing::Values(dynamic_cast<cta::catalogue::DbLoginFactory*>(&g_dbConfigLoginFactory))); ::testing::Values(dynamic_cast<cta::rdbms::DbLoginFactory*>(&g_dbConfigLoginFactory)));
} // namespace unitTests } // namespace unitTests
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "catalogue/InMemoryCatalogue.hpp" #include "catalogue/InMemoryCatalogue.hpp"
#include "catalogue/RdbmsCatalogueSchema.hpp" #include "catalogue/RdbmsCatalogueSchema.hpp"
#include "catalogue/SqliteConn.hpp" #include "rdbms/SqliteConn.hpp"
namespace cta { namespace cta {
namespace catalogue { namespace catalogue {
...@@ -27,7 +27,7 @@ namespace catalogue { ...@@ -27,7 +27,7 @@ namespace catalogue {
// constructor // constructor
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
InMemoryCatalogue::InMemoryCatalogue() { InMemoryCatalogue::InMemoryCatalogue() {
std::unique_ptr<SqliteConn> sqliteConn(new SqliteConn(":memory:")); std::unique_ptr<rdbms::SqliteConn> sqliteConn(new rdbms::SqliteConn(":memory:"));
m_conn.reset(sqliteConn.release()); m_conn.reset(sqliteConn.release());
createCatalogueSchema(); createCatalogueSchema();
} }
...@@ -51,7 +51,7 @@ void InMemoryCatalogue::executeNonQueryMultiStmt(const std::string &multiStmt) { ...@@ -51,7 +51,7 @@ void InMemoryCatalogue::executeNonQueryMultiStmt(const std::string &multiStmt) {
const std::string::size_type length = findResult - searchPos + 1; const std::string::size_type length = findResult - searchPos + 1;
const std::string sql = multiStmt.substr(searchPos, length); const std::string sql = multiStmt.substr(searchPos, length);
searchPos = findResult + 1; searchPos = findResult + 1;
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<rdbms::DbStmt> stmt(m_conn->createStmt(sql));
stmt->executeNonQuery(); stmt->executeNonQuery();
} }
} }
......
...@@ -25,7 +25,7 @@ namespace { ...@@ -25,7 +25,7 @@ namespace {
/** /**
* Creates DbLogin objects for in-memory catalogue databases. * Creates DbLogin objects for in-memory catalogue databases.
*/ */
class InMemoryDbLoginFactory: public cta::catalogue::DbLoginFactory { class InMemoryDbLoginFactory: public cta::rdbms::DbLoginFactory {
public: public:
/** /**
...@@ -39,9 +39,9 @@ public: ...@@ -39,9 +39,9 @@ public:
* *
* @return A newly created DbLogin object. * @return A newly created DbLogin object.
*/ */
virtual cta::catalogue::DbLogin create() { virtual cta::rdbms::DbLogin create() {
using namespace cta::catalogue; using namespace cta::catalogue;
return DbLogin(DbLogin::DBTYPE_IN_MEMORY, "", "", ""); return cta::rdbms::DbLogin(cta::rdbms::DbLogin::DBTYPE_IN_MEMORY, "", "", "");
} }
}; // class InMemoryDbLoginFactory }; // class InMemoryDbLoginFactory
...@@ -50,6 +50,6 @@ InMemoryDbLoginFactory g_inMemoryDbLoginFactory; ...@@ -50,6 +50,6 @@ InMemoryDbLoginFactory g_inMemoryDbLoginFactory;
} // anonymous namespace } // anonymous namespace
INSTANTIATE_TEST_CASE_P(InMemory, cta_catalogue_CatalogueTest, INSTANTIATE_TEST_CASE_P(InMemory, cta_catalogue_CatalogueTest,
::testing::Values(dynamic_cast<cta::catalogue::DbLoginFactory*>(&g_inMemoryDbLoginFactory))); ::testing::Values(dynamic_cast<cta::rdbms::DbLoginFactory*>(&g_inMemoryDbLoginFactory)));
} // namespace unitTests } // namespace unitTests
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "catalogue/OcciConn.hpp" #include "rdbms/OcciConn.hpp"
#include "catalogue/OcciEnvSingleton.hpp" #include "rdbms/OcciEnvSingleton.hpp"
#include "catalogue/OracleCatalogue.hpp" #include "catalogue/OracleCatalogue.hpp"
#include "catalogue/UserError.hpp" #include "catalogue/UserError.hpp"
#include "common/exception/Exception.hpp" #include "common/exception/Exception.hpp"
...@@ -33,7 +33,7 @@ OracleCatalogue::OracleCatalogue( ...@@ -33,7 +33,7 @@ OracleCatalogue::OracleCatalogue(
const std::string &username, const std::string &username,
const std::string &password, const std::string &password,
const std::string &database) { const std::string &database) {
m_conn.reset(OcciEnvSingleton::instance().createConn(username, password, database)); m_conn.reset(rdbms::OcciEnvSingleton::instance().createConn(username, password, database));
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -77,9 +77,9 @@ common::dataStructures::ArchiveFile OracleCatalogue::deleteArchiveFile(const uin ...@@ -77,9 +77,9 @@ common::dataStructures::ArchiveFile OracleCatalogue::deleteArchiveFile(const uin
"WHERE " "WHERE "
"ARCHIVE_FILE.ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID " "ARCHIVE_FILE.ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID "
"FOR UPDATE"; "FOR UPDATE";
std::unique_ptr<DbStmt> selectStmt(m_conn->createStmt(selectSql)); std::unique_ptr<rdbms::DbStmt> selectStmt(m_conn->createStmt(selectSql));
selectStmt->bindUint64(":ARCHIVE_FILE_ID", archiveFileId); selectStmt->bindUint64(":ARCHIVE_FILE_ID", archiveFileId);
std::unique_ptr<DbRset> selectRset(selectStmt->executeQuery()); std::unique_ptr<rdbms::DbRset> selectRset(selectStmt->executeQuery());
while(selectRset->next()) { while(selectRset->next()) {
if(NULL == archiveFile.get()) { if(NULL == archiveFile.get()) {
archiveFile.reset(new common::dataStructures::ArchiveFile); archiveFile.reset(new common::dataStructures::ArchiveFile);
...@@ -121,14 +121,14 @@ common::dataStructures::ArchiveFile OracleCatalogue::deleteArchiveFile(const uin ...@@ -121,14 +121,14 @@ common::dataStructures::ArchiveFile OracleCatalogue::deleteArchiveFile(const uin
{ {
const char *const sql = "DELETE FROM TAPE_FILE WHERE ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID"; const char *const sql = "DELETE FROM TAPE_FILE WHERE ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<rdbms::DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindUint64(":ARCHIVE_FILE_ID", archiveFileId); stmt->bindUint64(":ARCHIVE_FILE_ID", archiveFileId);
stmt->executeNonQuery(); stmt->executeNonQuery();
} }
{ {
const char *const sql = "DELETE FROM ARCHIVE_FILE WHERE ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID"; const char *const sql = "DELETE FROM ARCHIVE_FILE WHERE ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<rdbms::DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindUint64(":ARCHIVE_FILE_ID", archiveFileId); stmt->bindUint64(":ARCHIVE_FILE_ID", archiveFileId);
stmt->executeNonQuery(); stmt->executeNonQuery();
} }
...@@ -154,8 +154,8 @@ uint64_t OracleCatalogue::getNextArchiveFileId() { ...@@ -154,8 +154,8 @@ uint64_t OracleCatalogue::getNextArchiveFileId() {
"FROM " "FROM "
"DUAL"; "DUAL";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<rdbms::DbStmt> stmt(m_conn->createStmt(sql));
std::unique_ptr<DbRset> rset(stmt->executeQuery()); std::unique_ptr<rdbms::DbRset> rset(stmt->executeQuery());
if (!rset->next()) { if (!rset->next()) {
throw exception::Exception(std::string("Result set is unexpectedly empty")); throw exception::Exception(std::string("Result set is unexpectedly empty"));
} }
...@@ -208,9 +208,9 @@ common::dataStructures::Tape OracleCatalogue::selectTapeForUpdate(const std::str ...@@ -208,9 +208,9 @@ common::dataStructures::Tape OracleCatalogue::selectTapeForUpdate(const std::str
"VID = :VID " "VID = :VID "
"FOR UPDATE"; "FOR UPDATE";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<rdbms::DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":VID", vid); stmt->bindString(":VID", vid);
std::unique_ptr<DbRset> rset(stmt->executeQuery()); std::unique_ptr<rdbms::DbRset> rset(stmt->executeQuery());
if (!rset->next()) { if (!rset->next()) {
throw exception::Exception(std::string("The tape with VID " + vid + " does not exist")); throw exception::Exception(std::string("The tape with VID " + vid + " does not exist"));
} }
......
This diff is collapsed.
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#pragma once #pragma once
#include "catalogue/Catalogue.hpp" #include "catalogue/Catalogue.hpp"
#include "catalogue/DbConn.hpp" #include "rdbms/DbConn.hpp"
#include "catalogue/RequesterAndGroupMountPolicies.hpp" #include "catalogue/RequesterAndGroupMountPolicies.hpp"
#include <memory> #include <memory>
...@@ -460,7 +460,7 @@ protected: ...@@ -460,7 +460,7 @@ protected:
* @param timeColNAme The name of the database column that contains the time * @param timeColNAme The name of the database column that contains the time
* stamp. * stamp.
*/ */
optional<common::dataStructures::TapeLog> getTapeLogFromRset(const DbRset &rset, optional<common::dataStructures::TapeLog> getTapeLogFromRset(const rdbms::DbRset &rset,
const std::string &driveColName, const std::string &timeColName) const; const std::string &driveColName, const std::string &timeColName) const;
/** /**
...@@ -479,7 +479,7 @@ protected: ...@@ -479,7 +479,7 @@ protected:
/** /**
* The connection to the underlying relational database. * The connection to the underlying relational database.
*/ */
std::unique_ptr<DbConn> m_conn; std::unique_ptr<rdbms::DbConn> m_conn;
/** /**
* Creates the database schema. * Creates the database schema.
......
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "catalogue/AutoRollback.hpp" #include "rdbms/AutoRollback.hpp"
#include "catalogue/RdbmsCatalogueSchema.hpp" #include "catalogue/RdbmsCatalogueSchema.hpp"
#include "catalogue/SqliteCatalogue.hpp" #include "catalogue/SqliteCatalogue.hpp"
#include "catalogue/SqliteConn.hpp" #include "rdbms/SqliteConn.hpp"
#include "catalogue/UserError.hpp" #include "catalogue/UserError.hpp"
#include "common/exception/Exception.hpp" #include "common/exception/Exception.hpp"
#include "common/utils/utils.hpp" #include "common/utils/utils.hpp"
...@@ -31,7 +31,7 @@ namespace catalogue { ...@@ -31,7 +31,7 @@ namespace catalogue {
// constructor // constructor
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
SqliteCatalogue::SqliteCatalogue(const std::string &filename) { SqliteCatalogue::SqliteCatalogue(const std::string &filename) {
std::unique_ptr<SqliteConn> sqliteConn(new SqliteConn(filename)); std::unique_ptr<rdbms::SqliteConn> sqliteConn(new rdbms::SqliteConn(filename));
m_conn.reset(sqliteConn.release()); m_conn.reset(sqliteConn.release());
} }
...@@ -82,9 +82,9 @@ common::dataStructures::ArchiveFile SqliteCatalogue::deleteArchiveFile(const uin ...@@ -82,9 +82,9 @@ common::dataStructures::ArchiveFile SqliteCatalogue::deleteArchiveFile(const uin
"ARCHIVE_FILE.ARCHIVE_FILE_ID = TAPE_FILE.ARCHIVE_FILE_ID " "ARCHIVE_FILE.ARCHIVE_FILE_ID = TAPE_FILE.ARCHIVE_FILE_ID "
"WHERE " "WHERE "
"ARCHIVE_FILE.ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID"; "ARCHIVE_FILE.ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID";
std::unique_ptr<DbStmt> selectStmt(m_conn->createStmt(selectSql)); std::unique_ptr<rdbms::DbStmt> selectStmt(m_conn->createStmt(selectSql));
selectStmt->bindUint64(":ARCHIVE_FILE_ID", archiveFileId); selectStmt->bindUint64(":ARCHIVE_FILE_ID", archiveFileId);
std::unique_ptr<DbRset> selectRset(selectStmt->executeQuery()); std::unique_ptr<rdbms::DbRset> selectRset(selectStmt->executeQuery());
while(selectRset->next()) { while(selectRset->next()) {
if(NULL == archiveFile.get()) { if(NULL == archiveFile.get()) {
archiveFile.reset(new common::dataStructures::ArchiveFile); archiveFile.reset(new common::dataStructures::ArchiveFile);
...@@ -126,14 +126,14 @@ common::dataStructures::ArchiveFile SqliteCatalogue::deleteArchiveFile(const uin ...@@ -126,14 +126,14 @@ common::dataStructures::ArchiveFile SqliteCatalogue::deleteArchiveFile(const uin
{ {
const char *const sql = "DELETE FROM TAPE_FILE WHERE ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID;"; const char *const sql = "DELETE FROM TAPE_FILE WHERE ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID;";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<rdbms::DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindUint64(":ARCHIVE_FILE_ID", archiveFileId); stmt->bindUint64(":ARCHIVE_FILE_ID", archiveFileId);
stmt->executeNonQuery(); stmt->executeNonQuery();
} }
{ {
const char *const sql = "DELETE FROM ARCHIVE_FILE WHERE ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID;"; const char *const sql = "DELETE FROM ARCHIVE_FILE WHERE ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID;";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<rdbms::DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindUint64(":ARCHIVE_FILE_ID", archiveFileId); stmt->bindUint64(":ARCHIVE_FILE_ID", archiveFileId);
stmt->executeNonQuery(); stmt->executeNonQuery();
} }
...@@ -154,7 +154,7 @@ common::dataStructures::ArchiveFile SqliteCatalogue::deleteArchiveFile(const uin ...@@ -154,7 +154,7 @@ common::dataStructures::ArchiveFile SqliteCatalogue::deleteArchiveFile(const uin
uint64_t SqliteCatalogue::getNextArchiveFileId() { uint64_t SqliteCatalogue::getNextArchiveFileId() {
try { try {
m_conn->executeNonQuery("BEGIN EXCLUSIVE;"); m_conn->executeNonQuery("BEGIN EXCLUSIVE;");
AutoRollback autoRollback(m_conn.get()); rdbms::AutoRollback autoRollback(m_conn.get());
m_conn->executeNonQuery("UPDATE ARCHIVE_FILE_ID SET ID = ID + 1;"); m_conn->executeNonQuery("UPDATE ARCHIVE_FILE_ID SET ID = ID + 1;");
uint64_t archiveFileId = 0; uint64_t archiveFileId = 0;
...@@ -164,8 +164,8 @@ uint64_t SqliteCatalogue::getNextArchiveFileId() { ...@@ -164,8 +164,8 @@ uint64_t SqliteCatalogue::getNextArchiveFileId() {
"ID AS ID " "ID AS ID "
"FROM " "FROM "
"ARCHIVE_FILE_ID"; "ARCHIVE_FILE_ID";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<rdbms::DbStmt> stmt(m_conn->createStmt(sql));
std::unique_ptr<DbRset> rset(stmt->executeQuery()); std::unique_ptr<rdbms::DbRset> rset(stmt->executeQuery());
if(!rset->next()) { if(!rset->next()) {
throw exception::Exception("ARCHIVE_FILE_ID table is empty"); throw exception::Exception("ARCHIVE_FILE_ID table is empty");
} }
...@@ -227,9 +227,9 @@ common::dataStructures::Tape SqliteCatalogue::selectTapeForUpdate(const std::str ...@@ -227,9 +227,9 @@ common::dataStructures::Tape SqliteCatalogue::selectTapeForUpdate(const std::str
"WHERE " "WHERE "
"VID = :VID;"; "VID = :VID;";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<rdbms::DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":VID", vid); stmt->bindString(":VID", vid);
std::unique_ptr<DbRset> rset(stmt->executeQuery()); std::unique_ptr<rdbms::DbRset> rset(stmt->executeQuery());
if (!rset->next()) { if (!rset->next()) {
throw exception::Exception(std::string("The tape with VID " + vid + " does not exist")); throw exception::Exception(std::string("The tape with VID " + vid + " does not exist"));
} }
......
...@@ -129,6 +129,7 @@ The shared libraries ...@@ -129,6 +129,7 @@ The shared libraries
%attr(0755,root,root) %{_libdir}/libctamediachangerutils.so %attr(0755,root,root) %{_libdir}/libctamediachangerutils.so
%attr(0755,root,root) %{_libdir}/libctamessages.so %attr(0755,root,root) %{_libdir}/libctamessages.so
%attr(0755,root,root) %{_libdir}/libctamessagesutils.so %attr(0755,root,root) %{_libdir}/libctamessagesutils.so
%attr(0755,root,root) %{_libdir}/libctardbms.so
%attr(0755,root,root) %{_libdir}/libctatapereactorutils.so %attr(0755,root,root) %{_libdir}/libctatapereactorutils.so
%attr(0755,root,root) %{_libdir}/libctatapeserverdaemonutils.so %attr(0755,root,root) %{_libdir}/libctatapeserverdaemonutils.so