1 #include "otsdaq-utilities/ConfigurationGUI/ConfigurationGUISupervisor.h"
3 #include "otsdaq/CgiDataUtilities/CgiDataUtilities.h"
4 #include "otsdaq/Macros/CoutMacros.h"
5 #include "otsdaq/MessageFacility/MessageFacility.h"
6 #include "otsdaq/TablePlugins/IterateTable.h"
7 #include "otsdaq/XmlUtilities/HttpXmlDocument.h"
9 #include <boost/stacktrace.hpp>
11 #include "otsdaq/GatewaySupervisor/GatewaySupervisor.h"
12 #include "otsdaq/TablePlugins/ARTDAQTableBase/ARTDAQTableBase.h"
13 #include "otsdaq/TablePlugins/XDAQContextTable/XDAQContextTable.h"
15 #include <xdaq/NamespaceURI.h>
24 #define __MF_SUBJECT__ "CfgGUI"
26 #define TABLE_INFO_PATH std::string(__ENV__("TABLE_INFO_PATH")) + "/"
27 #define TABLE_INFO_EXT std::string("Info.xml")
43 __SUP_COUT__ <<
"Constructor started." << __E__;
48 mkdir(((std::string)ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH).c_str(), 0755);
51 __SUP_COUT__ <<
"Constructor complete." << __E__;
55 ConfigurationGUISupervisor::~ConfigurationGUISupervisor(
void) { destroy(); }
58 void ConfigurationGUISupervisor::init(
void)
60 __SUP_COUT__ <<
"Initializing..." << __E__;
64 __SUP_COUT__ <<
"Activating saved context, which may prepare for normal mode..."
69 __SUP_COUT__ <<
"Done with test context." << __E__;
73 __COUT_WARN__ <<
"Failed test context group activation. otsdaq, in Normal mode, "
74 "will not launch when this test fails. "
75 <<
"Check the active context group from within Wizard Mode."
80 refreshUserSession(
"" , 1);
83 if(CorePropertySupervisorBase::allSupervisorInfo_.isWizardMode())
86 <<
"After successful Config GUI init, marking alive for wiz mode!" << __E__;
87 CorePropertySupervisorBase::
93 void ConfigurationGUISupervisor::destroy(
void)
95 __SUP_COUT__ <<
"Destructing..." << __E__;
98 for(std::map<std::string, ConfigurationManagerRW*>::iterator it =
99 userConfigurationManagers_.begin();
100 it != userConfigurationManagers_.end();
106 userConfigurationManagers_.clear();
108 if(ConfigurationInterface::getInstance() !=
nullptr)
109 delete ConfigurationInterface::getInstance();
114 void ConfigurationGUISupervisor::defaultPage(xgi::Input* in, xgi::Output* out)
116 cgicc::Cgicc cgiIn(in);
117 std::string configWindowName =
119 if(configWindowName ==
"tableEditor")
120 *out <<
"<!DOCTYPE HTML><html lang='en'><frameset col='100%' row='100%'><frame "
121 "src='/WebPath/html/ConfigurationTableEditor.html?urn="
122 << this->getApplicationDescriptor()->getLocalId() <<
"'></frameset></html>";
123 if(configWindowName ==
"iterate")
124 *out <<
"<!DOCTYPE HTML><html lang='en'><frameset col='100%' row='100%'><frame "
125 "src='/WebPath/html/Iterate.html?urn="
126 << this->getApplicationDescriptor()->getLocalId() <<
"'></frameset></html>";
128 *out <<
"<!DOCTYPE HTML><html lang='en'><frameset col='100%' row='100%'><frame "
129 "src='/WebPath/html/ConfigurationGUI.html?urn="
130 << this->getApplicationDescriptor()->getLocalId() <<
"'></frameset></html>";
138 CorePropertySupervisorBase::setSupervisorProperty(
139 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.UserPermissionsThreshold,
140 "*=10 | deleteTreeNodeRecords=255 | saveTableInfo=255 | "
141 "deleteTableInfo=255");
143 CorePropertySupervisorBase::setSupervisorProperty(
144 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.RequireUserLockRequestTypes,
148 CorePropertySupervisorBase::setSupervisorProperty(
149 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.AutomatedRequestTypes,
"get*");
157 CorePropertySupervisorBase::addSupervisorProperty(
158 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.AutomatedRequestTypes,
159 "getActiveTableGroups");
162 CorePropertySupervisorBase::setSupervisorProperty(
163 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.CheckUserLockRequestTypes,
168 void ConfigurationGUISupervisor::request(
const std::string& requestType,
171 const WebUsers::RequestUserInfo& userInfo)
176 __COUTTV__(requestType);
247 refreshUserSession(userInfo.username_, (refresh ==
"1"));
248 __COUTTV__(userInfo.username_);
254 const std::set<TableGroupKey>& sortedKeys = groupInfo.getKeys();
255 __COUTTV__(sortedKeys.size());
258 if(requestType ==
"saveTableInfo")
260 std::string tableName =
262 std::string columnCSV =
264 std::string allowOverwrite =
266 std::string tableDescription =
268 std::string columnChoicesCSV =
271 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
272 __SUP_COUT__ <<
"columnCSV: " << columnCSV << __E__;
273 __SUP_COUT__ <<
"tableDescription: " << tableDescription << __E__;
274 __SUP_COUT__ <<
"columnChoicesCSV: " << columnChoicesCSV << __E__;
275 __SUP_COUT__ <<
"allowOverwrite: " << allowOverwrite << __E__;
277 if(!allSupervisorInfo_.isWizardMode())
279 __SUP_SS__ <<
"Improper permissions for saving table info." << __E__;
280 xmlOut.addTextElementToData(
"Error", ss.str());
283 handleSaveTableInfoXML(xmlOut,
289 allowOverwrite ==
"1");
291 else if(requestType ==
"deleteTableInfo")
293 std::string tableName =
295 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
296 handleDeleteTableInfoXML(xmlOut, cfgMgr, tableName);
298 else if(requestType ==
"gatewayLaunchOTS" || requestType ==
"gatewayLaunchWiz" ||
299 requestType ==
"flattenToSystemAliases")
302 __SUP_COUT_WARN__ << requestType <<
" command received! " << __E__;
303 __COUT_WARN__ << requestType <<
" command received! " << __E__;
306 __SUP_COUT_INFO__ <<
"Launching " << requestType <<
"... " << __E__;
308 __SUP_COUT__ <<
"Extracting target context hostnames... " << __E__;
309 std::vector<std::string> hostnames;
312 if(requestType ==
"flattenToSystemAliases" &&
313 CorePropertySupervisorBase::allSupervisorInfo_.isWizardMode())
315 hostnames.push_back(__ENV__(
"OTS_CONFIGURATION_WIZARD_SUPERVISOR_SERVER"));
316 __SUP_COUT__ <<
"hostname = " << hostnames.back() << __E__;
327 auto contexts = contextTable->getContexts();
329 for(
const auto& context : contexts)
336 for(i = 0; i < context.address_.size(); ++i)
337 if(context.address_[i] ==
'/')
339 hostnames.push_back(context.address_.substr(j));
340 __SUP_COUT__ <<
"hostname = " << hostnames.back() << __E__;
345 __SUP_SS__ <<
"The Configuration Manager could not be initialized to "
352 catch(
const std::exception& e)
354 ss <<
"Exception message: " << e.what();
360 __SUP_COUT_ERR__ <<
"\n" << ss.str();
365 if(hostnames.size() == 0)
367 __SUP_SS__ <<
"No hostnames found to launch command '" + requestType +
368 "'... Is there a valid Context group activated?"
370 __SUP_COUT_ERR__ <<
"\n" << ss.str();
372 xmlOut.addTextElementToData(
"Error", ss.str());
375 for(
const auto& hostname : hostnames)
377 std::string fn = (std::string(__ENV__(
"SERVICE_DATA_PATH")) +
378 "/StartOTS_action_" + hostname +
".cmd");
379 FILE* fp = fopen(fn.c_str(),
"w");
382 if(requestType ==
"gatewayLaunchOTS")
383 fprintf(fp,
"LAUNCH_OTS");
384 else if(requestType ==
"gatewayLaunchWiz")
385 fprintf(fp,
"LAUNCH_WIZ");
386 else if(requestType ==
"flattenToSystemAliases")
388 fprintf(fp,
"FLATTEN_TO_SYSTEM_ALIASES");
396 __SUP_COUT_ERR__ <<
"Unable to open command file: " << fn << __E__;
399 else if(requestType ==
"versionTracking" || requestType ==
"getVersionTracking")
402 if(requestType ==
"getVersionTracking")
406 __SUP_COUT__ <<
"type: " << type << __E__;
409 xmlOut.addTextElementToData(
410 "versionTrackingStatus",
411 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
412 else if(type ==
"ON")
414 ConfigurationInterface::setVersionTrackingEnabled(
true);
415 xmlOut.addTextElementToData(
416 "versionTrackingStatus",
417 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
419 else if(type ==
"OFF")
421 ConfigurationInterface::setVersionTrackingEnabled(
false);
422 xmlOut.addTextElementToData(
423 "versionTrackingStatus",
424 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
427 else if(requestType ==
"getColumnTypes")
430 std::vector<std::string> allTypes = TableViewColumnInfo::getAllTypesForGUI();
431 std::vector<std::string> allDataTypes =
432 TableViewColumnInfo::getAllDataTypesForGUI();
433 std::map<std::pair<std::string, std::string>, std::string> allDefaults =
436 for(
const auto& type : allTypes)
437 xmlOut.addTextElementToData(
"columnTypeForGUI", type);
438 for(
const auto& dataType : allDataTypes)
439 xmlOut.addTextElementToData(
"columnDataTypeForGUI", dataType);
441 for(
const auto& colDefault : allDefaults)
443 xmlOut.addTextElementToData(
"columnDefaultDataType", colDefault.first.first);
444 xmlOut.addTextElementToData(
"columnDefaultTypeFilter",
445 colDefault.first.second);
446 xmlOut.addTextElementToData(
"columnDefaultValue", colDefault.second);
450 else if(requestType ==
"getGroupAliases")
455 1 == CgiDataUtilities::getDataAsInt(cgiIn,
"reloadActiveGroups");
457 __SUP_COUT__ <<
"reloadActive: " << reloadActive << __E__;
465 catch(std::runtime_error& e)
467 __SUP_SS__ << (
"Error loading active groups!\n\n" + std::string(e.what()))
469 __SUP_COUT_ERR__ <<
"\n" << ss.str();
470 xmlOut.addTextElementToData(
"Error", ss.str());
474 __SUP_SS__ << (
"Error loading active groups!\n\n") << __E__;
479 catch(
const std::exception& e)
481 ss <<
"Exception message: " << e.what();
486 __SUP_COUT_ERR__ <<
"\n" << ss.str();
487 xmlOut.addTextElementToData(
"Error", ss.str());
491 handleGroupAliasesXML(xmlOut, cfgMgr);
493 else if(requestType ==
"setGroupAliasInActiveBackbone")
495 std::string groupAliasCSV =
497 std::string groupNameCSV =
499 std::string groupKeyCSV =
502 __SUP_COUTV__(groupAliasCSV);
503 __SUP_COUTV__(groupNameCSV);
504 __SUP_COUTV__(groupKeyCSV);
506 handleSetGroupAliasInBackboneXML(
507 xmlOut, cfgMgr, groupAliasCSV, groupNameCSV, groupKeyCSV, userInfo.username_);
509 else if(requestType ==
"setTableAliasInActiveBackbone")
511 std::string tableAlias =
513 std::string tableName =
517 __SUP_COUT__ <<
"tableAlias: " << tableAlias << __E__;
518 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
519 __SUP_COUT__ <<
"version: " << version << __E__;
521 handleSetTableAliasInBackboneXML(xmlOut,
528 else if(requestType ==
"setAliasOfGroupMembers")
530 std::string versionAlias =
532 std::string groupName =
536 __SUP_COUT__ <<
"versionAlias: " << versionAlias << __E__;
537 __SUP_COUT__ <<
"groupName: " << groupName << __E__;
538 __SUP_COUT__ <<
"groupKey: " << groupKey << __E__;
540 handleAliasGroupMembersInBackboneXML(xmlOut,
547 else if(requestType ==
"getVersionAliases")
549 handleVersionAliasesXML(xmlOut, cfgMgr);
551 else if(requestType ==
"getTableGroups")
553 bool doNotReturnMembers =
554 CgiDataUtilities::getDataAsInt(cgiIn,
"doNotReturnMembers") == 1
558 __SUP_COUT__ <<
"doNotReturnMembers: " << doNotReturnMembers << __E__;
559 handleTableGroupsXML(xmlOut, cfgMgr, !doNotReturnMembers);
561 else if(requestType ==
"getTableGroupType")
563 std::string tableList =
565 __SUP_COUT__ <<
"tableList: " << tableList << __E__;
567 handleGetTableGroupTypeXML(xmlOut, cfgMgr, tableList);
569 else if(requestType ==
"getTables")
571 handleTablesXML(xmlOut, cfgMgr);
573 else if(requestType ==
"getContextMemberNames")
575 std::set<std::string> members = cfgMgr->getFixedContextMemberNames();
577 for(
auto& member : members)
578 xmlOut.addTextElementToData(
"ContextMember", member);
580 else if(requestType ==
"getBackboneMemberNames")
582 std::set<std::string> members = cfgMgr->getBackboneMemberNames();
584 for(
auto& member : members)
585 xmlOut.addTextElementToData(
"BackboneMember", member);
587 else if(requestType ==
"getIterateMemberNames")
589 std::set<std::string> members = cfgMgr->getIterateMemberNames();
591 for(
auto& member : members)
592 xmlOut.addTextElementToData(
"IterateMember", member);
594 else if(requestType ==
"getSpecificTableGroup")
596 std::string groupName =
600 __SUP_COUT__ <<
"groupName: " << groupName << __E__;
601 __SUP_COUT__ <<
"groupKey: " << groupKey << __E__;
606 else if(requestType ==
"saveNewTableGroup")
608 std::string groupName =
610 bool ignoreWarnings =
611 CgiDataUtilities::getDataAsInt(cgiIn,
"ignoreWarnings");
612 bool allowDuplicates =
613 CgiDataUtilities::getDataAsInt(cgiIn,
"allowDuplicates");
614 bool lookForEquivalent =
615 CgiDataUtilities::getDataAsInt(cgiIn,
"lookForEquivalent");
616 std::string tableList =
618 std::string comment =
621 __SUP_COUT__ <<
"saveNewTableGroup: " << groupName << __E__;
622 __SUP_COUT__ <<
"tableList: " << tableList << __E__;
623 __SUP_COUT__ <<
"ignoreWarnings: " << ignoreWarnings << __E__;
624 __SUP_COUT__ <<
"allowDuplicates: " << allowDuplicates << __E__;
625 __SUP_COUT__ <<
"lookForEquivalent: " << lookForEquivalent << __E__;
626 __SUP_COUT__ <<
"comment: " << comment << __E__;
637 else if(requestType ==
"getSpecificTable")
639 std::string tableName =
642 int dataOffset = CgiDataUtilities::getDataAsInt(cgiIn,
"dataOffset");
643 int chunkSize = CgiDataUtilities::getDataAsInt(
646 bool descriptionOnly = CgiDataUtilities::getDataAsInt(
647 cgiIn,
"descriptionOnly");
648 bool allowIllegalColumns =
649 CgiDataUtilities::getDataAsInt(cgiIn,
"allowIllegalColumns");
650 bool rawData = CgiDataUtilities::getDataAsInt(cgiIn,
"rawData");
652 __SUP_COUT__ <<
"getSpecificTable: " << tableName <<
" versionStr: " << versionStr
653 <<
" chunkSize: " << chunkSize <<
" dataOffset: " << dataOffset
654 <<
" descriptionOnly: " << descriptionOnly
655 <<
" allowIllegalColumns: " << allowIllegalColumns
656 <<
" rawData: " << rawData << __E__;
659 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
661 if(allTableInfo.find(tableName) != allTableInfo.end())
663 if(versionStr ==
"" &&
664 allTableInfo.at(tableName).versions_.size())
667 auto it = allTableInfo.at(tableName).versions_.rbegin();
668 if(it->isScratchVersion())
672 else if(versionStr.find(ConfigurationManager::ALIAS_VERSION_PREAMBLE) == 0)
675 std::map<std::string ,
679 std::string versionAlias;
680 versionAlias = versionStr.substr(
681 ConfigurationManager::ALIAS_VERSION_PREAMBLE.size());
692 if(versionAliases.find(tableName) != versionAliases.end() &&
693 versionAliases[tableName].find(versionAlias) !=
694 versionAliases[tableName].end())
696 version = versionAliases[tableName][versionAlias];
697 __SUP_COUT__ <<
"version alias translated to: " << version << __E__;
702 << versionStr.substr(
703 ConfigurationManager::ALIAS_VERSION_PREAMBLE.size())
704 <<
"'was not found in active version aliases!" << __E__;
707 version = atoi(versionStr.c_str());
710 __SUP_COUT__ <<
"version: " << version << __E__;
712 handleGetTableXML(xmlOut,
720 xmlOut.addTextElementToData(
"DefaultRowValue", userInfo.username_);
722 else if(requestType ==
"saveSpecificTable")
724 std::string tableName =
726 int version = CgiDataUtilities::getDataAsInt(cgiIn,
"version");
727 int dataOffset = CgiDataUtilities::getDataAsInt(cgiIn,
"dataOffset");
728 bool sourceTableAsIs =
729 CgiDataUtilities::getDataAsInt(cgiIn,
"sourceTableAsIs");
730 bool lookForEquivalent =
731 CgiDataUtilities::getDataAsInt(cgiIn,
"lookForEquivalent");
732 int temporary = CgiDataUtilities::getDataAsInt(cgiIn,
"temporary");
733 std::string comment =
740 __SUP_COUT__ <<
"tableName: " << tableName <<
" version: " << version
741 <<
" temporary: " << temporary <<
" dataOffset: " << dataOffset
743 __SUP_COUT__ <<
"comment: " << comment << __E__;
744 __SUP_COUT__ <<
"data: " << data << __E__;
745 __SUP_COUT__ <<
"sourceTableAsIs: " << sourceTableAsIs << __E__;
746 __SUP_COUT__ <<
"lookForEquivalent: " << lookForEquivalent << __E__;
760 else if(requestType ==
"clearTableTemporaryVersions")
762 std::string tableName =
764 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
770 catch(std::runtime_error& e)
772 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
773 xmlOut.addTextElementToData(
774 "Error",
"Error clearing temporary views!\n " + std::string(e.what()));
778 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
779 xmlOut.addTextElementToData(
"Error",
"Error clearing temporary views! ");
782 else if(requestType ==
"clearTableCachedVersions")
784 std::string tableName =
786 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
797 catch(std::runtime_error& e)
799 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
800 xmlOut.addTextElementToData(
801 "Error",
"Error clearing cached views!\n " + std::string(e.what()));
805 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
806 xmlOut.addTextElementToData(
"Error",
"Error clearing cached views! ");
809 else if(requestType ==
"getGroupHistory")
816 __SUP_COUTV__(groupAction);
817 __SUP_COUTV__(groupType);
819 std::vector<std::map<std::string ,
822 groupAction, groupType,
true );
824 for(
const auto& group : groups)
826 auto parentEl = xmlOut.addTextElementToData(
827 "GroupHistoryEntry",
"");
828 for(
const auto& field : group)
832 else if(requestType ==
"getTreeView")
839 int depth = CgiDataUtilities::getDataAsInt(cgiIn,
"depth");
840 bool hideStatusFalse = CgiDataUtilities::getDataAsInt(cgiIn,
"hideStatusFalse");
844 __SUP_COUTT__ <<
"tableGroup: " << tableGroup << __E__;
845 __SUP_COUTT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
846 __SUP_COUTT__ <<
"startPath: " << startPath << __E__;
847 __SUP_COUTT__ <<
"depth: " << depth << __E__;
848 __SUP_COUTT__ <<
"hideStatusFalse: " << hideStatusFalse << __E__;
849 __SUP_COUTT__ <<
"modifiedTables: " << modifiedTables << __E__;
850 __SUP_COUTT__ <<
"filterList: " << filterList << __E__;
852 handleFillTreeViewXML(xmlOut,
864 else if(requestType ==
"getTreeNodeCommonFields")
872 int depth = CgiDataUtilities::getDataAsInt(cgiIn,
"depth");
874 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
875 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
876 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
877 __SUP_COUT__ <<
"depth: " << depth << __E__;
880 __SUP_COUT__ <<
"fieldList: " << fieldList << __E__;
881 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
882 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
884 handleFillTreeNodeCommonFieldsXML(xmlOut,
894 else if(requestType ==
"getUniqueFieldValuesForRecords")
903 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
904 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
905 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
906 __SUP_COUT__ <<
"fieldList: " << fieldList << __E__;
907 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
908 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
910 handleFillUniqueFieldValuesForRecordsXML(xmlOut,
919 else if(requestType ==
"getTreeNodeFieldValues")
928 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
929 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
930 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
931 __SUP_COUT__ <<
"fieldList: " << fieldList << __E__;
932 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
933 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
935 handleFillGetTreeNodeFieldValuesXML(xmlOut,
944 else if(requestType ==
"setTreeNodeFieldValues")
954 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
955 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
956 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
957 __SUP_COUT__ <<
"fieldList: " << fieldList << __E__;
958 __SUP_COUT__ <<
"valueList: " << valueList << __E__;
959 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
960 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
962 handleFillSetTreeNodeFieldValuesXML(xmlOut,
973 else if(requestType ==
"addTreeNodeRecords")
981 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
982 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
983 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
984 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
985 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
987 handleFillCreateTreeNodeRecordsXML(xmlOut,
996 else if(requestType ==
"deleteTreeNodeRecords")
1004 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
1005 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
1006 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
1007 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
1008 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
1010 handleFillDeleteTreeNodeRecordsXML(xmlOut,
1018 else if(requestType ==
"renameTreeNodeRecords")
1027 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
1028 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
1029 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
1030 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
1031 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
1032 __SUP_COUTV__(newRecordList);
1034 handleFillRenameTreeNodeRecordsXML(xmlOut,
1043 else if(requestType ==
"copyTreeNodeRecords")
1050 unsigned int numberOfCopies =
1051 CgiDataUtilities::getDataAsInt(cgiIn,
"numberOfCopies");
1055 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
1056 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
1057 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
1058 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
1059 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
1060 __SUP_COUTV__(numberOfCopies);
1062 handleFillCopyTreeNodeRecordsXML(xmlOut,
1071 else if(requestType ==
"getTableStructureStatusAsJSON")
1078 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
1079 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
1080 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
1081 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
1084 setupActiveTablesXML(xmlOut,
1093 xmlOut.addTextElementToData(
1094 "StructureStatusAsJSON",
1097 catch(
const std::runtime_error& e)
1099 __SUP_SS__ <<
"The table plugin feature getStructureStatusAsJSON(), does not "
1100 "seem to be supported for the table '"
1102 <<
".' Make sure you have the expected table plugin in your path, "
1103 "or contact system admins."
1105 ss <<
"Here is the error: " << e.what() << __E__;
1109 else if(requestType ==
"getArtdaqNodes")
1113 __SUP_COUTV__(modifiedTables);
1115 handleGetArtdaqNodeRecordsXML(xmlOut, cfgMgr, modifiedTables);
1117 else if(requestType ==
"saveArtdaqNodes")
1121 std::string subsystemString =
1124 __SUP_COUTV__(modifiedTables);
1125 __SUP_COUTV__(nodeString);
1126 __SUP_COUTV__(subsystemString);
1128 handleSaveArtdaqNodeRecordsXML(
1129 nodeString, subsystemString, xmlOut, cfgMgr, modifiedTables);
1131 else if(requestType ==
"getArtdaqNodeLayout")
1133 std::string contextGroupName =
1137 __SUP_COUTV__(contextGroupName);
1138 __SUP_COUTV__(contextGroupKey);
1140 handleLoadArtdaqNodeLayoutXML(
1141 xmlOut, cfgMgr, contextGroupName,
TableGroupKey(contextGroupKey));
1143 else if(requestType ==
"saveArtdaqNodeLayout")
1146 std::string contextGroupName =
1150 __SUP_COUTV__(layout);
1151 __SUP_COUTV__(contextGroupName);
1152 __SUP_COUTV__(contextGroupKey);
1154 handleSaveArtdaqNodeLayoutXML(
1155 xmlOut, cfgMgr, layout, contextGroupName,
TableGroupKey(contextGroupKey));
1157 else if(requestType ==
"checkAffectedActiveGroups")
1162 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
1163 __SUP_COUT__ <<
"groupName: " << groupName << __E__;
1164 __SUP_COUT__ <<
"groupKey: " << groupKey << __E__;
1166 handleGetAffectedGroupsXML(
1167 xmlOut, cfgMgr, groupName,
TableGroupKey(groupKey), modifiedTables);
1169 else if(requestType ==
"saveTreeNodeEdit")
1173 std::string targetTableVersion =
1179 __SUP_COUT__ <<
"editNodeType: " << editNodeType << __E__;
1180 __SUP_COUT__ <<
"targetTable: " << targetTable << __E__;
1181 __SUP_COUT__ <<
"targetTableVersion: " << targetTableVersion << __E__;
1182 __SUP_COUT__ <<
"targetUID: " << targetUID << __E__;
1183 __SUP_COUT__ <<
"targetColumn: " << targetColumn << __E__;
1184 __SUP_COUT__ <<
"newValue: " << newValue << __E__;
1186 handleSaveTreeNodeEditXML(xmlOut,
1194 userInfo.username_);
1196 else if(requestType ==
"getLinkToChoices")
1199 std::string linkToTableVersion =
1206 __SUP_COUT__ <<
"linkToTableName: " << linkToTableName << __E__;
1207 __SUP_COUT__ <<
"linkToTableVersion: " << linkToTableVersion << __E__;
1208 __SUP_COUT__ <<
"linkIdType: " << linkIdType << __E__;
1209 __SUP_COUT__ <<
"linkIndex: " << linkIndex << __E__;
1210 __SUP_COUT__ <<
"linkInitId: " << linkInitId << __E__;
1212 handleGetLinkToChoicesXML(xmlOut,
1220 else if(requestType ==
"activateTableGroup")
1224 bool ignoreWarnings = CgiDataUtilities::getDataAsInt(cgiIn,
"ignoreWarnings");
1226 __SUP_COUT__ <<
"Activating group: " << groupName <<
"(" << groupKey <<
")"
1228 __SUP_COUTV__(ignoreWarnings);
1231 xmlOut.addTextElementToData(
"AttemptedGroupActivation",
"1");
1232 xmlOut.addTextElementToData(
"AttemptedGroupActivationName", groupName);
1233 xmlOut.addTextElementToData(
"AttemptedGroupActivationKey", groupKey);
1237 std::string accumulatedErrors, groupTypeString;
1245 groupName,
TableGroupKey(groupKey), &accumulatedErrors, &groupTypeString);
1247 if(accumulatedErrors !=
"")
1251 __SS__ <<
"Throwing exception on accumulated errors: "
1252 << accumulatedErrors << __E__;
1256 __COUT_WARN__ <<
"Ignoring warnings so ignoring this error:"
1257 << accumulatedErrors << __E__;
1258 __COUT_WARN__ <<
"Done ignoring the above error(s)." << __E__;
1260 xmlOut.addTextElementToData(
"AttemptedGroupActivationType", groupTypeString);
1262 catch(std::runtime_error& e)
1267 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
1268 xmlOut.addTextElementToData(
1270 "Error activating table group '" + groupName +
"(" + groupKey +
")" +
1271 ".' Please see details below:\n\n" + std::string(e.what()));
1272 __SUP_COUT_ERR__ <<
"Errors detected so de-activating group: " << groupName
1273 <<
" (" << groupKey <<
")" << __E__;
1282 catch(cet::exception& e)
1288 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
1289 xmlOut.addTextElementToData(
"Error",
1290 "Error activating table group '" + groupName +
1291 "(" + groupKey +
")" +
"!'\n\n" +
1292 std::string(e.what()));
1293 __SUP_COUT_ERR__ <<
"Errors detected so de-activating group: " << groupName
1294 <<
" (" << groupKey <<
")" << __E__;
1305 __SUP_COUT__ <<
"Unknown error detected!" << __E__;
1317 else if(requestType ==
"getActiveTableGroups")
1319 else if(requestType ==
"copyViewToCurrentColumns")
1321 std::string tableName =
1325 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
1326 __SUP_COUT__ <<
"sourceVersion: " << sourceVersion << __E__;
1327 __SUP_COUT__ <<
"userInfo.username_: " << userInfo.username_ << __E__;
1333 newTemporaryVersion =
1336 __SUP_COUT__ <<
"New temporary version = " << newTemporaryVersion << __E__;
1338 catch(std::runtime_error& e)
1340 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
1341 xmlOut.addTextElementToData(
"Error",
1342 "Error copying view from '" + tableName +
"_v" +
1343 sourceVersion +
"'! " +
1344 std::string(e.what()));
1348 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
1349 xmlOut.addTextElementToData(
1351 "Error copying view from '" + tableName +
"_v" + sourceVersion +
"'! ");
1354 handleGetTableXML(xmlOut, cfgMgr, tableName, newTemporaryVersion);
1356 else if(requestType ==
"getLastTableGroups")
1359 std::map<std::string ,
1360 std::tuple<std::string ,
1365 theRemoteWebUsers_.getLastTableGroups(theGroups);
1367 for(
const auto& theGroup : theGroups)
1369 xmlOut.addTextElementToData(
"Last" + theGroup.first +
"GroupName",
1370 std::get<0>(theGroup.second));
1371 xmlOut.addTextElementToData(
"Last" + theGroup.first +
"GroupKey",
1372 std::get<1>(theGroup.second).toString());
1373 xmlOut.addTextElementToData(
"Last" + theGroup.first +
"GroupTime",
1374 std::get<2>(theGroup.second));
1407 handleOtherSubsystemActiveGroups(xmlOut, cfgMgr,
false );
1409 else if(requestType ==
"getSubsytemTableGroups")
1411 std::string subsystem =
1413 __SUP_COUTV__(subsystem);
1414 handleOtherSubsystemActiveGroups(
1415 xmlOut, cfgMgr,
true , subsystem);
1417 else if(requestType ==
"diffWithActiveGroup")
1419 std::string groupName =
1422 __SUP_COUTV__(groupName);
1423 __SUP_COUTV__(groupKey);
1428 else if(requestType ==
"diffWithGroupKey")
1430 std::string groupName =
1434 std::string diffGroupName =
1436 __SUP_COUTV__(groupName);
1437 __SUP_COUTV__(groupKey);
1438 __SUP_COUTV__(diffKey);
1439 __SUP_COUTV__(diffGroupName);
1441 handleGroupDiff(xmlOut,
1448 else if(requestType ==
"diffTableVersions")
1450 std::string tableName =
1454 __SUP_COUTV__(tableName);
1459 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
1462 if(allTableInfo.find(tableName) != allTableInfo.end())
1464 if(vA.find(ConfigurationManager::ALIAS_VERSION_PREAMBLE) == 0)
1467 std::map<std::string ,
1471 std::string versionAlias;
1473 vA.substr(ConfigurationManager::ALIAS_VERSION_PREAMBLE.size());
1475 if(versionAliases.find(tableName) != versionAliases.end() &&
1476 versionAliases[tableName].find(versionAlias) !=
1477 versionAliases[tableName].end())
1479 versionA = versionAliases[tableName][versionAlias];
1480 __SUP_COUT__ <<
"version alias translated to: " << versionA << __E__;
1483 __SUP_COUT_WARN__ <<
"version alias '" << versionAlias
1484 <<
"'was not found in active version aliases!"
1488 versionA = atoi(vA.c_str());
1490 if(vB.find(ConfigurationManager::ALIAS_VERSION_PREAMBLE) == 0)
1493 std::map<std::string ,
1497 std::string versionAlias;
1499 vB.substr(ConfigurationManager::ALIAS_VERSION_PREAMBLE.size());
1501 if(versionAliases.find(tableName) != versionAliases.end() &&
1502 versionAliases[tableName].find(versionAlias) !=
1503 versionAliases[tableName].end())
1505 versionB = versionAliases[tableName][versionAlias];
1506 __SUP_COUT__ <<
"version alias translated to: " << versionB << __E__;
1509 __SUP_COUT_WARN__ <<
"version alias '" << versionAlias
1510 <<
"'was not found in active version aliases!"
1514 versionB = atoi(vB.c_str());
1518 versionA = atoi(vA.c_str());
1519 versionB = atoi(vB.c_str());
1522 __SUP_COUTV__(versionA);
1523 __SUP_COUTV__(versionB);
1525 handleTableDiff(xmlOut, cfgMgr, tableName, versionA, versionB);
1527 else if(requestType ==
"findGroupsWithTable")
1529 std::string tableName =
1531 std::string tableVersion =
1534 __SUP_COUTV__(tableName);
1535 __SUP_COUTV__(tableVersion);
1537 std::set<std::string> groupsContainingTable =
1538 cfgMgr->getConfigurationInterface()->findGroupsWithTable(
1540 __SUP_COUT__ <<
"Groups containing " << tableName <<
"-v" << tableVersion
1541 <<
" count: " << groupsContainingTable.size() << __E__;
1542 std::string groupsContainingTableString =
1544 __SUP_COUTTV__(groupsContainingTableString);
1546 xmlOut.addNumberElementToData(
"GroupsContainingCount",
1547 groupsContainingTable.size());
1548 xmlOut.addTextElementToData(
"GroupsContainingCSV", groupsContainingTableString);
1551 else if(requestType ==
"savePlanCommandSequence")
1554 std::string commands =
1560 __SUP_COUTV__(modifiedTables);
1561 __SUP_COUTV__(planName);
1562 __SUP_COUTV__(commands);
1563 __SUP_COUTV__(groupName);
1564 __SUP_COUTV__(groupKey);
1566 handleSavePlanCommandSequenceXML(xmlOut,
1575 else if(requestType ==
"mergeGroups")
1577 std::string groupANameContext =
1579 std::string groupAKeyContext =
1581 std::string groupBNameContext =
1583 std::string groupBKeyContext =
1585 std::string groupANameConfig =
1588 std::string groupBNameConfig =
1593 __SUP_COUTV__(groupANameContext);
1594 __SUP_COUTV__(groupAKeyContext);
1595 __SUP_COUTV__(groupBNameContext);
1596 __SUP_COUTV__(groupBKeyContext);
1597 __SUP_COUTV__(groupANameConfig);
1598 __SUP_COUTV__(groupAKeyConfig);
1599 __SUP_COUTV__(groupBNameConfig);
1600 __SUP_COUTV__(groupBKeyConfig);
1601 __SUP_COUTV__(mergeApproach);
1603 handleMergeGroupsXML(xmlOut,
1618 __SUP_SS__ <<
"requestType Request, " << requestType
1619 <<
", not recognized by the Configuration GUI Supervisor (was it "
1620 "intended for another Supervisor?)."
1622 __SUP_COUT__ <<
"\n" << ss.str();
1623 xmlOut.addTextElementToData(
"Error", ss.str());
1626 __SUP_COUTT__ <<
"cfgMgr runtime=" << cfgMgr->runTimeSeconds() << __E__;
1629 xmlOut, cfgMgr, userInfo.username_);
1630 __SUP_COUTT__ <<
"cfgMgr runtime=" << cfgMgr->runTimeSeconds() << __E__;
1633 catch(
const std::runtime_error& e)
1635 __SS__ <<
"A fatal error occurred while handling the request '" << requestType
1636 <<
".' Error: " << e.what() << __E__;
1637 __COUT_ERR__ <<
"\n" << ss.str();
1638 xmlOut.addTextElementToData(
"Error", ss.str());
1643 xmlOut.addTextElementToData(
1645 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
1649 __COUT_ERR__ <<
"Error getting version tracking status!" << __E__;
1654 __SS__ <<
"An unknown fatal error occurred while handling the request '"
1655 << requestType <<
".'" << __E__;
1660 catch(
const std::exception& e)
1662 ss <<
"Exception message: " << e.what();
1667 __COUT_ERR__ <<
"\n" << ss.str();
1668 xmlOut.addTextElementToData(
"Error", ss.str());
1673 xmlOut.addTextElementToData(
1675 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
1679 __COUT_ERR__ <<
"Error getting version tracking status!" << __E__;
1699 void ConfigurationGUISupervisor::handleGetAffectedGroupsXML(
1702 const std::string& rootGroupName,
1704 const std::string& modifiedTables)
1707 __SUP_COUT__ <<
"rootGroupName " << rootGroupName <<
"(" << rootGroupKey
1708 <<
"). modifiedTables = " << modifiedTables << __E__;
1710 std::map<std::string, std::pair<std::string, TableGroupKey>> consideredGroups =
1715 if(consideredGroups[ConfigurationManager::GROUP_TYPE_NAME_CONTEXT].second.isInvalid())
1717 __SUP_COUT__ <<
"Finding a context group to consider..." << __E__;
1718 if(cfgMgr->getFailedTableGroups().find(
1719 ConfigurationManager::GROUP_TYPE_NAME_CONTEXT) !=
1720 cfgMgr->getFailedTableGroups().end())
1722 consideredGroups[ConfigurationManager::GROUP_TYPE_NAME_CONTEXT] =
1723 cfgMgr->getFailedTableGroups().at(
1724 ConfigurationManager::GROUP_TYPE_NAME_CONTEXT);
1726 else if(cfgMgr->getFailedTableGroups().find(
1727 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN) !=
1728 cfgMgr->getFailedTableGroups().end())
1730 consideredGroups[ConfigurationManager::GROUP_TYPE_NAME_CONTEXT] =
1731 cfgMgr->getFailedTableGroups().at(
1732 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN);
1735 if(consideredGroups[ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION]
1736 .second.isInvalid())
1738 __SUP_COUT__ <<
"Finding a table group to consider..." << __E__;
1739 if(cfgMgr->getFailedTableGroups().find(
1740 ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION) !=
1741 cfgMgr->getFailedTableGroups().end())
1743 consideredGroups[ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION] =
1744 cfgMgr->getFailedTableGroups().at(
1745 ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION);
1747 else if(cfgMgr->getFailedTableGroups().find(
1748 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN) !=
1749 cfgMgr->getFailedTableGroups().end())
1751 consideredGroups[ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION] =
1752 cfgMgr->getFailedTableGroups().at(
1753 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN);
1762 std::map<std::string ,
TableVersion > rootGroupMemberMap;
1767 &rootGroupMemberMap,
1777 consideredGroups[groupType] =
1778 std::pair<std::string, TableGroupKey>(rootGroupName, rootGroupKey);
1780 catch(
const std::runtime_error& e)
1783 if(rootGroupName.size())
1785 __SUP_SS__ <<
"Failed to determine type of table group for " << rootGroupName
1786 <<
"(" << rootGroupKey <<
")! " << e.what() << __E__;
1787 __SUP_COUT_ERR__ <<
"\n" << ss.str();
1792 __SUP_COUT__ <<
"Did not modify considered active groups due to empty root group "
1793 "name - assuming this was intentional."
1799 if(rootGroupName.size())
1801 __SUP_COUT_ERR__ <<
"Failed to determine type of table group for "
1802 << rootGroupName <<
"(" << rootGroupKey <<
")!" << __E__;
1807 __SUP_COUT__ <<
"Did not modify considered active groups due to empty root group "
1808 "name - assuming this was intentional."
1812 std::map<std::string ,
1815 std::map<std::string ,
1817 modifiedTablesMapIt;
1819 std::istringstream f(modifiedTables);
1820 std::string table, version;
1821 while(getline(f, table,
','))
1823 getline(f, version,
',');
1824 modifiedTablesMap.insert(
1827 std::pair<bool /*foundAffectedGroup*/, TableVersion /*version*/>>(
1831 __SUP_COUT__ << modifiedTables << __E__;
1832 for(
auto& pair : modifiedTablesMap)
1833 __SUP_COUT__ <<
"modified table " << pair.first <<
":" << pair.second.second
1838 xercesc::DOMElement* parentEl =
nullptr;
1839 std::string groupComment;
1840 std::vector<std::string> orderedGroupTypes(
1841 {ConfigurationManager::GROUP_TYPE_NAME_CONTEXT,
1842 ConfigurationManager::GROUP_TYPE_NAME_BACKBONE,
1843 ConfigurationManager::GROUP_TYPE_NAME_ITERATE,
1844 ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION});
1845 for(
auto groupType : orderedGroupTypes)
1847 if(consideredGroups.find(groupType) == consideredGroups.end())
1850 const std::pair<std::string, TableGroupKey>& group = consideredGroups[groupType];
1852 if(group.second.isInvalid())
1855 __SUP_COUT__ <<
"Considering " << groupType <<
" group " << group.first <<
" ("
1856 << group.second <<
")" << __E__;
1874 __SUP_COUT__ <<
"groupComment = " << groupComment << __E__;
1876 for(
auto& table : memberMap)
1878 if((modifiedTablesMapIt = modifiedTablesMap.find(table.first)) !=
1881 table.second != (*modifiedTablesMapIt).second.second)
1883 __SUP_COUT__ <<
"Affected by " << (*modifiedTablesMapIt).first <<
":"
1884 << (*modifiedTablesMapIt).second.second << __E__;
1886 memberMap[table.first] = (*modifiedTablesMapIt).second.second;
1887 (*modifiedTablesMapIt).second.first =
true;
1891 parentEl = xmlOut.addTextElementToData(
"AffectedActiveGroup",
"");
1895 if(groupType == ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION)
1897 __SUP_COUT__ <<
"Considering mockup tables for Configuration Group..."
1899 for(
auto& table : modifiedTablesMap)
1901 if(table.second.first)
1904 if(table.second.second.isMockupVersion() &&
1905 memberMap.find(table.first) == memberMap.end())
1907 __SUP_COUT__ <<
"Found mockup table '" << table.first
1908 <<
"' for Configuration Group." << __E__;
1909 memberMap[table.first] = table.second.second;
1912 parentEl = xmlOut.addTextElementToData(
"AffectedActiveGroup",
"");
1916 "AddMemberVersion", table.second.second.toString(), parentEl);
1923 __SUP_COUTV__(affected);
1927 parentEl = xmlOut.addTextElementToData(
"AffectedActiveGroup",
"");
1932 for(
auto& table : memberMap)
1936 "MemberVersion", table.second.toString(), parentEl);
1941 catch(std::runtime_error& e)
1943 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
1944 xmlOut.addTextElementToData(
1945 "Error",
"Error getting affected groups! " + std::string(e.what()));
1949 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
1950 xmlOut.addTextElementToData(
"Error",
"Error getting affected groups! ");
1961 void ConfigurationGUISupervisor::setupActiveTablesXML(
1964 const std::string& groupName,
1966 const std::string& modifiedTables,
1968 bool doGetGroupInfo,
1969 std::map<std::string /*name*/, TableVersion /*version*/>* returnMemberMap,
1970 bool outputActiveTables,
1971 std::string* accumulatedErrors)
1974 xmlOut.addTextElementToData(
"tableGroup", groupName);
1975 xmlOut.addTextElementToData(
"tableGroupKey", groupKey.
toString());
1977 bool usingActiveGroups = (groupName ==
"" || groupKey.
isInvalid());
1985 __SUP_COUT__ <<
"Refreshing all table info, ignoring warnings..." << __E__;
1986 std::string accumulatedWarnings =
"";
1988 &accumulatedWarnings,
2002 __SUP_COUT__ <<
"Restoring active table group tables..." << __E__;
2004 for(
const auto& activeGroup : activeGroups)
2006 if(activeGroup.second.first == groupName &&
2007 activeGroup.second.second == groupKey)
2009 __SUP_COUTT__ <<
"Skipping target active group." << __E__;
2012 __SUP_COUTT__ <<
"Loading " << activeGroup.first <<
" "
2013 << activeGroup.second.first <<
"(" << activeGroup.second.second
2018 activeGroup.second.second,
2024 __SUP_COUT__ <<
"Ignoring errors while setting up active tables for "
2025 << activeGroup.second.first <<
"("
2026 << activeGroup.second.second <<
")..." << __E__;
2032 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
2034 std::map<std::string ,
TableVersion > modifiedTablesMap;
2036 modifiedTablesMapIt;
2038 if(usingActiveGroups)
2041 __SUP_COUT__ <<
"Using active groups." << __E__;
2045 __SUP_COUT__ <<
"Loading group '" << groupName <<
"(" << groupKey <<
")'"
2048 std::string groupComment, groupAuthor, tableGroupCreationTime, groupType;
2057 doGetGroupInfo ? &groupComment : 0,
2058 doGetGroupInfo ? &groupAuthor : 0,
2059 doGetGroupInfo ? &tableGroupCreationTime : 0,
2061 doGetGroupInfo ? &groupType : 0);
2065 xmlOut.addTextElementToData(
"tableGroupComment", groupComment);
2066 xmlOut.addTextElementToData(
"tableGroupAuthor", groupAuthor);
2067 xmlOut.addTextElementToData(
"tableGroupCreationTime", tableGroupCreationTime);
2068 xmlOut.addTextElementToData(
"tableGroupType", groupType);
2071 if(accumulatedErrors && *accumulatedErrors !=
"")
2072 __SUP_COUTV__(*accumulatedErrors);
2078 std::istringstream f(modifiedTables);
2079 std::string table, version;
2080 while(getline(f, table,
','))
2082 getline(f, version,
',');
2083 modifiedTablesMap.insert(
2084 std::pair<std::string /*name*/, TableVersion /*version*/>(
2088 for(
auto& pair : modifiedTablesMap)
2089 __SUP_COUT__ <<
"modified table " << pair.first <<
":" << pair.second
2094 std::map<std::string, TableVersion> allActivePairs = cfgMgr->
getActiveVersions();
2095 xmlOut.addTextElementToData(
"DefaultNoLink",
2096 TableViewColumnInfo::DATATYPE_LINK_DEFAULT);
2099 std::set<std::string, StringMacros::IgnoreCaseCompareStruct> orderedTableSet;
2100 for(
const auto& tablePair : allActivePairs)
2101 orderedTableSet.emplace(tablePair.first);
2103 std::map<std::string, TableInfo>::const_iterator tableInfoIt;
2104 for(
auto& orderedTableName : orderedTableSet)
2106 tableInfoIt = allTableInfo.find(orderedTableName);
2107 if(tableInfoIt == allTableInfo.end())
2109 __SS__ <<
"Impossible missing table in map '" << orderedTableName <<
"'"
2114 if(outputActiveTables)
2115 xmlOut.addTextElementToData(
"ActiveTableName", orderedTableName);
2119 if((modifiedTablesMapIt = modifiedTablesMap.find(orderedTableName)) !=
2120 modifiedTablesMap.end())
2122 __SUP_COUT__ <<
"Found modified table " << (*modifiedTablesMapIt).first
2123 <<
": trying... " << (*modifiedTablesMapIt).second << __E__;
2127 tableInfoIt->second.tablePtr_->setActiveView(
2128 (*modifiedTablesMapIt).second);
2132 __SUP_SS__ <<
"Modified table version v" << (*modifiedTablesMapIt).second
2133 <<
" failed. Reverting to v"
2134 << tableInfoIt->second.tablePtr_->getView().getVersion() <<
"."
2136 __SUP_COUT_WARN__ <<
"Warning detected!\n\n " << ss.str() << __E__;
2137 xmlOut.addTextElementToData(
2139 "Error setting up active tables!\n\n" + std::string(ss.str()));
2143 if(outputActiveTables)
2145 xmlOut.addTextElementToData(
2146 "ActiveTableVersion",
2147 tableInfoIt->second.tablePtr_->getView().getVersion().toString());
2148 xmlOut.addTextElementToData(
2149 "ActiveTableComment",
2150 tableInfoIt->second.tablePtr_->getView().getAuthor() +
": " +
2151 tableInfoIt->second.tablePtr_->getView().getComment());
2159 catch(std::runtime_error& e)
2161 __SUP_SS__ << (
"Error setting up active tables!\n\n" + std::string(e.what()))
2163 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2164 xmlOut.addTextElementToData(
"Error", ss.str());
2169 __SUP_SS__ << (
"Error setting up active tables!\n\n") << __E__;
2174 catch(
const std::exception& e)
2176 ss <<
"Exception message: " << e.what();
2181 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2182 xmlOut.addTextElementToData(
"Error", ss.str());
2201 void ConfigurationGUISupervisor::handleFillCreateTreeNodeRecordsXML(
2204 const std::string& groupName,
2206 const std::string& startPath,
2207 const std::string& modifiedTables,
2208 const std::string& recordList,
2209 const std::string& author)
2212 setupActiveTablesXML(xmlOut,
2227 __SUP_COUT__ << table->getTableName() << __E__;
2237 bool firstSave =
true;
2244 std::istringstream f(recordList);
2245 std::string recordUID;
2247 while(getline(f, recordUID,
','))
2251 __SUP_COUT__ <<
"recordUID " << recordUID << __E__;
2256 .isTemporaryVersion())
2258 __SUP_COUT__ <<
"Start version " << temporaryVersion << __E__;
2260 temporaryVersion = table->createTemporaryView(temporaryVersion);
2266 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion
2270 __SUP_COUT__ <<
"Using temporary version " << temporaryVersion
2276 backupView.copy(table->getView(), temporaryVersion, author);
2285 unsigned int row = table->getViewP()->addRow(
2292 unsigned int col = table->getViewP()->getColStatus();
2293 table->getViewP()->setURIEncodedValue(
"1", row, col);
2300 table->getViewP()->setURIEncodedValue(
2301 recordUID, row, table->getViewP()->getColUID());
2309 table->getViewP()->init();
2313 __SUP_COUT_INFO__ <<
"Reverting to original view." << __E__;
2314 __SUP_COUT__ <<
"Before:" << __E__;
2315 table->getViewP()->print();
2316 table->getViewP()->copy(backupView, temporaryVersion, author);
2317 __SUP_COUT__ <<
"After:" << __E__;
2318 table->getViewP()->print();
2324 handleFillModifiedTablesXML(xmlOut, cfgMgr);
2326 catch(std::runtime_error& e)
2328 __SUP_SS__ << (
"Error creating new record(s)!\n\n" + std::string(e.what()))
2330 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2331 xmlOut.addTextElementToData(
"Error", ss.str());
2335 __SUP_SS__ << (
"Error creating new record(s)!\n\n") << __E__;
2340 catch(
const std::exception& e)
2342 ss <<
"Exception message: " << e.what();
2347 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2348 xmlOut.addTextElementToData(
"Error", ss.str());
2355 void ConfigurationGUISupervisor::handleFillModifiedTablesXML(
2360 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
2361 std::map<std::string, TableVersion> allActivePairs = cfgMgr->
getActiveVersions();
2362 for(
auto& activePair : allActivePairs)
2364 xmlOut.addTextElementToData(
"NewActiveTableName", activePair.first);
2365 xmlOut.addTextElementToData(
"NewActiveTableVersion",
2366 allTableInfo.at(activePair.first)
2367 .tablePtr_->getView()
2370 xmlOut.addTextElementToData(
2371 "NewActiveTableComment",
2372 allTableInfo.at(activePair.first).tablePtr_->getView().getAuthor() +
": " +
2373 allTableInfo.at(activePair.first).tablePtr_->getView().getComment());
2376 catch(std::runtime_error& e)
2378 __SUP_SS__ << (
"Error!\n\n" + std::string(e.what())) << __E__;
2379 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2380 xmlOut.addTextElementToData(
"Error", ss.str());
2384 __SUP_SS__ << (
"Error!\n\n") << __E__;
2389 catch(
const std::exception& e)
2391 ss <<
"Exception message: " << e.what();
2396 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2397 xmlOut.addTextElementToData(
"Error", ss.str());
2415 void ConfigurationGUISupervisor::handleFillDeleteTreeNodeRecordsXML(
2418 const std::string& groupName,
2420 const std::string& startPath,
2421 const std::string& modifiedTables,
2422 const std::string& recordList)
2425 setupActiveTablesXML(xmlOut,
2440 __SUP_COUT__ << table->getTableName() << __E__;
2450 bool firstSave =
true;
2454 std::istringstream f(recordList);
2455 std::string recordUID;
2458 while(getline(f, recordUID,
','))
2462 __SUP_COUT__ <<
"recordUID " << recordUID << __E__;
2467 .isTemporaryVersion())
2469 __SUP_COUT__ <<
"Start version " << temporaryVersion << __E__;
2471 temporaryVersion = table->createTemporaryView(temporaryVersion);
2477 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion
2481 __SUP_COUT__ <<
"Using temporary version " << temporaryVersion
2492 table->getViewP()->findRow(table->getViewP()->getColUID(), recordUID);
2493 table->getViewP()->deleteRow(row);
2498 table->getViewP()->init();
2500 handleFillModifiedTablesXML(xmlOut, cfgMgr);
2502 catch(std::runtime_error& e)
2504 __SUP_SS__ << (
"Error removing record(s)!\n\n" + std::string(e.what())) << __E__;
2505 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2506 xmlOut.addTextElementToData(
"Error", ss.str());
2510 __SUP_SS__ << (
"Error removing record(s)!\n\n") << __E__;
2515 catch(
const std::exception& e)
2517 ss <<
"Exception message: " << e.what();
2522 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2523 xmlOut.addTextElementToData(
"Error", ss.str());
2543 void ConfigurationGUISupervisor::handleFillRenameTreeNodeRecordsXML(
2546 const std::string& groupName,
2548 const std::string& startPath,
2549 const std::string& modifiedTables,
2550 const std::string& recordList,
2551 const std::string& newRecordList)
2554 setupActiveTablesXML(xmlOut,
2569 __SUP_COUT__ << table->getTableName() << __E__;
2580 std::vector<std::string> recordArray =
2582 std::vector<std::string> newRecordArray =
2588 if(recordArray.size() == 0 || recordArray.size() != newRecordArray.size())
2591 <<
"Invalid record size vs new record name size, they must be the same: "
2592 << recordArray.size() <<
" vs " << newRecordArray.size() << __E__;
2598 if(!(temporaryVersion = targetNode.
getTableVersion()).isTemporaryVersion())
2600 __SUP_COUT__ <<
"Start version " << temporaryVersion << __E__;
2602 temporaryVersion = table->createTemporaryView(temporaryVersion);
2608 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion << __E__;
2611 __SUP_COUT__ <<
"Using temporary version " << temporaryVersion << __E__;
2618 for(
unsigned int i = 0; i < recordArray.size(); ++i)
2620 row = table->getViewP()->findRow(
2621 table->getViewP()->getColUID(),
2624 table->getViewP()->setValueAsString(
2625 newRecordArray[i], row, table->getViewP()->getColUID());
2628 table->getViewP()->init();
2630 handleFillModifiedTablesXML(xmlOut, cfgMgr);
2632 catch(std::runtime_error& e)
2634 __SUP_SS__ << (
"Error renaming record(s)!\n\n" + std::string(e.what())) << __E__;
2635 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2636 xmlOut.addTextElementToData(
"Error", ss.str());
2640 __SUP_SS__ << (
"Error renaming record(s)!\n\n") << __E__;
2645 catch(
const std::exception& e)
2647 ss <<
"Exception message: " << e.what();
2652 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2653 xmlOut.addTextElementToData(
"Error", ss.str());
2674 void ConfigurationGUISupervisor::handleFillCopyTreeNodeRecordsXML(
2677 const std::string& groupName,
2679 const std::string& startPath,
2680 const std::string& modifiedTables,
2681 const std::string& recordList,
2682 unsigned int numberOfCopies )
2688 setupActiveTablesXML(xmlOut,
2703 __SUP_COUT__ << table->getTableName() << __E__;
2714 std::vector<std::string> recordArray =
2720 if(!(temporaryVersion = targetNode.
getTableVersion()).isTemporaryVersion())
2722 __SUP_COUT__ <<
"Start version " << temporaryVersion << __E__;
2724 temporaryVersion = table->createTemporaryView(temporaryVersion);
2730 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion << __E__;
2733 __SUP_COUT__ <<
"Using temporary version " << temporaryVersion << __E__;
2740 for(
const auto& recordUID : recordArray)
2742 row = table->getViewP()->findRow(table->getViewP()->getColUID(),
2744 for(
unsigned int i = 0; i < numberOfCopies; ++i)
2745 table->getViewP()->copyRows(
2755 table->getViewP()->init();
2757 handleFillModifiedTablesXML(xmlOut, cfgMgr);
2759 catch(std::runtime_error& e)
2761 __SUP_SS__ << (
"Error copying record(s)!\n\n" + std::string(e.what())) << __E__;
2762 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2763 xmlOut.addTextElementToData(
"Error", ss.str());
2767 __SUP_SS__ << (
"Error copying record(s)!\n\n") << __E__;
2772 catch(
const std::exception& e)
2774 ss <<
"Exception message: " << e.what();
2779 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2780 xmlOut.addTextElementToData(
"Error", ss.str());
2801 void ConfigurationGUISupervisor::handleFillSetTreeNodeFieldValuesXML(
2804 const std::string& groupName,
2806 const std::string& startPath,
2807 const std::string& modifiedTables,
2808 const std::string& recordList,
2809 const std::string& fieldList,
2810 const std::string& valueList,
2811 const std::string& author)
2814 setupActiveTablesXML(xmlOut,
2829 std::vector<std::string > fieldPaths;
2832 std::istringstream f(fieldList);
2833 std::string fieldPath;
2834 while(getline(f, fieldPath,
','))
2838 __SUP_COUT__ << fieldList << __E__;
2839 for(
const auto& field : fieldPaths)
2840 __SUP_COUT__ <<
"fieldPath " << field << __E__;
2843 std::vector<std::string > fieldValues;
2846 std::istringstream f(valueList);
2847 std::string fieldValue;
2848 while(getline(f, fieldValue,
','))
2850 fieldValues.push_back(fieldValue);
2855 if(valueList.size() && valueList[valueList.size() - 1] ==
',')
2856 fieldValues.push_back(
"");
2858 __SUP_COUT__ << valueList << __E__;
2859 for(
const auto& value : fieldValues)
2860 __SUP_COUT__ <<
"fieldValue " << value << __E__;
2863 if(fieldPaths.size() != fieldValues.size())
2866 __THROW__(ss.str() +
"Mismatch in fields and values array size!");
2873 std::istringstream f(recordList);
2874 std::string recordUID;
2877 while(getline(f, recordUID,
','))
2882 xmlOut.addTextElementToData(
"fieldValues", recordUID);
2885 for(i = 0; i < fieldPaths.size(); ++i)
2887 __SUP_COUT__ <<
"fieldPath " << fieldPaths[i] << __E__;
2888 __SUP_COUT__ <<
"fieldValue " << fieldValues[i] << __E__;
2893 cfgMgr->
getNode(startPath +
"/" + recordUID +
"/" + fieldPaths[i],
2934 if(!(temporaryVersion = table->getViewP()->getVersion())
2935 .isTemporaryVersion())
2939 table->createTemporaryView(table->getViewP()->getVersion());
2945 __SUP_COUT__ <<
"Created temporary version "
2946 << table->getTableName() <<
"-v" << temporaryVersion
2950 __SUP_COUT__ <<
"Using temporary version " << table->getTableName()
2951 <<
"-v" << temporaryVersion << __E__;
2955 table->getViewP()->setURIEncodedValue(fieldValues[i],
2966 handleFillModifiedTablesXML(xmlOut, cfgMgr);
2968 catch(std::runtime_error& e)
2970 __SUP_SS__ << (
"Error setting field values!\n\n" + std::string(e.what()))
2972 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2973 xmlOut.addTextElementToData(
"Error", ss.str());
2977 __SUP_SS__ << (
"Error setting field values!\n\n") << __E__;
2982 catch(
const std::exception& e)
2984 ss <<
"Exception message: " << e.what();
2989 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2990 xmlOut.addTextElementToData(
"Error", ss.str());
3009 void ConfigurationGUISupervisor::handleFillGetTreeNodeFieldValuesXML(
3012 const std::string& groupName,
3014 const std::string& startPath,
3015 const std::string& modifiedTables,
3016 const std::string& recordList,
3017 const std::string& fieldList)
3020 setupActiveTablesXML(
3021 xmlOut, cfgMgr, groupName, groupKey, modifiedTables,
false );
3028 std::vector<std::string > fieldPaths;
3031 std::istringstream f(fieldList);
3032 std::string fieldPath;
3033 while(getline(f, fieldPath,
','))
3037 __SUP_COUT__ << fieldList << __E__;
3042 std::istringstream f(recordList);
3043 std::string recordUID;
3044 while(getline(f, recordUID,
','))
3048 __SUP_COUT__ <<
"recordUID " << recordUID << __E__;
3050 xercesc::DOMElement* parentEl =
3051 xmlOut.addTextElementToData(
"fieldValues", recordUID);
3054 for(
const auto& fieldPath : fieldPaths)
3060 cfgMgr->
getNode(startPath +
"/" + recordUID +
"/" + fieldPath);
3072 catch(std::runtime_error& e)
3074 __SUP_SS__ << (
"Error getting field values!\n\n" + std::string(e.what()))
3076 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3077 xmlOut.addTextElementToData(
"Error", ss.str());
3081 __SUP_SS__ << (
"Error getting field values!\n\n") << __E__;
3086 catch(
const std::exception& e)
3088 ss <<
"Exception message: " << e.what();
3093 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3094 xmlOut.addTextElementToData(
"Error", ss.str());
3117 void ConfigurationGUISupervisor::handleFillTreeNodeCommonFieldsXML(
3120 const std::string& groupName,
3122 const std::string& startPath,
3124 const std::string& modifiedTables,
3125 const std::string& recordList,
3126 const std::string& fieldList)
3129 setupActiveTablesXML(
3130 xmlOut, cfgMgr, groupName, groupKey, modifiedTables,
false );
3134 xercesc::DOMElement* parentEl = xmlOut.addTextElementToData(
"fields", startPath);
3138 __SUP_SS__ <<
"Depth of search must be greater than 0." << __E__;
3139 __SUP_COUT__ << ss.str();
3148 std::vector<ConfigurationTree::RecordField> retFieldList;
3154 __SUP_SS__ <<
"Start path was a disconnected link node!" << __E__;
3160 std::vector<std::string > fieldAcceptList, fieldRejectList;
3165 std::istringstream f(fieldList);
3166 std::string fieldPath, decodedFieldPath;
3167 while(getline(f, fieldPath,
','))
3171 if(decodedFieldPath[0] ==
'!')
3172 fieldRejectList.push_back(decodedFieldPath.substr(1));
3174 fieldAcceptList.push_back(decodedFieldPath);
3176 __SUP_COUT__ << fieldList << __E__;
3177 for(
auto& field : fieldAcceptList)
3178 __SUP_COUT__ <<
"fieldAcceptList " << field << __E__;
3179 for(
auto& field : fieldRejectList)
3180 __SUP_COUT__ <<
"fieldRejectList " << field << __E__;
3184 std::vector<std::string > records;
3185 if(recordList ==
"*")
3189 __SUP_COUT__ <<
"Translating wildcard..." << __E__;
3190 for(
auto& record : records)
3191 __SUP_COUT__ <<
"recordList " << record << __E__;
3193 else if(recordList !=
"")
3197 std::istringstream f(recordList);
3198 std::string recordStr;
3199 while(getline(f, recordStr,
','))
3203 __SUP_COUT__ << recordList << __E__;
3204 for(
auto& record : records)
3205 __SUP_COUT__ <<
"recordList " << record << __E__;
3211 records, fieldAcceptList, fieldRejectList, depth);
3215 xercesc::DOMElement* parentTypeEl;
3216 for(
const auto& fieldInfo : retFieldList)
3219 "FieldTableName", fieldInfo.tableName_, parentEl);
3221 "FieldColumnName", fieldInfo.columnName_, parentEl);
3223 "FieldRelativePath", fieldInfo.relativePath_, parentEl);
3225 "FieldColumnType", fieldInfo.columnInfo_->getType(), parentEl);
3227 "FieldColumnDataType", fieldInfo.columnInfo_->getDataType(), parentEl);
3229 fieldInfo.columnInfo_->getDefaultValue(),
3236 auto dataChoices = fieldInfo.columnInfo_->getDataChoices();
3238 "FieldColumnDataChoice",
3239 fieldInfo.columnInfo_->getDefaultValue(),
3241 for(
const auto& dataChoice : dataChoices)
3243 "FieldColumnDataChoice", dataChoice, parentTypeEl);
3246 catch(std::runtime_error& e)
3248 __SUP_SS__ << (
"Error getting common fields!\n\n" + std::string(e.what()))
3250 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3251 xmlOut.addTextElementToData(
"Error", ss.str());
3255 __SUP_SS__ << (
"Error getting common fields!\n\n") << __E__;
3260 catch(
const std::exception& e)
3262 ss <<
"Exception message: " << e.what();
3267 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3268 xmlOut.addTextElementToData(
"Error", ss.str());
3300 void ConfigurationGUISupervisor::handleFillUniqueFieldValuesForRecordsXML(
3303 const std::string& groupName,
3305 const std::string& startPath,
3306 const std::string& modifiedTables,
3307 const std::string& recordList,
3308 const std::string& fieldList)
3311 setupActiveTablesXML(
3312 xmlOut, cfgMgr, groupName, groupKey, modifiedTables,
false );
3318 if(startPath ==
"/")
3324 __SUP_SS__ <<
"Start path was a disconnected link node!" << __E__;
3325 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3330 std::vector<std::string > records;
3331 if(recordList ==
"*")
3335 __SUP_COUT__ <<
"Translating wildcard..." << __E__;
3336 for(
auto& record : records)
3337 __SUP_COUT__ <<
"recordList " << record << __E__;
3339 else if(recordList !=
"")
3343 std::istringstream f(recordList);
3344 std::string recordStr;
3345 while(getline(f, recordStr,
','))
3349 __SUP_COUT__ << recordList << __E__;
3350 for(
auto& record : records)
3351 __SUP_COUT__ <<
"recordList " << record << __E__;
3356 std::vector<std::string > fieldsToGet;
3361 if(fieldList ==
"AUTO")
3366 __SUP_COUT__ <<
"Getting AUTO filter fields!" << __E__;
3368 std::vector<ConfigurationTree::RecordField> retFieldList;
3369 std::vector<std::string > fieldAcceptList,
3371 fieldRejectList.push_back(
"*" + TableViewColumnInfo::COL_NAME_COMMENT);
3373 records, fieldAcceptList, fieldRejectList, 5,
true );
3375 for(
const auto& retField : retFieldList)
3376 fieldsToGet.push_back(retField.relativePath_ + retField.columnName_);
3380 std::istringstream f(fieldList);
3381 std::string fieldPath;
3382 while(getline(f, fieldPath,
','))
3386 __SUP_COUTV__(fieldList);
3395 std::string fieldGroupIDChildLinkIndex;
3396 for(
auto& field : fieldsToGet)
3398 __SUP_COUTV__(field);
3400 xercesc::DOMElement* parentEl =
3401 xmlOut.addTextElementToData(
"field", field);
3407 std::set<std::string > uniqueValues =
3409 records, field, &fieldGroupIDChildLinkIndex);
3411 if(fieldGroupIDChildLinkIndex !=
"")
3413 "childLinkIndex", fieldGroupIDChildLinkIndex, parentEl);
3415 for(
auto& uniqueValue : uniqueValues)
3417 __SUP_COUT__ <<
"uniqueValue " << uniqueValue << __E__;
3424 catch(std::runtime_error& e)
3426 __SUP_SS__ <<
"Error getting unique field values from path '" << startPath
3427 <<
"' and field list '" << fieldList <<
"!'\n\n"
3428 << e.what() << __E__;
3429 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3430 xmlOut.addTextElementToData(
"Error", ss.str());
3434 __SUP_SS__ <<
"Error getting unique field values from path '" << startPath
3435 <<
"' and field list '" << fieldList <<
"!'\n\n"
3441 catch(
const std::exception& e)
3443 ss <<
"Exception message: " << e.what();
3448 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3449 xmlOut.addTextElementToData(
"Error", ss.str());
3473 void ConfigurationGUISupervisor::handleFillTreeViewXML(
3476 const std::string& groupName,
3478 const std::string& startPath,
3480 bool hideStatusFalse,
3481 const std::string& modifiedTables,
3482 const std::string& filterList,
3483 const std::string& diffGroupName ,
3486 __SUP_COUTT__ <<
"get Tree View: " << groupName <<
"(" << groupKey <<
")" << __E__;
3518 bool doDiff = (diffGroupName !=
"" && !diffGroupKey.
isInvalid());
3523 std::string diffAccumulateErrors;
3531 __SUP_COUT__ <<
"cfgMgr " << activeTable.first <<
"-v" << activeTable.second
3548 __SUP_COUT__ <<
"cfgMgr " << activeTable.first <<
"-v" << activeTable.second
3551 __SUP_COUTT__ <<
"Diff Group tables loaded." << __E__;
3553 *cfgMgr, diffMemberMap, diffGroupName, diffGroupKey);
3554 __SUP_COUTT__ <<
"Diff Group tables copied to local diff config manager."
3558 for(
auto& memberPair : diffMemberMap)
3560 ->setActiveView(memberPair.second);
3562 for(
const auto& lastGroupLoaded : cfgMgr->getLastTableGroups())
3563 __SUP_COUT__ <<
"cfgMgr Last loaded " << lastGroupLoaded.first <<
": "
3564 << lastGroupLoaded.second.first.first <<
"("
3565 << lastGroupLoaded.second.first.second <<
")";
3567 for(
const auto& lastGroupLoaded : diffCfgMgr->getLastTableGroups())
3568 __SUP_COUT__ <<
"diffCfgMgr Last loaded " << lastGroupLoaded.first <<
": "
3569 << lastGroupLoaded.second.first.first <<
"("
3570 << lastGroupLoaded.second.first.second <<
")";
3573 if(diffCfgMgr->getLastTableGroups().size() == 1)
3575 __SUP_COUT__ <<
"Type already loaded to diff = "
3576 << diffCfgMgr->getLastTableGroups().begin()->first << __E__;
3579 auto groupTypeToLoad = ConfigurationManager::GROUP_TYPE_NAME_CONTEXT;
3580 if(diffCfgMgr->getLastTableGroups().begin()->first ==
3581 ConfigurationManager::GROUP_TYPE_NAME_CONTEXT)
3582 groupTypeToLoad = ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION;
3583 else if(diffCfgMgr->getLastTableGroups().begin()->first ==
3584 ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION)
3585 groupTypeToLoad = ConfigurationManager::GROUP_TYPE_NAME_CONTEXT;
3588 <<
"Loading " << groupTypeToLoad
3589 << cfgMgr->getLastTableGroups().at(groupTypeToLoad).first.first <<
"("
3590 << cfgMgr->getLastTableGroups().at(groupTypeToLoad).first.second
3595 cfgMgr->getLastTableGroups().at(groupTypeToLoad).second,
3596 cfgMgr->getLastTableGroups().at(groupTypeToLoad).first.first,
3597 cfgMgr->getLastTableGroups().at(groupTypeToLoad).first.second);
3600 for(
auto& memberPair :
3601 cfgMgr->getLastTableGroups().at(groupTypeToLoad).second)
3603 ->setActiveView(memberPair.second);
3611 __SUP_COUTT__ <<
"cfgMgr " << activeTable.first <<
"-v" << activeTable.second
3614 __SUP_COUTT__ <<
"diffCfgMgr " << activeTable.first <<
"-v"
3615 << activeTable.second << __E__;
3617 __SUP_COUTT__ <<
"Diff Group tables are setup: " << diffAccumulateErrors << __E__;
3622 bool usingActiveGroups = (groupName ==
"" || groupKey.
isInvalid());
3625 std::string accumulatedErrors =
"";
3626 setupActiveTablesXML(
3639 if(memberMap.size() > ConfigurationManager::getFixedContextMemberNames().size() +
3641 && startPath ==
"/")
3643 __COUTT__ <<
"Checking for orphaned tables..." << __E__;
3646 std::set<std::string > linkingTables;
3651 __COUTS__(30) <<
"Table " << tableInfo.first << __E__;
3652 if(!tableInfo.second.tablePtr_->isActive())
3655 __COUTS__(30) <<
"Table active " << tableInfo.first << __E__;
3657 const TableView& view = tableInfo.second.tablePtr_->getView();
3659 bool addedThisTable =
false;
3660 for(
unsigned int col = 0; col < view.getNumberOfColumns(); ++col)
3662 if(!view.getColumnInfo(col).isChildLink())
3665 __COUTS__(30) <<
"Table " << tableInfo.first
3666 <<
" col: " << view.getColumnInfo(col).getName() << __E__;
3668 for(
unsigned int r = 0; r < view.getNumberOfRows(); ++r)
3670 if(view.getDataView()[r][col] ==
"" ||
3671 view.getDataView()[r][col] ==
3672 TableViewColumnInfo::DATATYPE_STRING_DEFAULT)
3677 linkingTables.emplace(tableInfo.first);
3678 addedThisTable =
true;
3680 linkingTables.emplace(
3681 view.getDataView()[r][col]);
3687 std::string missingTables =
"";
3688 for(
const auto& member : memberMap)
3691 if(linkingTables.find(member.first) != linkingTables.end())
3694 if(missingTables.size())
3695 missingTables +=
", ";
3696 missingTables += member.first;
3699 if(missingTables.size())
3701 __COUTV__(missingTables);
3702 std::stringstream ss;
3703 ss <<
"The following member tables of table group '" << groupName <<
"("
3705 <<
")' were identified as possibly orphaned (i.e. no active tables link "
3706 "to these tables, and these tables have no links to other tables):\n\n"
3707 << missingTables <<
".\n"
3709 xmlOut.addTextElementToData(
"NoTreeLinkWarning", ss.str());
3713 if(accumulatedErrors !=
"")
3715 xmlOut.addTextElementToData(
"Warning", accumulatedErrors);
3717 __SUP_COUT__ <<
"Active tables are setup. Warning string: '" << accumulatedErrors
3720 __SUP_COUT__ <<
"Active table versions: "
3725 __SUP_COUTT__ <<
"Active tables are setup. No issues found." << __E__;
3726 __SUP_COUTT__ <<
"Active table versions: "
3732 xercesc::DOMElement* parentEl = xmlOut.addTextElementToData(
"tree", startPath);
3737 std::vector<std::pair<std::string, ConfigurationTree>> rootMap;
3738 std::map<std::string, ConfigurationTree> diffRootMap;
3740 if(startPath ==
"/")
3744 std::string accumulateTreeErrs;
3746 if(usingActiveGroups)
3747 rootMap = cfgMgr->
getChildren(0, &accumulateTreeErrs);
3749 rootMap = cfgMgr->
getChildren(&memberMap, &accumulateTreeErrs);
3754 diffCfgMgr->
getChildrenMap(&diffMemberMap, &diffAccumulateErrors);
3755 __SUP_COUTV__(diffRootMap.size());
3756 for(
auto& diffChild : diffRootMap)
3757 __SUP_COUTV__(diffChild.first);
3760 __SUP_COUTV__(accumulateTreeErrs);
3762 if(accumulateTreeErrs !=
"")
3763 xmlOut.addTextElementToData(
"TreeErrors", accumulateTreeErrs);
3768 cfgMgr->
getNode(startPath,
true );
3771 xmlOut.addTextElementToData(
"DisconnectedStartNode",
"1");
3776 std::map<std::string , std::string > filterMap;
3780 std::set<char>({
';'}) ,
3781 std::set<char>({
'='}) );
3795 __SUP_COUTT__ <<
"Diff Group disconnected node." << __E__;
3800 catch(
const std::runtime_error& e)
3803 __SUP_COUTT__ <<
"Diff Group node does not exist." << __E__;
3810 for(
auto& treePair : rootMap)
3812 treePair.second, depth - 1, xmlOut, parentEl, hideStatusFalse);
3816 __SUP_COUTT__ <<
"Diff Tree recursive handling." << __E__;
3819 std::set<std::string > rootMapToSearch;
3820 for(
const auto& rootMember : rootMap)
3821 rootMapToSearch.emplace(rootMember.first);
3823 std::stringstream rootSs;
3824 for(
const auto& rootMember : rootMap)
3825 rootSs <<
", " << rootMember.first;
3828 std::stringstream diffRootSs;
3829 for(
const auto& diffMember : diffRootMap)
3831 diffRootSs <<
", " << diffMember.first <<
":"
3832 << diffMember.second.getNodeType();
3833 if(rootMapToSearch.find(diffMember.first) ==
3837 std::stringstream missingSs;
3838 missingSs << diffMember.first <<
3840 " <<< Only in " << diffGroupName <<
"(" << diffGroupKey
3843 "diffNodeMissing", missingSs.str(), parentEl);
3846 if(diffMember.second.getNodeType() ==
"UIDLinkNode")
3857 __SUP_COUTT__ <<
"diff map " << diffRootSs.str() << __E__;
3858 __SUP_COUTT__ <<
"root map " << rootSs.str() << __E__;
3860 __SUP_COUTT__ <<
"\t\t" << diffMember.second.getValueName() <<
": "
3861 << diffMember.second.getValueAsString() << __E__;
3863 __SUP_COUTT__ << diffMember.second.nodeDump();
3867 __SUP_COUTT__ <<
"diff map " << diffRootSs.str() << __E__;
3868 __SUP_COUTT__ <<
"root map " << rootSs.str() << __E__;
3871 for(
auto& treePair : rootMap)
3873 if(diffRootMap.find(treePair.first) == diffRootMap.end())
3875 __SUP_COUTT__ <<
"Diff Tree recursive handling... " << treePair.first
3888 __SUP_COUTT__ <<
"Diff Tree recursive handling... " << treePair.first
3890 recursiveTreeToXML(treePair.second,
3895 diffRootMap.at(treePair.first));
3900 catch(std::runtime_error& e)
3902 __SUP_SS__ <<
"Error detected generating XML tree!\n\n " << e.what() << __E__;
3903 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3904 xmlOut.addTextElementToData(
"Error", ss.str());
3908 __SUP_SS__ <<
"Error detected generating XML tree!" << __E__;
3913 catch(
const std::exception& e)
3915 ss <<
"Exception message: " << e.what();
3920 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3921 xmlOut.addTextElementToData(
"Error", ss.str());
3931 void ConfigurationGUISupervisor::recursiveTreeToXML(
3935 xercesc::DOMElement* parentEl,
3936 bool hideStatusFalse,
3937 std::optional<std::reference_wrapper<const ConfigurationTree>> diffTree)
3947 if(diffTree.has_value() &&
3948 t.
getValueName() != TableViewColumnInfo::COL_NAME_COMMENT &&
3949 t.
getValueName() != TableViewColumnInfo::COL_NAME_AUTHOR &&
3950 t.
getValueName() != TableViewColumnInfo::COL_NAME_CREATION)
3952 __COUTS__(30) <<
"\t\t diff type " << diffTree->get().getNodeType() << __E__;
3954 if(diffTree->get().isValueNode())
3956 __COUTS__(30) <<
"\t" << diffTree->get().getValueAsString() <<
" ? "
3958 __COUTS__(30) <<
"\t" << diffTree->get().getTableName() <<
"-v"
3959 << diffTree->get().getTableVersion() <<
" ? "
3964 std::stringstream missingSs;
3965 auto diffGroupPair =
3966 diffTree->get().getConfigurationManager()->getGroupOfLoadedTable(
3967 diffTree->get().getTableName());
3968 missingSs <<
"<<< '" << diffTree->get().getValueAsString() <<
"' in "
3969 << diffGroupPair.first <<
"(" << diffGroupPair.second
3976 std::stringstream missingSs;
3978 auto diffGroupPair =
3979 diffTree->get().getConfigurationManager()->getGroupOfLoadedTable(
3981 missingSs <<
"<<< Path not found in " << diffGroupPair.first <<
"("
3982 << diffGroupPair.second <<
") >>>";
3996 if(t.
getValueType() == TableViewColumnInfo::TYPE_FIXED_CHOICE_DATA ||
3997 t.
getValueType() == TableViewColumnInfo::TYPE_BITMAP_DATA)
4002 for(
const auto& choice : choices)
4019 if(diffTree.has_value())
4021 __COUTS__(30) <<
"\t\t diff type " << diffTree->get().getNodeType()
4028 std::stringstream missingSs;
4030 auto diffGroupPair =
4031 diffTree->get().getConfigurationManager()->getGroupOfLoadedTable(
4033 missingSs <<
"<<< Path not found in " << diffGroupPair.first <<
"("
4034 << diffGroupPair.second <<
") >>>";
4039 __COUTS__(30) <<
"\t\t diff isDisconnected "
4040 << diffTree->get().isDisconnected() << __E__;
4042 std::stringstream missingSs;
4044 auto diffGroupPair =
4045 diffTree->get().getConfigurationManager()->getGroupOfLoadedTable(
4047 missingSs <<
"<<< Link is "
4048 << (diffTree->get().isDisconnected() ?
"DISCONNECTED"
4050 <<
" in " << diffGroupPair.first <<
"("
4051 << diffGroupPair.second <<
") >>>";
4058 std::stringstream missingSs;
4060 auto diffGroupPair =
4061 diffTree->get().getConfigurationManager()->getGroupOfLoadedTable(
4063 missingSs <<
"<<< Link is "
4064 << (diffTree->get().isUIDLinkNode() ?
"a UID Link"
4066 <<
" in " << diffGroupPair.first <<
"("
4067 << diffGroupPair.second <<
") >>>";
4072 diffTree->get().getValueAsString())
4075 std::stringstream missingSs;
4077 auto diffGroupPair =
4078 diffTree->get().getConfigurationManager()->getGroupOfLoadedTable(
4080 missingSs <<
"<<< Link to '" << diffTree->get().getValueAsString()
4081 <<
"' in " << diffGroupPair.first <<
"("
4082 << diffGroupPair.second <<
") >>>";
4088 std::stringstream missingSs;
4091 auto dtchildren = diffTree->get().getChildrenMap();
4092 missingSs <<
"<<< Group link";
4093 if(tchildren.size() != dtchildren.size())
4094 missingSs <<
" has " << tchildren.size() <<
" vs "
4095 << dtchildren.size() <<
" children..";
4096 for(
auto& tchild : tchildren)
4097 if(dtchildren.find(tchild.first) == dtchildren.end())
4098 missingSs <<
" '" << tchild.first <<
"' missing..";
4099 for(
auto& dtchild : dtchildren)
4100 if(tchildren.find(dtchild.first) == tchildren.end())
4101 missingSs <<
" '" << dtchild.first <<
"' present...";
4104 if(missingSs.str().length() > std::string(
"<<< Group link").length())
4106 auto diffGroupPair =
4108 .getConfigurationManager()
4109 ->getGroupOfLoadedTable(diffTree->get().getTableName());
4110 missingSs <<
" in " << diffGroupPair.first <<
"("
4111 << diffGroupPair.second <<
") >>>";
4113 "nodeDiff", missingSs.str(), parentEl);
4141 xercesc::DOMElement* choicesParentEl =
4147 __COUTS__(30) <<
"choices.size() " << choices.size() << __E__;
4149 for(
const auto& choice : choices)
4171 xercesc::DOMElement* choicesParentEl =
4175 for(
const auto& choice : choices)
4182 bool returnNode =
true;
4196 "nodeStatus", t.
isEnabled() ?
"1" :
"0", parentEl);
4199 if(diffTree.has_value())
4202 <<
"\t\t diff type " << diffTree->get().getNodeType() << __E__;
4211 auto diffGroupPair =
4213 .getConfigurationManager()
4215 missingSs <<
"<<< Not in " << diffGroupPair.first <<
"("
4216 << diffGroupPair.second <<
") >>>";
4218 "nodeDiff", missingSs.str(), parentEl);
4252 void ConfigurationGUISupervisor::handleGetLinkToChoicesXML(
4255 const std::string& linkToTableName,
4257 const std::string& linkIdType,
4258 const std::string& linkIndex,
4259 const std::string& linkInitId)
4272 const std::string& tableName = linkToTableName;
4277 table->setActiveView(version);
4281 __SUP_COUT__ <<
"Failed to find stored version, so attempting to load version: "
4282 << version << __E__;
4286 if(version != table->getViewVersion())
4288 __SUP_SS__ <<
"Target table version (" << version
4289 <<
") is not the currently active version (" << table->getViewVersion()
4290 <<
". Try refreshing the tree." << __E__;
4291 __SUP_COUT_WARN__ << ss.str();
4295 __SUP_COUT__ <<
"Active version is " << table->getViewVersion() << __E__;
4297 if(linkIdType ==
"UID")
4300 unsigned int col = table->getView().getColUID();
4301 for(
unsigned int row = 0; row < table->getView().getNumberOfRows(); ++row)
4302 xmlOut.addTextElementToData(
"linkToChoice",
4303 table->getView().getDataView()[row][col]);
4305 else if(linkIdType ==
"GroupID")
4311 __SUP_COUTV__(linkIndex);
4312 __SUP_COUTV__(linkInitId);
4314 std::set<std::string> setOfGroupIDs =
4315 table->getView().getSetOfGroupIDs(linkIndex);
4320 bool foundInitId =
false;
4321 for(
const auto& groupID : setOfGroupIDs)
4323 if(!foundInitId && linkInitId == groupID)
4326 xmlOut.addTextElementToData(
"linkToChoice", groupID);
4330 xmlOut.addTextElementToData(
"linkToChoice", linkInitId);
4333 unsigned int col = table->getView().getColUID();
4334 for(
unsigned int row = 0; row < table->getView().getNumberOfRows(); ++row)
4336 xmlOut.addTextElementToData(
"groupChoice",
4337 table->getView().getDataView()[row][col]);
4338 if(table->getView().isEntryInGroup(row, linkIndex, linkInitId))
4339 xmlOut.addTextElementToData(
"groupMember",
4340 table->getView().getDataView()[row][col]);
4345 __SUP_SS__ <<
"Unrecognized linkIdType '" << linkIdType <<
".'" << __E__;
4349 catch(std::runtime_error& e)
4351 __SUP_SS__ <<
"Error detected saving tree node!\n\n " << e.what() << __E__;
4352 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
4353 xmlOut.addTextElementToData(
"Error", ss.str());
4357 __SUP_SS__ <<
"Error detected saving tree node!\n\n " << __E__;
4362 catch(
const std::exception& e)
4364 ss <<
"Exception message: " << e.what();
4369 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
4370 xmlOut.addTextElementToData(
"Error", ss.str());
4375 void ConfigurationGUISupervisor::handleMergeGroupsXML(
4378 const std::string& groupANameContext,
4380 const std::string& groupBNameContext,
4382 const std::string& groupANameConfig,
4384 const std::string& groupBNameConfig,
4386 const std::string& author,
4387 const std::string& mergeApproach)
4390 __SUP_COUT__ <<
"Merging context group pair " << groupANameContext <<
" ("
4391 << groupAKeyContext <<
") & " << groupBNameContext <<
" ("
4392 << groupBKeyContext <<
") and table group pair " << groupANameConfig
4393 <<
" (" << groupAKeyConfig <<
") & " << groupBNameConfig <<
" ("
4394 << groupBKeyConfig <<
") with approach '" << mergeApproach << __E__;
4410 if(!(mergeApproach ==
"Rename" || mergeApproach ==
"Replace" ||
4411 mergeApproach ==
"Skip"))
4413 __SS__ <<
"Error! Invalid merge approach '" << mergeApproach <<
".'" << __E__;
4417 std::map<std::string ,
TableVersion > memberMapAContext,
4418 memberMapBContext, memberMapAConfig, memberMapBConfig;
4421 bool skippingContextPair =
false;
4422 bool skippingConfigPair =
false;
4423 if(groupANameContext.size() == 0 || groupANameContext[0] ==
' ' ||
4424 groupBNameContext.size() == 0 || groupBNameContext[0] ==
' ')
4426 skippingContextPair =
true;
4427 __SUP_COUTV__(skippingContextPair);
4429 if(groupANameConfig.size() == 0 || groupANameConfig[0] ==
' ' ||
4430 groupBNameConfig.size() == 0 || groupBNameConfig[0] ==
' ')
4432 skippingConfigPair =
true;
4433 __SUP_COUTV__(skippingConfigPair);
4437 if(!skippingContextPair)
4470 if(!skippingConfigPair)
4507 std::map<std::pair<std::string , std::string >,
4511 std::pair<std::string ,
4512 std::pair<std::string , std::string >>,
4514 groupidConversionMap;
4516 std::stringstream mergeReport;
4517 mergeReport <<
"======================================" << __E__;
4519 mergeReport <<
"Merging context group pair " << groupANameContext <<
" ("
4520 << groupAKeyContext <<
") & " << groupBNameContext <<
" ("
4521 << groupBKeyContext <<
") and table group pair " << groupANameConfig
4522 <<
" (" << groupAKeyConfig <<
") & " << groupBNameConfig <<
" ("
4523 << groupBKeyConfig <<
") with approach '" << mergeApproach << __E__;
4524 mergeReport <<
"======================================" << __E__;
4528 for(
unsigned int i = 0; i < 2; ++i)
4530 if(i == 0 && mergeApproach !=
"Rename")
4534 for(
unsigned int j = 0; j < 2; ++j)
4536 if(j == 0 && skippingContextPair)
4538 __COUT__ <<
"Skipping context pair..." << __E__;
4541 else if(j == 1 && skippingConfigPair)
4543 __COUT__ <<
"Skipping table pair..." << __E__;
4548 j == 0 ? memberMapAContext : memberMapAConfig;
4551 j == 0 ? memberMapBContext : memberMapBConfig;
4554 __COUT__ <<
"Context pair..." << __E__;
4556 __COUT__ <<
"Table pair..." << __E__;
4558 __COUT__ <<
"Starting member map B scan." << __E__;
4559 for(
const auto& bkey : memberMapBref)
4561 __SUP_COUTV__(bkey.first);
4563 if(memberMapAref.find(bkey.first) == memberMapAref.end())
4565 mergeReport <<
"\n'" << mergeApproach <<
"'-Missing table '"
4566 << bkey.first <<
"' A=v" << -1 <<
", adding B=v"
4567 << bkey.second << __E__;
4570 memberMapAref[bkey.first] = bkey.second;
4572 else if(memberMapAref[bkey.first] != bkey.second)
4575 __SUP_COUTV__(memberMapAref[bkey.first]);
4576 __SUP_COUTV__(bkey.second);
4581 __SUP_COUT__ <<
"Got table." << __E__;
4585 ->getVersionedTableByName(bkey.first,
4586 memberMapAref[bkey.first])
4592 mergeApproach ==
"Rename"
4593 ? TableBase::MergeApproach::RENAME
4594 : (mergeApproach ==
"Replace"
4595 ? TableBase::MergeApproach::REPLACE
4596 : TableBase::MergeApproach::SKIP),
4598 groupidConversionMap,
4601 table->getTableName() ==
4602 ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME
4608 __SUP_COUTV__(newVersion);
4626 catch(std::runtime_error& e)
4629 <<
"There was an error saving the '"
4630 << table->getTableName()
4631 <<
"' merge result to a persistent table version. "
4632 <<
"Perhaps you can modify this table in one of the "
4633 "groups to resolve this issue, and then re-merge."
4634 << __E__ << e.what();
4638 __SUP_COUTV__(newVersion);
4640 memberMapAref[bkey.first] = newVersion;
4649 if(!skippingContextPair)
4651 __SUP_COUT__ <<
"New context member map complete." << __E__;
4658 "Merger of group " + groupANameContext +
" (" + groupAKeyContext.
toString() +
4659 ") and " + groupBNameContext +
" (" + groupBKeyContext.
toString() +
").");
4662 xmlOut.addTextElementToData(
"ContextGroupName", groupANameContext);
4663 xmlOut.addTextElementToData(
"ContextGroupKey", newKeyContext.
toString());
4665 if(!skippingConfigPair)
4667 __SUP_COUT__ <<
"New table member map complete." << __E__;
4674 "Merger of group " + groupANameConfig +
" (" + groupAKeyConfig.
toString() +
4675 ") and " + groupBNameConfig +
" (" + groupBKeyConfig.
toString() +
").");
4678 xmlOut.addTextElementToData(
"ConfigGroupName", groupANameConfig);
4679 xmlOut.addTextElementToData(
"ConfigGroupKey", newKeyConfig.
toString());
4684 std::string mergeReportBasePath = std::string(__ENV__(
"USER_DATA"));
4685 std::string mergeReportPath =
"/ServiceData/";
4687 mkdir((mergeReportBasePath + mergeReportPath).c_str(), 0755);
4688 mergeReportPath +=
"ConfigurationGUI_mergeReports/";
4690 mkdir((mergeReportBasePath + mergeReportPath).c_str(), 0755);
4693 "merge_" + std::to_string(time(0)) +
"_" + std::to_string(clock()) +
".txt";
4694 __SUP_COUTV__(mergeReportPath);
4696 FILE* fp = fopen((mergeReportBasePath + mergeReportPath).c_str(),
"w");
4699 fprintf(fp,
"%s", mergeReport.str().c_str());
4701 xmlOut.addTextElementToData(
"MergeReportFile",
4702 "/$USER_DATA/" + mergeReportPath);
4705 xmlOut.addTextElementToData(
"MergeReportFile",
"FILE FAILURE");
4709 catch(std::runtime_error& e)
4711 __SUP_SS__ <<
"Error merging context group pair " << groupANameContext <<
" ("
4712 << groupAKeyContext <<
") & " << groupBNameContext <<
" ("
4713 << groupBKeyContext <<
") and table group pair " << groupANameConfig
4714 <<
" (" << groupAKeyConfig <<
") & " << groupBNameConfig <<
" ("
4715 << groupBKeyConfig <<
") with approach '" << mergeApproach <<
"': \n\n"
4716 << e.what() << __E__;
4717 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
4718 xmlOut.addTextElementToData(
"Error", ss.str());
4722 __SUP_SS__ <<
"Unknown error merging context group pair " << groupANameContext <<
" ("
4723 << groupAKeyContext <<
") & " << groupBNameContext <<
" ("
4724 << groupBKeyContext <<
") and table group pair " << groupANameConfig
4725 <<
" (" << groupAKeyConfig <<
") & " << groupBNameConfig <<
" ("
4726 << groupBKeyConfig <<
") with approach '" << mergeApproach <<
".' \n\n";
4731 catch(
const std::exception& e)
4733 ss <<
"Exception message: " << e.what();
4738 __SUP_COUT_ERR__ <<
"\n" << ss.
str() << __E__;
4739 xmlOut.addTextElementToData(
"Error", ss.str());
4744 void ConfigurationGUISupervisor::handleSavePlanCommandSequenceXML(
4747 const std::string& groupName,
4749 const std::string& modifiedTables,
4750 const std::string& author,
4751 const std::string& planName,
4752 const std::string& commandString)
4755 __COUT__ <<
"handleSavePlanCommandSequenceXML " << planName << __E__;
4758 setupActiveTablesXML(xmlOut,
4777 for(
const auto& commandPair : IterateTable::commandToTableMap_)
4778 if(commandPair.second !=
"")
4779 commandTableToEditMap.emplace(std::pair<std::string, TableEditStruct>(
4796 std::string groupName = planName +
"-Plan";
4797 __SUP_COUT__ <<
"Handling commands for group " << groupName << __E__;
4799 unsigned int groupIdCol =
4800 planTable.tableView_->findCol(IterateTable::planTableCols_.GroupID_);
4801 unsigned int cmdTypeCol =
4802 planTable.tableView_->findCol(IterateTable::planTableCols_.CommandType_);
4804 unsigned int targetGroupIdCol =
4805 targetTable.tableView_->findCol(IterateTable::targetCols_.GroupID_);
4806 unsigned int targetTableCol =
4807 targetTable.tableView_->findCol(IterateTable::targetCols_.TargetLink_);
4808 unsigned int targetUIDCol =
4809 targetTable.tableView_->findCol(IterateTable::targetCols_.TargetLinkUID_);
4811 std::string groupLinkIndex =
4812 planTable.tableView_->getColumnInfo(groupIdCol).getChildLinkIndex();
4813 __SUP_COUT__ <<
"groupLinkIndex: " << groupLinkIndex << __E__;
4815 std::pair<
unsigned int ,
unsigned int > commandUidLink;
4818 planTable.tableView_->getChildLink(
4819 planTable.tableView_->findCol(IterateTable::planTableCols_.CommandLink_),
4824 unsigned int cmdRow, cmdCol;
4825 std::string targetGroupName;
4829 std::string targetUID, cmdType;
4831 for(
unsigned int row = 0; row < planTable.tableView_->getNumberOfRows();
4834 targetUID = planTable.tableView_
4835 ->getDataView()[row][planTable.tableView_->getColUID()];
4836 __SUP_COUT__ <<
"targetUID: " << targetUID << __E__;
4839 if(planTable.tableView_->isEntryInGroup(row, groupLinkIndex, groupName))
4841 __SUP_COUT__ <<
"Removing." << __E__;
4845 cmdType = planTable.tableView_->getDataView()[row][cmdTypeCol];
4846 auto cmdTypeTableIt = IterateTable::commandToTableMap_.find(cmdType);
4847 if(cmdTypeTableIt != IterateTable::commandToTableMap_.end() &&
4848 cmdTypeTableIt->second !=
4852 commandTableToEditMap.at(cmdTypeTableIt->second);
4853 cmdRow = cmdTypeTableEdit.tableView_->findRow(
4854 cmdTypeTableEdit.tableView_->getColUID(),
4855 planTable.tableView_
4856 ->getDataView()[row][commandUidLink.second]);
4863 cmdCol = cmdTypeTableEdit.tableView_->findCol(
4864 IterateTable::commandTargetCols_.TargetsLinkGroupID_);
4865 targetGroupName = cmdTypeTableEdit.tableView_
4866 ->getDataView()[cmdRow][cmdCol];
4868 for(
unsigned int trow = 0;
4869 trow < targetTable.tableView_->getNumberOfRows();
4873 if(targetTable.tableView_->isEntryInGroup(
4875 cmdTypeTableEdit.tableView_->getColumnInfo(cmdCol)
4876 .getChildLinkIndex(),
4879 __SUP_COUT__ <<
"Removing target." << __E__;
4881 if(targetTable.tableView_->removeRowFromGroup(
4892 __SUP_COUT__ <<
"No targets." << __E__;
4897 cmdTypeTableEdit.tableView_->deleteRow(cmdRow);
4903 if(planTable.tableView_->removeRowFromGroup(
4904 row, groupIdCol, groupName,
true ))
4913 std::vector<IterateTable::Command> commands;
4918 std::istringstream f(commandString);
4919 std::string commandSubString, paramSubString, paramValue;
4921 while(getline(f, commandSubString,
';'))
4923 __SUP_COUTT__ <<
"commandSubString " << commandSubString << __E__;
4924 std::istringstream g(commandSubString);
4927 while(getline(g, paramSubString,
','))
4929 __SUP_COUTT__ <<
"paramSubString " << paramSubString << __E__;
4932 if(paramSubString !=
"type")
4934 __SUP_SS__ <<
"Invalid command sequence" << __E__;
4938 commands.push_back(IterateTable::Command());
4940 getline(g, paramValue,
',');
4942 __SUP_COUTT__ <<
"paramValue " << paramValue << __E__;
4943 commands.back().type_ = paramValue;
4947 getline(g, paramValue,
',');
4949 __SUP_COUTT__ <<
"paramValue " << paramValue << __E__;
4951 commands.back().params_.emplace(
4952 std::pair<std::string ,
4964 __SUP_COUT__ <<
"commands size " << commands.size() << __E__;
4971 unsigned int row, tgtRow;
4972 unsigned int targetIndex;
4973 std::string targetStr, cmdUID;
4975 for(
auto& command : commands)
4977 __SUP_COUT__ <<
"command " << command.type_ << __E__;
4978 __SUP_COUT__ <<
"table " << IterateTable::commandToTableMap_.at(command.type_)
4982 row = planTable.tableView_->addRow(
4983 author,
true ,
"planCommand");
4984 planTable.tableView_->addRowToGroup(row, groupIdCol, groupName);
4987 planTable.tableView_->setURIEncodedValue(command.type_, row, cmdTypeCol);
4990 planTable.tableView_->setValueAsString(
4991 "1", row, planTable.tableView_->getColStatus());
4994 auto cmdTypeTableIt = IterateTable::commandToTableMap_.find(command.type_);
4995 if(cmdTypeTableIt != IterateTable::commandToTableMap_.end() &&
4996 cmdTypeTableIt->second !=
5000 commandTableToEditMap.at(cmdTypeTableIt->second);
5001 __SUP_COUT__ <<
"table " << cmdTypeTableEdit.tableName_ << __E__;
5006 cmdRow = cmdTypeTableEdit.tableView_->addRow(
5007 author,
true , command.type_ +
"_COMMAND_");
5013 for(
auto& param : command.params_)
5015 __SUP_COUT__ <<
"\t param " << param.first <<
" : " << param.second
5018 if(param.first == IterateTable::targetParams_.Tables_)
5020 __SUP_COUT__ <<
"\t\t found target tables" << __E__;
5021 std::istringstream f(param.second);
5024 while(getline(f, targetStr,
'='))
5026 __SUP_COUT__ <<
"\t\t targetStr = " << targetStr << __E__;
5027 if(!command.targets_.size() ||
5028 command.targets_.back().table_ !=
"")
5030 __SUP_COUT__ <<
"\t\t make targetStr = " << targetStr
5033 command.addTarget();
5034 command.targets_.back().table_ = targetStr;
5037 command.targets_[targetIndex++].table_ = targetStr;
5043 if(param.first == IterateTable::targetParams_.UIDs_)
5045 __SUP_COUT__ <<
"\t\t found target UIDs" << __E__;
5046 std::istringstream f(param.second);
5049 while(getline(f, targetStr,
'='))
5051 __SUP_COUT__ <<
"\t\t targetStr = " << targetStr << __E__;
5052 if(!command.targets_.size() ||
5053 command.targets_.back().UID_ !=
"")
5055 __SUP_COUT__ <<
"\t\t make targetStr = " << targetStr
5058 command.addTarget();
5059 command.targets_.back().UID_ = targetStr;
5062 command.targets_[targetIndex++].UID_ = targetStr;
5067 cmdCol = cmdTypeTableEdit.tableView_->findCol(param.first);
5069 __SUP_COUT__ <<
"param col " << cmdCol << __E__;
5071 cmdTypeTableEdit.tableView_->setURIEncodedValue(
5072 param.second, cmdRow, cmdCol);
5076 cmdTypeTableEdit.tableView_
5077 ->getDataView()[cmdRow][cmdTypeTableEdit.tableView_->getColUID()];
5079 if(command.targets_.size())
5083 __SUP_COUT__ <<
"targets found for command UID=" << cmdUID << __E__;
5086 cmdCol = cmdTypeTableEdit.tableView_->findCol(
5087 IterateTable::commandTargetCols_.TargetsLink_);
5088 cmdTypeTableEdit.tableView_->setValueAsString(
5089 IterateTable::TARGET_TABLE, cmdRow, cmdCol);
5091 cmdCol = cmdTypeTableEdit.tableView_->findCol(
5092 IterateTable::commandTargetCols_.TargetsLinkGroupID_);
5093 cmdTypeTableEdit.tableView_->setValueAsString(
5094 cmdUID +
"_Targets", cmdRow, cmdCol);
5098 for(
const auto& target : command.targets_)
5100 __SUP_COUT__ << target.
table_ <<
" " << target.UID_ << __E__;
5103 tgtRow = targetTable.tableView_->addRow(
5104 author,
true ,
"commandTarget");
5105 targetTable.tableView_->addRowToGroup(
5106 tgtRow, targetGroupIdCol, cmdUID +
"_Targets");
5109 targetTable.tableView_->setValueAsString(
5110 target.table_, tgtRow, targetTableCol);
5113 targetTable.tableView_->setValueAsString(
5114 target.UID_, tgtRow, targetUIDCol);
5119 planTable.tableView_->setValueAsString(
5120 cmdTypeTableEdit.tableName_, row, commandUidLink.first);
5121 planTable.tableView_->setValueAsString(
5122 cmdUID, row, commandUidLink.second);
5124 __SUP_COUT__ <<
"linked to uid = " << cmdUID << __E__;
5134 planTable.tableView_->print();
5135 planTable.tableView_->init();
5137 __SUP_COUT__ <<
"requestType tables:" << __E__;
5139 for(
auto& modifiedConfig : commandTableToEditMap)
5141 __SUP_COUTV__(modifiedConfig.second.modified_);
5142 modifiedConfig.second.tableView_->print();
5143 modifiedConfig.second.tableView_->init();
5146 targetTable.tableView_->print();
5147 targetTable.tableView_->init();
5152 __SUP_COUT__ <<
"Handling command table errors while saving. Erasing all newly "
5158 if(planTable.createdTemporaryVersion_)
5160 __SUP_COUT__ <<
"Erasing temporary version " << planTable.tableName_ <<
"-v"
5161 << planTable.temporaryVersion_ << __E__;
5164 planTable.temporaryVersion_);
5167 if(targetTable.createdTemporaryVersion_)
5169 __SUP_COUT__ <<
"Erasing temporary version " << targetTable.tableName_ <<
"-v"
5170 << targetTable.temporaryVersion_ << __E__;
5173 targetTable.temporaryVersion_);
5176 for(
auto& modifiedConfig : commandTableToEditMap)
5178 if(modifiedConfig.second
5179 .createdTemporaryVersion_)
5181 __SUP_COUT__ <<
"Erasing temporary version "
5182 << modifiedConfig.second.tableName_ <<
"-v"
5183 << modifiedConfig.second.temporaryVersion_ << __E__;
5186 modifiedConfig.second.temporaryVersion_);
5200 planTable.tableName_,
5201 planTable.originalVersion_,
5204 planTable.temporaryVersion_,
5207 __SUP_COUT__ <<
"Final plan version is " << planTable.tableName_ <<
"-v"
5208 << finalVersion << __E__;
5213 targetTable.tableName_,
5214 targetTable.originalVersion_,
5217 targetTable.temporaryVersion_,
5220 __SUP_COUT__ <<
"Final target version is " << targetTable.tableName_ <<
"-v"
5221 << finalVersion << __E__;
5223 for(
auto& modifiedConfig : commandTableToEditMap)
5225 if(!modifiedConfig.second.modified_)
5227 if(modifiedConfig.second
5228 .createdTemporaryVersion_)
5230 __SUP_COUT__ <<
"Erasing unmodified temporary version "
5231 << modifiedConfig.second.tableName_ <<
"-v"
5232 << modifiedConfig.second.temporaryVersion_ << __E__;
5235 modifiedConfig.second.temporaryVersion_);
5243 modifiedConfig.second.tableName_,
5244 modifiedConfig.second.originalVersion_,
5246 modifiedConfig.second.table_,
5247 modifiedConfig.second.temporaryVersion_,
5250 __SUP_COUT__ <<
"Final version is " << modifiedConfig.second.tableName_ <<
"-v"
5251 << finalVersion << __E__;
5254 handleFillModifiedTablesXML(xmlOut, cfgMgr);
5256 catch(std::runtime_error& e)
5258 __SUP_SS__ <<
"Error detected saving Iteration Plan!\n\n " << e.what() << __E__;
5259 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
5260 xmlOut.addTextElementToData(
"Error", ss.str());
5264 __SUP_SS__ <<
"Error detected saving Iteration Plan!\n\n " << __E__;
5269 catch(
const std::exception& e)
5271 ss <<
"Exception message: " << e.what();
5276 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
5277 xmlOut.addTextElementToData(
"Error", ss.str());
5290 void ConfigurationGUISupervisor::handleSaveTreeNodeEditXML(
HttpXmlDocument& xmlOut,
5292 const std::string& tableName,
5294 const std::string& type,
5295 const std::string& uid,
5296 const std::string& colName,
5297 const std::string& newValue,
5298 const std::string& author)
5301 __SUP_COUT__ <<
"Editing table " << tableName <<
"(" << version <<
") uid=" << uid
5302 <<
" type=" << type << __E__;
5312 table->setActiveView(version);
5316 if(version.isTemporaryVersion())
5319 __SUP_COUT__ <<
"Failed to find stored version, so attempting to load version: "
5320 << version << __E__;
5324 __SUP_COUT__ <<
"Active version is " << table->getViewVersion() << __E__;
5325 __SUP_COUTTV__(table->getView().getComment());
5327 if(version != table->getViewVersion())
5329 __SUP_SS__ <<
"Target table version (" << version
5330 <<
") is not the currently active version (" << table->getViewVersion()
5331 <<
"). Try refreshing the tree." << __E__;
5335 unsigned int col = -1;
5336 if(type ==
"uid" || type ==
"delete-uid" || type ==
"tree-copy")
5337 col = table->getView().getColUID();
5338 else if(type ==
"node-comment")
5339 col = table->getView().findCol(TableViewColumnInfo::COL_NAME_COMMENT);
5340 else if(type ==
"link-UID" || type ==
"link-GroupID" || type ==
"value" ||
5341 type ==
"value-groupid" || type ==
"value-bool" || type ==
"value-bitmap")
5342 col = table->getView().findCol(colName);
5343 else if(type ==
"table" || type ==
"link-comment" || type ==
"table-newGroupRow" ||
5344 type ==
"table-newUIDRow" || type ==
"table-newRow")
5348 __SUP_SS__ <<
"Impossible! Unrecognized edit type: " << type << __E__;
5353 if(type ==
"table" || type ==
"link-comment")
5356 if(table->getView().isURIEncodedCommentTheSame(newValue))
5359 <<
"' is the same as the current comment. No need to save change."
5375 TableVersion temporaryVersion = table->createTemporaryView(version);
5377 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion << __E__;
5379 TableView* cfgView = table->getTemporaryView(temporaryVersion);
5382 __SUP_COUTTV__(table->getView().getComment());
5388 if(type ==
"table" || type ==
"link-comment")
5393 else if(type ==
"table-newRow" || type ==
"table-newUIDRow")
5396 unsigned int row = cfgView->
addRow(
5397 author,
true , newValue );
5412 else if(type ==
"table-newGroupRow")
5415 unsigned int csvIndex = newValue.find(
',');
5417 std::string linkIndex = newValue.substr(0, csvIndex);
5418 std::string groupId = newValue.substr(csvIndex + 1);
5421 csvIndex = groupId.find(
',');
5422 std::string newRowUID = groupId.substr(csvIndex + 1);
5423 groupId = groupId.substr(0, csvIndex);
5425 __SUP_COUT__ <<
"newValue " << linkIndex <<
"," << groupId <<
"," << newRowUID
5429 unsigned int row = cfgView->
addRow(author,
5455 else if(type ==
"delete-uid")
5458 unsigned int row = cfgView->
findRow(col, uid);
5461 else if(type ==
"tree-copy")
5464 __COUTV__(newValue);
5465 std::vector<std::string> paramArray =
5469 if(paramArray.size() != 2)
5471 __SS__ <<
"Illegal parameters for tree copy request: must be number of "
5472 "copy instances & depth of copy."
5477 unsigned int row = cfgView->
findRow(col, uid);
5480 unsigned int numberOfInstances = atoi(paramArray[0].c_str());
5481 unsigned int depth = atoi(paramArray[1].c_str());
5483 __COUTV__(numberOfInstances);
5484 if(numberOfInstances > 1000)
5486 __SS__ <<
"Illegal parameters - the maximum number of copy instances is "
5487 "1000. Number of instances provided was "
5488 << numberOfInstances << __E__;
5495 ConfigurationSupervisorBase::recursiveCopyTreeUIDNode(xmlOut,
5504 else if(type ==
"uid" || type ==
"value" || type ==
"value-groupid" ||
5505 type ==
"value-bool" || type ==
"value-bitmap" || type ==
"node-comment")
5511 __SUP_SS__ <<
"Value '" << newValue
5512 <<
"' is the same as the current value. No need to save "
5513 "change to tree node."
5518 else if(type ==
"link-UID" || type ==
"link-GroupID")
5521 std::pair<
unsigned int ,
unsigned int > linkPair;
5525 __SUP_SS__ <<
"Col '" << colName <<
"' is not a link column." << __E__;
5529 __SUP_COUT__ <<
"linkPair " << linkPair.first <<
"," << linkPair.second
5532 std::string linkIndex = cfgView->getColumnInfo(col).getChildLinkIndex();
5534 __SUP_COUT__ <<
"linkIndex " << linkIndex << __E__;
5537 unsigned int csvIndexStart = 0, csvIndex = newValue.find(
',');
5539 std::string newTable = newValue.substr(csvIndexStart, csvIndex);
5540 csvIndexStart = csvIndex + 1;
5541 csvIndex = newValue.find(
',', csvIndexStart);
5542 std::string newLinkId = newValue.substr(
5547 __SUP_COUT__ <<
"newValue " << newTable <<
"," << newLinkId << __E__;
5551 bool changed =
false;
5552 bool needSecondaryChange = (type ==
"link-GroupID");
5557 __SUP_COUT__ <<
"Value '" << newTable
5558 <<
"' is the same as the current value." << __E__;
5566 std::string originalValue = cfgView->
getValueAsString(row, linkPair.second);
5570 __SUP_COUT__ <<
"Value '" << newLinkId
5571 <<
"' is the same as the current value." << __E__;
5576 needSecondaryChange =
5582 if(needSecondaryChange)
5584 bool secondaryChanged =
false;
5585 bool defaultIsInGroup =
5591 __SUP_COUT__ <<
"No changes to primary view. Erasing temporary table."
5593 table->eraseView(temporaryVersion);
5614 catch(std::runtime_error&
5617 __SUP_COUT__ <<
"Caught error while editing main table. Erasing "
5618 "temporary version."
5620 table->eraseView(temporaryVersion);
5624 xmlOut.addTextElementToData(
5626 "Error saving primary tree node! " + std::string(e.what()));
5636 __SUP_COUTV__(newValue);
5637 csvIndexStart = csvIndex + 1;
5638 csvIndex = newValue.find(
',', csvIndexStart);
5640 csvIndexStart, csvIndex - csvIndexStart));
5643 if(newTable == TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
5654 table->setActiveView(version);
5658 if(version.isTemporaryVersion())
5661 __SUP_COUT__ <<
"Failed to find stored version, so attempting to "
5663 << newTable <<
" v" << version << __E__;
5667 __SUP_COUT__ << newTable <<
" active version is "
5668 << table->getViewVersion() << __E__;
5670 if(version != table->getViewVersion())
5673 if(version.isMockupVersion())
5674 ss <<
"Target table '" << newTable
5675 <<
"' is likely not a member of the current table group "
5676 <<
"since the mock-up version was not successfully loaded. "
5681 "To add a table to a group, click the group name to go to "
5683 "group view, then click 'Add/Remove/Modify Member Tables.' "
5685 "can then add or remove tables and save the new group." +
5687 "OR!!! Click the following button to add the table '" +
5689 "' to the currently active Configuration Group: " +
5690 "<input type='button' style='color:black !important;' " +
5691 "title='Click to add table to the active Configuration "
5693 "onclick='addTableToConfigurationGroup(\"" + newTable +
5694 "\"); Debug.closeErrorPop();event.stopPropagation();' "
5695 "value='Add Table'>" +
5699 ss <<
"Target table version (" << version
5700 <<
") is not the currently active version ("
5701 << table->getViewVersion() <<
"). Try refreshing the tree."
5707 temporaryVersion = table->createTemporaryView(version);
5709 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion << __E__;
5711 cfgView = table->getTemporaryView(temporaryVersion);
5715 if(type ==
"link-UID")
5725 __SUP_COUT__ <<
"target col " << col << __E__;
5727 unsigned int row = -1;
5730 row = cfgView->
findRow(col, newLinkId);
5735 if(row == (
unsigned int)-1)
5737 __SUP_COUT__ <<
"New link UID '" << newLinkId
5738 <<
"' was not found, so attempting to change UID of "
5740 << originalValue <<
"'" << __E__;
5743 row = cfgView->
findRow(col, originalValue);
5746 secondaryChanged =
true;
5747 __SUP_COUT__ <<
"Original target record '"
5748 << originalValue <<
"' was changed to '"
5749 << newLinkId <<
"'" << __E__;
5754 __SUP_COUT__ <<
"Original target record '" << originalValue
5755 <<
"' not found." << __E__;
5759 else if(type ==
"link-GroupID")
5767 __SUP_COUT__ <<
"target col " << col << __E__;
5770 std::vector<std::string> memberUIDs;
5773 csvIndexStart = csvIndex + 1;
5774 csvIndex = newValue.find(
',', csvIndexStart);
5775 memberUIDs.push_back(
5776 newValue.substr(csvIndexStart, csvIndex - csvIndexStart));
5777 __SUP_COUT__ <<
"memberUIDs: " << memberUIDs.back() << __E__;
5779 (
unsigned int)std::string::npos);
5789 std::string targetUID;
5790 bool shouldBeInGroup;
5793 for(
unsigned int row = 0; row < cfgView->getNumberOfRows(); ++row)
5795 targetUID = cfgView->getDataView()[row][cfgView->
getColUID()];
5796 __SUP_COUT__ <<
"targetUID: " << targetUID << __E__;
5798 shouldBeInGroup =
false;
5799 for(
unsigned int i = 0; i < memberUIDs.size(); ++i)
5800 if(targetUID == memberUIDs[i])
5803 shouldBeInGroup =
true;
5810 if(shouldBeInGroup && !isInGroup)
5812 __SUP_COUT__ <<
"Changed to YES: " << row << __E__;
5813 secondaryChanged =
true;
5818 else if(!shouldBeInGroup && isInGroup)
5820 __SUP_COUT__ <<
"Changed to NO: " << row << __E__;
5821 secondaryChanged =
true;
5825 else if(targetUID ==
5827 ->getDefaultRowValues()[cfgView->
getColUID()] &&
5831 defaultIsInGroup =
true;
5837 if(!secondaryChanged)
5840 <<
"No changes to secondary view. Erasing temporary table."
5842 table->eraseView(temporaryVersion);
5863 catch(std::runtime_error&
5866 __SUP_COUT__ <<
"Caught error while editing secondary table. "
5867 "Erasing temporary version."
5869 table->eraseView(temporaryVersion);
5870 secondaryChanged =
false;
5873 xmlOut.addTextElementToData(
5875 "Error saving secondary tree node! " + std::string(e.what()));
5883 if(0 && !changed && !secondaryChanged && !defaultIsInGroup)
5885 __SUP_SS__ <<
"Link to table '" << newTable <<
"', linkID '"
5887 <<
"', and selected group members are the same as the "
5889 <<
"No need to save changes to tree." << __E__;
5895 else if(0 && !changed)
5900 __SUP_SS__ <<
"Link to table '" << newTable <<
"' and linkID '"
5902 <<
"' are the same as the current values. No need to save "
5903 "change to tree node."
5913 __SUP_COUT__ <<
"Caught error while editing. Erasing temporary version." << __E__;
5914 table->eraseView(temporaryVersion);
5928 catch(std::runtime_error& e)
5930 __SUP_SS__ <<
"Error saving tree node! " << e.what() << __E__;
5931 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
5932 xmlOut.addTextElementToData(
"Error", ss.str());
5936 __SUP_SS__ <<
"Unknown Error saving tree node! " << __E__;
5941 catch(
const std::exception& e)
5943 ss <<
"Exception message: " << e.what();
5948 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
5949 xmlOut.addTextElementToData(
"Error", ss.str());
5993 void ConfigurationGUISupervisor::handleGetTableXML(
HttpXmlDocument& xmlOut,
5995 const std::string& tableName,
5997 bool allowIllegalColumns ,
5999 bool descriptionOnly )
6002 char tmpIntStr[100];
6003 xercesc::DOMElement *parentEl, *subparentEl;
6005 std::string accumulatedErrors =
"";
6007 if(allowIllegalColumns)
6008 xmlOut.addTextElementToData(
"allowIllegalColumns",
"1");
6010 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo(
6011 allowIllegalColumns ,
6012 allowIllegalColumns ? &accumulatedErrors : 0,
6021 xmlOut.addTextElementToData(
"ExistingTableNames",
6022 TableViewColumnInfo::DATATYPE_LINK_DEFAULT);
6023 for(
auto& configPair : allTableInfo)
6025 xmlOut.addTextElementToData(
"ExistingTableNames", configPair.first);
6026 if(configPair.first == tableName &&
6027 configPair.second.versions_.find(version) ==
6028 configPair.second.versions_.end())
6030 __SUP_COUT__ <<
"Version not found, so using mockup." << __E__;
6036 xmlOut.addTextElementToData(
"TableName", tableName);
6037 xmlOut.addTextElementToData(
"TableDescription",
6038 table->getTableDescription());
6055 for(
const auto& aliases : versionAliases)
6056 for(
const auto& alias : aliases.second)
6057 __SUP_COUTT__ <<
"ALIAS: " << aliases.first <<
" " << alias.first
6058 <<
" ==> " << alias.second << __E__;
6060 catch(
const std::runtime_error& e)
6062 __SUP_COUT__ <<
"Could not get backbone information for version aliases: "
6063 << e.what() << __E__;
6066 auto tableIterator = versionAliases.find(tableName);
6068 parentEl = xmlOut.addTextElementToData(
"TableVersions",
"");
6071 for(
const TableVersion& v : allTableInfo.at(tableName).versions_)
6077 std::vector<std::string> aliases;
6078 if(tableIterator != versionAliases.end())
6081 for(
const auto& aliasPair : tableIterator->second)
6083 if(v == aliasPair.second)
6085 __SUP_COUT__ <<
"Found Alias " << aliasPair.second <<
" --> "
6086 << aliasPair.first << __E__;
6087 aliases.push_back(aliasPair.first);
6095 __SUP_COUT__ <<
"Handling version w/aliases" << __E__;
6098 TableVersion::INVALID)
6103 else if(hi.
version() + 1 == v.version())
6110 if(lo.
version() != TableVersion::INVALID)
6120 if(versionAliases.size())
6124 for(
const auto& alias : aliases)
6126 hi = lo = TableVersion::INVALID;
6131 if(lo.
version() != TableVersion::INVALID)
6145 if(version.isInvalid())
6147 tableViewPtr = table->getMockupViewP();
6155 std::string localAccumulatedErrors =
"";
6160 allowIllegalColumns ,
6161 &localAccumulatedErrors,
6167 xmlOut.addTextElementToData(
"TableRawData",
6168 tableViewPtr->getSourceRawData());
6170 const std::set<std::string>& srcColNames =
6171 tableViewPtr->getSourceColumnNames();
6172 for(
auto& srcColName : srcColNames)
6173 xmlOut.addTextElementToData(
"ColumnHeader", srcColName);
6175 if(!version.isTemporaryVersion())
6180 tableViewPtr = cfgMgr
6184 allowIllegalColumns ,
6185 &localAccumulatedErrors,
6191 if(localAccumulatedErrors !=
"")
6192 xmlOut.addTextElementToData(
"Error", localAccumulatedErrors);
6194 catch(std::runtime_error& e)
6196 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version " << version
6197 <<
"... defaulting to mock-up! " << __E__;
6198 ss <<
"\n\n...Here is why it failed:\n\n" << e.what() << __E__;
6200 __SUP_COUT_ERR__ <<
"\n" << ss.str();
6202 tableViewPtr = table->getMockupViewP();
6204 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
6208 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version: " << version
6209 <<
"... defaulting to mock-up! "
6210 <<
"(You may want to try again to see what was partially loaded "
6211 "into cache before failure. "
6212 <<
"If you think, the failure is due to a column name change, "
6213 <<
"you can also try to Copy the failing view to the new column "
6215 <<
"'Copy and Move' functionality.)" << __E__;
6220 catch(
const std::exception& e)
6222 ss <<
"Exception message: " << e.what();
6228 __SUP_COUT_ERR__ <<
"\n" << ss.str();
6230 tableViewPtr = table->getMockupViewP();
6232 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
6235 xmlOut.addTextElementToData(
"TableVersion", version.toString());
6241 xercesc::DOMElement* choicesParentEl;
6242 parentEl = xmlOut.addTextElementToData(
"CurrentVersionColumnHeaders",
"");
6244 std::vector<TableViewColumnInfo> colInfo = tableViewPtr->getColumnsInfo();
6246 for(
int i = 0; i < (int)colInfo.size(); ++i)
6251 "ColumnDataType", colInfo[i].getDataType(), parentEl);
6256 "ColumnDefaultValue", colInfo[i].getDefaultValue(), parentEl);
6260 if(colInfo[i].getType() == TableViewColumnInfo::TYPE_FIXED_CHOICE_DATA ||
6261 colInfo[i].getType() == TableViewColumnInfo::TYPE_BITMAP_DATA ||
6262 colInfo[i].isChildLink())
6264 for(
auto& choice : colInfo[i].getDataChoices())
6269 "ColumnMinValue", colInfo[i].getMinValue(), parentEl);
6271 "ColumnMaxValue", colInfo[i].getMaxValue(), parentEl);
6277 if(version.isInvalid())
6278 tableViewPtr->
init();
6280 catch(std::runtime_error& e)
6283 __THROW__(e.what() + std::string(
"\n\n") + accumulatedErrors);
6290 parentEl = xmlOut.addTextElementToData(
"CurrentVersionRows",
"");
6292 for(
int r = 0; r < (int)tableViewPtr->getNumberOfRows(); ++r)
6294 sprintf(tmpIntStr,
"%d", r);
6295 xercesc::DOMElement* tmpParentEl =
6298 for(
int c = 0; c < (int)tableViewPtr->getNumberOfColumns(); ++c)
6300 if(colInfo[c].getDataType() == TableViewColumnInfo::DATATYPE_TIME)
6302 std::string timeAsString;
6303 tableViewPtr->
getValue(timeAsString, r, c);
6308 "Entry", tableViewPtr->getDataView()[r][c], tmpParentEl);
6313 xmlOut.addTextElementToData(
"TableComment", tableViewPtr->getComment());
6314 xmlOut.addTextElementToData(
"TableAuthor", tableViewPtr->getAuthor());
6315 xmlOut.addTextElementToData(
"TableCreationTime",
6316 std::to_string(tableViewPtr->getCreationTime()));
6317 xmlOut.addTextElementToData(
"TableLastAccessTime",
6318 std::to_string(tableViewPtr->getLastAccessTime()));
6323 std::vector<std::string> defaultRowValues =
6324 table->getMockupViewP()->getDefaultRowValues();
6326 for(
unsigned int c = 0; c < defaultRowValues.size() - 2; ++c)
6328 xmlOut.addTextElementToData(
"DefaultRowValue", defaultRowValues[c]);
6331 const std::set<std::string> srcColNames = tableViewPtr->getSourceColumnNames();
6333 if(accumulatedErrors !=
"")
6335 __SUP_SS__ << (std::string(
"Column errors were allowed for this request, so "
6336 "perhaps you can ignore this, ") +
6337 "but please note the following warnings:\n" + accumulatedErrors)
6339 __SUP_COUT_ERR__ << ss.str();
6340 xmlOut.addTextElementToData(
"TableWarnings", ss.str());
6342 else if(!version.isTemporaryVersion() &&
6344 (srcColNames.size() != tableViewPtr->getNumberOfColumns() ||
6345 tableViewPtr->getSourceColumnMismatch() !=
6348 __SUP_SS__ <<
"\n\nThere were warnings found when loading the table " << tableName
6349 <<
":v" << version <<
". Please see the details below:\n\n"
6350 << tableViewPtr->getMismatchColumnInfo();
6352 __SUP_COUT__ <<
"\n" << ss.str();
6353 xmlOut.addTextElementToData(
"TableWarnings", ss.str());
6357 catch(std::runtime_error& e)
6359 __SUP_SS__ <<
"Error getting table view!\n\n " << e.what() << __E__;
6360 __SUP_COUT_ERR__ << ss.str();
6361 xmlOut.addTextElementToData(
"Error", ss.str());
6365 __SUP_SS__ <<
"Error getting table view!\n\n " << __E__;
6370 catch(
const std::exception& e)
6372 ss <<
"Exception message: " << e.what();
6377 __SUP_COUT_ERR__ << ss.str();
6378 xmlOut.addTextElementToData(
"Error", ss.str());
6389 std::string username,
bool refresh)
6391 uint64_t sessionIndex =
6394 std::stringstream ssMapKey;
6395 ssMapKey << username <<
":" << sessionIndex;
6396 std::string mapKey = ssMapKey.str();
6397 __SUP_COUTT__ <<
"Using Config Session " << mapKey
6398 <<
" ... Total Session Count: " << userConfigurationManagers_.size()
6399 <<
" refresh=" << refresh << __E__;
6401 time_t now = time(0);
6407 for(
auto& pair : userConfigurationManagers_)
6408 __SUP_COUTTV__(pair.first);
6411 const std::string preLoadCfgMgrName =
":0";
6412 if(userConfigurationManagers_.size() == 1 &&
6413 userConfigurationManagers_.find(preLoadCfgMgrName) !=
6414 userConfigurationManagers_.end())
6416 __SUP_COUT__ <<
"Using pre-loaded Configuration Manager. time=" << time(0) <<
" "
6417 << clock() <<
" Setting author from "
6418 << userConfigurationManagers_.at(preLoadCfgMgrName)->getUsername()
6419 <<
" to " << username << __E__;
6420 userConfigurationManagers_[mapKey] =
6421 userConfigurationManagers_.at(preLoadCfgMgrName);
6422 userLastUseTime_[mapKey] = userLastUseTime_.at(preLoadCfgMgrName);
6424 userConfigurationManagers_.at(mapKey)->setUsername(username);
6427 if(userConfigurationManagers_.find(mapKey) == userConfigurationManagers_.end())
6429 __SUP_COUT__ <<
"Creating new Configuration Manager. time=" << time(0) <<
" "
6430 << clock() << __E__;
6436 userConfigurationManagers_[mapKey]->getAllTableInfo(
6444 else if(userLastUseTime_.find(mapKey) == userLastUseTime_.end())
6446 __SUP_SS__ <<
"Fatal error managing user sessions! Check the logs for "
6447 "Configuration Interface failure."
6449 __SUP_COUT_ERR__ <<
"\n" << ss.str();
6454 (now - userLastUseTime_[mapKey]) >
6455 CONFIGURATION_MANAGER_REFRESH_THRESHOLD)
6457 __SUP_COUT__ <<
"Refreshing all table info." << __E__;
6458 userConfigurationManagers_[mapKey]->getAllTableInfo(
6466 __SUP_COUTT__ <<
"Configuration Manager for author="
6467 << userConfigurationManagers_[mapKey]->getUsername()
6468 <<
" ready. time=" << time(0) <<
" " << clock() <<
" runTimeSeconds()="
6469 << userConfigurationManagers_[mapKey]->runTimeSeconds() << __E__;
6472 userLastUseTime_[mapKey] = now;
6475 for(std::map<std::string, time_t>::iterator it = userLastUseTime_.begin();
6476 it != userLastUseTime_.end();
6478 if(now - it->second > CONFIGURATION_MANAGER_EXPIRATION_TIME)
6480 __SUP_COUT__ << now <<
":" << it->second <<
" = " << now - it->second
6482 delete userConfigurationManagers_[it->first];
6483 if(!(userConfigurationManagers_.erase(it->first)))
6485 __SUP_SS__ <<
"Fatal error erasing configuration manager by key!"
6487 __SUP_COUT_ERR__ <<
"\n" << ss.str();
6490 userLastUseTime_.erase(it);
6497 return userConfigurationManagers_[mapKey];
6505 void ConfigurationGUISupervisor::handleDeleteTableInfoXML(
HttpXmlDocument& xmlOut,
6507 std::string& tableName)
6509 if(0 == rename((TABLE_INFO_PATH + tableName + TABLE_INFO_EXT).c_str(),
6510 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused").c_str()))
6511 __SUP_COUT_INFO__ << (
"Table Info File successfully renamed: " +
6512 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused"))
6516 __SUP_COUT_ERR__ << (
"Error renaming file to " +
6517 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused"))
6520 xmlOut.addTextElementToData(
6522 (
"Error renaming Table Info File to " +
6523 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused")));
6538 void ConfigurationGUISupervisor::handleSaveTableInfoXML(
6541 std::string& tableName,
6542 const std::string& data,
6543 const std::string& tableDescription,
6544 const std::string& columnChoicesCSV,
6545 bool allowOverwrite)
6549 std::string capsName;
6554 catch(std::runtime_error& e)
6556 xmlOut.addTextElementToData(
"Error", e.what());
6562 FILE* fp = fopen((TABLE_INFO_PATH + tableName + TABLE_INFO_EXT).c_str(),
"r");
6566 xmlOut.addTextElementToData(
"TableName", tableName);
6567 xmlOut.addTextElementToData(
"OverwriteError",
"1");
6568 xmlOut.addTextElementToData(
6570 "File already exists! ('" +
6571 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT) +
"')");
6576 __SUP_COUT__ <<
"capsName=" << capsName << __E__;
6577 __SUP_COUT__ <<
"tableName=" << tableName << __E__;
6578 __SUP_COUT__ <<
"tableDescription=" << tableDescription << __E__;
6579 __SUP_COUT__ <<
"columnChoicesCSV=" << columnChoicesCSV << __E__;
6582 std::stringstream outss;
6584 outss <<
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n";
6585 outss <<
"\t<ROOT xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
6586 "xsi:noNamespaceSchemaLocation=\"TableInfo.xsd\">\n";
6587 outss <<
"\t\t<TABLE Name=\"" << tableName <<
"\">\n";
6588 outss <<
"\t\t\t<VIEW Name=\"" << capsName
6589 <<
"\" Type=\"File,Database,DatabaseTest\" Description=\"" << tableDescription
6595 std::istringstream columnChoicesISS(columnChoicesCSV);
6596 std::string columnChoicesString;
6597 std::string columnDefaultValue, columnMinValue, columnMaxValue;
6598 std::vector<std::string> columnParameters;
6599 std::vector<std::string> columnData =
6602 for(
unsigned int c = 0; c < columnData.size() - 1; ++c)
6606 __COUT__ <<
"Column #" << c <<
": "
6608 for(
unsigned int p = 0; p < columnParameters.size(); ++p)
6610 __COUT__ <<
"\t Parameter #" << p <<
": " << columnParameters[p] << __E__;
6612 __COUT__ <<
"\t creating the new xml" << __E__;
6614 std::string& columnType = columnParameters[0];
6615 std::string& columnName = columnParameters[1];
6616 std::string& columnDataType = columnParameters[2];
6617 const std::string columnStorageName =
6620 outss <<
"\t\t\t\t<COLUMN Type=\"";
6621 outss << columnType;
6622 outss <<
"\" \t Name=\"";
6623 outss << columnName;
6624 outss <<
"\" \t StorageName=\"";
6627 outss << columnStorageName;
6629 catch(std::runtime_error& e)
6631 xmlOut.addTextElementToData(
6633 std::string(
"For column name '") + columnName +
"' - " + e.what());
6636 outss <<
"\" \t DataType=\"";
6637 outss << columnDataType;
6641 std::string* columnDefaultValuePtr =
nullptr;
6642 if(columnDefaultValue !=
6645 __SUP_COUT__ <<
"FOUND user spec'd default value '" << columnDefaultValue
6647 outss <<
"\" \t DefaultValue=\"";
6648 outss << columnParameters[3];
6649 columnDefaultValuePtr = &columnParameters[3];
6651 getline(columnChoicesISS, columnChoicesString,
';');
6652 outss <<
"\" \t DataChoices=\"";
6653 outss << columnChoicesString;
6655 std::string* columnMinValuePtr =
nullptr;
6656 std::string* columnMaxValuePtr =
nullptr;
6658 if(columnParameters.size() > 4 &&
6662 if(columnMinValue !=
"")
6664 if(columnMinValue !=
6667 __SUP_COUT__ <<
"FOUND user spec'd min value '" << columnParameters[4]
6672 __SS__ <<
"Inavlid user spec'd min value '" << columnParameters[4]
6673 <<
"' which evaluates to '" << columnMinValue
6674 <<
"' and is not a valid number. The minimum value must "
6675 "be a number (environment variables and math "
6676 "operations are allowed)."
6680 outss <<
"\" \t MinValue=\"" << columnParameters[4];
6681 columnMinValuePtr = &columnParameters[4];
6686 if(columnMaxValue !=
"")
6688 if(columnMaxValue !=
6691 __SUP_COUT__ <<
"FOUND user spec'd max value = " << columnMaxValue
6696 __SS__ <<
"Inavlid user spec'd max value '" << columnParameters[5]
6697 <<
"' which evaluates to '" << columnMaxValue
6698 <<
"' and is not a valid number. The maximum value must "
6699 "be a number (environment variables and math "
6700 "operations are allowed)."
6704 outss <<
"\" \t MaxValue=\"" << columnParameters[5];
6705 columnMaxValuePtr = &columnParameters[5];
6717 columnDefaultValuePtr,
6718 columnChoicesString,
6724 catch(
const std::runtime_error& e)
6726 __SS__ <<
"Error identified with Column #" << c <<
": \n" << e.what();
6733 outss <<
"\t\t\t</VIEW>\n";
6734 outss <<
"\t\t</TABLE>\n";
6735 outss <<
"\t</ROOT>\n";
6737 __SUP_COUT__ << outss.str() << __E__;
6739 FILE* fp = fopen((TABLE_INFO_PATH + tableName + TABLE_INFO_EXT).c_str(),
"w");
6742 xmlOut.addTextElementToData(
"Error",
6743 "Failed to open destination Table Info file:" +
6744 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT));
6748 fprintf(fp,
"%s", outss.str().c_str());
6751 __SUP_COUT_INFO__ <<
"Finished saving Table Info for '" << tableName
6752 <<
".' Looking for errors in all table column info..." << __E__;
6756 std::string accumulatedErrors =
"";
6760 if(accumulatedErrors !=
"")
6762 __SUP_SS__ << (
"The new version of the '" + tableName +
6763 "' table column info was saved, however errors were detected "
6764 "reading back the table '" +
6765 tableName +
"' after the save attempt:\n\n" + accumulatedErrors)
6768 __SUP_COUT_ERR__ << ss.str() << __E__;
6769 xmlOut.addTextElementToData(
"Error", ss.str());
6775 handleGetTableXML(xmlOut, cfgMgr, tableName,
TableVersion());
6778 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
6781 for(
const auto& cfgInfo : allTableInfo)
6787 catch(std::runtime_error& e)
6789 __SUP_COUT_WARN__ <<
"\n\n##############################################\n"
6790 <<
"Error identified in column info of table '"
6791 << cfgInfo.first <<
"':\n\n"
6792 << e.what() <<
"\n\n"
6806 void ConfigurationGUISupervisor::handleSetGroupAliasInBackboneXML(
6809 const std::string& groupAliasCSV,
6810 const std::string& groupNameCSV,
6811 const std::string& groupKeyCSV,
6812 const std::string& author)
6816 std::map<std::string, TableVersion> activeVersions = cfgMgr->
getActiveVersions();
6818 const std::string groupAliasesTableName =
6819 ConfigurationManager::GROUP_ALIASES_TABLE_NAME;
6820 if(activeVersions.find(groupAliasesTableName) == activeVersions.end())
6822 __SUP_SS__ <<
"Active version of " << groupAliasesTableName <<
" missing!"
6824 xmlOut.addTextElementToData(
"Error", ss.str());
6829 const std::set<std::string> backboneMembers = cfgMgr->getBackboneMemberNames();
6830 for(
auto& memberName : backboneMembers)
6832 __SUP_COUT__ <<
"activeVersions[\"" << memberName
6833 <<
"\"]=" << activeVersions[memberName] << __E__;
6835 xmlOut.addTextElementToData(
"oldBackboneName", memberName);
6836 xmlOut.addTextElementToData(
"oldBackboneVersion",
6837 activeVersions[memberName].toString());
6845 TableVersion originalVersion = activeVersions[groupAliasesTableName];
6846 TableVersion temporaryVersion = table->createTemporaryView(originalVersion);
6848 __SUP_COUT__ <<
"\t\t temporaryVersion: " << temporaryVersion << __E__;
6849 bool isDifferent =
false;
6853 TableView* configView = table->getTemporaryView(temporaryVersion);
6855 unsigned int col = configView->
findCol(
"GroupKeyAlias");
6856 unsigned int ccol = configView->
findCol(TableViewColumnInfo::COL_NAME_COMMENT);
6857 unsigned int ncol = configView->
findCol(
"GroupName");
6858 unsigned int kcol = configView->
findCol(
"GroupKey");
6861 std::vector<std::string> groupAliases =
6863 std::vector<std::string> groupNames =
6865 std::vector<std::string> groupKeys =
6872 for(
const auto& groupAlias : groupAliases)
6874 if(groupAlias ==
"" || groupNames[i] ==
"" || groupKeys[i] ==
"")
6877 __SUP_COUT_WARN__ <<
"Empty alias parameter found [" << i <<
"] = {"
6878 << groupAlias <<
", " << groupNames[i] <<
"("
6879 << groupKeys[i] <<
")}" << __E__;
6884 bool localIsDifferent =
false;
6885 const std::string& groupName = groupNames[i];
6889 unsigned int row = -1;
6893 row = configView->
findRow(col, groupAlias);
6899 if(row == (
unsigned int)-1)
6901 localIsDifferent =
true;
6902 row = configView->
addRow();
6906 "This Group Alias was automatically setup by the server.", row, ccol);
6907 configView->
setValue(groupAlias, row, col);
6910 __SUP_COUT__ <<
"\t\t row: " << row << __E__;
6912 __SUP_COUT__ <<
"\t\t groupName: " << groupName <<
" vs "
6913 << configView->getDataView()[row][ncol] << __E__;
6914 if(groupName != configView->getDataView()[row][ncol])
6916 configView->
setValue(groupName, row, ncol);
6917 localIsDifferent =
true;
6920 __SUP_COUT__ <<
"\t\t groupKey: " << groupKey <<
" vs "
6921 << configView->getDataView()[row][kcol] << __E__;
6922 if(groupKey.
toString() != configView->getDataView()[row][kcol])
6925 localIsDifferent =
true;
6928 if(localIsDifferent)
6933 configView->
findCol(TableViewColumnInfo::COL_NAME_AUTHOR));
6937 configView->
findCol(TableViewColumnInfo::COL_NAME_CREATION));
6944 __SUP_COUT_ERR__ <<
"Error editing Group Alias view!" << __E__;
6947 table->eraseView(temporaryVersion);
6954 __SUP_COUT__ <<
"\t\t**************************** Save as new table version"
6961 table->getTableName(),
6972 <<
"\t\t**************************** Using the existing table version"
6976 table->eraseView(temporaryVersion);
6977 newAssignedVersion = activeVersions[groupAliasesTableName];
6979 xmlOut.addTextElementToData(
"savedName", groupAliasesTableName);
6980 xmlOut.addTextElementToData(
"savedVersion", newAssignedVersion.
toString());
6983 __SUP_COUT__ <<
"\t\t newAssignedVersion: " << newAssignedVersion << __E__;
6985 catch(std::runtime_error& e)
6987 __SUP_SS__ <<
"Error saving new Group Alias view!\n\n " << e.what() << __E__;
6988 __SUP_COUT_ERR__ << ss.str();
6989 xmlOut.addTextElementToData(
"Error", ss.str());
6993 __SUP_SS__ <<
"Error saving new Group Alias view!\n\n " << __E__;
6998 catch(
const std::exception& e)
7000 ss <<
"Exception message: " << e.what();
7005 __SUP_COUT_ERR__ << ss.str();
7006 xmlOut.addTextElementToData(
"Error", ss.str());
7017 void ConfigurationGUISupervisor::handleSetTableAliasInBackboneXML(
7020 const std::string& tableAlias,
7021 const std::string& tableName,
7023 const std::string& author)
7027 std::map<std::string, TableVersion> activeVersions = cfgMgr->
getActiveVersions();
7029 const std::string versionAliasesTableName =
7030 ConfigurationManager::VERSION_ALIASES_TABLE_NAME;
7031 if(activeVersions.find(versionAliasesTableName) == activeVersions.end())
7033 __SUP_SS__ <<
"Active version of " << versionAliasesTableName <<
" missing!"
7035 xmlOut.addTextElementToData(
"Error", ss.str());
7040 const std::set<std::string> backboneMembers = cfgMgr->getBackboneMemberNames();
7041 for(
auto& memberName : backboneMembers)
7043 __SUP_COUT__ <<
"activeVersions[\"" << memberName
7044 <<
"\"]=" << activeVersions[memberName] << __E__;
7046 xmlOut.addTextElementToData(
"oldBackboneName", memberName);
7047 xmlOut.addTextElementToData(
"oldBackboneVersion",
7048 activeVersions[memberName].toString());
7056 TableVersion originalVersion = activeVersions[versionAliasesTableName];
7057 TableVersion temporaryVersion = table->createTemporaryView(originalVersion);
7059 __SUP_COUT__ <<
"\t\t temporaryVersion: " << temporaryVersion << __E__;
7061 bool isDifferent =
false;
7065 TableView* configView = table->getTemporaryView(temporaryVersion);
7068 unsigned int col2 = configView->
findCol(
"VersionAlias");
7069 unsigned int col3 = configView->
findCol(
"TableName");
7073 unsigned int row = -1;
7078 unsigned int tmpRow = -1;
7081 tmpRow = configView->
findRow(col3, tableName, tmpRow + 1);
7082 }
while(configView->getDataView()[tmpRow][col2] != tableAlias);
7089 if(row == (
unsigned int)-1)
7092 row = configView->
addRow();
7095 col = configView->
findCol(TableViewColumnInfo::COL_NAME_COMMENT);
7097 std::string(
"Entry was added by server in ") +
7098 "ConfigurationGUISupervisor::setTableAliasInActiveBackbone().",
7102 col = configView->
findCol(
"VersionAliasUID");
7104 tableName.substr(0, tableName.rfind(
"Table")) + tableAlias, row, col);
7106 configView->
setValue(tableAlias, row, col2);
7107 configView->
setValue(tableName, row, col3);
7110 __SUP_COUT__ <<
"\t\t row: " << row << __E__;
7112 col = configView->
findCol(
"Version");
7113 __SUP_COUT__ <<
"\t\t version: " << version <<
" vs "
7114 << configView->getDataView()[row][col] << __E__;
7115 if(version.toString() != configView->getDataView()[row][col])
7117 configView->
setValue(version.toString(), row, col);
7124 author, row, configView->
findCol(TableViewColumnInfo::COL_NAME_AUTHOR));
7128 configView->
findCol(TableViewColumnInfo::COL_NAME_CREATION));
7133 __SUP_COUT_ERR__ <<
"Error editing Version Alias view!" << __E__;
7136 table->eraseView(temporaryVersion);
7143 __SUP_COUT__ <<
"\t\t**************************** Save as new table version"
7149 table->getTableName(),
7159 __SUP_COUT__ <<
"\t\t**************************** Using existing table version"
7163 table->eraseView(temporaryVersion);
7164 newAssignedVersion = activeVersions[versionAliasesTableName];
7166 xmlOut.addTextElementToData(
"savedName", versionAliasesTableName);
7167 xmlOut.addTextElementToData(
"savedVersion", newAssignedVersion.
toString());
7170 __SUP_COUT__ <<
"\t\t newAssignedVersion: " << newAssignedVersion << __E__;
7172 catch(std::runtime_error& e)
7174 __SUP_SS__ <<
"Error saving new Version Alias view!\n\n " << e.what() << __E__;
7175 __SUP_COUT_ERR__ << ss.str();
7176 xmlOut.addTextElementToData(
"Error", ss.str());
7180 __SUP_SS__ <<
"Error saving new Version Alias view!\n\n " << __E__;
7185 catch(
const std::exception& e)
7187 ss <<
"Exception message: " << e.what();
7192 __SUP_COUT_ERR__ << ss.str();
7193 xmlOut.addTextElementToData(
"Error", ss.str());
7202 void ConfigurationGUISupervisor::handleAliasGroupMembersInBackboneXML(
7205 const std::string& versionAlias,
7206 const std::string& groupName,
7208 const std::string& author)
7212 std::map<std::string, TableVersion> activeVersions = cfgMgr->
getActiveVersions();
7214 const std::string versionAliasesTableName =
7215 ConfigurationManager::VERSION_ALIASES_TABLE_NAME;
7216 if(activeVersions.find(versionAliasesTableName) == activeVersions.end())
7218 __SUP_SS__ <<
"Active version of " << versionAliasesTableName <<
" missing!"
7220 xmlOut.addTextElementToData(
"Error", ss.str());
7225 const std::set<std::string> backboneMembers = cfgMgr->getBackboneMemberNames();
7226 for(
auto& memberName : backboneMembers)
7228 __SUP_COUT__ <<
"activeVersions[\"" << memberName
7229 <<
"\"]=" << activeVersions[memberName] << __E__;
7231 xmlOut.addTextElementToData(
"oldBackboneName", memberName);
7232 xmlOut.addTextElementToData(
"oldBackboneVersion",
7233 activeVersions[memberName].toString());
7242 table->createTemporaryView(activeVersions[versionAliasesTableName]);
7244 __SUP_COUT__ <<
"\t\t temporaryVersion: " << temporaryVersion << __E__;
7246 TableView* configView = table->getTemporaryView(temporaryVersion);
7249 bool isDifferent =
false;
7268 xmlOut.addTextElementToData(
7271 "\" can not be retrieved!");
7276 unsigned int col2 = configView->
findCol(
"VersionAlias");
7277 unsigned int col3 = configView->
findCol(
"TableName");
7279 for(
auto& memberPair : memberMap)
7281 bool thisMemberIsDifferent =
false;
7282 unsigned int row = -1;
7284 __SUP_COUT__ <<
"Adding alias for " << memberPair.first <<
"_v"
7285 << memberPair.second <<
" to " << versionAlias << __E__;
7291 unsigned int tmpRow = -1;
7294 tmpRow = configView->
findRow(col3, memberPair.first, tmpRow + 1);
7295 }
while(configView->getDataView()[tmpRow][col2] != versionAlias);
7302 if(row == (
unsigned int)-1)
7304 thisMemberIsDifferent =
true;
7305 row = configView->
addRow();
7308 col = configView->
findCol(TableViewColumnInfo::COL_NAME_COMMENT);
7310 std::string(
"Entry was added by server in ") +
7311 "ConfigurationGUISupervisor::setTableAliasInActiveBackbone().",
7317 memberPair.first.substr(0, memberPair.first.rfind(
"Table")) +
7322 configView->
setValue(versionAlias, row, col2);
7323 configView->
setValue(memberPair.first, row, col3);
7326 col = configView->
findCol(
"Version");
7328 if(memberPair.second.toString() != configView->getDataView()[row][col])
7330 configView->
setValue(memberPair.second.toString(), row, col);
7331 thisMemberIsDifferent =
true;
7334 if(thisMemberIsDifferent)
7337 author, row, configView->
findCol(TableViewColumnInfo::COL_NAME_AUTHOR));
7341 configView->
findCol(TableViewColumnInfo::COL_NAME_CREATION));
7344 if(thisMemberIsDifferent)
7353 __SUP_COUT__ <<
"\t\t**************************** Save v" << temporaryVersion
7354 <<
" as new table version" << __E__;
7356 newAssignedVersion =
7357 cfgMgr->
saveNewTable(versionAliasesTableName, temporaryVersion);
7361 __SUP_COUT__ <<
"\t\t**************************** Using existing table version"
7365 table->eraseView(temporaryVersion);
7366 newAssignedVersion = activeVersions[versionAliasesTableName];
7369 xmlOut.addTextElementToData(
"savedName", versionAliasesTableName);
7370 xmlOut.addTextElementToData(
"savedVersion", newAssignedVersion.
toString());
7371 __SUP_COUT__ <<
"\t\t Resulting Version: " << newAssignedVersion << __E__;
7373 catch(std::runtime_error& e)
7375 __SUP_SS__ <<
"Error saving new Version Alias view!\n\n " << e.what() << __E__;
7376 __SUP_COUT_ERR__ << ss.str();
7377 xmlOut.addTextElementToData(
"Error", ss.str());
7381 __SUP_SS__ <<
"Error saving new Version Alias view!\n\n " << __E__;
7386 catch(
const std::exception& e)
7388 ss <<
"Exception message: " << e.what();
7393 __SUP_COUT_ERR__ << ss.str();
7394 xmlOut.addTextElementToData(
"Error", ss.str());
7408 void ConfigurationGUISupervisor::handleGroupAliasesXML(
HttpXmlDocument& xmlOut,
7412 std::map<std::string, TableVersion> activeVersions = cfgMgr->
getActiveVersions();
7414 std::string groupAliasesTableName = ConfigurationManager::GROUP_ALIASES_TABLE_NAME;
7415 if(activeVersions.find(groupAliasesTableName) == activeVersions.end())
7417 __SUP_SS__ <<
"\nActive version of " << groupAliasesTableName <<
" missing! "
7418 << groupAliasesTableName
7419 <<
" is a required member of the Backbone table group."
7420 <<
"\n\nLikely you need to activate a valid Backbone table group."
7422 __SUP_COUT__ << ss.str();
7427 __SUP_COUT__ <<
"activeVersions[\"" << groupAliasesTableName
7428 <<
"\"]=" << activeVersions[groupAliasesTableName] << __E__;
7429 xmlOut.addTextElementToData(
"GroupAliasesTableName", groupAliasesTableName);
7430 xmlOut.addTextElementToData(
"GroupAliasesTableVersion",
7431 activeVersions[groupAliasesTableName].toString());
7433 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
7438 <<
" ==> " << numOfThreads <<
" threads for alias group loads." << __E__;
7440 if(numOfThreads < 2)
7442 std::string groupName, groupKey, groupComment, groupAuthor, groupCreateTime,
7444 for(
auto& aliasNodePair : aliasNodePairs)
7446 groupName = aliasNodePair.second.getNode(
"GroupName").getValueAsString();
7447 groupKey = aliasNodePair.second.getNode(
"GroupKey").getValueAsString();
7449 xmlOut.addTextElementToData(
"GroupAlias", aliasNodePair.first);
7450 xmlOut.addTextElementToData(
"GroupName", groupName);
7451 xmlOut.addTextElementToData(
"GroupKey", groupKey);
7452 xmlOut.addTextElementToData(
7454 aliasNodePair.second.getNode(TableViewColumnInfo::COL_NAME_COMMENT)
7455 .getValueAsString());
7459 ConfigurationManager::UNKNOWN_INFO;
7460 groupType = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
7477 __SUP_COUT_WARN__ <<
"Failed to load group '" << groupName <<
"("
7478 << groupKey <<
")' to extract group comment and type."
7481 xmlOut.addTextElementToData(
"GroupComment", groupComment);
7482 xmlOut.addTextElementToData(
"GroupType", groupType);
7487 int threadsLaunched = 0;
7488 int foundThreadIndex = 0;
7489 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
7490 for(
int i = 0; i < numOfThreads; ++i)
7491 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
7493 std::vector<std::shared_ptr<ots::GroupInfo>> sharedGroupInfoPtrs;
7494 std::string groupName, groupKey;
7496 for(
auto& aliasNodePair : aliasNodePairs)
7499 sharedGroupInfoPtrs.push_back(std::make_shared<ots::GroupInfo>());
7501 groupName = aliasNodePair.second.getNode(
"GroupName").getValueAsString();
7502 groupKey = aliasNodePair.second.getNode(
"GroupKey").getValueAsString();
7504 if(threadsLaunched >= numOfThreads)
7507 foundThreadIndex = -1;
7508 while(foundThreadIndex == -1)
7510 for(
int i = 0; i < numOfThreads; ++i)
7511 if(*(threadDone[i]))
7513 foundThreadIndex = i;
7516 if(foundThreadIndex == -1)
7518 __SUP_COUTT__ <<
"Waiting for available thread..." << __E__;
7522 threadsLaunched = numOfThreads - 1;
7524 __SUP_COUTT__ <<
"Starting load group thread... " << groupName <<
"("
7525 << groupKey <<
")" << __E__;
7526 *(threadDone[foundThreadIndex]) =
false;
7530 std::string theGroupName,
7532 std::shared_ptr<ots::GroupInfo> theGroupInfo,
7533 std::shared_ptr<std::atomic<bool>> theThreadDone) {
7543 sharedGroupInfoPtrs.back(),
7544 threadDone[foundThreadIndex])
7555 foundThreadIndex = -1;
7556 for(
int i = 0; i < numOfThreads; ++i)
7557 if(!*(threadDone[i]))
7559 foundThreadIndex = i;
7562 if(foundThreadIndex != -1)
7564 __SUP_COUTT__ <<
"Waiting for thread to finish... " << foundThreadIndex
7568 }
while(foundThreadIndex != -1);
7572 for(
auto& aliasNodePair : aliasNodePairs)
7574 groupName = aliasNodePair.second.getNode(
"GroupName").getValueAsString();
7575 groupKey = aliasNodePair.second.getNode(
"GroupKey").getValueAsString();
7577 if(groupKey != sharedGroupInfoPtrs[i]->getLatestKey().toString())
7579 __SUP_SS__ <<
"Error loading group information for the group alias '"
7580 << aliasNodePair.first <<
"' mapping to group '" << groupName
7581 <<
"(" << groupKey <<
")" << __E__;
7585 xmlOut.addTextElementToData(
"GroupAlias", aliasNodePair.first);
7586 xmlOut.addTextElementToData(
"GroupName", groupName);
7587 xmlOut.addTextElementToData(
7588 "GroupKey", sharedGroupInfoPtrs[i]->getLatestKey().toString());
7589 xmlOut.addTextElementToData(
7591 aliasNodePair.second.getNode(TableViewColumnInfo::COL_NAME_COMMENT)
7592 .getValueAsString());
7594 xmlOut.addTextElementToData(
7595 "GroupComment", sharedGroupInfoPtrs[i]->getLatestKeyGroupComment());
7596 xmlOut.addTextElementToData(
7597 "GroupAuthor", sharedGroupInfoPtrs[i]->getLatestKeyGroupAuthor());
7598 xmlOut.addTextElementToData(
7599 "GroupCreationTime",
7600 sharedGroupInfoPtrs[i]->getLatestKeyGroupCreationTime());
7601 xmlOut.addTextElementToData(
7602 "GroupType", sharedGroupInfoPtrs[i]->getLatestKeyGroupTypeString());
7621 void ConfigurationGUISupervisor::handleVersionAliasesXML(
HttpXmlDocument& xmlOut,
7625 std::map<std::string, TableVersion> activeVersions = cfgMgr->
getActiveVersions();
7627 std::string versionAliasesTableName =
7628 ConfigurationManager::VERSION_ALIASES_TABLE_NAME;
7629 if(activeVersions.find(versionAliasesTableName) == activeVersions.end())
7631 __SUP_SS__ <<
"Active version of VersionAliases missing!"
7632 <<
"Make sure you have a valid active Backbone Group." << __E__;
7633 xmlOut.addTextElementToData(
"Error", ss.str());
7636 __SUP_COUT__ <<
"activeVersions[\"" << versionAliasesTableName
7637 <<
"\"]=" << activeVersions[versionAliasesTableName] << __E__;
7638 xmlOut.addTextElementToData(
"VersionAliasesVersion",
7639 activeVersions[versionAliasesTableName].toString());
7641 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
7644 for(
auto& aliasNodePair : aliasNodePairs)
7648 xmlOut.addTextElementToData(
7650 aliasNodePair.second.getNode(
"VersionAlias").getValueAsString());
7651 xmlOut.addTextElementToData(
7652 "TableName", aliasNodePair.second.getNode(
"TableName").getValueAsString());
7653 xmlOut.addTextElementToData(
7654 "Version", aliasNodePair.second.getNode(
"Version").getValueAsString());
7655 xmlOut.addTextElementToData(
7657 aliasNodePair.second.getNode(TableViewColumnInfo::COL_NAME_COMMENT)
7658 .getValueAsString());
7668 void ConfigurationGUISupervisor::handleGetTableGroupTypeXML(
7672 std::string name, versionStr;
7673 auto c = tableList.find(
',', 0);
7676 while(c < tableList.length())
7679 name = tableList.substr(i, c - i);
7681 c = tableList.find(
',', i);
7682 if(c == std::string::npos)
7684 __SUP_SS__ <<
"Incomplete Table Name-Version pair!" << __E__;
7685 __SUP_COUT_ERR__ <<
"\n" << ss.str();
7686 xmlOut.addTextElementToData(
"Error", ss.str());
7690 versionStr = tableList.substr(i, c - i);
7692 c = tableList.find(
',', i);
7697 std::string groupTypeString =
"";
7703 xmlOut.addTextElementToData(
"TableGroupType", groupTypeString);
7705 catch(std::runtime_error& e)
7707 __SUP_SS__ <<
"Table group has invalid type! " << e.what() << __E__;
7708 __SUP_COUT__ <<
"\n" << ss.str();
7709 groupTypeString = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
7710 xmlOut.addTextElementToData(
"TableGroupType", groupTypeString);
7714 __SUP_SS__ <<
"Table group has invalid type! " << __E__;
7719 catch(
const std::exception& e)
7721 ss <<
"Exception message: " << e.what();
7726 __SUP_COUT__ <<
"\n" << ss.str();
7727 groupTypeString = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
7728 xmlOut.addTextElementToData(
"TableGroupType", groupTypeString);
7748 void ConfigurationGUISupervisor::handleTableGroupsXML(
HttpXmlDocument& xmlOut,
7752 __SUP_COUTT__ <<
"cfgMgr runtime=" << cfgMgr->runTimeSeconds() << __E__;
7758 if(!cfgMgr->getAllGroupInfo().size() ||
7759 cfgMgr->getAllGroupInfo().begin()->second.getLatestKeyGroupTypeString() ==
"" ||
7760 cfgMgr->getAllGroupInfo().begin()->second.getLatestKeyGroupTypeString() ==
7761 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN ||
7763 cfgMgr->getActiveGroupKey(ConfigurationManager::GroupType::CONTEXT_TYPE) !=
7764 TableGroupKey::INVALID &&
7765 cfgMgr->getAllGroupInfo().find(cfgMgr->getActiveGroupName(
7766 ConfigurationManager::GroupType::CONTEXT_TYPE)) !=
7767 cfgMgr->getAllGroupInfo().end() &&
7768 (cfgMgr->getAllGroupInfo()
7769 .at(cfgMgr->getActiveGroupName(
7770 ConfigurationManager::GroupType::CONTEXT_TYPE))
7771 .getLatestKeyGroupTypeString() ==
"" ||
7772 cfgMgr->getAllGroupInfo()
7773 .at(cfgMgr->getActiveGroupName(
7774 ConfigurationManager::GroupType::CONTEXT_TYPE))
7775 .getLatestKeyGroupTypeString() ==
7776 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN)) ||
7778 cfgMgr->getActiveGroupKey(
7779 ConfigurationManager::GroupType::CONFIGURATION_TYPE) !=
7780 TableGroupKey::INVALID &&
7781 cfgMgr->getAllGroupInfo().find(cfgMgr->getActiveGroupName(
7782 ConfigurationManager::GroupType::CONFIGURATION_TYPE)) !=
7783 cfgMgr->getAllGroupInfo().end() &&
7784 (cfgMgr->getAllGroupInfo()
7785 .at(cfgMgr->getActiveGroupName(
7786 ConfigurationManager::GroupType::CONFIGURATION_TYPE))
7787 .getLatestKeyGroupTypeString() ==
"" ||
7788 cfgMgr->getAllGroupInfo()
7789 .at(cfgMgr->getActiveGroupName(
7790 ConfigurationManager::GroupType::CONFIGURATION_TYPE))
7791 .getLatestKeyGroupTypeString() ==
7792 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN)))
7795 <<
"Group Info cache appears empty or stale. Attempting to regenerate..."
7805 const std::map<std::string, GroupInfo>& allGroupInfo = cfgMgr->getAllGroupInfo();
7807 __SUP_COUTT__ <<
"cfgMgr runtime=" << cfgMgr->runTimeSeconds() << __E__;
7809 std::string groupName;
7810 std::string groupString, groupTypeString, groupComment, groupCreationTime,
7812 for(
auto& groupInfo : allGroupInfo)
7814 groupName = groupInfo.first;
7819 if(groupInfo.second.getKeys().size() == 0)
7821 __SUP_COUT__ <<
"Group name '" << groupName
7822 <<
"' found, but no keys so ignoring." << __E__;
7826 xmlOut.dataSs_ <<
"<TableGroupName value='" << groupName <<
"'/>" << __E__;
7827 xmlOut.dataSs_ <<
"<TableGroupKey value='" << groupInfo.second.getLatestKey()
7831 xmlOut.dataSs_ <<
"<TableGroupType value='"
7832 << groupInfo.second.getLatestKeyGroupTypeString() <<
"'/>"
7834 xmlOut.dataSs_ <<
"<TableGroupComment value='"
7836 groupInfo.second.getLatestKeyGroupComment(),
7839 xmlOut.dataSs_ <<
"<TableGroupAuthor value='"
7840 << groupInfo.second.getLatestKeyGroupAuthor() <<
"'/>" << __E__;
7841 xmlOut.dataSs_ <<
"<TableGroupCreationTime value='"
7842 << groupInfo.second.getLatestKeyGroupCreationTime() <<
"'/>"
7848 xmlOut.dataSs_ <<
"<TableGroupMembers value=''>" << __E__;
7850 for(
auto& memberPair : groupInfo.second.getLatestKeyMemberMap())
7852 xmlOut.dataSs_ <<
"\t<MemberName value='" << memberPair.first <<
"'/>"
7854 xmlOut.dataSs_ <<
"\t<MemberVersion value='" << memberPair.second <<
"'/>"
7861 xmlOut.dataSs_ <<
"</TableGroupMembers>" << __E__;
7866 for(
auto& keyInSet : groupInfo.second.getKeys())
7868 if(keyInSet == groupInfo.second.getLatestKey())
7871 xmlOut.dataSs_ <<
"<TableGroupName value='" << groupName <<
"'/>" << __E__;
7872 xmlOut.dataSs_ <<
"<TableGroupKey value='" << keyInSet <<
"'/>" << __E__;
7877 bool loadingHistoricalInfo =
false;
7878 if(loadingHistoricalInfo)
7897 groupTypeString = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
7898 __SUP_COUT_WARN__ <<
"Failed to load group '" << groupName <<
"("
7900 <<
")' to extract group comment and type." << __E__;
7903 xmlOut.dataSs_ <<
"<TableGroupType value='" << groupTypeString <<
"'/>"
7905 xmlOut.dataSs_ <<
"<TableGroupComment value='"
7909 xmlOut.dataSs_ <<
"<TableGroupAuthor value='" << groupAuthor <<
"'/>"
7911 xmlOut.dataSs_ <<
"<TableGroupCreationTime value='" << groupCreationTime
7921 xmlOut.dataSs_ <<
"<TableGroupType value='"
7922 << groupInfo.second.getLatestKeyGroupTypeString() <<
"'/>"
7925 xmlOut.dataSs_ <<
"<TableGroupComment value='"
7928 xmlOut.dataSs_ <<
"<TableGroupAuthor value='"
7931 xmlOut.dataSs_ <<
"<TableGroupCreationTime value='"
7939 xmlOut.dataSs_ <<
"<TableGroupMembers/>" << __E__;
7944 __SUP_COUTT__ << groupName <<
" runtime=" << cfgMgr->runTimeSeconds() << __E__;
7946 __SUP_COUTT__ <<
"cfgMgr runtime=" << cfgMgr->runTimeSeconds() << __E__;
7961 void ConfigurationGUISupervisor::handleTablesXML(
HttpXmlDocument& xmlOut,
7964 if(cfgMgr->getAllGroupInfo().size() == 0 || cfgMgr->
getActiveVersions().size() == 0)
7966 __SUP_COUT__ <<
"Table Info cache appears empty. Attempting to regenerate."
7976 xercesc::DOMElement* parentEl;
7977 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
7980 std::set<std::string, StringMacros::IgnoreCaseCompareStruct> orderedTableSet;
7981 for(
const auto& tablePair : allTableInfo)
7982 orderedTableSet.emplace(tablePair.first);
7986 __SUP_COUT__ <<
"# of tables found: " << allTableInfo.size() << __E__;
7988 std::map<std::string, std::map<std::string, TableVersion>> versionAliases =
7991 __SUP_COUT__ <<
"# of tables w/aliases: " << versionAliases.size() << __E__;
7993 for(
const auto& orderedTableName : orderedTableSet)
7996 std::map<std::string, TableInfo>::const_iterator it =
7997 allTableInfo.find(orderedTableName);
7998 if(it == allTableInfo.end())
8000 __SS__ <<
"Impossible missing table in map '" << orderedTableName <<
"'"
8009 xmlOut.addTextElementToData(
"TableName", it->first);
8010 parentEl = xmlOut.addTextElementToData(
"TableVersions",
"");
8013 if(versionAliases.find(it->first) != versionAliases.end())
8014 for(
auto& aliasVersion : versionAliases[it->first])
8015 if(it->second.versions_.find(aliasVersion.second) !=
8016 it->second.versions_
8020 ConfigurationManager::ALIAS_VERSION_PREAMBLE + aliasVersion.first,
8028 auto vSpanToXML = [](
auto const& sortedKeys,
auto& xmlOut,
auto& configEl) {
8030 size_t lo = -1, hi = -1;
8031 for(
auto& keyInOrder : sortedKeys)
8034 if(keyInOrder.isScratchVersion())
8037 if(lo ==
size_t(-1))
8039 hi = lo = keyInOrder.
version();
8042 else if(hi + 1 == keyInOrder.version())
8050 xmlOut.addNumberElementToParent(
"Version", lo, configEl);
8052 xmlOut.addTextElementToParent(
8054 "_" + std::to_string(lo) +
"_" + std::to_string(hi),
8056 hi = lo = keyInOrder.
version();
8059 if(lo !=
size_t(-1))
8062 xmlOut.addNumberElementToParent(
"Version", lo, configEl);
8064 xmlOut.addTextElementToParent(
8066 "_" + std::to_string(lo) +
"_" + std::to_string(hi),
8071 vSpanToXML(it->second.versions_, xmlOut, parentEl);
8084 void ConfigurationGUISupervisor::handleGetArtdaqNodeRecordsXML(
8087 const std::string& modifiedTables)
8089 __COUT__ <<
"Retrieving artdaq nodes..." << __E__;
8092 setupActiveTablesXML(
8093 xmlOut, cfgMgr,
"",
TableGroupKey(-1), modifiedTables,
false );
8095 std::map<std::string ,
8096 std::map<std::string , std::vector<std::string >>>
8097 nodeTypeToObjectMap;
8098 std::map<std::string , std::string >
8101 std::vector<std::string > artdaqSupervisorInfo;
8103 std::string artdaqSupervisorName;
8105 cfgMgr, nodeTypeToObjectMap, subsystemObjectMap, artdaqSupervisorInfo);
8107 if(artdaqSupervisorInfo.size() != 4 )
8109 __SUP_COUT__ <<
"No artdaq supervisor found." << __E__;
8113 __SUP_COUT__ <<
"========== "
8114 <<
"Found " << info.subsystems.size() <<
" subsystems." << __E__;
8116 unsigned int paramIndex = 0;
8118 auto parentEl = xmlOut.addTextElementToData(
"artdaqSupervisor",
8119 artdaqSupervisorInfo[paramIndex++]);
8121 std::string typeString =
"artdaqSupervisor";
8124 typeString +
"-status", artdaqSupervisorInfo[paramIndex++], parentEl);
8126 typeString +
"-contextAddress", artdaqSupervisorInfo[paramIndex++], parentEl);
8128 typeString +
"-contextPort", artdaqSupervisorInfo[paramIndex++], parentEl);
8130 for(
auto& subsystem : info.subsystems)
8132 typeString =
"subsystem";
8134 __SUP_COUT__ <<
"\t\t"
8135 <<
"Found " << typeString <<
" " << subsystem.first <<
" \t := '"
8136 << subsystem.second.label <<
"'" << __E__;
8140 typeString +
"-id", std::to_string(subsystem.first), parentEl);
8143 std::to_string(subsystem.second.sources.size()),
8148 std::to_string(subsystem.second.destination),
8153 __SUP_COUT__ <<
"========== "
8154 <<
"Found " << nodeTypeToObjectMap.size() <<
" process types." << __E__;
8156 for(
auto& nameTypePair : nodeTypeToObjectMap)
8158 typeString = nameTypePair.first;
8160 __SUP_COUT__ <<
"\t"
8161 <<
"Found " << nameTypePair.second.size() <<
" " << typeString
8164 for(
auto& artdaqNode : nameTypePair.second)
8166 __SUP_COUT__ <<
"\t\t"
8167 <<
"Found '" << artdaqNode.first <<
"' " << typeString << __E__;
8170 if(artdaqNode.second.size() < 2)
8172 __SUP_SS__ <<
"Impossible parameter size for node '" << artdaqNode.first
8173 <<
"' " << typeString <<
" - please notify admins!" << __E__;
8181 if(artdaqNode.second.size() > paramIndex)
8183 __SUP_COUTT__ <<
"\t\t\t"
8184 <<
"-multinode: " << artdaqNode.second[paramIndex] << __E__;
8186 typeString +
"-multinode", artdaqNode.second[paramIndex++], nodeEl);
8188 if(artdaqNode.second.size() > paramIndex)
8190 __SUP_COUTT__ <<
"\t\t\t"
8191 <<
"-nodefixedwidth: " << artdaqNode.second[paramIndex]
8194 artdaqNode.second[paramIndex++],
8197 if(artdaqNode.second.size() > paramIndex)
8199 __SUP_COUTT__ <<
"\t\t\t"
8200 <<
"-hostarray: " << artdaqNode.second[paramIndex] << __E__;
8202 typeString +
"-hostarray", artdaqNode.second[paramIndex++], nodeEl);
8204 if(artdaqNode.second.size() > paramIndex)
8206 __SUP_COUTT__ <<
"\t\t\t"
8207 <<
"-hostfixedwidth: " << artdaqNode.second[paramIndex]
8210 artdaqNode.second[paramIndex++],
8215 __SUP_COUTT__ <<
"\t\t\t"
8216 <<
"-status: " << artdaqNode.second[paramIndex] << __E__;
8218 typeString +
"-status", artdaqNode.second[paramIndex++], parentEl);
8219 __SUP_COUTT__ <<
"\t\t\t"
8220 <<
"-hostname: " << artdaqNode.second[paramIndex] << __E__;
8222 typeString +
"-hostname", artdaqNode.second[paramIndex++], parentEl);
8223 __SUP_COUTT__ <<
"\t\t\t"
8224 <<
"-subsystem: " << artdaqNode.second[paramIndex] << __E__;
8226 typeString +
"-subsystem", artdaqNode.second[paramIndex], parentEl);
8230 __SUP_COUT__ <<
"Done retrieving artdaq nodes." << __E__;
8241 void ConfigurationGUISupervisor::handleSaveArtdaqNodeRecordsXML(
8242 const std::string& nodeString,
8243 const std::string& subsystemString,
8246 const std::string& modifiedTables)
8248 __SUP_COUT__ <<
"Saving artdaq nodes..." << __E__;
8251 setupActiveTablesXML(
8252 xmlOut, cfgMgr,
"",
TableGroupKey(-1), modifiedTables,
false );
8255 std::map<std::string ,
8256 std::map<std::string , std::vector<std::string >>>
8257 nodeTypeToObjectMap;
8263 std::map<std::string , std::string >
8264 nodeTypeToStringMap;
8269 for(
auto& typePair : nodeTypeToStringMap)
8271 if(typePair.first ==
"")
8276 nodeTypeToObjectMap.emplace(
8278 std::map<std::string ,
8279 std::vector<std::string /*property*/>>()));
8281 std::map<std::string , std::string >
8282 nodeRecordToStringMap;
8285 typePair.second, nodeRecordToStringMap, {
';'}, {
'='});
8289 for(
auto& nodePair : nodeRecordToStringMap)
8291 if(nodePair.first ==
"")
8296 std::vector<std::string > nodePropertyVector;
8299 nodePair.second, nodePropertyVector, {
','});
8304 for(
unsigned int i = 0; i < nodePropertyVector.size(); ++i)
8309 nodePropertyVector[i] =
8313 nodeTypeToObjectMap[typePair.first].emplace(
8315 nodePropertyVector));
8321 std::map<std::string , std::string >
8328 std::map<std::string , std::string >
8329 tmpSubsystemObjectMap;
8331 subsystemString, tmpSubsystemObjectMap, {
';'}, {
':'});
8336 for(
auto& subsystemPair : tmpSubsystemObjectMap)
8341 subsystemObjectMap.emplace(
8348 cfgMgr, nodeTypeToObjectMap, subsystemObjectMap);
8350 __SUP_COUT__ <<
"Done saving artdaq nodes." << __E__;
8360 void ConfigurationGUISupervisor::handleLoadArtdaqNodeLayoutXML(
8364 const std::string& contextGroupName ,
8367 bool usingActiveGroups = (contextGroupName ==
"" || contextGroupKey.
isInvalid());
8370 const std::string& finalContextGroupName =
8372 ? cfgMgr->getActiveGroupName(ConfigurationManager::GroupType::CONTEXT_TYPE)
8376 ? cfgMgr->getActiveGroupKey(ConfigurationManager::GroupType::CONTEXT_TYPE)
8378 const std::string& finalConfigGroupName =
8379 cfgMgr->getActiveGroupName(ConfigurationManager::GroupType::CONFIGURATION_TYPE);
8381 cfgMgr->getActiveGroupKey(ConfigurationManager::GroupType::CONFIGURATION_TYPE);
8386 std::stringstream layoutPath;
8387 layoutPath << ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH << finalContextGroupName
8388 <<
"_" << finalContextGroupKey <<
"." << finalConfigGroupName <<
"_"
8389 << finalConfigGroupKey <<
".dat";
8391 fp = fopen(layoutPath.str().c_str(),
"r");
8394 __SUP_COUT__ <<
"Layout file not found for '" << finalContextGroupName <<
"("
8395 << finalContextGroupKey <<
") + " << finalConfigGroupName <<
"("
8396 << finalConfigGroupKey <<
")': " << layoutPath.
str() << __E__;
8400 __SUP_COUTV__(layoutPath.str());
8405 std::stringstream layoutPath;
8406 layoutPath << ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH << finalContextGroupName
8407 <<
"_" << finalContextGroupKey <<
".dat";
8408 __SUP_COUTV__(layoutPath.str());
8410 fp = fopen(layoutPath.str().c_str(),
"r");
8413 __SUP_COUT__ <<
"Layout file not found for '" << finalContextGroupName <<
"("
8414 << finalContextGroupKey <<
")': " << layoutPath.str() << __E__;
8418 __SUP_COUTV__(layoutPath.str());
8425 const size_t maxLineSz = 1000;
8426 char line[maxLineSz];
8427 if(!fgets(line, maxLineSz, fp))
8436 unsigned int rows, cols;
8438 sscanf(line,
"%u %u", &rows, &cols);
8440 __COUT__ <<
"Grid rows,cols = " << rows <<
"," << cols << __E__;
8442 xmlOut.addTextElementToData(
"grid-rows", std::to_string(rows));
8443 xmlOut.addTextElementToData(
"grid-cols", std::to_string(cols));
8446 char name[maxLineSz];
8447 char type[maxLineSz];
8449 while(fgets(line, maxLineSz, fp))
8452 sscanf(line,
"%s %s %u %u", type, name, &x, &y);
8454 xmlOut.addTextElementToData(
"node-type", type);
8455 xmlOut.addTextElementToData(
"node-name", name);
8456 xmlOut.addTextElementToData(
"node-x", std::to_string(x));
8457 xmlOut.addTextElementToData(
"node-y", std::to_string(y));
8471 void ConfigurationGUISupervisor::handleSaveArtdaqNodeLayoutXML(
8474 const std::string& layoutString,
8475 const std::string& contextGroupName,
8478 bool usingActiveGroups = (contextGroupName ==
"" || contextGroupKey.
isInvalid());
8480 const std::string& finalContextGroupName =
8482 ? cfgMgr->getActiveGroupName(ConfigurationManager::GroupType::CONTEXT_TYPE)
8486 ? cfgMgr->getActiveGroupKey(ConfigurationManager::GroupType::CONTEXT_TYPE)
8488 const std::string& finalConfigGroupName =
8489 cfgMgr->getActiveGroupName(ConfigurationManager::GroupType::CONFIGURATION_TYPE);
8491 cfgMgr->getActiveGroupKey(ConfigurationManager::GroupType::CONFIGURATION_TYPE);
8493 __SUP_COUTV__(layoutString);
8495 std::stringstream layoutPath;
8496 layoutPath << ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH << finalContextGroupName
8497 <<
"_" << finalContextGroupKey <<
"." << finalConfigGroupName <<
"_"
8498 << finalConfigGroupKey <<
".dat";
8499 __SUP_COUTV__(layoutPath.str());
8504 if(fields.size() < 2 || (fields.size() - 2) % 4 != 0)
8506 __SUP_SS__ <<
"Invalid layout string fields size of " << fields.size() << __E__;
8510 FILE* fp = fopen(layoutPath.str().c_str(),
"w");
8513 __SUP_SS__ <<
"Could not open layout file for writing for '"
8514 << finalContextGroupName <<
"(" << finalContextGroupKey <<
") + "
8515 << finalConfigGroupName <<
"(" << finalConfigGroupKey
8516 <<
")': " << layoutPath.
str() << __E__;
8523 fprintf(fp,
"%s %s\n", fields[0].c_str(), fields[1].c_str());
8526 for(
unsigned int i = 2; i < fields.size(); i += 4)
8529 fields[i + 0].c_str(),
8530 fields[i + 1].c_str(),
8531 fields[i + 2].c_str(),
8532 fields[i + 3].c_str());
8540 void ConfigurationGUISupervisor::handleOtherSubsystemActiveGroups(
8544 std::string targetSubsystem )
8550 cfgMgr->
getNode(ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE);
8553 for(
auto subsystem : children)
8555 __SUP_COUTV__(subsystem.first);
8559 std::string userPath =
8560 subsystem.second.getNode(
"SubsystemUserDataPath").getValue();
8561 __SUP_COUTV__(userPath);
8564 catch(
const std::runtime_error& e)
8566 __SUP_COUT__ <<
"Ignoring errors in handling other subsystem active groups "
8567 "(assuming the subsystem information map is not setup in "
8568 << ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE
8569 <<
") -- here is the error: \n"
8570 << e.what() << __E__;
8577 cfgMgr->
getNode(ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE);
8579 for(
auto subsystem : children)
8581 if(targetSubsystem !=
"" && targetSubsystem != subsystem.first)
8584 xercesc::DOMElement* parent =
8585 xmlOut.addTextElementToData(
"SubsystemName", subsystem.first);
8590 std::string filename, userDataPath;
8591 std::string username, hostname;
8593 std::map<std::string ,
8595 retMap = cfgMgr->getOtherSubsystemActiveTableGroups(
8596 subsystem.first, &userDataPath, &hostname, &username);
8598 for(
const auto& retPair : retMap)
8601 retPair.second.first,
8604 retPair.second.second.toString(),
8608 std::vector<std::string> filenameTypes = {
"Configured",
8612 "ActivatedBackbone",
8613 "ActivatedIterator"};
8615 std::vector<std::string> filenames = {
8616 ConfigurationManager::LAST_CONFIGURED_CONFIG_GROUP_FILE,
8617 ConfigurationManager::LAST_STARTED_CONFIG_GROUP_FILE,
8618 ConfigurationManager::LAST_ACTIVATED_CONFIG_GROUP_FILE,
8619 ConfigurationManager::LAST_ACTIVATED_CONTEXT_GROUP_FILE,
8620 ConfigurationManager::LAST_ACTIVATED_BACKBONE_GROUP_FILE,
8621 ConfigurationManager::LAST_ACTIVATED_ITERATE_GROUP_FILE};
8623 std::string userPath =
8624 subsystem.second.getNode(
"SubsystemUserDataPath").getValue();
8626 std::string cmdResult;
8627 for(
unsigned int i = 0; i < filenames.size(); ++i)
8629 filename = userDataPath +
"/ServiceData/RunControlData/" + filenames[i];
8630 __SUP_COUTV__(filename);
8632 std::string tmpSubsystemFilename =
8633 ConfigurationManager::LAST_TABLE_GROUP_SAVE_PATH +
"/" + filenames[i] +
8634 "." + subsystem.first;
8635 __SUP_COUTV__(tmpSubsystemFilename);
8637 if(splitPath.size() == 2)
8641 (
"rm " + tmpSubsystemFilename +
" 2>/dev/null; scp " + username +
8642 "@" + hostname +
":" + filename +
" " + tmpSubsystemFilename +
8643 " 2>&1; cat " + tmpSubsystemFilename +
" 2>&1")
8647 (
"rm " + tmpSubsystemFilename +
" 2>/dev/null; scp " + hostname +
8648 ":" + filename +
" " + tmpSubsystemFilename +
" 2>&1; cat " +
8649 tmpSubsystemFilename +
" 2>&1")
8652 else if(splitPath.size() == 1)
8655 " 2>/dev/null; cp " + filename +
" " +
8656 tmpSubsystemFilename +
" 2>&1; cat " +
8657 tmpSubsystemFilename +
" 2>&1")
8661 __SUP_COUTV__(cmdResult);
8662 std::string timeString;
8665 filenames[i] +
"." + subsystem.first, timeString);
8669 "Last" + filenameTypes[i] +
"GroupName", theGroup.first, parent);
8671 theGroup.second.toString(),
8674 "Last" + filenameTypes[i] +
"GroupTime", timeString, parent);
8679 catch(
const std::runtime_error& e)
8682 <<
"An error occurred handling subsystem active groups (Please check the "
8683 "subsystem user data path information map setup in the Context group table "
8684 << ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE
8685 <<
") -- here is the error: \n"
8686 << e.what() << __E__;
8692 void ConfigurationGUISupervisor::handleGroupDiff(
8695 const std::string& groupName,
8698 const std::string& diffGroupNameInput )
8704 std::string diffGroupName;
8707 __SUP_COUT__ <<
"Differencing group " << groupName <<
"(" << groupKey
8708 <<
") with the active group." << __E__;
8711 if(diffGroupNameInput ==
"")
8712 diffGroupName = groupName;
8714 diffGroupName = diffGroupNameInput;
8716 __SUP_COUT__ <<
"Differencing group " << groupName <<
"(" << groupKey
8717 <<
") with group " << diffGroupName <<
"(" << diffKey <<
")"
8723 std::map<std::string ,
TableVersion > memberMap, diffMemberMap;
8724 std::string groupType, accumulateErrors;
8725 std::stringstream diffReport;
8726 bool noDifference =
true;
8745 std::map<std::string , std::pair<std::string, TableGroupKey>>
8752 __SUP_COUTV__(groupType);
8754 if(activeGroups.find(groupType) == activeGroups.end() ||
8755 activeGroups.at(groupType).first ==
"" ||
8756 activeGroups.at(groupType).second.isInvalid())
8758 __SUP_SS__ <<
"Could not find an active group of type '" << groupType
8759 <<
".' Please check the expected active configuration groups "
8760 "for errors (going to 'System View' of the Config App may "
8766 __SUP_COUT__ <<
"active " << groupType <<
" group is "
8767 << activeGroups.at(groupType).first <<
"("
8768 << activeGroups.at(groupType).second <<
")" << __E__;
8770 diffReport <<
"This difference report is between " << groupType
8771 <<
" group <b>'" << groupName <<
"(" << groupKey <<
")'</b>"
8772 <<
" and active group <b>'" << activeGroups.at(groupType).first
8773 <<
"(" << activeGroups.at(groupType).second <<
")'</b>." << __E__;
8776 activeGroups.at(groupType).second,
8786 diffReport <<
"\n\n"
8787 <<
"'" << groupName <<
"(" << groupKey <<
")' has <b>"
8788 << memberMap.size() <<
" member tables</b>, and "
8789 <<
"'" << activeGroups.at(groupType).first <<
"("
8790 << activeGroups.at(groupType).second <<
")' has <b>"
8791 << diffMemberMap.size() <<
" member tables</b>." << __E__;
8795 diffReport <<
"This difference report is between group <b>'" << groupName
8796 <<
"(" << groupKey <<
")'</b>"
8797 <<
" and group <b>'" << diffGroupName <<
"(" << diffKey
8798 <<
")'</b>." << __E__;
8811 diffReport <<
"\n\n"
8812 <<
"'" << groupName <<
"(" << groupKey <<
")' has <b>"
8813 << memberMap.size() <<
" member tables</b>, and "
8814 <<
"'" << diffGroupName <<
"(" << diffKey <<
")' has <b>"
8815 << diffMemberMap.size() <<
" member tables</b>." << __E__;
8820 diffReport <<
"<INDENT><ol>";
8822 unsigned int tableDifferences = 0;
8824 for(
auto& member : memberMap)
8826 if(diffMemberMap.find(member.first) == diffMemberMap.end())
8828 diffReport <<
"\n\n<li>"
8829 <<
"Table <b>" << member.first <<
"-v" << member.second
8830 <<
"</b> not found in active group."
8831 <<
"</li>" << __E__;
8832 noDifference =
false;
8837 __SUP_COUTT__ <<
"Comparing " << member.first <<
"-v" << member.second
8838 <<
" ... " << member.first <<
"-v"
8839 << diffMemberMap.at(member.first) << __E__;
8841 if(member.second == diffMemberMap.at(member.first))
8844 diffReport <<
"\n\n<li>"
8845 <<
"Table <b>" << member.first <<
" v" << member.second
8846 <<
"</b> in " << groupName <<
"(" << groupKey <<
")' ...vs... "
8847 <<
" <b>v" << diffMemberMap.at(member.first) <<
"</b> in "
8848 << diffGroupName <<
"(" << diffKey <<
")':" << __E__;
8852 diffReport <<
"<ul>";
8853 std::map<std::string , std::vector<std::string >>
8855 if(!table->diffTwoVersions(member.second,
8856 diffMemberMap.at(member.first),
8861 noDifference =
false;
8864 xmlOut.addTextElementToData(
"TableWithDiff", member.first);
8865 for(
auto& modifiedRecord : modifiedRecords)
8868 "RecordWithDiff", modifiedRecord.first, parentEl);
8869 for(
auto& modifiedColumn : modifiedRecord.second)
8871 "ColNameWithDiff", modifiedColumn, recordParentEl);
8874 diffReport <<
"</ul></li>";
8878 for(
auto& diffMember : diffMemberMap)
8880 if(memberMap.find(diffMember.first) == memberMap.end())
8883 diffReport <<
"\n\n<li>"
8884 <<
"Active Group Table <b>" << diffMember.first <<
"-v"
8885 << diffMember.second <<
"</b> not found in '" << groupName
8886 <<
"(" << groupKey <<
")'."
8887 <<
"</li>" << __E__;
8889 diffReport <<
"\n\n<li>" << diffGroupName <<
"(" << diffKey
8890 <<
") Table <b>" << diffMember.first <<
"-v"
8891 << diffMember.second <<
"</b> not found in '" << groupName
8892 <<
"(" << groupKey <<
")'."
8893 <<
"</li>" << __E__;
8895 noDifference =
false;
8900 diffReport <<
"\n</ol></INDENT>";
8905 diffReport <<
"\n\nNo difference found between "
8906 <<
"<b>'" << groupName <<
"(" << groupKey
8907 <<
")'</b> and active group "
8908 <<
"<b>'" << activeGroups.at(groupType).first <<
"("
8909 << activeGroups.at(groupType).second <<
")'</b>." << __E__;
8911 diffReport <<
"\n\n<b>" << tableDifferences
8912 <<
"</b> member table differences identified between "
8913 <<
"<b>'" << groupName <<
"(" << groupKey
8914 <<
")'</b> and active group "
8915 <<
"<b>'" << activeGroups.at(groupType).first <<
"("
8916 << activeGroups.at(groupType).second <<
")'</b>." << __E__;
8921 diffReport <<
"\n\nNo difference found between "
8922 <<
"<b>'" << groupName <<
"(" << groupKey
8923 <<
")'</b> and group "
8924 <<
"<b>'" << diffGroupName <<
"(" << diffKey <<
")'</b>."
8927 diffReport <<
"\n\n<b>" << tableDifferences
8928 <<
"</b> member table differences identified between "
8929 <<
"<b>'" << groupName <<
"(" << groupKey
8930 <<
")'</b> and group "
8931 <<
"<b>'" << diffGroupName <<
"(" << diffKey <<
")'</b>."
8935 xmlOut.addTextElementToData(
"NoDifference", noDifference ?
"1" :
"0");
8936 xmlOut.addTextElementToData(
"DiffReport", diffReport.str());
8938 catch(
const std::runtime_error& e)
8940 __SUP_COUT_ERR__ <<
"Caught error while differencing group " << groupName <<
"("
8941 << groupKey <<
") with group " << diffGroupName <<
"(" << diffKey
8942 <<
")" << __E__ << e.what() << __E__;
8949 void ConfigurationGUISupervisor::handleTableDiff(
HttpXmlDocument& xmlOut,
8951 const std::string& tableName,
8955 __SUP_COUT__ <<
"Differencing tableName " << tableName <<
" v" << vA <<
" with v"
8965 std::string localAccumulatedErrors =
"";
8969 &localAccumulatedErrors,
8972 if(localAccumulatedErrors !=
"")
8973 xmlOut.addTextElementToData(
"Error", localAccumulatedErrors);
8975 catch(std::runtime_error& e)
8977 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version " << vA;
8978 ss <<
"\n\n...Here is why it failed:\n\n" << e.what() << __E__;
8979 __SUP_COUT_ERR__ <<
"\n" << ss.str();
8981 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
8985 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version: " << vA << __E__;
8990 catch(
const std::exception& e)
8992 ss <<
"Exception message: " << e.what();
8998 __SUP_COUT_ERR__ <<
"\n" << ss.str();
8999 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
9005 std::string localAccumulatedErrors =
"";
9009 &localAccumulatedErrors,
9012 if(localAccumulatedErrors !=
"")
9013 xmlOut.addTextElementToData(
"Error", localAccumulatedErrors);
9015 catch(std::runtime_error& e)
9017 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version " << vB;
9018 ss <<
"\n\n...Here is why it failed:\n\n" << e.what() << __E__;
9019 __SUP_COUT_ERR__ <<
"\n" << ss.str();
9021 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
9025 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version: " << vB << __E__;
9030 catch(
const std::exception& e)
9032 ss <<
"Exception message: " << e.what();
9038 __SUP_COUT_ERR__ <<
"\n" << ss.str();
9039 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
9042 bool noDifference =
true;
9043 std::stringstream diffReport;
9045 diffReport <<
"This difference report is between table " << tableName <<
" v" << vA
9046 <<
" and v" << vB <<
"</b>." << __E__;
9048 diffReport <<
"<INDENT>";
9049 diffReport <<
"<ul>";
9050 std::map<std::string , std::vector<std::string >>
9052 if(!table->diffTwoVersions(vA, vB, &diffReport))
9053 noDifference =
false;
9054 diffReport <<
"</ul></INDENT>";
9056 xmlOut.addTextElementToData(
"NoDifference", noDifference ?
"1" :
"0");
9057 xmlOut.addTextElementToData(
"DiffReport", diffReport.str());
9063 void ConfigurationGUISupervisor::testXDAQContext()
9067 __COUT_INFO__ <<
"Hello0!";
9069 __COUT_INFO__ <<
"Hello1!";
9071 __COUT_INFO__ <<
"Hello2!";
9073 __COUT_INFO__ <<
"Hello3!";
9079 __SUP_COUT_INFO__ <<
"Attempting test activation of the context group." << __E__;
9083 catch(
const std::runtime_error& e)
9086 <<
"The test activation of the context group failed. Ignoring error: \n"
9087 << e.what() << __E__;
9092 __SUP_COUT_WARN__ <<
"The test activation of the context group failed. Ignoring."
9097 __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)
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())
static void loadTableGroupThread(ConfigurationManagerRW *cfgMgr, std::string groupName, ots::TableGroupKey groupKey, std::shared_ptr< ots::GroupInfo > theGroupInfo, std::shared_ptr< std::atomic< bool >> theThreadDone)
TableBase * getVersionedTableByName(const std::string &tableName, TableVersion version, bool looseColumnMatching=false, std::string *accumulatedErrors=0, bool getRawData=false)
static const unsigned int PROCESSOR_COUNT
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
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)
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="")
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)