1 #include "otsdaq-utilities/ConfigurationGUI/ConfigurationGUISupervisor.h"
3 #include "otsdaq/CgiDataUtilities/CgiDataUtilities.h"
4 #include "otsdaq/Macros/CoutMacros.h"
5 #include "otsdaq/Macros/StringMacros.h"
6 #include "otsdaq/MessageFacility/MessageFacility.h"
7 #include "otsdaq/TablePlugins/IterateTable.h"
8 #include "otsdaq/XmlUtilities/HttpXmlDocument.h"
10 #include <boost/stacktrace.hpp>
12 #include "otsdaq/GatewaySupervisor/GatewaySupervisor.h"
13 #include "otsdaq/TablePlugins/ARTDAQTableBase/ARTDAQTableBase.h"
14 #include "otsdaq/TablePlugins/XDAQContextTable/XDAQContextTable.h"
16 #include <xdaq/NamespaceURI.h>
27 #define __MF_SUBJECT__ "CfgGUI"
29 #define TABLE_INFO_PATH std::string(__ENV__("TABLE_INFO_PATH")) + "/"
30 #define TABLE_INFO_EXT std::string("Info.xml")
46 __SUP_COUT__ <<
"Constructor started." << __E__;
51 mkdir(((std::string)ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH).c_str(), 0755);
54 __SUP_COUT__ <<
"Constructor complete." << __E__;
58 ConfigurationGUISupervisor::~ConfigurationGUISupervisor(
void) { destroy(); }
61 void ConfigurationGUISupervisor::init(
void)
63 __SUP_COUT__ <<
"Initializing..." << __E__;
67 __SUP_COUT__ <<
"Activating saved context, which may prepare for normal mode..."
72 __SUP_COUT__ <<
"Done with test context." << __E__;
76 __COUT_WARN__ <<
"Failed test context group activation. otsdaq, in Normal mode, "
77 "will not launch when this test fails. "
78 <<
"Check the active context group from within Wizard Mode."
83 refreshUserSession(
"" , 1);
86 if(CorePropertySupervisorBase::allSupervisorInfo_.isWizardMode())
89 <<
"After successful Config GUI init, marking alive for wiz mode!" << __E__;
90 CorePropertySupervisorBase::
96 void ConfigurationGUISupervisor::destroy(
void)
98 __SUP_COUT__ <<
"Destructing..." << __E__;
101 for(std::map<std::string, ConfigurationManagerRW*>::iterator it =
102 userConfigurationManagers_.begin();
103 it != userConfigurationManagers_.end();
109 userConfigurationManagers_.clear();
111 if(ConfigurationInterface::getInstance() !=
nullptr)
112 delete ConfigurationInterface::getInstance();
117 void ConfigurationGUISupervisor::defaultPage(xgi::Input* in, xgi::Output* out)
119 cgicc::Cgicc cgiIn(in);
120 std::string configWindowName =
122 if(configWindowName ==
"tableEditor")
123 *out <<
"<!DOCTYPE HTML><html lang='en'><frameset col='100%' row='100%'><frame "
124 "src='/WebPath/html/ConfigurationTableEditor.html?urn="
125 << this->getApplicationDescriptor()->getLocalId() <<
"'></frameset></html>";
126 if(configWindowName ==
"iterate")
127 *out <<
"<!DOCTYPE HTML><html lang='en'><frameset col='100%' row='100%'><frame "
128 "src='/WebPath/html/Iterate.html?urn="
129 << this->getApplicationDescriptor()->getLocalId() <<
"'></frameset></html>";
131 *out <<
"<!DOCTYPE HTML><html lang='en'><frameset col='100%' row='100%'><frame "
132 "src='/WebPath/html/ConfigurationGUI.html?urn="
133 << this->getApplicationDescriptor()->getLocalId() <<
"'></frameset></html>";
141 CorePropertySupervisorBase::setSupervisorProperty(
142 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.UserPermissionsThreshold,
143 "*=10 | deleteTreeNodeRecords=255 | saveTableInfo=255 | "
144 "deleteTableInfo=255");
146 CorePropertySupervisorBase::setSupervisorProperty(
147 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.RequireUserLockRequestTypes,
151 CorePropertySupervisorBase::setSupervisorProperty(
152 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.AutomatedRequestTypes,
"get*");
160 CorePropertySupervisorBase::addSupervisorProperty(
161 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.AutomatedRequestTypes,
162 "getActiveTableGroups");
165 CorePropertySupervisorBase::setSupervisorProperty(
166 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.CheckUserLockRequestTypes,
171 void ConfigurationGUISupervisor::request(
const std::string& requestType,
174 const WebUsers::RequestUserInfo& userInfo)
179 __COUTTV__(requestType);
252 refreshUserSession(userInfo.username_, (refresh ==
"1"));
253 __COUTTV__(userInfo.username_);
259 const std::set<TableGroupKey>& sortedKeys = groupInfo.getKeys();
260 __COUTTV__(sortedKeys.size());
263 if(requestType ==
"saveTableInfo")
265 std::string tableName =
267 std::string columnCSV =
269 std::string allowOverwrite =
271 std::string tableDescription =
273 std::string columnChoicesCSV =
276 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
277 __SUP_COUT__ <<
"columnCSV: " << columnCSV << __E__;
278 __SUP_COUT__ <<
"tableDescription: " << tableDescription << __E__;
279 __SUP_COUT__ <<
"columnChoicesCSV: " << columnChoicesCSV << __E__;
280 __SUP_COUT__ <<
"allowOverwrite: " << allowOverwrite << __E__;
282 if(!allSupervisorInfo_.isWizardMode())
284 __SUP_SS__ <<
"Improper permissions for saving table info." << __E__;
285 xmlOut.addTextElementToData(
"Error", ss.str());
288 handleSaveTableInfoXML(xmlOut,
294 allowOverwrite ==
"1");
296 else if(requestType ==
"deleteTableInfo")
298 std::string tableName =
300 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
301 handleDeleteTableInfoXML(xmlOut, cfgMgr, tableName);
303 else if(requestType ==
"gatewayLaunchOTS" || requestType ==
"gatewayLaunchWiz" ||
304 requestType ==
"flattenToSystemAliases")
307 __SUP_COUT_WARN__ << requestType <<
" command received! " << __E__;
308 __COUT_WARN__ << requestType <<
" command received! " << __E__;
311 __SUP_COUT_INFO__ <<
"Launching " << requestType <<
"... " << __E__;
313 __SUP_COUT__ <<
"Extracting target context hostnames... " << __E__;
314 std::vector<std::string> hostnames;
317 if(requestType ==
"flattenToSystemAliases" &&
318 CorePropertySupervisorBase::allSupervisorInfo_.isWizardMode())
320 hostnames.push_back(__ENV__(
"OTS_CONFIGURATION_WIZARD_SUPERVISOR_SERVER"));
321 __SUP_COUT__ <<
"hostname = " << hostnames.back() << __E__;
332 auto contexts = contextTable->getContexts();
334 for(
const auto& context : contexts)
341 for(i = 0; i < context.address_.size(); ++i)
342 if(context.address_[i] ==
'/')
344 hostnames.push_back(context.address_.substr(j));
345 __SUP_COUT__ <<
"hostname = " << hostnames.back() << __E__;
350 __SUP_SS__ <<
"The Configuration Manager could not be initialized to "
357 catch(
const std::exception& e)
359 ss <<
"Exception message: " << e.what();
365 __SUP_COUT_ERR__ <<
"\n" << ss.str();
370 if(hostnames.size() == 0)
372 __SUP_SS__ <<
"No hostnames found to launch command '" + requestType +
373 "'... Is there a valid Context group activated?"
375 __SUP_COUT_ERR__ <<
"\n" << ss.str();
377 xmlOut.addTextElementToData(
"Error", ss.str());
380 for(
const auto& hostname : hostnames)
382 std::string fn = (std::string(__ENV__(
"SERVICE_DATA_PATH")) +
383 "/StartOTS_action_" + hostname +
".cmd");
384 FILE* fp = fopen(fn.c_str(),
"w");
387 if(requestType ==
"gatewayLaunchOTS")
388 fprintf(fp,
"LAUNCH_OTS");
389 else if(requestType ==
"gatewayLaunchWiz")
390 fprintf(fp,
"LAUNCH_WIZ");
391 else if(requestType ==
"flattenToSystemAliases")
393 fprintf(fp,
"FLATTEN_TO_SYSTEM_ALIASES");
401 __SUP_COUT_ERR__ <<
"Unable to open command file: " << fn << __E__;
404 else if(requestType ==
"versionTracking" || requestType ==
"getVersionTracking")
407 if(requestType ==
"getVersionTracking")
411 __SUP_COUT__ <<
"type: " << type << __E__;
414 xmlOut.addTextElementToData(
415 "versionTrackingStatus",
416 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
417 else if(type ==
"ON")
419 ConfigurationInterface::setVersionTrackingEnabled(
true);
420 xmlOut.addTextElementToData(
421 "versionTrackingStatus",
422 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
424 else if(type ==
"OFF")
426 ConfigurationInterface::setVersionTrackingEnabled(
false);
427 xmlOut.addTextElementToData(
428 "versionTrackingStatus",
429 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
432 else if(requestType ==
"getColumnTypes")
435 std::vector<std::string> allTypes = TableViewColumnInfo::getAllTypesForGUI();
436 std::vector<std::string> allDataTypes =
437 TableViewColumnInfo::getAllDataTypesForGUI();
438 std::map<std::pair<std::string, std::string>, std::string> allDefaults =
441 for(
const auto& type : allTypes)
442 xmlOut.addTextElementToData(
"columnTypeForGUI", type);
443 for(
const auto& dataType : allDataTypes)
444 xmlOut.addTextElementToData(
"columnDataTypeForGUI", dataType);
446 for(
const auto& colDefault : allDefaults)
448 xmlOut.addTextElementToData(
"columnDefaultDataType", colDefault.first.first);
449 xmlOut.addTextElementToData(
"columnDefaultTypeFilter",
450 colDefault.first.second);
451 xmlOut.addTextElementToData(
"columnDefaultValue", colDefault.second);
455 else if(requestType ==
"getGroupAliases")
460 1 == CgiDataUtilities::getDataAsInt(cgiIn,
"reloadActiveGroups");
462 __SUP_COUT__ <<
"reloadActive: " << reloadActive << __E__;
470 catch(std::runtime_error& e)
472 __SUP_SS__ << (
"Error loading active groups!\n\n" + std::string(e.what()))
474 __SUP_COUT_ERR__ <<
"\n" << ss.str();
475 xmlOut.addTextElementToData(
"Error", ss.str());
479 __SUP_SS__ << (
"Error loading active groups!\n\n") << __E__;
484 catch(
const std::exception& e)
486 ss <<
"Exception message: " << e.what();
491 __SUP_COUT_ERR__ <<
"\n" << ss.str();
492 xmlOut.addTextElementToData(
"Error", ss.str());
496 handleGroupAliasesXML(xmlOut, cfgMgr);
498 else if(requestType ==
"setGroupAliasInActiveBackbone")
500 std::string groupAliasCSV =
502 std::string groupNameCSV =
504 std::string groupKeyCSV =
507 __SUP_COUTV__(groupAliasCSV);
508 __SUP_COUTV__(groupNameCSV);
509 __SUP_COUTV__(groupKeyCSV);
511 handleSetGroupAliasInBackboneXML(
512 xmlOut, cfgMgr, groupAliasCSV, groupNameCSV, groupKeyCSV, userInfo.username_);
514 else if(requestType ==
"setTableAliasInActiveBackbone")
516 std::string tableAlias =
518 std::string tableName =
522 __SUP_COUT__ <<
"tableAlias: " << tableAlias << __E__;
523 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
524 __SUP_COUT__ <<
"version: " << version << __E__;
526 handleSetTableAliasInBackboneXML(xmlOut,
533 else if(requestType ==
"setAliasOfGroupMembers")
535 std::string versionAlias =
537 std::string groupName =
541 __SUP_COUT__ <<
"versionAlias: " << versionAlias << __E__;
542 __SUP_COUT__ <<
"groupName: " << groupName << __E__;
543 __SUP_COUT__ <<
"groupKey: " << groupKey << __E__;
545 handleAliasGroupMembersInBackboneXML(xmlOut,
552 else if(requestType ==
"getVersionAliases")
554 handleVersionAliasesXML(xmlOut, cfgMgr);
556 else if(requestType ==
"getTableGroups")
558 bool doNotReturnMembers =
559 CgiDataUtilities::getDataAsInt(cgiIn,
"doNotReturnMembers") == 1
563 __SUP_COUT__ <<
"doNotReturnMembers: " << doNotReturnMembers << __E__;
564 handleTableGroupsXML(xmlOut, cfgMgr, !doNotReturnMembers);
566 else if(requestType ==
"getTableGroupType")
568 std::string tableList =
570 __SUP_COUT__ <<
"tableList: " << tableList << __E__;
572 handleGetTableGroupTypeXML(xmlOut, cfgMgr, tableList);
574 else if(requestType ==
"getTables")
580 filterMode =
"created";
581 __COUT__ <<
"startTime: " << filterStartTime << __E__;
582 __COUT__ <<
"endTime: " << filterEndTime << __E__;
583 __COUT__ <<
"filterMode: " << filterMode << __E__;
585 handleTablesXML(xmlOut, cfgMgr, filterStartTime, filterEndTime, filterMode);
587 else if(requestType ==
"getContextMemberNames")
589 std::set<std::string> members = cfgMgr->getFixedContextMemberNames();
591 for(
auto& member : members)
592 xmlOut.addTextElementToData(
"ContextMember", member);
594 else if(requestType ==
"getBackboneMemberNames")
596 std::set<std::string> members = cfgMgr->getBackboneMemberNames();
598 for(
auto& member : members)
599 xmlOut.addTextElementToData(
"BackboneMember", member);
601 else if(requestType ==
"getIterateMemberNames")
603 std::set<std::string> members = cfgMgr->getIterateMemberNames();
605 for(
auto& member : members)
606 xmlOut.addTextElementToData(
"IterateMember", member);
608 else if(requestType ==
"getSpecificTableGroup")
610 std::string groupName =
614 __SUP_COUT__ <<
"groupName: " << groupName << __E__;
615 __SUP_COUT__ <<
"groupKey: " << groupKey << __E__;
620 else if(requestType ==
"saveNewTableGroup")
622 std::string groupName =
624 bool ignoreWarnings =
625 CgiDataUtilities::getDataAsInt(cgiIn,
"ignoreWarnings");
626 bool allowDuplicates =
627 CgiDataUtilities::getDataAsInt(cgiIn,
"allowDuplicates");
628 bool lookForEquivalent =
629 CgiDataUtilities::getDataAsInt(cgiIn,
"lookForEquivalent");
630 std::string tableList =
632 std::string comment =
635 __SUP_COUT__ <<
"saveNewTableGroup: " << groupName << __E__;
636 __SUP_COUT__ <<
"tableList: " << tableList << __E__;
637 __SUP_COUT__ <<
"ignoreWarnings: " << ignoreWarnings << __E__;
638 __SUP_COUT__ <<
"allowDuplicates: " << allowDuplicates << __E__;
639 __SUP_COUT__ <<
"lookForEquivalent: " << lookForEquivalent << __E__;
640 __SUP_COUT__ <<
"comment: " << comment << __E__;
651 else if(requestType ==
"getSpecificTable")
653 std::string tableName =
656 int dataOffset = CgiDataUtilities::getDataAsInt(cgiIn,
"dataOffset");
657 int chunkSize = CgiDataUtilities::getDataAsInt(
660 bool descriptionOnly = CgiDataUtilities::getDataAsInt(
661 cgiIn,
"descriptionOnly");
662 bool allowIllegalColumns =
663 CgiDataUtilities::getDataAsInt(cgiIn,
"allowIllegalColumns");
664 bool rawData = CgiDataUtilities::getDataAsInt(cgiIn,
"rawData");
666 __SUP_COUT__ <<
"getSpecificTable: " << tableName <<
" versionStr: " << versionStr
667 <<
" chunkSize: " << chunkSize <<
" dataOffset: " << dataOffset
668 <<
" descriptionOnly: " << descriptionOnly
669 <<
" allowIllegalColumns: " << allowIllegalColumns
670 <<
" rawData: " << rawData << __E__;
673 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
675 if(allTableInfo.find(tableName) != allTableInfo.end())
677 if(versionStr ==
"" &&
678 allTableInfo.at(tableName).versions_.size())
681 auto it = allTableInfo.at(tableName).versions_.rbegin();
682 if(it->isScratchVersion())
686 else if(versionStr.find(ConfigurationManager::ALIAS_VERSION_PREAMBLE) == 0)
689 std::map<std::string ,
693 std::string versionAlias;
694 versionAlias = versionStr.substr(
695 ConfigurationManager::ALIAS_VERSION_PREAMBLE.size());
706 if(versionAliases.find(tableName) != versionAliases.end() &&
707 versionAliases[tableName].find(versionAlias) !=
708 versionAliases[tableName].end())
710 version = versionAliases[tableName][versionAlias];
711 __SUP_COUT__ <<
"version alias translated to: " << version << __E__;
716 << versionStr.substr(
717 ConfigurationManager::ALIAS_VERSION_PREAMBLE.size())
718 <<
"'was not found in active version aliases!" << __E__;
721 version = atoi(versionStr.c_str());
724 __SUP_COUT__ <<
"version: " << version << __E__;
726 handleGetTableXML(xmlOut,
734 xmlOut.addTextElementToData(
"DefaultRowValue", userInfo.username_);
736 else if(requestType ==
"saveSpecificTable")
738 std::string tableName =
740 int version = CgiDataUtilities::getDataAsInt(cgiIn,
"version");
741 int dataOffset = CgiDataUtilities::getDataAsInt(cgiIn,
"dataOffset");
742 bool sourceTableAsIs =
743 CgiDataUtilities::getDataAsInt(cgiIn,
"sourceTableAsIs");
744 bool lookForEquivalent =
745 CgiDataUtilities::getDataAsInt(cgiIn,
"lookForEquivalent");
746 int temporary = CgiDataUtilities::getDataAsInt(cgiIn,
"temporary");
747 std::string comment =
754 __SUP_COUT__ <<
"tableName: " << tableName <<
" version: " << version
755 <<
" temporary: " << temporary <<
" dataOffset: " << dataOffset
757 __SUP_COUT__ <<
"comment: " << comment << __E__;
758 __SUP_COUT__ <<
"data: " << data << __E__;
759 __SUP_COUT__ <<
"sourceTableAsIs: " << sourceTableAsIs << __E__;
760 __SUP_COUT__ <<
"lookForEquivalent: " << lookForEquivalent << __E__;
774 else if(requestType ==
"clearTableTemporaryVersions")
776 std::string tableName =
778 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
784 catch(std::runtime_error& e)
786 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
787 xmlOut.addTextElementToData(
788 "Error",
"Error clearing temporary views!\n " + std::string(e.what()));
792 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
793 xmlOut.addTextElementToData(
"Error",
"Error clearing temporary views! ");
796 else if(requestType ==
"clearTableCachedVersions")
798 std::string tableName =
800 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
811 catch(std::runtime_error& e)
813 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
814 xmlOut.addTextElementToData(
815 "Error",
"Error clearing cached views!\n " + std::string(e.what()));
819 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
820 xmlOut.addTextElementToData(
"Error",
"Error clearing cached views! ");
823 else if(requestType ==
"getGroupHistory")
830 __SUP_COUTV__(groupAction);
831 __SUP_COUTV__(groupType);
833 std::vector<std::map<std::string ,
836 groupAction, groupType,
true );
838 for(
const auto& group : groups)
840 auto parentEl = xmlOut.addTextElementToData(
841 "GroupHistoryEntry",
"");
842 for(
const auto& field : group)
846 else if(requestType ==
"getTreeView")
853 int depth = CgiDataUtilities::getDataAsInt(cgiIn,
"depth");
854 bool hideStatusFalse = CgiDataUtilities::getDataAsInt(cgiIn,
"hideStatusFalse");
858 __SUP_COUTT__ <<
"tableGroup: " << tableGroup << __E__;
859 __SUP_COUTT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
860 __SUP_COUTT__ <<
"startPath: " << startPath << __E__;
861 __SUP_COUTT__ <<
"depth: " << depth << __E__;
862 __SUP_COUTT__ <<
"hideStatusFalse: " << hideStatusFalse << __E__;
863 __SUP_COUTT__ <<
"modifiedTables: " << modifiedTables << __E__;
864 __SUP_COUTT__ <<
"filterList: " << filterList << __E__;
866 handleFillTreeViewXML(xmlOut,
878 else if(requestType ==
"getTreeNodeCommonFields")
886 int depth = CgiDataUtilities::getDataAsInt(cgiIn,
"depth");
888 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
889 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
890 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
891 __SUP_COUT__ <<
"depth: " << depth << __E__;
894 __SUP_COUT__ <<
"fieldList: " << fieldList << __E__;
895 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
896 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
898 handleFillTreeNodeCommonFieldsXML(xmlOut,
908 else if(requestType ==
"getUniqueFieldValuesForRecords")
917 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
918 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
919 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
920 __SUP_COUT__ <<
"fieldList: " << fieldList << __E__;
921 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
922 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
924 handleFillUniqueFieldValuesForRecordsXML(xmlOut,
933 else if(requestType ==
"getTreeNodeFieldValues")
942 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
943 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
944 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
945 __SUP_COUT__ <<
"fieldList: " << fieldList << __E__;
946 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
947 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
949 handleFillGetTreeNodeFieldValuesXML(xmlOut,
958 else if(requestType ==
"setTreeNodeFieldValues")
968 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
969 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
970 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
971 __SUP_COUT__ <<
"fieldList: " << fieldList << __E__;
972 __SUP_COUT__ <<
"valueList: " << valueList << __E__;
973 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
974 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
976 handleFillSetTreeNodeFieldValuesXML(xmlOut,
987 else if(requestType ==
"addTreeNodeRecords")
995 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
996 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
997 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
998 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
999 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
1001 handleFillCreateTreeNodeRecordsXML(xmlOut,
1008 userInfo.username_);
1010 else if(requestType ==
"deleteTreeNodeRecords")
1018 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
1019 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
1020 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
1021 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
1022 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
1024 handleFillDeleteTreeNodeRecordsXML(xmlOut,
1032 else if(requestType ==
"renameTreeNodeRecords")
1041 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
1042 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
1043 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
1044 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
1045 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
1046 __SUP_COUTV__(newRecordList);
1048 handleFillRenameTreeNodeRecordsXML(xmlOut,
1057 else if(requestType ==
"copyTreeNodeRecords")
1064 unsigned int numberOfCopies =
1065 CgiDataUtilities::getDataAsInt(cgiIn,
"numberOfCopies");
1069 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
1070 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
1071 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
1072 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
1073 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
1074 __SUP_COUTV__(numberOfCopies);
1076 handleFillCopyTreeNodeRecordsXML(xmlOut,
1085 else if(requestType ==
"getTableStructureStatusAsJSON")
1092 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
1093 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
1094 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
1095 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
1098 setupActiveTablesXML(xmlOut,
1107 xmlOut.addTextElementToData(
1108 "StructureStatusAsJSON",
1111 catch(
const std::runtime_error& e)
1113 __SUP_SS__ <<
"The table plugin feature getStructureStatusAsJSON(), does not "
1114 "seem to be supported for the table '"
1116 <<
".' Make sure you have the expected table plugin in your path, "
1117 "or contact system admins."
1119 ss <<
"Here is the error: " << e.what() << __E__;
1123 else if(requestType ==
"getArtdaqNodes")
1130 bool suppressMultiNode =
1131 1 == CgiDataUtilities::getDataAsInt(cgiIn,
"suppressMultiNode");
1133 __SUP_COUTV__(modifiedTables);
1134 __SUP_COUTT__ <<
"tableGroup: " << tableGroup << __E__;
1135 __SUP_COUTT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
1136 __SUP_COUTT__ <<
"contextGroup: " << contextGroup << __E__;
1137 __SUP_COUTT__ <<
"contextGroupKey: " << contextGroupKey << __E__;
1138 __SUP_COUTT__ <<
"suppressMultiNode: " << suppressMultiNode << __E__;
1140 handleGetArtdaqNodeRecordsXML(xmlOut,
1149 else if(requestType ==
"saveArtdaqNodes")
1153 std::string subsystemString =
1156 __SUP_COUTV__(modifiedTables);
1157 __SUP_COUTV__(nodeString);
1158 __SUP_COUTV__(subsystemString);
1160 handleSaveArtdaqNodeRecordsXML(
1161 nodeString, subsystemString, xmlOut, cfgMgr, modifiedTables);
1163 else if(requestType ==
"getArtdaqNodeLayout")
1165 std::string contextGroupName =
1169 __SUP_COUTV__(contextGroupName);
1170 __SUP_COUTV__(contextGroupKey);
1172 handleLoadArtdaqNodeLayoutXML(
1173 xmlOut, cfgMgr, contextGroupName,
TableGroupKey(contextGroupKey));
1175 else if(requestType ==
"saveArtdaqNodeLayout")
1178 std::string contextGroupName =
1182 __SUP_COUTV__(layout);
1183 __SUP_COUTV__(contextGroupName);
1184 __SUP_COUTV__(contextGroupKey);
1186 handleSaveArtdaqNodeLayoutXML(
1187 xmlOut, cfgMgr, layout, contextGroupName,
TableGroupKey(contextGroupKey));
1189 else if(requestType ==
"checkAffectedActiveGroups")
1194 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
1195 __SUP_COUT__ <<
"groupName: " << groupName << __E__;
1196 __SUP_COUT__ <<
"groupKey: " << groupKey << __E__;
1198 handleGetAffectedGroupsXML(
1199 xmlOut, cfgMgr, groupName,
TableGroupKey(groupKey), modifiedTables);
1201 else if(requestType ==
"SearchFieldInGroup")
1215 __SUP_COUT__ <<
"searchText: " << searchText << __E__;
1216 __SUP_COUT__ <<
"filterValue: " << filterValue << __E__;
1217 __SUP_COUT__ <<
"groupType: " << groupType << __E__;
1218 __SUP_COUT__ <<
"optionGroups: " << optionGroups << __E__;
1219 __SUP_COUT__ <<
"versionsToCheck: " << versionsToCheck << __E__;
1221 handleSearchFieldInGroupXML(xmlOut,
1224 (filterValue ==
"true"),
1229 else if(requestType ==
"SearchFieldInTableVersions")
1233 std::string searchVersionToCheck =
1242 __SUP_COUT__ <<
"searchText: " << searchText << __E__;
1243 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
1244 __SUP_COUT__ <<
"searchVersionToCheck: " << searchVersionToCheck << __E__;
1245 __SUP_COUT__ <<
"activeTablesOnly: " << activeTablesOnly << __E__;
1247 handleSearchFieldInTableXML(xmlOut,
1251 searchVersionToCheck,
1252 (activeTablesOnly ==
"true"));
1254 else if(requestType ==
"saveTreeNodeEdit")
1258 std::string targetTableVersion =
1264 __SUP_COUT__ <<
"editNodeType: " << editNodeType << __E__;
1265 __SUP_COUT__ <<
"targetTable: " << targetTable << __E__;
1266 __SUP_COUT__ <<
"targetTableVersion: " << targetTableVersion << __E__;
1267 __SUP_COUT__ <<
"targetUID: " << targetUID << __E__;
1268 __SUP_COUT__ <<
"targetColumn: " << targetColumn << __E__;
1269 __SUP_COUT__ <<
"newValue: " << newValue << __E__;
1271 handleSaveTreeNodeEditXML(xmlOut,
1279 userInfo.username_);
1281 else if(requestType ==
"getLinkToChoices")
1284 std::string linkToTableVersion =
1291 __SUP_COUT__ <<
"linkToTableName: " << linkToTableName << __E__;
1292 __SUP_COUT__ <<
"linkToTableVersion: " << linkToTableVersion << __E__;
1293 __SUP_COUT__ <<
"linkIdType: " << linkIdType << __E__;
1294 __SUP_COUT__ <<
"linkIndex: " << linkIndex << __E__;
1295 __SUP_COUT__ <<
"linkInitId: " << linkInitId << __E__;
1297 handleGetLinkToChoicesXML(xmlOut,
1305 else if(requestType ==
"activateTableGroup")
1309 bool ignoreWarnings = CgiDataUtilities::getDataAsInt(cgiIn,
"ignoreWarnings");
1311 __SUP_COUT__ <<
"Activating group: " << groupName <<
"(" << groupKey <<
")"
1313 __SUP_COUTV__(ignoreWarnings);
1316 xmlOut.addTextElementToData(
"AttemptedGroupActivation",
"1");
1317 xmlOut.addTextElementToData(
"AttemptedGroupActivationName", groupName);
1318 xmlOut.addTextElementToData(
"AttemptedGroupActivationKey", groupKey);
1322 std::string accumulatedErrors, groupTypeString;
1330 groupName,
TableGroupKey(groupKey), &accumulatedErrors, &groupTypeString);
1332 if(accumulatedErrors !=
"")
1336 __SS__ <<
"Throwing exception on accumulated errors: "
1337 << accumulatedErrors << __E__;
1341 __COUT_WARN__ <<
"Ignoring warnings so ignoring this error:"
1342 << accumulatedErrors << __E__;
1343 __COUT_WARN__ <<
"Done ignoring the above error(s)." << __E__;
1345 xmlOut.addTextElementToData(
"AttemptedGroupActivationType", groupTypeString);
1347 catch(std::runtime_error& e)
1352 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
1353 xmlOut.addTextElementToData(
1355 "Error activating table group '" + groupName +
"(" + groupKey +
")" +
1356 ".' Please see details below:\n\n" + std::string(e.what()));
1357 __SUP_COUT_ERR__ <<
"Errors detected so de-activating group: " << groupName
1358 <<
" (" << groupKey <<
")" << __E__;
1367 catch(cet::exception& e)
1373 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
1374 xmlOut.addTextElementToData(
"Error",
1375 "Error activating table group '" + groupName +
1376 "(" + groupKey +
")" +
"!'\n\n" +
1377 std::string(e.what()));
1378 __SUP_COUT_ERR__ <<
"Errors detected so de-activating group: " << groupName
1379 <<
" (" << groupKey <<
")" << __E__;
1390 __SUP_COUT__ <<
"Unknown error detected!" << __E__;
1402 else if(requestType ==
"getActiveTableGroups")
1404 else if(requestType ==
"copyViewToCurrentColumns")
1406 std::string tableName =
1410 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
1411 __SUP_COUT__ <<
"sourceVersion: " << sourceVersion << __E__;
1412 __SUP_COUT__ <<
"userInfo.username_: " << userInfo.username_ << __E__;
1418 newTemporaryVersion =
1421 __SUP_COUT__ <<
"New temporary version = " << newTemporaryVersion << __E__;
1423 catch(std::runtime_error& e)
1425 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
1426 xmlOut.addTextElementToData(
"Error",
1427 "Error copying view from '" + tableName +
"_v" +
1428 sourceVersion +
"'! " +
1429 std::string(e.what()));
1433 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
1434 xmlOut.addTextElementToData(
1436 "Error copying view from '" + tableName +
"_v" + sourceVersion +
"'! ");
1439 handleGetTableXML(xmlOut, cfgMgr, tableName, newTemporaryVersion);
1441 else if(requestType ==
"getLastTableGroups")
1444 std::map<std::string ,
1445 std::tuple<std::string ,
1450 theRemoteWebUsers_.getLastTableGroups(theGroups);
1452 for(
const auto& theGroup : theGroups)
1454 xmlOut.addTextElementToData(
"Last" + theGroup.first +
"GroupName",
1455 std::get<0>(theGroup.second));
1456 xmlOut.addTextElementToData(
"Last" + theGroup.first +
"GroupKey",
1457 std::get<1>(theGroup.second).toString());
1458 xmlOut.addTextElementToData(
"Last" + theGroup.first +
"GroupTime",
1459 std::get<2>(theGroup.second));
1492 handleOtherSubsystemActiveGroups(xmlOut, cfgMgr,
false );
1494 else if(requestType ==
"getSubsytemTableGroups")
1496 std::string subsystem =
1498 __SUP_COUTV__(subsystem);
1499 handleOtherSubsystemActiveGroups(
1500 xmlOut, cfgMgr,
true , subsystem);
1502 else if(requestType ==
"diffWithActiveGroup")
1504 std::string groupName =
1507 __SUP_COUTV__(groupName);
1508 __SUP_COUTV__(groupKey);
1513 else if(requestType ==
"diffWithGroupKey")
1515 std::string groupName =
1519 std::string diffGroupName =
1521 __SUP_COUTV__(groupName);
1522 __SUP_COUTV__(groupKey);
1523 __SUP_COUTV__(diffKey);
1524 __SUP_COUTV__(diffGroupName);
1526 handleGroupDiff(xmlOut,
1533 else if(requestType ==
"diffTableVersions")
1535 std::string tableName =
1539 __SUP_COUTV__(tableName);
1544 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
1547 if(allTableInfo.find(tableName) != allTableInfo.end())
1549 if(vA.find(ConfigurationManager::ALIAS_VERSION_PREAMBLE) == 0)
1552 std::map<std::string ,
1556 std::string versionAlias;
1558 vA.substr(ConfigurationManager::ALIAS_VERSION_PREAMBLE.size());
1560 if(versionAliases.find(tableName) != versionAliases.end() &&
1561 versionAliases[tableName].find(versionAlias) !=
1562 versionAliases[tableName].end())
1564 versionA = versionAliases[tableName][versionAlias];
1565 __SUP_COUT__ <<
"version alias translated to: " << versionA << __E__;
1568 __SUP_COUT_WARN__ <<
"version alias '" << versionAlias
1569 <<
"'was not found in active version aliases!"
1573 versionA = atoi(vA.c_str());
1575 if(vB.find(ConfigurationManager::ALIAS_VERSION_PREAMBLE) == 0)
1578 std::map<std::string ,
1582 std::string versionAlias;
1584 vB.substr(ConfigurationManager::ALIAS_VERSION_PREAMBLE.size());
1586 if(versionAliases.find(tableName) != versionAliases.end() &&
1587 versionAliases[tableName].find(versionAlias) !=
1588 versionAliases[tableName].end())
1590 versionB = versionAliases[tableName][versionAlias];
1591 __SUP_COUT__ <<
"version alias translated to: " << versionB << __E__;
1594 __SUP_COUT_WARN__ <<
"version alias '" << versionAlias
1595 <<
"'was not found in active version aliases!"
1599 versionB = atoi(vB.c_str());
1603 versionA = atoi(vA.c_str());
1604 versionB = atoi(vB.c_str());
1607 __SUP_COUTV__(versionA);
1608 __SUP_COUTV__(versionB);
1610 handleTableDiff(xmlOut, cfgMgr, tableName, versionA, versionB);
1612 else if(requestType ==
"findGroupsWithTable")
1614 std::string tableName =
1616 std::string tableVersion =
1619 __SUP_COUTV__(tableName);
1620 __SUP_COUTV__(tableVersion);
1622 std::set<std::string> groupsContainingTable =
1623 cfgMgr->getConfigurationInterface()->findGroupsWithTable(
1625 __SUP_COUT__ <<
"Groups containing " << tableName <<
"-v" << tableVersion
1626 <<
" count: " << groupsContainingTable.size() << __E__;
1627 std::string groupsContainingTableString =
1629 __SUP_COUTTV__(groupsContainingTableString);
1631 xmlOut.addNumberElementToData(
"GroupsContainingCount",
1632 groupsContainingTable.size());
1633 xmlOut.addTextElementToData(
"GroupsContainingCSV", groupsContainingTableString);
1636 else if(requestType ==
"savePlanCommandSequence")
1639 std::string commands =
1645 __SUP_COUTV__(modifiedTables);
1646 __SUP_COUTV__(planName);
1647 __SUP_COUTV__(commands);
1648 __SUP_COUTV__(groupName);
1649 __SUP_COUTV__(groupKey);
1651 handleSavePlanCommandSequenceXML(xmlOut,
1660 else if(requestType ==
"mergeGroups")
1662 std::string groupANameContext =
1664 std::string groupAKeyContext =
1666 std::string groupBNameContext =
1668 std::string groupBKeyContext =
1670 std::string groupANameConfig =
1673 std::string groupBNameConfig =
1678 __SUP_COUTV__(groupANameContext);
1679 __SUP_COUTV__(groupAKeyContext);
1680 __SUP_COUTV__(groupBNameContext);
1681 __SUP_COUTV__(groupBKeyContext);
1682 __SUP_COUTV__(groupANameConfig);
1683 __SUP_COUTV__(groupAKeyConfig);
1684 __SUP_COUTV__(groupBNameConfig);
1685 __SUP_COUTV__(groupBKeyConfig);
1686 __SUP_COUTV__(mergeApproach);
1688 handleMergeGroupsXML(xmlOut,
1701 else if(requestType ==
"getArtdaqSystemVariables")
1703 std::string filePath =
1704 std::string(__ENV__(
"USER_DATA")) +
"/ServiceData/ArtdaqSystemVariables.dat";
1705 std::ifstream inFile(filePath);
1706 if(inFile.is_open())
1709 while(std::getline(inFile, line))
1711 size_t eqPos = line.find(
'=');
1712 if(eqPos == std::string::npos)
1714 std::string key = line.substr(0, eqPos);
1715 std::string value = line.substr(eqPos + 1);
1716 xmlOut.addTextElementToData(
"artdaq_" + key, value);
1720 else if(requestType ==
"setArtdaqSystemVariable")
1728 xmlOut.addTextElementToData(
"Error",
"Variable key must not be empty.");
1734 if(!std::isalnum(c) && c !=
'_')
1741 xmlOut.addTextElementToData(
"Error",
1742 "Variable key must contain only alphanumeric "
1743 "characters and underscores.");
1747 std::string filePath = std::string(__ENV__(
"USER_DATA")) +
1748 "/ServiceData/ArtdaqSystemVariables.dat";
1749 std::map<std::string, std::string> vars;
1751 std::ifstream inFile(filePath);
1752 if(inFile.is_open())
1755 while(std::getline(inFile, line))
1757 size_t eqPos = line.find(
'=');
1758 if(eqPos == std::string::npos)
1760 vars[line.substr(0, eqPos)] = line.substr(eqPos + 1);
1767 std::ofstream outFile(filePath);
1768 if(!outFile.is_open())
1770 xmlOut.addTextElementToData(
1771 "Error",
"Failed to open persistence file for writing.");
1775 for(
auto& [k, v] : vars)
1776 outFile << k <<
"=" << v <<
"\n";
1777 __SUP_COUT__ <<
"Set artdaq system variable " << key <<
" = " << value
1779 xmlOut.addTextElementToData(
"Success",
"Variable '" + key +
"' set.");
1784 else if(requestType ==
"getJsonDocuments")
1786 auto* ifc = ConfigurationInterface::getInstance();
1788 std::set<std::string> allTableNames = ifc->getAllTableNames();
1790 for(
const auto& tableName : allTableNames)
1792 if(tableName.find(TableBase::JSON_DOC_PREPEND) != 0)
1795 std::string docName = tableName.substr(TableBase::JSON_DOC_PREPEND.size());
1798 std::set<TableVersion> versions = ifc->getVersions(&tmpTable);
1800 std::string versionList;
1801 for(
const auto& v : versions)
1803 if(!versionList.empty())
1805 versionList += v.toString();
1808 xmlOut.addTextElementToData(
"jsonDoc_name", docName);
1809 xmlOut.addTextElementToData(
"jsonDoc_versions", versionList);
1812 else if(requestType ==
"getJsonDocumentContent")
1817 __SUP_COUTV__(docName);
1818 __SUP_COUTV__(docVersion);
1820 bool valid = !docName.empty();
1821 for(
char c : docName)
1822 if(!std::isalnum(c) && c !=
'_' && c !=
'-')
1829 xmlOut.addTextElementToData(
1831 "Document name must be non-empty and contain only "
1832 "alphanumeric characters, dashes, and underscores.");
1834 else if(docVersion.empty() ||
1835 docVersion.find_first_not_of(
"0123456789") != std::string::npos)
1837 xmlOut.addTextElementToData(
1838 "Error",
"Document version must contain only numeric characters.");
1844 auto* ifc = ConfigurationInterface::getInstance();
1845 std::string json = ifc->loadCustomJSON(docName,
TableVersion(docVersion));
1846 xmlOut.addTextElementToData(
"content", json);
1848 catch(
const std::exception& e)
1850 xmlOut.addTextElementToData(
"Error",
1851 "Failed to load document '" + docName +
"-v" +
1852 docVersion +
"': " + e.what());
1856 else if(requestType ==
"saveJsonDocumentContent")
1863 __SUP_COUTV__(docName);
1864 __SUP_COUTVS__(10, content);
1866 bool valid = !docName.empty();
1867 for(
char c : docName)
1868 if(!std::isalnum(c) && c !=
'_' && c !=
'-')
1875 xmlOut.addTextElementToData(
1877 "Document name must be non-empty and contain only "
1878 "alphanumeric characters, dashes, and underscores.");
1880 else if(content.empty())
1882 xmlOut.addTextElementToData(
"Error",
"Document content must not be empty.");
1888 auto* ifc = ConfigurationInterface::getInstance();
1889 std::pair<std::string, TableVersion> saved =
1890 ifc->saveCustomJSON(content, docName);
1891 __SUP_COUT__ <<
"Saved JSON document '" << docName <<
"' as version "
1892 << saved.second.toString() << __E__;
1893 xmlOut.addTextElementToData(
"newVersion", saved.second.toString());
1894 xmlOut.addTextElementToData(
1895 "Success",
"Saved as version " + saved.second.toString());
1897 catch(
const std::exception& e)
1899 xmlOut.addTextElementToData(
1900 "Error",
"Failed to save document '" + docName +
"': " + e.what());
1904 else if(requestType ==
"getAppUrnByClass")
1908 __SUP_COUTV__(className);
1910 if(className.empty())
1912 xmlOut.addTextElementToData(
"Error",
"className must not be empty.");
1918 std::vector<std::pair<std::string, ConfigurationTree>> appRecords =
1919 cfgMgr->
getNode(ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME)
1923 for(
const auto& appRecord : appRecords)
1925 std::string appClass =
1926 appRecord.second.getNode(
"Class").getValueAsString();
1932 appClass == className ||
1933 (appClass.size() > className.size() &&
1934 appClass.compare(appClass.size() - className.size(),
1937 appClass[appClass.size() - className.size() - 1] ==
':');
1941 std::string appId = appRecord.second.getNode(
"Id").getValueAsString();
1942 xmlOut.addTextElementToData(
"urn", appId);
1948 xmlOut.addTextElementToData(
1950 "No enabled application found for class '" + className +
"'.");
1952 catch(
const std::exception& e)
1954 xmlOut.addTextElementToData(
1956 "Failed to look up application URN for class '" + className +
1963 __SUP_SS__ <<
"requestType Request, " << requestType
1964 <<
", not recognized by the Configuration GUI Supervisor (was it "
1965 "intended for another Supervisor?)."
1967 __SUP_COUT__ <<
"\n" << ss.str();
1968 xmlOut.addTextElementToData(
"Error", ss.str());
1971 __SUP_COUTT__ <<
"cfgMgr runtime=" << cfgMgr->runTimeSeconds() << __E__;
1974 xmlOut, cfgMgr, userInfo.username_);
1975 __SUP_COUTT__ <<
"cfgMgr runtime=" << cfgMgr->runTimeSeconds() << __E__;
1978 catch(
const std::runtime_error& e)
1980 __SS__ <<
"A fatal error occurred while handling the request '" << requestType
1981 <<
".' Error: " << e.what() << __E__;
1982 __COUT_ERR__ <<
"\n" << ss.str();
1983 xmlOut.addTextElementToData(
"Error", ss.str());
1988 xmlOut.addTextElementToData(
1990 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
1994 __COUT_ERR__ <<
"Error getting version tracking status!" << __E__;
1999 __SS__ <<
"An unknown fatal error occurred while handling the request '"
2000 << requestType <<
".'" << __E__;
2005 catch(
const std::exception& e)
2007 ss <<
"Exception message: " << e.what();
2012 __COUT_ERR__ <<
"\n" << ss.str();
2013 xmlOut.addTextElementToData(
"Error", ss.str());
2018 xmlOut.addTextElementToData(
2020 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
2024 __COUT_ERR__ <<
"Error getting version tracking status!" << __E__;
2044 void ConfigurationGUISupervisor::handleGetAffectedGroupsXML(
2047 const std::string& rootGroupName,
2049 const std::string& modifiedTables)
2052 __SUP_COUT__ <<
"rootGroupName " << rootGroupName <<
"(" << rootGroupKey
2053 <<
"). modifiedTables = " << modifiedTables << __E__;
2055 std::map<std::string, std::pair<std::string, TableGroupKey>> consideredGroups =
2060 if(consideredGroups[ConfigurationManager::GROUP_TYPE_NAME_CONTEXT].second.isInvalid())
2062 __SUP_COUT__ <<
"Finding a context group to consider..." << __E__;
2063 if(cfgMgr->getFailedTableGroups().find(
2064 ConfigurationManager::GROUP_TYPE_NAME_CONTEXT) !=
2065 cfgMgr->getFailedTableGroups().end())
2067 consideredGroups[ConfigurationManager::GROUP_TYPE_NAME_CONTEXT] =
2068 cfgMgr->getFailedTableGroups().at(
2069 ConfigurationManager::GROUP_TYPE_NAME_CONTEXT);
2071 else if(cfgMgr->getFailedTableGroups().find(
2072 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN) !=
2073 cfgMgr->getFailedTableGroups().end())
2075 consideredGroups[ConfigurationManager::GROUP_TYPE_NAME_CONTEXT] =
2076 cfgMgr->getFailedTableGroups().at(
2077 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN);
2080 if(consideredGroups[ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION]
2081 .second.isInvalid())
2083 __SUP_COUT__ <<
"Finding a table group to consider..." << __E__;
2084 if(cfgMgr->getFailedTableGroups().find(
2085 ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION) !=
2086 cfgMgr->getFailedTableGroups().end())
2088 consideredGroups[ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION] =
2089 cfgMgr->getFailedTableGroups().at(
2090 ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION);
2092 else if(cfgMgr->getFailedTableGroups().find(
2093 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN) !=
2094 cfgMgr->getFailedTableGroups().end())
2096 consideredGroups[ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION] =
2097 cfgMgr->getFailedTableGroups().at(
2098 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN);
2107 std::map<std::string ,
TableVersion > rootGroupMemberMap;
2112 &rootGroupMemberMap,
2122 consideredGroups[groupType] =
2123 std::pair<std::string, TableGroupKey>(rootGroupName, rootGroupKey);
2125 catch(
const std::runtime_error& e)
2128 if(rootGroupName.size())
2130 __SUP_SS__ <<
"Failed to determine type of table group for " << rootGroupName
2131 <<
"(" << rootGroupKey <<
")! " << e.what() << __E__;
2132 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2137 __SUP_COUT__ <<
"Did not modify considered active groups due to empty root group "
2138 "name - assuming this was intentional."
2144 if(rootGroupName.size())
2146 __SUP_COUT_ERR__ <<
"Failed to determine type of table group for "
2147 << rootGroupName <<
"(" << rootGroupKey <<
")!" << __E__;
2152 __SUP_COUT__ <<
"Did not modify considered active groups due to empty root group "
2153 "name - assuming this was intentional."
2157 std::map<std::string ,
2160 std::map<std::string ,
2162 modifiedTablesMapIt;
2164 std::istringstream f(modifiedTables);
2165 std::string table, version;
2166 while(getline(f, table,
','))
2168 getline(f, version,
',');
2169 modifiedTablesMap.insert(
2172 std::pair<bool /*foundAffectedGroup*/, TableVersion /*version*/>>(
2176 __SUP_COUT__ << modifiedTables << __E__;
2177 for(
auto& pair : modifiedTablesMap)
2178 __SUP_COUT__ <<
"modified table " << pair.first <<
":" << pair.second.second
2183 xercesc::DOMElement* parentEl =
nullptr;
2184 std::string groupComment;
2185 std::vector<std::string> orderedGroupTypes(
2186 {ConfigurationManager::GROUP_TYPE_NAME_CONTEXT,
2187 ConfigurationManager::GROUP_TYPE_NAME_BACKBONE,
2188 ConfigurationManager::GROUP_TYPE_NAME_ITERATE,
2189 ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION});
2190 for(
auto groupType : orderedGroupTypes)
2192 if(consideredGroups.find(groupType) == consideredGroups.end())
2195 const std::pair<std::string, TableGroupKey>& group = consideredGroups[groupType];
2197 if(group.second.isInvalid())
2200 __SUP_COUT__ <<
"Considering " << groupType <<
" group " << group.first <<
" ("
2201 << group.second <<
")" << __E__;
2219 __SUP_COUT__ <<
"groupComment = " << groupComment << __E__;
2221 for(
auto& table : memberMap)
2223 if((modifiedTablesMapIt = modifiedTablesMap.find(table.first)) !=
2226 table.second != (*modifiedTablesMapIt).second.second)
2228 __SUP_COUT__ <<
"Affected by " << (*modifiedTablesMapIt).first <<
":"
2229 << (*modifiedTablesMapIt).second.second << __E__;
2231 memberMap[table.first] = (*modifiedTablesMapIt).second.second;
2232 (*modifiedTablesMapIt).second.first =
true;
2236 parentEl = xmlOut.addTextElementToData(
"AffectedActiveGroup",
"");
2240 if(groupType == ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION)
2242 __SUP_COUT__ <<
"Considering mockup tables for Configuration Group..."
2244 for(
auto& table : modifiedTablesMap)
2246 if(table.second.first)
2249 if(table.second.second.isMockupVersion() &&
2250 memberMap.find(table.first) == memberMap.end())
2252 __SUP_COUT__ <<
"Found mockup table '" << table.first
2253 <<
"' for Configuration Group." << __E__;
2254 memberMap[table.first] = table.second.second;
2257 parentEl = xmlOut.addTextElementToData(
"AffectedActiveGroup",
"");
2261 "AddMemberVersion", table.second.second.toString(), parentEl);
2268 __SUP_COUTV__(affected);
2272 parentEl = xmlOut.addTextElementToData(
"AffectedActiveGroup",
"");
2277 for(
auto& table : memberMap)
2281 "MemberVersion", table.second.toString(), parentEl);
2286 catch(std::runtime_error& e)
2288 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
2289 xmlOut.addTextElementToData(
2290 "Error",
"Error getting affected groups! " + std::string(e.what()));
2294 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
2295 xmlOut.addTextElementToData(
"Error",
"Error getting affected groups! ");
2306 void ConfigurationGUISupervisor::setupActiveTablesXML(
2309 const std::string& groupName,
2311 const std::string& modifiedTables,
2313 bool doGetGroupInfo,
2314 std::map<std::string /*name*/, TableVersion /*version*/>* returnMemberMap,
2315 bool outputActiveTables,
2316 std::string* accumulatedErrors)
2319 xmlOut.addTextElementToData(
"tableGroup", groupName);
2320 xmlOut.addTextElementToData(
"tableGroupKey", groupKey.
toString());
2322 bool usingActiveGroups = (groupName ==
"" || groupKey.
isInvalid());
2330 __SUP_COUT__ <<
"Refreshing all table info, ignoring warnings..." << __E__;
2331 std::string accumulatedWarnings =
"";
2333 &accumulatedWarnings,
2347 __SUP_COUT__ <<
"Restoring active table group tables..." << __E__;
2349 for(
const auto& activeGroup : activeGroups)
2351 if(activeGroup.second.first == groupName &&
2352 activeGroup.second.second == groupKey)
2354 __SUP_COUTT__ <<
"Skipping target active group." << __E__;
2357 __SUP_COUTT__ <<
"Loading " << activeGroup.first <<
" "
2358 << activeGroup.second.first <<
"(" << activeGroup.second.second
2363 activeGroup.second.second,
2369 __SUP_COUT__ <<
"Ignoring errors while setting up active tables for "
2370 << activeGroup.second.first <<
"("
2371 << activeGroup.second.second <<
")..." << __E__;
2377 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
2379 std::map<std::string ,
TableVersion > modifiedTablesMap;
2381 modifiedTablesMapIt;
2383 if(usingActiveGroups)
2386 __SUP_COUT__ <<
"Using active groups." << __E__;
2390 __SUP_COUT__ <<
"Loading group '" << groupName <<
"(" << groupKey <<
")'"
2393 std::string groupComment, groupAuthor, tableGroupCreationTime, groupType;
2402 doGetGroupInfo ? &groupComment : 0,
2403 doGetGroupInfo ? &groupAuthor : 0,
2404 doGetGroupInfo ? &tableGroupCreationTime : 0,
2406 doGetGroupInfo ? &groupType : 0);
2410 xmlOut.addTextElementToData(
"tableGroupComment", groupComment);
2411 xmlOut.addTextElementToData(
"tableGroupAuthor", groupAuthor);
2412 xmlOut.addTextElementToData(
"tableGroupCreationTime", tableGroupCreationTime);
2413 xmlOut.addTextElementToData(
"tableGroupType", groupType);
2416 if(accumulatedErrors && *accumulatedErrors !=
"")
2417 __SUP_COUTV__(*accumulatedErrors);
2423 std::istringstream f(modifiedTables);
2424 std::string table, version;
2425 while(getline(f, table,
','))
2427 getline(f, version,
',');
2428 modifiedTablesMap.insert(
2429 std::pair<std::string /*name*/, TableVersion /*version*/>(
2433 for(
auto& pair : modifiedTablesMap)
2434 __SUP_COUT__ <<
"modified table " << pair.first <<
":" << pair.second
2439 std::map<std::string, TableVersion> allActivePairs = cfgMgr->
getActiveVersions();
2440 xmlOut.addTextElementToData(
"DefaultNoLink",
2441 TableViewColumnInfo::DATATYPE_LINK_DEFAULT);
2444 std::set<std::string, StringMacros::IgnoreCaseCompareStruct> orderedTableSet;
2445 for(
const auto& tablePair : allActivePairs)
2446 orderedTableSet.emplace(tablePair.first);
2448 std::map<std::string, TableInfo>::const_iterator tableInfoIt;
2449 for(
auto& orderedTableName : orderedTableSet)
2451 tableInfoIt = allTableInfo.find(orderedTableName);
2452 if(tableInfoIt == allTableInfo.end())
2454 __SS__ <<
"Impossible missing table in map '" << orderedTableName <<
"'"
2459 if(outputActiveTables)
2460 xmlOut.addTextElementToData(
"ActiveTableName", orderedTableName);
2464 if((modifiedTablesMapIt = modifiedTablesMap.find(orderedTableName)) !=
2465 modifiedTablesMap.end())
2467 __SUP_COUT__ <<
"Found modified table " << (*modifiedTablesMapIt).first
2468 <<
": trying... " << (*modifiedTablesMapIt).second << __E__;
2472 tableInfoIt->second.tablePtr_->setActiveView(
2473 (*modifiedTablesMapIt).second);
2477 __SUP_SS__ <<
"Modified table version v" << (*modifiedTablesMapIt).second
2478 <<
" failed. Reverting to v"
2479 << tableInfoIt->second.tablePtr_->getView().getVersion() <<
"."
2481 __SUP_COUT_WARN__ <<
"Warning detected!\n\n " << ss.str() << __E__;
2482 xmlOut.addTextElementToData(
2484 "Error setting up active tables!\n\n" + std::string(ss.str()));
2488 if(outputActiveTables)
2490 xmlOut.addTextElementToData(
2491 "ActiveTableVersion",
2492 tableInfoIt->second.tablePtr_->getView().getVersion().toString());
2493 xmlOut.addTextElementToData(
2494 "ActiveTableComment",
2495 tableInfoIt->second.tablePtr_->getView().getAuthor() +
": " +
2496 tableInfoIt->second.tablePtr_->getView().getComment());
2504 catch(std::runtime_error& e)
2506 __SUP_SS__ << (
"Error setting up active tables!\n\n" + std::string(e.what()))
2508 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2509 xmlOut.addTextElementToData(
"Error", ss.str());
2514 __SUP_SS__ << (
"Error setting up active tables!\n\n") << __E__;
2519 catch(
const std::exception& e)
2521 ss <<
"Exception message: " << e.what();
2526 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2527 xmlOut.addTextElementToData(
"Error", ss.str());
2546 void ConfigurationGUISupervisor::handleFillCreateTreeNodeRecordsXML(
2549 const std::string& groupName,
2551 const std::string& startPath,
2552 const std::string& modifiedTables,
2553 const std::string& recordList,
2554 const std::string& author)
2557 setupActiveTablesXML(xmlOut,
2572 __SUP_COUT__ << table->getTableName() << __E__;
2582 bool firstSave =
true;
2589 std::istringstream f(recordList);
2590 std::string recordUID;
2592 while(getline(f, recordUID,
','))
2596 __SUP_COUT__ <<
"recordUID " << recordUID << __E__;
2601 .isTemporaryVersion())
2603 __SUP_COUT__ <<
"Start version " << temporaryVersion << __E__;
2605 temporaryVersion = table->createTemporaryView(temporaryVersion);
2611 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion
2615 __SUP_COUT__ <<
"Using temporary version " << temporaryVersion
2621 backupView.copy(table->getView(), temporaryVersion, author);
2630 unsigned int row = table->getViewP()->addRow(
2637 unsigned int col = table->getViewP()->getColStatus();
2638 table->getViewP()->setURIEncodedValue(
"1", row, col);
2645 table->getViewP()->setURIEncodedValue(
2646 recordUID, row, table->getViewP()->getColUID());
2654 table->getViewP()->init();
2658 __SUP_COUT_INFO__ <<
"Reverting to original view." << __E__;
2659 __SUP_COUT__ <<
"Before:" << __E__;
2660 table->getViewP()->print();
2661 table->getViewP()->copy(backupView, temporaryVersion, author);
2662 __SUP_COUT__ <<
"After:" << __E__;
2663 table->getViewP()->print();
2669 handleFillModifiedTablesXML(xmlOut, cfgMgr);
2671 catch(std::runtime_error& e)
2673 __SUP_SS__ << (
"Error creating new record(s)!\n\n" + std::string(e.what()))
2675 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2676 xmlOut.addTextElementToData(
"Error", ss.str());
2680 __SUP_SS__ << (
"Error creating new record(s)!\n\n") << __E__;
2685 catch(
const std::exception& e)
2687 ss <<
"Exception message: " << e.what();
2692 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2693 xmlOut.addTextElementToData(
"Error", ss.str());
2700 void ConfigurationGUISupervisor::handleFillModifiedTablesXML(
2705 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
2706 std::map<std::string, TableVersion> allActivePairs = cfgMgr->
getActiveVersions();
2707 for(
auto& activePair : allActivePairs)
2709 xmlOut.addTextElementToData(
"NewActiveTableName", activePair.first);
2710 xmlOut.addTextElementToData(
"NewActiveTableVersion",
2711 allTableInfo.at(activePair.first)
2712 .tablePtr_->getView()
2715 xmlOut.addTextElementToData(
2716 "NewActiveTableComment",
2717 allTableInfo.at(activePair.first).tablePtr_->getView().getAuthor() +
": " +
2718 allTableInfo.at(activePair.first).tablePtr_->getView().getComment());
2721 catch(std::runtime_error& e)
2723 __SUP_SS__ << (
"Error!\n\n" + std::string(e.what())) << __E__;
2724 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2725 xmlOut.addTextElementToData(
"Error", ss.str());
2729 __SUP_SS__ << (
"Error!\n\n") << __E__;
2734 catch(
const std::exception& e)
2736 ss <<
"Exception message: " << e.what();
2741 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2742 xmlOut.addTextElementToData(
"Error", ss.str());
2760 void ConfigurationGUISupervisor::handleFillDeleteTreeNodeRecordsXML(
2763 const std::string& groupName,
2765 const std::string& startPath,
2766 const std::string& modifiedTables,
2767 const std::string& recordList)
2770 setupActiveTablesXML(xmlOut,
2785 __SUP_COUT__ << table->getTableName() << __E__;
2795 bool firstSave =
true;
2799 std::istringstream f(recordList);
2800 std::string recordUID;
2803 while(getline(f, recordUID,
','))
2807 __SUP_COUT__ <<
"recordUID " << recordUID << __E__;
2812 .isTemporaryVersion())
2814 __SUP_COUT__ <<
"Start version " << temporaryVersion << __E__;
2816 temporaryVersion = table->createTemporaryView(temporaryVersion);
2822 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion
2826 __SUP_COUT__ <<
"Using temporary version " << temporaryVersion
2837 table->getViewP()->findRow(table->getViewP()->getColUID(), recordUID);
2838 table->getViewP()->deleteRow(row);
2843 table->getViewP()->init();
2845 handleFillModifiedTablesXML(xmlOut, cfgMgr);
2847 catch(std::runtime_error& e)
2849 __SUP_SS__ << (
"Error removing record(s)!\n\n" + std::string(e.what())) << __E__;
2850 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2851 xmlOut.addTextElementToData(
"Error", ss.str());
2855 __SUP_SS__ << (
"Error removing record(s)!\n\n") << __E__;
2860 catch(
const std::exception& e)
2862 ss <<
"Exception message: " << e.what();
2867 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2868 xmlOut.addTextElementToData(
"Error", ss.str());
2888 void ConfigurationGUISupervisor::handleFillRenameTreeNodeRecordsXML(
2891 const std::string& groupName,
2893 const std::string& startPath,
2894 const std::string& modifiedTables,
2895 const std::string& recordList,
2896 const std::string& newRecordList)
2899 setupActiveTablesXML(xmlOut,
2914 __SUP_COUT__ << table->getTableName() << __E__;
2925 std::vector<std::string> recordArray =
2927 std::vector<std::string> newRecordArray =
2933 if(recordArray.size() == 0 || recordArray.size() != newRecordArray.size())
2936 <<
"Invalid record size vs new record name size, they must be the same: "
2937 << recordArray.size() <<
" vs " << newRecordArray.size() << __E__;
2943 if(!(temporaryVersion = targetNode.
getTableVersion()).isTemporaryVersion())
2945 __SUP_COUT__ <<
"Start version " << temporaryVersion << __E__;
2947 temporaryVersion = table->createTemporaryView(temporaryVersion);
2953 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion << __E__;
2956 __SUP_COUT__ <<
"Using temporary version " << temporaryVersion << __E__;
2963 for(
unsigned int i = 0; i < recordArray.size(); ++i)
2965 row = table->getViewP()->findRow(
2966 table->getViewP()->getColUID(),
2969 table->getViewP()->setValueAsString(
2970 newRecordArray[i], row, table->getViewP()->getColUID());
2973 table->getViewP()->init();
2975 handleFillModifiedTablesXML(xmlOut, cfgMgr);
2977 catch(std::runtime_error& e)
2979 __SUP_SS__ << (
"Error renaming record(s)!\n\n" + std::string(e.what())) << __E__;
2980 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2981 xmlOut.addTextElementToData(
"Error", ss.str());
2985 __SUP_SS__ << (
"Error renaming record(s)!\n\n") << __E__;
2990 catch(
const std::exception& e)
2992 ss <<
"Exception message: " << e.what();
2997 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2998 xmlOut.addTextElementToData(
"Error", ss.str());
3019 void ConfigurationGUISupervisor::handleFillCopyTreeNodeRecordsXML(
3022 const std::string& groupName,
3024 const std::string& startPath,
3025 const std::string& modifiedTables,
3026 const std::string& recordList,
3027 unsigned int numberOfCopies )
3033 setupActiveTablesXML(xmlOut,
3048 __SUP_COUT__ << table->getTableName() << __E__;
3059 std::vector<std::string> recordArray =
3065 if(!(temporaryVersion = targetNode.
getTableVersion()).isTemporaryVersion())
3067 __SUP_COUT__ <<
"Start version " << temporaryVersion << __E__;
3069 temporaryVersion = table->createTemporaryView(temporaryVersion);
3075 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion << __E__;
3078 __SUP_COUT__ <<
"Using temporary version " << temporaryVersion << __E__;
3085 for(
const auto& recordUID : recordArray)
3087 row = table->getViewP()->findRow(table->getViewP()->getColUID(),
3089 for(
unsigned int i = 0; i < numberOfCopies; ++i)
3090 table->getViewP()->copyRows(
3100 table->getViewP()->init();
3102 handleFillModifiedTablesXML(xmlOut, cfgMgr);
3104 catch(std::runtime_error& e)
3106 __SUP_SS__ << (
"Error copying record(s)!\n\n" + std::string(e.what())) << __E__;
3107 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3108 xmlOut.addTextElementToData(
"Error", ss.str());
3112 __SUP_SS__ << (
"Error copying record(s)!\n\n") << __E__;
3117 catch(
const std::exception& e)
3119 ss <<
"Exception message: " << e.what();
3124 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3125 xmlOut.addTextElementToData(
"Error", ss.str());
3146 void ConfigurationGUISupervisor::handleFillSetTreeNodeFieldValuesXML(
3149 const std::string& groupName,
3151 const std::string& startPath,
3152 const std::string& modifiedTables,
3153 const std::string& recordList,
3154 const std::string& fieldList,
3155 const std::string& valueList,
3156 const std::string& author)
3159 setupActiveTablesXML(xmlOut,
3174 std::vector<std::string > fieldPaths;
3177 std::istringstream f(fieldList);
3178 std::string fieldPath;
3179 while(getline(f, fieldPath,
','))
3183 __SUP_COUT__ << fieldList << __E__;
3184 for(
const auto& field : fieldPaths)
3185 __SUP_COUT__ <<
"fieldPath " << field << __E__;
3188 std::vector<std::string > fieldValues;
3191 std::istringstream f(valueList);
3192 std::string fieldValue;
3193 while(getline(f, fieldValue,
','))
3195 fieldValues.push_back(fieldValue);
3200 if(valueList.size() && valueList[valueList.size() - 1] ==
',')
3201 fieldValues.push_back(
"");
3203 __SUP_COUT__ << valueList << __E__;
3204 for(
const auto& value : fieldValues)
3205 __SUP_COUT__ <<
"fieldValue " << value << __E__;
3208 if(fieldPaths.size() != fieldValues.size())
3211 __THROW__(ss.str() +
"Mismatch in fields and values array size!");
3218 std::istringstream f(recordList);
3219 std::string recordUID;
3222 while(getline(f, recordUID,
','))
3227 xmlOut.addTextElementToData(
"fieldValues", recordUID);
3230 for(i = 0; i < fieldPaths.size(); ++i)
3232 __SUP_COUT__ <<
"fieldPath " << fieldPaths[i] << __E__;
3233 __SUP_COUT__ <<
"fieldValue " << fieldValues[i] << __E__;
3238 cfgMgr->
getNode(startPath +
"/" + recordUID +
"/" + fieldPaths[i],
3279 if(!(temporaryVersion = table->getViewP()->getVersion())
3280 .isTemporaryVersion())
3284 table->createTemporaryView(table->getViewP()->getVersion());
3290 __SUP_COUT__ <<
"Created temporary version "
3291 << table->getTableName() <<
"-v" << temporaryVersion
3295 __SUP_COUT__ <<
"Using temporary version " << table->getTableName()
3296 <<
"-v" << temporaryVersion << __E__;
3300 table->getViewP()->setURIEncodedValue(fieldValues[i],
3311 handleFillModifiedTablesXML(xmlOut, cfgMgr);
3313 catch(std::runtime_error& e)
3315 __SUP_SS__ << (
"Error setting field values!\n\n" + std::string(e.what()))
3317 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3318 xmlOut.addTextElementToData(
"Error", ss.str());
3322 __SUP_SS__ << (
"Error setting field values!\n\n") << __E__;
3327 catch(
const std::exception& e)
3329 ss <<
"Exception message: " << e.what();
3334 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3335 xmlOut.addTextElementToData(
"Error", ss.str());
3354 void ConfigurationGUISupervisor::handleFillGetTreeNodeFieldValuesXML(
3357 const std::string& groupName,
3359 const std::string& startPath,
3360 const std::string& modifiedTables,
3361 const std::string& recordList,
3362 const std::string& fieldList)
3365 setupActiveTablesXML(
3366 xmlOut, cfgMgr, groupName, groupKey, modifiedTables,
false );
3373 std::vector<std::string > fieldPaths;
3376 std::istringstream f(fieldList);
3377 std::string fieldPath;
3378 while(getline(f, fieldPath,
','))
3382 __SUP_COUT__ << fieldList << __E__;
3387 std::istringstream f(recordList);
3388 std::string recordUID;
3389 while(getline(f, recordUID,
','))
3393 __SUP_COUT__ <<
"recordUID " << recordUID << __E__;
3395 xercesc::DOMElement* parentEl =
3396 xmlOut.addTextElementToData(
"fieldValues", recordUID);
3399 for(
const auto& fieldPath : fieldPaths)
3405 cfgMgr->
getNode(startPath +
"/" + recordUID +
"/" + fieldPath);
3417 catch(std::runtime_error& e)
3419 __SUP_SS__ << (
"Error getting field values!\n\n" + std::string(e.what()))
3421 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3422 xmlOut.addTextElementToData(
"Error", ss.str());
3426 __SUP_SS__ << (
"Error getting field values!\n\n") << __E__;
3431 catch(
const std::exception& e)
3433 ss <<
"Exception message: " << e.what();
3438 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3439 xmlOut.addTextElementToData(
"Error", ss.str());
3462 void ConfigurationGUISupervisor::handleFillTreeNodeCommonFieldsXML(
3465 const std::string& groupName,
3467 const std::string& startPath,
3469 const std::string& modifiedTables,
3470 const std::string& recordList,
3471 const std::string& fieldList)
3474 setupActiveTablesXML(
3475 xmlOut, cfgMgr, groupName, groupKey, modifiedTables,
false );
3479 xercesc::DOMElement* parentEl = xmlOut.addTextElementToData(
"fields", startPath);
3483 __SUP_SS__ <<
"Depth of search must be greater than 0." << __E__;
3484 __SUP_COUT__ << ss.str();
3493 std::vector<ConfigurationTree::RecordField> retFieldList;
3499 __SUP_SS__ <<
"Start path was a disconnected link node!" << __E__;
3505 std::vector<std::string > fieldAcceptList, fieldRejectList;
3510 std::istringstream f(fieldList);
3511 std::string fieldPath, decodedFieldPath;
3512 while(getline(f, fieldPath,
','))
3516 if(decodedFieldPath[0] ==
'!')
3517 fieldRejectList.push_back(decodedFieldPath.substr(1));
3519 fieldAcceptList.push_back(decodedFieldPath);
3521 __SUP_COUT__ << fieldList << __E__;
3522 for(
auto& field : fieldAcceptList)
3523 __SUP_COUT__ <<
"fieldAcceptList " << field << __E__;
3524 for(
auto& field : fieldRejectList)
3525 __SUP_COUT__ <<
"fieldRejectList " << field << __E__;
3529 std::vector<std::string > records;
3530 if(recordList ==
"*")
3534 __SUP_COUT__ <<
"Translating wildcard..." << __E__;
3535 for(
auto& record : records)
3536 __SUP_COUT__ <<
"recordList " << record << __E__;
3538 else if(recordList !=
"")
3542 std::istringstream f(recordList);
3543 std::string recordStr;
3544 while(getline(f, recordStr,
','))
3548 __SUP_COUT__ << recordList << __E__;
3549 for(
auto& record : records)
3550 __SUP_COUT__ <<
"recordList " << record << __E__;
3556 records, fieldAcceptList, fieldRejectList, depth);
3560 xercesc::DOMElement* parentTypeEl;
3561 for(
const auto& fieldInfo : retFieldList)
3564 "FieldTableName", fieldInfo.tableName_, parentEl);
3566 "FieldColumnName", fieldInfo.columnName_, parentEl);
3568 "FieldRelativePath", fieldInfo.relativePath_, parentEl);
3570 "FieldColumnType", fieldInfo.columnInfo_->getType(), parentEl);
3572 "FieldColumnDataType", fieldInfo.columnInfo_->getDataType(), parentEl);
3574 fieldInfo.columnInfo_->getDefaultValue(),
3581 auto dataChoices = fieldInfo.columnInfo_->getDataChoices();
3583 "FieldColumnDataChoice",
3584 fieldInfo.columnInfo_->getDefaultValue(),
3586 for(
const auto& dataChoice : dataChoices)
3588 "FieldColumnDataChoice", dataChoice, parentTypeEl);
3591 catch(std::runtime_error& e)
3593 __SUP_SS__ << (
"Error getting common fields!\n\n" + std::string(e.what()))
3595 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3596 xmlOut.addTextElementToData(
"Error", ss.str());
3600 __SUP_SS__ << (
"Error getting common fields!\n\n") << __E__;
3605 catch(
const std::exception& e)
3607 ss <<
"Exception message: " << e.what();
3612 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3613 xmlOut.addTextElementToData(
"Error", ss.str());
3645 void ConfigurationGUISupervisor::handleFillUniqueFieldValuesForRecordsXML(
3648 const std::string& groupName,
3650 const std::string& startPath,
3651 const std::string& modifiedTables,
3652 const std::string& recordList,
3653 const std::string& fieldList)
3656 setupActiveTablesXML(
3657 xmlOut, cfgMgr, groupName, groupKey, modifiedTables,
false );
3663 if(startPath ==
"/")
3669 __SUP_SS__ <<
"Start path was a disconnected link node!" << __E__;
3670 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3675 std::vector<std::string > records;
3676 if(recordList ==
"*")
3680 __SUP_COUT__ <<
"Translating wildcard..." << __E__;
3681 for(
auto& record : records)
3682 __SUP_COUT__ <<
"recordList " << record << __E__;
3684 else if(recordList !=
"")
3688 std::istringstream f(recordList);
3689 std::string recordStr;
3690 while(getline(f, recordStr,
','))
3694 __SUP_COUT__ << recordList << __E__;
3695 for(
auto& record : records)
3696 __SUP_COUT__ <<
"recordList " << record << __E__;
3701 std::vector<std::string > fieldsToGet;
3706 if(fieldList ==
"AUTO")
3711 __SUP_COUT__ <<
"Getting AUTO filter fields!" << __E__;
3713 std::vector<ConfigurationTree::RecordField> retFieldList;
3714 std::vector<std::string > fieldAcceptList,
3716 fieldRejectList.push_back(
"*" + TableViewColumnInfo::COL_NAME_COMMENT);
3718 records, fieldAcceptList, fieldRejectList, 5,
true );
3720 for(
const auto& retField : retFieldList)
3721 fieldsToGet.push_back(retField.relativePath_ + retField.columnName_);
3725 std::istringstream f(fieldList);
3726 std::string fieldPath;
3727 while(getline(f, fieldPath,
','))
3731 __SUP_COUTV__(fieldList);
3740 std::string fieldGroupIDChildLinkIndex;
3741 for(
auto& field : fieldsToGet)
3743 __SUP_COUTV__(field);
3745 xercesc::DOMElement* parentEl =
3746 xmlOut.addTextElementToData(
"field", field);
3752 std::set<std::string > uniqueValues =
3754 records, field, &fieldGroupIDChildLinkIndex);
3756 if(fieldGroupIDChildLinkIndex !=
"")
3758 "childLinkIndex", fieldGroupIDChildLinkIndex, parentEl);
3760 for(
auto& uniqueValue : uniqueValues)
3762 __SUP_COUT__ <<
"uniqueValue " << uniqueValue << __E__;
3769 catch(std::runtime_error& e)
3771 __SUP_SS__ <<
"Error getting unique field values from path '" << startPath
3772 <<
"' and field list '" << fieldList <<
"!'\n\n"
3773 << e.what() << __E__;
3774 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3775 xmlOut.addTextElementToData(
"Error", ss.str());
3779 __SUP_SS__ <<
"Error getting unique field values from path '" << startPath
3780 <<
"' and field list '" << fieldList <<
"!'\n\n"
3786 catch(
const std::exception& e)
3788 ss <<
"Exception message: " << e.what();
3793 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3794 xmlOut.addTextElementToData(
"Error", ss.str());
3818 void ConfigurationGUISupervisor::handleFillTreeViewXML(
3821 const std::string& groupName,
3823 const std::string& startPath,
3825 bool hideStatusFalse,
3826 const std::string& modifiedTables,
3827 const std::string& filterList,
3828 const std::string& diffGroupName ,
3831 __SUP_COUTT__ <<
"get Tree View: " << groupName <<
"(" << groupKey <<
")" << __E__;
3863 bool doDiff = (diffGroupName !=
"" && !diffGroupKey.
isInvalid());
3868 std::string diffAccumulateErrors;
3876 __SUP_COUT__ <<
"cfgMgr " << activeTable.first <<
"-v" << activeTable.second
3893 __SUP_COUT__ <<
"cfgMgr " << activeTable.first <<
"-v" << activeTable.second
3896 __SUP_COUTT__ <<
"Diff Group tables loaded." << __E__;
3898 *cfgMgr, diffMemberMap, diffGroupName, diffGroupKey);
3899 __SUP_COUTT__ <<
"Diff Group tables copied to local diff config manager."
3903 for(
auto& memberPair : diffMemberMap)
3905 ->setActiveView(memberPair.second);
3907 for(
const auto& lastGroupLoaded : cfgMgr->getLastTableGroups())
3908 __SUP_COUT__ <<
"cfgMgr Last loaded " << lastGroupLoaded.first <<
": "
3909 << lastGroupLoaded.second.first.first <<
"("
3910 << lastGroupLoaded.second.first.second <<
")";
3912 for(
const auto& lastGroupLoaded : diffCfgMgr->getLastTableGroups())
3913 __SUP_COUT__ <<
"diffCfgMgr Last loaded " << lastGroupLoaded.first <<
": "
3914 << lastGroupLoaded.second.first.first <<
"("
3915 << lastGroupLoaded.second.first.second <<
")";
3918 if(diffCfgMgr->getLastTableGroups().size() == 1)
3920 __SUP_COUT__ <<
"Type already loaded to diff = "
3921 << diffCfgMgr->getLastTableGroups().begin()->first << __E__;
3924 auto groupTypeToLoad = ConfigurationManager::GROUP_TYPE_NAME_CONTEXT;
3925 if(diffCfgMgr->getLastTableGroups().begin()->first ==
3926 ConfigurationManager::GROUP_TYPE_NAME_CONTEXT)
3927 groupTypeToLoad = ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION;
3928 else if(diffCfgMgr->getLastTableGroups().begin()->first ==
3929 ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION)
3930 groupTypeToLoad = ConfigurationManager::GROUP_TYPE_NAME_CONTEXT;
3933 <<
"Loading " << groupTypeToLoad
3934 << cfgMgr->getLastTableGroups().at(groupTypeToLoad).first.first <<
"("
3935 << cfgMgr->getLastTableGroups().at(groupTypeToLoad).first.second
3940 cfgMgr->getLastTableGroups().at(groupTypeToLoad).second,
3941 cfgMgr->getLastTableGroups().at(groupTypeToLoad).first.first,
3942 cfgMgr->getLastTableGroups().at(groupTypeToLoad).first.second);
3945 for(
auto& memberPair :
3946 cfgMgr->getLastTableGroups().at(groupTypeToLoad).second)
3948 ->setActiveView(memberPair.second);
3956 __SUP_COUTT__ <<
"cfgMgr " << activeTable.first <<
"-v" << activeTable.second
3959 __SUP_COUTT__ <<
"diffCfgMgr " << activeTable.first <<
"-v"
3960 << activeTable.second << __E__;
3962 __SUP_COUTT__ <<
"Diff Group tables are setup: " << diffAccumulateErrors << __E__;
3967 bool usingActiveGroups = (groupName ==
"" || groupKey.
isInvalid());
3970 std::string accumulatedErrors =
"";
3971 setupActiveTablesXML(
3984 if(memberMap.size() > ConfigurationManager::getFixedContextMemberNames().size() +
3986 && startPath ==
"/")
3988 __COUTT__ <<
"Checking for orphaned tables..." << __E__;
3991 std::set<std::string > linkingTables;
3996 __COUTS__(30) <<
"Table " << tableInfo.first << __E__;
3997 if(!tableInfo.second.tablePtr_->isActive())
4000 __COUTS__(30) <<
"Table active " << tableInfo.first << __E__;
4002 const TableView& view = tableInfo.second.tablePtr_->getView();
4004 bool addedThisTable =
false;
4005 for(
unsigned int col = 0; col < view.getNumberOfColumns(); ++col)
4007 if(!view.getColumnInfo(col).isChildLink())
4010 __COUTS__(30) <<
"Table " << tableInfo.first
4011 <<
" col: " << view.getColumnInfo(col).getName() << __E__;
4013 for(
unsigned int r = 0; r < view.getNumberOfRows(); ++r)
4015 if(view.getDataView()[r][col] ==
"" ||
4016 view.getDataView()[r][col] ==
4017 TableViewColumnInfo::DATATYPE_STRING_DEFAULT ||
4018 view.getDataView()[r][col] ==
4019 TableViewColumnInfo::DATATYPE_STRING_ALT_DEFAULT)
4024 linkingTables.emplace(tableInfo.first);
4025 addedThisTable =
true;
4027 linkingTables.emplace(
4028 view.getDataView()[r][col]);
4034 std::string missingTables =
"";
4035 for(
const auto& member : memberMap)
4038 if(linkingTables.find(member.first) != linkingTables.end())
4041 if(missingTables.size())
4042 missingTables +=
", ";
4043 missingTables += member.first;
4046 if(missingTables.size())
4048 __COUTV__(missingTables);
4049 std::stringstream ss;
4050 ss <<
"The following member tables of table group '" << groupName <<
"("
4052 <<
")' were identified as possibly orphaned (i.e. no active tables link "
4053 "to these tables, and these tables have no links to other tables):\n\n"
4054 << missingTables <<
".\n"
4056 xmlOut.addTextElementToData(
"NoTreeLinkWarning", ss.str());
4060 if(accumulatedErrors !=
"")
4062 xmlOut.addTextElementToData(
"Warning", accumulatedErrors);
4064 __SUP_COUT__ <<
"Active tables are setup. Warning string: '" << accumulatedErrors
4067 __SUP_COUT__ <<
"Active table versions: "
4072 __SUP_COUTT__ <<
"Active tables are setup. No issues found." << __E__;
4073 __SUP_COUTT__ <<
"Active table versions: "
4079 xercesc::DOMElement* parentEl = xmlOut.addTextElementToData(
"tree", startPath);
4084 std::vector<std::pair<std::string, ConfigurationTree>> rootMap;
4085 std::map<std::string, ConfigurationTree> diffRootMap;
4087 if(startPath ==
"/")
4091 std::string accumulateTreeErrs;
4093 if(usingActiveGroups)
4094 rootMap = cfgMgr->
getChildren(0, &accumulateTreeErrs);
4096 rootMap = cfgMgr->
getChildren(&memberMap, &accumulateTreeErrs);
4101 diffCfgMgr->
getChildrenMap(&diffMemberMap, &diffAccumulateErrors);
4102 __SUP_COUTV__(diffRootMap.size());
4103 for(
auto& diffChild : diffRootMap)
4104 __SUP_COUTV__(diffChild.first);
4107 __SUP_COUTV__(accumulateTreeErrs);
4109 if(accumulateTreeErrs !=
"")
4110 xmlOut.addTextElementToData(
"TreeErrors", accumulateTreeErrs);
4115 cfgMgr->
getNode(startPath,
true );
4118 xmlOut.addTextElementToData(
"DisconnectedStartNode",
"1");
4123 std::map<std::string , std::string > filterMap;
4127 std::set<char>({
';'}) ,
4128 std::set<char>({
'='}) );
4142 __SUP_COUTT__ <<
"Diff Group disconnected node." << __E__;
4147 catch(
const std::runtime_error& e)
4150 __SUP_COUTT__ <<
"Diff Group node does not exist." << __E__;
4157 for(
auto& treePair : rootMap)
4159 treePair.second, depth - 1, xmlOut, parentEl, hideStatusFalse);
4163 __SUP_COUTT__ <<
"Diff Tree recursive handling." << __E__;
4166 std::set<std::string > rootMapToSearch;
4167 for(
const auto& rootMember : rootMap)
4168 rootMapToSearch.emplace(rootMember.first);
4170 std::stringstream rootSs;
4171 for(
const auto& rootMember : rootMap)
4172 rootSs <<
", " << rootMember.first;
4175 std::stringstream diffRootSs;
4176 for(
const auto& diffMember : diffRootMap)
4178 diffRootSs <<
", " << diffMember.first <<
":"
4179 << diffMember.second.getNodeType();
4180 if(rootMapToSearch.find(diffMember.first) ==
4184 std::stringstream missingSs;
4185 missingSs << diffMember.first <<
4187 " <<< Only in " << diffGroupName <<
"(" << diffGroupKey
4190 "diffNodeMissing", missingSs.str(), parentEl);
4193 if(diffMember.second.getNodeType() ==
"UIDLinkNode")
4204 __SUP_COUTT__ <<
"diff map " << diffRootSs.str() << __E__;
4205 __SUP_COUTT__ <<
"root map " << rootSs.str() << __E__;
4207 __SUP_COUTT__ <<
"\t\t" << diffMember.second.getValueName() <<
": "
4208 << diffMember.second.getValueAsString() << __E__;
4210 __SUP_COUTT__ << diffMember.second.nodeDump();
4214 __SUP_COUTT__ <<
"diff map " << diffRootSs.str() << __E__;
4215 __SUP_COUTT__ <<
"root map " << rootSs.str() << __E__;
4218 for(
auto& treePair : rootMap)
4220 if(diffRootMap.find(treePair.first) == diffRootMap.end())
4222 __SUP_COUTT__ <<
"Diff Tree recursive handling... " << treePair.first
4235 __SUP_COUTT__ <<
"Diff Tree recursive handling... " << treePair.first
4237 recursiveTreeToXML(treePair.second,
4242 diffRootMap.at(treePair.first));
4247 catch(std::runtime_error& e)
4249 __SUP_SS__ <<
"Error detected generating XML tree!\n\n " << e.what() << __E__;
4250 __SUP_COUT_ERR__ <<
"\n" << ss.str();
4251 xmlOut.addTextElementToData(
"Error", ss.str());
4255 __SUP_SS__ <<
"Error detected generating XML tree!" << __E__;
4260 catch(
const std::exception& e)
4262 ss <<
"Exception message: " << e.what();
4267 __SUP_COUT_ERR__ <<
"\n" << ss.str();
4268 xmlOut.addTextElementToData(
"Error", ss.str());
4278 void ConfigurationGUISupervisor::recursiveTreeToXML(
4282 xercesc::DOMElement* parentEl,
4283 bool hideStatusFalse,
4284 std::optional<std::reference_wrapper<const ConfigurationTree>> diffTree)
4294 if(diffTree.has_value() &&
4295 t.
getValueName() != TableViewColumnInfo::COL_NAME_COMMENT &&
4296 t.
getValueName() != TableViewColumnInfo::COL_NAME_AUTHOR &&
4297 t.
getValueName() != TableViewColumnInfo::COL_NAME_CREATION)
4299 __COUTS__(30) <<
"\t\t diff type " << diffTree->get().getNodeType() << __E__;
4301 if(diffTree->get().isValueNode())
4303 __COUTS__(30) <<
"\t" << diffTree->get().getValueAsString() <<
" ? "
4305 __COUTS__(30) <<
"\t" << diffTree->get().getTableName() <<
"-v"
4306 << diffTree->get().getTableVersion() <<
" ? "
4311 std::stringstream missingSs;
4312 auto diffGroupPair =
4313 diffTree->get().getConfigurationManager()->getGroupOfLoadedTable(
4314 diffTree->get().getTableName());
4315 missingSs <<
"<<< '" << diffTree->get().getValueAsString() <<
"' in "
4316 << diffGroupPair.first <<
"(" << diffGroupPair.second
4323 std::stringstream missingSs;
4325 auto diffGroupPair =
4326 diffTree->get().getConfigurationManager()->getGroupOfLoadedTable(
4328 missingSs <<
"<<< Path not found in " << diffGroupPair.first <<
"("
4329 << diffGroupPair.second <<
") >>>";
4343 if(t.
getValueType() == TableViewColumnInfo::TYPE_FIXED_CHOICE_DATA ||
4344 t.
getValueType() == TableViewColumnInfo::TYPE_BITMAP_DATA)
4349 for(
const auto& choice : choices)
4366 if(diffTree.has_value())
4368 __COUTS__(30) <<
"\t\t diff type " << diffTree->get().getNodeType()
4375 std::stringstream missingSs;
4377 auto diffGroupPair =
4378 diffTree->get().getConfigurationManager()->getGroupOfLoadedTable(
4380 missingSs <<
"<<< Path not found in " << diffGroupPair.first <<
"("
4381 << diffGroupPair.second <<
") >>>";
4386 __COUTS__(30) <<
"\t\t diff isDisconnected "
4387 << diffTree->get().isDisconnected() << __E__;
4389 std::stringstream missingSs;
4391 auto diffGroupPair =
4392 diffTree->get().getConfigurationManager()->getGroupOfLoadedTable(
4394 missingSs <<
"<<< Link is "
4395 << (diffTree->get().isDisconnected() ?
"DISCONNECTED"
4397 <<
" in " << diffGroupPair.first <<
"("
4398 << diffGroupPair.second <<
") >>>";
4405 std::stringstream missingSs;
4407 auto diffGroupPair =
4408 diffTree->get().getConfigurationManager()->getGroupOfLoadedTable(
4410 missingSs <<
"<<< Link is "
4411 << (diffTree->get().isUIDLinkNode() ?
"a UID Link"
4413 <<
" in " << diffGroupPair.first <<
"("
4414 << diffGroupPair.second <<
") >>>";
4419 diffTree->get().getValueAsString())
4422 std::stringstream missingSs;
4424 auto diffGroupPair =
4425 diffTree->get().getConfigurationManager()->getGroupOfLoadedTable(
4427 missingSs <<
"<<< Link to '" << diffTree->get().getValueAsString()
4428 <<
"' in " << diffGroupPair.first <<
"("
4429 << diffGroupPair.second <<
") >>>";
4435 std::stringstream missingSs;
4438 auto dtchildren = diffTree->get().getChildrenMap();
4439 missingSs <<
"<<< Group link";
4440 if(tchildren.size() != dtchildren.size())
4441 missingSs <<
" has " << tchildren.size() <<
" vs "
4442 << dtchildren.size() <<
" children..";
4443 for(
auto& tchild : tchildren)
4444 if(dtchildren.find(tchild.first) == dtchildren.end())
4445 missingSs <<
" '" << tchild.first <<
"' missing..";
4446 for(
auto& dtchild : dtchildren)
4447 if(tchildren.find(dtchild.first) == tchildren.end())
4448 missingSs <<
" '" << dtchild.first <<
"' present...";
4451 if(missingSs.str().length() > std::string(
"<<< Group link").length())
4453 auto diffGroupPair =
4455 .getConfigurationManager()
4456 ->getGroupOfLoadedTable(diffTree->get().getTableName());
4457 missingSs <<
" in " << diffGroupPair.first <<
"("
4458 << diffGroupPair.second <<
") >>>";
4460 "nodeDiff", missingSs.str(), parentEl);
4488 xercesc::DOMElement* choicesParentEl =
4494 __COUTS__(30) <<
"choices.size() " << choices.size() << __E__;
4496 for(
const auto& choice : choices)
4518 xercesc::DOMElement* choicesParentEl =
4522 for(
const auto& choice : choices)
4529 bool returnNode =
true;
4543 "nodeStatus", t.
isEnabled() ?
"1" :
"0", parentEl);
4546 if(diffTree.has_value())
4549 <<
"\t\t diff type " << diffTree->get().getNodeType() << __E__;
4558 auto diffGroupPair =
4560 .getConfigurationManager()
4562 missingSs <<
"<<< Not in " << diffGroupPair.first <<
"("
4563 << diffGroupPair.second <<
") >>>";
4565 "nodeDiff", missingSs.str(), parentEl);
4599 void ConfigurationGUISupervisor::handleGetLinkToChoicesXML(
4602 const std::string& linkToTableName,
4604 const std::string& linkIdType,
4605 const std::string& linkIndex,
4606 const std::string& linkInitId)
4619 const std::string& tableName = linkToTableName;
4624 table->setActiveView(version);
4628 __SUP_COUT__ <<
"Failed to find stored version, so attempting to load version: "
4629 << version << __E__;
4633 if(version != table->getViewVersion())
4635 __SUP_SS__ <<
"Target table version (" << version
4636 <<
") is not the currently active version (" << table->getViewVersion()
4637 <<
". Try refreshing the tree." << __E__;
4638 __SUP_COUT_WARN__ << ss.str();
4642 __SUP_COUT__ <<
"Active version is " << table->getViewVersion() << __E__;
4644 if(linkIdType ==
"UID")
4647 unsigned int col = table->getView().getColUID();
4648 for(
unsigned int row = 0; row < table->getView().getNumberOfRows(); ++row)
4649 xmlOut.addTextElementToData(
"linkToChoice",
4650 table->getView().getDataView()[row][col]);
4652 else if(linkIdType ==
"GroupID")
4658 __SUP_COUTV__(linkIndex);
4659 __SUP_COUTV__(linkInitId);
4661 std::set<std::string> setOfGroupIDs =
4662 table->getView().getSetOfGroupIDs(linkIndex);
4667 bool foundInitId =
false;
4668 for(
const auto& groupID : setOfGroupIDs)
4670 if(!foundInitId && linkInitId == groupID)
4673 xmlOut.addTextElementToData(
"linkToChoice", groupID);
4677 xmlOut.addTextElementToData(
"linkToChoice", linkInitId);
4680 unsigned int col = table->getView().getColUID();
4681 for(
unsigned int row = 0; row < table->getView().getNumberOfRows(); ++row)
4683 xmlOut.addTextElementToData(
"groupChoice",
4684 table->getView().getDataView()[row][col]);
4685 if(table->getView().isEntryInGroup(row, linkIndex, linkInitId))
4686 xmlOut.addTextElementToData(
"groupMember",
4687 table->getView().getDataView()[row][col]);
4692 __SUP_SS__ <<
"Unrecognized linkIdType '" << linkIdType <<
".'" << __E__;
4696 catch(std::runtime_error& e)
4698 __SUP_SS__ <<
"Error detected saving tree node!\n\n " << e.what() << __E__;
4699 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
4700 xmlOut.addTextElementToData(
"Error", ss.str());
4704 __SUP_SS__ <<
"Error detected saving tree node!\n\n " << __E__;
4709 catch(
const std::exception& e)
4711 ss <<
"Exception message: " << e.what();
4716 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
4717 xmlOut.addTextElementToData(
"Error", ss.str());
4722 void ConfigurationGUISupervisor::handleMergeGroupsXML(
4725 const std::string& groupANameContext,
4727 const std::string& groupBNameContext,
4729 const std::string& groupANameConfig,
4731 const std::string& groupBNameConfig,
4733 const std::string& author,
4734 const std::string& mergeApproach)
4737 __SUP_COUT__ <<
"Merging context group pair " << groupANameContext <<
" ("
4738 << groupAKeyContext <<
") & " << groupBNameContext <<
" ("
4739 << groupBKeyContext <<
") and table group pair " << groupANameConfig
4740 <<
" (" << groupAKeyConfig <<
") & " << groupBNameConfig <<
" ("
4741 << groupBKeyConfig <<
") with approach '" << mergeApproach << __E__;
4757 if(!(mergeApproach ==
"Rename" || mergeApproach ==
"Replace" ||
4758 mergeApproach ==
"Skip"))
4760 __SS__ <<
"Error! Invalid merge approach '" << mergeApproach <<
".'" << __E__;
4764 std::map<std::string ,
TableVersion > memberMapAContext,
4765 memberMapBContext, memberMapAConfig, memberMapBConfig;
4768 bool skippingContextPair =
false;
4769 bool skippingConfigPair =
false;
4770 if(groupANameContext.size() == 0 || groupANameContext[0] ==
' ' ||
4771 groupBNameContext.size() == 0 || groupBNameContext[0] ==
' ')
4773 skippingContextPair =
true;
4774 __SUP_COUTV__(skippingContextPair);
4776 if(groupANameConfig.size() == 0 || groupANameConfig[0] ==
' ' ||
4777 groupBNameConfig.size() == 0 || groupBNameConfig[0] ==
' ')
4779 skippingConfigPair =
true;
4780 __SUP_COUTV__(skippingConfigPair);
4784 if(!skippingContextPair)
4817 if(!skippingConfigPair)
4854 std::map<std::pair<std::string , std::string >,
4858 std::pair<std::string ,
4859 std::pair<std::string , std::string >>,
4861 groupidConversionMap;
4863 std::stringstream mergeReport;
4864 mergeReport <<
"======================================" << __E__;
4866 mergeReport <<
"Merging context group pair " << groupANameContext <<
" ("
4867 << groupAKeyContext <<
") & " << groupBNameContext <<
" ("
4868 << groupBKeyContext <<
") and table group pair " << groupANameConfig
4869 <<
" (" << groupAKeyConfig <<
") & " << groupBNameConfig <<
" ("
4870 << groupBKeyConfig <<
") with approach '" << mergeApproach << __E__;
4871 mergeReport <<
"======================================" << __E__;
4875 for(
unsigned int i = 0; i < 2; ++i)
4877 if(i == 0 && mergeApproach !=
"Rename")
4881 for(
unsigned int j = 0; j < 2; ++j)
4883 if(j == 0 && skippingContextPair)
4885 __COUT__ <<
"Skipping context pair..." << __E__;
4888 else if(j == 1 && skippingConfigPair)
4890 __COUT__ <<
"Skipping table pair..." << __E__;
4895 j == 0 ? memberMapAContext : memberMapAConfig;
4898 j == 0 ? memberMapBContext : memberMapBConfig;
4901 __COUT__ <<
"Context pair..." << __E__;
4903 __COUT__ <<
"Table pair..." << __E__;
4905 __COUT__ <<
"Starting member map B scan." << __E__;
4906 for(
const auto& bkey : memberMapBref)
4908 __SUP_COUTV__(bkey.first);
4910 if(memberMapAref.find(bkey.first) == memberMapAref.end())
4912 mergeReport <<
"\n'" << mergeApproach <<
"'-Missing table '"
4913 << bkey.first <<
"' A=v" << -1 <<
", adding B=v"
4914 << bkey.second << __E__;
4917 memberMapAref[bkey.first] = bkey.second;
4919 else if(memberMapAref[bkey.first] != bkey.second)
4922 __SUP_COUTV__(memberMapAref[bkey.first]);
4923 __SUP_COUTV__(bkey.second);
4928 __SUP_COUT__ <<
"Got table." << __E__;
4932 ->getVersionedTableByName(bkey.first,
4933 memberMapAref[bkey.first])
4939 mergeApproach ==
"Rename"
4940 ? TableBase::MergeApproach::RENAME
4941 : (mergeApproach ==
"Replace"
4942 ? TableBase::MergeApproach::REPLACE
4943 : TableBase::MergeApproach::SKIP),
4945 groupidConversionMap,
4948 table->getTableName() ==
4949 ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME
4955 __SUP_COUTV__(newVersion);
4973 catch(std::runtime_error& e)
4976 <<
"There was an error saving the '"
4977 << table->getTableName()
4978 <<
"' merge result to a persistent table version. "
4979 <<
"Perhaps you can modify this table in one of the "
4980 "groups to resolve this issue, and then re-merge."
4981 << __E__ << e.what();
4985 __SUP_COUTV__(newVersion);
4987 memberMapAref[bkey.first] = newVersion;
4996 if(!skippingContextPair)
4998 __SUP_COUT__ <<
"New context member map complete." << __E__;
5005 "Merger of group " + groupANameContext +
" (" + groupAKeyContext.
toString() +
5006 ") and " + groupBNameContext +
" (" + groupBKeyContext.
toString() +
").");
5009 xmlOut.addTextElementToData(
"ContextGroupName", groupANameContext);
5010 xmlOut.addTextElementToData(
"ContextGroupKey", newKeyContext.
toString());
5012 if(!skippingConfigPair)
5014 __SUP_COUT__ <<
"New table member map complete." << __E__;
5021 "Merger of group " + groupANameConfig +
" (" + groupAKeyConfig.
toString() +
5022 ") and " + groupBNameConfig +
" (" + groupBKeyConfig.
toString() +
").");
5025 xmlOut.addTextElementToData(
"ConfigGroupName", groupANameConfig);
5026 xmlOut.addTextElementToData(
"ConfigGroupKey", newKeyConfig.
toString());
5031 std::string mergeReportBasePath = std::string(__ENV__(
"USER_DATA"));
5032 std::string mergeReportPath =
"/ServiceData/";
5034 mkdir((mergeReportBasePath + mergeReportPath).c_str(), 0755);
5035 mergeReportPath +=
"ConfigurationGUI_mergeReports/";
5037 mkdir((mergeReportBasePath + mergeReportPath).c_str(), 0755);
5040 "merge_" + std::to_string(time(0)) +
"_" + std::to_string(clock()) +
".txt";
5041 __SUP_COUTV__(mergeReportPath);
5043 FILE* fp = fopen((mergeReportBasePath + mergeReportPath).c_str(),
"w");
5046 fprintf(fp,
"%s", mergeReport.str().c_str());
5048 xmlOut.addTextElementToData(
"MergeReportFile",
5049 "/$USER_DATA/" + mergeReportPath);
5052 xmlOut.addTextElementToData(
"MergeReportFile",
"FILE FAILURE");
5056 catch(std::runtime_error& e)
5058 __SUP_SS__ <<
"Error merging context group pair " << groupANameContext <<
" ("
5059 << groupAKeyContext <<
") & " << groupBNameContext <<
" ("
5060 << groupBKeyContext <<
") and table group pair " << groupANameConfig
5061 <<
" (" << groupAKeyConfig <<
") & " << groupBNameConfig <<
" ("
5062 << groupBKeyConfig <<
") with approach '" << mergeApproach <<
"': \n\n"
5063 << e.what() << __E__;
5064 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
5065 xmlOut.addTextElementToData(
"Error", ss.str());
5069 __SUP_SS__ <<
"Unknown error merging context group pair " << groupANameContext <<
" ("
5070 << groupAKeyContext <<
") & " << groupBNameContext <<
" ("
5071 << groupBKeyContext <<
") and table group pair " << groupANameConfig
5072 <<
" (" << groupAKeyConfig <<
") & " << groupBNameConfig <<
" ("
5073 << groupBKeyConfig <<
") with approach '" << mergeApproach <<
".' \n\n";
5078 catch(
const std::exception& e)
5080 ss <<
"Exception message: " << e.what();
5085 __SUP_COUT_ERR__ <<
"\n" << ss.
str() << __E__;
5086 xmlOut.addTextElementToData(
"Error", ss.str());
5091 void ConfigurationGUISupervisor::handleSavePlanCommandSequenceXML(
5094 const std::string& groupName,
5096 const std::string& modifiedTables,
5097 const std::string& author,
5098 const std::string& planName,
5099 const std::string& commandString)
5102 __COUT__ <<
"handleSavePlanCommandSequenceXML " << planName << __E__;
5105 setupActiveTablesXML(xmlOut,
5124 for(
const auto& commandPair : IterateTable::commandToTableMap_)
5125 if(commandPair.second !=
"")
5126 commandTableToEditMap.emplace(std::pair<std::string, TableEditStruct>(
5143 std::string groupName = planName +
"-Plan";
5144 __SUP_COUT__ <<
"Handling commands for group " << groupName << __E__;
5146 unsigned int groupIdCol =
5147 planTable.tableView_->findCol(IterateTable::planTableCols_.GroupID_);
5148 unsigned int cmdTypeCol =
5149 planTable.tableView_->findCol(IterateTable::planTableCols_.CommandType_);
5151 unsigned int targetGroupIdCol =
5152 targetTable.tableView_->findCol(IterateTable::targetCols_.GroupID_);
5153 unsigned int targetTableCol =
5154 targetTable.tableView_->findCol(IterateTable::targetCols_.TargetLink_);
5155 unsigned int targetUIDCol =
5156 targetTable.tableView_->findCol(IterateTable::targetCols_.TargetLinkUID_);
5158 std::string groupLinkIndex =
5159 planTable.tableView_->getColumnInfo(groupIdCol).getChildLinkIndex();
5160 __SUP_COUT__ <<
"groupLinkIndex: " << groupLinkIndex << __E__;
5162 std::pair<
unsigned int ,
unsigned int > commandUidLink;
5165 planTable.tableView_->getChildLink(
5166 planTable.tableView_->findCol(IterateTable::planTableCols_.CommandLink_),
5171 unsigned int cmdRow, cmdCol;
5172 std::string targetGroupName;
5176 std::string targetUID, cmdType;
5178 for(
unsigned int row = 0; row < planTable.tableView_->getNumberOfRows();
5181 targetUID = planTable.tableView_
5182 ->getDataView()[row][planTable.tableView_->getColUID()];
5183 __SUP_COUT__ <<
"targetUID: " << targetUID << __E__;
5186 if(planTable.tableView_->isEntryInGroup(row, groupLinkIndex, groupName))
5188 __SUP_COUT__ <<
"Removing." << __E__;
5192 cmdType = planTable.tableView_->getDataView()[row][cmdTypeCol];
5193 auto cmdTypeTableIt = IterateTable::commandToTableMap_.find(cmdType);
5194 if(cmdTypeTableIt != IterateTable::commandToTableMap_.end() &&
5195 cmdTypeTableIt->second !=
5199 commandTableToEditMap.at(cmdTypeTableIt->second);
5200 cmdRow = cmdTypeTableEdit.tableView_->findRow(
5201 cmdTypeTableEdit.tableView_->getColUID(),
5202 planTable.tableView_
5203 ->getDataView()[row][commandUidLink.second]);
5210 cmdCol = cmdTypeTableEdit.tableView_->findCol(
5211 IterateTable::commandTargetCols_.TargetsLinkGroupID_);
5212 targetGroupName = cmdTypeTableEdit.tableView_
5213 ->getDataView()[cmdRow][cmdCol];
5215 for(
unsigned int trow = 0;
5216 trow < targetTable.tableView_->getNumberOfRows();
5220 if(targetTable.tableView_->isEntryInGroup(
5222 cmdTypeTableEdit.tableView_->getColumnInfo(cmdCol)
5223 .getChildLinkIndex(),
5226 __SUP_COUT__ <<
"Removing target." << __E__;
5228 if(targetTable.tableView_->removeRowFromGroup(
5239 __SUP_COUT__ <<
"No targets." << __E__;
5244 cmdTypeTableEdit.tableView_->deleteRow(cmdRow);
5250 if(planTable.tableView_->removeRowFromGroup(
5251 row, groupIdCol, groupName,
true ))
5260 std::vector<IterateTable::Command> commands;
5265 std::istringstream f(commandString);
5266 std::string commandSubString, paramSubString, paramValue;
5268 while(getline(f, commandSubString,
';'))
5270 __SUP_COUTT__ <<
"commandSubString " << commandSubString << __E__;
5271 std::istringstream g(commandSubString);
5274 while(getline(g, paramSubString,
','))
5276 __SUP_COUTT__ <<
"paramSubString " << paramSubString << __E__;
5279 if(paramSubString !=
"type")
5281 __SUP_SS__ <<
"Invalid command sequence" << __E__;
5285 commands.push_back(IterateTable::Command());
5287 getline(g, paramValue,
',');
5289 __SUP_COUTT__ <<
"paramValue " << paramValue << __E__;
5290 commands.back().type_ = paramValue;
5294 getline(g, paramValue,
',');
5296 __SUP_COUTT__ <<
"paramValue " << paramValue << __E__;
5298 commands.back().params_.emplace(
5299 std::pair<std::string ,
5311 __SUP_COUT__ <<
"commands size " << commands.size() << __E__;
5318 unsigned int row, tgtRow;
5319 unsigned int targetIndex;
5320 std::string targetStr, cmdUID;
5322 for(
auto& command : commands)
5324 __SUP_COUT__ <<
"command " << command.type_ << __E__;
5325 __SUP_COUT__ <<
"table " << IterateTable::commandToTableMap_.at(command.type_)
5329 row = planTable.tableView_->addRow(
5330 author,
true ,
"planCommand");
5331 planTable.tableView_->addRowToGroup(row, groupIdCol, groupName);
5334 planTable.tableView_->setURIEncodedValue(command.type_, row, cmdTypeCol);
5337 planTable.tableView_->setValueAsString(
5338 "1", row, planTable.tableView_->getColStatus());
5341 auto cmdTypeTableIt = IterateTable::commandToTableMap_.find(command.type_);
5342 if(cmdTypeTableIt != IterateTable::commandToTableMap_.end() &&
5343 cmdTypeTableIt->second !=
5347 commandTableToEditMap.at(cmdTypeTableIt->second);
5348 __SUP_COUT__ <<
"table " << cmdTypeTableEdit.tableName_ << __E__;
5353 cmdRow = cmdTypeTableEdit.tableView_->addRow(
5354 author,
true , command.type_ +
"_COMMAND_");
5360 for(
auto& param : command.params_)
5362 __SUP_COUT__ <<
"\t param " << param.first <<
" : " << param.second
5365 if(param.first == IterateTable::targetParams_.Tables_)
5367 __SUP_COUT__ <<
"\t\t found target tables" << __E__;
5368 std::istringstream f(param.second);
5371 while(getline(f, targetStr,
'='))
5373 __SUP_COUT__ <<
"\t\t targetStr = " << targetStr << __E__;
5374 if(!command.targets_.size() ||
5375 command.targets_.back().table_ !=
"")
5377 __SUP_COUT__ <<
"\t\t make targetStr = " << targetStr
5380 command.addTarget();
5381 command.targets_.back().table_ = targetStr;
5384 command.targets_[targetIndex++].table_ = targetStr;
5390 if(param.first == IterateTable::targetParams_.UIDs_)
5392 __SUP_COUT__ <<
"\t\t found target UIDs" << __E__;
5393 std::istringstream f(param.second);
5396 while(getline(f, targetStr,
'='))
5398 __SUP_COUT__ <<
"\t\t targetStr = " << targetStr << __E__;
5399 if(!command.targets_.size() ||
5400 command.targets_.back().UID_ !=
"")
5402 __SUP_COUT__ <<
"\t\t make targetStr = " << targetStr
5405 command.addTarget();
5406 command.targets_.back().UID_ = targetStr;
5409 command.targets_[targetIndex++].UID_ = targetStr;
5414 cmdCol = cmdTypeTableEdit.tableView_->findCol(param.first);
5416 __SUP_COUT__ <<
"param col " << cmdCol << __E__;
5418 cmdTypeTableEdit.tableView_->setURIEncodedValue(
5419 param.second, cmdRow, cmdCol);
5423 cmdTypeTableEdit.tableView_
5424 ->getDataView()[cmdRow][cmdTypeTableEdit.tableView_->getColUID()];
5426 if(command.targets_.size())
5430 __SUP_COUT__ <<
"targets found for command UID=" << cmdUID << __E__;
5433 cmdCol = cmdTypeTableEdit.tableView_->findCol(
5434 IterateTable::commandTargetCols_.TargetsLink_);
5435 cmdTypeTableEdit.tableView_->setValueAsString(
5436 IterateTable::TARGET_TABLE, cmdRow, cmdCol);
5438 cmdCol = cmdTypeTableEdit.tableView_->findCol(
5439 IterateTable::commandTargetCols_.TargetsLinkGroupID_);
5440 cmdTypeTableEdit.tableView_->setValueAsString(
5441 cmdUID +
"_Targets", cmdRow, cmdCol);
5445 for(
const auto& target : command.targets_)
5447 __SUP_COUT__ << target.
table_ <<
" " << target.UID_ << __E__;
5450 tgtRow = targetTable.tableView_->addRow(
5451 author,
true ,
"commandTarget");
5452 targetTable.tableView_->addRowToGroup(
5453 tgtRow, targetGroupIdCol, cmdUID +
"_Targets");
5456 targetTable.tableView_->setValueAsString(
5457 target.table_, tgtRow, targetTableCol);
5460 targetTable.tableView_->setValueAsString(
5461 target.UID_, tgtRow, targetUIDCol);
5466 planTable.tableView_->setValueAsString(
5467 cmdTypeTableEdit.tableName_, row, commandUidLink.first);
5468 planTable.tableView_->setValueAsString(
5469 cmdUID, row, commandUidLink.second);
5471 __SUP_COUT__ <<
"linked to uid = " << cmdUID << __E__;
5481 planTable.tableView_->print();
5482 planTable.tableView_->init();
5484 __SUP_COUT__ <<
"requestType tables:" << __E__;
5486 for(
auto& modifiedConfig : commandTableToEditMap)
5488 __SUP_COUTV__(modifiedConfig.second.modified_);
5489 modifiedConfig.second.tableView_->print();
5490 modifiedConfig.second.tableView_->init();
5493 targetTable.tableView_->print();
5494 targetTable.tableView_->init();
5499 __SUP_COUT__ <<
"Handling command table errors while saving. Erasing all newly "
5505 if(planTable.createdTemporaryVersion_)
5507 __SUP_COUT__ <<
"Erasing temporary version " << planTable.tableName_ <<
"-v"
5508 << planTable.temporaryVersion_ << __E__;
5511 planTable.temporaryVersion_);
5514 if(targetTable.createdTemporaryVersion_)
5516 __SUP_COUT__ <<
"Erasing temporary version " << targetTable.tableName_ <<
"-v"
5517 << targetTable.temporaryVersion_ << __E__;
5520 targetTable.temporaryVersion_);
5523 for(
auto& modifiedConfig : commandTableToEditMap)
5525 if(modifiedConfig.second
5526 .createdTemporaryVersion_)
5528 __SUP_COUT__ <<
"Erasing temporary version "
5529 << modifiedConfig.second.tableName_ <<
"-v"
5530 << modifiedConfig.second.temporaryVersion_ << __E__;
5533 modifiedConfig.second.temporaryVersion_);
5547 planTable.tableName_,
5548 planTable.originalVersion_,
5551 planTable.temporaryVersion_,
5554 __SUP_COUT__ <<
"Final plan version is " << planTable.tableName_ <<
"-v"
5555 << finalVersion << __E__;
5560 targetTable.tableName_,
5561 targetTable.originalVersion_,
5564 targetTable.temporaryVersion_,
5567 __SUP_COUT__ <<
"Final target version is " << targetTable.tableName_ <<
"-v"
5568 << finalVersion << __E__;
5570 for(
auto& modifiedConfig : commandTableToEditMap)
5572 if(!modifiedConfig.second.modified_)
5574 if(modifiedConfig.second
5575 .createdTemporaryVersion_)
5577 __SUP_COUT__ <<
"Erasing unmodified temporary version "
5578 << modifiedConfig.second.tableName_ <<
"-v"
5579 << modifiedConfig.second.temporaryVersion_ << __E__;
5582 modifiedConfig.second.temporaryVersion_);
5590 modifiedConfig.second.tableName_,
5591 modifiedConfig.second.originalVersion_,
5593 modifiedConfig.second.table_,
5594 modifiedConfig.second.temporaryVersion_,
5597 __SUP_COUT__ <<
"Final version is " << modifiedConfig.second.tableName_ <<
"-v"
5598 << finalVersion << __E__;
5601 handleFillModifiedTablesXML(xmlOut, cfgMgr);
5603 catch(std::runtime_error& e)
5605 __SUP_SS__ <<
"Error detected saving Iteration Plan!\n\n " << e.what() << __E__;
5606 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
5607 xmlOut.addTextElementToData(
"Error", ss.str());
5611 __SUP_SS__ <<
"Error detected saving Iteration Plan!\n\n " << __E__;
5616 catch(
const std::exception& e)
5618 ss <<
"Exception message: " << e.what();
5623 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
5624 xmlOut.addTextElementToData(
"Error", ss.str());
5637 void ConfigurationGUISupervisor::handleSaveTreeNodeEditXML(
HttpXmlDocument& xmlOut,
5639 const std::string& tableName,
5641 const std::string& type,
5642 const std::string& uid,
5643 const std::string& colName,
5644 const std::string& newValue,
5645 const std::string& author)
5648 __SUP_COUT__ <<
"Editing table " << tableName <<
"(" << version <<
") uid=" << uid
5649 <<
" type=" << type << __E__;
5659 table->setActiveView(version);
5663 if(version.isTemporaryVersion())
5666 __SUP_COUT__ <<
"Failed to find stored version, so attempting to load version: "
5667 << version << __E__;
5671 __SUP_COUT__ <<
"Active version is " << table->getViewVersion() << __E__;
5672 __SUP_COUTTV__(table->getView().getComment());
5674 if(version != table->getViewVersion())
5676 __SUP_SS__ <<
"Target table version (" << version
5677 <<
") is not the currently active version (" << table->getViewVersion()
5678 <<
"). Try refreshing the tree." << __E__;
5682 unsigned int col = -1;
5683 if(type ==
"uid" || type ==
"delete-uid" || type ==
"tree-copy")
5684 col = table->getView().getColUID();
5685 else if(type ==
"node-comment")
5686 col = table->getView().findCol(TableViewColumnInfo::COL_NAME_COMMENT);
5687 else if(type ==
"link-UID" || type ==
"link-GroupID" || type ==
"value" ||
5688 type ==
"value-groupid" || type ==
"value-bool" || type ==
"value-bitmap")
5689 col = table->getView().findCol(colName);
5690 else if(type ==
"table" || type ==
"link-comment" || type ==
"table-newGroupRow" ||
5691 type ==
"table-newUIDRow" || type ==
"table-newRow")
5695 __SUP_SS__ <<
"Impossible! Unrecognized edit type: " << type << __E__;
5700 if(type ==
"table" || type ==
"link-comment")
5703 if(table->getView().isURIEncodedCommentTheSame(newValue))
5706 <<
"' is the same as the current comment. No need to save change."
5722 TableVersion temporaryVersion = table->createTemporaryView(version);
5724 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion << __E__;
5726 TableView* cfgView = table->getTemporaryView(temporaryVersion);
5729 __SUP_COUTTV__(table->getView().getComment());
5735 if(type ==
"table" || type ==
"link-comment")
5740 else if(type ==
"table-newRow" || type ==
"table-newUIDRow")
5743 unsigned int row = cfgView->
addRow(
5744 author,
true , newValue );
5759 else if(type ==
"table-newGroupRow")
5762 unsigned int csvIndex = newValue.find(
',');
5764 std::string linkIndex = newValue.substr(0, csvIndex);
5765 std::string groupId = newValue.substr(csvIndex + 1);
5768 csvIndex = groupId.find(
',');
5769 std::string newRowUID = groupId.substr(csvIndex + 1);
5770 groupId = groupId.substr(0, csvIndex);
5772 __SUP_COUT__ <<
"newValue " << linkIndex <<
"," << groupId <<
"," << newRowUID
5776 unsigned int row = cfgView->
addRow(author,
5802 else if(type ==
"delete-uid")
5805 unsigned int row = cfgView->
findRow(col, uid);
5808 else if(type ==
"tree-copy")
5811 __COUTV__(newValue);
5812 std::vector<std::string> paramArray =
5818 if(paramArray.size() < 2 || paramArray.size() > 3)
5820 __SS__ <<
"Illegal parameters for tree copy request: must be number of "
5821 "copy instances & depth of copy (optionally followed by a "
5822 "custom UID for the new record)."
5827 unsigned int row = cfgView->
findRow(col, uid);
5830 unsigned int numberOfInstances = atoi(paramArray[0].c_str());
5831 unsigned int depth = atoi(paramArray[1].c_str());
5832 std::string customUID = paramArray.size() == 3
5836 __COUTV__(numberOfInstances);
5837 __COUTV__(customUID);
5838 if(numberOfInstances > 1000)
5840 __SS__ <<
"Illegal parameters - the maximum number of copy instances is "
5841 "1000. Number of instances provided was "
5842 << numberOfInstances << __E__;
5845 if(!customUID.empty() && numberOfInstances != 1)
5847 __SS__ <<
"A custom UID can only be supplied when copying a single "
5848 "instance. Requested instances: "
5849 << numberOfInstances << __E__;
5857 unsigned int rowsBeforeCopy = cfgView->getNumberOfRows();
5858 ConfigurationSupervisorBase::recursiveCopyTreeUIDNode(xmlOut,
5868 if(!customUID.empty() && cfgView->getNumberOfRows() > rowsBeforeCopy)
5870 unsigned int uidCol = cfgView->
getColUID();
5871 unsigned int newRow = cfgView->getNumberOfRows() - 1;
5873 xmlOut.addTextElementToData(
"CopiedRecordUID", customUID);
5876 else if(type ==
"uid" || type ==
"value" || type ==
"value-groupid" ||
5877 type ==
"value-bool" || type ==
"value-bitmap" || type ==
"node-comment")
5883 __SUP_SS__ <<
"Value '" << newValue
5884 <<
"' is the same as the current value. No need to save "
5885 "change to tree node."
5890 else if(type ==
"link-UID" || type ==
"link-GroupID")
5893 std::pair<
unsigned int ,
unsigned int > linkPair;
5897 __SUP_SS__ <<
"Col '" << colName <<
"' is not a link column." << __E__;
5901 __SUP_COUT__ <<
"linkPair " << linkPair.first <<
"," << linkPair.second
5904 std::string linkIndex = cfgView->getColumnInfo(col).getChildLinkIndex();
5906 __SUP_COUT__ <<
"linkIndex " << linkIndex << __E__;
5909 unsigned int csvIndexStart = 0, csvIndex = newValue.find(
',');
5911 std::string newTable = newValue.substr(csvIndexStart, csvIndex);
5912 csvIndexStart = csvIndex + 1;
5913 csvIndex = newValue.find(
',', csvIndexStart);
5914 std::string newLinkId = newValue.substr(
5919 __SUP_COUT__ <<
"newValue " << newTable <<
"," << newLinkId << __E__;
5923 bool changed =
false;
5924 bool needSecondaryChange = (type ==
"link-GroupID");
5929 __SUP_COUT__ <<
"Value '" << newTable
5930 <<
"' is the same as the current value." << __E__;
5938 std::string originalValue = cfgView->
getValueAsString(row, linkPair.second);
5942 __SUP_COUT__ <<
"Value '" << newLinkId
5943 <<
"' is the same as the current value." << __E__;
5948 needSecondaryChange =
5954 if(needSecondaryChange)
5956 bool secondaryChanged =
false;
5957 bool defaultIsInGroup =
5963 __SUP_COUT__ <<
"No changes to primary view. Erasing temporary table."
5965 table->eraseView(temporaryVersion);
5986 catch(std::runtime_error&
5989 __SUP_COUT__ <<
"Caught error while editing main table. Erasing "
5990 "temporary version."
5992 table->eraseView(temporaryVersion);
5996 xmlOut.addTextElementToData(
5998 "Error saving primary tree node! " + std::string(e.what()));
6008 __SUP_COUTV__(newValue);
6009 csvIndexStart = csvIndex + 1;
6010 csvIndex = newValue.find(
',', csvIndexStart);
6012 csvIndexStart, csvIndex - csvIndexStart));
6015 if(newTable == TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
6026 table->setActiveView(version);
6030 if(version.isTemporaryVersion())
6033 __SUP_COUT__ <<
"Failed to find stored version, so attempting to "
6035 << newTable <<
" v" << version << __E__;
6039 __SUP_COUT__ << newTable <<
" active version is "
6040 << table->getViewVersion() << __E__;
6042 if(version != table->getViewVersion())
6045 if(version.isMockupVersion())
6046 ss <<
"Target table '" << newTable
6047 <<
"' is likely not a member of the current table group "
6048 <<
"since the mock-up version was not successfully loaded. "
6053 "To add a table to a group, click the group name to go to "
6055 "group view, then click 'Add/Remove/Modify Member Tables.' "
6057 "can then add or remove tables and save the new group." +
6059 "OR!!! Click the following button to add the table '" +
6061 "' to the currently active Configuration Group: " +
6062 "<input type='button' style='color:black !important;' " +
6063 "title='Click to add table to the active Configuration "
6065 "onclick='addTableToConfigurationGroup(\"" + newTable +
6066 "\"); Debug.closeErrorPop();event.stopPropagation();' "
6067 "value='Add Table'>" +
6071 ss <<
"Target table version (" << version
6072 <<
") is not the currently active version ("
6073 << table->getViewVersion() <<
"). Try refreshing the tree."
6079 temporaryVersion = table->createTemporaryView(version);
6081 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion << __E__;
6083 cfgView = table->getTemporaryView(temporaryVersion);
6087 if(type ==
"link-UID")
6097 __SUP_COUT__ <<
"target col " << col << __E__;
6099 unsigned int row = -1;
6102 row = cfgView->
findRow(col, newLinkId);
6107 if(row == (
unsigned int)-1)
6109 __SUP_COUT__ <<
"New link UID '" << newLinkId
6110 <<
"' was not found, so attempting to change UID of "
6112 << originalValue <<
"'" << __E__;
6115 row = cfgView->
findRow(col, originalValue);
6118 secondaryChanged =
true;
6119 __SUP_COUT__ <<
"Original target record '"
6120 << originalValue <<
"' was changed to '"
6121 << newLinkId <<
"'" << __E__;
6126 __SUP_COUT__ <<
"Original target record '" << originalValue
6127 <<
"' not found." << __E__;
6131 else if(type ==
"link-GroupID")
6139 __SUP_COUT__ <<
"target col " << col << __E__;
6142 std::vector<std::string> memberUIDs;
6145 csvIndexStart = csvIndex + 1;
6146 csvIndex = newValue.find(
',', csvIndexStart);
6147 memberUIDs.push_back(
6148 newValue.substr(csvIndexStart, csvIndex - csvIndexStart));
6149 __SUP_COUT__ <<
"memberUIDs: " << memberUIDs.back() << __E__;
6151 (
unsigned int)std::string::npos);
6161 std::string targetUID;
6162 bool shouldBeInGroup;
6165 for(
unsigned int row = 0; row < cfgView->getNumberOfRows(); ++row)
6167 targetUID = cfgView->getDataView()[row][cfgView->
getColUID()];
6168 __SUP_COUT__ <<
"targetUID: " << targetUID << __E__;
6170 shouldBeInGroup =
false;
6171 for(
unsigned int i = 0; i < memberUIDs.size(); ++i)
6172 if(targetUID == memberUIDs[i])
6175 shouldBeInGroup =
true;
6182 if(shouldBeInGroup && !isInGroup)
6184 __SUP_COUT__ <<
"Changed to YES: " << row << __E__;
6185 secondaryChanged =
true;
6190 else if(!shouldBeInGroup && isInGroup)
6192 __SUP_COUT__ <<
"Changed to NO: " << row << __E__;
6193 secondaryChanged =
true;
6197 else if(targetUID ==
6199 ->getDefaultRowValues()[cfgView->
getColUID()] &&
6203 defaultIsInGroup =
true;
6209 if(!secondaryChanged)
6212 <<
"No changes to secondary view. Erasing temporary table."
6214 table->eraseView(temporaryVersion);
6235 catch(std::runtime_error&
6238 __SUP_COUT__ <<
"Caught error while editing secondary table. "
6239 "Erasing temporary version."
6241 table->eraseView(temporaryVersion);
6242 secondaryChanged =
false;
6245 xmlOut.addTextElementToData(
6247 "Error saving secondary tree node! " + std::string(e.what()));
6255 if(0 && !changed && !secondaryChanged && !defaultIsInGroup)
6257 __SUP_SS__ <<
"Link to table '" << newTable <<
"', linkID '"
6259 <<
"', and selected group members are the same as the "
6261 <<
"No need to save changes to tree." << __E__;
6267 else if(0 && !changed)
6272 __SUP_SS__ <<
"Link to table '" << newTable <<
"' and linkID '"
6274 <<
"' are the same as the current values. No need to save "
6275 "change to tree node."
6285 __SUP_COUT__ <<
"Caught error while editing. Erasing temporary version." << __E__;
6286 table->eraseView(temporaryVersion);
6300 catch(std::runtime_error& e)
6302 __SUP_SS__ <<
"Error saving tree node! " << e.what() << __E__;
6303 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
6304 xmlOut.addTextElementToData(
"Error", ss.str());
6308 __SUP_SS__ <<
"Unknown Error saving tree node! " << __E__;
6313 catch(
const std::exception& e)
6315 ss <<
"Exception message: " << e.what();
6320 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
6321 xmlOut.addTextElementToData(
"Error", ss.str());
6365 void ConfigurationGUISupervisor::handleGetTableXML(
HttpXmlDocument& xmlOut,
6367 const std::string& tableName,
6369 bool allowIllegalColumns ,
6371 bool descriptionOnly )
6374 xercesc::DOMElement *parentEl, *subparentEl;
6376 std::string accumulatedErrors =
"";
6378 if(allowIllegalColumns)
6379 xmlOut.addTextElementToData(
"allowIllegalColumns",
"1");
6381 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo(
6382 allowIllegalColumns ,
6383 allowIllegalColumns ? &accumulatedErrors : 0,
6392 xmlOut.addTextElementToData(
"ExistingTableNames",
6393 TableViewColumnInfo::DATATYPE_LINK_DEFAULT);
6394 for(
auto& configPair : allTableInfo)
6396 xmlOut.addTextElementToData(
"ExistingTableNames", configPair.first);
6397 if(configPair.first == tableName &&
6398 configPair.second.versions_.find(version) ==
6399 configPair.second.versions_.end())
6401 __SUP_COUT__ <<
"Version not found, so using mockup." << __E__;
6407 xmlOut.addTextElementToData(
"TableName", tableName);
6408 xmlOut.addTextElementToData(
"TableDescription",
6409 table->getTableDescription());
6426 for(
const auto& aliases : versionAliases)
6427 for(
const auto& alias : aliases.second)
6428 __SUP_COUTT__ <<
"ALIAS: " << aliases.first <<
" " << alias.first
6429 <<
" ==> " << alias.second << __E__;
6431 catch(
const std::runtime_error& e)
6433 __SUP_COUT__ <<
"Could not get backbone information for version aliases: "
6434 << e.what() << __E__;
6437 auto tableIterator = versionAliases.find(tableName);
6439 parentEl = xmlOut.addTextElementToData(
"TableVersions",
"");
6442 for(
const TableVersion& v : allTableInfo.at(tableName).versions_)
6448 std::vector<std::string> aliases;
6449 if(tableIterator != versionAliases.end())
6452 for(
const auto& aliasPair : tableIterator->second)
6454 if(v == aliasPair.second)
6456 __SUP_COUT__ <<
"Found Alias " << aliasPair.second <<
" --> "
6457 << aliasPair.first << __E__;
6458 aliases.push_back(aliasPair.first);
6466 __SUP_COUT__ <<
"Handling version w/aliases" << __E__;
6469 TableVersion::INVALID)
6474 else if(hi.
version() + 1 == v.version())
6481 if(lo.
version() != TableVersion::INVALID)
6491 if(versionAliases.size())
6495 for(
const auto& alias : aliases)
6497 hi = lo = TableVersion::INVALID;
6502 if(lo.
version() != TableVersion::INVALID)
6516 if(version.isInvalid())
6518 tableViewPtr = table->getMockupViewP();
6526 std::string localAccumulatedErrors =
"";
6531 allowIllegalColumns ,
6532 &localAccumulatedErrors,
6538 xmlOut.addTextElementToData(
"TableRawData",
6539 tableViewPtr->getSourceRawData());
6541 const std::set<std::string>& srcColNames =
6542 tableViewPtr->getSourceColumnNames();
6543 for(
auto& srcColName : srcColNames)
6544 xmlOut.addTextElementToData(
"ColumnHeader", srcColName);
6546 if(!version.isTemporaryVersion())
6551 tableViewPtr = cfgMgr
6555 allowIllegalColumns ,
6556 &localAccumulatedErrors,
6562 if(localAccumulatedErrors !=
"")
6563 xmlOut.addTextElementToData(
"Error", localAccumulatedErrors);
6565 catch(std::runtime_error& e)
6567 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version " << version
6568 <<
"... defaulting to mock-up! " << __E__;
6569 ss <<
"\n\n...Here is why it failed:\n\n" << e.what() << __E__;
6571 __SUP_COUT_ERR__ <<
"\n" << ss.str();
6573 tableViewPtr = table->getMockupViewP();
6575 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
6579 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version: " << version
6580 <<
"... defaulting to mock-up! "
6581 <<
"(You may want to try again to see what was partially loaded "
6582 "into cache before failure. "
6583 <<
"If you think, the failure is due to a column name change, "
6584 <<
"you can also try to Copy the failing view to the new column "
6586 <<
"'Copy and Move' functionality.)" << __E__;
6591 catch(
const std::exception& e)
6593 ss <<
"Exception message: " << e.what();
6599 __SUP_COUT_ERR__ <<
"\n" << ss.str();
6601 tableViewPtr = table->getMockupViewP();
6603 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
6606 xmlOut.addTextElementToData(
"TableVersion", version.toString());
6612 xercesc::DOMElement* choicesParentEl;
6613 parentEl = xmlOut.addTextElementToData(
"CurrentVersionColumnHeaders",
"");
6615 std::vector<TableViewColumnInfo> colInfo = tableViewPtr->getColumnsInfo();
6617 for(
int i = 0; i < (int)colInfo.size(); ++i)
6622 "ColumnDataType", colInfo[i].getDataType(), parentEl);
6627 "ColumnDefaultValue", colInfo[i].getDefaultValue(), parentEl);
6631 if(colInfo[i].getType() == TableViewColumnInfo::TYPE_FIXED_CHOICE_DATA ||
6632 colInfo[i].getType() == TableViewColumnInfo::TYPE_BITMAP_DATA ||
6633 colInfo[i].isChildLink())
6635 for(
auto& choice : colInfo[i].getDataChoices())
6640 "ColumnMinValue", colInfo[i].getMinValue(), parentEl);
6642 "ColumnMaxValue", colInfo[i].getMaxValue(), parentEl);
6648 if(version.isInvalid())
6649 tableViewPtr->
init();
6651 catch(std::runtime_error& e)
6654 __THROW__(e.what() + std::string(
"\n\n") + accumulatedErrors);
6661 parentEl = xmlOut.addTextElementToData(
"CurrentVersionRows",
"");
6663 int numRows = (int)tableViewPtr->getNumberOfRows();
6664 int numCols = (int)tableViewPtr->getNumberOfColumns();
6666 for(
int c = 0; c < numCols; ++c)
6669 csvStr.reserve(numRows * 20);
6670 for(
int r = 0; r < numRows; ++r)
6674 if(colInfo[c].getDataType() == TableViewColumnInfo::DATATYPE_TIME)
6676 std::string timeAsString;
6677 tableViewPtr->
getValue(timeAsString, r, c);
6678 csvStr += StringMacros::encodeURIComponent(timeAsString);
6682 StringMacros::encodeURIComponent(tableViewPtr->getDataView()[r][c]);
6688 xmlOut.addTextElementToData(
"TableComment", tableViewPtr->getComment());
6689 xmlOut.addTextElementToData(
"TableAuthor", tableViewPtr->getAuthor());
6690 xmlOut.addTextElementToData(
"TableCreationTime",
6691 std::to_string(tableViewPtr->getCreationTime()));
6692 xmlOut.addTextElementToData(
"TableLastAccessTime",
6693 std::to_string(tableViewPtr->getLastAccessTime()));
6698 std::vector<std::string> defaultRowValues =
6699 table->getMockupViewP()->getDefaultRowValues();
6701 for(
unsigned int c = 0; c < defaultRowValues.size() - 2; ++c)
6703 xmlOut.addTextElementToData(
"DefaultRowValue", defaultRowValues[c]);
6706 const std::set<std::string> srcColNames = tableViewPtr->getSourceColumnNames();
6708 if(accumulatedErrors !=
"")
6710 __SUP_SS__ << (std::string(
"Column errors were allowed for this request, so "
6711 "perhaps you can ignore this, ") +
6712 "but please note the following warnings:\n" + accumulatedErrors)
6714 __SUP_COUT_ERR__ << ss.str();
6715 xmlOut.addTextElementToData(
"TableWarnings", ss.str());
6717 else if(!version.isTemporaryVersion() &&
6719 (srcColNames.size() != tableViewPtr->getNumberOfColumns() ||
6720 tableViewPtr->getSourceColumnMismatch() !=
6723 __SUP_SS__ <<
"\n\nThere were warnings found when loading the table " << tableName
6724 <<
":v" << version <<
". Please see the details below:\n\n"
6725 << tableViewPtr->getMismatchColumnInfo();
6727 __SUP_COUT__ <<
"\n" << ss.str();
6728 xmlOut.addTextElementToData(
"TableWarnings", ss.str());
6732 catch(std::runtime_error& e)
6734 __SUP_SS__ <<
"Error getting table view!\n\n " << e.what() << __E__;
6735 __SUP_COUT_ERR__ << ss.str();
6736 xmlOut.addTextElementToData(
"Error", ss.str());
6740 __SUP_SS__ <<
"Error getting table view!\n\n " << __E__;
6745 catch(
const std::exception& e)
6747 ss <<
"Exception message: " << e.what();
6752 __SUP_COUT_ERR__ << ss.str();
6753 xmlOut.addTextElementToData(
"Error", ss.str());
6764 std::string username,
bool refresh)
6766 uint64_t sessionIndex =
6769 std::stringstream ssMapKey;
6770 ssMapKey << username <<
":" << sessionIndex;
6771 std::string mapKey = ssMapKey.str();
6772 __SUP_COUTT__ <<
"Using Config Session " << mapKey
6773 <<
" ... Total Session Count: " << userConfigurationManagers_.size()
6774 <<
" refresh=" << refresh << __E__;
6776 time_t now = time(0);
6782 for(
auto& pair : userConfigurationManagers_)
6783 __SUP_COUTTV__(pair.first);
6786 const std::string preLoadCfgMgrName =
":0";
6787 if(userConfigurationManagers_.size() == 1 &&
6788 userConfigurationManagers_.find(preLoadCfgMgrName) !=
6789 userConfigurationManagers_.end())
6791 __SUP_COUT__ <<
"Using pre-loaded Configuration Manager. time=" << time(0) <<
" "
6792 << clock() <<
" Setting author from "
6793 << userConfigurationManagers_.at(preLoadCfgMgrName)->getUsername()
6794 <<
" to " << username << __E__;
6795 userConfigurationManagers_[mapKey] =
6796 userConfigurationManagers_.at(preLoadCfgMgrName);
6797 userLastUseTime_[mapKey] = userLastUseTime_.at(preLoadCfgMgrName);
6799 userConfigurationManagers_.at(mapKey)->setUsername(username);
6802 if(userConfigurationManagers_.find(mapKey) == userConfigurationManagers_.end())
6804 __SUP_COUT__ <<
"Creating new Configuration Manager. time=" << time(0) <<
" "
6805 << clock() << __E__;
6811 userConfigurationManagers_[mapKey]->getAllTableInfo(
6819 else if(userLastUseTime_.find(mapKey) == userLastUseTime_.end())
6821 __SUP_SS__ <<
"Fatal error managing user sessions! Check the logs for "
6822 "Configuration Interface failure."
6824 __SUP_COUT_ERR__ <<
"\n" << ss.str();
6829 (now - userLastUseTime_[mapKey]) >
6830 CONFIGURATION_MANAGER_REFRESH_THRESHOLD)
6832 __SUP_COUT__ <<
"Refreshing all table info." << __E__;
6833 userConfigurationManagers_[mapKey]->getAllTableInfo(
6841 __SUP_COUTT__ <<
"Configuration Manager for author="
6842 << userConfigurationManagers_[mapKey]->getUsername()
6843 <<
" ready. time=" << time(0) <<
" " << clock() <<
" runTimeSeconds()="
6844 << userConfigurationManagers_[mapKey]->runTimeSeconds() << __E__;
6847 userLastUseTime_[mapKey] = now;
6850 for(std::map<std::string, time_t>::iterator it = userLastUseTime_.begin();
6851 it != userLastUseTime_.end();
6853 if(now - it->second > CONFIGURATION_MANAGER_EXPIRATION_TIME)
6855 __SUP_COUT__ << now <<
":" << it->second <<
" = " << now - it->second
6857 delete userConfigurationManagers_[it->first];
6858 if(!(userConfigurationManagers_.erase(it->first)))
6860 __SUP_SS__ <<
"Fatal error erasing configuration manager by key!"
6862 __SUP_COUT_ERR__ <<
"\n" << ss.str();
6865 userLastUseTime_.erase(it);
6872 return userConfigurationManagers_[mapKey];
6880 void ConfigurationGUISupervisor::handleDeleteTableInfoXML(
HttpXmlDocument& xmlOut,
6882 std::string& tableName)
6884 if(0 == rename((TABLE_INFO_PATH + tableName + TABLE_INFO_EXT).c_str(),
6885 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused").c_str()))
6886 __SUP_COUT_INFO__ << (
"Table Info File successfully renamed: " +
6887 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused"))
6891 __SUP_COUT_ERR__ << (
"Error renaming file to " +
6892 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused"))
6895 xmlOut.addTextElementToData(
6897 (
"Error renaming Table Info File to " +
6898 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused")));
6913 void ConfigurationGUISupervisor::handleSaveTableInfoXML(
6916 std::string& tableName,
6917 const std::string& data,
6918 const std::string& tableDescription,
6919 const std::string& columnChoicesCSV,
6920 bool allowOverwrite)
6924 std::string capsName;
6929 catch(std::runtime_error& e)
6931 xmlOut.addTextElementToData(
"Error", e.what());
6937 FILE* fp = fopen((TABLE_INFO_PATH + tableName + TABLE_INFO_EXT).c_str(),
"r");
6941 xmlOut.addTextElementToData(
"TableName", tableName);
6942 xmlOut.addTextElementToData(
"OverwriteError",
"1");
6943 xmlOut.addTextElementToData(
6945 "File already exists! ('" +
6946 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT) +
"')");
6951 __SUP_COUT__ <<
"capsName=" << capsName << __E__;
6952 __SUP_COUT__ <<
"tableName=" << tableName << __E__;
6953 __SUP_COUT__ <<
"tableDescription=" << tableDescription << __E__;
6954 __SUP_COUT__ <<
"columnChoicesCSV=" << columnChoicesCSV << __E__;
6957 std::stringstream outss;
6959 outss <<
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n";
6960 outss <<
"\t<ROOT xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
6961 "xsi:noNamespaceSchemaLocation=\"TableInfo.xsd\">\n";
6962 outss <<
"\t\t<TABLE Name=\"" << tableName <<
"\">\n";
6963 outss <<
"\t\t\t<VIEW Name=\"" << capsName
6964 <<
"\" Type=\"File,Database,DatabaseTest\" Description=\"" << tableDescription
6970 std::istringstream columnChoicesISS(columnChoicesCSV);
6971 std::string columnChoicesString;
6972 std::string columnDefaultValue, columnMinValue, columnMaxValue;
6973 std::vector<std::string> columnParameters;
6974 std::vector<std::string> columnData =
6977 std::set<std::string> childLinkIndices, childLinkUIDIndices, childLinkGroupIDIndices;
6979 for(
unsigned int c = 0; c < columnData.size() - 1; ++c)
6983 __COUT__ <<
"Column #" << c <<
": "
6985 for(
unsigned int p = 0; p < columnParameters.size(); ++p)
6987 __COUT__ <<
"\t Parameter #" << p <<
": " << columnParameters[p] << __E__;
6989 __COUT__ <<
"\t creating the new xml" << __E__;
6991 std::string& columnType = columnParameters[0];
6992 std::string& columnName = columnParameters[1];
6993 std::string& columnDataType = columnParameters[2];
6994 const std::string columnStorageName =
6997 outss <<
"\t\t\t\t<COLUMN Type=\"";
6998 outss << columnType;
6999 outss <<
"\" \t Name=\"";
7000 outss << columnName;
7001 outss <<
"\" \t StorageName=\"";
7004 outss << columnStorageName;
7006 catch(std::runtime_error& e)
7008 xmlOut.addTextElementToData(
7010 std::string(
"For column name '") + columnName +
"' - " + e.what());
7013 outss <<
"\" \t DataType=\"";
7014 outss << columnDataType;
7018 std::string* columnDefaultValuePtr =
nullptr;
7019 if(columnDefaultValue !=
7022 __SUP_COUT__ <<
"FOUND user spec'd default value '" << columnDefaultValue
7024 outss <<
"\" \t DefaultValue=\"";
7025 outss << columnParameters[3];
7026 columnDefaultValuePtr = &columnParameters[3];
7028 getline(columnChoicesISS, columnChoicesString,
';');
7029 outss <<
"\" \t DataChoices=\"";
7030 outss << columnChoicesString;
7032 std::string* columnMinValuePtr =
nullptr;
7033 std::string* columnMaxValuePtr =
nullptr;
7035 if(columnParameters.size() > 4 &&
7039 if(columnMinValue !=
"")
7041 if(columnMinValue !=
7044 __SUP_COUT__ <<
"FOUND user spec'd min value '" << columnParameters[4]
7049 __SS__ <<
"Inavlid user spec'd min value '" << columnParameters[4]
7050 <<
"' which evaluates to '" << columnMinValue
7051 <<
"' and is not a valid number. The minimum value must "
7052 "be a number (environment variables and math "
7053 "operations are allowed)."
7057 outss <<
"\" \t MinValue=\"" << columnParameters[4];
7058 columnMinValuePtr = &columnParameters[4];
7063 if(columnMaxValue !=
"")
7065 if(columnMaxValue !=
7068 __SUP_COUT__ <<
"FOUND user spec'd max value = " << columnMaxValue
7073 __SS__ <<
"Inavlid user spec'd max value '" << columnParameters[5]
7074 <<
"' which evaluates to '" << columnMaxValue
7075 <<
"' and is not a valid number. The maximum value must "
7076 "be a number (environment variables and math "
7077 "operations are allowed)."
7081 outss <<
"\" \t MaxValue=\"" << columnParameters[5];
7082 columnMaxValuePtr = &columnParameters[5];
7094 columnDefaultValuePtr,
7095 columnChoicesString,
7101 catch(
const std::runtime_error& e)
7103 __SS__ <<
"Error identified with Column #" << c <<
": \n" << e.what();
7108 childLinkIndices.insert(columnType.substr(
sizeof(
"ChildLink-") - 1));
7109 else if(columnType.find(
"ChildLinkUID-") == 0)
7110 childLinkUIDIndices.insert(columnType.substr(
sizeof(
"ChildLinkUID-") - 1));
7111 else if(columnType.find(
"ChildLinkGroupID-") == 0)
7112 childLinkGroupIDIndices.insert(
7113 columnType.substr(
sizeof(
"ChildLinkGroupID-") - 1));
7120 for(
const auto& idx : childLinkUIDIndices)
7121 if(childLinkIndices.find(idx) == childLinkIndices.end())
7123 __SS__ <<
"Column type 'ChildLinkUID-" << idx
7124 <<
"' has no matching 'ChildLink-" << idx
7125 <<
"' column. A ChildLinkUID column must be paired with a "
7126 "ChildLink column using the same link index."
7130 for(
const auto& idx : childLinkGroupIDIndices)
7131 if(childLinkIndices.find(idx) == childLinkIndices.end())
7133 __SS__ <<
"Column type 'ChildLinkGroupID-" << idx
7134 <<
"' has no matching 'ChildLink-" << idx
7135 <<
"' column. A ChildLinkGroupID column must be paired with a "
7136 "ChildLink column using the same link index. "
7137 "Did you intend to make a target of a Group Link? "
7138 "If so, use the 'GroupID' column type instead."
7142 for(
const auto& idx : childLinkIndices)
7143 if(childLinkUIDIndices.find(idx) == childLinkUIDIndices.end() &&
7144 childLinkGroupIDIndices.find(idx) == childLinkGroupIDIndices.end())
7146 __SS__ <<
"Column type 'ChildLink-" << idx
7147 <<
"' has no matching 'ChildLinkUID-" << idx
7148 <<
"' or 'ChildLinkGroupID-" << idx
7149 <<
"' column. A ChildLink column must be paired with either a "
7150 "ChildLinkUID or ChildLinkGroupID column using the same link index."
7155 outss <<
"\t\t\t</VIEW>\n";
7156 outss <<
"\t\t</TABLE>\n";
7157 outss <<
"\t</ROOT>\n";
7159 __SUP_COUT__ << outss.str() << __E__;
7161 FILE* fp = fopen((TABLE_INFO_PATH + tableName + TABLE_INFO_EXT).c_str(),
"w");
7164 xmlOut.addTextElementToData(
"Error",
7165 "Failed to open destination Table Info file:" +
7166 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT));
7170 fprintf(fp,
"%s", outss.str().c_str());
7173 __SUP_COUT_INFO__ <<
"Finished saving Table Info for '" << tableName
7174 <<
".' Looking for errors in all table column info..." << __E__;
7178 std::string accumulatedErrors =
"";
7182 if(accumulatedErrors !=
"")
7184 __SUP_SS__ << (
"The new version of the '" + tableName +
7185 "' table column info was saved, however errors were detected "
7186 "reading back the table '" +
7187 tableName +
"' after the save attempt:\n\n" + accumulatedErrors)
7190 __SUP_COUT_ERR__ << ss.str() << __E__;
7191 xmlOut.addTextElementToData(
"Error", ss.str());
7197 handleGetTableXML(xmlOut, cfgMgr, tableName,
TableVersion());
7200 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
7203 for(
const auto& cfgInfo : allTableInfo)
7209 catch(std::runtime_error& e)
7211 __SUP_COUT_WARN__ <<
"\n\n##############################################\n"
7212 <<
"Error identified in column info of table '"
7213 << cfgInfo.first <<
"':\n\n"
7214 << e.what() <<
"\n\n"
7228 void ConfigurationGUISupervisor::handleSetGroupAliasInBackboneXML(
7231 const std::string& groupAliasCSV,
7232 const std::string& groupNameCSV,
7233 const std::string& groupKeyCSV,
7234 const std::string& author)
7238 std::map<std::string, TableVersion> activeVersions = cfgMgr->
getActiveVersions();
7240 const std::string groupAliasesTableName =
7241 ConfigurationManager::GROUP_ALIASES_TABLE_NAME;
7242 if(activeVersions.find(groupAliasesTableName) == activeVersions.end())
7244 __SUP_SS__ <<
"Active version of " << groupAliasesTableName <<
" missing!"
7246 xmlOut.addTextElementToData(
"Error", ss.str());
7251 const std::set<std::string> backboneMembers = cfgMgr->getBackboneMemberNames();
7252 for(
auto& memberName : backboneMembers)
7254 __SUP_COUT__ <<
"activeVersions[\"" << memberName
7255 <<
"\"]=" << activeVersions[memberName] << __E__;
7257 xmlOut.addTextElementToData(
"oldBackboneName", memberName);
7258 xmlOut.addTextElementToData(
"oldBackboneVersion",
7259 activeVersions[memberName].toString());
7267 TableVersion originalVersion = activeVersions[groupAliasesTableName];
7268 TableVersion temporaryVersion = table->createTemporaryView(originalVersion);
7270 __SUP_COUT__ <<
"\t\t temporaryVersion: " << temporaryVersion << __E__;
7271 bool isDifferent =
false;
7275 TableView* configView = table->getTemporaryView(temporaryVersion);
7277 unsigned int col = configView->
findCol(
"GroupKeyAlias");
7278 unsigned int ccol = configView->
findCol(TableViewColumnInfo::COL_NAME_COMMENT);
7279 unsigned int ncol = configView->
findCol(
"GroupName");
7280 unsigned int kcol = configView->
findCol(
"GroupKey");
7283 std::vector<std::string> groupAliases =
7285 std::vector<std::string> groupNames =
7287 std::vector<std::string> groupKeys =
7294 for(
const auto& groupAlias : groupAliases)
7296 if(groupAlias ==
"" || groupNames[i] ==
"" || groupKeys[i] ==
"")
7299 __SUP_COUT_WARN__ <<
"Empty alias parameter found [" << i <<
"] = {"
7300 << groupAlias <<
", " << groupNames[i] <<
"("
7301 << groupKeys[i] <<
")}" << __E__;
7306 bool localIsDifferent =
false;
7307 const std::string& groupName = groupNames[i];
7311 unsigned int row = -1;
7315 row = configView->
findRow(col, groupAlias);
7321 if(row == (
unsigned int)-1)
7323 localIsDifferent =
true;
7324 row = configView->
addRow();
7328 "This Group Alias was automatically setup by the server.", row, ccol);
7329 configView->
setValue(groupAlias, row, col);
7332 __SUP_COUT__ <<
"\t\t row: " << row << __E__;
7334 __SUP_COUT__ <<
"\t\t groupName: " << groupName <<
" vs "
7335 << configView->getDataView()[row][ncol] << __E__;
7336 if(groupName != configView->getDataView()[row][ncol])
7338 configView->
setValue(groupName, row, ncol);
7339 localIsDifferent =
true;
7342 __SUP_COUT__ <<
"\t\t groupKey: " << groupKey <<
" vs "
7343 << configView->getDataView()[row][kcol] << __E__;
7344 if(groupKey.
toString() != configView->getDataView()[row][kcol])
7347 localIsDifferent =
true;
7350 if(localIsDifferent)
7355 configView->
findCol(TableViewColumnInfo::COL_NAME_AUTHOR));
7359 configView->
findCol(TableViewColumnInfo::COL_NAME_CREATION));
7366 __SUP_COUT_ERR__ <<
"Error editing Group Alias view!" << __E__;
7369 table->eraseView(temporaryVersion);
7376 __SUP_COUT__ <<
"\t\t**************************** Save as new table version"
7383 table->getTableName(),
7394 <<
"\t\t**************************** Using the existing table version"
7398 table->eraseView(temporaryVersion);
7399 newAssignedVersion = activeVersions[groupAliasesTableName];
7401 xmlOut.addTextElementToData(
"savedName", groupAliasesTableName);
7402 xmlOut.addTextElementToData(
"savedVersion", newAssignedVersion.
toString());
7405 __SUP_COUT__ <<
"\t\t newAssignedVersion: " << newAssignedVersion << __E__;
7407 catch(std::runtime_error& e)
7409 __SUP_SS__ <<
"Error saving new Group Alias view!\n\n " << e.what() << __E__;
7410 __SUP_COUT_ERR__ << ss.str();
7411 xmlOut.addTextElementToData(
"Error", ss.str());
7415 __SUP_SS__ <<
"Error saving new Group Alias view!\n\n " << __E__;
7420 catch(
const std::exception& e)
7422 ss <<
"Exception message: " << e.what();
7427 __SUP_COUT_ERR__ << ss.str();
7428 xmlOut.addTextElementToData(
"Error", ss.str());
7439 void ConfigurationGUISupervisor::handleSetTableAliasInBackboneXML(
7442 const std::string& tableAlias,
7443 const std::string& tableName,
7445 const std::string& author)
7449 std::map<std::string, TableVersion> activeVersions = cfgMgr->
getActiveVersions();
7451 const std::string versionAliasesTableName =
7452 ConfigurationManager::VERSION_ALIASES_TABLE_NAME;
7453 if(activeVersions.find(versionAliasesTableName) == activeVersions.end())
7455 __SUP_SS__ <<
"Active version of " << versionAliasesTableName <<
" missing!"
7457 xmlOut.addTextElementToData(
"Error", ss.str());
7462 const std::set<std::string> backboneMembers = cfgMgr->getBackboneMemberNames();
7463 for(
auto& memberName : backboneMembers)
7465 __SUP_COUT__ <<
"activeVersions[\"" << memberName
7466 <<
"\"]=" << activeVersions[memberName] << __E__;
7468 xmlOut.addTextElementToData(
"oldBackboneName", memberName);
7469 xmlOut.addTextElementToData(
"oldBackboneVersion",
7470 activeVersions[memberName].toString());
7478 TableVersion originalVersion = activeVersions[versionAliasesTableName];
7479 TableVersion temporaryVersion = table->createTemporaryView(originalVersion);
7481 __SUP_COUT__ <<
"\t\t temporaryVersion: " << temporaryVersion << __E__;
7483 bool isDifferent =
false;
7487 TableView* configView = table->getTemporaryView(temporaryVersion);
7490 unsigned int col2 = configView->
findCol(
"VersionAlias");
7491 unsigned int col3 = configView->
findCol(
"TableName");
7495 unsigned int row = -1;
7500 unsigned int tmpRow = -1;
7503 tmpRow = configView->
findRow(col3, tableName, tmpRow + 1);
7504 }
while(configView->getDataView()[tmpRow][col2] != tableAlias);
7511 if(row == (
unsigned int)-1)
7514 row = configView->
addRow();
7517 col = configView->
findCol(TableViewColumnInfo::COL_NAME_COMMENT);
7519 std::string(
"Entry was added by server in ") +
7520 "ConfigurationGUISupervisor::setTableAliasInActiveBackbone().",
7524 col = configView->
findCol(
"VersionAliasUID");
7526 tableName.substr(0, tableName.rfind(
"Table")) + tableAlias, row, col);
7528 configView->
setValue(tableAlias, row, col2);
7529 configView->
setValue(tableName, row, col3);
7532 __SUP_COUT__ <<
"\t\t row: " << row << __E__;
7534 col = configView->
findCol(
"Version");
7535 __SUP_COUT__ <<
"\t\t version: " << version <<
" vs "
7536 << configView->getDataView()[row][col] << __E__;
7537 if(version.toString() != configView->getDataView()[row][col])
7539 configView->
setValue(version.toString(), row, col);
7546 author, row, configView->
findCol(TableViewColumnInfo::COL_NAME_AUTHOR));
7550 configView->
findCol(TableViewColumnInfo::COL_NAME_CREATION));
7555 __SUP_COUT_ERR__ <<
"Error editing Version Alias view!" << __E__;
7558 table->eraseView(temporaryVersion);
7565 __SUP_COUT__ <<
"\t\t**************************** Save as new table version"
7571 table->getTableName(),
7581 __SUP_COUT__ <<
"\t\t**************************** Using existing table version"
7585 table->eraseView(temporaryVersion);
7586 newAssignedVersion = activeVersions[versionAliasesTableName];
7588 xmlOut.addTextElementToData(
"savedName", versionAliasesTableName);
7589 xmlOut.addTextElementToData(
"savedVersion", newAssignedVersion.
toString());
7592 __SUP_COUT__ <<
"\t\t newAssignedVersion: " << newAssignedVersion << __E__;
7594 catch(std::runtime_error& e)
7596 __SUP_SS__ <<
"Error saving new Version Alias view!\n\n " << e.what() << __E__;
7597 __SUP_COUT_ERR__ << ss.str();
7598 xmlOut.addTextElementToData(
"Error", ss.str());
7602 __SUP_SS__ <<
"Error saving new Version Alias view!\n\n " << __E__;
7607 catch(
const std::exception& e)
7609 ss <<
"Exception message: " << e.what();
7614 __SUP_COUT_ERR__ << ss.str();
7615 xmlOut.addTextElementToData(
"Error", ss.str());
7624 void ConfigurationGUISupervisor::handleAliasGroupMembersInBackboneXML(
7627 const std::string& versionAlias,
7628 const std::string& groupName,
7630 const std::string& author)
7634 std::map<std::string, TableVersion> activeVersions = cfgMgr->
getActiveVersions();
7636 const std::string versionAliasesTableName =
7637 ConfigurationManager::VERSION_ALIASES_TABLE_NAME;
7638 if(activeVersions.find(versionAliasesTableName) == activeVersions.end())
7640 __SUP_SS__ <<
"Active version of " << versionAliasesTableName <<
" missing!"
7642 xmlOut.addTextElementToData(
"Error", ss.str());
7647 const std::set<std::string> backboneMembers = cfgMgr->getBackboneMemberNames();
7648 for(
auto& memberName : backboneMembers)
7650 __SUP_COUT__ <<
"activeVersions[\"" << memberName
7651 <<
"\"]=" << activeVersions[memberName] << __E__;
7653 xmlOut.addTextElementToData(
"oldBackboneName", memberName);
7654 xmlOut.addTextElementToData(
"oldBackboneVersion",
7655 activeVersions[memberName].toString());
7664 table->createTemporaryView(activeVersions[versionAliasesTableName]);
7666 __SUP_COUT__ <<
"\t\t temporaryVersion: " << temporaryVersion << __E__;
7668 TableView* configView = table->getTemporaryView(temporaryVersion);
7671 bool isDifferent =
false;
7690 xmlOut.addTextElementToData(
7693 "\" can not be retrieved!");
7698 unsigned int col2 = configView->
findCol(
"VersionAlias");
7699 unsigned int col3 = configView->
findCol(
"TableName");
7701 for(
auto& memberPair : memberMap)
7703 bool thisMemberIsDifferent =
false;
7704 unsigned int row = -1;
7706 __SUP_COUT__ <<
"Adding alias for " << memberPair.first <<
"_v"
7707 << memberPair.second <<
" to " << versionAlias << __E__;
7713 unsigned int tmpRow = -1;
7716 tmpRow = configView->
findRow(col3, memberPair.first, tmpRow + 1);
7717 }
while(configView->getDataView()[tmpRow][col2] != versionAlias);
7724 if(row == (
unsigned int)-1)
7726 thisMemberIsDifferent =
true;
7727 row = configView->
addRow();
7730 col = configView->
findCol(TableViewColumnInfo::COL_NAME_COMMENT);
7732 std::string(
"Entry was added by server in ") +
7733 "ConfigurationGUISupervisor::setTableAliasInActiveBackbone().",
7739 memberPair.first.substr(0, memberPair.first.rfind(
"Table")) +
7744 configView->
setValue(versionAlias, row, col2);
7745 configView->
setValue(memberPair.first, row, col3);
7748 col = configView->
findCol(
"Version");
7750 if(memberPair.second.toString() != configView->getDataView()[row][col])
7752 configView->
setValue(memberPair.second.toString(), row, col);
7753 thisMemberIsDifferent =
true;
7756 if(thisMemberIsDifferent)
7759 author, row, configView->
findCol(TableViewColumnInfo::COL_NAME_AUTHOR));
7763 configView->
findCol(TableViewColumnInfo::COL_NAME_CREATION));
7766 if(thisMemberIsDifferent)
7775 __SUP_COUT__ <<
"\t\t**************************** Save v" << temporaryVersion
7776 <<
" as new table version" << __E__;
7778 newAssignedVersion =
7779 cfgMgr->
saveNewTable(versionAliasesTableName, temporaryVersion);
7783 __SUP_COUT__ <<
"\t\t**************************** Using existing table version"
7787 table->eraseView(temporaryVersion);
7788 newAssignedVersion = activeVersions[versionAliasesTableName];
7791 xmlOut.addTextElementToData(
"savedName", versionAliasesTableName);
7792 xmlOut.addTextElementToData(
"savedVersion", newAssignedVersion.
toString());
7793 __SUP_COUT__ <<
"\t\t Resulting Version: " << newAssignedVersion << __E__;
7795 catch(std::runtime_error& e)
7797 __SUP_SS__ <<
"Error saving new Version Alias view!\n\n " << e.what() << __E__;
7798 __SUP_COUT_ERR__ << ss.str();
7799 xmlOut.addTextElementToData(
"Error", ss.str());
7803 __SUP_SS__ <<
"Error saving new Version Alias view!\n\n " << __E__;
7808 catch(
const std::exception& e)
7810 ss <<
"Exception message: " << e.what();
7815 __SUP_COUT_ERR__ << ss.str();
7816 xmlOut.addTextElementToData(
"Error", ss.str());
7830 void ConfigurationGUISupervisor::handleGroupAliasesXML(
HttpXmlDocument& xmlOut,
7834 std::map<std::string, TableVersion> activeVersions = cfgMgr->
getActiveVersions();
7836 std::string groupAliasesTableName = ConfigurationManager::GROUP_ALIASES_TABLE_NAME;
7837 if(activeVersions.find(groupAliasesTableName) == activeVersions.end())
7839 __SUP_SS__ <<
"\nActive version of " << groupAliasesTableName <<
" missing! "
7840 << groupAliasesTableName
7841 <<
" is a required member of the Backbone table group."
7842 <<
"\n\nLikely you need to activate a valid Backbone table group."
7844 __SUP_COUT__ << ss.str();
7849 __SUP_COUT__ <<
"activeVersions[\"" << groupAliasesTableName
7850 <<
"\"]=" << activeVersions[groupAliasesTableName] << __E__;
7851 xmlOut.addTextElementToData(
"GroupAliasesTableName", groupAliasesTableName);
7852 xmlOut.addTextElementToData(
"GroupAliasesTableVersion",
7853 activeVersions[groupAliasesTableName].toString());
7855 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
7858 const int numOfThreads = StringMacros::getConcurrencyCount() / 2;
7859 __SUP_COUT__ <<
" getConcurrencyCount " << StringMacros::getConcurrencyCount()
7860 <<
" ==> " << numOfThreads <<
" threads for alias group loads." << __E__;
7862 if(numOfThreads < 2)
7864 std::string groupName, groupKey, groupComment, groupAuthor, groupCreateTime,
7866 for(
auto& aliasNodePair : aliasNodePairs)
7868 groupName = aliasNodePair.second.getNode(
"GroupName").getValueAsString();
7869 groupKey = aliasNodePair.second.getNode(
"GroupKey").getValueAsString();
7871 xmlOut.addTextElementToData(
"GroupAlias", aliasNodePair.first);
7872 xmlOut.addTextElementToData(
"GroupName", groupName);
7873 xmlOut.addTextElementToData(
"GroupKey", groupKey);
7874 xmlOut.addTextElementToData(
7876 aliasNodePair.second.getNode(TableViewColumnInfo::COL_NAME_COMMENT)
7877 .getValueAsString());
7881 ConfigurationManager::UNKNOWN_INFO;
7882 groupType = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
7899 __SUP_COUT_WARN__ <<
"Failed to load group '" << groupName <<
"("
7900 << groupKey <<
")' to extract group comment and type."
7903 xmlOut.addTextElementToData(
"GroupComment", groupComment);
7904 xmlOut.addTextElementToData(
"GroupType", groupType);
7909 int threadsLaunched = 0;
7910 int foundThreadIndex = 0;
7911 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
7912 for(
int i = 0; i < numOfThreads; ++i)
7913 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
7915 std::vector<std::shared_ptr<ots::GroupInfo>> sharedGroupInfoPtrs;
7916 std::string groupName, groupKey;
7918 for(
auto& aliasNodePair : aliasNodePairs)
7921 sharedGroupInfoPtrs.push_back(std::make_shared<ots::GroupInfo>());
7923 groupName = aliasNodePair.second.getNode(
"GroupName").getValueAsString();
7924 groupKey = aliasNodePair.second.getNode(
"GroupKey").getValueAsString();
7926 if(threadsLaunched >= numOfThreads)
7929 foundThreadIndex = -1;
7930 while(foundThreadIndex == -1)
7932 for(
int i = 0; i < numOfThreads; ++i)
7933 if(*(threadDone[i]))
7935 foundThreadIndex = i;
7938 if(foundThreadIndex == -1)
7940 __SUP_COUTT__ <<
"Waiting for available thread..." << __E__;
7944 threadsLaunched = numOfThreads - 1;
7946 __SUP_COUTT__ <<
"Starting load group thread... " << groupName <<
"("
7947 << groupKey <<
")" << __E__;
7948 *(threadDone[foundThreadIndex]) =
false;
7952 std::string theGroupName,
7954 std::shared_ptr<ots::GroupInfo> theGroupInfo,
7955 std::shared_ptr<std::atomic<bool>> theThreadDone) {
7965 sharedGroupInfoPtrs.back(),
7966 threadDone[foundThreadIndex])
7977 foundThreadIndex = -1;
7978 for(
int i = 0; i < numOfThreads; ++i)
7979 if(!*(threadDone[i]))
7981 foundThreadIndex = i;
7984 if(foundThreadIndex != -1)
7986 __SUP_COUTT__ <<
"Waiting for thread to finish... " << foundThreadIndex
7990 }
while(foundThreadIndex != -1);
7994 for(
auto& aliasNodePair : aliasNodePairs)
7996 groupName = aliasNodePair.second.getNode(
"GroupName").getValueAsString();
7997 groupKey = aliasNodePair.second.getNode(
"GroupKey").getValueAsString();
7999 if(groupKey != sharedGroupInfoPtrs[i]->getLatestKey().toString())
8001 __SUP_SS__ <<
"Error loading group information for the group alias '"
8002 << aliasNodePair.first <<
"' mapping to group '" << groupName
8003 <<
"(" << groupKey <<
")" << __E__;
8007 xmlOut.addTextElementToData(
"GroupAlias", aliasNodePair.first);
8008 xmlOut.addTextElementToData(
"GroupName", groupName);
8009 xmlOut.addTextElementToData(
8010 "GroupKey", sharedGroupInfoPtrs[i]->getLatestKey().toString());
8011 xmlOut.addTextElementToData(
8013 aliasNodePair.second.getNode(TableViewColumnInfo::COL_NAME_COMMENT)
8014 .getValueAsString());
8016 xmlOut.addTextElementToData(
8017 "GroupComment", sharedGroupInfoPtrs[i]->getLatestKeyGroupComment());
8018 xmlOut.addTextElementToData(
8019 "GroupAuthor", sharedGroupInfoPtrs[i]->getLatestKeyGroupAuthor());
8020 xmlOut.addTextElementToData(
8021 "GroupCreationTime",
8022 sharedGroupInfoPtrs[i]->getLatestKeyGroupCreationTime());
8023 xmlOut.addTextElementToData(
8024 "GroupType", sharedGroupInfoPtrs[i]->getLatestKeyGroupTypeString());
8043 void ConfigurationGUISupervisor::handleVersionAliasesXML(
HttpXmlDocument& xmlOut,
8047 std::map<std::string, TableVersion> activeVersions = cfgMgr->
getActiveVersions();
8049 std::string versionAliasesTableName =
8050 ConfigurationManager::VERSION_ALIASES_TABLE_NAME;
8051 if(activeVersions.find(versionAliasesTableName) == activeVersions.end())
8053 __SUP_SS__ <<
"Active version of VersionAliases missing!"
8054 <<
"Make sure you have a valid active Backbone Group." << __E__;
8055 xmlOut.addTextElementToData(
"Error", ss.str());
8058 __SUP_COUT__ <<
"activeVersions[\"" << versionAliasesTableName
8059 <<
"\"]=" << activeVersions[versionAliasesTableName] << __E__;
8060 xmlOut.addTextElementToData(
"VersionAliasesVersion",
8061 activeVersions[versionAliasesTableName].toString());
8063 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
8066 for(
auto& aliasNodePair : aliasNodePairs)
8070 xmlOut.addTextElementToData(
8072 aliasNodePair.second.getNode(
"VersionAlias").getValueAsString());
8073 xmlOut.addTextElementToData(
8074 "TableName", aliasNodePair.second.getNode(
"TableName").getValueAsString());
8075 xmlOut.addTextElementToData(
8076 "Version", aliasNodePair.second.getNode(
"Version").getValueAsString());
8077 xmlOut.addTextElementToData(
8079 aliasNodePair.second.getNode(TableViewColumnInfo::COL_NAME_COMMENT)
8080 .getValueAsString());
8090 void ConfigurationGUISupervisor::handleGetTableGroupTypeXML(
8094 std::string name, versionStr;
8095 auto c = tableList.find(
',', 0);
8098 while(c < tableList.length())
8101 name = tableList.substr(i, c - i);
8103 c = tableList.find(
',', i);
8104 if(c == std::string::npos)
8106 __SUP_SS__ <<
"Incomplete Table Name-Version pair!" << __E__;
8107 __SUP_COUT_ERR__ <<
"\n" << ss.str();
8108 xmlOut.addTextElementToData(
"Error", ss.str());
8112 versionStr = tableList.substr(i, c - i);
8114 c = tableList.find(
',', i);
8119 std::string groupTypeString =
"";
8125 xmlOut.addTextElementToData(
"TableGroupType", groupTypeString);
8127 catch(std::runtime_error& e)
8129 __SUP_SS__ <<
"Table group has invalid type! " << e.what() << __E__;
8130 __SUP_COUT__ <<
"\n" << ss.str();
8131 groupTypeString = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
8132 xmlOut.addTextElementToData(
"TableGroupType", groupTypeString);
8136 __SUP_SS__ <<
"Table group has invalid type! " << __E__;
8141 catch(
const std::exception& e)
8143 ss <<
"Exception message: " << e.what();
8148 __SUP_COUT__ <<
"\n" << ss.str();
8149 groupTypeString = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
8150 xmlOut.addTextElementToData(
"TableGroupType", groupTypeString);
8170 void ConfigurationGUISupervisor::handleTableGroupsXML(
HttpXmlDocument& xmlOut,
8174 __SUP_COUTT__ <<
"cfgMgr runtime=" << cfgMgr->runTimeSeconds() << __E__;
8180 if(!cfgMgr->getAllGroupInfo().size() ||
8181 cfgMgr->getAllGroupInfo().begin()->second.getLatestKeyGroupTypeString() ==
"" ||
8182 cfgMgr->getAllGroupInfo().begin()->second.getLatestKeyGroupTypeString() ==
8183 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN ||
8185 cfgMgr->getActiveGroupKey(ConfigurationManager::GroupType::CONTEXT_TYPE) !=
8186 TableGroupKey::INVALID &&
8187 cfgMgr->getAllGroupInfo().find(cfgMgr->getActiveGroupName(
8188 ConfigurationManager::GroupType::CONTEXT_TYPE)) !=
8189 cfgMgr->getAllGroupInfo().end() &&
8190 (cfgMgr->getAllGroupInfo()
8191 .at(cfgMgr->getActiveGroupName(
8192 ConfigurationManager::GroupType::CONTEXT_TYPE))
8193 .getLatestKeyGroupTypeString() ==
"" ||
8194 cfgMgr->getAllGroupInfo()
8195 .at(cfgMgr->getActiveGroupName(
8196 ConfigurationManager::GroupType::CONTEXT_TYPE))
8197 .getLatestKeyGroupTypeString() ==
8198 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN)) ||
8200 cfgMgr->getActiveGroupKey(
8201 ConfigurationManager::GroupType::CONFIGURATION_TYPE) !=
8202 TableGroupKey::INVALID &&
8203 cfgMgr->getAllGroupInfo().find(cfgMgr->getActiveGroupName(
8204 ConfigurationManager::GroupType::CONFIGURATION_TYPE)) !=
8205 cfgMgr->getAllGroupInfo().end() &&
8206 (cfgMgr->getAllGroupInfo()
8207 .at(cfgMgr->getActiveGroupName(
8208 ConfigurationManager::GroupType::CONFIGURATION_TYPE))
8209 .getLatestKeyGroupTypeString() ==
"" ||
8210 cfgMgr->getAllGroupInfo()
8211 .at(cfgMgr->getActiveGroupName(
8212 ConfigurationManager::GroupType::CONFIGURATION_TYPE))
8213 .getLatestKeyGroupTypeString() ==
8214 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN)))
8217 <<
"Group Info cache appears empty or stale. Attempting to regenerate..."
8227 const std::map<std::string, GroupInfo>& allGroupInfo = cfgMgr->getAllGroupInfo();
8229 __SUP_COUTT__ <<
"cfgMgr runtime=" << cfgMgr->runTimeSeconds() << __E__;
8231 std::string groupName;
8232 std::string groupString, groupTypeString, groupComment, groupCreationTime,
8234 for(
auto& groupInfo : allGroupInfo)
8236 groupName = groupInfo.first;
8241 if(groupInfo.second.getKeys().size() == 0)
8243 __SUP_COUT__ <<
"Group name '" << groupName
8244 <<
"' found, but no keys so ignoring." << __E__;
8248 xmlOut.dataSs_ <<
"<TableGroupName value='" << groupName <<
"'/>" << __E__;
8249 xmlOut.dataSs_ <<
"<TableGroupKey value='" << groupInfo.second.getLatestKey()
8253 xmlOut.dataSs_ <<
"<TableGroupType value='"
8254 << groupInfo.second.getLatestKeyGroupTypeString() <<
"'/>"
8256 xmlOut.dataSs_ <<
"<TableGroupComment value='"
8258 groupInfo.second.getLatestKeyGroupComment(),
8261 xmlOut.dataSs_ <<
"<TableGroupAuthor value='"
8262 << groupInfo.second.getLatestKeyGroupAuthor() <<
"'/>" << __E__;
8263 xmlOut.dataSs_ <<
"<TableGroupCreationTime value='"
8264 << groupInfo.second.getLatestKeyGroupCreationTime() <<
"'/>"
8270 xmlOut.dataSs_ <<
"<TableGroupMembers value=''>" << __E__;
8272 for(
auto& memberPair : groupInfo.second.getLatestKeyMemberMap())
8274 xmlOut.dataSs_ <<
"\t<MemberName value='" << memberPair.first <<
"'/>"
8276 xmlOut.dataSs_ <<
"\t<MemberVersion value='" << memberPair.second <<
"'/>"
8283 xmlOut.dataSs_ <<
"</TableGroupMembers>" << __E__;
8288 for(
auto& keyInSet : groupInfo.second.getKeys())
8290 if(keyInSet == groupInfo.second.getLatestKey())
8293 xmlOut.dataSs_ <<
"<TableGroupName value='" << groupName <<
"'/>" << __E__;
8294 xmlOut.dataSs_ <<
"<TableGroupKey value='" << keyInSet <<
"'/>" << __E__;
8299 bool loadingHistoricalInfo =
false;
8300 if(loadingHistoricalInfo)
8319 groupTypeString = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
8320 __SUP_COUT_WARN__ <<
"Failed to load group '" << groupName <<
"("
8322 <<
")' to extract group comment and type." << __E__;
8325 xmlOut.dataSs_ <<
"<TableGroupType value='" << groupTypeString <<
"'/>"
8327 xmlOut.dataSs_ <<
"<TableGroupComment value='"
8331 xmlOut.dataSs_ <<
"<TableGroupAuthor value='" << groupAuthor <<
"'/>"
8333 xmlOut.dataSs_ <<
"<TableGroupCreationTime value='" << groupCreationTime
8343 xmlOut.dataSs_ <<
"<TableGroupType value='"
8344 << groupInfo.second.getLatestKeyGroupTypeString() <<
"'/>"
8347 xmlOut.dataSs_ <<
"<TableGroupComment value='"
8350 xmlOut.dataSs_ <<
"<TableGroupAuthor value='"
8353 xmlOut.dataSs_ <<
"<TableGroupCreationTime value='"
8361 xmlOut.dataSs_ <<
"<TableGroupMembers/>" << __E__;
8366 __SUP_COUTT__ << groupName <<
" runtime=" << cfgMgr->runTimeSeconds() << __E__;
8368 __SUP_COUTT__ <<
"cfgMgr runtime=" << cfgMgr->runTimeSeconds() << __E__;
8390 void ConfigurationGUISupervisor::handleTablesXML(
HttpXmlDocument& xmlOut,
8392 const std::string& filterStartTimeStr,
8393 const std::string& filterEndTimeStr,
8394 const std::string& filterMode)
8396 time_t filterStartTime = 0;
8397 time_t filterEndTime = 0;
8398 if(filterStartTimeStr !=
"")
8402 filterStartTime =
static_cast<time_t
>(std::stoll(filterStartTimeStr));
8404 catch(
const std::exception& e)
8406 __SUP_SS__ <<
"Error parsing startTime parameter: " << e.what() << __E__;
8407 __SUP_COUT_ERR__ <<
"\n" << ss.str();
8408 xmlOut.addTextElementToData(
"Error", ss.str());
8412 if(filterEndTimeStr !=
"")
8416 filterEndTime =
static_cast<time_t
>(std::stoll(filterEndTimeStr));
8418 catch(
const std::exception& e)
8420 __SUP_SS__ <<
"Error parsing endTime parameter: " << e.what() << __E__;
8421 __SUP_COUT_ERR__ <<
"\n" << ss.str();
8422 xmlOut.addTextElementToData(
"Error", ss.str());
8426 if(filterStartTime != 0 && filterEndTime != 0 && filterStartTime > filterEndTime)
8428 __SUP_SS__ <<
"Invalid time range: startTime (" << filterStartTime
8429 <<
") must be <= endTime (" << filterEndTime <<
")." << __E__;
8432 if(filterMode !=
"created" && filterMode !=
"loaded")
8434 __SUP_SS__ <<
"Invalid filterMode parameter '" << filterMode
8435 <<
".' Expected 'created' or 'loaded.'" << __E__;
8436 __SUP_COUT_ERR__ <<
"\n" << ss.str();
8437 xmlOut.addTextElementToData(
"Error", ss.str());
8441 const auto diagStartTime = std::chrono::steady_clock::now();
8442 auto diagElapsedSec = [](
const std::chrono::steady_clock::time_point& start) {
8443 return std::chrono::duration<double>(std::chrono::steady_clock::now() - start)
8447 if(cfgMgr->getAllGroupInfo().size() == 0 || cfgMgr->
getActiveVersions().size() == 0)
8449 __SUP_COUT__ <<
"Table Info cache appears empty. Attempting to regenerate."
8457 __SUP_COUT__ <<
"getAllTableInfo() regenerate took "
8458 << diagElapsedSec(diagStartTime) <<
" s" << __E__;
8461 xercesc::DOMElement* parentEl;
8462 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
8465 std::set<std::string, StringMacros::IgnoreCaseCompareStruct> orderedTableSet;
8466 for(
const auto& tablePair : allTableInfo)
8467 orderedTableSet.emplace(tablePair.first);
8471 __SUP_COUT__ <<
"# of tables to consider: " << allTableInfo.size() << __E__;
8473 const auto diagAliasStartTime = std::chrono::steady_clock::now();
8474 std::map<std::string, std::map<std::string, TableVersion>> versionAliases =
8477 __SUP_COUT__ <<
"# of tables w/aliases: " << versionAliases.size() <<
" (took "
8478 << diagElapsedSec(diagAliasStartTime) <<
" s)" << __E__;
8480 if(filterStartTime != 0 && filterEndTime != 0 && filterMode ==
"created")
8485 const auto diagPreloadStartTime = std::chrono::steady_clock::now();
8487 __SUP_COUT__ <<
"Version creation time cache pre-warm took "
8488 << diagElapsedSec(diagPreloadStartTime) <<
" s" << __E__;
8492 size_t diagNumTablesFound = 0;
8493 size_t diagNumVersionsConsidered = 0;
8494 size_t diagNumVersionsMatched = 0;
8495 size_t diagNumTimeLookups = 0;
8496 double diagTimeLookupSec = 0;
8497 double diagSlowestTableSec = 0;
8498 std::string diagSlowestTableName =
"";
8499 size_t diagTableCount = 0;
8501 for(
const auto& orderedTableName : orderedTableSet)
8504 std::map<std::string, TableInfo>::const_iterator it =
8505 allTableInfo.find(orderedTableName);
8506 if(it == allTableInfo.end())
8508 __SS__ <<
"Impossible missing table in map '" << orderedTableName <<
"'"
8517 xmlOut.addTextElementToData(
"TableName", it->first);
8518 parentEl = xmlOut.addTextElementToData(
"TableVersions",
"");
8521 if(versionAliases.find(it->first) != versionAliases.end())
8522 for(
auto& aliasVersion : versionAliases[it->first])
8523 if(it->second.versions_.find(aliasVersion.second) !=
8524 it->second.versions_
8528 ConfigurationManager::ALIAS_VERSION_PREAMBLE + aliasVersion.first,
8536 auto vSpanToXML = [&diagNumVersionsConsidered,
8537 &diagNumVersionsMatched,
8538 &diagNumTimeLookups,
8539 &diagTimeLookupSec](
auto const& sortedKeys,
8542 const std::string& tableName,
8544 const time_t filterStartTime,
8545 const time_t filterEndTime,
8546 const std::string& filterMode) {
8548 size_t lo = -1, hi = -1;
8549 bool allVersionsFiltered =
true;
8550 for(
auto& keyInOrder : sortedKeys)
8553 if(keyInOrder.isScratchVersion())
8556 ++diagNumVersionsConsidered;
8558 if(filterStartTime != 0 && filterEndTime != 0)
8560 const auto diagLookupStartTime = std::chrono::steady_clock::now();
8569 time_t tableVersionTime =
8570 filterMode ==
"loaded"
8571 ? cfgMgr->getVersionLastAccessTime(tableName, keyInOrder)
8572 : cfgMgr->getVersionCreationTime(tableName, keyInOrder);
8574 ++diagNumTimeLookups;
8575 diagTimeLookupSec +=
8576 std::chrono::duration<double>(
8577 std::chrono::steady_clock::now() - diagLookupStartTime)
8580 if(tableVersionTime < filterStartTime ||
8581 tableVersionTime > filterEndTime)
8585 __COUTT__ <<
"Table '" << tableName <<
"' version v"
8586 << keyInOrder <<
" " << filterMode
8587 <<
" time is outside the filter range, so "
8593 catch(
const std::runtime_error&)
8595 ++diagNumTimeLookups;
8596 diagTimeLookupSec +=
8597 std::chrono::duration<double>(
8598 std::chrono::steady_clock::now() - diagLookupStartTime)
8600 __COUT__ <<
"Failed to get " << filterMode <<
" time for table '"
8601 << tableName <<
"' version v" << keyInOrder
8602 <<
", so skipping." << __E__;
8607 allVersionsFiltered =
false;
8608 ++diagNumVersionsMatched;
8610 if(lo ==
size_t(-1))
8612 hi = lo = keyInOrder.
version();
8615 else if(hi + 1 == keyInOrder.version())
8623 xmlOut.addNumberElementToParent(
"Version", lo, configEl);
8625 xmlOut.addTextElementToParent(
8627 "_" + std::to_string(lo) +
"_" + std::to_string(hi),
8629 hi = lo = keyInOrder.
version();
8632 if(lo !=
size_t(-1))
8635 xmlOut.addNumberElementToParent(
"Version", lo, configEl);
8637 xmlOut.addTextElementToParent(
8639 "_" + std::to_string(lo) +
"_" + std::to_string(hi),
8642 return allVersionsFiltered;
8645 const auto diagTableStartTime = std::chrono::steady_clock::now();
8646 if(vSpanToXML(it->second.versions_,
8654 filterStartTime != 0 && filterEndTime != 0)
8660 unsigned int childCount = xmlOut.getChildrenCount();
8663 xmlOut.removeDataElement(childCount - 1);
8664 xmlOut.removeDataElement(childCount - 2);
8668 ++diagNumTablesFound;
8671 double diagTableSec = diagElapsedSec(diagTableStartTime);
8672 if(diagTableSec > diagSlowestTableSec)
8674 diagSlowestTableSec = diagTableSec;
8675 diagSlowestTableName = it->first;
8677 if(diagTableSec > 1.0)
8678 __SUP_COUT__ <<
"Slow table filter: '" << it->first <<
"' with "
8679 << it->second.versions_.size() <<
" versions took "
8680 << diagTableSec <<
" s" << __E__;
8682 if(diagTableCount % 50 == 0)
8683 __SUP_COUT__ <<
"getTables filter progress: " << diagTableCount <<
" of "
8684 << orderedTableSet.size() <<
" tables in "
8685 << diagElapsedSec(diagStartTime) <<
" s (" << diagNumTimeLookups
8686 <<
" version time lookups taking " << diagTimeLookupSec
8687 <<
" s so far)" << __E__;
8692 xmlOut.addTextElementToData(
"NumberOfTablesConsidered",
8693 std::to_string(allTableInfo.size()));
8694 xmlOut.addTextElementToData(
"NumberOfTablesFound",
8695 std::to_string(diagNumTablesFound));
8696 xmlOut.addTextElementToData(
"NumberOfVersionsConsidered",
8697 std::to_string(diagNumVersionsConsidered));
8698 xmlOut.addTextElementToData(
"NumberOfVersionsFound",
8699 std::to_string(diagNumVersionsMatched));
8701 __SUP_COUT__ <<
"getTables filter summary: mode=" << filterMode <<
" range=["
8702 << filterStartTime <<
"," << filterEndTime <<
"]"
8703 <<
" tables considered=" << allTableInfo.size()
8704 <<
" found=" << diagNumTablesFound
8705 <<
"; versions considered=" << diagNumVersionsConsidered
8706 <<
" matched=" << diagNumVersionsMatched <<
"; " << diagNumTimeLookups
8707 <<
" version time lookups took " << diagTimeLookupSec
8708 <<
" s; slowest table '" << diagSlowestTableName <<
"' took "
8709 << diagSlowestTableSec <<
" s; total " << diagElapsedSec(diagStartTime)
8723 void ConfigurationGUISupervisor::handleGetArtdaqNodeRecordsXML(
8726 const std::string& modifiedTables,
8727 const std::string& tableGroup,
8729 const std::string& contextGroup,
8731 bool suppressMultiNode)
8733 __COUT__ <<
"Retrieving artdaq nodes..." << __E__;
8736 setupActiveTablesXML(xmlOut,
8743 if(contextGroup !=
"" && !contextGroupKey.
isInvalid())
8750 cfgMgr->
getTableByName(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME);
8754 __SUP_SS__ <<
"Failed to cast "
8755 << ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME
8756 <<
" to XDAQContextTable." << __E__;
8762 std::map<std::string ,
8763 std::map<std::string , std::vector<std::string >>>
8764 nodeTypeToObjectMap;
8765 std::map<std::string , std::string >
8768 std::vector<std::string > artdaqSupervisorInfo;
8770 std::string artdaqSupervisorName;
8771 const ARTDAQTableBase::ARTDAQInfo& info =
8773 nodeTypeToObjectMap,
8775 artdaqSupervisorInfo,
8778 if(artdaqSupervisorInfo.size() != 4 )
8780 __SUP_COUT__ <<
"No artdaq supervisor found." << __E__;
8784 __SUP_COUT__ <<
"========== "
8785 <<
"Found " << info.subsystems.size() <<
" subsystems." << __E__;
8787 unsigned int paramIndex = 0;
8789 auto parentEl = xmlOut.addTextElementToData(
"artdaqSupervisor",
8790 artdaqSupervisorInfo[paramIndex++]);
8792 std::string typeString =
"artdaqSupervisor";
8795 typeString +
"-status", artdaqSupervisorInfo[paramIndex++], parentEl);
8797 typeString +
"-contextAddress", artdaqSupervisorInfo[paramIndex++], parentEl);
8799 typeString +
"-contextPort", artdaqSupervisorInfo[paramIndex++], parentEl);
8801 for(
auto& subsystem : info.subsystems)
8803 typeString =
"subsystem";
8805 __SUP_COUT__ <<
"\t\t"
8806 <<
"Found " << typeString <<
" " << subsystem.first <<
" \t := '"
8807 << subsystem.second.label <<
"'" << __E__;
8811 typeString +
"-id", std::to_string(subsystem.first), parentEl);
8814 std::to_string(subsystem.second.sources.size()),
8819 std::to_string(subsystem.second.destination),
8824 __SUP_COUT__ <<
"========== "
8825 <<
"Found " << nodeTypeToObjectMap.size() <<
" process types." << __E__;
8827 for(
auto& nameTypePair : nodeTypeToObjectMap)
8829 typeString = nameTypePair.first;
8831 __SUP_COUT__ <<
"\t"
8832 <<
"Found " << nameTypePair.second.size() <<
" " << typeString
8835 for(
auto& artdaqNode : nameTypePair.second)
8837 __SUP_COUT__ <<
"\t\t"
8838 <<
"Found '" << artdaqNode.first <<
"' " << typeString << __E__;
8841 if(artdaqNode.second.size() < 2)
8843 __SUP_SS__ <<
"Impossible parameter size for node '" << artdaqNode.first
8844 <<
"' " << typeString <<
" - please notify admins!" << __E__;
8852 if(artdaqNode.second.size() > paramIndex)
8854 __SUP_COUTT__ <<
"\t\t\t"
8855 <<
"-multinode: " << artdaqNode.second[paramIndex] << __E__;
8857 typeString +
"-multinode", artdaqNode.second[paramIndex++], nodeEl);
8859 if(artdaqNode.second.size() > paramIndex)
8861 __SUP_COUTT__ <<
"\t\t\t"
8862 <<
"-nodefixedwidth: " << artdaqNode.second[paramIndex]
8865 artdaqNode.second[paramIndex++],
8868 if(artdaqNode.second.size() > paramIndex)
8870 __SUP_COUTT__ <<
"\t\t\t"
8871 <<
"-hostarray: " << artdaqNode.second[paramIndex] << __E__;
8873 typeString +
"-hostarray", artdaqNode.second[paramIndex++], nodeEl);
8875 if(artdaqNode.second.size() > paramIndex)
8877 __SUP_COUTT__ <<
"\t\t\t"
8878 <<
"-hostfixedwidth: " << artdaqNode.second[paramIndex]
8881 artdaqNode.second[paramIndex++],
8886 __SUP_COUTT__ <<
"\t\t\t"
8887 <<
"-status: " << artdaqNode.second[paramIndex] << __E__;
8889 typeString +
"-status", artdaqNode.second[paramIndex++], parentEl);
8890 __SUP_COUTT__ <<
"\t\t\t"
8891 <<
"-hostname: " << artdaqNode.second[paramIndex] << __E__;
8893 typeString +
"-hostname", artdaqNode.second[paramIndex++], parentEl);
8894 __SUP_COUTT__ <<
"\t\t\t"
8895 <<
"-subsystem: " << artdaqNode.second[paramIndex] << __E__;
8897 typeString +
"-subsystem", artdaqNode.second[paramIndex], parentEl);
8901 __SUP_COUT__ <<
"Done retrieving artdaq nodes." << __E__;
8912 void ConfigurationGUISupervisor::handleSaveArtdaqNodeRecordsXML(
8913 const std::string& nodeString,
8914 const std::string& subsystemString,
8917 const std::string& modifiedTables)
8919 __SUP_COUT__ <<
"Saving artdaq nodes..." << __E__;
8922 setupActiveTablesXML(
8923 xmlOut, cfgMgr,
"",
TableGroupKey(-1), modifiedTables,
false );
8926 std::map<std::string ,
8927 std::map<std::string , std::vector<std::string >>>
8928 nodeTypeToObjectMap;
8934 std::map<std::string , std::string >
8935 nodeTypeToStringMap;
8940 for(
auto& typePair : nodeTypeToStringMap)
8942 if(typePair.first ==
"")
8947 nodeTypeToObjectMap.emplace(
8949 std::map<std::string ,
8950 std::vector<std::string /*property*/>>()));
8952 std::map<std::string , std::string >
8953 nodeRecordToStringMap;
8956 typePair.second, nodeRecordToStringMap, {
';'}, {
'='});
8960 for(
auto& nodePair : nodeRecordToStringMap)
8962 if(nodePair.first ==
"")
8967 std::vector<std::string > nodePropertyVector;
8970 nodePair.second, nodePropertyVector, {
','});
8975 for(
unsigned int i = 0; i < nodePropertyVector.size(); ++i)
8980 nodePropertyVector[i] =
8984 nodeTypeToObjectMap[typePair.first].emplace(
8986 nodePropertyVector));
8992 std::map<std::string , std::string >
8999 std::map<std::string , std::string >
9000 tmpSubsystemObjectMap;
9002 subsystemString, tmpSubsystemObjectMap, {
';'}, {
':'});
9007 for(
auto& subsystemPair : tmpSubsystemObjectMap)
9012 subsystemObjectMap.emplace(
9019 cfgMgr, nodeTypeToObjectMap, subsystemObjectMap);
9021 __SUP_COUT__ <<
"Done saving artdaq nodes." << __E__;
9031 void ConfigurationGUISupervisor::handleLoadArtdaqNodeLayoutXML(
9035 const std::string& contextGroupName ,
9038 bool usingActiveGroups = (contextGroupName ==
"" || contextGroupKey.
isInvalid());
9041 const std::string& finalContextGroupName =
9043 ? cfgMgr->getActiveGroupName(ConfigurationManager::GroupType::CONTEXT_TYPE)
9047 ? cfgMgr->getActiveGroupKey(ConfigurationManager::GroupType::CONTEXT_TYPE)
9049 const std::string& finalConfigGroupName =
9050 cfgMgr->getActiveGroupName(ConfigurationManager::GroupType::CONFIGURATION_TYPE);
9052 cfgMgr->getActiveGroupKey(ConfigurationManager::GroupType::CONFIGURATION_TYPE);
9057 std::stringstream layoutPath;
9058 layoutPath << ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH << finalContextGroupName
9059 <<
"_" << finalContextGroupKey <<
"." << finalConfigGroupName <<
"_"
9060 << finalConfigGroupKey <<
".dat";
9062 fp = fopen(layoutPath.str().c_str(),
"r");
9065 __SUP_COUT__ <<
"Layout file not found for '" << finalContextGroupName <<
"("
9066 << finalContextGroupKey <<
") + " << finalConfigGroupName <<
"("
9067 << finalConfigGroupKey <<
")': " << layoutPath.
str() << __E__;
9071 __SUP_COUTV__(layoutPath.str());
9076 std::stringstream layoutPath;
9077 layoutPath << ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH << finalContextGroupName
9078 <<
"_" << finalContextGroupKey <<
".dat";
9079 __SUP_COUTV__(layoutPath.str());
9081 fp = fopen(layoutPath.str().c_str(),
"r");
9084 __SUP_COUT__ <<
"Layout file not found for '" << finalContextGroupName <<
"("
9085 << finalContextGroupKey <<
")': " << layoutPath.str() << __E__;
9089 __SUP_COUTV__(layoutPath.str());
9096 const size_t maxLineSz = 1000;
9097 char line[maxLineSz];
9098 if(!fgets(line, maxLineSz, fp))
9107 unsigned int rows, cols;
9109 sscanf(line,
"%u %u", &rows, &cols);
9111 __COUT__ <<
"Grid rows,cols = " << rows <<
"," << cols << __E__;
9113 xmlOut.addTextElementToData(
"grid-rows", std::to_string(rows));
9114 xmlOut.addTextElementToData(
"grid-cols", std::to_string(cols));
9117 char name[maxLineSz];
9118 char type[maxLineSz];
9120 while(fgets(line, maxLineSz, fp))
9123 sscanf(line,
"%s %s %u %u", type, name, &x, &y);
9125 xmlOut.addTextElementToData(
"node-type", type);
9126 xmlOut.addTextElementToData(
"node-name", name);
9127 xmlOut.addTextElementToData(
"node-x", std::to_string(x));
9128 xmlOut.addTextElementToData(
"node-y", std::to_string(y));
9142 void ConfigurationGUISupervisor::handleSaveArtdaqNodeLayoutXML(
9145 const std::string& layoutString,
9146 const std::string& contextGroupName,
9149 bool usingActiveGroups = (contextGroupName ==
"" || contextGroupKey.
isInvalid());
9151 const std::string& finalContextGroupName =
9153 ? cfgMgr->getActiveGroupName(ConfigurationManager::GroupType::CONTEXT_TYPE)
9157 ? cfgMgr->getActiveGroupKey(ConfigurationManager::GroupType::CONTEXT_TYPE)
9159 const std::string& finalConfigGroupName =
9160 cfgMgr->getActiveGroupName(ConfigurationManager::GroupType::CONFIGURATION_TYPE);
9162 cfgMgr->getActiveGroupKey(ConfigurationManager::GroupType::CONFIGURATION_TYPE);
9164 __SUP_COUTV__(layoutString);
9166 std::stringstream layoutPath;
9167 layoutPath << ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH << finalContextGroupName
9168 <<
"_" << finalContextGroupKey <<
"." << finalConfigGroupName <<
"_"
9169 << finalConfigGroupKey <<
".dat";
9170 __SUP_COUTV__(layoutPath.str());
9175 if(fields.size() < 2 || (fields.size() - 2) % 4 != 0)
9177 __SUP_SS__ <<
"Invalid layout string fields size of " << fields.size() << __E__;
9181 FILE* fp = fopen(layoutPath.str().c_str(),
"w");
9184 __SUP_SS__ <<
"Could not open layout file for writing for '"
9185 << finalContextGroupName <<
"(" << finalContextGroupKey <<
") + "
9186 << finalConfigGroupName <<
"(" << finalConfigGroupKey
9187 <<
")': " << layoutPath.
str() << __E__;
9194 fprintf(fp,
"%s %s\n", fields[0].c_str(), fields[1].c_str());
9197 for(
unsigned int i = 2; i < fields.size(); i += 4)
9200 fields[i + 0].c_str(),
9201 fields[i + 1].c_str(),
9202 fields[i + 2].c_str(),
9203 fields[i + 3].c_str());
9211 void ConfigurationGUISupervisor::handleOtherSubsystemActiveGroups(
9215 std::string targetSubsystem )
9221 cfgMgr->
getNode(ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE);
9224 for(
auto subsystem : children)
9226 __SUP_COUTV__(subsystem.first);
9230 std::string userPath =
9231 subsystem.second.getNode(
"SubsystemUserDataPath").getValue();
9232 __SUP_COUTV__(userPath);
9235 catch(
const std::runtime_error& e)
9237 __SUP_COUT__ <<
"Ignoring errors in handling other subsystem active groups "
9238 "(assuming the subsystem information map is not setup in "
9239 << ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE
9240 <<
") -- here is the error: \n"
9241 << e.what() << __E__;
9248 cfgMgr->
getNode(ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE);
9250 for(
auto subsystem : children)
9252 if(targetSubsystem !=
"" && targetSubsystem != subsystem.first)
9255 xercesc::DOMElement* parent =
9256 xmlOut.addTextElementToData(
"SubsystemName", subsystem.first);
9261 std::string filename, userDataPath;
9262 std::string username, hostname;
9264 std::map<std::string ,
9266 retMap = cfgMgr->getOtherSubsystemActiveTableGroups(
9267 subsystem.first, &userDataPath, &hostname, &username);
9269 for(
const auto& retPair : retMap)
9272 retPair.second.first,
9275 retPair.second.second.toString(),
9279 std::vector<std::string> filenameTypes = {
"Configured",
9283 "ActivatedBackbone",
9284 "ActivatedIterator"};
9286 std::vector<std::string> filenames = {
9287 ConfigurationManager::LAST_CONFIGURED_CONFIG_GROUP_FILE,
9288 ConfigurationManager::LAST_STARTED_CONFIG_GROUP_FILE,
9289 ConfigurationManager::LAST_ACTIVATED_CONFIG_GROUP_FILE,
9290 ConfigurationManager::LAST_ACTIVATED_CONTEXT_GROUP_FILE,
9291 ConfigurationManager::LAST_ACTIVATED_BACKBONE_GROUP_FILE,
9292 ConfigurationManager::LAST_ACTIVATED_ITERATE_GROUP_FILE};
9294 std::string userPath =
9295 subsystem.second.getNode(
"SubsystemUserDataPath").getValue();
9297 std::string cmdResult;
9298 for(
unsigned int i = 0; i < filenames.size(); ++i)
9300 filename = userDataPath +
"/ServiceData/RunControlData/" + filenames[i];
9301 __SUP_COUTV__(filename);
9303 std::string tmpSubsystemFilename =
9304 ConfigurationManager::LAST_TABLE_GROUP_SAVE_PATH +
"/" + filenames[i] +
9305 "." + subsystem.first;
9306 __SUP_COUTV__(tmpSubsystemFilename);
9308 if(splitPath.size() == 2)
9312 (
"rm " + tmpSubsystemFilename +
" 2>/dev/null; scp " + username +
9313 "@" + hostname +
":" + filename +
" " + tmpSubsystemFilename +
9314 " 2>&1; cat " + tmpSubsystemFilename +
" 2>&1")
9318 (
"rm " + tmpSubsystemFilename +
" 2>/dev/null; scp " + hostname +
9319 ":" + filename +
" " + tmpSubsystemFilename +
" 2>&1; cat " +
9320 tmpSubsystemFilename +
" 2>&1")
9323 else if(splitPath.size() == 1)
9326 " 2>/dev/null; cp " + filename +
" " +
9327 tmpSubsystemFilename +
" 2>&1; cat " +
9328 tmpSubsystemFilename +
" 2>&1")
9332 __SUP_COUTV__(cmdResult);
9333 std::string timeString;
9336 filenames[i] +
"." + subsystem.first, timeString);
9340 "Last" + filenameTypes[i] +
"GroupName", theGroup.first, parent);
9342 theGroup.second.toString(),
9345 "Last" + filenameTypes[i] +
"GroupTime", timeString, parent);
9350 catch(
const std::runtime_error& e)
9353 <<
"An error occurred handling subsystem active groups (Please check the "
9354 "subsystem user data path information map setup in the Context group table "
9355 << ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE
9356 <<
") -- here is the error: \n"
9357 << e.what() << __E__;
9363 void ConfigurationGUISupervisor::handleSearchFieldInGroupXML(
9366 const std::string& searchText,
9367 const bool activeGroupsOnly,
9368 const std::string& groupType,
9369 const std::string& optionGroups,
9370 const std::string& versionsToCheck)
9373 if(searchText.empty() || searchText.find_first_not_of(
" \t\r\n") == std::string::npos)
9375 __COUT_WARN__ <<
"searchText is empty or whitespace; aborting search." << __E__;
9376 xmlOut.addTextElementToData(
"Error",
"Search text must not be empty.");
9380 bool searchAllGroups =
false;
9381 if(optionGroups.size() == 0)
9383 __COUT__ <<
"No optionGroups specified, searching all groups of type "
9384 << groupType << __E__;
9385 searchAllGroups =
true;
9387 std::vector<std::string> optionGroupsList =
9390 const std::map<std::string, GroupInfo>& allGroupInfo = cfgMgr->getAllGroupInfo();
9392 int searchMinThreshold = 0;
9393 int searchMaxThreshold = 0;
9394 size_t dashPos = -1;
9397 if(versionsToCheck.empty())
9399 searchMaxThreshold = INT_MAX;
9401 else if(versionsToCheck.find(
'-') != std::string::npos)
9403 __COUT__ <<
"Parsing versionsToCheck for range: " << versionsToCheck << __E__;
9404 dashPos = versionsToCheck.find(
'-');
9409 std::string minStr = versionsToCheck.substr(0, dashPos);
9410 std::string maxStr = versionsToCheck.substr(dashPos + 1);
9412 searchMinThreshold = atoi(minStr.c_str());
9413 searchMaxThreshold = atoi(maxStr.c_str());
9416 else if(versionsToCheck !=
"")
9419 searchMinThreshold = atoi(versionsToCheck.c_str());
9420 searchMaxThreshold = INT_MAX;
9424 __COUT__ <<
"Unable to set min and max thresholds for versionsToCheck: "
9425 << versionsToCheck << __E__;
9426 xmlOut.addTextElementToData(
9428 "Unable to set min and max thresholds for versionsToCheck: " +
9431 __SUP_COUT__ <<
"versionsToCheck range: " << searchMinThreshold <<
" to "
9432 << searchMaxThreshold << __E__;
9434 auto parentEl = xmlOut.addTextElementToData(
"SearchResults",
"");
9436 for(
auto& groupInfo : allGroupInfo)
9438 __COUT__ <<
"Checking group: " << groupInfo.first
9439 <<
" group type : " << groupInfo.second.getLatestKeyGroupTypeString()
9442 if(groupInfo.second.getLatestKeyGroupTypeString() != groupType)
9446 if(!searchAllGroups &&
9447 std::find(optionGroupsList.begin(), optionGroupsList.end(), groupInfo.first) ==
9448 optionGroupsList.end())
9450 __COUT__ <<
"\tSkipping group not in optionGroups list." << __E__;
9454 std::set<
TableGroupKey > allGroupKeys = groupInfo.second.getKeys();
9456 std::vector<TableGroupKey> groupKeysVec(allGroupKeys.begin(), allGroupKeys.end());
9459 __COUT__ <<
"Group keys:" << groupKeysStr << __E__;
9464 std::string offsetStr = versionsToCheck.substr(1);
9466 atoi(offsetStr.c_str()) - 1;
9468 __SUP_COUT__ <<
"versionsToCheck offset from end: " << offset << __E__;
9471 if(groupKeysVec.size() > 0)
9474 groupKeysVec.size() - 1);
9475 int maxVersionNum = std::stoi(maxVersion.
toString());
9476 int minVersionNum = std::max(0, maxVersionNum - offset);
9478 searchMinThreshold = minVersionNum;
9479 searchMaxThreshold = maxVersionNum;
9481 __SUP_COUT__ <<
"Version range: " << searchMinThreshold <<
" to "
9482 << searchMaxThreshold << __E__;
9488 if(activeGroupsOnly)
9490 std::set<TableGroupKey> singleKeySet;
9491 singleKeySet.insert(groupInfo.second.getLatestKey());
9492 groupKeys = std::move(singleKeySet);
9495 groupKeys = std::move(allGroupKeys);
9497 for(
const auto& groupKey : groupKeys)
9499 __COUT__ <<
"\tProcessing group: " << groupInfo.first <<
" v" << groupKey
9502 if(!activeGroupsOnly &&
9503 (std::stoi(groupKey.toString()) < searchMinThreshold ||
9504 std::stoi(groupKey.toString()) > searchMaxThreshold))
9506 __COUT__ <<
"\tSkipping group version outside of versionsToCheck range."
9527 for(
auto& tablePair : memberMap)
9529 __COUT__ <<
"\t\tTable: " << tablePair.first <<
" v"
9530 << tablePair.second << __E__;
9536 tablePair.first, tablePair.second);
9539 const TableView& tableView = memberTable->getView();
9542 for(
unsigned int row = 0; row < tableView.getNumberOfRows();
9545 for(
unsigned int col = 0;
9546 col < tableView.getNumberOfColumns();
9549 const std::string& cellValue =
9550 tableView.getDataView()[row][col];
9553 if(cellValue.find(searchText) != std::string::npos)
9555 __COUT__ <<
"\t\t\tMatch found in " << tablePair.first
9556 <<
" v" << tablePair.second <<
" row " << row
9557 <<
" column " << col
9558 <<
" value: " << cellValue << __E__;
9562 groupInfo.first +
"/" + tablePair.first,
9565 "MatchRow", std::to_string(row), groupTableEl);
9568 tableView.getColumnInfo(col).getName(),
9571 groupKey.toString(),
9574 "MatchTableVersion",
9575 tablePair.second.toString(),
9581 catch(
const std::runtime_error& e)
9583 __COUT_WARN__ <<
"Failed to search table " << tablePair.first
9584 <<
" v" << tablePair.second <<
": " << e.what()
9589 catch(
const std::runtime_error& e)
9591 __COUT_WARN__ <<
"Failed to load group members for " << groupInfo.first
9592 <<
": " << e.what() << __E__;
9600 void ConfigurationGUISupervisor::handleSearchFieldInTableXML(
9603 const std::string& searchText,
9604 const std::string& tableName,
9605 const std::string& searchVersionToCheck,
9606 bool activeTablesOnly)
9609 if(searchText.empty() || searchText.find_first_not_of(
" \t\r\n") == std::string::npos)
9611 __COUT_WARN__ <<
"searchText is empty or whitespace; aborting search." << __E__;
9612 xmlOut.addTextElementToData(
"Error",
"Search text must not be empty.");
9616 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
9617 std::map<std::string, TableVersion> allActivePairs = cfgMgr->
getActiveVersions();
9619 int searchMinThreshold = 0;
9620 int searchMaxThreshold = 0;
9623 if(searchVersionToCheck.empty())
9625 searchMaxThreshold = INT_MAX;
9627 else if(searchVersionToCheck.find(
'-') != std::string::npos)
9629 size_t dashPos = searchVersionToCheck.find(
'-');
9634 std::string offsetStr = searchVersionToCheck.substr(1);
9636 atoi(offsetStr.c_str()) - 1;
9638 __SUP_COUT__ <<
"searchVersionToCheck offset from end: " << offset << __E__;
9641 if(allTableInfo.find(tableName) != allTableInfo.end())
9643 const TableInfo& tableInfo = allTableInfo.at(tableName);
9644 if(tableInfo.versions_.size() > 0)
9646 auto maxVersionIter = tableInfo.versions_.rbegin();
9647 int maxVersionNum = maxVersionIter->version();
9648 int minVersionNum = std::max(0, maxVersionNum - offset);
9650 searchMinThreshold = minVersionNum;
9651 searchMaxThreshold = maxVersionNum;
9653 __SUP_COUT__ <<
"Version range: " << searchMinThreshold <<
" to "
9654 << searchMaxThreshold << __E__;
9661 std::string minStr = searchVersionToCheck.substr(0, dashPos);
9662 std::string maxStr = searchVersionToCheck.substr(dashPos + 1);
9664 searchMinThreshold = atoi(minStr.c_str());
9665 searchMaxThreshold = atoi(maxStr.c_str());
9668 else if(searchVersionToCheck !=
"")
9671 searchMinThreshold = atoi(searchVersionToCheck.c_str());
9672 searchMaxThreshold = INT_MAX;
9676 __COUT__ <<
"Unable to set min and max thresholds for searchVersionToCheck: "
9677 << searchVersionToCheck << __E__;
9678 xmlOut.addTextElementToData(
9680 "Unable to set min and max thresholds for searchVersionToCheck: " +
9681 searchVersionToCheck);
9683 __SUP_COUT__ <<
"searchVersionToCheck range: " << searchMinThreshold <<
" to "
9684 << searchMaxThreshold << __E__;
9688 if(allTableInfo.find(tableName) == allTableInfo.end())
9690 __SUP_SS__ <<
"Table '" << tableName <<
"' not found." << __E__;
9691 xmlOut.addTextElementToData(
"Error", ss.str());
9695 const TableInfo& tableInfo = allTableInfo.at(tableName);
9696 __COUT__ <<
"tableInfo versions length " << tableInfo.versions_.size() << __E__;
9698 unsigned int matchCount = 0;
9699 bool allowIllegalColumns =
true;
9701 auto parentEl = xmlOut.addTextElementToData(
"SearchResults",
"");
9704 for(
const auto& version : tableInfo.versions_)
9708 auto activeIt = allActivePairs.find(tableName);
9709 bool isActiveVersion =
9710 (activeIt != allActivePairs.end() && activeIt->second == version);
9711 __COUT__ <<
"Active check for " << tableName <<
" v" << version <<
" => "
9712 << (isActiveVersion ?
"active" :
"inactive") << __E__;
9713 if(!isActiveVersion && activeTablesOnly)
9716 if((std::stoi(version.toString()) < searchMinThreshold ||
9717 std::stoi(version.toString()) > searchMaxThreshold) &&
9718 activeTablesOnly ==
false )
9720 __COUT__ <<
"Skipping version " << version <<
" out of range "
9721 << searchMinThreshold <<
" to " << searchMaxThreshold
9729 if(version.isInvalid())
9731 __COUT__ <<
"Using mock-up for table " << tableName <<
" version "
9732 << version << __E__;
9733 tableViewPtr = table->getMockupViewP();
9741 std::string localAccumulatedErrors =
"";
9747 allowIllegalColumns ,
9748 &localAccumulatedErrors,
9752 if(localAccumulatedErrors !=
"")
9753 xmlOut.addTextElementToData(
"Error", localAccumulatedErrors);
9755 catch(
const std::runtime_error& e)
9757 __COUT__ <<
"Error loading version " << version <<
" for table "
9758 << tableName <<
": " << e.what() << __E__;
9759 __SUP_COUT_WARN__ <<
"Could not load version " << version
9760 <<
" for table " << tableName <<
": "
9761 << e.what() << __E__;
9763 tableViewPtr = table->getMockupViewP();
9767 __COUT__ <<
"Getting table " << tableName <<
" version " << version
9771 for(
unsigned int row = 0; row < tableViewPtr->getNumberOfRows(); ++row)
9773 for(
unsigned int col = 0; col < tableViewPtr->getNumberOfColumns();
9776 const std::string& cellValue =
9777 tableViewPtr->getDataView()[row][col];
9779 if(cellValue.find(searchText) != std::string::npos)
9781 __COUT__ <<
"Match found in row " << row <<
" column " << col
9782 <<
" value: " << cellValue << __E__;
9784 "Match", cellValue, parentEl);
9786 "MatchVersion", version.toString(), matchEl);
9788 "MatchRow", std::to_string(row), matchEl);
9791 tableViewPtr->getColumnInfo(col).getName(),
9799 catch(
const std::runtime_error& e)
9801 __COUT__ <<
"Error searching in version " << version <<
" for table "
9802 << tableName <<
": " << e.what() << __E__;
9803 __SUP_COUT_WARN__ <<
"Could not load version " << version <<
" for table "
9804 << tableName <<
": " << e.what() << __E__;
9808 xmlOut.addTextElementToData(
"MatchCount", std::to_string(matchCount));
9810 catch(std::runtime_error& e)
9812 __SUP_SS__ <<
"Error searching in table '" << tableName <<
"'!\n\n " << e.what()
9814 __SUP_COUT_ERR__ << ss.str();
9815 xmlOut.addTextElementToData(
"Error", ss.str());
9819 __SUP_SS__ <<
"Error searching in table '" << tableName <<
"'!\n\n " << __E__;
9824 catch(
const std::exception& e)
9826 ss <<
"Exception message: " << e.what();
9831 __SUP_COUT_ERR__ << ss.str();
9832 xmlOut.addTextElementToData(
"Error", ss.str());
9838 void ConfigurationGUISupervisor::handleGroupDiff(
9841 const std::string& groupName,
9844 const std::string& diffGroupNameInput )
9850 std::string diffGroupName;
9853 __SUP_COUT__ <<
"Differencing group " << groupName <<
"(" << groupKey
9854 <<
") with the active group." << __E__;
9857 if(diffGroupNameInput ==
"")
9858 diffGroupName = groupName;
9860 diffGroupName = diffGroupNameInput;
9862 __SUP_COUT__ <<
"Differencing group " << groupName <<
"(" << groupKey
9863 <<
") with group " << diffGroupName <<
"(" << diffKey <<
")"
9869 std::map<std::string ,
TableVersion > memberMap, diffMemberMap;
9870 std::string groupType, accumulateErrors;
9871 std::stringstream diffReport;
9872 bool noDifference =
true;
9891 std::map<std::string , std::pair<std::string, TableGroupKey>>
9898 __SUP_COUTV__(groupType);
9900 if(activeGroups.find(groupType) == activeGroups.end() ||
9901 activeGroups.at(groupType).first ==
"" ||
9902 activeGroups.at(groupType).second.isInvalid())
9904 __SUP_SS__ <<
"Could not find an active group of type '" << groupType
9905 <<
".' Please check the expected active configuration groups "
9906 "for errors (going to 'System View' of the Config App may "
9912 __SUP_COUT__ <<
"active " << groupType <<
" group is "
9913 << activeGroups.at(groupType).first <<
"("
9914 << activeGroups.at(groupType).second <<
")" << __E__;
9916 diffReport <<
"This difference report is between " << groupType
9917 <<
" group <b>'" << groupName <<
"(" << groupKey <<
")'</b>"
9918 <<
" and active group <b>'" << activeGroups.at(groupType).first
9919 <<
"(" << activeGroups.at(groupType).second <<
")'</b>." << __E__;
9922 activeGroups.at(groupType).second,
9932 diffReport <<
"\n\n"
9933 <<
"'" << groupName <<
"(" << groupKey <<
")' has <b>"
9934 << memberMap.size() <<
" member tables</b>, and "
9935 <<
"'" << activeGroups.at(groupType).first <<
"("
9936 << activeGroups.at(groupType).second <<
")' has <b>"
9937 << diffMemberMap.size() <<
" member tables</b>." << __E__;
9941 diffReport <<
"This difference report is between group <b>'" << groupName
9942 <<
"(" << groupKey <<
")'</b>"
9943 <<
" and group <b>'" << diffGroupName <<
"(" << diffKey
9944 <<
")'</b>." << __E__;
9957 diffReport <<
"\n\n"
9958 <<
"'" << groupName <<
"(" << groupKey <<
")' has <b>"
9959 << memberMap.size() <<
" member tables</b>, and "
9960 <<
"'" << diffGroupName <<
"(" << diffKey <<
")' has <b>"
9961 << diffMemberMap.size() <<
" member tables</b>." << __E__;
9966 diffReport <<
"<INDENT><ol>";
9968 unsigned int tableDifferences = 0;
9970 for(
auto& member : memberMap)
9972 if(diffMemberMap.find(member.first) == diffMemberMap.end())
9974 diffReport <<
"\n\n<li>"
9975 <<
"Table <b>" << member.first <<
"-v" << member.second
9976 <<
"</b> not found in active group."
9977 <<
"</li>" << __E__;
9978 noDifference =
false;
9983 __SUP_COUTT__ <<
"Comparing " << member.first <<
"-v" << member.second
9984 <<
" ... " << member.first <<
"-v"
9985 << diffMemberMap.at(member.first) << __E__;
9987 if(member.second == diffMemberMap.at(member.first))
9990 diffReport <<
"\n\n<li>"
9991 <<
"Table <b>" << member.first <<
" v" << member.second
9992 <<
"</b> in " << groupName <<
"(" << groupKey <<
")' ...vs... "
9993 <<
" <b>v" << diffMemberMap.at(member.first) <<
"</b> in "
9994 << diffGroupName <<
"(" << diffKey <<
")':" << __E__;
9998 diffReport <<
"<ul>";
9999 std::map<std::string , std::vector<std::string >>
10001 if(!table->diffTwoVersions(member.second,
10002 diffMemberMap.at(member.first),
10007 noDifference =
false;
10008 ++tableDifferences;
10010 xmlOut.addTextElementToData(
"TableWithDiff", member.first);
10011 for(
auto& modifiedRecord : modifiedRecords)
10014 "RecordWithDiff", modifiedRecord.first, parentEl);
10015 for(
auto& modifiedColumn : modifiedRecord.second)
10017 "ColNameWithDiff", modifiedColumn, recordParentEl);
10020 diffReport <<
"</ul></li>";
10024 for(
auto& diffMember : diffMemberMap)
10026 if(memberMap.find(diffMember.first) == memberMap.end())
10029 diffReport <<
"\n\n<li>"
10030 <<
"Active Group Table <b>" << diffMember.first <<
"-v"
10031 << diffMember.second <<
"</b> not found in '" << groupName
10032 <<
"(" << groupKey <<
")'."
10033 <<
"</li>" << __E__;
10035 diffReport <<
"\n\n<li>" << diffGroupName <<
"(" << diffKey
10036 <<
") Table <b>" << diffMember.first <<
"-v"
10037 << diffMember.second <<
"</b> not found in '" << groupName
10038 <<
"(" << groupKey <<
")'."
10039 <<
"</li>" << __E__;
10041 noDifference =
false;
10042 ++tableDifferences;
10046 diffReport <<
"\n</ol></INDENT>";
10051 diffReport <<
"\n\nNo difference found between "
10052 <<
"<b>'" << groupName <<
"(" << groupKey
10053 <<
")'</b> and active group "
10054 <<
"<b>'" << activeGroups.at(groupType).first <<
"("
10055 << activeGroups.at(groupType).second <<
")'</b>." << __E__;
10057 diffReport <<
"\n\n<b>" << tableDifferences
10058 <<
"</b> member table differences identified between "
10059 <<
"<b>'" << groupName <<
"(" << groupKey
10060 <<
")'</b> and active group "
10061 <<
"<b>'" << activeGroups.at(groupType).first <<
"("
10062 << activeGroups.at(groupType).second <<
")'</b>." << __E__;
10067 diffReport <<
"\n\nNo difference found between "
10068 <<
"<b>'" << groupName <<
"(" << groupKey
10069 <<
")'</b> and group "
10070 <<
"<b>'" << diffGroupName <<
"(" << diffKey <<
")'</b>."
10073 diffReport <<
"\n\n<b>" << tableDifferences
10074 <<
"</b> member table differences identified between "
10075 <<
"<b>'" << groupName <<
"(" << groupKey
10076 <<
")'</b> and group "
10077 <<
"<b>'" << diffGroupName <<
"(" << diffKey <<
")'</b>."
10081 xmlOut.addTextElementToData(
"NoDifference", noDifference ?
"1" :
"0");
10082 xmlOut.addTextElementToData(
"DiffReport", diffReport.str());
10084 catch(
const std::runtime_error& e)
10086 __SUP_COUT_ERR__ <<
"Caught error while differencing group " << groupName <<
"("
10087 << groupKey <<
") with group " << diffGroupName <<
"(" << diffKey
10088 <<
")" << __E__ << e.what() << __E__;
10095 void ConfigurationGUISupervisor::handleTableDiff(
HttpXmlDocument& xmlOut,
10097 const std::string& tableName,
10101 __SUP_COUT__ <<
"Differencing tableName " << tableName <<
" v" << vA <<
" with v"
10111 std::string localAccumulatedErrors =
"";
10115 &localAccumulatedErrors,
10118 if(localAccumulatedErrors !=
"")
10119 xmlOut.addTextElementToData(
"Error", localAccumulatedErrors);
10121 catch(std::runtime_error& e)
10123 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version " << vA;
10124 ss <<
"\n\n...Here is why it failed:\n\n" << e.what() << __E__;
10125 __SUP_COUT_ERR__ <<
"\n" << ss.str();
10127 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
10131 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version: " << vA << __E__;
10136 catch(
const std::exception& e)
10138 ss <<
"Exception message: " << e.what();
10144 __SUP_COUT_ERR__ <<
"\n" << ss.str();
10145 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
10151 std::string localAccumulatedErrors =
"";
10155 &localAccumulatedErrors,
10158 if(localAccumulatedErrors !=
"")
10159 xmlOut.addTextElementToData(
"Error", localAccumulatedErrors);
10161 catch(std::runtime_error& e)
10163 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version " << vB;
10164 ss <<
"\n\n...Here is why it failed:\n\n" << e.what() << __E__;
10165 __SUP_COUT_ERR__ <<
"\n" << ss.str();
10167 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
10171 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version: " << vB << __E__;
10176 catch(
const std::exception& e)
10178 ss <<
"Exception message: " << e.what();
10184 __SUP_COUT_ERR__ <<
"\n" << ss.str();
10185 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
10188 bool noDifference =
true;
10189 std::stringstream diffReport;
10191 diffReport <<
"This difference report is between table " << tableName <<
" v" << vA
10192 <<
" and v" << vB <<
"</b>." << __E__;
10194 diffReport <<
"<INDENT>";
10195 diffReport <<
"<ul>";
10196 std::map<std::string , std::vector<std::string >>
10198 if(!table->diffTwoVersions(vA, vB, &diffReport))
10199 noDifference =
false;
10200 diffReport <<
"</ul></INDENT>";
10202 xmlOut.addTextElementToData(
"NoDifference", noDifference ?
"1" :
"0");
10203 xmlOut.addTextElementToData(
"DiffReport", diffReport.str());
10209 void ConfigurationGUISupervisor::testXDAQContext()
10213 __COUT_INFO__ <<
"Hello0!";
10215 __COUT_INFO__ <<
"Hello1!";
10217 __COUT_INFO__ <<
"Hello2!";
10219 __COUT_INFO__ <<
"Hello3!";
10225 __SUP_COUT_INFO__ <<
"Attempting test activation of the context group." << __E__;
10229 catch(
const std::runtime_error& e)
10232 <<
"The test activation of the context group failed. Ignoring error: \n"
10233 << e.what() << __E__;
10238 __SUP_COUT_WARN__ <<
"The test activation of the context group failed. Ignoring."
10243 __SUP_COUT_INFO__ <<
"Completed test activation of the context group." << __E__;
static void setAndActivateARTDAQSystem(ConfigurationManagerRW *cfgMgr, const std::map< std::string, std::map< std::string, std::vector< std::string >>> &nodeTypeToObjectMap, const std::map< std::string, std::string > &subsystemObjectMap)
static const ARTDAQInfo & getARTDAQSystem(ConfigurationManagerRW *cfgMgr, std::map< std::string, std::map< std::string, std::vector< std::string >>> &nodeTypeToObjectMap, std::map< std::string, std::string > &subsystemObjectMap, std::vector< std::string > &artdaqSupervisoInfo, bool suppressMultiNode=false)
static std::string postData(cgicc::Cgicc &cgi, const std::string &needle)
static std::string getData(cgicc::Cgicc &cgi, const std::string &needle)
virtual void forceSupervisorPropertyValues(void) override
override to force supervisor property values (and ignore user settings)
virtual void setSupervisorPropertyDefaults(void) override
ConfigurationGUISupervisor(xdaq::ApplicationStub *s)
static xdaq::Application * instantiate(xdaq::ApplicationStub *s)
TableVersion saveNewTable(const std::string &tableName, TableVersion temporaryVersion=TableVersion(), bool makeTemporary=false)
void testXDAQContext(void)
const GroupInfo & getGroupInfo(const std::string &groupName, bool attemptToReloadKeys=false)
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)
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 groupTypeToLoad=ConfigurationManager::LoadGroupType::ALL_TYPES, bool ignoreVersionTracking=false)
TableVersion copyViewToCurrentColumns(const std::string &tableName, TableVersion sourceVersion)
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)
void activateTableGroup(const std::string &tableGroupName, TableGroupKey tableGroupKey, std::string *accumulatedTreeErrors=0, std::string *groupTypeString=0)
void clearCachedVersions(const std::string &tableName)
const std::string & getUsername(void) const
std::map< std::string, std::map< std::string, TableVersion > > getVersionAliases(void) const
void eraseTemporaryVersion(const std::string &tableName, TableVersion targetVersion=TableVersion())
void preloadVersionCreationTimes(void)
static void loadTableGroupThread(ConfigurationManagerRW *cfgMgr, std::string groupName, ots::TableGroupKey groupKey, std::shared_ptr< ots::GroupInfo > theGroupInfo, std::shared_ptr< std::atomic< bool >> theThreadDone)
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
void copyTableGroupFromCache(const ConfigurationManager &cacheConfigMgr, const std::map< std::string, TableVersion > &groupMembers, const std::string &configGroupName="", const TableGroupKey &tableGroupKey=TableGroupKey(TableGroupKey::INVALID), bool doActivate=false, bool ignoreVersionTracking=false)
ConfigurationTree getNode(const std::string &nodeString, bool doNotThrowOnBrokenUIDLinks=false) const
TableBase * getVersionedTableByName(const std::string &tableName, TableVersion version, bool looseColumnMatching=false, std::string *accumulatedErrors=0, bool getRawData=false, bool touchLastAccessTime=true)
void init(std::string *accumulatedErrors=0, bool initForWriteAccess=false, std::string *accumulatedWarnings=0)
static const std::string & getTypeNameOfGroup(const std::map< std::string, TableVersion > &memberMap)
void destroyTableGroup(const std::string &theGroup="", bool onlyDeactivate=false)
std::vector< std::pair< std::string, ConfigurationTree > > getChildren(std::map< std::string, TableVersion > *memberMap=0, std::string *accumulatedTreeErrors=0) const
std::map< std::string, ConfigurationTree > getChildrenMap(std::map< std::string, TableVersion > *memberMap=0, std::string *accumulatedTreeErrors=0) const
static std::vector< std::map< std::string, std::string > > loadGroupHistory(const std::string &groupAction, const std::string &groupType, bool formatTime=false)
TableGroupKey loadConfigurationBackbone(void)
const TableBase * getTableByName(const std::string &configurationName) const
static std::pair< std::string, TableGroupKey > loadGroupNameAndKey(const std::string &fileName, std::string &returnedTimeString)
static void getConfigurationStatusXML(HttpXmlDocument &xmlOut, ConfigurationManagerRW *cfgMgr, const std::string &username)
static void handleGetTableGroupXML(HttpXmlDocument &xmlOut, ConfigurationManagerRW *cfgMgr, const std::string &groupName, TableGroupKey groupKey, bool ignoreWarnings=false, bool cacheOnly=false)
static TableVersion saveModifiedVersionXML(HttpXmlDocument &xmlOut, ConfigurationManagerRW *cfgMgr, const std::string &tableName, TableVersion originalVersion, bool makeTemporary, TableBase *config, TableVersion temporaryModifiedVersion, bool ignoreDuplicates=false, bool lookForEquivalent=false)
static void handleCreateTableXML(HttpXmlDocument &xmlOut, ConfigurationManagerRW *cfgMgr, const std::string &tableName, TableVersion version, bool makeTemporary, const std::string &data, const int &dataOffset, const std::string &author, const std::string &comment, bool sourceTableAsIs, bool lookForEquivalent)
static void handleCreateTableGroupXML(HttpXmlDocument &xmlOut, ConfigurationManagerRW *cfgMgr, const std::string &groupName, const std::string &configList, bool allowDuplicates=false, bool ignoreWarnings=false, const std::string &groupComment="", bool lookForEquivalent=false)
bool isUIDNode(void) const
const TableVersion & getTableVersion(void) const
bool isDisconnected(void) const
const std::string & getAuthor(void) const
const std::string & getComment(void) const
std::vector< std::string > getChildrenNames(bool byPriority=false, bool onlyStatusTrue=false) const
bool isEnabled(void) const
const std::string & getTableName(void) const
const unsigned int & getFieldRow(void) const
std::map< std::string, ConfigurationTree > getChildrenMap(std::map< std::string, std::string > filterMap=std::map< std::string, std::string >(), bool onlyStatusTrue=false) const
const std::string & getValueName(void) const
const std::string & getValueAsString(bool returnLinkTableValue=false) const
const std::string & getChildLinkIndex(void) const
const std::string & getDisconnectedTableName(void) 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
std::vector< std::string > getFixedChoices(void) const
bool isLinkNode(void) const
std::vector< ConfigurationTree::RecordField > getCommonFields(const std::vector< std::string > &recordList, const std::vector< std::string > &fieldAcceptList, const std::vector< std::string > &fieldRejectList, unsigned int depth=-1, bool autoSelectFilterFields=false) const
bool isValueNode(void) const
std::set< std::string > getUniqueValuesForField(const std::vector< std::string > &recordList, const std::string &fieldName, std::string *fieldGroupIDChildLinkIndex=0) const
const std::string & getValueType(void) const
bool isGroupLinkNode(void) const
const std::string & getFieldTableName(void) const
const std::string & getDisconnectedLinkID(void) const
const std::string & getParentTableName(void) const
bool isUIDLinkNode(void) const
const unsigned int & getFieldColumn(void) const
static std::string convertToCaps(std::string &str, bool isConfigName=false)
std::string toString(void) const
bool isInvalid(void) const
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
unsigned int version(void) const
static const std::string DATATYPE_NUMBER
static std::map< std::pair< std::string, std::string >, std::string > getAllDefaultsForGUI(void)
bool isChildLink(void) const
static const std::string & getDefaultDefaultValue(const std::string &type, const std::string &dataType)
static const std::string & getMaxDefaultValue(const std::string &dataType)
static const std::string & getMinDefaultValue(const std::string &dataType)
unsigned int findRow(unsigned int col, const T &value, unsigned int offsetRow=0, bool doNotThrow=false) const
bool isEntryInGroup(const unsigned int &row, const std::string &childLinkIndex, const std::string &groupNeedle) const
void setValueAsString(const std::string &value, unsigned int row, unsigned int col)
unsigned int getColStatus(void) const
unsigned int getLinkGroupIDColumn(const std::string &childLinkIndex) const
bool removeRowFromGroup(const unsigned int &row, const unsigned int &col, const std::string &groupID, bool deleteRowIfNoGroupLeft=false)
bool getChildLink(const unsigned int &col, bool &isGroup, std::pair< unsigned int, unsigned int > &linkPair) const
void addRowToGroup(const unsigned int &row, const unsigned int &col, const std::string &groupID)
std::string getValueAsString(unsigned int row, unsigned int col, bool convertEnvironmentVariables=true) const
void getValue(T &value, unsigned int row, unsigned int col, bool doConvertEnvironmentVariables=true) const
unsigned int getColUID(void) const
bool setURIEncodedValue(const std::string &value, const unsigned int &row, const unsigned int &col, const std::string &author="")
unsigned int findCol(const std::string &name) const
void setValue(const T &value, unsigned int row, unsigned int col)
void setURIEncodedComment(const std::string &uriComment)
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 extractContexts(ConfigurationManager *configManager)
xercesc::DOMElement * addTextElementToParent(const std::string &childName, const std::string &childText, xercesc::DOMElement *parent)
void INIT_MF(const char *name)
static std::string getTimestampString(const std::string &linuxTimeInSeconds)
static void getVectorFromString(const std::string &inputString, std::vector< std::string > &listToReturn, const std::set< char > &delimiter={',', '|', '&'}, const std::set< char > &whitespace={' ', '\t', '\n', '\r'}, std::vector< char > *listOfDelimiters=0, bool decodeURIComponents=false)
static std::string exec(const char *cmd)
static std::string setToString(const std::set< T > &setToReturn, const std::string &delimeter=", ")
static std::string escapeString(std::string inString, bool allowWhiteSpace=false, bool forHtml=false)
static std::string vectorToString(const std::vector< T > &setToReturn, const std::string &delimeter=", ")
static std::string convertEnvironmentVariables(const std::string &data)
static bool isNumber(const std::string &stringToCheck)
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'})
static std::string decodeURIComponent(const std::string &data)