1 #include "otsdaq/ConfigurationInterface/ConfigurationManagerRW.h"
8 #define __MF_SUBJECT__ "ConfigurationManagerRW"
10 #define TABLE_INFO_PATH std::string(__ENV__("TABLE_INFO_PATH")) + "/"
11 #define TABLE_INFO_EXT "Info.xml"
13 #define CORE_TABLE_INFO_FILENAME \
14 ((getenv("SERVICE_DATA_PATH") == NULL) \
15 ? (std::string(__ENV__("USER_DATA")) + "/ServiceData") \
16 : (std::string(__ENV__("SERVICE_DATA_PATH")))) + \
17 "/CoreTableInfoNames.dat"
19 std::atomic<bool> ConfigurationManagerRW::firstTimeConstructed_ =
true;
26 __GEN_COUT__ <<
"Instantiating Config Manager with Write Access! (for " << username
27 <<
") time=" << time(0) <<
" runTimeSeconds()=" << runTimeSeconds()
30 theInterface_ = ConfigurationInterface::getInstance(
31 ConfigurationInterface::CONFIGURATION_MODE::
37 if(firstTimeConstructed_)
39 firstTimeConstructed_ =
false;
42 mkdir((ConfigurationManager::LAST_TABLE_GROUP_SAVE_PATH).c_str(), 0755);
44 const std::set<std::string>& contextMemberNames = getContextMemberNames();
45 const std::set<std::string>& backboneMemberNames = getBackboneMemberNames();
46 const std::set<std::string>& iterateMemberNames = getIterateMemberNames();
48 FILE* fp = fopen((CORE_TABLE_INFO_FILENAME).c_str(),
"r");
52 std::vector<unsigned int> foundVector;
54 for(
const auto& name : contextMemberNames)
56 foundVector.push_back(
false);
58 while(fgets(line, 100, fp))
62 line[strlen(line) - 1] =
'\0';
63 if(strcmp(line, (
"ContextGroup/" + name).c_str()) == 0)
65 foundVector.back() =
true;
71 for(
const auto& name : backboneMemberNames)
73 foundVector.push_back(
false);
75 while(fgets(line, 100, fp))
79 line[strlen(line) - 1] =
'\0';
80 if(strcmp(line, (
"BackboneGroup/" + name).c_str()) == 0)
82 foundVector.back() =
true;
88 for(
const auto& name : iterateMemberNames)
90 foundVector.push_back(
false);
92 while(fgets(line, 100, fp))
96 line[strlen(line) - 1] =
'\0';
97 if(strcmp(line, (
"IterateGroup/" + name).c_str()) == 0)
99 foundVector.back() =
true;
107 foundVector.push_back(
false);
109 while(fgets(line, 100, fp))
113 line[strlen(line) - 1] =
'\0';
116 ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE)
119 foundVector.back() =
true;
128 fp = fopen((CORE_TABLE_INFO_FILENAME).c_str(),
"a");
132 for(
const auto& name : contextMemberNames)
135 fprintf(fp,
"\nContextGroup/%s", name.c_str());
139 for(
const auto& name : backboneMemberNames)
142 fprintf(fp,
"\nBackboneGroup/%s", name.c_str());
146 for(
const auto& name : iterateMemberNames)
149 fprintf(fp,
"\nIterateGroup/%s", name.c_str());
159 ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE.c_str());
165 __SS__ <<
"Failed to open core table info file for appending: "
166 << CORE_TABLE_INFO_FILENAME << __E__;
172 fp = fopen((CORE_TABLE_INFO_FILENAME).c_str(),
"w");
175 fprintf(fp,
"ARTDAQ/*");
176 fprintf(fp,
"\nConfigCore/*");
177 for(
const auto& name : contextMemberNames)
178 fprintf(fp,
"\nContextGroup/%s", name.c_str());
179 for(
const auto& name : backboneMemberNames)
180 fprintf(fp,
"\nBackboneGroup/%s", name.c_str());
181 for(
const auto& name : iterateMemberNames)
182 fprintf(fp,
"\nIterateGroup/%s", name.c_str());
187 __SS__ <<
"Failed to open core table info file: "
188 << CORE_TABLE_INFO_FILENAME << __E__;
194 __GEN_COUTV__(runTimeSeconds());
206 std::string* accumulatedWarnings ,
207 const std::string& errorFilterName ,
210 bool initializeActiveGroups )
215 return allTableInfo_;
218 allTableInfo_.clear();
225 __GEN_COUT__ <<
"======================================================== "
226 "getAllTableInfo start runTimeSeconds()="
227 << runTimeSeconds() << __E__;
229 __GEN_COUT__ <<
"Refreshing all! Extracting list of tables..." << __E__;
231 struct dirent* entry;
232 std::string path = TABLE_INFO_PATH;
233 char fileExt[] = TABLE_INFO_EXT;
234 const unsigned char MIN_TABLE_NAME_SZ = 3;
237 __GEN_COUT__ <<
" PROCESSOR_COUNT " <<
PROCESSOR_COUNT <<
" ==> " << numOfThreads
238 <<
" threads." << __E__;
241 if((pDIR = opendir(path.c_str())) != 0)
243 while((entry = readdir(pDIR)) != 0)
246 if(strlen(entry->d_name) < strlen(fileExt) + MIN_TABLE_NAME_SZ)
250 if(strcmp(&(entry->d_name[strlen(entry->d_name) - strlen(fileExt)]),
254 entry->d_name[strlen(entry->d_name) - strlen(fileExt)] =
262 theInterface_->get(table,
268 catch(cet::exception
const&)
274 __GEN_COUT__ <<
"Skipping! No valid class found for... "
275 << entry->d_name <<
"\n";
278 catch(std::runtime_error& e)
284 __GEN_COUT__ <<
"Skipping! No valid class found for... "
285 << entry->d_name <<
"\n";
286 __GEN_COUT__ <<
"Error: " << e.what() << __E__;
291 if(accumulatedWarnings)
293 if(errorFilterName ==
"" || errorFilterName == entry->d_name)
295 *accumulatedWarnings += std::string(
"\nIn table '") +
296 entry->d_name +
"'..." +
299 __SS__ <<
"Attempting to allow illegal columns!" << __E__;
300 *accumulatedWarnings += ss.str();
304 __GEN_COUT__ <<
"Attempting to allow illegal columns!"
307 std::string returnedAccumulatedErrors;
311 &returnedAccumulatedErrors);
315 __GEN_COUT__ <<
"Skipping! Allowing illegal columns "
316 "didn't work either... "
317 << entry->d_name <<
"\n";
321 <<
"Error (but allowed): " << returnedAccumulatedErrors
324 if(errorFilterName ==
"" || errorFilterName == entry->d_name)
325 *accumulatedWarnings +=
326 std::string(
"\nIn table '") + entry->d_name +
"'..." +
327 returnedAccumulatedErrors;
333 if(nameToTableMap_[entry->d_name])
336 std::set<TableVersion> versions =
337 nameToTableMap_[entry->d_name]->getStoredVersions();
338 for(
auto& version : versions)
339 if(version.isTemporaryVersion())
343 nameToTableMap_[entry->d_name]->setActiveView(
346 nameToTableMap_[entry->d_name]->getView(),
357 delete nameToTableMap_[entry->d_name];
358 nameToTableMap_[entry->d_name] = 0;
361 nameToTableMap_[entry->d_name] = table;
363 allTableInfo_[entry->d_name].tablePtr_ = table;
364 allTableInfo_[entry->d_name].versions_ =
365 theInterface_->getVersions(table);
369 std::set<TableVersion> versions =
370 nameToTableMap_[entry->d_name]->getStoredVersions();
371 for(
auto& version : versions)
372 if(version.isTemporaryVersion())
374 allTableInfo_[entry->d_name].versions_.emplace(version);
382 int threadsLaunched = 0;
383 int foundThreadIndex = 0;
384 std::string tableName;
386 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
387 for(
int i = 0; i < numOfThreads; ++i)
388 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
390 std::vector<std::shared_ptr<ots::TableInfo>> sharedTableInfoPtrs;
392 if((pDIR = opendir(path.c_str())) != 0)
394 while((entry = readdir(pDIR)) != 0)
397 if(strlen(entry->d_name) < strlen(fileExt) + MIN_TABLE_NAME_SZ)
401 if(strcmp(&(entry->d_name[strlen(entry->d_name) - strlen(fileExt)]),
405 entry->d_name[strlen(entry->d_name) - strlen(fileExt)] =
412 sharedTableInfoPtrs.push_back(std::make_shared<ots::TableInfo>());
413 sharedTableInfoPtrs.back()->accumulatedWarnings_ =
414 accumulatedWarnings ?
"ALLOW"
417 if(threadsLaunched >= numOfThreads)
420 foundThreadIndex = -1;
422 while(foundThreadIndex == -1)
424 for(
int i = 0; i < numOfThreads; ++i)
427 foundThreadIndex = i;
430 if(foundThreadIndex == -1)
432 __GEN_COUT_TYPE__(TLVL_DEBUG + 2)
434 <<
"Waiting for available thread... iteration # "
438 __GEN_SS__ <<
"Threads seem to be stuck getting "
439 "table info! Timeout while waiting..."
446 threadsLaunched = numOfThreads - 1;
448 __GEN_COUTT__ <<
"Starting thread... " << foundThreadIndex
449 <<
" for table " << tableName << __E__;
451 *(threadDone[foundThreadIndex]) =
false;
454 std::string theTableName,
456 std::shared_ptr<ots::TableInfo> theTableInfo,
457 std::shared_ptr<std::atomic<bool>> theThreadDone) {
466 nameToTableMap_[tableName],
467 sharedTableInfoPtrs.back(),
468 threadDone[foundThreadIndex])
480 foundThreadIndex = -1;
481 for(
int i = 0; i < numOfThreads; ++i)
482 if(!*(threadDone[i]))
484 foundThreadIndex = i;
487 if(foundThreadIndex != -1)
489 __GEN_COUTT__ <<
"Waiting for thread to finish... "
490 << foundThreadIndex << __E__;
493 }
while(foundThreadIndex != -1);
496 for(
auto& tableInfo : sharedTableInfoPtrs)
498 __GEN_COUT_TYPE__(TLVL_DEBUG + 3)
499 << __COUT_HDR__ <<
"Copying table info for "
500 << tableInfo->tablePtr_->getTableName() << __E__;
501 nameToTableMap_[tableInfo->tablePtr_->getTableName()] =
502 tableInfo->tablePtr_;
503 allTableInfo_[tableInfo->tablePtr_->getTableName()].tablePtr_ =
504 tableInfo->tablePtr_;
505 allTableInfo_[tableInfo->tablePtr_->getTableName()].versions_ =
506 tableInfo->versions_;
509 __GEN_COUT__ <<
"Extracting list of tables complete." << __E__;
513 if(initializeActiveGroups)
515 __GEN_COUT__ <<
"Now initializing..." << __E__;
517 std::string tmpAccumulateWarnings;
520 accumulatedWarnings ? &tmpAccumulateWarnings :
nullptr);
522 if(accumulatedWarnings && errorFilterName ==
"")
523 *accumulatedWarnings += tmpAccumulateWarnings;
525 __GEN_COUT__ <<
"======================================================== "
526 "getAllTableInfo end runTimeSeconds()="
527 << runTimeSeconds() << __E__;
532 allGroupInfo_.clear();
537 std::set<std::string > tableGroups =
538 theInterface_->getAllTableGroupNames();
539 __GEN_COUT__ <<
"Number of Groups: " << tableGroups.size() << __E__;
541 __GEN_COUTT__ <<
"Group Info start runTimeSeconds()=" << runTimeSeconds()
546 for(
const auto& fullName : tableGroups)
549 cacheGroupKey(name, key);
552 __GEN_COUTT__ <<
"Group Keys end runTimeSeconds()=" << runTimeSeconds()
560 << numOfThreads <<
" threads." << __E__;
562 for(
auto& groupInfo : allGroupInfo_)
568 groupInfo.second.getLatestKey(),
570 &groupInfo.second.latestKeyMemberMap_ ,
573 &groupInfo.second.latestKeyGroupComment_,
574 &groupInfo.second.latestKeyGroupAuthor_,
575 &groupInfo.second.latestKeyGroupCreationTime_,
577 &groupInfo.second.latestKeyGroupTypeString_);
581 __GEN_COUT_WARN__ <<
"Error occurred loading latest group "
582 "info into cache for '"
583 << groupInfo.first <<
"("
584 << groupInfo.second.getLatestKey()
586 groupInfo.second.latestKeyGroupComment_ =
587 ConfigurationManager::UNKNOWN_INFO;
588 groupInfo.second.latestKeyGroupAuthor_ =
589 ConfigurationManager::UNKNOWN_INFO;
590 groupInfo.second.latestKeyGroupCreationTime_ =
591 ConfigurationManager::UNKNOWN_TIME;
592 groupInfo.second.latestKeyGroupTypeString_ =
593 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
594 groupInfo.second.latestKeyMemberMap_ = {};
599 int threadsLaunched = 0;
600 int foundThreadIndex = 0;
602 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
603 for(
int i = 0; i < numOfThreads; ++i)
604 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
606 std::vector<std::shared_ptr<ots::GroupInfo>> sharedGroupInfoPtrs;
608 for(
auto& groupInfo : allGroupInfo_)
611 sharedGroupInfoPtrs.push_back(std::make_shared<ots::GroupInfo>());
613 if(threadsLaunched >= numOfThreads)
616 foundThreadIndex = -1;
617 while(foundThreadIndex == -1)
619 for(
int i = 0; i < numOfThreads; ++i)
622 foundThreadIndex = i;
625 if(foundThreadIndex == -1)
627 __GEN_COUTT__ <<
"Waiting for available thread..."
632 threadsLaunched = numOfThreads - 1;
634 __GEN_COUTT__ <<
"Starting thread... " << foundThreadIndex
635 <<
" for " << groupInfo.first <<
"("
636 << groupInfo.second.getLatestKey() <<
")" << __E__;
638 *(threadDone[foundThreadIndex]) =
false;
642 std::string theGroupName,
644 std::shared_ptr<ots::GroupInfo> theGroupInfo,
645 std::shared_ptr<std::atomic<bool>> theThreadDone) {
655 groupInfo.second.getLatestKey(),
656 sharedGroupInfoPtrs.back(),
657 threadDone[foundThreadIndex])
667 foundThreadIndex = -1;
668 for(
int i = 0; i < numOfThreads; ++i)
669 if(!*(threadDone[i]))
671 foundThreadIndex = i;
674 if(foundThreadIndex != -1)
676 __GEN_COUTT__ <<
"Waiting for thread to finish... "
677 << foundThreadIndex << __E__;
680 }
while(foundThreadIndex != -1);
684 for(
auto& groupInfo : allGroupInfo_)
686 groupInfo.second.latestKeyGroupComment_ =
687 sharedGroupInfoPtrs[i]->latestKeyGroupComment_;
688 groupInfo.second.latestKeyGroupAuthor_ =
689 sharedGroupInfoPtrs[i]->latestKeyGroupAuthor_;
690 groupInfo.second.latestKeyGroupCreationTime_ =
691 sharedGroupInfoPtrs[i]->latestKeyGroupCreationTime_;
692 groupInfo.second.latestKeyGroupTypeString_ =
693 sharedGroupInfoPtrs[i]->latestKeyGroupTypeString_;
694 groupInfo.second.latestKeyMemberMap_ =
695 sharedGroupInfoPtrs[i]->latestKeyMemberMap_;
702 catch(
const std::runtime_error& e)
705 <<
"A fatal error occurred reading the info for all table groups. Error: "
706 << e.what() << __E__;
707 __GEN_COUT_ERR__ <<
"\n" << ss.str();
708 if(accumulatedWarnings)
709 *accumulatedWarnings += ss.str();
715 __SS__ <<
"An unknown fatal error occurred reading the info for all table "
722 catch(
const std::exception& e)
724 ss <<
"Exception message: " << e.what();
729 __GEN_COUT_ERR__ <<
"\n" << ss.str();
730 if(accumulatedWarnings)
731 *accumulatedWarnings += ss.str();
735 __GEN_COUTT__ <<
"Group Info end runTimeSeconds()=" << runTimeSeconds() << __E__;
738 __GEN_COUTT__ <<
"Table Info end runTimeSeconds()=" << runTimeSeconds() << __E__;
740 return allTableInfo_;
747 std::string tableName,
749 std::shared_ptr<ots::TableInfo> tableInfo,
750 std::shared_ptr<std::atomic<bool>> threadDone)
753 __COUTT__ <<
"Thread started... table " << tableName << __E__;
756 tableInfo->tablePtr_ = 0;
760 cfgMgr->theInterface_->get(tableInfo->tablePtr_,
766 catch(cet::exception
const&)
768 if(tableInfo->tablePtr_)
769 delete tableInfo->tablePtr_;
770 tableInfo->tablePtr_ = 0;
772 __COUT__ <<
"Skipping! No valid class found for... " << tableName <<
"\n";
773 *(threadDone) =
true;
776 catch(std::runtime_error& e)
778 if(tableInfo->tablePtr_)
779 delete tableInfo->tablePtr_;
780 tableInfo->tablePtr_ = 0;
782 __COUT__ <<
"Skipping! No valid class found for... " << tableName <<
"\n";
783 __COUTT__ <<
"Error: " << e.what() << __E__;
788 if(tableInfo->accumulatedWarnings_ ==
"ALLOW")
790 tableInfo->accumulatedWarnings_ =
"";
793 tableInfo->accumulatedWarnings_ += std::string(
"\nIn table '") +
797 __SS__ <<
"Attempting to allow illegal columns!" << __E__;
798 tableInfo->accumulatedWarnings_ += ss.str();
802 __COUT__ <<
"Attempting to allow illegal columns!" << __E__;
804 std::string returnedAccumulatedErrors;
807 tableInfo->tablePtr_ =
808 new TableBase(tableName, &returnedAccumulatedErrors);
812 __COUT__ <<
"Skipping! Allowing illegal columns didn't work either... "
813 << tableName <<
"\n";
814 *(threadDone) =
true;
817 __COUT_WARN__ <<
"Error (but allowed): " << returnedAccumulatedErrors
821 tableInfo->accumulatedWarnings_ +=
822 std::string(
"\nIn table '") + tableName +
"'..." +
823 returnedAccumulatedErrors;
827 tableInfo->accumulatedWarnings_ =
"";
828 *(threadDone) =
true;
835 __COUTT__ <<
"Copying temporary version from existing table object for "
836 << tableName << __E__;
838 std::set<TableVersion> versions = existingTable->getStoredVersions();
839 for(
auto& version : versions)
840 if(version.isTemporaryVersion())
844 existingTable->setActiveView(version);
845 tableInfo->tablePtr_->copyView(
846 existingTable->getView(),
856 delete existingTable;
860 tableInfo->versions_ = cfgMgr->theInterface_->getVersions(tableInfo->tablePtr_);
864 std::set<TableVersion> versions = tableInfo->tablePtr_->getStoredVersions();
865 for(
auto& version : versions)
866 if(version.isTemporaryVersion())
868 tableInfo->versions_.emplace(version);
871 __COUTT__ <<
"Thread done... table " << tableName << __E__;
872 *(threadDone) =
true;
876 __COUT_ERR__ <<
"Error occurred loading latest table info into cache for '"
877 << tableName <<
"'..." << __E__;
878 *(threadDone) =
true;
885 std::string groupName,
887 std::shared_ptr<ots::GroupInfo> groupInfo,
888 std::shared_ptr<std::atomic<bool>> threadDone)
891 __COUTT__ <<
"Thread started... " << groupName <<
"(" << groupKey <<
")" << __E__;
896 &(groupInfo->latestKeyMemberMap_) ,
899 &(groupInfo->latestKeyGroupComment_),
900 &(groupInfo->latestKeyGroupAuthor_),
901 &(groupInfo->latestKeyGroupCreationTime_),
903 &(groupInfo->latestKeyGroupTypeString_));
905 *(threadDone) =
true;
909 __COUT_WARN__ <<
"Error occurred loading latest group info into cache for '"
910 << groupName <<
"(" << groupInfo->getLatestKey() <<
")'..." << __E__;
911 groupInfo->latestKeyGroupComment_ = ConfigurationManager::UNKNOWN_INFO;
912 groupInfo->latestKeyGroupAuthor_ = ConfigurationManager::UNKNOWN_INFO;
913 groupInfo->latestKeyGroupCreationTime_ = ConfigurationManager::UNKNOWN_TIME;
914 groupInfo->latestKeyGroupTypeString_ = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
915 groupInfo->latestKeyMemberMap_ = {};
916 *(threadDone) =
true;
925 std::string groupName,
927 const std::map<std::string, TableVersion>& groupMemberMap,
928 const std::map<std::string /*name*/, std::string /*alias*/>& memberTableAliases,
929 std::atomic<bool>* foundIdentical,
931 std::mutex* threadMutex,
932 std::shared_ptr<std::atomic<bool>> threadDone)
935 std::map<std::string ,
TableVersion > compareToMemberMap;
936 std::map<std::string , std::string > compareToMemberTableAliases;
937 std::map<std::string , std::string >*
938 compareToMemberTableAliasesPtr =
nullptr;
939 if(memberTableAliases
941 compareToMemberTableAliasesPtr = &compareToMemberTableAliases;
946 &compareToMemberMap ,
954 compareToMemberTableAliasesPtr);
960 for(
auto& memberPair : groupMemberMap)
961 __COUTS__(9) <<
"member " << memberPair.first <<
" (" << memberPair.second
963 for(
auto& memberPair : compareToMemberMap)
964 __COUTS__(9) <<
"compare " << groupName <<
" (" << groupKeyToCompare
965 <<
") member:" << memberPair.first <<
" (" << memberPair.second
969 bool isDifferent =
false;
970 for(
auto& memberPair : groupMemberMap)
972 if(memberTableAliases.find(memberPair.first) != memberTableAliases.end())
975 if(compareToMemberTableAliases.find(memberPair.first) ==
976 compareToMemberTableAliases.end() ||
977 memberTableAliases.at(memberPair.first) !=
978 compareToMemberTableAliases.at(memberPair.first))
982 __COUTT__ <<
"diff " << groupName <<
" (" << groupKeyToCompare
983 <<
") on alias " << memberPair.first << __E__;
989 else if(compareToMemberTableAliases.find(memberPair.first) !=
990 compareToMemberTableAliases.end())
995 __COUTT__ <<
"diff " << groupName <<
" (" << groupKeyToCompare
996 <<
") on reverse alias " << memberPair.first << __E__;
1000 else if(compareToMemberMap.find(memberPair.first) ==
1001 compareToMemberMap.end() ||
1002 memberPair.second !=
1003 compareToMemberMap.at(memberPair.first))
1008 __COUTT__ <<
"diff " << groupName <<
" (" << groupKeyToCompare
1009 <<
") on mismatch " << memberPair.first << __E__;
1016 groupMemberMap.size() !=
1023 __COUTT__ <<
"diff " << groupName <<
" (" << groupKeyToCompare <<
") on size "
1029 *foundIdentical =
true;
1030 __COUT__ <<
"=====> Found exact match with key: " << groupKeyToCompare << __E__;
1032 std::lock_guard<std::mutex> lock(*threadMutex);
1033 *identicalKey = groupKeyToCompare;
1036 *(threadDone) =
true;
1040 __COUT_WARN__ <<
"Error occurred comparing group '" << groupName <<
"("
1041 << groupKeyToCompare <<
")'..." << __E__;
1043 *(threadDone) =
true;
1050 std::map<std::string ,
1054 std::map<std::string ,
1060 if(!ConfigurationInterface::isVersionTrackingEnabled())
1061 for(
const auto& tableInfo : allTableInfo_)
1062 for(
const auto& version : tableInfo.second.versions_)
1063 if(version.isScratchVersion())
1064 retMap[tableInfo.first][ConfigurationManager::SCRATCH_VERSION_ALIAS] =
1076 std::string* accumulatedTreeErrors,
1077 std::string* groupTypeString)
1086 accumulatedTreeErrors,
1095 __GEN_COUT_ERR__ <<
"There were errors, so de-activating group: "
1096 << tableGroupName <<
" (" << tableGroupKey <<
")" << __E__;
1107 __GEN_COUT_INFO__ <<
"Updating persistent active groups to "
1110 __COUT_INFO__ <<
"Active Context table group: " << theContextTableGroup_ <<
"("
1111 << (theContextTableGroupKey_
1112 ? theContextTableGroupKey_->toString().c_str()
1115 __COUT_INFO__ <<
"Active Backbone table group: " << theBackboneTableGroup_ <<
"("
1116 << (theBackboneTableGroupKey_
1117 ? theBackboneTableGroupKey_->toString().c_str()
1120 __COUT_INFO__ <<
"Active Iterate table group: " << theIterateTableGroup_ <<
"("
1121 << (theIterateTableGroupKey_
1122 ? theIterateTableGroupKey_->toString().c_str()
1125 __COUT_INFO__ <<
"Active Configuration table group: " << theConfigurationTableGroup_
1127 << (theConfigurationTableGroupKey_
1128 ? theConfigurationTableGroupKey_->toString().c_str()
1133 FILE* fp = fopen(fn.c_str(),
"w");
1136 __SS__ <<
"Fatal Error! Unable to open the file "
1138 <<
" for editing! Is there a permissions problem?" << __E__;
1139 __GEN_COUT_ERR__ << ss.str();
1143 fprintf(fp,
"%s\n", theContextTableGroup_.c_str());
1147 theContextTableGroupKey_ ? theContextTableGroupKey_->toString().c_str() :
"-1");
1148 fprintf(fp,
"%s\n", theBackboneTableGroup_.c_str());
1152 theBackboneTableGroupKey_ ? theBackboneTableGroupKey_->toString().c_str() :
"-1");
1153 fprintf(fp,
"%s\n", theIterateTableGroup_.c_str());
1157 theIterateTableGroupKey_ ? theIterateTableGroupKey_->toString().c_str() :
"-1");
1158 fprintf(fp,
"%s\n", theConfigurationTableGroup_.c_str());
1161 theConfigurationTableGroupKey_
1162 ? theConfigurationTableGroupKey_->toString().c_str()
1169 std::string(tableGroupName), tableGroupKey);
1170 if(theConfigurationTableGroupKey_ &&
1171 theConfigurationTableGroup_ == tableGroupName &&
1172 *theConfigurationTableGroupKey_ == tableGroupKey)
1173 ConfigurationManager::saveGroupNameAndKey(activatedGroup,
1174 LAST_ACTIVATED_CONFIG_GROUP_FILE);
1175 else if(theContextTableGroupKey_ && theContextTableGroup_ == tableGroupName &&
1176 *theContextTableGroupKey_ == tableGroupKey)
1177 ConfigurationManager::saveGroupNameAndKey(activatedGroup,
1178 LAST_ACTIVATED_CONTEXT_GROUP_FILE);
1179 else if(theBackboneTableGroupKey_ && theBackboneTableGroup_ == tableGroupName &&
1180 *theBackboneTableGroupKey_ == tableGroupKey)
1181 ConfigurationManager::saveGroupNameAndKey(activatedGroup,
1182 LAST_ACTIVATED_BACKBONE_GROUP_FILE);
1183 else if(theIterateTableGroupKey_ && theIterateTableGroup_ == tableGroupName &&
1184 *theIterateTableGroupKey_ == tableGroupKey)
1185 ConfigurationManager::saveGroupNameAndKey(activatedGroup,
1186 LAST_ACTIVATED_ITERATOR_GROUP_FILE);
1198 __GEN_COUT_INFO__ <<
"Creating temporary backbone view from version "
1199 << sourceViewVersion << __E__;
1205 auto backboneMemberNames = ConfigurationManager::getBackboneMemberNames();
1206 for(
auto& name : backboneMemberNames)
1210 if(retTmpVersion < tmpVersion)
1211 tmpVersion = retTmpVersion;
1214 __GEN_COUT__ <<
"Common temporary backbone version found as " << tmpVersion << __E__;
1217 for(
auto& name : backboneMemberNames)
1221 if(retTmpVersion != tmpVersion)
1223 __SS__ <<
"Failure! Temporary view requested was " << tmpVersion
1224 <<
". Mismatched temporary view created: " << retTmpVersion << __E__;
1225 __GEN_COUT_ERR__ << ss.str();
1234 TableBase* ConfigurationManagerRW::getTableByName(
const std::string& tableName)
1236 if(nameToTableMap_.find(tableName) == nameToTableMap_.end())
1238 if(tableName == ConfigurationManager::ARTDAQ_TOP_TABLE_NAME)
1241 <<
"Since target table was the artdaq top configuration level, "
1242 "attempting to help user by appending to core tables file: "
1243 << CORE_TABLE_INFO_FILENAME << __E__;
1244 FILE* fp = fopen((CORE_TABLE_INFO_FILENAME).c_str(),
"a");
1247 fprintf(fp,
"\nARTDAQ/*");
1252 __SS__ <<
"Table not found with name: " << tableName << __E__;
1254 if((f = tableName.find(
' ')) != std::string::npos)
1255 ss <<
"There was a space character found in the table name needle at "
1257 << f <<
" in the string (was this intended?). " << __E__;
1259 ss <<
"\nIf you think this table should exist in the core set of tables, try "
1260 "running 'UpdateOTS.sh --tables' to update your tables, then relaunch ots."
1262 ss <<
"\nTables must be defined at path $USER_DATA/TableInfo/ to exist in ots. "
1263 "Please verify your table definitions, and then restart ots."
1265 __GEN_COUT_ERR__ <<
"\n" << ss.str();
1268 return nameToTableMap_[tableName];
1277 const std::string& tableName,
1279 bool looseColumnMatching ,
1280 std::string* accumulatedErrors ,
1283 auto it = nameToTableMap_.find(tableName);
1284 if(it == nameToTableMap_.end())
1286 __SS__ <<
"\nCan not find table named '" << tableName
1287 <<
"'\n\n\n\nYou need to load the table before it can be used."
1288 <<
"It probably is missing from the member list of the Table "
1289 "Group that was loaded?\n\n\n\n\n"
1297 table->setActiveView(version);
1301 std::stringstream jsonSs;
1302 table->getViewP()->printJSON(jsonSs);
1303 table->getViewP()->doGetSourceRawData(
true);
1309 theInterface_->get(table,
1316 looseColumnMatching,
1334 TableBase* table = getTableByName(tableName);
1339 newVersion = theInterface_->saveNewVersion(table, temporaryVersion);
1341 table->setActiveView(newVersion);
1345 allTableInfo_[tableName].versions_.find(newVersion) !=
1346 allTableInfo_[tableName].versions_.end())
1349 <<
"What happenened!?? ERROR::: new persistent version v" << newVersion
1350 <<
" already exists!? How is it possible? Retrace your steps and "
1358 newVersion = temporaryVersion;
1362 __GEN_COUT_WARN__ <<
"Attempting to recover and use v" << newVersion << __E__;
1366 theInterface_->saveNewVersion(table, temporaryVersion, newVersion);
1368 table->setActiveView(newVersion);
1373 __SS__ <<
"Something went wrong saving the new version v" << newVersion
1374 <<
". What happened?! (duplicates? database error?)" << __E__;
1375 __GEN_COUT_ERR__ <<
"\n" << ss.str();
1380 allTableInfo_[tableName].versions_.insert(newVersion);
1394 TableBase* table = getTableByName(tableName);
1399 if(allTableInfo_.find(tableName) == allTableInfo_.end())
1406 for(
auto it = allTableInfo_[tableName].versions_.begin();
1407 it != allTableInfo_[tableName].versions_.end();
1410 if(it->isTemporaryVersion())
1412 __GEN_COUT__ <<
"Removing '" << tableName <<
"' version info: " << *it
1414 allTableInfo_[tableName].versions_.erase(it++);
1423 auto it = allTableInfo_[tableName].versions_.find(targetVersion);
1424 if(it == allTableInfo_[tableName].versions_.end())
1426 __GEN_COUT__ <<
"Target '" << tableName <<
"' version v" << targetVersion
1427 <<
" was not found in info versions..." << __E__;
1430 allTableInfo_[tableName].versions_.erase(
1431 allTableInfo_[tableName].versions_.find(targetVersion));
1442 TableBase* table = getTableByName(tableName);
1454 for(
auto configInfo : allTableInfo_)
1455 configInfo.second.tablePtr_->trimCache(0);
1461 const std::string& tableName,
TableVersion sourceVersion)
1463 getTableByName(tableName)->reset();
1475 allTableInfo_[tableName].versions_.insert(newTemporaryVersion);
1477 return newTemporaryVersion;
1482 void ConfigurationManagerRW::cacheGroupKey(
const std::string& groupName,
1485 allGroupInfo_[groupName].keys_.emplace(key);
1504 auto it = allGroupInfo_.find(groupName);
1505 if(it == allGroupInfo_.end())
1507 __SS__ <<
"Group name '" << groupName
1508 <<
"' not found in group info! (creating empty info)" << __E__;
1509 __GEN_COUT_WARN__ << ss.str();
1511 return allGroupInfo_[groupName];
1527 const std::string& groupName,
1528 const std::map<std::string, TableVersion>& groupMemberMap,
1529 const std::map<std::string /*name*/, std::string /*alias*/>& memberTableAliases)
1535 std::set<TableGroupKey> keys;
1538 bool cacheFailed =
false;
1544 TableBase::GROUP_CACHE_PREPEND + groupName);
1545 auto versions = theInterface_->getVersions(&localGroupMemberCacheLoader);
1546 for(
const auto& version : versions)
1551 __COUT__ <<
"Ignoring cache loading error. Doing full load of keys..."
1557 keys = theInterface_->getKeys(groupName);
1562 const unsigned int MAX_DEPTH_TO_CHECK = 20;
1563 unsigned int keyMinToCheck = 0;
1566 keyMinToCheck = keys.rbegin()->key();
1567 if(keyMinToCheck > MAX_DEPTH_TO_CHECK)
1569 keyMinToCheck -= MAX_DEPTH_TO_CHECK;
1570 __GEN_COUT__ <<
"Checking groups back to key... " << keyMinToCheck << __E__;
1575 __GEN_COUT__ <<
"Checking all groups." << __E__;
1583 __GEN_COUT__ <<
" PROCESSOR_COUNT " <<
PROCESSOR_COUNT <<
" ==> " << numOfThreads
1584 <<
" threads." << __E__;
1585 if(numOfThreads < 2)
1587 std::map<std::string ,
TableVersion > compareToMemberMap;
1588 std::map<std::string , std::string > compareToMemberTableAliases;
1589 std::map<std::string , std::string >*
1590 compareToMemberTableAliasesPtr =
nullptr;
1591 if(memberTableAliases.size())
1592 compareToMemberTableAliasesPtr = &compareToMemberTableAliases;
1595 for(
const auto& key : keys)
1597 if(key.key() < keyMinToCheck)
1603 &compareToMemberMap ,
1611 compareToMemberTableAliasesPtr);
1613 isDifferent =
false;
1614 for(
auto& memberPair : groupMemberMap)
1616 if(memberTableAliases.find(memberPair.first) != memberTableAliases.end())
1619 if(compareToMemberTableAliases.find(memberPair.first) ==
1620 compareToMemberTableAliases.end() ||
1621 memberTableAliases.at(memberPair.first) !=
1622 compareToMemberTableAliases.at(memberPair.first))
1630 else if(compareToMemberTableAliases.find(memberPair.first) !=
1631 compareToMemberTableAliases.end())
1638 else if(compareToMemberMap.find(memberPair.first) ==
1639 compareToMemberMap.end() ||
1640 memberPair.second !=
1641 compareToMemberMap.at(
1653 if(groupMemberMap.size() != compareToMemberMap.size())
1657 __GEN_COUT__ <<
"Found exact match with key: " << key << __E__;
1661 __GEN_COUT__ <<
"No match found - this group is new!" << __E__;
1667 int threadsLaunched = 0;
1668 int foundThreadIndex = 0;
1669 std::atomic<bool> foundIdentical =
false;
1671 std::mutex threadMutex;
1673 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
1674 for(
int i = 0; i < numOfThreads; ++i)
1675 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
1677 for(
const auto& key : keys)
1681 if(key.key() < keyMinToCheck)
1684 if(threadsLaunched >= numOfThreads)
1687 foundThreadIndex = -1;
1688 while(foundThreadIndex == -1)
1693 for(
int i = 0; i < numOfThreads; ++i)
1694 if(*(threadDone[i]))
1696 foundThreadIndex = i;
1699 if(foundThreadIndex == -1)
1701 __GEN_COUTT__ <<
"Waiting for available thread..." << __E__;
1705 threadsLaunched = numOfThreads - 1;
1710 __GEN_COUTT__ <<
"Starting thread... " << foundThreadIndex << __E__;
1711 *(threadDone[foundThreadIndex]) =
false;
1715 std::string theGroupName,
1717 const std::map<std::string, TableVersion>& groupMemberMap,
1718 const std::map<std::string /*name*/, std::string /*alias*/>&
1720 std::atomic<bool>* theFoundIdentical,
1722 std::mutex* theThreadMutex,
1723 std::shared_ptr<std::atomic<bool>> theThreadDone) {
1742 threadDone[foundThreadIndex])
1752 foundThreadIndex = -1;
1753 for(
int i = 0; i < numOfThreads; ++i)
1754 if(!*(threadDone[i]))
1756 foundThreadIndex = i;
1759 if(foundThreadIndex != -1)
1761 __GEN_COUTT__ <<
"Waiting for thread to finish... " << foundThreadIndex
1765 }
while(foundThreadIndex != -1);
1769 __GEN_COUT__ <<
"Found exact match with key: " << identicalKey << __E__;
1770 return identicalKey;
1787 return &groupMetadataTable_;
1791 std::lock_guard<std::mutex> lock(metaDataTableMutex_);
1794 while(groupMetadataTable_.getView().getNumberOfRows())
1795 groupMetadataTable_.getViewP()->deleteRow(0);
1800 theInterface_->fill(&groupMetadataTable_, fillVersion);
1802 catch(
const std::runtime_error& e)
1804 __GEN_COUT_WARN__ <<
"Failed to load " << groupMetadataTable_.getTableName()
1805 <<
"-v" << fillVersion <<
". Metadata error: " << e.what()
1810 __GEN_COUT_WARN__ <<
"Failed to load " << groupMetadataTable_.getTableName()
1811 <<
"-v" << fillVersion <<
". Ignoring unknown metadata error. "
1816 if(groupMetadataTable_.getView().getNumberOfRows() != 1)
1818 groupMetadataTable_.print();
1819 __GEN_COUT_ERR__ <<
"Ignoring that groupMetadataTable_ v" << fillVersion
1821 "number of rows!' Must "
1822 "be 1. Going with anonymous defaults."
1826 while(groupMetadataTable_.getViewP()->getNumberOfRows() > 1)
1827 groupMetadataTable_.getViewP()->deleteRow(0);
1828 if(groupMetadataTable_.getViewP()->getNumberOfRows() == 0)
1829 groupMetadataTable_.getViewP()->addRow();
1832 return &groupMetadataTable_;
1843 const std::string& groupName,
1844 std::map<std::string, TableVersion>& groupMembers,
1845 const std::string& groupComment,
1846 std::map<std::string /*table*/, std::string /*alias*/>* groupAliases)
1854 if(groupMembers.size() == 0)
1856 __SS__ <<
"Empty group member list. Can not create a group without members!"
1861 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
1866 for(
auto& memberPair : groupMembers)
1869 if(allCfgInfo.find(memberPair.first) == allCfgInfo.end())
1871 __GEN_COUT_ERR__ <<
"Group member \"" << memberPair.first
1872 <<
"\" not found in database!";
1874 if(groupMetadataTable_.getTableName() == memberPair.first)
1877 <<
"Looks like this is the groupMetadataTable_ '"
1878 << TableBase::GROUP_METADATA_TABLE_NAME
1879 <<
".' Note that this table is added to the member map when groups "
1881 <<
"It should not be part of member map when calling this function."
1883 __GEN_COUT__ <<
"Attempting to recover." << __E__;
1884 groupMembers.erase(groupMembers.find(memberPair.first));
1888 __SS__ << (
"Group member not found!") << __E__;
1893 if(allCfgInfo[memberPair.first].versions_.find(memberPair.second) ==
1894 allCfgInfo[memberPair.first].versions_.end())
1896 __SS__ <<
"Group member \"" << memberPair.first <<
"\" version \""
1897 << memberPair.second <<
"\" not found in database!";
1902 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
1907 for(
auto& aliasPair : *groupAliases)
1910 if(groupMembers.find(aliasPair.first) == groupMembers.end())
1912 __GEN_COUT_ERR__ <<
"Group member \"" << aliasPair.first
1913 <<
"\" not found in group member map!";
1915 __SS__ << (
"Alias table not found in member list!") << __E__;
1923 __GEN_COUT__ <<
"New Key for group: " << groupName <<
" found as " << newKey << __E__;
1924 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
1930 std::string groupAliasesString =
"";
1933 *groupAliases,
"," ,
":" );
1934 __GEN_COUT__ <<
"Metadata: " << username_ <<
" " << time(0) <<
" " << groupComment
1935 <<
" " << groupAliasesString << __E__;
1939 while(groupMetadataTable_.getViewP()->getNumberOfRows() > 1)
1940 groupMetadataTable_.getViewP()->deleteRow(0);
1941 if(groupMetadataTable_.getViewP()->getNumberOfRows() == 0)
1942 groupMetadataTable_.getViewP()->addRow();
1945 groupMetadataTable_.getViewP()->setValue(
1946 groupAliasesString, 0, ConfigurationManager::METADATA_COL_ALIASES);
1947 groupMetadataTable_.getViewP()->setValue(
1948 groupComment, 0, ConfigurationManager::METADATA_COL_COMMENT);
1949 groupMetadataTable_.getViewP()->setValue(
1950 username_, 0, ConfigurationManager::METADATA_COL_AUTHOR);
1951 groupMetadataTable_.getViewP()->setValue(
1952 time(0), 0, ConfigurationManager::METADATA_COL_TIMESTAMP);
1956 std::stringstream ss;
1957 groupMetadataTable_.print(ss);
1958 __COUT_MULTI__(2, ss.str());
1965 theInterface_->findLatestVersion(&groupMetadataTable_));
1966 groupMetadataTable_.getViewP()->setVersion(newVersion);
1968 uint16_t retries = 0;
1973 theInterface_->saveActiveVersion(&groupMetadataTable_);
1975 catch(
const std::runtime_error& e)
1977 __GEN_COUT__ <<
"Caught runtime_error exception during table save."
1979 if(std::string(e.what()).find(
"there was a collision") !=
1983 <<
"There was a collision saving the new table "
1984 << groupMetadataTable_ <<
"(" << newVersion
1985 <<
"), trying incremented table version... retries="
1986 << retries << __E__;
1991 groupMetadataTable_.getViewP()->setVersion(newVersion);
1992 __GEN_COUT__ <<
"New version for table: " << groupMetadataTable_
1993 <<
" found as " << newVersion << __E__;
2000 __GEN_COUT__ <<
"Created table: " << groupMetadataTable_ <<
"-v"
2001 << newVersion << __E__;
2006 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds()
2010 groupMembers[groupMetadataTable_.getTableName()] =
2011 groupMetadataTable_.getViewVersion();
2015 uint16_t retries = 0;
2018 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds()
2023 theInterface_->saveTableGroup(
2027 catch(
const std::runtime_error& e)
2029 __GEN_COUT__ <<
"Caught runtime_error exception during group save."
2031 if(std::string(e.what()).find(
"there was a collision") !=
2035 <<
"There was a collision saving the new group " << groupName
2037 <<
"), trying incremented group key... retries=" << retries
2042 __GEN_COUT__ <<
"New Key for group: " << groupName <<
" found as "
2050 __GEN_COUT__ <<
"Created table group: " << groupName <<
"(" << newKey
2056 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds()
2059 catch(std::runtime_error& e)
2061 __GEN_COUT_ERR__ <<
"Failed to create table group: " << groupName <<
"(" << newKey
2063 __GEN_COUT_ERR__ <<
"\n\n" << e.what() << __E__;
2068 __GEN_COUT_ERR__ <<
"Failed to create table group: " << groupName <<
":" << newKey
2073 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
2076 cacheGroupKey(groupName, newKey);
2078 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
2090 __GEN_COUT_INFO__ <<
"Creating new backbone from temporary version "
2091 << temporaryVersion << __E__;
2096 auto backboneMemberNames = ConfigurationManager::getBackboneMemberNames();
2097 for(
auto& name : backboneMemberNames)
2100 __GEN_COUT__ <<
"New version for backbone member (" << name
2101 <<
"): " << retNewVersion << __E__;
2102 if(retNewVersion > newVersion)
2103 newVersion = retNewVersion;
2106 __GEN_COUT__ <<
"Common new backbone version found as " << newVersion << __E__;
2109 for(
auto& name : backboneMemberNames)
2113 getTableByName(name), temporaryVersion, newVersion);
2114 if(retNewVersion != newVersion)
2116 __SS__ <<
"Failure! New view requested was " << newVersion
2117 <<
". Mismatched new view created: " << retNewVersion << __E__;
2118 __GEN_COUT_ERR__ << ss.str();
2132 const std::string& tableName,
2137 bool ignoreDuplicates ,
2138 bool lookForEquivalent ,
2139 bool* foundEquivalent )
2141 bool needToEraseTemporarySource =
2145 *foundEquivalent =
false;
2148 if(!ignoreDuplicates)
2150 __GEN_COUT__ <<
"Checking for duplicate '" << tableName <<
"' tables..." << __E__;
2158 const std::map<std::string, TableInfo>& allTableInfo =
2161 auto versionReverseIterator =
2162 allTableInfo.at(tableName).versions_.rbegin();
2163 __GEN_COUT__ <<
"Filling up '" << tableName <<
"' cache from "
2167 versionReverseIterator != allTableInfo.at(tableName).versions_.rend();
2168 ++versionReverseIterator)
2170 __GEN_COUTT__ <<
"'" << tableName <<
"' versions in reverse order "
2171 << *versionReverseIterator << __E__;
2175 *versionReverseIterator);
2177 catch(
const std::runtime_error& e)
2180 __COUTT__ <<
"'" << tableName
2181 <<
"' version failed to load: " << *versionReverseIterator
2187 __GEN_COUT__ <<
"Checking '" << tableName <<
"' for duplicate..." << __E__;
2190 temporaryModifiedVersion,
2196 if(lookForEquivalent && !duplicateVersion.
isInvalid())
2199 __GEN_COUT__ <<
"Equivalent '" << tableName <<
"' table found in version v"
2200 << duplicateVersion << __E__;
2205 __GEN_COUT__ <<
"Need persistent. Duplicate '" << tableName
2206 <<
"' version was temporary. "
2207 "Abandoning duplicate."
2219 if(needToEraseTemporarySource)
2223 *foundEquivalent =
true;
2225 __GEN_COUT__ <<
"\t\t Equivalent '" << tableName
2226 <<
"' assigned version: " << duplicateVersion << __E__;
2228 return duplicateVersion;
2234 __SS__ <<
"This version of table '" << tableName
2235 <<
"' is identical to another version currently cached v"
2236 << duplicateVersion <<
". No reason to save a duplicate." << __E__;
2237 __GEN_COUT_ERR__ <<
"\n" << ss.str();
2240 table->eraseView(temporaryModifiedVersion);
2244 __GEN_COUT__ <<
"Check for duplicate '" << tableName <<
"' tables complete."
2249 __GEN_COUT__ <<
"\t\t**************************** Save as temporary '"
2250 << tableName <<
"' table version" << __E__;
2252 __GEN_COUT__ <<
"\t\t**************************** Save as new '" << tableName
2253 <<
"' table version" << __E__;
2256 saveNewTable(tableName, temporaryModifiedVersion, makeTemporary);
2258 __GEN_COUTTV__(table->getView().getComment());
2260 if(needToEraseTemporarySource)
2263 __GEN_COUT__ <<
"\t\t '" << tableName
2264 <<
"' new assigned version: " << newAssignedVersion << __E__;
2265 return newAssignedVersion;
2269 GroupEditStruct::GroupEditStruct(
const ConfigurationManager::GroupType& groupType,
2271 : groupType_(groupType)
2272 , originalGroupName_(cfgMgr->getActiveGroupName(groupType))
2273 , originalGroupKey_(cfgMgr->getActiveGroupKey(groupType))
2275 , mfSubject_(cfgMgr->getUsername())
2277 if(originalGroupName_ ==
"" || originalGroupKey_.isInvalid())
2279 __SS__ <<
"Error! No active group found for type '"
2281 <<
".' There must be an active group to edit the group." << __E__ << __E__
2286 __GEN_COUT__ <<
"Extracting Group-Edit Struct for type "
2291 const std::set<std::string>& memberNames =
2292 groupType == ConfigurationManager::GroupType::CONTEXT_TYPE
2293 ? ConfigurationManager::getContextMemberNames()
2298 : cfgMgr->getConfigurationMemberNames()));
2300 for(
auto& memberName : memberNames)
2303 groupMembers_.emplace(
2304 std::make_pair(memberName, activeTables.at(memberName)));
2305 groupTables_.emplace(std::make_pair(
2312 __SS__ <<
"Error! Could not find group member table '" << memberName
2313 <<
"' for group type '"
2315 <<
".' All group members must be present to create the group editing "
2324 GroupEditStruct::~GroupEditStruct()
2326 __GEN_COUT__ <<
"GroupEditStruct from editing '" << originalGroupName_ <<
"("
2327 << originalGroupKey_ <<
")' Destructing..." << __E__;
2329 __GEN_COUT__ <<
"GroupEditStruct from editing '" << originalGroupName_ <<
"("
2330 << originalGroupKey_ <<
")' Desctructed." << __E__;
2338 auto it = groupTables_.find(tableName);
2339 if(it == groupTables_.end())
2341 if(groupType_ == ConfigurationManager::GroupType::CONFIGURATION_TYPE &&
2344 __GEN_COUT__ <<
"Table '" << tableName
2345 <<
"' not found in configuration table members from editing '"
2346 << originalGroupName_ <<
"(" << originalGroupKey_ <<
")..."
2347 <<
" Attempting to add it!" << __E__;
2350 auto newIt = groupTables_.emplace(std::make_pair(
2355 newIt.first->second.modified_ =
2357 groupMembers_.emplace(
2358 std::make_pair(tableName, newIt.first->second.temporaryVersion_));
2359 return newIt.first->second;
2361 __GEN_COUT_ERR__ <<
"Failed to emplace new table..." << __E__;
2364 __SS__ <<
"Table '" << tableName <<
"' not found in table members from editing '"
2365 << originalGroupName_ <<
"(" << originalGroupKey_ <<
")!'" << __E__;
2368 it->second.modified_ =
2374 void GroupEditStruct::dropChanges()
2376 __GEN_COUT__ <<
"Dropping unsaved changes from editing '" << originalGroupName_ <<
"("
2377 << originalGroupKey_ <<
")'..." << __E__;
2382 for(
auto& groupTable : groupTables_)
2383 if(groupTable.second
2384 .createdTemporaryVersion_)
2388 groupTable.second.temporaryVersion_);
2389 groupTable.second.createdTemporaryVersion_ =
false;
2390 groupTable.second.modified_ =
false;
2393 __GEN_COUT__ <<
"Unsaved changes dropped from editing '" << originalGroupName_ <<
"("
2394 << originalGroupKey_ <<
").'" << __E__;
2398 void GroupEditStruct::saveChanges(
const std::string& groupNameToSave,
2400 bool* foundEquivalentGroupKey ,
2401 bool activateNewGroup ,
2402 bool updateGroupAliases ,
2403 bool updateTableAliases ,
2405 bool* foundEquivalentBackboneKey ,
2406 std::string* accumulatedWarnings )
2408 __GEN_COUT__ <<
"Saving changes..." << __E__;
2413 if(foundEquivalentBackboneKey)
2414 *foundEquivalentBackboneKey =
false;
2418 bool anyTableNew =
false;
2419 for(
auto& groupTable : groupTables_)
2421 if(!groupTable.second.modified_)
2424 __GEN_COUT__ <<
"Original version is " << groupTable.second.tableName_ <<
"-v"
2425 << groupTable.second.originalVersion_ << __E__;
2428 groupTable.second.tableName_,
2429 groupTable.second.originalVersion_,
2431 groupTable.second.table_,
2432 groupTable.second.temporaryVersion_,
2435 __GEN_COUT__ <<
"Temporary target version is " << groupTable.second.tableName_
2436 <<
"-v" << groupMembers_.at(groupTable.first) <<
"-v"
2437 << groupTable.second.temporaryVersion_ << __E__;
2440 groupTable.second.tableName_,
2441 groupTable.second.originalVersion_,
2443 groupTable.second.table_,
2444 groupTable.second.temporaryVersion_,
2448 if(groupTable.second.originalVersion_ != groupMembers_.at(groupTable.first))
2451 __GEN_COUT__ <<
"Final NEW target version is " << groupTable.second.tableName_
2452 <<
"-v" << groupMembers_.at(groupTable.first) << __E__;
2455 __GEN_COUT__ <<
"Final target version is " << groupTable.second.tableName_
2456 <<
"-v" << groupMembers_.at(groupTable.first) << __E__;
2458 groupTable.second.modified_ =
false;
2459 groupTable.second.createdTemporaryVersion_ =
false;
2462 for(
auto& table : groupMembers_)
2464 __GEN_COUT__ << table.first <<
" v" << table.second << __E__;
2469 __GEN_COUT__ <<
"Checking for duplicate groups..." << __E__;
2470 newGroupKey = cfgMgr->
findTableGroup(groupNameToSave, groupMembers_);
2473 __GEN_COUT__ <<
"New table found, so no need to check duplicate groups." << __E__;
2477 __GEN_COUT__ <<
"Found equivalent group key (" << newGroupKey <<
") for "
2478 << groupNameToSave <<
"." << __E__;
2479 if(foundEquivalentGroupKey)
2480 *foundEquivalentGroupKey =
true;
2485 __GEN_COUT__ <<
"Saved new Context group key (" << newGroupKey <<
") for "
2486 << groupNameToSave <<
"." << __E__;
2489 bool groupAliasChange =
false;
2490 bool tableAliasChange =
false;
2493 ConfigurationManager::GroupType::
2496 GroupEditStruct backboneGroupEdit(ConfigurationManager::GroupType::BACKBONE_TYPE,
2499 if(groupType_ != ConfigurationManager::GroupType::BACKBONE_TYPE &&
2505 TableEditStruct& groupAliasTable = backboneGroupEdit.getTableEditStruct(
2506 ConfigurationManager::GROUP_ALIASES_TABLE_NAME,
true );
2507 TableView* tableView = groupAliasTable.tableView_;
2510 unsigned int row = 0;
2512 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
2513 cfgMgr->
getNode(ConfigurationManager::GROUP_ALIASES_TABLE_NAME)
2515 std::string groupName, groupKey;
2516 for(
auto& aliasNodePair : aliasNodePairs)
2518 groupName = aliasNodePair.second.getNode(
"GroupName").getValueAsString();
2519 groupKey = aliasNodePair.second.getNode(
"GroupKey").getValueAsString();
2521 __GEN_COUT__ <<
"Group Alias: " << aliasNodePair.first <<
" => "
2522 << groupName <<
"(" << groupKey <<
"); row=" << row << __E__;
2524 if(groupName == originalGroupName_ &&
2527 __GEN_COUT__ <<
"Found alias! Changing group key from ("
2528 << originalGroupKey_ <<
") to (" << newGroupKey <<
")"
2531 groupAliasChange =
true;
2540 if(groupAliasChange)
2542 std::stringstream ss;
2543 tableView->print(ss);
2544 __GEN_COUT__ << ss.str();
2548 if(groupType_ != ConfigurationManager::GroupType::BACKBONE_TYPE &&
2554 .getTableEditStruct(ConfigurationManager::VERSION_ALIASES_TABLE_NAME,
2558 for(
auto& groupTable : groupTables_)
2560 if(groupTable.second.originalVersion_ ==
2561 groupMembers_.at(groupTable.second.tableName_))
2564 __GEN_COUT__ <<
"Checking alias... original version is "
2565 << groupTable.second.tableName_ <<
"-v"
2566 << groupTable.second.originalVersion_
2567 <<
" and new version is v"
2568 << groupMembers_.at(groupTable.second.tableName_) << __E__;
2571 unsigned int row = 0;
2573 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
2574 cfgMgr->
getNode(ConfigurationManager::VERSION_ALIASES_TABLE_NAME)
2576 std::string tableName, tableVersion;
2577 for(
auto& aliasNodePair : aliasNodePairs)
2580 aliasNodePair.second.getNode(
"TableName").getValueAsString();
2582 aliasNodePair.second.getNode(
"Version").getValueAsString();
2584 __GEN_COUT__ <<
"Table Alias: " << aliasNodePair.first <<
" => "
2585 << tableName <<
"-v" << tableVersion <<
"" << __E__;
2587 if(tableName == groupTable.second.tableName_ &&
2588 TableVersion(tableVersion) == groupTable.second.originalVersion_)
2590 __GEN_COUT__ <<
"Found alias! Changing icon table version alias."
2593 tableAliasChange =
true;
2596 groupMembers_.at(groupTable.second.tableName_).toString(),
2598 tableView->
findCol(
"Version"));
2605 if(tableAliasChange)
2607 std::stringstream ss;
2608 tableView->print(ss);
2609 __GEN_COUT__ << ss.str();
2615 if(groupAliasChange || tableAliasChange)
2617 for(
auto& table : backboneGroupEdit.groupMembers_)
2619 __GEN_COUT__ << table.first <<
" v" << table.second << __E__;
2621 backboneGroupEdit.saveChanges(
2622 backboneGroupEdit.originalGroupName_,
2623 localNewBackboneKey,
2624 foundEquivalentBackboneKey ? foundEquivalentBackboneKey :
nullptr);
2627 *newBackboneKey = localNewBackboneKey;
2634 <<
"Restoring active table groups, before activating new groups..."
2637 std::string localAccumulatedWarnings;
2641 ConfigurationManager::LoadGroupType::
2643 &localAccumulatedWarnings);
2649 backboneGroupEdit.originalGroupName_,
2650 localNewBackboneKey,
2651 accumulatedWarnings ? accumulatedWarnings :
nullptr);
2660 <<
"Restoring active table groups, before activating new groups..."
2663 std::string localAccumulatedWarnings;
2667 ConfigurationManager::LoadGroupType::
2669 &localAccumulatedWarnings);
2673 if(activateNewGroup)
2676 accumulatedWarnings ? accumulatedWarnings :
nullptr);
2678 __GEN_COUT__ <<
"Changes saved." << __E__;
2687 __GEN_COUTV__(runTimeSeconds());
2689 std::string accumulatedWarningsStr;
2690 std::string* accumulatedWarnings = &accumulatedWarningsStr;
2695 std::string debugGroupName =
"Mu2eHWEmulatorContext";
2700 theInterface_->findLatestGroupKey(debugGroupName);
2701 __GEN_COUTV__(latestGroupKey);
2703 __GEN_COUTV__(runTimeSeconds());
2710 std::set<std::string > tableGroups =
2711 theInterface_->getAllTableGroupNames();
2712 __GEN_COUT__ <<
"Number of Groups: " << tableGroups.size() << __E__;
2714 __GEN_COUTV__(runTimeSeconds());
2719 for(
const auto& fullName : tableGroups)
2722 cacheGroupKey(name, key);
2724 if(name == debugGroupName)
2729 __GEN_COUTV__(runTimeSeconds());
2731 std::set<std::string > tableNames = theInterface_->getAllTableNames();
2732 __GEN_COUT__ <<
"Number of Tables: " << tableNames.size() << __E__;
2734 __GEN_COUTV__(runTimeSeconds());
2736 for(
const auto& fullName : tableNames)
2738 if(fullName.find(debugGroupName) != std::string::npos)
2740 __GEN_COUTV__(fullName);
2743 __GEN_COUTV__(runTimeSeconds());
2745 TableGroupKey latestGroupKey = theInterface_->findLatestGroupKey(debugGroupName);
2746 __GEN_COUTV__(latestGroupKey);
2748 __GEN_COUTV__(runTimeSeconds());
2753 TableBase::GROUP_CACHE_PREPEND + debugGroupName);
2755 theInterface_->findLatestVersion(&localGroupMemberCacheSaver);
2756 __GEN_COUTV__(lastestGroupCacheKey);
2758 __GEN_COUTV__(runTimeSeconds());
2764 __GEN_COUT__ <<
"Testing group save of pre-existing " << debugGroupName <<
"("
2765 << groupKey <<
")" << __E__;
2766 std::map<std::string, TableVersion> groupMembers;
2768 theInterface_->saveTableGroup(
2774 __GEN_COUT__ <<
"Exception during group save." << __E__;
2776 __GEN_COUTV__(runTimeSeconds());
2781 std::string debugGroupName =
"testGroupSave";
2783 __GEN_COUT__ <<
"Testing group save of non-existing " << debugGroupName <<
"("
2784 << groupKey <<
")" << __E__;
2785 std::map<std::string, TableVersion> groupMembers;
2787 groupMembers[
"MessageFacilityTable"] =
TableVersion(7);
2788 theInterface_->saveTableGroup(
2794 __GEN_COUT__ <<
"Exception during new group save." << __E__;
2796 __GEN_COUTV__(runTimeSeconds());
2800 std::string documentNameToLoad =
"XDAQApplicationTable";
2803 __GEN_COUT__ <<
"Testing table save of pre-existing " << documentNameToLoad
2808 documentNameToLoad);
2809 localDocLoader.changeVersionAndActivateView(
2811 theInterface_->fill(&localDocLoader, documentVersionToLoad);
2813 localDocLoader.
print(ss);
2814 __GEN_COUTV__(ss.str());
2816 __GEN_COUTV__(runTimeSeconds());
2820 std::string documentNameToSave = documentNameToLoad;
2823 documentNameToSave);
2824 localDocSaver.changeVersionAndActivateView(
2827 std::string json =
"{ }";
2830 __COUTT__ <<
"Saving JSON string: "
2833 __COUTT__ <<
"Saving JSON doc as "
2834 << localDocSaver.getView().getTableName() <<
"("
2835 << localDocSaver.getView().getVersion().
toString() <<
")"
2839 theInterface_->saveActiveVersion(&localDocSaver,
false );
2843 __GEN_COUT__ <<
"Exception during table save." << __E__;
2845 __GEN_COUTV__(runTimeSeconds());
2849 documentNameToLoad);
2850 localDocLoader.changeVersionAndActivateView(
2852 theInterface_->fill(&localDocLoader, documentVersionToLoad);
2854 localDocLoader.
print(ss);
2855 __GEN_COUTV__(ss.str());
2857 __GEN_COUTV__(runTimeSeconds());
2859 __GEN_COUTV__(runTimeSeconds());
2863 std::string documentNameToLoad =
"MessageFacilityTable";
2866 documentNameToLoad);
2868 __GEN_COUT__ <<
"Testing table save of non-existing " << documentNameToLoad
2872 localDocLoader.changeVersionAndActivateView(
2874 theInterface_->fill(&localDocLoader, documentVersionToLoad);
2876 localDocLoader.
print(ss);
2877 __GEN_COUTV__(ss.str());
2878 __GEN_COUTV__(runTimeSeconds());
2880 __GEN_COUTV__(runTimeSeconds());
2887 theInterface_->findLatestVersion(&localDocLoader));
2888 localDocLoader.getViewP()->
setVersion(newVersion);
2890 __GEN_COUTT__ <<
"Saving new table as "
2891 << localDocLoader.getView().getTableName() <<
"("
2892 << localDocLoader.getView().getVersion().
toString() <<
")"
2896 "10.226.9.17", 0, 4);
2899 localDocLoader.
print(ss);
2900 __GEN_COUTV__(ss.str());
2907 __GEN_COUT__ <<
"Exception during new table save." << __E__;
2909 __GEN_COUTV__(runTimeSeconds());
2911 __GEN_COUTV__(runTimeSeconds());
2915 for(
auto& groupInfo : allGroupInfo_)
2920 groupInfo.second.getLatestKey(),
2922 &groupInfo.second.latestKeyMemberMap_ ,
2925 &groupInfo.second.latestKeyGroupComment_,
2926 &groupInfo.second.latestKeyGroupAuthor_,
2927 &groupInfo.second.latestKeyGroupCreationTime_,
2929 &groupInfo.second.latestKeyGroupTypeString_);
2931 catch(
const std::runtime_error& e)
2934 <<
"Error occurred loading latest group info into cache for '"
2935 << groupInfo.first <<
"(" << groupInfo.second.getLatestKey()
2937 << e.what() << __E__;
2939 groupInfo.second.latestKeyGroupComment_ =
2940 ConfigurationManager::UNKNOWN_INFO;
2941 groupInfo.second.latestKeyGroupAuthor_ =
2942 ConfigurationManager::UNKNOWN_INFO;
2943 groupInfo.second.latestKeyGroupCreationTime_ =
2944 ConfigurationManager::UNKNOWN_TIME;
2945 groupInfo.second.latestKeyGroupTypeString_ =
2946 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
2947 groupInfo.second.latestKeyMemberMap_ = {};
2952 <<
"Error occurred loading latest group info into cache for '"
2953 << groupInfo.first <<
"(" << groupInfo.second.getLatestKey()
2954 <<
")'..." << __E__;
2955 groupInfo.second.latestKeyGroupComment_ =
2956 ConfigurationManager::UNKNOWN_INFO;
2957 groupInfo.second.latestKeyGroupAuthor_ =
2958 ConfigurationManager::UNKNOWN_INFO;
2959 groupInfo.second.latestKeyGroupCreationTime_ =
2960 ConfigurationManager::UNKNOWN_TIME;
2961 groupInfo.second.latestKeyGroupTypeString_ =
2962 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
2963 groupInfo.second.latestKeyMemberMap_ = {};
2966 __GEN_COUTV__(runTimeSeconds());
2968 catch(
const std::runtime_error& e)
2970 __SS__ <<
"A fatal error occurred reading the info for all table groups. Error: "
2971 << e.what() << __E__;
2972 __GEN_COUT_ERR__ <<
"\n" << ss.str();
2973 if(accumulatedWarnings)
2974 *accumulatedWarnings += ss.str();
2980 __SS__ <<
"An unknown fatal error occurred reading the info for all table groups."
2982 __GEN_COUT_ERR__ <<
"\n" << ss.str();
2983 if(accumulatedWarnings)
2984 *accumulatedWarnings += ss.str();
2989 __GEN_COUT__ <<
"testXDAQContext() end runTimeSeconds()=" << runTimeSeconds()
2995 __GEN_COUT__ <<
"Loading table..." << __E__;
3001 __GEN_COUT__ << __E__;
3003 __GEN_COUT__ <<
"Value: " << v << __E__;
3004 __GEN_COUT__ <<
"Value index: " << t.
getValue<
int>() << __E__;
3010 __GEN_COUT__ <<
"Failed to load table..." << __E__;
TableVersion saveNewVersion(TableBase *configuration, TableVersion temporaryVersion, TableVersion newVersion=TableVersion())
TableVersion saveNewTable(const std::string &tableName, TableVersion temporaryVersion=TableVersion(), bool makeTemporary=false)
modifiers of generic TableBase
TableGroupKey findTableGroup(const std::string &groupName, const std::map< std::string, TableVersion > &groupMembers, const std::map< std::string, std::string > &groupAliases=std::map< std::string, std::string >())
void testXDAQContext(void)
for debugging
TableVersion saveNewBackbone(TableVersion temporaryVersion=TableVersion())
void clearAllCachedVersions(void)
const std::map< std::string, TableInfo > & getAllTableInfo(bool refresh=false, std::string *accumulatedWarnings=0, const std::string &errorFilterName="", bool getGroupKeys=false, bool getGroupInfo=false, bool initializeActiveGroups=false)
TableVersion copyViewToCurrentColumns(const std::string &tableName, TableVersion sourceVersion)
copyViewToCurrentColumns
TableGroupKey saveNewTableGroup(const std::string &groupName, std::map< std::string, TableVersion > &groupMembers, const std::string &groupComment=TableViewColumnInfo::DATATYPE_COMMENT_DEFAULT, std::map< std::string, std::string > *groupAliases=0)
modifiers of a table group based on alias, e.g. "Physics"
void activateTableGroup(const std::string &tableGroupName, TableGroupKey tableGroupKey, std::string *accumulatedTreeErrors=0, std::string *groupTypeString=0)
modifiers of table groups
TableBase * getMetadataTable(TableVersion fillVersion=TableVersion())
created for use in otsdaq_flatten_system_aliases and otsdaq_export_system_aliases,...
TableVersion saveModifiedVersion(const std::string &tableName, TableVersion originalVersion, bool makeTemporary, TableBase *config, TableVersion temporaryModifiedVersion, bool ignoreDuplicates=false, bool lookForEquivalent=false, bool *foundEquivalent=nullptr)
TableVersion createTemporaryBackboneView(TableVersion sourceViewVersion=TableVersion())
-1, from MockUp, else from valid backbone view version
const GroupInfo & getGroupInfo(const std::string &groupName)
public group cache handling
void clearCachedVersions(const std::string &tableName)
std::map< std::string, std::map< std::string, TableVersion > > getVersionAliases(void) const
void eraseTemporaryVersion(const std::string &tableName, TableVersion targetVersion=TableVersion())
TableBase * getVersionedTableByName(const std::string &tableName, TableVersion version, bool looseColumnMatching=false, std::string *accumulatedErrors=0, bool getRawData=false)
static void compareTableGroupThread(ConfigurationManagerRW *cfgMgr, std::string groupName, ots::TableGroupKey groupKeyToCompare, const std::map< std::string, TableVersion > &groupMemberMap, const std::map< std::string, std::string > &memberTableAliases, std::atomic< bool > *theFoundIdentical, ots::TableGroupKey *theIdenticalKey, std::mutex *theThreadMutex, std::shared_ptr< std::atomic< bool >> theThreadDone)
static void loadTableGroupThread(ConfigurationManagerRW *cfgMgr, std::string groupName, ots::TableGroupKey groupKey, std::shared_ptr< ots::GroupInfo > theGroupInfo, std::shared_ptr< std::atomic< bool >> theThreadDone)
loadTableGroupThread()
static void loadTableInfoThread(ConfigurationManagerRW *cfgMgr, std::string tableName, TableBase *existingTable, std::shared_ptr< ots::TableInfo > tableInfo, std::shared_ptr< std::atomic< bool >> threadDone)
loadTableInfoThread()
std::map< std::string, std::map< std::string, TableVersion > > getVersionAliases(void) const
void loadTableGroup(const std::string &tableGroupName, const TableGroupKey &tableGroupKey, bool doActivate=false, std::map< std::string, TableVersion > *groupMembers=0, ProgressBar *progressBar=0, std::string *accumulateWarnings=0, std::string *groupComment=0, std::string *groupAuthor=0, std::string *groupCreateTime=0, bool doNotLoadMember=false, std::string *groupTypeString=0, std::map< std::string, std::string > *groupAliases=0, ConfigurationManager::LoadGroupType onlyLoadIfBackboneOrContext=ConfigurationManager::LoadGroupType::ALL_TYPES, bool ignoreVersionTracking=false)
static const unsigned int PROCESSOR_COUNT
Static members.
static const std::string & convertGroupTypeToName(const ConfigurationManager::GroupType &groupTypeId)
void restoreActiveTableGroups(bool throwErrors=false, const std::string &pathToActiveGroupsFile="", ConfigurationManager::LoadGroupType onlyLoadIfBackboneOrContext=ConfigurationManager::LoadGroupType::ALL_TYPES, std::string *accumulatedWarnings=0)
std::map< std::string, TableVersion > getActiveVersions(void) const
getActiveVersions
ConfigurationTree getNode(const std::string &nodeString, bool doNotThrowOnBrokenUIDLinks=false) const
"root/parent/parent/"
void init(std::string *accumulatedErrors=0, bool initForWriteAccess=false, std::string *accumulatedWarnings=0)
void destroyTableGroup(const std::string &theGroup="", bool onlyDeactivate=false)
static const std::string ACTIVE_GROUPS_FILENAME
added env check for otsdaq_flatten_active_to_version to function
const TableBase * getTableByName(const std::string &configurationName) const
friend class ConfigurationManagerRW
void getValue(T &value) const
std::vector< std::pair< std::string, ConfigurationTree > > getChildren(std::map< std::string, std::string > filterMap=std::map< std::string, std::string >(), bool byPriority=false, bool onlyStatusTrue=false) const
TableVersion createTemporaryView(TableVersion sourceViewVersion=TableVersion(), TableVersion destTemporaryViewVersion=TableVersion::getNextTemporaryVersion())
source of -1, from MockUp, else from valid view version
void trimTemporary(TableVersion targetVersion=TableVersion())
unsigned int getNumberOfStoredViews(void) const
TableVersion checkForDuplicate(TableVersion needleVersion, TableVersion ignoreVersion=TableVersion()) const
TableView * getTemporaryView(TableVersion temporaryVersion)
const unsigned int MAX_VIEWS_IN_CACHE
TableVersion getNextVersion(void) const
TableVersion copyView(const TableView &sourceView, TableVersion destinationVersion, const std::string &author, bool looseColumnMatching=false)
void print(std::ostream &out=std::cout) const
always prints active view
TableVersion getNextTemporaryVersion(void) const
void trimCache(unsigned int trimSize=-1)
std::string toString(void) const
toString
static TableGroupKey getNextKey(const TableGroupKey &key=TableGroupKey())
static void getGroupNameAndKey(const std::string &fullGroupString, std::string &groupName, TableGroupKey &key)
requires fullGroupString created as name + "_v" + key + ""
bool isInvalid(void) const
isInvalid
static std::string getFullGroupString(const std::string &groupName, const TableGroupKey &key, const std::string &preKey="_v", const std::string &postKey="")
std::string toString(void) const
toString
bool isInvalid(void) const
isInvalid
static TableVersion getNextVersion(const TableVersion &version=TableVersion())
bool isScratchVersion(void) const
bool isTemporaryVersion(void) const
static TableVersion getNextTemporaryVersion(const TableVersion &version=TableVersion())
void setValueAsString(const std::string &value, unsigned int row, unsigned int col)
void setVersion(const T &version)
< in included .icc source
const std::string & getCustomStorageData(void) const
Getters.
int fillFromJSON(const std::string &json)
unsigned int findCol(const std::string &name) const
void setCustomStorageData(const std::string &storageData)
TableEditStruct & getTableEditStruct(const std::string &tableName, bool markModified=false)
Note: if markModified, and table not found in group, this function will try to add it to group.
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 std::string stackTrace(void)