From 396360b9314f4b39ff1303bc5c5e65d6c90cfe92 Mon Sep 17 00:00:00 2001 From: Steven Murray <steven.murray@cern.ch> Date: Mon, 28 Nov 2016 18:19:34 +0100 Subject: [PATCH] Renamed RdbmsCatalogueSchema to InMemoryCatalogueSchema and simplied sql filenames --- catalogue/CMakeLists.txt | 30 +++++++++---------- catalogue/InMemoryCatalogue.cpp | 2 +- ...=> InMemoryCatalogueSchema.before_SQL.cpp} | 6 ++-- ...Schema.hpp => InMemoryCatalogueSchema.hpp} | 29 ++++++++---------- catalogue/RdbmsCatalogue.cpp | 2 +- catalogue/SchemaCreatingSqliteCatalogue.cpp | 4 +-- catalogue/SqliteCatalogue.cpp | 2 +- ...sql => oracle_catalogue_schema_header.sql} | 0 ...ql => oracle_catalogue_schema_trailer.sql} | 0 ...sql => sqlite_catalogue_schema_header.sql} | 0 ...ql => sqlite_catalogue_schema_trailer.sql} | 0 cta.spec.in | 4 +-- 12 files changed, 38 insertions(+), 41 deletions(-) rename catalogue/{RdbmsCatalogueSchema.before_SQL.cpp => InMemoryCatalogueSchema.before_SQL.cpp} (85%) rename catalogue/{RdbmsCatalogueSchema.hpp => InMemoryCatalogueSchema.hpp} (51%) rename catalogue/{create_oracle_catalogue_schema_header.sql => oracle_catalogue_schema_header.sql} (100%) rename catalogue/{create_oracle_catalogue_schema_trailer.sql => oracle_catalogue_schema_trailer.sql} (100%) rename catalogue/{create_sqlite_catalogue_schema_header.sql => sqlite_catalogue_schema_header.sql} (100%) rename catalogue/{create_sqlite_catalogue_schema_trailer.sql => sqlite_catalogue_schema_trailer.sql} (100%) diff --git a/catalogue/CMakeLists.txt b/catalogue/CMakeLists.txt index e7b729f5be..e9ce58f59a 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 cc68ca2472..172a700c20 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 be13ef6116..32f169a26a 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 73c1bbeb69..33600b6f6e 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 dfc86e5c8a..784467759f 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 2dbca13370..906ea1176f 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 d1e361025a..60478af399 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 020f1157be..dbb65245f7 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 -- GitLab