diff --git a/catalogue/CMakeLists.txt b/catalogue/CMakeLists.txt index e7b729f5bea584e175e2cfbc9667992d8f3378fc..e9ce58f59a9b0c52b6d747b84ded317c61df8506 100644 --- a/catalogue/CMakeLists.txt +++ b/catalogue/CMakeLists.txt @@ -24,8 +24,8 @@ set (CATALOGUE_LIB_SRC_FILES CatalogueFactory.cpp CmdLineTool.cpp InMemoryCatalogue.cpp + InMemoryCatalogueSchema.cpp OracleCatalogue.cpp - RdbmsCatalogueSchema.cpp TapeFileWritten.cpp RdbmsCatalogue.cpp SchemaCreatingSqliteCatalogue.cpp @@ -41,31 +41,31 @@ target_link_libraries (ctacatalogue ctacommon ctardbms) -add_custom_command (OUTPUT create_sqlite_catalogue_schema.sql create_oracle_catalogue_schema.sql - COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/create_sqlite_catalogue_schema_header.sql ${CMAKE_CURRENT_SOURCE_DIR}/catalogue_common_schema.sql ${CMAKE_CURRENT_SOURCE_DIR}/create_sqlite_catalogue_schema_trailer.sql > create_sqlite_catalogue_schema.sql - COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/create_oracle_catalogue_schema_header.sql ${CMAKE_CURRENT_SOURCE_DIR}/catalogue_common_schema.sql ${CMAKE_CURRENT_SOURCE_DIR}/create_oracle_catalogue_schema_trailer.sql > create_oracle_catalogue_schema.sql +add_custom_command (OUTPUT sqlite_catalogue_schema.sql oracle_catalogue_schema.sql + COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/sqlite_catalogue_schema_header.sql ${CMAKE_CURRENT_SOURCE_DIR}/catalogue_common_schema.sql ${CMAKE_CURRENT_SOURCE_DIR}/sqlite_catalogue_schema_trailer.sql > sqlite_catalogue_schema.sql + COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_header.sql ${CMAKE_CURRENT_SOURCE_DIR}/catalogue_common_schema.sql ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_trailer.sql > oracle_catalogue_schema.sql DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/catalogue_common_schema.sql - ${CMAKE_CURRENT_SOURCE_DIR}/create_sqlite_catalogue_schema_header.sql - ${CMAKE_CURRENT_SOURCE_DIR}/create_sqlite_catalogue_schema_trailer.sql - ${CMAKE_CURRENT_SOURCE_DIR}/create_oracle_catalogue_schema_header.sql - ${CMAKE_CURRENT_SOURCE_DIR}/create_oracle_catalogue_schema_trailer.sql) + ${CMAKE_CURRENT_SOURCE_DIR}/sqlite_catalogue_schema_header.sql + ${CMAKE_CURRENT_SOURCE_DIR}/sqlite_catalogue_schema_trailer.sql + ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_header.sql + ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_trailer.sql) -install (FILES ${CMAKE_CURRENT_BINARY_DIR}/create_sqlite_catalogue_schema.sql +install (FILES ${CMAKE_CURRENT_BINARY_DIR}/sqlite_catalogue_schema.sql DESTINATION usr/share/cta-${CTA_VERSION}/sql PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) -install (FILES ${CMAKE_CURRENT_BINARY_DIR}/create_oracle_catalogue_schema.sql +install (FILES ${CMAKE_CURRENT_BINARY_DIR}/oracle_catalogue_schema.sql DESTINATION usr/share/cta-${CTA_VERSION}/sql PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) add_custom_command(OUTPUT in_memory_catalogue_schema.cpp - COMMAND sed 's/^/\ \ \"/' create_sqlite_catalogue_schema.sql | sed 's/$$/\"/' > in_memory_catalogue_schema.cpp - DEPENDS create_sqlite_catalogue_schema.sql) + COMMAND sed 's/^/\ \ \"/' sqlite_catalogue_schema.sql | sed 's/$$/\"/' > in_memory_catalogue_schema.cpp + DEPENDS sqlite_catalogue_schema.sql) -add_custom_command(OUTPUT RdbmsCatalogueSchema.cpp - COMMAND sed '/CTA_SQL_SCHEMA/r in_memory_catalogue_schema.cpp' ${CMAKE_CURRENT_SOURCE_DIR}/RdbmsCatalogueSchema.before_SQL.cpp > RdbmsCatalogueSchema.cpp - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/RdbmsCatalogueSchema.before_SQL.cpp in_memory_catalogue_schema.cpp) +add_custom_command(OUTPUT InMemoryCatalogueSchema.cpp + COMMAND sed '/CTA_SQL_SCHEMA/r in_memory_catalogue_schema.cpp' ${CMAKE_CURRENT_SOURCE_DIR}/InMemoryCatalogueSchema.before_SQL.cpp > InMemoryCatalogueSchema.cpp + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/InMemoryCatalogueSchema.before_SQL.cpp in_memory_catalogue_schema.cpp) set(IN_MEMORY_CATALOGUE_UNIT_TESTS_LIB_SRC_FILES CatalogueTest.cpp diff --git a/catalogue/InMemoryCatalogue.cpp b/catalogue/InMemoryCatalogue.cpp index cc68ca247239841d170528aabf41099585d3d3cd..172a700c202d461b04e98a7443166451f2c3ae81 100644 --- a/catalogue/InMemoryCatalogue.cpp +++ b/catalogue/InMemoryCatalogue.cpp @@ -17,7 +17,7 @@ */ #include "catalogue/InMemoryCatalogue.hpp" -#include "catalogue/RdbmsCatalogueSchema.hpp" +#include "catalogue/InMemoryCatalogueSchema.hpp" #include "rdbms/SqliteConn.hpp" #include "rdbms/SqliteConnFactory.hpp" diff --git a/catalogue/RdbmsCatalogueSchema.before_SQL.cpp b/catalogue/InMemoryCatalogueSchema.before_SQL.cpp similarity index 85% rename from catalogue/RdbmsCatalogueSchema.before_SQL.cpp rename to catalogue/InMemoryCatalogueSchema.before_SQL.cpp index be13ef6116f985c99ca83e945dc41545e50e64d8..32f169a26a8029a1cae563fc66e2b20b7b95aa83 100644 --- a/catalogue/RdbmsCatalogueSchema.before_SQL.cpp +++ b/catalogue/InMemoryCatalogueSchema.before_SQL.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "catalogue/RdbmsCatalogueSchema.hpp" +#include "catalogue/InMemoryCatalogueSchema.hpp" namespace cta { namespace catalogue { @@ -24,8 +24,8 @@ namespace catalogue { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -RdbmsCatalogueSchema::RdbmsCatalogueSchema(): sql( - // CTA_SQL_SCHEMA - The contents of catalogue_schema.cpp go here +InMemoryCatalogueSchema::InMemoryCatalogueSchema(): sql( + // CTA_SQL_SCHEMA - The contents of in_memory_schema.cpp go here ) { } diff --git a/catalogue/RdbmsCatalogueSchema.hpp b/catalogue/InMemoryCatalogueSchema.hpp similarity index 51% rename from catalogue/RdbmsCatalogueSchema.hpp rename to catalogue/InMemoryCatalogueSchema.hpp index 73c1bbeb69e7601c9f8574eab550ab71b7d6d334..33600b6f6e3b99633a27968fd2ba4d175ad99f2d 100644 --- a/catalogue/RdbmsCatalogueSchema.hpp +++ b/catalogue/InMemoryCatalogueSchema.hpp @@ -22,28 +22,25 @@ namespace cta { namespace catalogue { /** - * Structure containing the SQL to generate the database schema of the CTA - * catalogue. + * Structure containing the SQL to create the schema of the in memory CTA + * database. * - * The CMakeLists.txt file of this directory instructs cmake to generate the - * implementation file of this class, RdbmsCatalogueSchema.cpp, by combining - * the contents of the RdbmsCatalogueSchema.before_SQL.cpp with the - * contents of the master schema file, catalogue_schema.sql. This means the - * RdbmsCatalogueSchema.before_SQL.cpp file is not compilable. + * The CMakeLists.txt file of this directory instructs cmake to generate + * InMemoryCatalogueSchema.cpp from: + * - InMemoryCatalogueSchema.before_SQL.cpp + * - create_sqlite_catalogue_schema.sql * - * The purpose of this class is to isolate the "non-compilable" issues into a - * a small and encapsulated compilation unit, namely RdbmsCatalogueSchema.o, so - * that the remaining business logic can be implemented in the non-generated - * and compilable RdbmsCatalogue.cpp file. This means that IDEs can work as - * normal with the bulk of the code in RdbmsCatalogue.cpp, whereas they will - * struggle with RdbmsCatalogueSchema.before_SQL.cpp which is therefore - * intentionally small. + * The InMemorySchema.before_SQL.cpp file is not compilable and is therefore + * difficult for Integrated Developent Environments (IDEs) to handle. + * + * The purpose of this class is to help IDEs by isolating the "non-compilable" + * issues into a small cpp file. */ -struct RdbmsCatalogueSchema { +struct InMemoryCatalogueSchema { /** * Constructor. */ - RdbmsCatalogueSchema(); + InMemoryCatalogueSchema(); /** * The schema. diff --git a/catalogue/RdbmsCatalogue.cpp b/catalogue/RdbmsCatalogue.cpp index dfc86e5c8a2837d8a008e12b5c7907d0cab0d223..784467759f7f6376da869e9c6b655addfe5ca101 100644 --- a/catalogue/RdbmsCatalogue.cpp +++ b/catalogue/RdbmsCatalogue.cpp @@ -17,8 +17,8 @@ */ #include "catalogue/ArchiveFileRow.hpp" +#include "catalogue/InMemoryCatalogueSchema.hpp" #include "catalogue/RdbmsCatalogue.hpp" -#include "catalogue/RdbmsCatalogueSchema.hpp" #include "common/dataStructures/TapeFile.hpp" #include "common/exception/Exception.hpp" #include "common/exception/UserError.hpp" diff --git a/catalogue/SchemaCreatingSqliteCatalogue.cpp b/catalogue/SchemaCreatingSqliteCatalogue.cpp index 2dbca13370199e6cfb6d74940a24409675c057a4..906ea1176fba4ffc04f17589c2bfd598139c2109 100644 --- a/catalogue/SchemaCreatingSqliteCatalogue.cpp +++ b/catalogue/SchemaCreatingSqliteCatalogue.cpp @@ -16,8 +16,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "catalogue/InMemoryCatalogueSchema.hpp" #include "catalogue/SchemaCreatingSqliteCatalogue.hpp" -#include "catalogue/RdbmsCatalogueSchema.hpp" #include "rdbms/SqliteConn.hpp" #include "rdbms/SqliteConnFactory.hpp" @@ -36,7 +36,7 @@ SchemaCreatingSqliteCatalogue::SchemaCreatingSqliteCatalogue(const std::string & // createCatalogueSchema //------------------------------------------------------------------------------ void SchemaCreatingSqliteCatalogue::createCatalogueSchema() { - const RdbmsCatalogueSchema schema; + const InMemoryCatalogueSchema schema; std::string::size_type searchPos = 0; std::string::size_type findResult = std::string::npos; auto conn = m_connPool.getConn(); diff --git a/catalogue/SqliteCatalogue.cpp b/catalogue/SqliteCatalogue.cpp index d1e361025af18bef2583aa35475e5ce13516d840..60478af3997ef38b95eda419ba0e52f8e59b2167 100644 --- a/catalogue/SqliteCatalogue.cpp +++ b/catalogue/SqliteCatalogue.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "catalogue/RdbmsCatalogueSchema.hpp" +#include "catalogue/InMemoryCatalogueSchema.hpp" #include "catalogue/SqliteCatalogue.hpp" #include "common/exception/Exception.hpp" #include "common/exception/UserError.hpp" diff --git a/catalogue/create_oracle_catalogue_schema_header.sql b/catalogue/oracle_catalogue_schema_header.sql similarity index 100% rename from catalogue/create_oracle_catalogue_schema_header.sql rename to catalogue/oracle_catalogue_schema_header.sql diff --git a/catalogue/create_oracle_catalogue_schema_trailer.sql b/catalogue/oracle_catalogue_schema_trailer.sql similarity index 100% rename from catalogue/create_oracle_catalogue_schema_trailer.sql rename to catalogue/oracle_catalogue_schema_trailer.sql diff --git a/catalogue/create_sqlite_catalogue_schema_header.sql b/catalogue/sqlite_catalogue_schema_header.sql similarity index 100% rename from catalogue/create_sqlite_catalogue_schema_header.sql rename to catalogue/sqlite_catalogue_schema_header.sql diff --git a/catalogue/create_sqlite_catalogue_schema_trailer.sql b/catalogue/sqlite_catalogue_schema_trailer.sql similarity index 100% rename from catalogue/create_sqlite_catalogue_schema_trailer.sql rename to catalogue/sqlite_catalogue_schema_trailer.sql diff --git a/cta.spec.in b/cta.spec.in index 020f1157bec3b5ae0ff036f24ef12a90bfe77d8e..dbb65245f786b98e48a5fb46fc38a23cceeb3c9d 100644 --- a/cta.spec.in +++ b/cta.spec.in @@ -183,8 +183,8 @@ Group: Application/CTA CERN Tape Archive: Documents and supporting SQL scripts %files -n cta-doc -%attr(0644,root,root) %{_datarootdir}/%{name}-%{ctaVersion}/sql/create_oracle_catalogue_schema.sql -%attr(0644,root,root) %{_datarootdir}/%{name}-%{ctaVersion}/sql/create_sqlite_catalogue_schema.sql +%attr(0644,root,root) %{_datarootdir}/%{name}-%{ctaVersion}/sql/oracle_catalogue_schema.sql +%attr(0644,root,root) %{_datarootdir}/%{name}-%{ctaVersion}/sql/sqlite_catalogue_schema.sql %package -n cta-systemtests Summary: CERN Tape Archive: unit and system tests with virtual tape drives