1 #include "otsdaq/MessageFacility/MessageFacility.h"
9 #include "otsdaq/ConfigurationInterface/ConfigurationInterface.h"
10 #include "otsdaq/ConfigurationInterface/ConfigurationManagerRW.h"
22 void FlattenActiveSystemAliasTableGroups(
int argc,
char* argv[])
25 if(getenv(
"SERVICE_DATA_PATH") == NULL)
26 setenv(
"SERVICE_DATA_PATH",
27 (std::string(__ENV__(
"USER_DATA")) +
"/ServiceData").c_str(),
30 std::cout <<
"=================================================\n";
31 std::cout <<
"=================================================\n";
32 std::cout <<
"=================================================\n";
33 __COUT__ <<
"\nFlattening Active System Aliases!" << std::endl;
35 std::cout <<
"\n\nusage: Two arguments:\n\t <baseFlatVersion> <pathToSwapIn "
37 <<
"\t Default values: baseFlatVersion = 0, pathToSwapIn = \"\" \n\n"
40 std::cout <<
"\n\nNote: you can optionally just swap databases (and not modify their "
42 <<
" by providing an invalid baseFlatVersion of -1.\n\n"
45 std::cout <<
"\n\nNote: This assumes artdaq db file type interface. "
46 <<
"The current database/ will be moved to database_<linuxtime>/ "
47 <<
"and if a pathToSwapIn is specified it will be copied to database/ "
48 <<
"before saving the currently active groups.\n\n"
51 std::cout <<
"argc = " << argc << std::endl;
52 for(
int i = 0; i < argc; i++)
53 std::cout <<
"argv[" << i <<
"] = " << argv[i] << std::endl;
57 std::cout <<
"Error! Must provide at least one parameter.\n\n" << std::endl;
62 std::string flatVersionStr = argv[1];
63 if(flatVersionStr.find(
'h') != std::string::npos)
66 <<
"Recognized parameter 1. as a 'help' option. Usage was printed. Exiting."
72 std::string pathToSwapIn =
"";
74 sscanf(argv[1],
"%d", &flatVersion);
76 pathToSwapIn = argv[2];
78 __COUT__ <<
"flatVersion = " << flatVersion << std::endl;
79 __COUT__ <<
"pathToSwapIn = " << pathToSwapIn << std::endl;
89 setenv(
"CONFIGURATION_TYPE",
"File", 1);
90 setenv(
"CONFIGURATION_DATA_PATH",
91 (std::string(getenv(
"USER_DATA")) +
"/ConfigurationDataExamples").c_str(),
94 "TABLE_INFO_PATH", (std::string(getenv(
"USER_DATA")) +
"/TableInfo").c_str(), 1);
99 setenv(
"OTSDAQ_LIB", (std::string(getenv(
"USER_DATA")) +
"/").c_str(), 1);
100 setenv(
"OTSDAQ_UTILITIES_LIB", (std::string(getenv(
"USER_DATA")) +
"/").c_str(), 1);
103 setenv(
"OTS_MAIN_PORT",
"2015", 1);
106 setenv(
"XDAQ_CONFIGURATION_DATA_PATH",
107 (std::string(getenv(
"USER_DATA")) +
"/XDAQConfigurations").c_str(),
109 setenv(
"XDAQ_CONFIGURATION_XML",
"otsConfigurationNoRU_CMake", 1);
116 __COUT__ <<
"Loading active Aliases..." << std::endl;
121 std::string accumulatedWarnings;
124 ConfigurationManager::LoadGroupType::ALL_TYPES,
125 &accumulatedWarnings);
127 __COUT__ <<
"Done Loading active groups: \n" << accumulatedWarnings << std::endl;
155 std::map<std::pair<std::string, TableGroupKey>,
TableGroupKey> groupSet;
157 std::map<std::pair<std::string, TableVersion>,
TableVersion> modifiedTables;
158 std::map<std::string, std::pair<TableGroupKey, TableGroupKey>> activeGroupKeys;
159 std::map<std::pair<std::string, TableGroupKey>, std::string> groupErrors;
161 std::string activeBackboneGroupName =
"";
162 std::string activeContextGroupName =
"";
163 std::string activeIterateGroupName =
"";
164 std::string activeConfigGroupName =
"";
166 std::string nowTime = std::to_string(time(0));
168 std::string thenTime =
"";
169 if(pathToSwapIn !=
"")
171 thenTime = pathToSwapIn.substr(pathToSwapIn.rfind(
'_') + 1);
172 __COUT__ <<
"thenTime = " << thenTime << std::endl;
177 std::map<std::string, std::pair<std::string, TableGroupKey>> activeGroupsMap =
180 bool foundAnyActiveGroups =
false;
182 for(
const auto& activeGroup : activeGroupsMap)
184 if(activeGroup.second.second.TableGroupKey::isInvalid())
187 groupSet.insert(std::pair<std::pair<std::string, TableGroupKey>,
TableGroupKey>(
188 std::pair<std::string, TableGroupKey>(activeGroup.second.first,
189 activeGroup.second.second),
191 activeGroupKeys.insert(
192 std::pair<std::string, std::pair<TableGroupKey, TableGroupKey>>(
193 activeGroup.second.first,
194 std::pair<TableGroupKey, TableGroupKey>(activeGroup.second.second,
197 if(activeGroup.first == ConfigurationManager::GROUP_TYPE_NAME_BACKBONE)
199 activeBackboneGroupName = activeGroup.second.first;
200 __COUT__ <<
"found activeBackboneGroupName = " << activeBackboneGroupName
202 foundAnyActiveGroups =
true;
204 else if(activeGroup.first == ConfigurationManager::GROUP_TYPE_NAME_CONTEXT)
206 activeContextGroupName = activeGroup.second.first;
207 __COUT__ <<
"found activeContextGroupName = " << activeContextGroupName
209 foundAnyActiveGroups =
true;
211 else if(activeGroup.first == ConfigurationManager::GROUP_TYPE_NAME_ITERATE)
213 activeIterateGroupName = activeGroup.second.first;
214 __COUT__ <<
"found activeIterateGroupName = " << activeIterateGroupName
216 foundAnyActiveGroups =
true;
218 else if(activeGroup.first == ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION)
220 activeConfigGroupName = activeGroup.second.first;
221 __COUT__ <<
"found activeConfigGroupName = " << activeConfigGroupName
223 foundAnyActiveGroups =
true;
227 if(!foundAnyActiveGroups)
229 __SS__ <<
"Did not find any active groups to convert! Should not be possible, "
230 "must have a backbone at least?"
235 __COUT__ <<
"Identified active groups:" << std::endl;
236 for(
auto& group : groupSet)
237 __COUT__ <<
" ==> Group to convert: " << group.first.first <<
" ("
238 << group.first.second <<
")" << std::endl;
242 const std::string groupAliasesTableName =
243 ConfigurationManager::GROUP_ALIASES_TABLE_NAME;
244 std::map<std::string, TableVersion> activeVersions = cfgMgr->
getActiveVersions();
245 if(activeVersions.find(groupAliasesTableName) == activeVersions.end())
247 __SS__ <<
"\nActive version of " << groupAliasesTableName <<
" missing! "
248 << groupAliasesTableName
249 <<
" is a required member of the Backbone configuration group."
250 <<
"\n\nLikely you need to activate a valid Backbone group." << std::endl;
254 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
256 for(
auto& groupPair : aliasNodePairs)
257 groupSet.insert(std::pair<std::pair<std::string, TableGroupKey>,
TableGroupKey>(
258 std::pair<std::string, TableGroupKey>(
259 groupPair.second.getNode(
"GroupName").getValueAsString(),
260 TableGroupKey(groupPair.second.getNode(
"GroupKey").getValueAsString())),
263 __COUT__ <<
"All identified groups:" << std::endl;
264 for(
auto& group : groupSet)
265 __COUT__ <<
" ==> Group to convert: " << group.first.first <<
" ("
266 << group.first.second <<
")" << std::endl;
267 __COUT__ << std::endl;
268 __COUT__ << std::endl;
272 __SS__ <<
"No groups identified to convert!" << __E__;
279 std::string currentDir = __ENV__(
"ARTDAQ_DATABASE_URI");
281 if(currentDir.find(
"filesystemdb://") != 0)
283 __SS__ <<
"filesystemdb:// was not found in $ARTDAQ_DATABASE_URI!" << std::endl;
284 __COUT_ERR__ <<
"\n" << ss.str();
288 currentDir = currentDir.substr(std::string(
"filesystemdb://").length());
289 while(currentDir.length() &&
290 currentDir[currentDir.length() - 1] ==
'/')
291 currentDir = currentDir.substr(0, currentDir.length() - 1);
292 std::string moveToDir = currentDir +
"_" + nowTime;
295 __SS__ << (
"Aborting move! Must at least give version argument to flatten to!")
297 __COUT_ERR__ <<
"\n" << ss.str();
301 if(pathToSwapIn !=
"")
304 if((dp = opendir(pathToSwapIn.c_str())) == 0)
306 __COUT__ <<
"ERROR:(" << errno <<
"). Can't open directory: " << pathToSwapIn
314 __COUT__ <<
"Moving current directory: \t" << currentDir << std::endl;
315 __COUT__ <<
"\t... to: \t\t" << moveToDir << std::endl;
317 rename(currentDir.c_str(), moveToDir.c_str());
319 if(pathToSwapIn !=
"")
321 __COUT__ <<
"Swapping in directory: \t" << pathToSwapIn << std::endl;
322 __COUT__ <<
"\t.. to: \t\t" << currentDir << std::endl;
323 rename(pathToSwapIn.c_str(), currentDir.c_str());
327 std::string activeGroupsFile =
329 FILE* fp = fopen(activeGroupsFile.c_str(),
"r");
332 __COUT__ <<
"Swapping active groups file: \t" << activeGroupsFile
336 rename(activeGroupsFile.c_str(),
342 ConfigurationInterface::CONFIGURATION_MODE::ARTDAQ_DATABASE);
347 std::string accumulateErrors =
"";
351 std::map<std::string , std::string > groupAliases;
352 std::string groupComment;
353 std::string groupAuthor;
354 std::string groupCreateTime;
355 time_t groupCreateTime_t;
356 TableBase* groupMetadataTable = cfgMgr->getMetadataTable();
362 __COUT__ <<
"\n\nflatVersion " <<
TableVersion(flatVersion)
363 <<
" is an invalid or temporary version. Skipping to end!" << std::endl;
367 for(
auto& groupPair : groupSet)
371 __COUT__ <<
"****************************" << std::endl;
372 __COUT__ <<
"Loading members for " << groupPair.first.first <<
"("
373 << groupPair.first.second <<
")" << std::endl;
374 __COUT__ <<
"flatVersion = " << flatVersion << std::endl;
377 if(pathToSwapIn !=
"")
379 __COUT__ <<
"REVERT by Swapping back directory: \t" << currentDir
381 __COUT__ <<
"\t.. to: \t\t" << pathToSwapIn << std::endl;
382 if(rename(currentDir.c_str(), pathToSwapIn.c_str()) < 0)
384 __SS__ <<
"Problem!" << std::endl;
390 __COUT__ <<
"REVERT by Moving directory: \t" << currentDir << std::endl;
391 __COUT__ <<
"\t.. to temporary directory: \t\t" << (moveToDir +
"_tmp")
393 if(rename(currentDir.c_str(), (moveToDir +
"_tmp").c_str()) < 0)
395 __SS__ <<
"Problem!" << std::endl;
400 __COUT__ <<
"REVERT by Moving directory: \t" << moveToDir << std::endl;
401 __COUT__ <<
"\t... to: \t\t" << currentDir << std::endl;
402 if(rename(moveToDir.c_str(), currentDir.c_str()) < 0)
404 __SS__ <<
"Problem!" << std::endl;
412 accumulateErrors =
"";
414 groupPair.first.second,
426 catch(std::runtime_error& e)
428 __COUT__ <<
"Error was caught loading members for " << groupPair.first.first
429 <<
"(" << groupPair.first.second <<
")" << std::endl;
430 __COUT__ << e.what() << std::endl;
435 __COUT__ <<
"Error was caught loading members for " << groupPair.first.first
436 <<
"(" << groupPair.first.second <<
")" << std::endl;
445 __COUT__ <<
"Moving current directory: \t" << currentDir << std::endl;
446 __COUT__ <<
"\t... to: \t\t" << moveToDir << std::endl;
447 if(rename(currentDir.c_str(), moveToDir.c_str()) < 0)
449 __SS__ <<
"Problem!" << std::endl;
453 if(pathToSwapIn !=
"")
455 __COUT__ <<
"Swapping in directory: \t" << pathToSwapIn << std::endl;
456 __COUT__ <<
"\t.. to: \t\t" << currentDir << std::endl;
457 if(rename(pathToSwapIn.c_str(), currentDir.c_str()) < 0)
459 __SS__ <<
"Problem!" << std::endl;
465 __COUT__ <<
"Moving temporary directory: \t" << (moveToDir +
"_tmp")
467 __COUT__ <<
"\t.. to current directory: \t\t" << currentDir << std::endl;
468 if(rename((moveToDir +
"_tmp").c_str(), currentDir.c_str()) < 0)
470 __SS__ <<
"Problem!" << std::endl;
484 std::pair<std::pair<std::string, TableGroupKey>, std::string>(
485 std::pair<std::string, TableGroupKey>(groupPair.first.first,
486 groupPair.first.second),
487 "Error caught loading the group."));
496 for(
auto& memberPair : memberMap)
498 __COUT__ << memberPair.first <<
":v" << memberPair.second << std::endl;
502 if(modifiedTables.find(std::pair<std::string, TableVersion>(
503 memberPair.first, memberPair.second)) != modifiedTables.end())
505 __COUT__ <<
"Table was already modified!" << std::endl;
507 modifiedTables[std::pair<std::string, TableVersion>(
508 memberPair.first, memberPair.second)];
509 __COUT__ <<
"\t to...\t" << memberPair.first <<
":v"
510 << memberPair.second << std::endl;
515 config = cfgMgr->getTableByName(memberPair.first);
516 cfgView = config->getViewP();
518 theInterface_->saveActiveVersion(config);
525 modifiedTables.insert(
526 std::pair<std::pair<std::string, TableVersion>,
TableVersion>(
527 std::pair<std::string, TableVersion>(memberPair.first,
531 memberPair.second = flatVersion;
533 __COUT__ <<
"\t to...\t" << memberPair.first <<
":v" << memberPair.second
541 __COUTV__(groupComment);
542 __COUTV__(groupAuthor);
543 __COUTV__(groupCreateTime);
544 sscanf(groupCreateTime.c_str(),
"%ld", &groupCreateTime_t);
545 __COUTV__(groupCreateTime_t);
549 while(groupMetadataTable->getViewP()->getNumberOfRows() > 1)
550 groupMetadataTable->getViewP()->
deleteRow(0);
551 if(groupMetadataTable->getViewP()->getNumberOfRows() == 0)
552 groupMetadataTable->getViewP()->
addRow();
556 groupMetadataTable->getViewP()->
setValue(
558 groupAliases,
"," ,
":" ),
560 ConfigurationManager::METADATA_COL_ALIASES);
561 groupMetadataTable->getViewP()->
setValue(
562 groupComment, 0, ConfigurationManager::METADATA_COL_COMMENT);
563 groupMetadataTable->getViewP()->
setValue(
564 groupAuthor, 0, ConfigurationManager::METADATA_COL_AUTHOR);
565 groupMetadataTable->getViewP()->
setValue(
566 groupCreateTime_t, 0, ConfigurationManager::METADATA_COL_TIMESTAMP);
570 theInterface_->saveActiveVersion(groupMetadataTable);
578 theInterface_->saveTableGroup(
587 if(activeGroupKeys.find(groupPair.first.first) != activeGroupKeys.end() &&
588 activeGroupKeys[groupPair.first.first].first == groupPair.first.second)
589 activeGroupKeys[groupPair.first.first].second =
592 catch(std::runtime_error& e)
594 __COUT__ <<
"Error was caught saving group " << groupPair.first.first <<
" ("
595 << groupPair.first.second <<
") " << std::endl;
596 __COUT__ << e.what() << std::endl;
599 std::pair<std::pair<std::string, TableGroupKey>, std::string>(
600 std::pair<std::string, TableGroupKey>(groupPair.first.first,
601 groupPair.first.second),
602 "Error caught saving the group."));
606 __COUT__ <<
"Error was caught saving group " << groupPair.first.first <<
" ("
607 << groupPair.first.second <<
") " << std::endl;
610 std::pair<std::pair<std::string, TableGroupKey>, std::string>(
611 std::pair<std::string, TableGroupKey>(groupPair.first.first,
612 groupPair.first.second),
613 "Error caught saving the group."));
624 FILE* fp = fopen((moveToDir +
"/README_otsdaq_flatten.txt").c_str(),
"a");
626 __COUT__ <<
"\tError opening README file!" << std::endl;
634 timeinfo = localtime(&rawtime);
635 strftime(buffer, 200,
"%b %d, %Y %I:%M%p %Z", timeinfo);
638 "This database was moved from...\n\t %s \nto...\n\t %s \nat this "
639 "time \n\t %lu \t %s\n\n\n",
651 FILE* fp = fopen((currentDir +
"/README_otsdaq_flatten.txt").c_str(),
"a");
654 __COUT__ <<
"\tError opening README file!" << std::endl;
662 timeinfo = localtime(&rawtime);
663 strftime(buffer, 200,
"%b %d, %Y %I:%M:%S%p %Z", timeinfo);
666 "This database was moved from...\t %s \t to...\t %s at this time \t "
668 pathToSwapIn.c_str(),
702 if(activeBackboneGroupName ==
"")
704 __COUT__ <<
"No active Backbone table identified." << std::endl;
710 <<
"Modifying the active Backbone table to reflect new table versions and "
716 activeGroupKeys[activeBackboneGroupName].second,
725 const std::string groupAliasesName =
726 ConfigurationManager::GROUP_ALIASES_TABLE_NAME;
727 const std::string versionAliasesName =
728 ConfigurationManager::VERSION_ALIASES_TABLE_NAME;
733 if(activeMap.find(groupAliasesName) != activeMap.end())
735 __COUT__ <<
"\n\nModifying " << groupAliasesName << std::endl;
736 config = cfgMgr->getTableByName(groupAliasesName);
737 cfgView = config->getViewP();
739 unsigned int col1 = cfgView->
findCol(
"GroupName");
740 unsigned int col2 = cfgView->
findCol(
"GroupKey");
747 for(
unsigned int row = 0; row < cfgView->getNumberOfRows(); ++row)
750 for(
const auto& group : groupSet)
751 if(group.second.isInvalid())
753 else if(cfgView->getDataView()[row][col1] == group.first.first &&
754 cfgView->getDataView()[row][col2] ==
755 group.first.second.toString())
758 __COUT__ <<
"Changing row " << row <<
" for "
759 << cfgView->getDataView()[row][col1]
760 <<
" key=" << cfgView->getDataView()[row][col2]
761 <<
" to NEW key=" << group.second << std::endl;
762 cfgView->
setValue(group.second.toString(), row, col2);
774 if(activeMap.find(versionAliasesName) != activeMap.end())
776 __COUT__ <<
"\n\nModifying " << versionAliasesName << std::endl;
777 config = cfgMgr->getTableByName(versionAliasesName);
778 cfgView = config->getViewP();
779 unsigned int col1 = cfgView->
findCol(
"TableName");
780 unsigned int col2 = cfgView->
findCol(
"Version");
784 for(
unsigned int row = 0; row < cfgView->getNumberOfRows(); ++row)
787 for(
const auto& table : modifiedTables)
788 if(cfgView->getDataView()[row][col1] == table.first.first &&
789 cfgView->getDataView()[row][col2] == table.first.second.toString())
792 __COUT__ <<
"Changing row " << row <<
" for "
793 << cfgView->getDataView()[row][col1]
794 <<
" version=" << cfgView->getDataView()[row][col2]
795 <<
" to NEW version=" << table.second << std::endl;
796 cfgView->
setValue(table.second.toString(), row, col2);
808 __COUT__ << groupAliasesName <<
":v" << memberMap[groupAliasesName] << std::endl;
810 config = cfgMgr->getTableByName(groupAliasesName);
811 cfgView = config->getViewP();
813 theInterface_->saveActiveVersion(config);
815 memberMap[groupAliasesName] = flatVersion;
817 __COUT__ <<
"\t to...\t" << groupAliasesName <<
":v"
818 << memberMap[groupAliasesName] << std::endl;
820 __COUT__ << versionAliasesName <<
":v" << memberMap[versionAliasesName]
823 config = cfgMgr->getTableByName(versionAliasesName);
824 cfgView = config->getViewP();
826 theInterface_->saveActiveVersion(config);
828 memberMap[versionAliasesName] = flatVersion;
830 __COUT__ <<
"\t to...\t" << versionAliasesName <<
":v"
831 << memberMap[versionAliasesName] << std::endl;
834 theInterface_->saveTableGroup(
839 activeGroupKeys[activeBackboneGroupName].second =
TableGroupKey(flatVersion);
841 __COUT__ <<
"New to-be-active backbone group " << activeBackboneGroupName <<
":v"
842 << activeGroupKeys[activeBackboneGroupName].second << std::endl;
851 << __COUT_HDR_FL__ <<
"Manipulating the Active Groups file..."
858 __SS__ <<
"Original active groups file '"
869 std::string renameFile =
873 __COUT__ <<
"Backup file name: " << renameFile << std::endl;
875 TableGroupKey *theConfigurationTableGroupKey_, *theContextTableGroupKey_,
876 *theBackboneTableGroupKey_, *theIterateTableGroupKey_;
877 std::string theConfigurationTableGroup_, theContextTableGroup_,
878 theBackboneTableGroup_, theIterateTableGroup_;
880 theConfigurationTableGroup_ = activeConfigGroupName;
881 theConfigurationTableGroupKey_ = &(activeGroupKeys[activeConfigGroupName].second);
883 theContextTableGroup_ = activeContextGroupName;
884 theContextTableGroupKey_ = &(activeGroupKeys[activeContextGroupName].second);
886 theBackboneTableGroup_ = activeBackboneGroupName;
887 theBackboneTableGroupKey_ = &(activeGroupKeys[activeBackboneGroupName].second);
889 theIterateTableGroup_ = activeIterateGroupName;
890 theIterateTableGroupKey_ = &(activeGroupKeys[activeIterateGroupName].second);
894 __COUT__ <<
"Updating persistent active groups to "
899 FILE* fp = fopen(fn.c_str(),
"w");
903 fprintf(fp,
"%s\n", theContextTableGroup_.c_str());
906 theContextTableGroupKey_
907 ? theContextTableGroupKey_->
toString().c_str()
909 fprintf(fp,
"%s\n", theBackboneTableGroup_.c_str());
912 theBackboneTableGroupKey_
913 ? theBackboneTableGroupKey_->
toString().c_str()
915 fprintf(fp,
"%s\n", theConfigurationTableGroup_.c_str());
918 theConfigurationTableGroupKey_
919 ? theConfigurationTableGroupKey_->
toString().c_str()
921 fprintf(fp,
"%s\n", theIterateTableGroup_.c_str());
924 theIterateTableGroupKey_
925 ? theIterateTableGroupKey_->
toString().c_str()
933 std::cout <<
"\n\n" << __COUT_HDR_FL__ <<
"Resulting Groups:" << std::endl;
934 for(
const auto& group : groupSet)
935 __COUT__ <<
"------------ " << group.first.first <<
": " << group.first.second
936 <<
" => " << group.second << std::endl;
937 std::cout <<
"\n\n" << __COUT_HDR_FL__ <<
"Resulting Groups end." << std::endl;
941 std::cout <<
"\n\n" << __COUT_HDR_FL__ <<
"Resulting Active Groups:" << std::endl;
942 for(
const auto& activeGroup : activeGroupKeys)
943 __COUT__ <<
"------------ " << activeGroup.first <<
": "
944 << activeGroup.second.first <<
" => " << activeGroup.second.second
947 __COUT__ << activeBackboneGroupName <<
" is the "
948 << ConfigurationManager::GROUP_TYPE_NAME_BACKBONE <<
"." << std::endl;
949 std::cout <<
"\n\n" << __COUT_HDR_FL__ <<
"Resulting Active Groups end." << std::endl;
954 << __COUT_HDR_FL__ <<
"End of Flattening Active Table Groups!\n\n\n"
957 __COUT__ <<
"****************************" << std::endl;
958 __COUT__ <<
"There were " << groupSet.size() <<
" groups considered, and there were "
959 << groupErrors.size() <<
" errors found handling those groups." << std::endl;
960 if(groupErrors.size())
962 __COUT_ERR__ <<
"There were " << groupErrors.size()
963 <<
" errors found while loading and converting groups. The "
964 "following errors were found handling the groups:"
966 for(
auto& groupErr : groupErrors)
967 __COUT_ERR__ <<
"\t" << groupErr.first.first <<
" " << groupErr.first.second
968 <<
": \t" << groupErr.second << std::endl;
969 __COUT_ERR__ <<
"End of errors.\n\n" << std::endl;
972 __COUT_INFO__ <<
"There were NO ERRORS found while loading and converting groups."
975 __COUT__ <<
"Run the following to return to your previous database structure:"
977 __COUT__ <<
"\t otsdaq_flatten_system_aliases -1 " << moveToDir <<
"\n\n"
983 fopen((currentDir +
"/fromConfigurationToTableConversion").c_str(),
"w");
986 fprintf(fp,
"converted");
992 fopen((currentDir +
"/fromConfigurationToTableConversion2").c_str(),
"w");
995 fprintf(fp,
"converted");
1000 FILE* fp = fopen((currentDir +
"/artdaqDaqTableConversion").c_str(),
"w");
1003 fprintf(fp,
"converted");
1008 FILE* fp = fopen((currentDir +
"/fromIndexRebuild").c_str(),
"w");
1011 fprintf(fp,
"rebuilt");
1019 int main(
int argc,
char* argv[])
1021 if(getenv(
"OTSDAQ_LOG_FHICL") == NULL)
1022 setenv(
"OTSDAQ_LOG_FHICL",
1023 (std::string(__ENV__(
"USER_DATA")) +
1024 "/MessageFacilityConfigurations/MessageFacilityWithCout.fcl")
1028 if(getenv(
"OTSDAQ_LOG_ROOT") == NULL)
1030 "OTSDAQ_LOG_ROOT", (std::string(__ENV__(
"USER_DATA")) +
"/Logs").c_str(), 1);
1032 INIT_MF(
"FlattenSystemAliases");
1033 FlattenActiveSystemAliasTableGroups(argc, argv);
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)
void restoreActiveTableGroups(bool throwErrors=false, const std::string &pathToActiveGroupsFile="", ConfigurationManager::LoadGroupType onlyLoadIfBackboneOrContext=ConfigurationManager::LoadGroupType::ALL_TYPES, std::string *accumulatedWarnings=0)
std::map< std::string, std::pair< std::string, TableGroupKey > > getActiveTableGroups(void) const
std::map< std::string, TableVersion > getActiveVersions(void) const
getActiveVersions
ConfigurationTree getNode(const std::string &nodeString, bool doNotThrowOnBrokenUIDLinks=false) const
"root/parent/parent/"
static const std::string ACTIVE_GROUPS_FILENAME
added env check for otsdaq_flatten_active_to_version to function
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
const std::string & getTableName(void) const
Getters.
const TableVersion & getViewVersion(void) const
always the active one
std::string toString(void) const
toString
static std::string getFullGroupString(const std::string &groupName, const TableGroupKey &key, const std::string &preKey="_v", const std::string &postKey="")
void setVersion(const T &version)
< in included .icc source
unsigned int findCol(const std::string &name) const
void setValue(const T &value, unsigned int row, unsigned int col)
< in included .icc source
unsigned int addRow(const std::string &author="", unsigned char incrementUniqueData=false, const std::string &baseNameAutoUID="", unsigned int rowToAdd=(unsigned int) -1, std::string childLinkIndex="", std::string groupId="")
void INIT_MF(const char *name)
static std::string mapToString(const std::map< std::string, T > &mapToReturn, const std::string &primaryDelimeter=", ", const std::string &secondaryDelimeter=": ")