1 #include "otsdaq/ConfigurationInterface/Database_configInterface.h"
2 #include "otsdaq/Macros/ConfigurationInterfacePluginMacros.h"
3 #include "otsdaq/Macros/CoutMacros.h"
4 #include "otsdaq/MessageFacility/MessageFacility.h"
11 #include "artdaq-database/BasicTypes/basictypes.h"
12 #include "artdaq-database/ConfigurationDB/configurationdbifc.h"
13 #include "otsdaq/TableCore/TableBase.h"
15 #include "artdaq-database/ConfigurationDB/configuration_common.h"
16 #include "artdaq-database/ConfigurationDB/dispatch_common.h"
17 #include "artdaq-database/StorageProviders/FileSystemDB/provider_filedb.h"
18 #include "artdaq-database/StorageProviders/FileSystemDB/provider_filedb_index.h"
24 #define TRACE_NAME __MF_DECOR__
28 using artdaq::database::basictypes::FhiclData;
29 using artdaq::database::basictypes::JsonData;
32 using table_version_map_t = ots::DatabaseConfigurationInterface::table_version_map_t;
34 namespace db = artdaq::database::configuration;
35 using VersionInfoList_t = db::ConfigurationInterface::VersionInfoList_t;
37 constexpr
auto default_dbprovider =
"filesystem";
38 constexpr
auto default_entity =
"OTSROOT";
41 DatabaseConfigurationInterface::DatabaseConfigurationInterface()
43 #ifdef ARTDAQ_DATABASE_DEBUG_ENABLE
46 artdaq::database::configuration::debug::ExportImport();
47 artdaq::database::configuration::debug::ManageAliases();
48 artdaq::database::configuration::debug::ManageConfigs();
49 artdaq::database::configuration::debug::ManageDocuments();
50 artdaq::database::configuration::debug::Metadata();
52 artdaq::database::configuration::debug::detail::ExportImport();
53 artdaq::database::configuration::debug::detail::ManageAliases();
54 artdaq::database::configuration::debug::detail::ManageConfigs();
55 artdaq::database::configuration::debug::detail::ManageDocuments();
56 artdaq::database::configuration::debug::detail::Metadata();
58 artdaq::database::configuration::debug::options::OperationBase();
59 artdaq::database::configuration::debug::options::BulkOperations();
60 artdaq::database::configuration::debug::options::ManageDocuments();
61 artdaq::database::configuration::debug::options::ManageConfigs();
62 artdaq::database::configuration::debug::options::ManageAliases();
64 artdaq::database::configuration::debug::MongoDB();
65 artdaq::database::configuration::debug::UconDB();
66 artdaq::database::configuration::debug::FileSystemDB();
68 artdaq::database::filesystem::index::debug::enable();
71 artdaq::database::filesystem::debug::enable();
80 artdaq::database::configuration::Multitasker();
81 TRACE_CNTL(
"modeS",
true);
85 std::string envVar = __ENV__(
"ARTDAQ_DATABASE_URI");
88 IS_FILESYSTEM_DB =
false;
90 IS_FILESYSTEM_DB =
true;
91 __COUTV__(IS_FILESYSTEM_DB);
99 auto start = std::chrono::high_resolution_clock::now();
101 auto ifc = db::ConfigurationInterface{default_dbprovider};
103 auto versionstring = version.
toString();
105 auto result = ifc.template loadVersion<decltype(table), JsonData>(
106 table, versionstring, default_entity);
108 auto end = std::chrono::high_resolution_clock::now();
110 std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
111 __COUTT__ <<
"Time taken to call DatabaseConfigurationInterface::fill(tableName="
112 << table->
getTableName() <<
", version=" << versionstring <<
") "
113 << duration <<
" milliseconds." << std::endl;
121 if(result.second.find(
"failed to create a client session") != std::string::npos ||
122 result.second.find(
"closed connection. calling hello") != std::string::npos)
124 __SS__ <<
"Error at time: " << time(0)
125 <<
"\n\n======> Database Interface Error while filling '"
126 << table->
getTableName() <<
"' version '" << versionstring
127 <<
"' - it appears that the connection to the database been lost. Please "
128 "check the database server and route to server.\n\n"
129 <<
"Here is the error detail:\n\n"
130 << result.second <<
"\n\n"
135 __SS__ <<
"\n\n======> Database Interface Error while filling '"
136 << table->
getTableName() <<
"' version '" << versionstring
137 <<
"' - are you sure this version exists? Or has the connection to the "
138 "database been lost?\n\n"
139 <<
"Here is the error detail:\n\n"
140 << result.second << __E__;
147 bool overwrite)
const
150 auto start = std::chrono::high_resolution_clock::now();
152 auto ifc = db::ConfigurationInterface{default_dbprovider};
154 auto versionstring = table->getView().getVersion().toString();
155 __COUTTV__(versionstring);
156 std::stringstream preSaveJSONss;
157 table->getView().printJSON(preSaveJSONss);
162 auto result = overwrite ? ifc.template overwriteVersion<decltype(table), JsonData>(
163 table, versionstring, default_entity)
164 : ifc.template storeVersion<decltype(table), JsonData>(
165 table, versionstring, default_entity);
167 auto end = std::chrono::high_resolution_clock::now();
169 std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
170 __COUTT__ <<
"Time taken to call "
171 "DatabaseConfigurationInterface::saveActiveVersion(tableName="
172 << table->getTableName() <<
", versionstring=" << versionstring
173 <<
" overwrite=" << overwrite <<
") " << duration <<
" milliseconds"
176 __COUTTV__(result.first);
177 __COUTVS__(10, result.second);
186 table->getTableName());
187 localDocLoader.changeVersionAndActivateView(
189 fill(&localDocLoader, table->getView().getVersion());
191 std::stringstream postSaveJSONss;
192 localDocLoader.getView().printJSON(postSaveJSONss);
194 __COUTVS__(2, preSaveJSONss.str());
195 __COUTVS__(2, postSaveJSONss.str());
199 auto preSaveJSON = preSaveJSONss.str();
200 auto postSaveJSON = postSaveJSONss.str();
201 size_t prec = 0, postc = 0;
202 for(; prec < preSaveJSON.size() && postc < postSaveJSON.size();
205 if(preSaveJSON[prec] ==
'\n' || preSaveJSON[prec] ==
'\t' ||
206 preSaveJSON[prec] ==
' ')
212 else if(postSaveJSON[postc] ==
'\n' || postSaveJSON[postc] ==
'\t' ||
213 postSaveJSON[postc] ==
' ')
219 if(preSaveJSON[prec] != postSaveJSON[postc])
221 __COUTT__ <<
"Mismatch at preSaveJSON[" << prec
222 <<
"] != postSaveJSON[" << postc <<
"] ... "
223 << preSaveJSON.substr(prec, 30)
224 <<
" != " << postSaveJSON.substr(postc, 30) << __E__;
237 __COUT__ <<
"NOT Same";
238 auto end = std::chrono::high_resolution_clock::now();
240 std::chrono::duration_cast<std::chrono::milliseconds>(end - start)
243 <<
"Time taken to call "
244 "DatabaseConfigurationInterface::saveActiveVersion(tableName="
245 << table->getTableName() <<
", versionstring=" << versionstring
246 <<
") " << duration <<
" milliseconds" << std::endl;
248 __SS__ <<
"Error saving table '" << table->getTableName() <<
"'-v"
250 <<
" (perhaps there was a collision with another user saving the "
251 "same table name/version?! Please try again with an "
252 "incremented table version). "
253 <<
"Expected data size is " << preSaveJSONss.str().size()
254 <<
" and readback found size of " << postSaveJSONss.str().size()
255 <<
" with character mismatches." << __E__;
259 auto end = std::chrono::high_resolution_clock::now();
261 std::chrono::duration_cast<std::chrono::milliseconds>(end - start)
263 __COUTT__ <<
"Time taken to call "
264 "DatabaseConfigurationInterface::saveActiveVersion(tableName="
265 << table->getTableName() <<
", versionstring=" << versionstring
266 <<
") " << duration <<
" milliseconds" << std::endl;
272 __SS__ <<
"Return value indicates error in Database Interface saveActiveVersion "
273 "attempting to save "
274 << table->getTableName() <<
"-v" << table->getView().getVersion().toString()
275 <<
": " << result.second << __E__;
278 catch(std::exception
const& e)
280 __SS__ <<
"Database Interface Exception in saveActiveVersion attempting to save "
281 << table->getTableName() <<
"-v" << table->getView().getVersion().toString()
282 <<
": " << e.what() << __E__;
288 <<
"Database Interface Unknown exception in saveActiveVersion attempting to save "
289 << table->getTableName() <<
"-v" << table->getView().getVersion().toString()
299 auto versions = getVersions(table);
303 __COUTT__ <<
"Table Name: " << table->getTableName() << __E__;
304 __SS__ <<
"All Versions: ";
305 for(
auto& v : versions)
308 __COUTT__ <<
"\n" << ss.str();
314 return *(versions.rbegin());
323 auto start = std::chrono::high_resolution_clock::now();
325 auto ifc = db::ConfigurationInterface{default_dbprovider};
326 auto result = ifc.template getVersions<decltype(table)>(table, default_entity);
328 auto end = std::chrono::high_resolution_clock::now();
330 std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
332 <<
"Time taken to call DatabaseConfigurationInterface::getVersions(tableName="
333 << table->getTableName() <<
") " << duration <<
" milliseconds." << std::endl;
335 auto resultSet = std::set<TableVersion>{};
336 for(std::string
const& version : result)
337 resultSet.insert(
TableVersion(std::stol(version, 0, 10)));
343 catch(std::exception
const& e)
345 __COUT_WARN__ <<
"Database Interface Exception:" << e.what() <<
"\n";
354 auto start = std::chrono::high_resolution_clock::now();
356 auto ifc = db::ConfigurationInterface{default_dbprovider};
357 auto collection_name_prefix = std::string{};
359 auto result = ifc.listCollections(collection_name_prefix);
361 auto end = std::chrono::high_resolution_clock::now();
363 std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
365 <<
"Time taken to call "
366 "DatabaseConfigurationInterface::getAllTableNames(collection_name_prefix="
367 << collection_name_prefix <<
") " << duration <<
" milliseconds." << std::endl;
371 catch(std::exception
const& e)
373 __SS__ <<
"Database Interface Exception:" << e.what() <<
"\n";
378 __SS__ <<
"Database Interface Unknown exception.\n";
385 std::string
const& filterString)
const
388 auto start = std::chrono::high_resolution_clock::now();
390 auto ifc = db::ConfigurationInterface{default_dbprovider};
392 auto result = std::set<std::string>();
394 if(filterString ==
"")
395 result = ifc.findGlobalConfigurations(
398 result = ifc.findGlobalConfigurations(
401 auto end = std::chrono::high_resolution_clock::now();
403 std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
404 __COUTT__ <<
"Time taken to call "
405 "DatabaseConfigurationInterface::getAllTableGroupNames(filterString="
406 << filterString <<
") " << duration <<
" milliseconds." << std::endl;
410 catch(std::exception
const& e)
412 __SS__ <<
"Filter string '" << filterString
413 <<
"' yielded Database Interface Exception:" << e.what() <<
"\n";
418 __SS__ <<
"Filter string '" << filterString
419 <<
"' yielded Database Interface Unknown exception.\n";
427 const std::string& groupName)
const noexcept
435 TableBase::GROUP_CACHE_PREPEND + groupName);
437 findLatestVersion(&localGroupMemberCacheLoader);
438 __COUTTV__(lastestGroupCacheKey);
444 __COUT__ <<
"Ignoring cache loading error." << __E__;
449 return *(keys.crbegin());
458 const std::string& groupName)
const
460 std::set<TableGroupKey> retSet;
463 if(n.find(groupName) == 0)
471 std::string
const& tableGroup,
bool includeMetaDataTable )
const
474 auto start = std::chrono::high_resolution_clock::now();
489 table_version_map_t retMap = getCachedTableGroupMembers(tableGroup);
490 __COUTTV__(tableGroup);
493 if(!includeMetaDataTable)
496 auto metaTable = retMap.find(TableBase::GROUP_METADATA_TABLE_NAME);
497 if(metaTable != retMap.end())
498 retMap.erase(metaTable);
501 auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(
502 std::chrono::high_resolution_clock::now() - start)
504 __COUTT__ <<
"Time taken to call "
505 "DatabaseConfigurationInterface::getTableGroupMembers(tableGroup="
506 << tableGroup <<
") " << duration <<
" milliseconds." << std::endl;
511 __COUTT__ <<
"Ignoring getCachedTableGroupMembers() error in "
512 "DatabaseConfigurationInterface::getTableGroupMembers(tableGroup="
513 << tableGroup <<
") " << __E__;
516 auto ifc = db::ConfigurationInterface{default_dbprovider};
517 auto result = ifc.loadGlobalConfiguration(tableGroup);
521 for(
auto& item : result)
522 __COUTT__ <<
"====================> " << item.configuration <<
": "
523 << item.version << __E__;
526 auto to_map = [](
auto const& inputList,
bool includeMetaDataTable) {
527 auto resultMap = table_version_map_t{};
529 std::for_each(inputList.begin(), inputList.end(), [&resultMap](
auto const& info) {
530 resultMap[info.configuration] = std::stol(info.version, 0, 10);
533 if(!includeMetaDataTable)
536 auto metaTable = resultMap.find(TableBase::GROUP_METADATA_TABLE_NAME);
537 if(metaTable != resultMap.end())
538 resultMap.erase(metaTable);
543 table_version_map_t retMap = to_map(result, includeMetaDataTable);
546 saveTableGroupMemberCache(retMap, tableGroup);
551 auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(
552 std::chrono::high_resolution_clock::now() - start)
554 __COUTT__ <<
"Time taken to call "
555 "DatabaseConfigurationInterface::getTableGroupMembers(tableGroup="
556 << tableGroup <<
") " << duration <<
" milliseconds." << std::endl;
560 catch(std::exception
const& e)
562 __SS__ <<
"Database Interface Exception getting Group's member tables for '"
563 << tableGroup <<
"':\n\n"
565 if(std::string(e.what()).find(
"connection refused") != std::string::npos)
567 ss <<
"\n\nConnection to database refused. Perhaps your ssh tunnel has "
574 __SS__ <<
"Database Interface Unknown exception getting Group's member tables for '"
575 << tableGroup <<
".'\n";
576 __COUT_ERR__ << ss.str();
583 table_version_map_t DatabaseConfigurationInterface::getCachedTableGroupMembers(
584 std::string
const& tableGroup)
const
587 table_version_map_t retMap;
601 std::size_t vi = tableGroup.rfind(
"_v");
602 std::string groupName = tableGroup.substr(0, vi);
603 std::string groupKey = tableGroup.substr(vi + 2);
604 __COUTT__ <<
"Getting cache for " << groupName <<
"(" << groupKey <<
")" << __E__;
609 TableBase::GROUP_CACHE_PREPEND + groupName);
615 __COUTT__ <<
"IS_FILESYSTEM_DB=true, so checking cached keys for " << groupName
616 <<
"(" << groupKey <<
")" << __E__;
617 std::set<TableVersion> versions = getVersions(&localGroupMemberCacheSaver);
618 if(versions.find(localVersion) == versions.end())
620 __SS__ <<
"Cached member table versions not found for " << groupName <<
"("
621 << groupKey <<
")" << __E__;
626 localGroupMemberCacheSaver.changeVersionAndActivateView(
627 localGroupMemberCacheSaver.createTemporaryView(), localVersion);
629 fill(&localGroupMemberCacheSaver, localVersion);
631 __COUTS__(20) <<
"Loaded cache member map string "
632 << localGroupMemberCacheSaver.getViewP()->getCustomStorageData()
637 std::string jsonClean =
"";
638 const std::string& json =
639 localGroupMemberCacheSaver.getViewP()->getCustomStorageData();
641 if(c ==
'{' || c ==
'}' || c ==
'"' || c ==
' ')
645 __COUTVS__(21, jsonClean);
649 __COUTS__(20) <<
"Loaded cache member map string "
654 catch(std::exception
const& e)
656 __SS__ <<
"Database Interface Exception getCachedTableGroupMembers for '"
657 << tableGroup <<
"':\n\n"
663 __SS__ <<
"Database Interface Unknown exception getCachedTableGroupMembers for '"
664 << tableGroup <<
".'\n";
670 void DatabaseConfigurationInterface::saveTableGroupMemberCache(
671 table_version_map_t
const& memberMap, std::string
const& tableGroup)
const
686 std::size_t vi = tableGroup.rfind(
"_v");
687 std::string groupName = tableGroup.substr(0, vi);
688 std::string groupKey = tableGroup.substr(vi + 2);
689 __COUTT__ <<
"Saving cache for " << groupName <<
"(" << groupKey <<
")" << __E__;
694 TableBase::GROUP_CACHE_PREPEND + groupName);
695 localGroupMemberCacheSaver.changeVersionAndActivateView(
696 localGroupMemberCacheSaver.createTemporaryView(),
700 std::stringstream groupCacheData;
701 groupCacheData <<
"{ ";
702 for(
const auto& member : memberMap)
703 groupCacheData << (member.first == memberMap.begin()->first ?
"" :
", ")
705 "\"" << member.first <<
"\" : \"" << member.second <<
"\"";
706 groupCacheData <<
"}";
708 localGroupMemberCacheSaver.getViewP()->setCustomStorageData(groupCacheData.str());
711 __COUTT__ <<
"Saving member map string "
712 << localGroupMemberCacheSaver.getViewP()->getCustomStorageData() << __E__;
714 __COUTT__ <<
"Saving cache table "
715 << localGroupMemberCacheSaver.getView().getTableName() <<
"("
716 << localGroupMemberCacheSaver.getView().getVersion().toString() <<
")"
720 saveActiveVersion(&localGroupMemberCacheSaver,
false );
723 catch(std::exception
const& e)
725 __SS__ <<
"Database Interface Exception saveTableGroupMemberCache for '" << tableGroup
728 __COUT_ERR__ << ss.str();
733 __SS__ <<
"Database Interface Unknown exception saveTableGroupMemberCache for '"
734 << tableGroup <<
".'\n";
735 __COUT_ERR__ << ss.str();
742 std::string
const& tableGroup)
const
745 if(memberMap.size() == 0)
747 __SS__ <<
"Error: Attempting to save table group '" << tableGroup
748 <<
"' with empty member map! Please provide at least one member table for "
754 auto start = std::chrono::high_resolution_clock::now();
756 auto ifc = db::ConfigurationInterface{default_dbprovider};
760 auto to_list = [](
auto const& inputMap) {
761 auto resultList = VersionInfoList_t{};
765 std::back_inserter(resultList),
766 [](
auto const& mapEntry) {
767 return VersionInfoList_t::value_type{
768 mapEntry.first, mapEntry.second.toString(), default_entity};
775 auto result = IS_FILESYSTEM_DB
776 ? ifc.storeGlobalConfiguration(to_list(memberMap), tableGroup)
777 : ifc.storeGlobalConfiguration_mt(to_list(memberMap), tableGroup);
779 __COUTTV__(result.first);
780 __COUTVS__(10, result.second);
782 auto end = std::chrono::high_resolution_clock::now();
784 std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
786 <<
"Time taken to call DatabaseConfigurationInterface::saveTableGroup(tableGroup="
787 << tableGroup <<
") " << duration <<
" milliseconds." << std::endl;
793 auto readbackResult = ifc.loadGlobalConfiguration(tableGroup);
796 for(
auto& item : readbackResult)
797 __COUTT__ <<
"--==> " << item.configuration <<
": " << item.version
800 size_t countOfMatches = 0;
801 for(
auto& item : readbackResult)
803 __COUTT__ <<
"====================> " << item.configuration <<
": "
804 << item.version << __E__;
805 const auto& it = memberMap.find(item.configuration);
806 if(it == memberMap.end() ||
807 it->second !=
TableVersion(std::stol(item.version, 0, 10)))
809 auto end = std::chrono::high_resolution_clock::now();
811 std::chrono::duration_cast<std::chrono::milliseconds>(end - start)
814 <<
"Time taken to call "
815 "DatabaseConfigurationInterface::saveTableGroup(tableGroup="
816 << tableGroup <<
") " << duration <<
" milliseconds."
818 __SS__ <<
"Error saving group '" << tableGroup
819 <<
"' (perhaps there was a collision with another user saving "
820 "the same group name?! Please try again with an "
821 "incremented group key)). Table '"
822 << item.configuration <<
"'-v" << item.version
823 <<
" was unexpectedly read back as a member table after the "
824 "attempted group save. Expected member tables of group '"
825 << tableGroup <<
"' are as follows:" << __E__;
826 for(
const auto& memberPair : memberMap)
827 ss <<
"\t" << memberPair.first <<
"-v" << memberPair.second
836 if(countOfMatches != memberMap.size())
838 auto end = std::chrono::high_resolution_clock::now();
840 std::chrono::duration_cast<std::chrono::milliseconds>(end - start)
842 __COUTT__ <<
"Time taken to call "
843 "DatabaseConfigurationInterface::saveTableGroup(tableGroup="
844 << tableGroup <<
") " << duration <<
" milliseconds."
846 __SS__ <<
"Error saving group '" << tableGroup
847 <<
"' (perhaps there was a collision with another user saving the "
848 "same group name?! Please try again with an incremented group "
850 <<
"Expected group count is " << memberMap.size() <<
", and found "
851 << countOfMatches <<
" matching tables during readback check."
855 __COUTT__ <<
"Readback check passed." << __E__;
859 auto end = std::chrono::high_resolution_clock::now();
861 std::chrono::duration_cast<std::chrono::milliseconds>(end - start)
863 __COUTT__ <<
"Time taken to call "
864 "DatabaseConfigurationInterface::saveTableGroup(tableGroup="
865 << tableGroup <<
") " << duration <<
" milliseconds." << std::endl;
871 saveTableGroupMemberCache(memberMap, tableGroup);
875 __COUT_WARN__ <<
"Ignoring errors during saveTableGroupMemberCache()"
880 auto end = std::chrono::high_resolution_clock::now();
882 std::chrono::duration_cast<std::chrono::milliseconds>(end - start)
884 __COUTT__ <<
"Time taken to call "
885 "DatabaseConfigurationInterface::saveTableGroup(tableGroup="
886 << tableGroup <<
") " << duration <<
" milliseconds." << std::endl;
892 __SS__ <<
"Return value indicates failure to save group '" << tableGroup <<
"':\n"
893 << result.second << __E__;
896 catch(std::exception
const& e)
898 __SS__ <<
"Database Interface Exception saveTableGroup for '" << tableGroup
905 __SS__ <<
"Database Interface Unknown exception saveTableGroup for '" << tableGroup
912 std::pair<std::string, TableVersion> DatabaseConfigurationInterface::saveCustomJSON(
913 const std::string& json,
const std::string& documentNameToSave)
const
916 __COUTT__ <<
"Saving doc '" << documentNameToSave <<
"'" << __E__;
921 TableBase::JSON_DOC_PREPEND + documentNameToSave);
923 std::set<TableVersion> versions = getVersions(&localDocSaver);
926 version = TableVersion::getNextVersion(*versions.rbegin());
928 version = TableVersion::DEFAULT;
936 __COUTS__(10) <<
"Saving JSON string: "
939 __COUTT__ <<
"Saving JSON doc as " << localDocSaver.getView().getTableName() <<
"("
940 << localDocSaver.getView().getVersion().
toString() <<
")" << __E__;
943 saveActiveVersion(&localDocSaver,
false );
946 localDocSaver.getView().getVersion());
948 catch(std::exception
const& e)
950 __SS__ <<
"Database Interface Exception saveCustomJSON for '" << documentNameToSave
953 __COUT_ERR__ << ss.str();
958 __SS__ <<
"Database Interface Unknown exception saveCustomJSON for '"
959 << documentNameToSave <<
".'\n";
960 __COUT_ERR__ << ss.str();
966 std::string DatabaseConfigurationInterface::loadCustomJSON(
967 const std::string& documentNameToLoad,
TableVersion documentVersionToLoad)
const
970 __COUTT__ <<
"Loading doc '" << documentNameToLoad <<
"-v" << documentVersionToLoad
976 TableBase::JSON_DOC_PREPEND + documentNameToLoad);
979 documentVersionToLoad);
981 fill(&localDocLoader, documentVersionToLoad);
983 __COUTS__(10) <<
"Loaded JSON doc string "
988 catch(std::exception
const& e)
990 __SS__ <<
"Database Interface Exception saveCustomJSON for '" << documentNameToLoad
991 <<
"-v" << documentVersionToLoad <<
"':\n\n"
993 __COUTS__(3) << ss.str();
998 __SS__ <<
"Database Interface Unknown exception saveCustomJSON for '"
999 << documentNameToLoad <<
"-v" << documentVersionToLoad <<
".'\n";
1000 __COUTS__(3) << ss.str();
1007 std::set<std::string > DatabaseConfigurationInterface::findGroupsWithTable(
1008 std::string
const& tableName,
TableVersion version)
const
1011 auto start = std::chrono::high_resolution_clock::now();
1013 auto ifc = db::ConfigurationInterface{default_dbprovider};
1020 std::set<std::string> returnSet =
1021 ifc.findGlobalConfigurationsContaining(tableName, version.toString());
1023 __COUTT__ <<
"Number of Groups containing table '" << tableName <<
"-v" << version
1024 <<
"': " << returnSet.size() << __E__;
1026 auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(
1027 std::chrono::high_resolution_clock::now() - start)
1029 __COUTT__ <<
"Time taken to call "
1030 "DatabaseConfigurationInterface::findGroupsWithTable(table="
1031 << tableName <<
"-v" << version <<
") " << duration <<
" milliseconds."
1036 catch(std::exception
const& e)
1038 __SS__ <<
"Database Interface Exception running findGroupsWithTable for '"
1039 << tableName <<
"-v" << version <<
"':\n\n"
1040 << e.what() <<
"\n";
1045 __SS__ <<
"Database Interface Unknown exception running findGroupsWithTable for '"
1046 << tableName <<
"-v" << version <<
".'\n";
void saveTableGroup(table_version_map_t const &memberMap, std::string const &tableGroup) const override
create a new table group from the contents map
TableVersion findLatestVersion(const TableBase *table) const noexcept override
find the latest table version by table type
table_version_map_t getTableGroupMembers(std::string const &tableGroup, bool includeMetaDataTable=false) const override
return the contents of a table group
std::set< std::string > getAllTableGroupNames(std::string const &filterString="") const override
find all table groups in database
std::set< TableGroupKey > getKeys(const std::string &groupName) const override
find all configuration groups in database
std::set< TableVersion > getVersions(const TableBase *table) const noexcept override
find all table versions by table type
std::set< std::string > getAllTableNames(void) const override
returns a list of all table names
void fill(TableBase *table, TableVersion version) const override
read table from database
TableGroupKey findLatestGroupKey(const std::string &groupName) const noexcept override
void saveActiveVersion(const TableBase *table, bool overwrite=false) const override
write table to database
const std::string & getTableName(void) const
Getters.
TableVersion createTemporaryView(TableVersion sourceViewVersion=TableVersion(), TableVersion destTemporaryViewVersion=TableVersion::getNextTemporaryVersion())
source of -1, from MockUp, else from valid view version
std::string toString(void) const
toString
bool isInvalid(void) const
isInvalid
unsigned int version(void) const
void setVersion(const T &version)
< in included .icc source
const std::string & getCustomStorageData(void) const
Getters.
void setCustomStorageData(const std::string &storageData)
defines used also by OtsConfigurationWizardSupervisor
static std::string setToString(const std::set< T > &setToReturn, const std::string &delimeter=", ")
setToString ~
static std::string mapToString(const std::map< std::string, T > &mapToReturn, const std::string &primaryDelimeter=", ", const std::string &secondaryDelimeter=": ")
static void getMapFromString(const std::string &inputString, std::map< S, T > &mapToReturn, const std::set< char > &pairPairDelimiter={',', '|', '&'}, const std::set< char > &nameValueDelimiter={'=', ':'}, const std::set< char > &whitespace={' ', '\t', '\n', '\r'})
getMapFromString ~
static std::string stackTrace(void)