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);
86 void ConfigurationGUISupervisor::destroy(
void)
88 __SUP_COUT__ <<
"Destructing..." << __E__;
91 for(std::map<std::string, ConfigurationManagerRW*>::iterator it =
92 userConfigurationManagers_.begin();
93 it != userConfigurationManagers_.end();
99 userConfigurationManagers_.clear();
101 if(ConfigurationInterface::getInstance() !=
nullptr)
102 delete ConfigurationInterface::getInstance();
107 void ConfigurationGUISupervisor::defaultPage(xgi::Input* in, xgi::Output* out)
109 cgicc::Cgicc cgiIn(in);
110 std::string configWindowName =
112 if(configWindowName ==
"tableEditor")
113 *out <<
"<!DOCTYPE HTML><html lang='en'><frameset col='100%' row='100%'><frame "
114 "src='/WebPath/html/ConfigurationTableEditor.html?urn="
115 << this->getApplicationDescriptor()->getLocalId() <<
"'></frameset></html>";
116 if(configWindowName ==
"iterate")
117 *out <<
"<!DOCTYPE HTML><html lang='en'><frameset col='100%' row='100%'><frame "
118 "src='/WebPath/html/Iterate.html?urn="
119 << this->getApplicationDescriptor()->getLocalId() <<
"'></frameset></html>";
121 *out <<
"<!DOCTYPE HTML><html lang='en'><frameset col='100%' row='100%'><frame "
122 "src='/WebPath/html/ConfigurationGUI.html?urn="
123 << this->getApplicationDescriptor()->getLocalId() <<
"'></frameset></html>";
131 CorePropertySupervisorBase::setSupervisorProperty(
132 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.UserPermissionsThreshold,
133 "*=10 | deleteTreeNodeRecords=255 | saveTableInfo=255 | "
134 "deleteTableInfo=255");
136 CorePropertySupervisorBase::setSupervisorProperty(
137 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.RequireUserLockRequestTypes,
141 CorePropertySupervisorBase::setSupervisorProperty(
142 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.AutomatedRequestTypes,
"get*");
150 CorePropertySupervisorBase::addSupervisorProperty(
151 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.AutomatedRequestTypes,
152 "getActiveTableGroups");
155 CorePropertySupervisorBase::setSupervisorProperty(
156 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.CheckUserLockRequestTypes,
161 void ConfigurationGUISupervisor::request(
const std::string& requestType,
164 const WebUsers::RequestUserInfo& userInfo)
169 __COUTTV__(requestType);
238 refreshUserSession(userInfo.username_, (refresh ==
"1"));
239 __COUTTV__(userInfo.username_);
245 const std::set<TableGroupKey>& sortedKeys = groupInfo.keys_;
246 __COUTTV__(sortedKeys.size());
249 if(requestType ==
"saveTableInfo")
251 std::string tableName =
253 std::string columnCSV =
255 std::string allowOverwrite =
257 std::string tableDescription =
259 std::string columnChoicesCSV =
262 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
263 __SUP_COUT__ <<
"columnCSV: " << columnCSV << __E__;
264 __SUP_COUT__ <<
"tableDescription: " << tableDescription << __E__;
265 __SUP_COUT__ <<
"columnChoicesCSV: " << columnChoicesCSV << __E__;
266 __SUP_COUT__ <<
"allowOverwrite: " << allowOverwrite << __E__;
268 if(!allSupervisorInfo_.isWizardMode())
270 __SUP_SS__ <<
"Improper permissions for saving table info." << __E__;
271 xmlOut.addTextElementToData(
"Error", ss.str());
274 handleSaveTableInfoXML(xmlOut,
280 allowOverwrite ==
"1");
282 else if(requestType ==
"deleteTableInfo")
284 std::string tableName =
286 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
287 handleDeleteTableInfoXML(xmlOut, cfgMgr, tableName);
289 else if(requestType ==
"gatewayLaunchOTS" || requestType ==
"gatewayLaunchWiz" ||
290 requestType ==
"flattenToSystemAliases")
293 __SUP_COUT_WARN__ << requestType <<
" command received! " << __E__;
294 __COUT_WARN__ << requestType <<
" command received! " << __E__;
297 __SUP_COUT_INFO__ <<
"Launching " << requestType <<
"... " << __E__;
299 __SUP_COUT__ <<
"Extracting target context hostnames... " << __E__;
300 std::vector<std::string> hostnames;
303 if(requestType ==
"flattenToSystemAliases" &&
304 CorePropertySupervisorBase::allSupervisorInfo_.isWizardMode())
306 hostnames.push_back(__ENV__(
"OTS_CONFIGURATION_WIZARD_SUPERVISOR_SERVER"));
307 __SUP_COUT__ <<
"hostname = " << hostnames.back() << __E__;
318 auto contexts = contextTable->getContexts();
320 for(
const auto& context : contexts)
327 for(i = 0; i < context.address_.size(); ++i)
328 if(context.address_[i] ==
'/')
330 hostnames.push_back(context.address_.substr(j));
331 __SUP_COUT__ <<
"hostname = " << hostnames.back() << __E__;
336 __SUP_SS__ <<
"The Configuration Manager could not be initialized to "
343 catch(
const std::exception& e)
345 ss <<
"Exception message: " << e.what();
351 __SUP_COUT_ERR__ <<
"\n" << ss.str();
356 if(hostnames.size() == 0)
358 __SUP_SS__ <<
"No hostnames found to launch command '" + requestType +
359 "'... Is there a valid Context group activated?"
361 __SUP_COUT_ERR__ <<
"\n" << ss.str();
363 xmlOut.addTextElementToData(
"Error", ss.str());
366 for(
const auto& hostname : hostnames)
368 std::string fn = (std::string(__ENV__(
"SERVICE_DATA_PATH")) +
369 "/StartOTS_action_" + hostname +
".cmd");
370 FILE* fp = fopen(fn.c_str(),
"w");
373 if(requestType ==
"gatewayLaunchOTS")
374 fprintf(fp,
"LAUNCH_OTS");
375 else if(requestType ==
"gatewayLaunchWiz")
376 fprintf(fp,
"LAUNCH_WIZ");
377 else if(requestType ==
"flattenToSystemAliases")
379 fprintf(fp,
"FLATTEN_TO_SYSTEM_ALIASES");
387 __SUP_COUT_ERR__ <<
"Unable to open command file: " << fn << __E__;
390 else if(requestType ==
"versionTracking" || requestType ==
"getVersionTracking")
393 if(requestType ==
"getVersionTracking")
397 __SUP_COUT__ <<
"type: " << type << __E__;
400 xmlOut.addTextElementToData(
401 "versionTrackingStatus",
402 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
403 else if(type ==
"ON")
405 ConfigurationInterface::setVersionTrackingEnabled(
true);
406 xmlOut.addTextElementToData(
407 "versionTrackingStatus",
408 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
410 else if(type ==
"OFF")
412 ConfigurationInterface::setVersionTrackingEnabled(
false);
413 xmlOut.addTextElementToData(
414 "versionTrackingStatus",
415 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
418 else if(requestType ==
"getColumnTypes")
421 std::vector<std::string> allTypes = TableViewColumnInfo::getAllTypesForGUI();
422 std::vector<std::string> allDataTypes =
423 TableViewColumnInfo::getAllDataTypesForGUI();
424 std::map<std::pair<std::string, std::string>, std::string> allDefaults =
427 for(
const auto& type : allTypes)
428 xmlOut.addTextElementToData(
"columnTypeForGUI", type);
429 for(
const auto& dataType : allDataTypes)
430 xmlOut.addTextElementToData(
"columnDataTypeForGUI", dataType);
432 for(
const auto& colDefault : allDefaults)
434 xmlOut.addTextElementToData(
"columnDefaultDataType", colDefault.first.first);
435 xmlOut.addTextElementToData(
"columnDefaultTypeFilter",
436 colDefault.first.second);
437 xmlOut.addTextElementToData(
"columnDefaultValue", colDefault.second);
441 else if(requestType ==
"getGroupAliases")
446 1 == CgiDataUtilities::getDataAsInt(cgiIn,
"reloadActiveGroups");
448 __SUP_COUT__ <<
"reloadActive: " << reloadActive << __E__;
456 catch(std::runtime_error& e)
458 __SUP_SS__ << (
"Error loading active groups!\n\n" + std::string(e.what()))
460 __SUP_COUT_ERR__ <<
"\n" << ss.str();
461 xmlOut.addTextElementToData(
"Error", ss.str());
465 __SUP_SS__ << (
"Error loading active groups!\n\n") << __E__;
470 catch(
const std::exception& e)
472 ss <<
"Exception message: " << e.what();
477 __SUP_COUT_ERR__ <<
"\n" << ss.str();
478 xmlOut.addTextElementToData(
"Error", ss.str());
482 handleGroupAliasesXML(xmlOut, cfgMgr);
484 else if(requestType ==
"setGroupAliasInActiveBackbone")
486 std::string groupAliasCSV =
488 std::string groupNameCSV =
490 std::string groupKeyCSV =
493 __SUP_COUTV__(groupAliasCSV);
494 __SUP_COUTV__(groupNameCSV);
495 __SUP_COUTV__(groupKeyCSV);
497 handleSetGroupAliasInBackboneXML(
498 xmlOut, cfgMgr, groupAliasCSV, groupNameCSV, groupKeyCSV, userInfo.username_);
500 else if(requestType ==
"setTableAliasInActiveBackbone")
502 std::string tableAlias =
504 std::string tableName =
508 __SUP_COUT__ <<
"tableAlias: " << tableAlias << __E__;
509 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
510 __SUP_COUT__ <<
"version: " << version << __E__;
512 handleSetTableAliasInBackboneXML(xmlOut,
519 else if(requestType ==
"setAliasOfGroupMembers")
521 std::string versionAlias =
523 std::string groupName =
527 __SUP_COUT__ <<
"versionAlias: " << versionAlias << __E__;
528 __SUP_COUT__ <<
"groupName: " << groupName << __E__;
529 __SUP_COUT__ <<
"groupKey: " << groupKey << __E__;
531 handleAliasGroupMembersInBackboneXML(xmlOut,
538 else if(requestType ==
"getVersionAliases")
540 handleVersionAliasesXML(xmlOut, cfgMgr);
542 else if(requestType ==
"getTableGroups")
544 bool doNotReturnMembers =
545 CgiDataUtilities::getDataAsInt(cgiIn,
"doNotReturnMembers") == 1
549 __SUP_COUT__ <<
"doNotReturnMembers: " << doNotReturnMembers << __E__;
550 handleTableGroupsXML(xmlOut, cfgMgr, !doNotReturnMembers);
552 else if(requestType ==
"getTableGroupType")
554 std::string tableList =
556 __SUP_COUT__ <<
"tableList: " << tableList << __E__;
558 handleGetTableGroupTypeXML(xmlOut, cfgMgr, tableList);
560 else if(requestType ==
"getTables")
562 handleTablesXML(xmlOut, cfgMgr);
564 else if(requestType ==
"getContextMemberNames")
566 std::set<std::string> members = cfgMgr->getContextMemberNames();
568 for(
auto& member : members)
569 xmlOut.addTextElementToData(
"ContextMember", member);
571 else if(requestType ==
"getBackboneMemberNames")
573 std::set<std::string> members = cfgMgr->getBackboneMemberNames();
575 for(
auto& member : members)
576 xmlOut.addTextElementToData(
"BackboneMember", member);
578 else if(requestType ==
"getIterateMemberNames")
580 std::set<std::string> members = cfgMgr->getIterateMemberNames();
582 for(
auto& member : members)
583 xmlOut.addTextElementToData(
"IterateMember", member);
585 else if(requestType ==
"getSpecificTableGroup")
587 std::string groupName =
591 __SUP_COUT__ <<
"groupName: " << groupName << __E__;
592 __SUP_COUT__ <<
"groupKey: " << groupKey << __E__;
597 else if(requestType ==
"saveNewTableGroup")
599 std::string groupName =
601 bool ignoreWarnings =
602 CgiDataUtilities::getDataAsInt(cgiIn,
"ignoreWarnings");
603 bool allowDuplicates =
604 CgiDataUtilities::getDataAsInt(cgiIn,
"allowDuplicates");
605 bool lookForEquivalent =
606 CgiDataUtilities::getDataAsInt(cgiIn,
"lookForEquivalent");
607 std::string tableList =
609 std::string comment =
612 __SUP_COUT__ <<
"saveNewTableGroup: " << groupName << __E__;
613 __SUP_COUT__ <<
"tableList: " << tableList << __E__;
614 __SUP_COUT__ <<
"ignoreWarnings: " << ignoreWarnings << __E__;
615 __SUP_COUT__ <<
"allowDuplicates: " << allowDuplicates << __E__;
616 __SUP_COUT__ <<
"lookForEquivalent: " << lookForEquivalent << __E__;
617 __SUP_COUT__ <<
"comment: " << comment << __E__;
628 else if(requestType ==
"getSpecificTable")
630 std::string tableName =
633 int dataOffset = CgiDataUtilities::getDataAsInt(cgiIn,
"dataOffset");
634 int chunkSize = CgiDataUtilities::getDataAsInt(cgiIn,
"chunkSize");
637 std::string allowIllegalColumns =
639 __SUP_COUT__ <<
"allowIllegalColumns: " << (allowIllegalColumns ==
"1") << __E__;
642 __SUP_COUT__ <<
"rawData: " << (rawData ==
"1") << __E__;
644 __SUP_COUT__ <<
"getSpecificTable: " << tableName <<
" versionStr: " << versionStr
645 <<
" chunkSize: " << chunkSize <<
" dataOffset: " << dataOffset
649 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
651 if(allTableInfo.find(tableName) != allTableInfo.end())
653 if(versionStr ==
"" &&
654 allTableInfo.at(tableName).versions_.size())
657 auto it = allTableInfo.at(tableName).versions_.rbegin();
658 if(it->isScratchVersion())
662 else if(versionStr.find(ConfigurationManager::ALIAS_VERSION_PREAMBLE) == 0)
665 std::map<std::string ,
669 std::string versionAlias;
670 versionAlias = versionStr.substr(
671 ConfigurationManager::ALIAS_VERSION_PREAMBLE.size());
682 if(versionAliases.find(tableName) != versionAliases.end() &&
683 versionAliases[tableName].find(versionAlias) !=
684 versionAliases[tableName].end())
686 version = versionAliases[tableName][versionAlias];
687 __SUP_COUT__ <<
"version alias translated to: " << version << __E__;
692 << versionStr.substr(
693 ConfigurationManager::ALIAS_VERSION_PREAMBLE.size())
694 <<
"'was not found in active version aliases!" << __E__;
697 version = atoi(versionStr.c_str());
700 __SUP_COUT__ <<
"version: " << version << __E__;
702 handleGetTableXML(xmlOut,
706 (allowIllegalColumns ==
"1"),
709 xmlOut.addTextElementToData(
"DefaultRowValue", userInfo.username_);
711 else if(requestType ==
"saveSpecificTable")
713 std::string tableName =
715 int version = CgiDataUtilities::getDataAsInt(cgiIn,
"version");
716 int dataOffset = CgiDataUtilities::getDataAsInt(cgiIn,
"dataOffset");
717 bool sourceTableAsIs =
718 CgiDataUtilities::getDataAsInt(cgiIn,
"sourceTableAsIs");
719 bool lookForEquivalent =
720 CgiDataUtilities::getDataAsInt(cgiIn,
"lookForEquivalent");
721 int temporary = CgiDataUtilities::getDataAsInt(cgiIn,
"temporary");
722 std::string comment =
729 __SUP_COUT__ <<
"tableName: " << tableName <<
" version: " << version
730 <<
" temporary: " << temporary <<
" dataOffset: " << dataOffset
732 __SUP_COUT__ <<
"comment: " << comment << __E__;
733 __SUP_COUT__ <<
"data: " << data << __E__;
734 __SUP_COUT__ <<
"sourceTableAsIs: " << sourceTableAsIs << __E__;
735 __SUP_COUT__ <<
"lookForEquivalent: " << lookForEquivalent << __E__;
749 else if(requestType ==
"clearTableTemporaryVersions")
751 std::string tableName =
753 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
759 catch(std::runtime_error& e)
761 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
762 xmlOut.addTextElementToData(
763 "Error",
"Error clearing temporary views!\n " + std::string(e.what()));
767 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
768 xmlOut.addTextElementToData(
"Error",
"Error clearing temporary views! ");
771 else if(requestType ==
"clearTableCachedVersions")
773 std::string tableName =
775 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
786 catch(std::runtime_error& e)
788 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
789 xmlOut.addTextElementToData(
790 "Error",
"Error clearing cached views!\n " + std::string(e.what()));
794 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
795 xmlOut.addTextElementToData(
"Error",
"Error clearing cached views! ");
798 else if(requestType ==
"getTreeView")
805 int depth = CgiDataUtilities::getDataAsInt(cgiIn,
"depth");
806 bool hideStatusFalse = CgiDataUtilities::getDataAsInt(cgiIn,
"hideStatusFalse");
810 __SUP_COUTT__ <<
"tableGroup: " << tableGroup << __E__;
811 __SUP_COUTT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
812 __SUP_COUTT__ <<
"startPath: " << startPath << __E__;
813 __SUP_COUTT__ <<
"depth: " << depth << __E__;
814 __SUP_COUTT__ <<
"hideStatusFalse: " << hideStatusFalse << __E__;
815 __SUP_COUTT__ <<
"modifiedTables: " << modifiedTables << __E__;
816 __SUP_COUTT__ <<
"filterList: " << filterList << __E__;
818 handleFillTreeViewXML(xmlOut,
830 else if(requestType ==
"getTreeNodeCommonFields")
838 int depth = CgiDataUtilities::getDataAsInt(cgiIn,
"depth");
840 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
841 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
842 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
843 __SUP_COUT__ <<
"depth: " << depth << __E__;
846 __SUP_COUT__ <<
"fieldList: " << fieldList << __E__;
847 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
848 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
850 handleFillTreeNodeCommonFieldsXML(xmlOut,
860 else if(requestType ==
"getUniqueFieldValuesForRecords")
869 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
870 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
871 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
872 __SUP_COUT__ <<
"fieldList: " << fieldList << __E__;
873 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
874 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
876 handleFillUniqueFieldValuesForRecordsXML(xmlOut,
885 else if(requestType ==
"getTreeNodeFieldValues")
894 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
895 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
896 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
897 __SUP_COUT__ <<
"fieldList: " << fieldList << __E__;
898 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
899 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
901 handleFillGetTreeNodeFieldValuesXML(xmlOut,
910 else if(requestType ==
"setTreeNodeFieldValues")
920 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
921 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
922 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
923 __SUP_COUT__ <<
"fieldList: " << fieldList << __E__;
924 __SUP_COUT__ <<
"valueList: " << valueList << __E__;
925 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
926 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
928 handleFillSetTreeNodeFieldValuesXML(xmlOut,
939 else if(requestType ==
"addTreeNodeRecords")
947 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
948 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
949 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
950 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
951 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
953 handleFillCreateTreeNodeRecordsXML(xmlOut,
962 else if(requestType ==
"deleteTreeNodeRecords")
970 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
971 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
972 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
973 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
974 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
976 handleFillDeleteTreeNodeRecordsXML(xmlOut,
984 else if(requestType ==
"renameTreeNodeRecords")
993 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
994 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
995 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
996 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
997 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
998 __SUP_COUTV__(newRecordList);
1000 handleFillRenameTreeNodeRecordsXML(xmlOut,
1009 else if(requestType ==
"copyTreeNodeRecords")
1016 unsigned int numberOfCopies =
1017 CgiDataUtilities::getDataAsInt(cgiIn,
"numberOfCopies");
1021 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
1022 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
1023 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
1024 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
1025 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
1026 __SUP_COUTV__(numberOfCopies);
1028 handleFillCopyTreeNodeRecordsXML(xmlOut,
1037 else if(requestType ==
"getTableStructureStatusAsJSON")
1044 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
1045 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
1046 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
1047 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
1050 setupActiveTablesXML(xmlOut,
1059 xmlOut.addTextElementToData(
1060 "StructureStatusAsJSON",
1061 cfgMgr->
getTableByName(tableName)->getStructureStatusAsJSON(cfgMgr));
1063 catch(
const std::runtime_error& e)
1065 __SUP_SS__ <<
"The table plugin feature getStructureStatusAsJSON(), does not "
1066 "seem to be supported for the table '"
1068 <<
".' Make sure you have the expected table plugin in your path, "
1069 "or contact system admins."
1071 ss <<
"Here is the error: " << e.what() << __E__;
1075 else if(requestType ==
"getArtdaqNodes")
1079 __SUP_COUTV__(modifiedTables);
1081 handleGetArtdaqNodeRecordsXML(xmlOut, cfgMgr, modifiedTables);
1083 else if(requestType ==
"saveArtdaqNodes")
1087 std::string subsystemString =
1090 __SUP_COUTV__(modifiedTables);
1091 __SUP_COUTV__(nodeString);
1092 __SUP_COUTV__(subsystemString);
1094 handleSaveArtdaqNodeRecordsXML(
1095 nodeString, subsystemString, xmlOut, cfgMgr, modifiedTables);
1097 else if(requestType ==
"getArtdaqNodeLayout")
1099 std::string contextGroupName =
1103 __SUP_COUTV__(contextGroupName);
1104 __SUP_COUTV__(contextGroupKey);
1106 handleLoadArtdaqNodeLayoutXML(
1107 xmlOut, cfgMgr, contextGroupName,
TableGroupKey(contextGroupKey));
1109 else if(requestType ==
"saveArtdaqNodeLayout")
1112 std::string contextGroupName =
1116 __SUP_COUTV__(layout);
1117 __SUP_COUTV__(contextGroupName);
1118 __SUP_COUTV__(contextGroupKey);
1120 handleSaveArtdaqNodeLayoutXML(
1121 xmlOut, cfgMgr, layout, contextGroupName,
TableGroupKey(contextGroupKey));
1123 else if(requestType ==
"checkAffectedActiveGroups")
1128 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
1129 __SUP_COUT__ <<
"groupName: " << groupName << __E__;
1130 __SUP_COUT__ <<
"groupKey: " << groupKey << __E__;
1132 handleGetAffectedGroupsXML(
1133 xmlOut, cfgMgr, groupName,
TableGroupKey(groupKey), modifiedTables);
1135 else if(requestType ==
"saveTreeNodeEdit")
1139 std::string targetTableVersion =
1145 __SUP_COUT__ <<
"editNodeType: " << editNodeType << __E__;
1146 __SUP_COUT__ <<
"targetTable: " << targetTable << __E__;
1147 __SUP_COUT__ <<
"targetTableVersion: " << targetTableVersion << __E__;
1148 __SUP_COUT__ <<
"targetUID: " << targetUID << __E__;
1149 __SUP_COUT__ <<
"targetColumn: " << targetColumn << __E__;
1150 __SUP_COUT__ <<
"newValue: " << newValue << __E__;
1152 handleSaveTreeNodeEditXML(xmlOut,
1160 userInfo.username_);
1162 else if(requestType ==
"getLinkToChoices")
1165 std::string linkToTableVersion =
1172 __SUP_COUT__ <<
"linkToTableName: " << linkToTableName << __E__;
1173 __SUP_COUT__ <<
"linkToTableVersion: " << linkToTableVersion << __E__;
1174 __SUP_COUT__ <<
"linkIdType: " << linkIdType << __E__;
1175 __SUP_COUT__ <<
"linkIndex: " << linkIndex << __E__;
1176 __SUP_COUT__ <<
"linkInitId: " << linkInitId << __E__;
1178 handleGetLinkToChoicesXML(xmlOut,
1186 else if(requestType ==
"activateTableGroup")
1190 bool ignoreWarnings = CgiDataUtilities::getDataAsInt(cgiIn,
"ignoreWarnings");
1192 __SUP_COUT__ <<
"Activating group: " << groupName <<
"(" << groupKey <<
")"
1194 __SUP_COUTV__(ignoreWarnings);
1197 xmlOut.addTextElementToData(
"AttemptedGroupActivation",
"1");
1198 xmlOut.addTextElementToData(
"AttemptedGroupActivationName", groupName);
1199 xmlOut.addTextElementToData(
"AttemptedGroupActivationKey", groupKey);
1203 std::string accumulatedErrors, groupTypeString;
1209 groupName,
TableGroupKey(groupKey), &accumulatedErrors, &groupTypeString);
1211 if(accumulatedErrors !=
"")
1215 __SS__ <<
"Throwing exception on accumulated errors: "
1216 << accumulatedErrors << __E__;
1220 __COUT_WARN__ <<
"Ignoring warnings so ignoring this error:"
1221 << accumulatedErrors << __E__;
1222 __COUT_WARN__ <<
"Done ignoring the above error(s)." << __E__;
1224 xmlOut.addTextElementToData(
"AttemptedGroupActivationType", groupTypeString);
1226 catch(std::runtime_error& e)
1231 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
1232 xmlOut.addTextElementToData(
1234 "Error activating table group '" + groupName +
"(" + groupKey +
")" +
1235 ".' Please see details below:\n\n" + std::string(e.what()));
1236 __SUP_COUT_ERR__ <<
"Errors detected so de-activating group: " << groupName
1237 <<
" (" << groupKey <<
")" << __E__;
1246 catch(cet::exception& e)
1252 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
1253 xmlOut.addTextElementToData(
"Error",
1254 "Error activating table group '" + groupName +
1255 "(" + groupKey +
")" +
"!'\n\n" +
1256 std::string(e.what()));
1257 __SUP_COUT_ERR__ <<
"Errors detected so de-activating group: " << groupName
1258 <<
" (" << groupKey <<
")" << __E__;
1269 __SUP_COUT__ <<
"Unknown error detected!" << __E__;
1281 else if(requestType ==
"getActiveTableGroups")
1283 else if(requestType ==
"copyViewToCurrentColumns")
1285 std::string tableName =
1289 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
1290 __SUP_COUT__ <<
"sourceVersion: " << sourceVersion << __E__;
1291 __SUP_COUT__ <<
"userInfo.username_: " << userInfo.username_ << __E__;
1297 newTemporaryVersion =
1300 __SUP_COUT__ <<
"New temporary version = " << newTemporaryVersion << __E__;
1302 catch(std::runtime_error& e)
1304 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
1305 xmlOut.addTextElementToData(
"Error",
1306 "Error copying view from '" + tableName +
"_v" +
1307 sourceVersion +
"'! " +
1308 std::string(e.what()));
1312 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
1313 xmlOut.addTextElementToData(
1315 "Error copying view from '" + tableName +
"_v" + sourceVersion +
"'! ");
1318 handleGetTableXML(xmlOut, cfgMgr, tableName, newTemporaryVersion);
1320 else if(requestType ==
"getLastTableGroups")
1323 std::map<std::string ,
1324 std::tuple<std::string ,
1329 theRemoteWebUsers_.getLastTableGroups(theGroups);
1331 for(
const auto& theGroup : theGroups)
1333 xmlOut.addTextElementToData(
"Last" + theGroup.first +
"GroupName",
1334 std::get<0>(theGroup.second));
1335 xmlOut.addTextElementToData(
"Last" + theGroup.first +
"GroupKey",
1336 std::get<1>(theGroup.second).toString());
1337 xmlOut.addTextElementToData(
"Last" + theGroup.first +
"GroupTime",
1338 std::get<2>(theGroup.second));
1371 handleOtherSubsystemActiveGroups(xmlOut, cfgMgr,
false );
1373 else if(requestType ==
"getSubsytemTableGroups")
1375 std::string subsystem =
1377 __SUP_COUTV__(subsystem);
1378 handleOtherSubsystemActiveGroups(
1379 xmlOut, cfgMgr,
true , subsystem);
1381 else if(requestType ==
"diffWithActiveGroup")
1383 std::string groupName =
1386 __SUP_COUTV__(groupName);
1387 __SUP_COUTV__(groupKey);
1392 else if(requestType ==
"diffWithGroupKey")
1394 std::string groupName =
1398 std::string diffGroupName =
1400 __SUP_COUTV__(groupName);
1401 __SUP_COUTV__(groupKey);
1402 __SUP_COUTV__(diffKey);
1403 __SUP_COUTV__(diffGroupName);
1405 handleGroupDiff(xmlOut,
1412 else if(requestType ==
"diffTableVersions")
1414 std::string tableName =
1418 __SUP_COUTV__(tableName);
1423 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
1426 if(allTableInfo.find(tableName) != allTableInfo.end())
1428 if(vA.find(ConfigurationManager::ALIAS_VERSION_PREAMBLE) == 0)
1431 std::map<std::string ,
1435 std::string versionAlias;
1437 vA.substr(ConfigurationManager::ALIAS_VERSION_PREAMBLE.size());
1439 if(versionAliases.find(tableName) != versionAliases.end() &&
1440 versionAliases[tableName].find(versionAlias) !=
1441 versionAliases[tableName].end())
1443 versionA = versionAliases[tableName][versionAlias];
1444 __SUP_COUT__ <<
"version alias translated to: " << versionA << __E__;
1447 __SUP_COUT_WARN__ <<
"version alias '" << versionAlias
1448 <<
"'was not found in active version aliases!"
1452 versionA = atoi(vA.c_str());
1454 if(vB.find(ConfigurationManager::ALIAS_VERSION_PREAMBLE) == 0)
1457 std::map<std::string ,
1461 std::string versionAlias;
1463 vB.substr(ConfigurationManager::ALIAS_VERSION_PREAMBLE.size());
1465 if(versionAliases.find(tableName) != versionAliases.end() &&
1466 versionAliases[tableName].find(versionAlias) !=
1467 versionAliases[tableName].end())
1469 versionB = versionAliases[tableName][versionAlias];
1470 __SUP_COUT__ <<
"version alias translated to: " << versionB << __E__;
1473 __SUP_COUT_WARN__ <<
"version alias '" << versionAlias
1474 <<
"'was not found in active version aliases!"
1478 versionB = atoi(vB.c_str());
1482 versionA = atoi(vA.c_str());
1483 versionB = atoi(vB.c_str());
1486 __SUP_COUTV__(versionA);
1487 __SUP_COUTV__(versionB);
1489 handleTableDiff(xmlOut, cfgMgr, tableName, versionA, versionB);
1491 else if(requestType ==
"savePlanCommandSequence")
1494 std::string commands =
1500 __SUP_COUTV__(modifiedTables);
1501 __SUP_COUTV__(planName);
1502 __SUP_COUTV__(commands);
1503 __SUP_COUTV__(groupName);
1504 __SUP_COUTV__(groupKey);
1506 handleSavePlanCommandSequenceXML(xmlOut,
1515 else if(requestType ==
"mergeGroups")
1517 std::string groupANameContext =
1519 std::string groupAKeyContext =
1521 std::string groupBNameContext =
1523 std::string groupBKeyContext =
1525 std::string groupANameConfig =
1528 std::string groupBNameConfig =
1533 __SUP_COUTV__(groupANameContext);
1534 __SUP_COUTV__(groupAKeyContext);
1535 __SUP_COUTV__(groupBNameContext);
1536 __SUP_COUTV__(groupBKeyContext);
1537 __SUP_COUTV__(groupANameConfig);
1538 __SUP_COUTV__(groupAKeyConfig);
1539 __SUP_COUTV__(groupBNameConfig);
1540 __SUP_COUTV__(groupBKeyConfig);
1541 __SUP_COUTV__(mergeApproach);
1543 handleMergeGroupsXML(xmlOut,
1558 __SUP_SS__ <<
"requestType Request, " << requestType
1559 <<
", not recognized by the Configuration GUI Supervisor (was it "
1560 "intended for another Supervisor?)."
1562 __SUP_COUT__ <<
"\n" << ss.str();
1563 xmlOut.addTextElementToData(
"Error", ss.str());
1566 __SUP_COUTT__ <<
"cfgMgr runtime=" << cfgMgr->runTimeSeconds() << __E__;
1569 xmlOut, cfgMgr, userInfo.username_);
1570 __SUP_COUTT__ <<
"cfgMgr runtime=" << cfgMgr->runTimeSeconds() << __E__;
1573 catch(
const std::runtime_error& e)
1575 __SS__ <<
"A fatal error occurred while handling the request '" << requestType
1576 <<
".' Error: " << e.what() << __E__;
1577 __COUT_ERR__ <<
"\n" << ss.str();
1578 xmlOut.addTextElementToData(
"Error", ss.str());
1583 xmlOut.addTextElementToData(
1585 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
1589 __COUT_ERR__ <<
"Error getting version tracking status!" << __E__;
1594 __SS__ <<
"An unknown fatal error occurred while handling the request '"
1595 << requestType <<
".'" << __E__;
1600 catch(
const std::exception& e)
1602 ss <<
"Exception message: " << e.what();
1607 __COUT_ERR__ <<
"\n" << ss.str();
1608 xmlOut.addTextElementToData(
"Error", ss.str());
1613 xmlOut.addTextElementToData(
1615 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
1619 __COUT_ERR__ <<
"Error getting version tracking status!" << __E__;
1639 void ConfigurationGUISupervisor::handleGetAffectedGroupsXML(
1642 const std::string& rootGroupName,
1644 const std::string& modifiedTables)
1647 __SUP_COUT__ <<
"rootGroupName " << rootGroupName <<
"(" << rootGroupKey
1648 <<
"). modifiedTables = " << modifiedTables << __E__;
1650 std::map<std::string, std::pair<std::string, TableGroupKey>> consideredGroups =
1655 if(consideredGroups[ConfigurationManager::GROUP_TYPE_NAME_CONTEXT].second.isInvalid())
1657 __SUP_COUT__ <<
"Finding a context group to consider..." << __E__;
1658 if(cfgMgr->getFailedTableGroups().find(
1659 ConfigurationManager::GROUP_TYPE_NAME_CONTEXT) !=
1660 cfgMgr->getFailedTableGroups().end())
1662 consideredGroups[ConfigurationManager::GROUP_TYPE_NAME_CONTEXT] =
1663 cfgMgr->getFailedTableGroups().at(
1664 ConfigurationManager::GROUP_TYPE_NAME_CONTEXT);
1666 else if(cfgMgr->getFailedTableGroups().find(
1667 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN) !=
1668 cfgMgr->getFailedTableGroups().end())
1670 consideredGroups[ConfigurationManager::GROUP_TYPE_NAME_CONTEXT] =
1671 cfgMgr->getFailedTableGroups().at(
1672 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN);
1675 if(consideredGroups[ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION]
1676 .second.isInvalid())
1678 __SUP_COUT__ <<
"Finding a table group to consider..." << __E__;
1679 if(cfgMgr->getFailedTableGroups().find(
1680 ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION) !=
1681 cfgMgr->getFailedTableGroups().end())
1683 consideredGroups[ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION] =
1684 cfgMgr->getFailedTableGroups().at(
1685 ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION);
1687 else if(cfgMgr->getFailedTableGroups().find(
1688 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN) !=
1689 cfgMgr->getFailedTableGroups().end())
1691 consideredGroups[ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION] =
1692 cfgMgr->getFailedTableGroups().at(
1693 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN);
1702 std::map<std::string ,
TableVersion > rootGroupMemberMap;
1707 &rootGroupMemberMap,
1717 consideredGroups[groupType] =
1718 std::pair<std::string, TableGroupKey>(rootGroupName, rootGroupKey);
1720 catch(
const std::runtime_error& e)
1723 if(rootGroupName.size())
1725 __SUP_SS__ <<
"Failed to determine type of table group for " << rootGroupName
1726 <<
"(" << rootGroupKey <<
")! " << e.what() << __E__;
1727 __SUP_COUT_ERR__ <<
"\n" << ss.str();
1732 __SUP_COUT__ <<
"Did not modify considered active groups due to empty root group "
1733 "name - assuming this was intentional."
1739 if(rootGroupName.size())
1741 __SUP_COUT_ERR__ <<
"Failed to determine type of table group for "
1742 << rootGroupName <<
"(" << rootGroupKey <<
")!" << __E__;
1747 __SUP_COUT__ <<
"Did not modify considered active groups due to empty root group "
1748 "name - assuming this was intentional."
1752 std::map<std::string ,
1755 std::map<std::string ,
1757 modifiedTablesMapIt;
1759 std::istringstream f(modifiedTables);
1760 std::string table, version;
1761 while(getline(f, table,
','))
1763 getline(f, version,
',');
1764 modifiedTablesMap.insert(
1767 std::pair<bool /*foundAffectedGroup*/, TableVersion /*version*/>>(
1771 __SUP_COUT__ << modifiedTables << __E__;
1772 for(
auto& pair : modifiedTablesMap)
1773 __SUP_COUT__ <<
"modified table " << pair.first <<
":" << pair.second.second
1778 xercesc::DOMElement* parentEl =
nullptr;
1779 std::string groupComment;
1780 std::vector<std::string> orderedGroupTypes(
1781 {ConfigurationManager::GROUP_TYPE_NAME_CONTEXT,
1782 ConfigurationManager::GROUP_TYPE_NAME_BACKBONE,
1783 ConfigurationManager::GROUP_TYPE_NAME_ITERATE,
1784 ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION});
1785 for(
auto groupType : orderedGroupTypes)
1787 if(consideredGroups.find(groupType) == consideredGroups.end())
1790 const std::pair<std::string, TableGroupKey>& group = consideredGroups[groupType];
1792 if(group.second.isInvalid())
1795 __SUP_COUT__ <<
"Considering " << groupType <<
" group " << group.first <<
" ("
1796 << group.second <<
")" << __E__;
1814 __SUP_COUT__ <<
"groupComment = " << groupComment << __E__;
1816 for(
auto& table : memberMap)
1818 if((modifiedTablesMapIt = modifiedTablesMap.find(table.first)) !=
1821 table.second != (*modifiedTablesMapIt).second.second)
1823 __SUP_COUT__ <<
"Affected by " << (*modifiedTablesMapIt).first <<
":"
1824 << (*modifiedTablesMapIt).second.second << __E__;
1826 memberMap[table.first] = (*modifiedTablesMapIt).second.second;
1827 (*modifiedTablesMapIt).second.first =
true;
1831 parentEl = xmlOut.addTextElementToData(
"AffectedActiveGroup",
"");
1835 if(groupType == ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION)
1837 __SUP_COUT__ <<
"Considering mockup tables for Configuration Group..."
1839 for(
auto& table : modifiedTablesMap)
1841 if(table.second.first)
1844 if(table.second.second.isMockupVersion() &&
1845 memberMap.find(table.first) == memberMap.end())
1847 __SUP_COUT__ <<
"Found mockup table '" << table.first
1848 <<
"' for Configuration Group." << __E__;
1849 memberMap[table.first] = table.second.second;
1852 parentEl = xmlOut.addTextElementToData(
"AffectedActiveGroup",
"");
1856 "AddMemberVersion", table.second.second.toString(), parentEl);
1863 __SUP_COUTV__(affected);
1867 parentEl = xmlOut.addTextElementToData(
"AffectedActiveGroup",
"");
1872 for(
auto& table : memberMap)
1876 "MemberVersion", table.second.toString(), parentEl);
1881 catch(std::runtime_error& e)
1883 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
1884 xmlOut.addTextElementToData(
1885 "Error",
"Error getting affected groups! " + std::string(e.what()));
1889 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
1890 xmlOut.addTextElementToData(
"Error",
"Error getting affected groups! ");
1901 void ConfigurationGUISupervisor::setupActiveTablesXML(
1904 const std::string& groupName,
1906 const std::string& modifiedTables,
1908 bool doGetGroupInfo,
1909 std::map<std::string /*name*/, TableVersion /*version*/>* returnMemberMap,
1910 bool outputActiveTables,
1911 std::string* accumulatedErrors)
1914 xmlOut.addTextElementToData(
"tableGroup", groupName);
1915 xmlOut.addTextElementToData(
"tableGroupKey", groupKey.
toString());
1917 bool usingActiveGroups = (groupName ==
"" || groupKey.
isInvalid());
1925 __SUP_COUT__ <<
"Refreshing all table info, ignoring warnings..." << __E__;
1926 std::string accumulatedWarnings =
"";
1928 &accumulatedWarnings,
1942 __SUP_COUT__ <<
"Restoring active table group tables..." << __E__;
1944 for(
const auto& activeGroup : activeGroups)
1946 if(activeGroup.second.first == groupName &&
1947 activeGroup.second.second == groupKey)
1949 __SUP_COUTT__ <<
"Skipping target active group." << __E__;
1952 __SUP_COUTT__ <<
"Loading " << activeGroup.first <<
" "
1953 << activeGroup.second.first <<
"(" << activeGroup.second.second
1958 activeGroup.second.second,
1964 __SUP_COUT__ <<
"Ignoring errors while setting up active tables for "
1965 << activeGroup.second.first <<
"("
1966 << activeGroup.second.second <<
")..." << __E__;
1972 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
1974 std::map<std::string ,
TableVersion > modifiedTablesMap;
1976 modifiedTablesMapIt;
1978 if(usingActiveGroups)
1981 __SUP_COUT__ <<
"Using active groups." << __E__;
1985 __SUP_COUT__ <<
"Loading group '" << groupName <<
"(" << groupKey <<
")'"
1988 std::string groupComment, groupAuthor, tableGroupCreationTime, groupType;
1997 doGetGroupInfo ? &groupComment : 0,
1998 doGetGroupInfo ? &groupAuthor : 0,
1999 doGetGroupInfo ? &tableGroupCreationTime : 0,
2001 doGetGroupInfo ? &groupType : 0);
2005 xmlOut.addTextElementToData(
"tableGroupComment", groupComment);
2006 xmlOut.addTextElementToData(
"tableGroupAuthor", groupAuthor);
2007 xmlOut.addTextElementToData(
"tableGroupCreationTime", tableGroupCreationTime);
2008 xmlOut.addTextElementToData(
"tableGroupType", groupType);
2011 if(accumulatedErrors && *accumulatedErrors !=
"")
2012 __SUP_COUTV__(*accumulatedErrors);
2018 std::istringstream f(modifiedTables);
2019 std::string table, version;
2020 while(getline(f, table,
','))
2022 getline(f, version,
',');
2023 modifiedTablesMap.insert(
2024 std::pair<std::string /*name*/, TableVersion /*version*/>(
2028 for(
auto& pair : modifiedTablesMap)
2029 __SUP_COUT__ <<
"modified table " << pair.first <<
":" << pair.second
2034 std::map<std::string, TableVersion> allActivePairs = cfgMgr->
getActiveVersions();
2035 xmlOut.addTextElementToData(
"DefaultNoLink",
2036 TableViewColumnInfo::DATATYPE_LINK_DEFAULT);
2039 std::set<std::string, StringMacros::IgnoreCaseCompareStruct> orderedTableSet;
2040 for(
const auto& tablePair : allActivePairs)
2041 orderedTableSet.emplace(tablePair.first);
2043 std::map<std::string, TableInfo>::const_iterator tableInfoIt;
2044 for(
auto& orderedTableName : orderedTableSet)
2046 tableInfoIt = allTableInfo.find(orderedTableName);
2047 if(tableInfoIt == allTableInfo.end())
2049 __SS__ <<
"Impossible missing table in map '" << orderedTableName <<
"'"
2054 if(outputActiveTables)
2055 xmlOut.addTextElementToData(
"ActiveTableName", orderedTableName);
2059 if((modifiedTablesMapIt = modifiedTablesMap.find(orderedTableName)) !=
2060 modifiedTablesMap.end())
2062 __SUP_COUT__ <<
"Found modified table " << (*modifiedTablesMapIt).first
2063 <<
": trying... " << (*modifiedTablesMapIt).second << __E__;
2067 tableInfoIt->second.tablePtr_->setActiveView(
2068 (*modifiedTablesMapIt).second);
2072 __SUP_SS__ <<
"Modified table version v" << (*modifiedTablesMapIt).second
2073 <<
" failed. Reverting to v"
2074 << tableInfoIt->second.tablePtr_->getView().getVersion() <<
"."
2076 __SUP_COUT_WARN__ <<
"Warning detected!\n\n " << ss.str() << __E__;
2077 xmlOut.addTextElementToData(
2079 "Error setting up active tables!\n\n" + std::string(ss.str()));
2083 if(outputActiveTables)
2085 xmlOut.addTextElementToData(
2086 "ActiveTableVersion",
2087 tableInfoIt->second.tablePtr_->getView().getVersion().toString());
2088 xmlOut.addTextElementToData(
2089 "ActiveTableComment",
2090 tableInfoIt->second.tablePtr_->getView().getAuthor() +
": " +
2091 tableInfoIt->second.tablePtr_->getView().getComment());
2099 catch(std::runtime_error& e)
2101 __SUP_SS__ << (
"Error setting up active tables!\n\n" + std::string(e.what()))
2103 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2104 xmlOut.addTextElementToData(
"Error", ss.str());
2109 __SUP_SS__ << (
"Error setting up active tables!\n\n") << __E__;
2114 catch(
const std::exception& e)
2116 ss <<
"Exception message: " << e.what();
2121 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2122 xmlOut.addTextElementToData(
"Error", ss.str());
2141 void ConfigurationGUISupervisor::handleFillCreateTreeNodeRecordsXML(
2144 const std::string& groupName,
2146 const std::string& startPath,
2147 const std::string& modifiedTables,
2148 const std::string& recordList,
2149 const std::string& author)
2152 setupActiveTablesXML(xmlOut,
2177 bool firstSave =
true;
2184 std::istringstream f(recordList);
2185 std::string recordUID;
2187 while(getline(f, recordUID,
','))
2191 __SUP_COUT__ <<
"recordUID " << recordUID << __E__;
2196 .isTemporaryVersion())
2198 __SUP_COUT__ <<
"Start version " << temporaryVersion << __E__;
2206 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion
2210 __SUP_COUT__ <<
"Using temporary version " << temporaryVersion
2216 backupView.copy(table->getView(), temporaryVersion, author);
2225 unsigned int row = table->getViewP()->addRow(
2232 unsigned int col = table->getViewP()->getColStatus();
2233 table->getViewP()->setURIEncodedValue(
"1", row, col);
2240 table->getViewP()->setURIEncodedValue(
2241 recordUID, row, table->getViewP()->getColUID());
2249 table->getViewP()->init();
2253 __SUP_COUT_INFO__ <<
"Reverting to original view." << __E__;
2254 __SUP_COUT__ <<
"Before:" << __E__;
2255 table->getViewP()->
print();
2256 table->getViewP()->copy(backupView, temporaryVersion, author);
2257 __SUP_COUT__ <<
"After:" << __E__;
2258 table->getViewP()->
print();
2264 handleFillModifiedTablesXML(xmlOut, cfgMgr);
2266 catch(std::runtime_error& e)
2268 __SUP_SS__ << (
"Error creating new record(s)!\n\n" + std::string(e.what()))
2270 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2271 xmlOut.addTextElementToData(
"Error", ss.str());
2275 __SUP_SS__ << (
"Error creating new record(s)!\n\n") << __E__;
2280 catch(
const std::exception& e)
2282 ss <<
"Exception message: " << e.what();
2287 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2288 xmlOut.addTextElementToData(
"Error", ss.str());
2295 void ConfigurationGUISupervisor::handleFillModifiedTablesXML(
2300 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
2301 std::map<std::string, TableVersion> allActivePairs = cfgMgr->
getActiveVersions();
2302 for(
auto& activePair : allActivePairs)
2304 xmlOut.addTextElementToData(
"NewActiveTableName", activePair.first);
2305 xmlOut.addTextElementToData(
"NewActiveTableVersion",
2306 allTableInfo.at(activePair.first)
2307 .tablePtr_->getView()
2310 xmlOut.addTextElementToData(
2311 "NewActiveTableComment",
2312 allTableInfo.at(activePair.first).tablePtr_->getView().getAuthor() +
": " +
2313 allTableInfo.at(activePair.first).tablePtr_->getView().getComment());
2316 catch(std::runtime_error& e)
2318 __SUP_SS__ << (
"Error!\n\n" + std::string(e.what())) << __E__;
2319 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2320 xmlOut.addTextElementToData(
"Error", ss.str());
2324 __SUP_SS__ << (
"Error!\n\n") << __E__;
2329 catch(
const std::exception& e)
2331 ss <<
"Exception message: " << e.what();
2336 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2337 xmlOut.addTextElementToData(
"Error", ss.str());
2355 void ConfigurationGUISupervisor::handleFillDeleteTreeNodeRecordsXML(
2358 const std::string& groupName,
2360 const std::string& startPath,
2361 const std::string& modifiedTables,
2362 const std::string& recordList)
2365 setupActiveTablesXML(xmlOut,
2390 bool firstSave =
true;
2394 std::istringstream f(recordList);
2395 std::string recordUID;
2398 while(getline(f, recordUID,
','))
2402 __SUP_COUT__ <<
"recordUID " << recordUID << __E__;
2407 .isTemporaryVersion())
2409 __SUP_COUT__ <<
"Start version " << temporaryVersion << __E__;
2417 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion
2421 __SUP_COUT__ <<
"Using temporary version " << temporaryVersion
2432 table->getViewP()->findRow(table->getViewP()->getColUID(), recordUID);
2433 table->getViewP()->deleteRow(row);
2438 table->getViewP()->init();
2440 handleFillModifiedTablesXML(xmlOut, cfgMgr);
2442 catch(std::runtime_error& e)
2444 __SUP_SS__ << (
"Error removing record(s)!\n\n" + std::string(e.what())) << __E__;
2445 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2446 xmlOut.addTextElementToData(
"Error", ss.str());
2450 __SUP_SS__ << (
"Error removing record(s)!\n\n") << __E__;
2455 catch(
const std::exception& e)
2457 ss <<
"Exception message: " << e.what();
2462 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2463 xmlOut.addTextElementToData(
"Error", ss.str());
2483 void ConfigurationGUISupervisor::handleFillRenameTreeNodeRecordsXML(
2486 const std::string& groupName,
2488 const std::string& startPath,
2489 const std::string& modifiedTables,
2490 const std::string& recordList,
2491 const std::string& newRecordList)
2494 setupActiveTablesXML(xmlOut,
2520 std::vector<std::string> recordArray =
2522 std::vector<std::string> newRecordArray =
2528 if(recordArray.size() == 0 || recordArray.size() != newRecordArray.size())
2531 <<
"Invalid record size vs new record name size, they must be the same: "
2532 << recordArray.size() <<
" vs " << newRecordArray.size() << __E__;
2538 if(!(temporaryVersion = targetNode.
getTableVersion()).isTemporaryVersion())
2540 __SUP_COUT__ <<
"Start version " << temporaryVersion << __E__;
2548 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion << __E__;
2551 __SUP_COUT__ <<
"Using temporary version " << temporaryVersion << __E__;
2558 for(
unsigned int i = 0; i < recordArray.size(); ++i)
2560 row = table->getViewP()->findRow(
2561 table->getViewP()->getColUID(),
2564 table->getViewP()->setValueAsString(
2565 newRecordArray[i], row, table->getViewP()->getColUID());
2568 table->getViewP()->init();
2570 handleFillModifiedTablesXML(xmlOut, cfgMgr);
2572 catch(std::runtime_error& e)
2574 __SUP_SS__ << (
"Error renaming record(s)!\n\n" + std::string(e.what())) << __E__;
2575 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2576 xmlOut.addTextElementToData(
"Error", ss.str());
2580 __SUP_SS__ << (
"Error renaming record(s)!\n\n") << __E__;
2585 catch(
const std::exception& e)
2587 ss <<
"Exception message: " << e.what();
2592 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2593 xmlOut.addTextElementToData(
"Error", ss.str());
2614 void ConfigurationGUISupervisor::handleFillCopyTreeNodeRecordsXML(
2617 const std::string& groupName,
2619 const std::string& startPath,
2620 const std::string& modifiedTables,
2621 const std::string& recordList,
2622 unsigned int numberOfCopies )
2628 setupActiveTablesXML(xmlOut,
2654 std::vector<std::string> recordArray =
2660 if(!(temporaryVersion = targetNode.
getTableVersion()).isTemporaryVersion())
2662 __SUP_COUT__ <<
"Start version " << temporaryVersion << __E__;
2670 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion << __E__;
2673 __SUP_COUT__ <<
"Using temporary version " << temporaryVersion << __E__;
2680 for(
const auto& recordUID : recordArray)
2682 row = table->getViewP()->findRow(table->getViewP()->getColUID(),
2684 for(
unsigned int i = 0; i < numberOfCopies; ++i)
2685 table->getViewP()->copyRows(
2695 table->getViewP()->init();
2697 handleFillModifiedTablesXML(xmlOut, cfgMgr);
2699 catch(std::runtime_error& e)
2701 __SUP_SS__ << (
"Error copying record(s)!\n\n" + std::string(e.what())) << __E__;
2702 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2703 xmlOut.addTextElementToData(
"Error", ss.str());
2707 __SUP_SS__ << (
"Error copying record(s)!\n\n") << __E__;
2712 catch(
const std::exception& e)
2714 ss <<
"Exception message: " << e.what();
2719 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2720 xmlOut.addTextElementToData(
"Error", ss.str());
2741 void ConfigurationGUISupervisor::handleFillSetTreeNodeFieldValuesXML(
2744 const std::string& groupName,
2746 const std::string& startPath,
2747 const std::string& modifiedTables,
2748 const std::string& recordList,
2749 const std::string& fieldList,
2750 const std::string& valueList,
2751 const std::string& author)
2754 setupActiveTablesXML(xmlOut,
2769 std::vector<std::string > fieldPaths;
2772 std::istringstream f(fieldList);
2773 std::string fieldPath;
2774 while(getline(f, fieldPath,
','))
2778 __SUP_COUT__ << fieldList << __E__;
2779 for(
const auto& field : fieldPaths)
2780 __SUP_COUT__ <<
"fieldPath " << field << __E__;
2783 std::vector<std::string > fieldValues;
2786 std::istringstream f(valueList);
2787 std::string fieldValue;
2788 while(getline(f, fieldValue,
','))
2790 fieldValues.push_back(fieldValue);
2795 if(valueList.size() && valueList[valueList.size() - 1] ==
',')
2796 fieldValues.push_back(
"");
2798 __SUP_COUT__ << valueList << __E__;
2799 for(
const auto& value : fieldValues)
2800 __SUP_COUT__ <<
"fieldValue " << value << __E__;
2803 if(fieldPaths.size() != fieldValues.size())
2806 __THROW__(ss.str() +
"Mismatch in fields and values array size!");
2813 std::istringstream f(recordList);
2814 std::string recordUID;
2817 while(getline(f, recordUID,
','))
2822 xmlOut.addTextElementToData(
"fieldValues", recordUID);
2825 for(i = 0; i < fieldPaths.size(); ++i)
2827 __SUP_COUT__ <<
"fieldPath " << fieldPaths[i] << __E__;
2828 __SUP_COUT__ <<
"fieldValue " << fieldValues[i] << __E__;
2833 cfgMgr->
getNode(startPath +
"/" + recordUID +
"/" + fieldPaths[i],
2874 if(!(temporaryVersion = table->getViewP()->getVersion())
2875 .isTemporaryVersion())
2885 __SUP_COUT__ <<
"Created temporary version "
2890 __SUP_COUT__ <<
"Using temporary version " << table->
getTableName()
2891 <<
"-v" << temporaryVersion << __E__;
2895 table->getViewP()->setURIEncodedValue(fieldValues[i],
2906 handleFillModifiedTablesXML(xmlOut, cfgMgr);
2908 catch(std::runtime_error& e)
2910 __SUP_SS__ << (
"Error setting field values!\n\n" + std::string(e.what()))
2912 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2913 xmlOut.addTextElementToData(
"Error", ss.str());
2917 __SUP_SS__ << (
"Error setting field values!\n\n") << __E__;
2922 catch(
const std::exception& e)
2924 ss <<
"Exception message: " << e.what();
2929 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2930 xmlOut.addTextElementToData(
"Error", ss.str());
2949 void ConfigurationGUISupervisor::handleFillGetTreeNodeFieldValuesXML(
2952 const std::string& groupName,
2954 const std::string& startPath,
2955 const std::string& modifiedTables,
2956 const std::string& recordList,
2957 const std::string& fieldList)
2960 setupActiveTablesXML(
2961 xmlOut, cfgMgr, groupName, groupKey, modifiedTables,
false );
2968 std::vector<std::string > fieldPaths;
2971 std::istringstream f(fieldList);
2972 std::string fieldPath;
2973 while(getline(f, fieldPath,
','))
2977 __SUP_COUT__ << fieldList << __E__;
2982 std::istringstream f(recordList);
2983 std::string recordUID;
2984 while(getline(f, recordUID,
','))
2988 __SUP_COUT__ <<
"recordUID " << recordUID << __E__;
2990 xercesc::DOMElement* parentEl =
2991 xmlOut.addTextElementToData(
"fieldValues", recordUID);
2994 for(
const auto& fieldPath : fieldPaths)
3000 cfgMgr->
getNode(startPath +
"/" + recordUID +
"/" + fieldPath);
3012 catch(std::runtime_error& e)
3014 __SUP_SS__ << (
"Error getting field values!\n\n" + std::string(e.what()))
3016 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3017 xmlOut.addTextElementToData(
"Error", ss.str());
3021 __SUP_SS__ << (
"Error getting field values!\n\n") << __E__;
3026 catch(
const std::exception& e)
3028 ss <<
"Exception message: " << e.what();
3033 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3034 xmlOut.addTextElementToData(
"Error", ss.str());
3057 void ConfigurationGUISupervisor::handleFillTreeNodeCommonFieldsXML(
3060 const std::string& groupName,
3062 const std::string& startPath,
3064 const std::string& modifiedTables,
3065 const std::string& recordList,
3066 const std::string& fieldList)
3069 setupActiveTablesXML(
3070 xmlOut, cfgMgr, groupName, groupKey, modifiedTables,
false );
3074 xercesc::DOMElement* parentEl = xmlOut.addTextElementToData(
"fields", startPath);
3078 __SUP_SS__ <<
"Depth of search must be greater than 0." << __E__;
3079 __SUP_COUT__ << ss.str();
3088 std::vector<ConfigurationTree::RecordField> retFieldList;
3094 __SUP_SS__ <<
"Start path was a disconnected link node!" << __E__;
3100 std::vector<std::string > fieldAcceptList, fieldRejectList;
3105 std::istringstream f(fieldList);
3106 std::string fieldPath, decodedFieldPath;
3107 while(getline(f, fieldPath,
','))
3111 if(decodedFieldPath[0] ==
'!')
3112 fieldRejectList.push_back(decodedFieldPath.substr(1));
3114 fieldAcceptList.push_back(decodedFieldPath);
3116 __SUP_COUT__ << fieldList << __E__;
3117 for(
auto& field : fieldAcceptList)
3118 __SUP_COUT__ <<
"fieldAcceptList " << field << __E__;
3119 for(
auto& field : fieldRejectList)
3120 __SUP_COUT__ <<
"fieldRejectList " << field << __E__;
3124 std::vector<std::string > records;
3125 if(recordList ==
"*")
3129 __SUP_COUT__ <<
"Translating wildcard..." << __E__;
3130 for(
auto& record : records)
3131 __SUP_COUT__ <<
"recordList " << record << __E__;
3133 else if(recordList !=
"")
3137 std::istringstream f(recordList);
3138 std::string recordStr;
3139 while(getline(f, recordStr,
','))
3143 __SUP_COUT__ << recordList << __E__;
3144 for(
auto& record : records)
3145 __SUP_COUT__ <<
"recordList " << record << __E__;
3151 records, fieldAcceptList, fieldRejectList, depth);
3155 xercesc::DOMElement* parentTypeEl;
3156 for(
const auto& fieldInfo : retFieldList)
3159 "FieldTableName", fieldInfo.tableName_, parentEl);
3161 "FieldColumnName", fieldInfo.columnName_, parentEl);
3163 "FieldRelativePath", fieldInfo.relativePath_, parentEl);
3165 "FieldColumnType", fieldInfo.columnInfo_->getType(), parentEl);
3167 "FieldColumnDataType", fieldInfo.columnInfo_->getDataType(), parentEl);
3169 fieldInfo.columnInfo_->getDefaultValue(),
3176 auto dataChoices = fieldInfo.columnInfo_->getDataChoices();
3178 "FieldColumnDataChoice",
3179 fieldInfo.columnInfo_->getDefaultValue(),
3181 for(
const auto& dataChoice : dataChoices)
3183 "FieldColumnDataChoice", dataChoice, parentTypeEl);
3186 catch(std::runtime_error& e)
3188 __SUP_SS__ << (
"Error getting common fields!\n\n" + std::string(e.what()))
3190 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3191 xmlOut.addTextElementToData(
"Error", ss.str());
3195 __SUP_SS__ << (
"Error getting common fields!\n\n") << __E__;
3200 catch(
const std::exception& e)
3202 ss <<
"Exception message: " << e.what();
3207 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3208 xmlOut.addTextElementToData(
"Error", ss.str());
3240 void ConfigurationGUISupervisor::handleFillUniqueFieldValuesForRecordsXML(
3243 const std::string& groupName,
3245 const std::string& startPath,
3246 const std::string& modifiedTables,
3247 const std::string& recordList,
3248 const std::string& fieldList)
3251 setupActiveTablesXML(
3252 xmlOut, cfgMgr, groupName, groupKey, modifiedTables,
false );
3258 if(startPath ==
"/")
3264 __SUP_SS__ <<
"Start path was a disconnected link node!" << __E__;
3265 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3270 std::vector<std::string > records;
3271 if(recordList ==
"*")
3275 __SUP_COUT__ <<
"Translating wildcard..." << __E__;
3276 for(
auto& record : records)
3277 __SUP_COUT__ <<
"recordList " << record << __E__;
3279 else if(recordList !=
"")
3283 std::istringstream f(recordList);
3284 std::string recordStr;
3285 while(getline(f, recordStr,
','))
3289 __SUP_COUT__ << recordList << __E__;
3290 for(
auto& record : records)
3291 __SUP_COUT__ <<
"recordList " << record << __E__;
3296 std::vector<std::string > fieldsToGet;
3301 if(fieldList ==
"AUTO")
3306 __SUP_COUT__ <<
"Getting AUTO filter fields!" << __E__;
3308 std::vector<ConfigurationTree::RecordField> retFieldList;
3309 std::vector<std::string > fieldAcceptList,
3311 fieldRejectList.push_back(
"*" + TableViewColumnInfo::COL_NAME_COMMENT);
3313 records, fieldAcceptList, fieldRejectList, 5,
true );
3315 for(
const auto& retField : retFieldList)
3316 fieldsToGet.push_back(retField.relativePath_ + retField.columnName_);
3320 std::istringstream f(fieldList);
3321 std::string fieldPath;
3322 while(getline(f, fieldPath,
','))
3326 __SUP_COUTV__(fieldList);
3335 std::string fieldGroupIDChildLinkIndex;
3336 for(
auto& field : fieldsToGet)
3338 __SUP_COUTV__(field);
3340 xercesc::DOMElement* parentEl =
3341 xmlOut.addTextElementToData(
"field", field);
3347 std::set<std::string > uniqueValues =
3349 records, field, &fieldGroupIDChildLinkIndex);
3351 if(fieldGroupIDChildLinkIndex !=
"")
3353 "childLinkIndex", fieldGroupIDChildLinkIndex, parentEl);
3355 for(
auto& uniqueValue : uniqueValues)
3357 __SUP_COUT__ <<
"uniqueValue " << uniqueValue << __E__;
3364 catch(std::runtime_error& e)
3366 __SUP_SS__ <<
"Error getting unique field values from path '" << startPath
3367 <<
"' and field list '" << fieldList <<
"!'\n\n"
3368 << e.what() << __E__;
3369 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3370 xmlOut.addTextElementToData(
"Error", ss.str());
3374 __SUP_SS__ <<
"Error getting unique field values from path '" << startPath
3375 <<
"' and field list '" << fieldList <<
"!'\n\n"
3381 catch(
const std::exception& e)
3383 ss <<
"Exception message: " << e.what();
3388 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3389 xmlOut.addTextElementToData(
"Error", ss.str());
3413 void ConfigurationGUISupervisor::handleFillTreeViewXML(
3416 const std::string& groupName,
3418 const std::string& startPath,
3420 bool hideStatusFalse,
3421 const std::string& modifiedTables,
3422 const std::string& filterList,
3423 const std::string& diffGroupName ,
3426 __SUP_COUTT__ <<
"get Tree View: " << groupName <<
"(" << groupKey <<
")" << __E__;
3458 bool doDiff = (diffGroupName !=
"" && !diffGroupKey.
isInvalid());
3463 std::string diffAccumulateErrors;
3471 __SUP_COUT__ <<
"cfgMgr " << activeTable.first <<
"-v" << activeTable.second
3488 __SUP_COUT__ <<
"cfgMgr " << activeTable.first <<
"-v" << activeTable.second
3491 __SUP_COUTT__ <<
"Diff Group tables loaded." << __E__;
3493 *cfgMgr, diffMemberMap, diffGroupName, diffGroupKey);
3494 __SUP_COUTT__ <<
"Diff Group tables copied to local diff config manager."
3498 for(
auto& memberPair : diffMemberMap)
3500 ->setActiveView(memberPair.second);
3502 for(
const auto& lastGroupLoaded : cfgMgr->getLastTableGroups())
3503 __SUP_COUT__ <<
"cfgMgr Last loaded " << lastGroupLoaded.first <<
": "
3504 << lastGroupLoaded.second.first.first <<
"("
3505 << lastGroupLoaded.second.first.second <<
")";
3507 for(
const auto& lastGroupLoaded : diffCfgMgr->getLastTableGroups())
3508 __SUP_COUT__ <<
"diffCfgMgr Last loaded " << lastGroupLoaded.first <<
": "
3509 << lastGroupLoaded.second.first.first <<
"("
3510 << lastGroupLoaded.second.first.second <<
")";
3513 if(diffCfgMgr->getLastTableGroups().size() == 1)
3515 __SUP_COUT__ <<
"Type already loaded to diff = "
3516 << diffCfgMgr->getLastTableGroups().begin()->first << __E__;
3519 auto groupTypeToLoad = ConfigurationManager::GROUP_TYPE_NAME_CONTEXT;
3520 if(diffCfgMgr->getLastTableGroups().begin()->first ==
3521 ConfigurationManager::GROUP_TYPE_NAME_CONTEXT)
3522 groupTypeToLoad = ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION;
3523 else if(diffCfgMgr->getLastTableGroups().begin()->first ==
3524 ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION)
3525 groupTypeToLoad = ConfigurationManager::GROUP_TYPE_NAME_CONTEXT;
3528 <<
"Loading " << groupTypeToLoad
3529 << cfgMgr->getLastTableGroups().at(groupTypeToLoad).first.first <<
"("
3530 << cfgMgr->getLastTableGroups().at(groupTypeToLoad).first.second
3535 cfgMgr->getLastTableGroups().at(groupTypeToLoad).second,
3536 cfgMgr->getLastTableGroups().at(groupTypeToLoad).first.first,
3537 cfgMgr->getLastTableGroups().at(groupTypeToLoad).first.second);
3540 for(
auto& memberPair :
3541 cfgMgr->getLastTableGroups().at(groupTypeToLoad).second)
3543 ->setActiveView(memberPair.second);
3551 __SUP_COUTT__ <<
"cfgMgr " << activeTable.first <<
"-v" << activeTable.second
3554 __SUP_COUTT__ <<
"diffCfgMgr " << activeTable.first <<
"-v"
3555 << activeTable.second << __E__;
3557 __SUP_COUTT__ <<
"Diff Group tables are setup: " << diffAccumulateErrors << __E__;
3562 bool usingActiveGroups = (groupName ==
"" || groupKey.
isInvalid());
3565 std::string accumulatedErrors =
"";
3566 setupActiveTablesXML(
3579 if(memberMap.size() >
3581 && startPath ==
"/")
3583 __COUTT__ <<
"Checking for orphaned tables..." << __E__;
3586 std::set<std::string > linkingTables;
3591 __COUTS__(30) <<
"Table " << tableInfo.first << __E__;
3592 if(!tableInfo.second.tablePtr_->isActive())
3595 __COUTS__(30) <<
"Table active " << tableInfo.first << __E__;
3597 const TableView& view = tableInfo.second.tablePtr_->getView();
3599 bool addedThisTable =
false;
3600 for(
unsigned int col = 0; col < view.getNumberOfColumns(); ++col)
3602 if(!view.getColumnInfo(col).isChildLink())
3605 __COUTS__(30) <<
"Table " << tableInfo.first
3606 <<
" col: " << view.getColumnInfo(col).getName() << __E__;
3608 for(
unsigned int r = 0; r < view.getNumberOfRows(); ++r)
3610 if(view.getDataView()[r][col] ==
"" ||
3611 view.getDataView()[r][col] ==
3612 TableViewColumnInfo::DATATYPE_STRING_DEFAULT)
3617 linkingTables.emplace(tableInfo.first);
3618 addedThisTable =
true;
3620 linkingTables.emplace(
3621 view.getDataView()[r][col]);
3627 std::string missingTables =
"";
3628 for(
const auto& member : memberMap)
3631 if(linkingTables.find(member.first) != linkingTables.end())
3634 if(missingTables.size())
3635 missingTables +=
", ";
3636 missingTables += member.first;
3639 if(missingTables.size())
3641 __COUTV__(missingTables);
3642 std::stringstream ss;
3643 ss <<
"The following member tables of table group '" << groupName <<
"("
3645 <<
")' were identified as possibly orphaned (i.e. no active tables link "
3646 "to these tables, and these tables have no links to other tables):\n\n"
3647 << missingTables <<
".\n"
3649 xmlOut.addTextElementToData(
"NoTreeLinkWarning", ss.str());
3653 if(accumulatedErrors !=
"")
3655 xmlOut.addTextElementToData(
"Warning", accumulatedErrors);
3657 __SUP_COUT__ <<
"Active tables are setup. Warning string: '" << accumulatedErrors
3660 __SUP_COUT__ <<
"Active table versions: "
3665 __SUP_COUTT__ <<
"Active tables are setup. No issues found." << __E__;
3666 __SUP_COUTT__ <<
"Active table versions: "
3672 xercesc::DOMElement* parentEl = xmlOut.addTextElementToData(
"tree", startPath);
3677 std::vector<std::pair<std::string, ConfigurationTree>> rootMap;
3678 std::map<std::string, ConfigurationTree> diffRootMap;
3680 if(startPath ==
"/")
3684 std::string accumulateTreeErrs;
3686 if(usingActiveGroups)
3687 rootMap = cfgMgr->
getChildren(0, &accumulateTreeErrs);
3689 rootMap = cfgMgr->
getChildren(&memberMap, &accumulateTreeErrs);
3694 diffCfgMgr->
getChildrenMap(&diffMemberMap, &diffAccumulateErrors);
3695 __SUP_COUTV__(diffRootMap.size());
3696 for(
auto& diffChild : diffRootMap)
3697 __SUP_COUTV__(diffChild.first);
3700 __SUP_COUTV__(accumulateTreeErrs);
3702 if(accumulateTreeErrs !=
"")
3703 xmlOut.addTextElementToData(
"TreeErrors", accumulateTreeErrs);
3708 cfgMgr->
getNode(startPath,
true );
3711 xmlOut.addTextElementToData(
"DisconnectedStartNode",
"1");
3716 std::map<std::string , std::string > filterMap;
3720 std::set<char>({
';'}) ,
3721 std::set<char>({
'='}) );
3735 __SUP_COUTT__ <<
"Diff Group disconnected node." << __E__;
3740 catch(
const std::runtime_error& e)
3743 __SUP_COUTT__ <<
"Diff Group node does not exist." << __E__;
3750 for(
auto& treePair : rootMap)
3752 treePair.second, depth - 1, xmlOut, parentEl, hideStatusFalse);
3756 __SUP_COUTT__ <<
"Diff Tree recursive handling." << __E__;
3759 std::set<std::string > rootMapToSearch;
3760 for(
const auto& rootMember : rootMap)
3761 rootMapToSearch.emplace(rootMember.first);
3763 std::stringstream rootSs;
3764 for(
const auto& rootMember : rootMap)
3765 rootSs <<
", " << rootMember.first;
3768 std::stringstream diffRootSs;
3769 for(
const auto& diffMember : diffRootMap)
3771 diffRootSs <<
", " << diffMember.first <<
":"
3772 << diffMember.second.getNodeType();
3773 if(rootMapToSearch.find(diffMember.first) ==
3777 std::stringstream missingSs;
3778 missingSs << diffMember.first <<
3780 " <<< Only in " << diffGroupName <<
"(" << diffGroupKey
3783 "diffNodeMissing", missingSs.str(), parentEl);
3786 if(diffMember.second.getNodeType() ==
"UIDLinkNode")
3797 __SUP_COUTT__ <<
"diff map " << diffRootSs.str() << __E__;
3798 __SUP_COUTT__ <<
"root map " << rootSs.str() << __E__;
3800 __SUP_COUTT__ <<
"\t\t" << diffMember.second.getValueName() <<
": "
3801 << diffMember.second.getValueAsString() << __E__;
3803 __SUP_COUTT__ << diffMember.second.nodeDump();
3807 __SUP_COUTT__ <<
"diff map " << diffRootSs.str() << __E__;
3808 __SUP_COUTT__ <<
"root map " << rootSs.str() << __E__;
3811 for(
auto& treePair : rootMap)
3813 if(diffRootMap.find(treePair.first) == diffRootMap.end())
3815 __SUP_COUTT__ <<
"Diff Tree recursive handling... " << treePair.first
3828 __SUP_COUTT__ <<
"Diff Tree recursive handling... " << treePair.first
3830 recursiveTreeToXML(treePair.second,
3835 diffRootMap.at(treePair.first));
3840 catch(std::runtime_error& e)
3842 __SUP_SS__ <<
"Error detected generating XML tree!\n\n " << e.what() << __E__;
3843 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3844 xmlOut.addTextElementToData(
"Error", ss.str());
3848 __SUP_SS__ <<
"Error detected generating XML tree!" << __E__;
3853 catch(
const std::exception& e)
3855 ss <<
"Exception message: " << e.what();
3860 __SUP_COUT_ERR__ <<
"\n" << ss.str();
3861 xmlOut.addTextElementToData(
"Error", ss.str());
3871 void ConfigurationGUISupervisor::recursiveTreeToXML(
3875 xercesc::DOMElement* parentEl,
3876 bool hideStatusFalse,
3877 std::optional<std::reference_wrapper<const ConfigurationTree>> diffTree)
3887 if(diffTree.has_value() &&
3888 t.
getValueName() != TableViewColumnInfo::COL_NAME_COMMENT &&
3889 t.
getValueName() != TableViewColumnInfo::COL_NAME_AUTHOR &&
3890 t.
getValueName() != TableViewColumnInfo::COL_NAME_CREATION)
3892 __COUTS__(30) <<
"\t\t diff type " << diffTree->get().getNodeType() << __E__;
3894 if(diffTree->get().isValueNode())
3896 __COUTS__(30) <<
"\t" << diffTree->get().getValueAsString() <<
" ? "
3898 __COUTS__(30) <<
"\t" << diffTree->get().getTableName() <<
"-v"
3899 << diffTree->get().getTableVersion() <<
" ? "
3904 std::stringstream missingSs;
3905 auto diffGroupPair =
3906 diffTree->get().getConfigurationManager()->getGroupOfLoadedTable(
3907 diffTree->get().getTableName());
3908 missingSs <<
"<<< '" << diffTree->get().getValueAsString() <<
"' in "
3909 << diffGroupPair.first <<
"(" << diffGroupPair.second
3916 std::stringstream missingSs;
3918 auto diffGroupPair =
3919 diffTree->get().getConfigurationManager()->getGroupOfLoadedTable(
3921 missingSs <<
"<<< Path not found in " << diffGroupPair.first <<
"("
3922 << diffGroupPair.second <<
") >>>";
3936 if(t.
getValueType() == TableViewColumnInfo::TYPE_FIXED_CHOICE_DATA ||
3937 t.
getValueType() == TableViewColumnInfo::TYPE_BITMAP_DATA)
3942 for(
const auto& choice : choices)
3959 if(diffTree.has_value())
3961 __COUTS__(30) <<
"\t\t diff type " << diffTree->get().getNodeType()
3968 std::stringstream missingSs;
3970 auto diffGroupPair =
3971 diffTree->get().getConfigurationManager()->getGroupOfLoadedTable(
3973 missingSs <<
"<<< Path not found in " << diffGroupPair.first <<
"("
3974 << diffGroupPair.second <<
") >>>";
3979 __COUTS__(30) <<
"\t\t diff isDisconnected "
3980 << diffTree->get().isDisconnected() << __E__;
3982 std::stringstream missingSs;
3984 auto diffGroupPair =
3985 diffTree->get().getConfigurationManager()->getGroupOfLoadedTable(
3987 missingSs <<
"<<< Link is "
3988 << (diffTree->get().isDisconnected() ?
"DISCONNECTED"
3990 <<
" in " << diffGroupPair.first <<
"("
3991 << diffGroupPair.second <<
") >>>";
3998 std::stringstream missingSs;
4000 auto diffGroupPair =
4001 diffTree->get().getConfigurationManager()->getGroupOfLoadedTable(
4003 missingSs <<
"<<< Link is "
4004 << (diffTree->get().isUIDLinkNode() ?
"a UID Link"
4006 <<
" in " << diffGroupPair.first <<
"("
4007 << diffGroupPair.second <<
") >>>";
4012 diffTree->get().getValueAsString())
4015 std::stringstream missingSs;
4017 auto diffGroupPair =
4018 diffTree->get().getConfigurationManager()->getGroupOfLoadedTable(
4020 missingSs <<
"<<< Link to '" << diffTree->get().getValueAsString()
4021 <<
"' in " << diffGroupPair.first <<
"("
4022 << diffGroupPair.second <<
") >>>";
4028 std::stringstream missingSs;
4031 auto dtchildren = diffTree->get().getChildrenMap();
4032 missingSs <<
"<<< Group link";
4033 if(tchildren.size() != dtchildren.size())
4034 missingSs <<
" has " << tchildren.size() <<
" vs "
4035 << dtchildren.size() <<
" children..";
4036 for(
auto& tchild : tchildren)
4037 if(dtchildren.find(tchild.first) == dtchildren.end())
4038 missingSs <<
" '" << tchild.first <<
"' missing..";
4039 for(
auto& dtchild : dtchildren)
4040 if(tchildren.find(dtchild.first) == tchildren.end())
4041 missingSs <<
" '" << dtchild.first <<
"' present...";
4044 if(missingSs.str().length() > std::string(
"<<< Group link").length())
4046 auto diffGroupPair =
4048 .getConfigurationManager()
4049 ->getGroupOfLoadedTable(diffTree->get().getTableName());
4050 missingSs <<
" in " << diffGroupPair.first <<
"("
4051 << diffGroupPair.second <<
") >>>";
4053 "nodeDiff", missingSs.str(), parentEl);
4081 xercesc::DOMElement* choicesParentEl =
4087 __COUTS__(30) <<
"choices.size() " << choices.size() << __E__;
4089 for(
const auto& choice : choices)
4111 xercesc::DOMElement* choicesParentEl =
4115 for(
const auto& choice : choices)
4122 bool returnNode =
true;
4135 if(diffTree.has_value())
4138 <<
"\t\t diff type " << diffTree->get().getNodeType() << __E__;
4147 auto diffGroupPair =
4149 .getConfigurationManager()
4151 missingSs <<
"<<< Not in " << diffGroupPair.first <<
"("
4152 << diffGroupPair.second <<
") >>>";
4154 "nodeDiff", missingSs.str(), parentEl);
4188 void ConfigurationGUISupervisor::handleGetLinkToChoicesXML(
4191 const std::string& linkToTableName,
4193 const std::string& linkIdType,
4194 const std::string& linkIndex,
4195 const std::string& linkInitId)
4208 const std::string& tableName = linkToTableName;
4213 table->setActiveView(version);
4217 __SUP_COUT__ <<
"Failed to find stored version, so attempting to load version: "
4218 << version << __E__;
4224 __SUP_SS__ <<
"Target table version (" << version
4225 <<
") is not the currently active version (" << table->
getViewVersion()
4226 <<
". Try refreshing the tree." << __E__;
4227 __SUP_COUT_WARN__ << ss.str();
4231 __SUP_COUT__ <<
"Active version is " << table->
getViewVersion() << __E__;
4233 if(linkIdType ==
"UID")
4236 unsigned int col = table->getView().getColUID();
4237 for(
unsigned int row = 0; row < table->getView().getNumberOfRows(); ++row)
4238 xmlOut.addTextElementToData(
"linkToChoice",
4239 table->getView().getDataView()[row][col]);
4241 else if(linkIdType ==
"GroupID")
4247 __SUP_COUTV__(linkIndex);
4248 __SUP_COUTV__(linkInitId);
4250 std::set<std::string> setOfGroupIDs =
4251 table->getView().getSetOfGroupIDs(linkIndex);
4256 bool foundInitId =
false;
4257 for(
const auto& groupID : setOfGroupIDs)
4259 if(!foundInitId && linkInitId == groupID)
4262 xmlOut.addTextElementToData(
"linkToChoice", groupID);
4266 xmlOut.addTextElementToData(
"linkToChoice", linkInitId);
4269 unsigned int col = table->getView().getColUID();
4270 for(
unsigned int row = 0; row < table->getView().getNumberOfRows(); ++row)
4272 xmlOut.addTextElementToData(
"groupChoice",
4273 table->getView().getDataView()[row][col]);
4274 if(table->getView().isEntryInGroup(row, linkIndex, linkInitId))
4275 xmlOut.addTextElementToData(
"groupMember",
4276 table->getView().getDataView()[row][col]);
4281 __SUP_SS__ <<
"Unrecognized linkIdType '" << linkIdType <<
".'" << __E__;
4285 catch(std::runtime_error& e)
4287 __SUP_SS__ <<
"Error detected saving tree node!\n\n " << e.what() << __E__;
4288 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
4289 xmlOut.addTextElementToData(
"Error", ss.str());
4293 __SUP_SS__ <<
"Error detected saving tree node!\n\n " << __E__;
4298 catch(
const std::exception& e)
4300 ss <<
"Exception message: " << e.what();
4305 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
4306 xmlOut.addTextElementToData(
"Error", ss.str());
4311 void ConfigurationGUISupervisor::handleMergeGroupsXML(
4314 const std::string& groupANameContext,
4316 const std::string& groupBNameContext,
4318 const std::string& groupANameConfig,
4320 const std::string& groupBNameConfig,
4322 const std::string& author,
4323 const std::string& mergeApproach)
4326 __SUP_COUT__ <<
"Merging context group pair " << groupANameContext <<
" ("
4327 << groupAKeyContext <<
") & " << groupBNameContext <<
" ("
4328 << groupBKeyContext <<
") and table group pair " << groupANameConfig
4329 <<
" (" << groupAKeyConfig <<
") & " << groupBNameConfig <<
" ("
4330 << groupBKeyConfig <<
") with approach '" << mergeApproach << __E__;
4346 if(!(mergeApproach ==
"Rename" || mergeApproach ==
"Replace" ||
4347 mergeApproach ==
"Skip"))
4349 __SS__ <<
"Error! Invalid merge approach '" << mergeApproach <<
".'" << __E__;
4353 std::map<std::string ,
TableVersion > memberMapAContext,
4354 memberMapBContext, memberMapAConfig, memberMapBConfig;
4357 bool skippingContextPair =
false;
4358 bool skippingConfigPair =
false;
4359 if(groupANameContext.size() == 0 || groupANameContext[0] ==
' ' ||
4360 groupBNameContext.size() == 0 || groupBNameContext[0] ==
' ')
4362 skippingContextPair =
true;
4363 __SUP_COUTV__(skippingContextPair);
4365 if(groupANameConfig.size() == 0 || groupANameConfig[0] ==
' ' ||
4366 groupBNameConfig.size() == 0 || groupBNameConfig[0] ==
' ')
4368 skippingConfigPair =
true;
4369 __SUP_COUTV__(skippingConfigPair);
4373 if(!skippingContextPair)
4406 if(!skippingConfigPair)
4443 std::map<std::pair<std::string , std::string >,
4447 std::pair<std::string ,
4448 std::pair<std::string , std::string >>,
4450 groupidConversionMap;
4452 std::stringstream mergeReport;
4453 mergeReport <<
"======================================" << __E__;
4455 mergeReport <<
"Merging context group pair " << groupANameContext <<
" ("
4456 << groupAKeyContext <<
") & " << groupBNameContext <<
" ("
4457 << groupBKeyContext <<
") and table group pair " << groupANameConfig
4458 <<
" (" << groupAKeyConfig <<
") & " << groupBNameConfig <<
" ("
4459 << groupBKeyConfig <<
") with approach '" << mergeApproach << __E__;
4460 mergeReport <<
"======================================" << __E__;
4464 for(
unsigned int i = 0; i < 2; ++i)
4466 if(i == 0 && mergeApproach !=
"Rename")
4470 for(
unsigned int j = 0; j < 2; ++j)
4472 if(j == 0 && skippingContextPair)
4474 __COUT__ <<
"Skipping context pair..." << __E__;
4477 else if(j == 1 && skippingConfigPair)
4479 __COUT__ <<
"Skipping table pair..." << __E__;
4484 j == 0 ? memberMapAContext : memberMapAConfig;
4487 j == 0 ? memberMapBContext : memberMapBConfig;
4490 __COUT__ <<
"Context pair..." << __E__;
4492 __COUT__ <<
"Table pair..." << __E__;
4494 __COUT__ <<
"Starting member map B scan." << __E__;
4495 for(
const auto& bkey : memberMapBref)
4497 __SUP_COUTV__(bkey.first);
4499 if(memberMapAref.find(bkey.first) == memberMapAref.end())
4501 mergeReport <<
"\n'" << mergeApproach <<
"'-Missing table '"
4502 << bkey.first <<
"' A=v" << -1 <<
", adding B=v"
4503 << bkey.second << __E__;
4506 memberMapAref[bkey.first] = bkey.second;
4508 else if(memberMapAref[bkey.first] != bkey.second)
4511 __SUP_COUTV__(memberMapAref[bkey.first]);
4512 __SUP_COUTV__(bkey.second);
4517 __SUP_COUT__ <<
"Got table." << __E__;
4521 ->getVersionedTableByName(bkey.first,
4522 memberMapAref[bkey.first])
4530 groupidConversionMap,
4534 ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME
4540 __SUP_COUTV__(newVersion);
4558 catch(std::runtime_error& e)
4561 <<
"There was an error saving the '"
4563 <<
"' merge result to a persistent table version. "
4564 <<
"Perhaps you can modify this table in one of the "
4565 "groups to resolve this issue, and then re-merge."
4566 << __E__ << e.what();
4570 __SUP_COUTV__(newVersion);
4572 memberMapAref[bkey.first] = newVersion;
4581 if(!skippingContextPair)
4583 __SUP_COUT__ <<
"New context member map complete." << __E__;
4590 "Merger of group " + groupANameContext +
" (" + groupAKeyContext.
toString() +
4591 ") and " + groupBNameContext +
" (" + groupBKeyContext.
toString() +
").");
4594 xmlOut.addTextElementToData(
"ContextGroupName", groupANameContext);
4595 xmlOut.addTextElementToData(
"ContextGroupKey", newKeyContext.
toString());
4597 if(!skippingConfigPair)
4599 __SUP_COUT__ <<
"New table member map complete." << __E__;
4606 "Merger of group " + groupANameConfig +
" (" + groupAKeyConfig.
toString() +
4607 ") and " + groupBNameConfig +
" (" + groupBKeyConfig.
toString() +
").");
4610 xmlOut.addTextElementToData(
"ConfigGroupName", groupANameConfig);
4611 xmlOut.addTextElementToData(
"ConfigGroupKey", newKeyConfig.
toString());
4616 std::string mergeReportBasePath = std::string(__ENV__(
"USER_DATA"));
4617 std::string mergeReportPath =
"/ServiceData/";
4619 mkdir((mergeReportBasePath + mergeReportPath).c_str(), 0755);
4620 mergeReportPath +=
"ConfigurationGUI_mergeReports/";
4622 mkdir((mergeReportBasePath + mergeReportPath).c_str(), 0755);
4625 "merge_" + std::to_string(time(0)) +
"_" + std::to_string(clock()) +
".txt";
4626 __SUP_COUTV__(mergeReportPath);
4628 FILE* fp = fopen((mergeReportBasePath + mergeReportPath).c_str(),
"w");
4631 fprintf(fp,
"%s", mergeReport.str().c_str());
4633 xmlOut.addTextElementToData(
"MergeReportFile",
4634 "/$USER_DATA/" + mergeReportPath);
4637 xmlOut.addTextElementToData(
"MergeReportFile",
"FILE FAILURE");
4641 catch(std::runtime_error& e)
4643 __SUP_SS__ <<
"Error merging context group pair " << groupANameContext <<
" ("
4644 << groupAKeyContext <<
") & " << groupBNameContext <<
" ("
4645 << groupBKeyContext <<
") and table group pair " << groupANameConfig
4646 <<
" (" << groupAKeyConfig <<
") & " << groupBNameConfig <<
" ("
4647 << groupBKeyConfig <<
") with approach '" << mergeApproach <<
"': \n\n"
4648 << e.what() << __E__;
4649 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
4650 xmlOut.addTextElementToData(
"Error", ss.str());
4654 __SUP_SS__ <<
"Unknown error merging context group pair " << groupANameContext <<
" ("
4655 << groupAKeyContext <<
") & " << groupBNameContext <<
" ("
4656 << groupBKeyContext <<
") and table group pair " << groupANameConfig
4657 <<
" (" << groupAKeyConfig <<
") & " << groupBNameConfig <<
" ("
4658 << groupBKeyConfig <<
") with approach '" << mergeApproach <<
".' \n\n";
4663 catch(
const std::exception& e)
4665 ss <<
"Exception message: " << e.what();
4670 __SUP_COUT_ERR__ <<
"\n" << ss.
str() << __E__;
4671 xmlOut.addTextElementToData(
"Error", ss.str());
4676 void ConfigurationGUISupervisor::handleSavePlanCommandSequenceXML(
4679 const std::string& groupName,
4681 const std::string& modifiedTables,
4682 const std::string& author,
4683 const std::string& planName,
4684 const std::string& commandString)
4687 __COUT__ <<
"handleSavePlanCommandSequenceXML " << planName << __E__;
4690 setupActiveTablesXML(xmlOut,
4709 for(
const auto& commandPair : IterateTable::commandToTableMap_)
4710 if(commandPair.second !=
"")
4711 commandTableToEditMap.emplace(std::pair<std::string, TableEditStruct>(
4728 std::string groupName = planName +
"-Plan";
4729 __SUP_COUT__ <<
"Handling commands for group " << groupName << __E__;
4731 unsigned int groupIdCol =
4732 planTable.tableView_->findCol(IterateTable::planTableCols_.GroupID_);
4733 unsigned int cmdTypeCol =
4734 planTable.tableView_->findCol(IterateTable::planTableCols_.CommandType_);
4736 unsigned int targetGroupIdCol =
4737 targetTable.tableView_->findCol(IterateTable::targetCols_.GroupID_);
4738 unsigned int targetTableCol =
4739 targetTable.tableView_->findCol(IterateTable::targetCols_.TargetLink_);
4740 unsigned int targetUIDCol =
4741 targetTable.tableView_->findCol(IterateTable::targetCols_.TargetLinkUID_);
4743 std::string groupLinkIndex =
4744 planTable.tableView_->getColumnInfo(groupIdCol).getChildLinkIndex();
4745 __SUP_COUT__ <<
"groupLinkIndex: " << groupLinkIndex << __E__;
4747 std::pair<
unsigned int ,
unsigned int > commandUidLink;
4750 planTable.tableView_->getChildLink(
4751 planTable.tableView_->findCol(IterateTable::planTableCols_.CommandLink_),
4756 unsigned int cmdRow, cmdCol;
4757 std::string targetGroupName;
4761 std::string targetUID, cmdType;
4763 for(
unsigned int row = 0; row < planTable.tableView_->getNumberOfRows();
4766 targetUID = planTable.tableView_
4767 ->getDataView()[row][planTable.tableView_->getColUID()];
4768 __SUP_COUT__ <<
"targetUID: " << targetUID << __E__;
4771 if(planTable.tableView_->isEntryInGroup(row, groupLinkIndex, groupName))
4773 __SUP_COUT__ <<
"Removing." << __E__;
4777 cmdType = planTable.tableView_->getDataView()[row][cmdTypeCol];
4778 auto cmdTypeTableIt = IterateTable::commandToTableMap_.find(cmdType);
4779 if(cmdTypeTableIt != IterateTable::commandToTableMap_.end() &&
4780 cmdTypeTableIt->second !=
4784 commandTableToEditMap.at(cmdTypeTableIt->second);
4785 cmdRow = cmdTypeTableEdit.tableView_->findRow(
4786 cmdTypeTableEdit.tableView_->getColUID(),
4787 planTable.tableView_
4788 ->getDataView()[row][commandUidLink.second]);
4795 cmdCol = cmdTypeTableEdit.tableView_->findCol(
4796 IterateTable::commandTargetCols_.TargetsLinkGroupID_);
4797 targetGroupName = cmdTypeTableEdit.tableView_
4798 ->getDataView()[cmdRow][cmdCol];
4800 for(
unsigned int trow = 0;
4801 trow < targetTable.tableView_->getNumberOfRows();
4805 if(targetTable.tableView_->isEntryInGroup(
4807 cmdTypeTableEdit.tableView_->getColumnInfo(cmdCol)
4808 .getChildLinkIndex(),
4811 __SUP_COUT__ <<
"Removing target." << __E__;
4813 if(targetTable.tableView_->removeRowFromGroup(
4824 __SUP_COUT__ <<
"No targets." << __E__;
4829 cmdTypeTableEdit.tableView_->deleteRow(cmdRow);
4835 if(planTable.tableView_->removeRowFromGroup(
4836 row, groupIdCol, groupName,
true ))
4845 std::vector<IterateTable::Command> commands;
4850 std::istringstream f(commandString);
4851 std::string commandSubString, paramSubString, paramValue;
4853 while(getline(f, commandSubString,
';'))
4855 __SUP_COUTT__ <<
"commandSubString " << commandSubString << __E__;
4856 std::istringstream g(commandSubString);
4859 while(getline(g, paramSubString,
','))
4861 __SUP_COUTT__ <<
"paramSubString " << paramSubString << __E__;
4864 if(paramSubString !=
"type")
4866 __SUP_SS__ <<
"Invalid command sequence" << __E__;
4870 commands.push_back(IterateTable::Command());
4872 getline(g, paramValue,
',');
4874 __SUP_COUTT__ <<
"paramValue " << paramValue << __E__;
4875 commands.back().type_ = paramValue;
4879 getline(g, paramValue,
',');
4881 __SUP_COUTT__ <<
"paramValue " << paramValue << __E__;
4883 commands.back().params_.emplace(
4884 std::pair<std::string ,
4896 __SUP_COUT__ <<
"commands size " << commands.size() << __E__;
4903 unsigned int row, tgtRow;
4904 unsigned int targetIndex;
4905 std::string targetStr, cmdUID;
4907 for(
auto& command : commands)
4909 __SUP_COUT__ <<
"command " << command.type_ << __E__;
4910 __SUP_COUT__ <<
"table " << IterateTable::commandToTableMap_.at(command.type_)
4914 row = planTable.tableView_->addRow(
4915 author,
true ,
"planCommand");
4916 planTable.tableView_->addRowToGroup(row, groupIdCol, groupName);
4919 planTable.tableView_->setURIEncodedValue(command.type_, row, cmdTypeCol);
4922 planTable.tableView_->setValueAsString(
4923 "1", row, planTable.tableView_->getColStatus());
4926 auto cmdTypeTableIt = IterateTable::commandToTableMap_.find(command.type_);
4927 if(cmdTypeTableIt != IterateTable::commandToTableMap_.end() &&
4928 cmdTypeTableIt->second !=
4932 commandTableToEditMap.at(cmdTypeTableIt->second);
4933 __SUP_COUT__ <<
"table " << cmdTypeTableEdit.tableName_ << __E__;
4938 cmdRow = cmdTypeTableEdit.tableView_->addRow(
4939 author,
true , command.type_ +
"_COMMAND_");
4945 for(
auto& param : command.params_)
4947 __SUP_COUT__ <<
"\t param " << param.first <<
" : " << param.second
4950 if(param.first == IterateTable::targetParams_.Tables_)
4952 __SUP_COUT__ <<
"\t\t found target tables" << __E__;
4953 std::istringstream f(param.second);
4956 while(getline(f, targetStr,
'='))
4958 __SUP_COUT__ <<
"\t\t targetStr = " << targetStr << __E__;
4959 if(!command.targets_.size() ||
4960 command.targets_.back().table_ !=
"")
4962 __SUP_COUT__ <<
"\t\t make targetStr = " << targetStr
4965 command.addTarget();
4966 command.targets_.back().table_ = targetStr;
4969 command.targets_[targetIndex++].table_ = targetStr;
4975 if(param.first == IterateTable::targetParams_.UIDs_)
4977 __SUP_COUT__ <<
"\t\t found target UIDs" << __E__;
4978 std::istringstream f(param.second);
4981 while(getline(f, targetStr,
'='))
4983 __SUP_COUT__ <<
"\t\t targetStr = " << targetStr << __E__;
4984 if(!command.targets_.size() ||
4985 command.targets_.back().UID_ !=
"")
4987 __SUP_COUT__ <<
"\t\t make targetStr = " << targetStr
4990 command.addTarget();
4991 command.targets_.back().UID_ = targetStr;
4994 command.targets_[targetIndex++].UID_ = targetStr;
4999 cmdCol = cmdTypeTableEdit.tableView_->findCol(param.first);
5001 __SUP_COUT__ <<
"param col " << cmdCol << __E__;
5003 cmdTypeTableEdit.tableView_->setURIEncodedValue(
5004 param.second, cmdRow, cmdCol);
5008 cmdTypeTableEdit.tableView_
5009 ->getDataView()[cmdRow][cmdTypeTableEdit.tableView_->getColUID()];
5011 if(command.targets_.size())
5015 __SUP_COUT__ <<
"targets found for command UID=" << cmdUID << __E__;
5018 cmdCol = cmdTypeTableEdit.tableView_->findCol(
5019 IterateTable::commandTargetCols_.TargetsLink_);
5020 cmdTypeTableEdit.tableView_->setValueAsString(
5021 IterateTable::TARGET_TABLE, cmdRow, cmdCol);
5023 cmdCol = cmdTypeTableEdit.tableView_->findCol(
5024 IterateTable::commandTargetCols_.TargetsLinkGroupID_);
5025 cmdTypeTableEdit.tableView_->setValueAsString(
5026 cmdUID +
"_Targets", cmdRow, cmdCol);
5030 for(
const auto& target : command.targets_)
5032 __SUP_COUT__ << target.
table_ <<
" " << target.UID_ << __E__;
5035 tgtRow = targetTable.tableView_->addRow(
5036 author,
true ,
"commandTarget");
5037 targetTable.tableView_->addRowToGroup(
5038 tgtRow, targetGroupIdCol, cmdUID +
"_Targets");
5041 targetTable.tableView_->setValueAsString(
5042 target.table_, tgtRow, targetTableCol);
5045 targetTable.tableView_->setValueAsString(
5046 target.UID_, tgtRow, targetUIDCol);
5051 planTable.tableView_->setValueAsString(
5052 cmdTypeTableEdit.tableName_, row, commandUidLink.first);
5053 planTable.tableView_->setValueAsString(
5054 cmdUID, row, commandUidLink.second);
5056 __SUP_COUT__ <<
"linked to uid = " << cmdUID << __E__;
5066 planTable.tableView_->print();
5067 planTable.tableView_->init();
5069 __SUP_COUT__ <<
"requestType tables:" << __E__;
5071 for(
auto& modifiedConfig : commandTableToEditMap)
5073 __SUP_COUTV__(modifiedConfig.second.modified_);
5074 modifiedConfig.second.tableView_->print();
5075 modifiedConfig.second.tableView_->init();
5078 targetTable.tableView_->print();
5079 targetTable.tableView_->init();
5084 __SUP_COUT__ <<
"Handling command table errors while saving. Erasing all newly "
5090 if(planTable.createdTemporaryVersion_)
5092 __SUP_COUT__ <<
"Erasing temporary version " << planTable.tableName_ <<
"-v"
5093 << planTable.temporaryVersion_ << __E__;
5096 planTable.temporaryVersion_);
5099 if(targetTable.createdTemporaryVersion_)
5101 __SUP_COUT__ <<
"Erasing temporary version " << targetTable.tableName_ <<
"-v"
5102 << targetTable.temporaryVersion_ << __E__;
5105 targetTable.temporaryVersion_);
5108 for(
auto& modifiedConfig : commandTableToEditMap)
5110 if(modifiedConfig.second
5111 .createdTemporaryVersion_)
5113 __SUP_COUT__ <<
"Erasing temporary version "
5114 << modifiedConfig.second.tableName_ <<
"-v"
5115 << modifiedConfig.second.temporaryVersion_ << __E__;
5118 modifiedConfig.second.temporaryVersion_);
5132 planTable.tableName_,
5133 planTable.originalVersion_,
5136 planTable.temporaryVersion_,
5139 __SUP_COUT__ <<
"Final plan version is " << planTable.tableName_ <<
"-v"
5140 << finalVersion << __E__;
5145 targetTable.tableName_,
5146 targetTable.originalVersion_,
5149 targetTable.temporaryVersion_,
5152 __SUP_COUT__ <<
"Final target version is " << targetTable.tableName_ <<
"-v"
5153 << finalVersion << __E__;
5155 for(
auto& modifiedConfig : commandTableToEditMap)
5157 if(!modifiedConfig.second.modified_)
5159 if(modifiedConfig.second
5160 .createdTemporaryVersion_)
5162 __SUP_COUT__ <<
"Erasing unmodified temporary version "
5163 << modifiedConfig.second.tableName_ <<
"-v"
5164 << modifiedConfig.second.temporaryVersion_ << __E__;
5167 modifiedConfig.second.temporaryVersion_);
5175 modifiedConfig.second.tableName_,
5176 modifiedConfig.second.originalVersion_,
5178 modifiedConfig.second.table_,
5179 modifiedConfig.second.temporaryVersion_,
5182 __SUP_COUT__ <<
"Final version is " << modifiedConfig.second.tableName_ <<
"-v"
5183 << finalVersion << __E__;
5186 handleFillModifiedTablesXML(xmlOut, cfgMgr);
5188 catch(std::runtime_error& e)
5190 __SUP_SS__ <<
"Error detected saving Iteration Plan!\n\n " << e.what() << __E__;
5191 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
5192 xmlOut.addTextElementToData(
"Error", ss.str());
5196 __SUP_SS__ <<
"Error detected saving Iteration Plan!\n\n " << __E__;
5201 catch(
const std::exception& e)
5203 ss <<
"Exception message: " << e.what();
5208 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
5209 xmlOut.addTextElementToData(
"Error", ss.str());
5222 void ConfigurationGUISupervisor::handleSaveTreeNodeEditXML(
HttpXmlDocument& xmlOut,
5224 const std::string& tableName,
5226 const std::string& type,
5227 const std::string& uid,
5228 const std::string& colName,
5229 const std::string& newValue,
5230 const std::string& author)
5233 __SUP_COUT__ <<
"Editing table " << tableName <<
"(" << version <<
") uid=" << uid
5234 <<
" type=" << type << __E__;
5244 table->setActiveView(version);
5251 __SUP_COUT__ <<
"Failed to find stored version, so attempting to load version: "
5252 << version << __E__;
5256 __SUP_COUT__ <<
"Active version is " << table->
getViewVersion() << __E__;
5257 __SUP_COUTTV__(table->getView().getComment());
5261 __SUP_SS__ <<
"Target table version (" << version
5262 <<
") is not the currently active version (" << table->
getViewVersion()
5263 <<
"). Try refreshing the tree." << __E__;
5267 unsigned int col = -1;
5268 if(type ==
"uid" || type ==
"delete-uid" || type ==
"tree-copy")
5269 col = table->getView().getColUID();
5270 else if(type ==
"node-comment")
5271 col = table->getView().findCol(TableViewColumnInfo::COL_NAME_COMMENT);
5272 else if(type ==
"link-UID" || type ==
"link-GroupID" || type ==
"value" ||
5273 type ==
"value-groupid" || type ==
"value-bool" || type ==
"value-bitmap")
5274 col = table->getView().findCol(colName);
5275 else if(type ==
"table" || type ==
"link-comment" || type ==
"table-newGroupRow" ||
5276 type ==
"table-newUIDRow" || type ==
"table-newRow")
5280 __SUP_SS__ <<
"Impossible! Unrecognized edit type: " << type << __E__;
5285 if(type ==
"table" || type ==
"link-comment")
5288 if(table->getView().isURIEncodedCommentTheSame(newValue))
5291 <<
"' is the same as the current comment. No need to save change."
5309 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion << __E__;
5314 __SUP_COUTTV__(table->getView().getComment());
5320 if(type ==
"table" || type ==
"link-comment")
5325 else if(type ==
"table-newRow" || type ==
"table-newUIDRow")
5328 unsigned int row = cfgView->
addRow(
5329 author,
true , newValue );
5344 else if(type ==
"table-newGroupRow")
5347 unsigned int csvIndex = newValue.find(
',');
5349 std::string linkIndex = newValue.substr(0, csvIndex);
5350 std::string groupId = newValue.substr(csvIndex + 1);
5353 csvIndex = groupId.find(
',');
5354 std::string newRowUID = groupId.substr(csvIndex + 1);
5355 groupId = groupId.substr(0, csvIndex);
5357 __SUP_COUT__ <<
"newValue " << linkIndex <<
"," << groupId <<
"," << newRowUID
5361 unsigned int row = cfgView->
addRow(author,
5387 else if(type ==
"delete-uid")
5390 unsigned int row = cfgView->
findRow(col, uid);
5393 else if(type ==
"tree-copy")
5396 __COUTV__(newValue);
5397 std::vector<std::string> paramArray =
5401 if(paramArray.size() != 2)
5403 __SS__ <<
"Illegal parameters for tree copy request: must be number of "
5404 "copy instances & depth of copy."
5409 unsigned int row = cfgView->
findRow(col, uid);
5412 unsigned int numberOfInstances = atoi(paramArray[0].c_str());
5413 unsigned int depth = atoi(paramArray[1].c_str());
5415 __COUTV__(numberOfInstances);
5416 if(numberOfInstances > 1000)
5418 __SS__ <<
"Illegal parameters - the maximum number of copy instances is "
5419 "1000. Number of instances provided was "
5420 << numberOfInstances << __E__;
5427 ConfigurationSupervisorBase::recursiveCopyTreeUIDNode(xmlOut,
5436 else if(type ==
"uid" || type ==
"value" || type ==
"value-groupid" ||
5437 type ==
"value-bool" || type ==
"value-bitmap" || type ==
"node-comment")
5443 __SUP_SS__ <<
"Value '" << newValue
5444 <<
"' is the same as the current value. No need to save "
5445 "change to tree node."
5450 else if(type ==
"link-UID" || type ==
"link-GroupID")
5453 std::pair<
unsigned int ,
unsigned int > linkPair;
5457 __SUP_SS__ <<
"Col '" << colName <<
"' is not a link column." << __E__;
5461 __SUP_COUT__ <<
"linkPair " << linkPair.first <<
"," << linkPair.second
5464 std::string linkIndex = cfgView->getColumnInfo(col).getChildLinkIndex();
5466 __SUP_COUT__ <<
"linkIndex " << linkIndex << __E__;
5469 unsigned int csvIndexStart = 0, csvIndex = newValue.find(
',');
5471 std::string newTable = newValue.substr(csvIndexStart, csvIndex);
5472 csvIndexStart = csvIndex + 1;
5473 csvIndex = newValue.find(
',', csvIndexStart);
5474 std::string newLinkId = newValue.substr(
5479 __SUP_COUT__ <<
"newValue " << newTable <<
"," << newLinkId << __E__;
5483 bool changed =
false;
5484 bool needSecondaryChange = (type ==
"link-GroupID");
5489 __SUP_COUT__ <<
"Value '" << newTable
5490 <<
"' is the same as the current value." << __E__;
5498 std::string originalValue = cfgView->
getValueAsString(row, linkPair.second);
5502 __SUP_COUT__ <<
"Value '" << newLinkId
5503 <<
"' is the same as the current value." << __E__;
5508 needSecondaryChange =
5514 if(needSecondaryChange)
5516 bool secondaryChanged =
false;
5517 bool defaultIsInGroup =
5523 __SUP_COUT__ <<
"No changes to primary view. Erasing temporary table."
5525 table->eraseView(temporaryVersion);
5546 catch(std::runtime_error&
5549 __SUP_COUT__ <<
"Caught error while editing main table. Erasing "
5550 "temporary version."
5552 table->eraseView(temporaryVersion);
5556 xmlOut.addTextElementToData(
5558 "Error saving primary tree node! " + std::string(e.what()));
5568 __SUP_COUTV__(newValue);
5569 csvIndexStart = csvIndex + 1;
5570 csvIndex = newValue.find(
',', csvIndexStart);
5572 csvIndexStart, csvIndex - csvIndexStart));
5575 if(newTable == TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
5586 table->setActiveView(version);
5593 __SUP_COUT__ <<
"Failed to find stored version, so attempting to "
5595 << newTable <<
" v" << version << __E__;
5599 __SUP_COUT__ << newTable <<
" active version is "
5606 ss <<
"Target table '" << newTable
5607 <<
"' is likely not a member of the current table group "
5608 <<
"since the mock-up version was not successfully loaded. "
5613 "To add a table to a group, click the group name to go to "
5615 "group view, then click 'Add/Remove/Modify Member Tables.' "
5617 "can then add or remove tables and save the new group." +
5619 "OR!!! Click the following button to add the table '" +
5621 "' to the currently active Configuration Group: " +
5622 "<input type='button' style='color:black !important;' " +
5623 "title='Click to add table to the active Configuration "
5625 "onclick='addTableToConfigurationGroup(\"" + newTable +
5626 "\"); Debug.closeErrorPop();event.stopPropagation();' "
5627 "value='Add Table'>" +
5631 ss <<
"Target table version (" << version
5632 <<
") is not the currently active version ("
5641 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion << __E__;
5647 if(type ==
"link-UID")
5657 __SUP_COUT__ <<
"target col " << col << __E__;
5659 unsigned int row = -1;
5662 row = cfgView->
findRow(col, newLinkId);
5667 if(row == (
unsigned int)-1)
5669 __SUP_COUT__ <<
"New link UID '" << newLinkId
5670 <<
"' was not found, so attempting to change UID of "
5672 << originalValue <<
"'" << __E__;
5675 row = cfgView->
findRow(col, originalValue);
5678 secondaryChanged =
true;
5679 __SUP_COUT__ <<
"Original target record '"
5680 << originalValue <<
"' was changed to '"
5681 << newLinkId <<
"'" << __E__;
5686 __SUP_COUT__ <<
"Original target record '" << originalValue
5687 <<
"' not found." << __E__;
5691 else if(type ==
"link-GroupID")
5699 __SUP_COUT__ <<
"target col " << col << __E__;
5702 std::vector<std::string> memberUIDs;
5705 csvIndexStart = csvIndex + 1;
5706 csvIndex = newValue.find(
',', csvIndexStart);
5707 memberUIDs.push_back(
5708 newValue.substr(csvIndexStart, csvIndex - csvIndexStart));
5709 __SUP_COUT__ <<
"memberUIDs: " << memberUIDs.back() << __E__;
5711 (
unsigned int)std::string::npos);
5721 std::string targetUID;
5722 bool shouldBeInGroup;
5725 for(
unsigned int row = 0; row < cfgView->getNumberOfRows(); ++row)
5727 targetUID = cfgView->getDataView()[row][cfgView->
getColUID()];
5728 __SUP_COUT__ <<
"targetUID: " << targetUID << __E__;
5730 shouldBeInGroup =
false;
5731 for(
unsigned int i = 0; i < memberUIDs.size(); ++i)
5732 if(targetUID == memberUIDs[i])
5735 shouldBeInGroup =
true;
5742 if(shouldBeInGroup && !isInGroup)
5744 __SUP_COUT__ <<
"Changed to YES: " << row << __E__;
5745 secondaryChanged =
true;
5750 else if(!shouldBeInGroup && isInGroup)
5752 __SUP_COUT__ <<
"Changed to NO: " << row << __E__;
5753 secondaryChanged =
true;
5757 else if(targetUID ==
5759 ->getDefaultRowValues()[cfgView->
getColUID()] &&
5763 defaultIsInGroup =
true;
5769 if(!secondaryChanged)
5772 <<
"No changes to secondary view. Erasing temporary table."
5774 table->eraseView(temporaryVersion);
5795 catch(std::runtime_error&
5798 __SUP_COUT__ <<
"Caught error while editing secondary table. "
5799 "Erasing temporary version."
5801 table->eraseView(temporaryVersion);
5802 secondaryChanged =
false;
5805 xmlOut.addTextElementToData(
5807 "Error saving secondary tree node! " + std::string(e.what()));
5815 if(0 && !changed && !secondaryChanged && !defaultIsInGroup)
5817 __SUP_SS__ <<
"Link to table '" << newTable <<
"', linkID '"
5819 <<
"', and selected group members are the same as the "
5821 <<
"No need to save changes to tree." << __E__;
5827 else if(0 && !changed)
5832 __SUP_SS__ <<
"Link to table '" << newTable <<
"' and linkID '"
5834 <<
"' are the same as the current values. No need to save "
5835 "change to tree node."
5845 __SUP_COUT__ <<
"Caught error while editing. Erasing temporary version." << __E__;
5846 table->eraseView(temporaryVersion);
5860 catch(std::runtime_error& e)
5862 __SUP_SS__ <<
"Error saving tree node! " << e.what() << __E__;
5863 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
5864 xmlOut.addTextElementToData(
"Error", ss.str());
5868 __SUP_SS__ <<
"Unknown Error saving tree node! " << __E__;
5873 catch(
const std::exception& e)
5875 ss <<
"Exception message: " << e.what();
5880 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
5881 xmlOut.addTextElementToData(
"Error", ss.str());
5925 void ConfigurationGUISupervisor::handleGetTableXML(
HttpXmlDocument& xmlOut,
5927 const std::string& tableName,
5929 bool allowIllegalColumns ,
5933 char tmpIntStr[100];
5934 xercesc::DOMElement *parentEl, *subparentEl;
5936 std::string accumulatedErrors =
"";
5938 if(allowIllegalColumns)
5939 xmlOut.addTextElementToData(
"allowIllegalColumns",
"1");
5941 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo(
5942 allowIllegalColumns ,
5943 allowIllegalColumns ? &accumulatedErrors : 0,
5952 xmlOut.addTextElementToData(
"ExistingTableNames",
5953 TableViewColumnInfo::DATATYPE_LINK_DEFAULT);
5954 for(
auto& configPair : allTableInfo)
5956 xmlOut.addTextElementToData(
"ExistingTableNames", configPair.first);
5957 if(configPair.first == tableName &&
5958 configPair.second.versions_.find(version) ==
5959 configPair.second.versions_.end())
5961 __SUP_COUT__ <<
"Version not found, so using mockup." << __E__;
5967 xmlOut.addTextElementToData(
"TableName", tableName);
5968 xmlOut.addTextElementToData(
"TableDescription",
5969 table->getTableDescription());
5983 for(
const auto& aliases : versionAliases)
5984 for(
const auto& alias : aliases.second)
5985 __SUP_COUTT__ <<
"ALIAS: " << aliases.first <<
" " << alias.first
5986 <<
" ==> " << alias.second << __E__;
5988 catch(
const std::runtime_error& e)
5990 __SUP_COUT__ <<
"Could not get backbone information for version aliases: "
5991 << e.what() << __E__;
5994 auto tableIterator = versionAliases.find(tableName);
5996 parentEl = xmlOut.addTextElementToData(
"TableVersions",
"");
5999 for(
const TableVersion& v : allTableInfo.at(tableName).versions_)
6005 std::vector<std::string> aliases;
6006 if(tableIterator != versionAliases.end())
6009 for(
const auto& aliasPair : tableIterator->second)
6011 if(v == aliasPair.second)
6013 __SUP_COUT__ <<
"Found Alias " << aliasPair.second <<
" --> "
6014 << aliasPair.first << __E__;
6015 aliases.push_back(aliasPair.first);
6023 __SUP_COUT__ <<
"Handling version w/aliases" << __E__;
6026 TableVersion::INVALID)
6031 else if(hi.
version() + 1 == v.version())
6038 if(lo.
version() != TableVersion::INVALID)
6048 if(versionAliases.size())
6052 for(
const auto& alias : aliases)
6054 hi = lo = TableVersion::INVALID;
6059 if(lo.
version() != TableVersion::INVALID)
6075 tableViewPtr = table->getMockupViewP();
6083 std::string localAccumulatedErrors =
"";
6088 allowIllegalColumns ,
6089 &localAccumulatedErrors,
6095 xmlOut.addTextElementToData(
"TableRawData",
6096 tableViewPtr->getSourceRawData());
6098 const std::set<std::string>& srcColNames =
6099 tableViewPtr->getSourceColumnNames();
6100 for(
auto& srcColName : srcColNames)
6101 xmlOut.addTextElementToData(
"ColumnHeader", srcColName);
6108 tableViewPtr = cfgMgr
6112 allowIllegalColumns ,
6113 &localAccumulatedErrors,
6119 if(localAccumulatedErrors !=
"")
6120 xmlOut.addTextElementToData(
"Error", localAccumulatedErrors);
6122 catch(std::runtime_error& e)
6124 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version " << version
6125 <<
"... defaulting to mock-up! " << __E__;
6126 ss <<
"\n\n...Here is why it failed:\n\n" << e.what() << __E__;
6128 __SUP_COUT_ERR__ <<
"\n" << ss.str();
6130 tableViewPtr = table->getMockupViewP();
6132 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
6136 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version: " << version
6137 <<
"... defaulting to mock-up! "
6138 <<
"(You may want to try again to see what was partially loaded "
6139 "into cache before failure. "
6140 <<
"If you think, the failure is due to a column name change, "
6141 <<
"you can also try to Copy the failing view to the new column "
6143 <<
"'Copy and Move' functionality.)" << __E__;
6148 catch(
const std::exception& e)
6150 ss <<
"Exception message: " << e.what();
6156 __SUP_COUT_ERR__ <<
"\n" << ss.str();
6158 tableViewPtr = table->getMockupViewP();
6160 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
6163 xmlOut.addTextElementToData(
"TableVersion", version.
toString());
6169 xercesc::DOMElement* choicesParentEl;
6170 parentEl = xmlOut.addTextElementToData(
"CurrentVersionColumnHeaders",
"");
6172 std::vector<TableViewColumnInfo> colInfo = tableViewPtr->getColumnsInfo();
6174 for(
int i = 0; i < (int)colInfo.size(); ++i)
6179 "ColumnDataType", colInfo[i].getDataType(), parentEl);
6184 "ColumnDefaultValue", colInfo[i].getDefaultValue(), parentEl);
6188 if(colInfo[i].getType() == TableViewColumnInfo::TYPE_FIXED_CHOICE_DATA ||
6189 colInfo[i].getType() == TableViewColumnInfo::TYPE_BITMAP_DATA ||
6190 colInfo[i].isChildLink())
6192 for(
auto& choice : colInfo[i].getDataChoices())
6197 "ColumnMinValue", colInfo[i].getMinValue(), parentEl);
6199 "ColumnMaxValue", colInfo[i].getMaxValue(), parentEl);
6206 tableViewPtr->
init();
6208 catch(std::runtime_error& e)
6211 __THROW__(e.what() + std::string(
"\n\n") + accumulatedErrors);
6218 parentEl = xmlOut.addTextElementToData(
"CurrentVersionRows",
"");
6220 for(
int r = 0; r < (int)tableViewPtr->getNumberOfRows(); ++r)
6222 sprintf(tmpIntStr,
"%d", r);
6223 xercesc::DOMElement* tmpParentEl =
6226 for(
int c = 0; c < (int)tableViewPtr->getNumberOfColumns(); ++c)
6228 if(colInfo[c].getDataType() == TableViewColumnInfo::DATATYPE_TIME)
6230 std::string timeAsString;
6231 tableViewPtr->
getValue(timeAsString, r, c);
6236 "Entry", tableViewPtr->getDataView()[r][c], tmpParentEl);
6241 xmlOut.addTextElementToData(
"TableComment", tableViewPtr->getComment());
6242 xmlOut.addTextElementToData(
"TableAuthor", tableViewPtr->getAuthor());
6243 xmlOut.addTextElementToData(
"TableCreationTime",
6244 std::to_string(tableViewPtr->getCreationTime()));
6245 xmlOut.addTextElementToData(
"TableLastAccessTime",
6246 std::to_string(tableViewPtr->getLastAccessTime()));
6251 std::vector<std::string> defaultRowValues =
6252 table->getMockupViewP()->getDefaultRowValues();
6254 for(
unsigned int c = 0; c < defaultRowValues.size() - 2; ++c)
6256 xmlOut.addTextElementToData(
"DefaultRowValue", defaultRowValues[c]);
6259 const std::set<std::string> srcColNames = tableViewPtr->getSourceColumnNames();
6261 if(accumulatedErrors !=
"")
6263 __SUP_SS__ << (std::string(
"Column errors were allowed for this request, so "
6264 "perhaps you can ignore this, ") +
6265 "but please note the following warnings:\n" + accumulatedErrors)
6267 __SUP_COUT_ERR__ << ss.str();
6268 xmlOut.addTextElementToData(
"TableWarnings", ss.str());
6272 (srcColNames.size() != tableViewPtr->getNumberOfColumns() ||
6273 tableViewPtr->getSourceColumnMismatch() !=
6276 __SUP_SS__ <<
"\n\nThere were warnings found when loading the table " << tableName
6277 <<
":v" << version <<
". Please see the details below:\n\n"
6278 << tableViewPtr->getMismatchColumnInfo();
6280 __SUP_COUT__ <<
"\n" << ss.str();
6281 xmlOut.addTextElementToData(
"TableWarnings", ss.str());
6285 catch(std::runtime_error& e)
6287 __SUP_SS__ <<
"Error getting table view!\n\n " << e.what() << __E__;
6288 __SUP_COUT_ERR__ << ss.str();
6289 xmlOut.addTextElementToData(
"Error", ss.str());
6293 __SUP_SS__ <<
"Error getting table view!\n\n " << __E__;
6298 catch(
const std::exception& e)
6300 ss <<
"Exception message: " << e.what();
6305 __SUP_COUT_ERR__ << ss.str();
6306 xmlOut.addTextElementToData(
"Error", ss.str());
6317 std::string username,
bool refresh)
6319 uint64_t sessionIndex =
6322 std::stringstream ssMapKey;
6323 ssMapKey << username <<
":" << sessionIndex;
6324 std::string mapKey = ssMapKey.str();
6325 __SUP_COUTT__ <<
"Using Config Session " << mapKey
6326 <<
" ... Total Session Count: " << userConfigurationManagers_.size()
6327 <<
" refresh=" << refresh << __E__;
6329 time_t now = time(0);
6335 for(
auto& pair : userConfigurationManagers_)
6336 __SUP_COUTTV__(pair.first);
6339 const std::string preLoadCfgMgrName =
":0";
6340 if(userConfigurationManagers_.size() == 1 &&
6341 userConfigurationManagers_.find(preLoadCfgMgrName) !=
6342 userConfigurationManagers_.end())
6344 __SUP_COUT__ <<
"Using pre-loaded Configuration Manager. time=" << time(0) <<
" "
6345 << clock() <<
" Setting author from "
6346 << userConfigurationManagers_.at(preLoadCfgMgrName)->getUsername()
6347 <<
" to " << username << __E__;
6348 userConfigurationManagers_[mapKey] =
6349 userConfigurationManagers_.at(preLoadCfgMgrName);
6350 userLastUseTime_[mapKey] = userLastUseTime_.at(preLoadCfgMgrName);
6352 userConfigurationManagers_.at(mapKey)->setUsername(username);
6355 if(userConfigurationManagers_.find(mapKey) == userConfigurationManagers_.end())
6357 __SUP_COUT__ <<
"Creating new Configuration Manager. time=" << time(0) <<
" "
6358 << clock() << __E__;
6364 userConfigurationManagers_[mapKey]->getAllTableInfo(
6372 else if(userLastUseTime_.find(mapKey) == userLastUseTime_.end())
6374 __SUP_SS__ <<
"Fatal error managing userLastUseTime_! Check the logs for "
6375 "Configuration Interface failure."
6377 __SUP_COUT_ERR__ <<
"\n" << ss.str();
6382 (now - userLastUseTime_[mapKey]) >
6383 CONFIGURATION_MANAGER_REFRESH_THRESHOLD)
6385 __SUP_COUT__ <<
"Refreshing all table info." << __E__;
6386 userConfigurationManagers_[mapKey]->getAllTableInfo(
6394 __SUP_COUTT__ <<
"Configuration Manager for author="
6395 << userConfigurationManagers_[mapKey]->getUsername()
6396 <<
" ready. time=" << time(0) <<
" " << clock() <<
" runTimeSeconds()="
6397 << userConfigurationManagers_[mapKey]->runTimeSeconds() << __E__;
6400 userLastUseTime_[mapKey] = now;
6403 for(std::map<std::string, time_t>::iterator it = userLastUseTime_.begin();
6404 it != userLastUseTime_.end();
6406 if(now - it->second > CONFIGURATION_MANAGER_EXPIRATION_TIME)
6408 __SUP_COUT__ << now <<
":" << it->second <<
" = " << now - it->second
6410 delete userConfigurationManagers_[it->first];
6411 if(!(userConfigurationManagers_.erase(it->first)))
6413 __SUP_SS__ <<
"Fatal error erasing configuration manager by key!"
6415 __SUP_COUT_ERR__ <<
"\n" << ss.str();
6418 userLastUseTime_.erase(it);
6425 return userConfigurationManagers_[mapKey];
6433 void ConfigurationGUISupervisor::handleDeleteTableInfoXML(
HttpXmlDocument& xmlOut,
6435 std::string& tableName)
6437 if(0 == rename((TABLE_INFO_PATH + tableName + TABLE_INFO_EXT).c_str(),
6438 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused").c_str()))
6439 __SUP_COUT_INFO__ << (
"Table Info File successfully renamed: " +
6440 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused"))
6444 __SUP_COUT_ERR__ << (
"Error renaming file to " +
6445 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused"))
6448 xmlOut.addTextElementToData(
6450 (
"Error renaming Table Info File to " +
6451 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused")));
6466 void ConfigurationGUISupervisor::handleSaveTableInfoXML(
6469 std::string& tableName,
6470 const std::string& data,
6471 const std::string& tableDescription,
6472 const std::string& columnChoicesCSV,
6473 bool allowOverwrite)
6477 std::string capsName;
6482 catch(std::runtime_error& e)
6484 xmlOut.addTextElementToData(
"Error", e.what());
6490 FILE* fp = fopen((TABLE_INFO_PATH + tableName + TABLE_INFO_EXT).c_str(),
"r");
6494 xmlOut.addTextElementToData(
"TableName", tableName);
6495 xmlOut.addTextElementToData(
"OverwriteError",
"1");
6496 xmlOut.addTextElementToData(
6498 "File already exists! ('" +
6499 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT) +
"')");
6504 __SUP_COUT__ <<
"capsName=" << capsName << __E__;
6505 __SUP_COUT__ <<
"tableName=" << tableName << __E__;
6506 __SUP_COUT__ <<
"tableDescription=" << tableDescription << __E__;
6507 __SUP_COUT__ <<
"columnChoicesCSV=" << columnChoicesCSV << __E__;
6510 std::stringstream outss;
6512 outss <<
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n";
6513 outss <<
"\t<ROOT xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
6514 "xsi:noNamespaceSchemaLocation=\"TableInfo.xsd\">\n";
6515 outss <<
"\t\t<TABLE Name=\"" << tableName <<
"\">\n";
6516 outss <<
"\t\t\t<VIEW Name=\"" << capsName
6517 <<
"\" Type=\"File,Database,DatabaseTest\" Description=\"" << tableDescription
6523 std::istringstream columnChoicesISS(columnChoicesCSV);
6524 std::string columnChoicesString;
6525 std::string columnDefaultValue, columnMinValue, columnMaxValue;
6526 std::vector<std::string> columnParameters;
6527 std::vector<std::string> columnData =
6530 for(
unsigned int c = 0; c < columnData.size() - 1; ++c)
6534 __COUT__ <<
"Column #" << c <<
": "
6536 for(
unsigned int p = 0; p < columnParameters.size(); ++p)
6538 __COUT__ <<
"\t Parameter #" << p <<
": " << columnParameters[p] << __E__;
6540 __COUT__ <<
"\t creating the new xml" << __E__;
6542 std::string& columnType = columnParameters[0];
6543 std::string& columnName = columnParameters[1];
6544 std::string& columnDataType = columnParameters[2];
6545 const std::string columnStorageName =
6548 outss <<
"\t\t\t\t<COLUMN Type=\"";
6549 outss << columnType;
6550 outss <<
"\" \t Name=\"";
6551 outss << columnName;
6552 outss <<
"\" \t StorageName=\"";
6555 outss << columnStorageName;
6557 catch(std::runtime_error& e)
6559 xmlOut.addTextElementToData(
6561 std::string(
"For column name '") + columnName +
"' - " + e.what());
6564 outss <<
"\" \t DataType=\"";
6565 outss << columnDataType;
6569 std::string* columnDefaultValuePtr =
nullptr;
6570 if(columnDefaultValue !=
6571 TableViewColumnInfo::getDefaultDefaultValue(columnType, columnDataType))
6573 __SUP_COUT__ <<
"FOUND user spec'd default value '" << columnDefaultValue
6575 outss <<
"\" \t DefaultValue=\"";
6576 outss << columnParameters[3];
6577 columnDefaultValuePtr = &columnParameters[3];
6579 getline(columnChoicesISS, columnChoicesString,
';');
6580 outss <<
"\" \t DataChoices=\"";
6581 outss << columnChoicesString;
6583 std::string* columnMinValuePtr =
nullptr;
6584 std::string* columnMaxValuePtr =
nullptr;
6586 if(columnParameters.size() > 4 &&
6590 if(columnMinValue !=
"")
6592 if(columnMinValue !=
6595 __SUP_COUT__ <<
"FOUND user spec'd min value '" << columnParameters[4]
6600 __SS__ <<
"Inavlid user spec'd min value '" << columnParameters[4]
6601 <<
"' which evaluates to '" << columnMinValue
6602 <<
"' and is not a valid number. The minimum value must "
6603 "be a number (environment variables and math "
6604 "operations are allowed)."
6608 outss <<
"\" \t MinValue=\"" << columnParameters[4];
6609 columnMinValuePtr = &columnParameters[4];
6614 if(columnMaxValue !=
"")
6616 if(columnMaxValue !=
6619 __SUP_COUT__ <<
"FOUND user spec'd max value = " << columnMaxValue
6624 __SS__ <<
"Inavlid user spec'd max value '" << columnParameters[5]
6625 <<
"' which evaluates to '" << columnMaxValue
6626 <<
"' and is not a valid number. The maximum value must "
6627 "be a number (environment variables and math "
6628 "operations are allowed)."
6632 outss <<
"\" \t MaxValue=\"" << columnParameters[5];
6633 columnMaxValuePtr = &columnParameters[5];
6645 columnDefaultValuePtr,
6646 columnChoicesString,
6652 catch(
const std::runtime_error& e)
6654 __SS__ <<
"Error identified with Column #" << c <<
": \n" << e.what();
6661 outss <<
"\t\t\t</VIEW>\n";
6662 outss <<
"\t\t</TABLE>\n";
6663 outss <<
"\t</ROOT>\n";
6665 __SUP_COUT__ << outss.str() << __E__;
6667 FILE* fp = fopen((TABLE_INFO_PATH + tableName + TABLE_INFO_EXT).c_str(),
"w");
6670 xmlOut.addTextElementToData(
"Error",
6671 "Failed to open destination Table Info file:" +
6672 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT));
6676 fprintf(fp,
"%s", outss.str().c_str());
6679 __SUP_COUT_INFO__ <<
"Finished saving Table Info for '" << tableName
6680 <<
".' Looking for errors in all table column info..." << __E__;
6684 std::string accumulatedErrors =
"";
6688 if(accumulatedErrors !=
"")
6690 __SUP_SS__ << (
"The new version of the '" + tableName +
6691 "' table column info was saved, however errors were detected "
6692 "reading back the table '" +
6693 tableName +
"' after the save attempt:\n\n" + accumulatedErrors)
6696 __SUP_COUT_ERR__ << ss.str() << __E__;
6697 xmlOut.addTextElementToData(
"Error", ss.str());
6703 handleGetTableXML(xmlOut, cfgMgr, tableName,
TableVersion());
6706 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
6709 for(
const auto& cfgInfo : allTableInfo)
6715 catch(std::runtime_error& e)
6717 __SUP_COUT_WARN__ <<
"\n\n##############################################\n"
6718 <<
"Error identified in column info of table '"
6719 << cfgInfo.first <<
"':\n\n"
6720 << e.what() <<
"\n\n"
6734 void ConfigurationGUISupervisor::handleSetGroupAliasInBackboneXML(
6737 const std::string& groupAliasCSV,
6738 const std::string& groupNameCSV,
6739 const std::string& groupKeyCSV,
6740 const std::string& author)
6744 std::map<std::string, TableVersion> activeVersions = cfgMgr->
getActiveVersions();
6746 const std::string groupAliasesTableName =
6747 ConfigurationManager::GROUP_ALIASES_TABLE_NAME;
6748 if(activeVersions.find(groupAliasesTableName) == activeVersions.end())
6750 __SUP_SS__ <<
"Active version of " << groupAliasesTableName <<
" missing!"
6752 xmlOut.addTextElementToData(
"Error", ss.str());
6757 const std::set<std::string> backboneMembers = cfgMgr->getBackboneMemberNames();
6758 for(
auto& memberName : backboneMembers)
6760 __SUP_COUT__ <<
"activeVersions[\"" << memberName
6761 <<
"\"]=" << activeVersions[memberName] << __E__;
6763 xmlOut.addTextElementToData(
"oldBackboneName", memberName);
6764 xmlOut.addTextElementToData(
"oldBackboneVersion",
6765 activeVersions[memberName].toString());
6773 TableVersion originalVersion = activeVersions[groupAliasesTableName];
6776 __SUP_COUT__ <<
"\t\t temporaryVersion: " << temporaryVersion << __E__;
6777 bool isDifferent =
false;
6783 unsigned int col = configView->
findCol(
"GroupKeyAlias");
6784 unsigned int ccol = configView->
findCol(TableViewColumnInfo::COL_NAME_COMMENT);
6785 unsigned int ncol = configView->
findCol(
"GroupName");
6786 unsigned int kcol = configView->
findCol(
"GroupKey");
6789 std::vector<std::string> groupAliases =
6791 std::vector<std::string> groupNames =
6793 std::vector<std::string> groupKeys =
6800 for(
const auto& groupAlias : groupAliases)
6802 if(groupAlias ==
"" || groupNames[i] ==
"" || groupKeys[i] ==
"")
6805 __SUP_COUT_WARN__ <<
"Empty alias parameter found [" << i <<
"] = {"
6806 << groupAlias <<
", " << groupNames[i] <<
"("
6807 << groupKeys[i] <<
")}" << __E__;
6812 bool localIsDifferent =
false;
6813 const std::string& groupName = groupNames[i];
6817 unsigned int row = -1;
6821 row = configView->
findRow(col, groupAlias);
6827 if(row == (
unsigned int)-1)
6829 localIsDifferent =
true;
6830 row = configView->
addRow();
6834 "This Group Alias was automatically setup by the server.", row, ccol);
6835 configView->
setValue(groupAlias, row, col);
6838 __SUP_COUT__ <<
"\t\t row: " << row << __E__;
6840 __SUP_COUT__ <<
"\t\t groupName: " << groupName <<
" vs "
6841 << configView->getDataView()[row][ncol] << __E__;
6842 if(groupName != configView->getDataView()[row][ncol])
6844 configView->
setValue(groupName, row, ncol);
6845 localIsDifferent =
true;
6848 __SUP_COUT__ <<
"\t\t groupKey: " << groupKey <<
" vs "
6849 << configView->getDataView()[row][kcol] << __E__;
6850 if(groupKey.
toString() != configView->getDataView()[row][kcol])
6853 localIsDifferent =
true;
6856 if(localIsDifferent)
6861 configView->
findCol(TableViewColumnInfo::COL_NAME_AUTHOR));
6865 configView->
findCol(TableViewColumnInfo::COL_NAME_CREATION));
6872 __SUP_COUT_ERR__ <<
"Error editing Group Alias view!" << __E__;
6875 table->eraseView(temporaryVersion);
6882 __SUP_COUT__ <<
"\t\t**************************** Save as new table version"
6900 <<
"\t\t**************************** Using the existing table version"
6904 table->eraseView(temporaryVersion);
6905 newAssignedVersion = activeVersions[groupAliasesTableName];
6907 xmlOut.addTextElementToData(
"savedName", groupAliasesTableName);
6908 xmlOut.addTextElementToData(
"savedVersion", newAssignedVersion.
toString());
6911 __SUP_COUT__ <<
"\t\t newAssignedVersion: " << newAssignedVersion << __E__;
6913 catch(std::runtime_error& e)
6915 __SUP_SS__ <<
"Error saving new Group Alias view!\n\n " << e.what() << __E__;
6916 __SUP_COUT_ERR__ << ss.str();
6917 xmlOut.addTextElementToData(
"Error", ss.str());
6921 __SUP_SS__ <<
"Error saving new Group Alias view!\n\n " << __E__;
6926 catch(
const std::exception& e)
6928 ss <<
"Exception message: " << e.what();
6933 __SUP_COUT_ERR__ << ss.str();
6934 xmlOut.addTextElementToData(
"Error", ss.str());
6945 void ConfigurationGUISupervisor::handleSetTableAliasInBackboneXML(
6948 const std::string& tableAlias,
6949 const std::string& tableName,
6951 const std::string& author)
6955 std::map<std::string, TableVersion> activeVersions = cfgMgr->
getActiveVersions();
6957 const std::string versionAliasesTableName =
6958 ConfigurationManager::VERSION_ALIASES_TABLE_NAME;
6959 if(activeVersions.find(versionAliasesTableName) == activeVersions.end())
6961 __SUP_SS__ <<
"Active version of " << versionAliasesTableName <<
" missing!"
6963 xmlOut.addTextElementToData(
"Error", ss.str());
6968 const std::set<std::string> backboneMembers = cfgMgr->getBackboneMemberNames();
6969 for(
auto& memberName : backboneMembers)
6971 __SUP_COUT__ <<
"activeVersions[\"" << memberName
6972 <<
"\"]=" << activeVersions[memberName] << __E__;
6974 xmlOut.addTextElementToData(
"oldBackboneName", memberName);
6975 xmlOut.addTextElementToData(
"oldBackboneVersion",
6976 activeVersions[memberName].toString());
6984 TableVersion originalVersion = activeVersions[versionAliasesTableName];
6987 __SUP_COUT__ <<
"\t\t temporaryVersion: " << temporaryVersion << __E__;
6989 bool isDifferent =
false;
6996 unsigned int col2 = configView->
findCol(
"VersionAlias");
6997 unsigned int col3 = configView->
findCol(
"TableName");
7001 unsigned int row = -1;
7006 unsigned int tmpRow = -1;
7009 tmpRow = configView->
findRow(col3, tableName, tmpRow + 1);
7010 }
while(configView->getDataView()[tmpRow][col2] != tableAlias);
7017 if(row == (
unsigned int)-1)
7020 row = configView->
addRow();
7023 col = configView->
findCol(TableViewColumnInfo::COL_NAME_COMMENT);
7025 std::string(
"Entry was added by server in ") +
7026 "ConfigurationGUISupervisor::setTableAliasInActiveBackbone().",
7030 col = configView->
findCol(
"VersionAliasUID");
7032 tableName.substr(0, tableName.rfind(
"Table")) + tableAlias, row, col);
7034 configView->
setValue(tableAlias, row, col2);
7035 configView->
setValue(tableName, row, col3);
7038 __SUP_COUT__ <<
"\t\t row: " << row << __E__;
7040 col = configView->
findCol(
"Version");
7041 __SUP_COUT__ <<
"\t\t version: " << version <<
" vs "
7042 << configView->getDataView()[row][col] << __E__;
7043 if(version.
toString() != configView->getDataView()[row][col])
7052 author, row, configView->
findCol(TableViewColumnInfo::COL_NAME_AUTHOR));
7056 configView->
findCol(TableViewColumnInfo::COL_NAME_CREATION));
7061 __SUP_COUT_ERR__ <<
"Error editing Version Alias view!" << __E__;
7064 table->eraseView(temporaryVersion);
7071 __SUP_COUT__ <<
"\t\t**************************** Save as new table version"
7087 __SUP_COUT__ <<
"\t\t**************************** Using existing table version"
7091 table->eraseView(temporaryVersion);
7092 newAssignedVersion = activeVersions[versionAliasesTableName];
7094 xmlOut.addTextElementToData(
"savedName", versionAliasesTableName);
7095 xmlOut.addTextElementToData(
"savedVersion", newAssignedVersion.
toString());
7098 __SUP_COUT__ <<
"\t\t newAssignedVersion: " << newAssignedVersion << __E__;
7100 catch(std::runtime_error& e)
7102 __SUP_SS__ <<
"Error saving new Version Alias view!\n\n " << e.what() << __E__;
7103 __SUP_COUT_ERR__ << ss.str();
7104 xmlOut.addTextElementToData(
"Error", ss.str());
7108 __SUP_SS__ <<
"Error saving new Version Alias view!\n\n " << __E__;
7113 catch(
const std::exception& e)
7115 ss <<
"Exception message: " << e.what();
7120 __SUP_COUT_ERR__ << ss.str();
7121 xmlOut.addTextElementToData(
"Error", ss.str());
7130 void ConfigurationGUISupervisor::handleAliasGroupMembersInBackboneXML(
7133 const std::string& versionAlias,
7134 const std::string& groupName,
7136 const std::string& author)
7140 std::map<std::string, TableVersion> activeVersions = cfgMgr->
getActiveVersions();
7142 const std::string versionAliasesTableName =
7143 ConfigurationManager::VERSION_ALIASES_TABLE_NAME;
7144 if(activeVersions.find(versionAliasesTableName) == activeVersions.end())
7146 __SUP_SS__ <<
"Active version of " << versionAliasesTableName <<
" missing!"
7148 xmlOut.addTextElementToData(
"Error", ss.str());
7153 const std::set<std::string> backboneMembers = cfgMgr->getBackboneMemberNames();
7154 for(
auto& memberName : backboneMembers)
7156 __SUP_COUT__ <<
"activeVersions[\"" << memberName
7157 <<
"\"]=" << activeVersions[memberName] << __E__;
7159 xmlOut.addTextElementToData(
"oldBackboneName", memberName);
7160 xmlOut.addTextElementToData(
"oldBackboneVersion",
7161 activeVersions[memberName].toString());
7172 __SUP_COUT__ <<
"\t\t temporaryVersion: " << temporaryVersion << __E__;
7177 bool isDifferent =
false;
7196 xmlOut.addTextElementToData(
7199 "\" can not be retrieved!");
7204 unsigned int col2 = configView->
findCol(
"VersionAlias");
7205 unsigned int col3 = configView->
findCol(
"TableName");
7207 for(
auto& memberPair : memberMap)
7209 bool thisMemberIsDifferent =
false;
7210 unsigned int row = -1;
7212 __SUP_COUT__ <<
"Adding alias for " << memberPair.first <<
"_v"
7213 << memberPair.second <<
" to " << versionAlias << __E__;
7219 unsigned int tmpRow = -1;
7222 tmpRow = configView->
findRow(col3, memberPair.first, tmpRow + 1);
7223 }
while(configView->getDataView()[tmpRow][col2] != versionAlias);
7230 if(row == (
unsigned int)-1)
7232 thisMemberIsDifferent =
true;
7233 row = configView->
addRow();
7236 col = configView->
findCol(TableViewColumnInfo::COL_NAME_COMMENT);
7238 std::string(
"Entry was added by server in ") +
7239 "ConfigurationGUISupervisor::setTableAliasInActiveBackbone().",
7245 memberPair.first.substr(0, memberPair.first.rfind(
"Table")) +
7250 configView->
setValue(versionAlias, row, col2);
7251 configView->
setValue(memberPair.first, row, col3);
7254 col = configView->
findCol(
"Version");
7256 if(memberPair.second.toString() != configView->getDataView()[row][col])
7258 configView->
setValue(memberPair.second.toString(), row, col);
7259 thisMemberIsDifferent =
true;
7262 if(thisMemberIsDifferent)
7265 author, row, configView->
findCol(TableViewColumnInfo::COL_NAME_AUTHOR));
7269 configView->
findCol(TableViewColumnInfo::COL_NAME_CREATION));
7272 if(thisMemberIsDifferent)
7281 __SUP_COUT__ <<
"\t\t**************************** Save v" << temporaryVersion
7282 <<
" as new table version" << __E__;
7284 newAssignedVersion =
7285 cfgMgr->
saveNewTable(versionAliasesTableName, temporaryVersion);
7289 __SUP_COUT__ <<
"\t\t**************************** Using existing table version"
7293 table->eraseView(temporaryVersion);
7294 newAssignedVersion = activeVersions[versionAliasesTableName];
7297 xmlOut.addTextElementToData(
"savedName", versionAliasesTableName);
7298 xmlOut.addTextElementToData(
"savedVersion", newAssignedVersion.
toString());
7299 __SUP_COUT__ <<
"\t\t Resulting Version: " << newAssignedVersion << __E__;
7301 catch(std::runtime_error& e)
7303 __SUP_SS__ <<
"Error saving new Version Alias view!\n\n " << e.what() << __E__;
7304 __SUP_COUT_ERR__ << ss.str();
7305 xmlOut.addTextElementToData(
"Error", ss.str());
7309 __SUP_SS__ <<
"Error saving new Version Alias view!\n\n " << __E__;
7314 catch(
const std::exception& e)
7316 ss <<
"Exception message: " << e.what();
7321 __SUP_COUT_ERR__ << ss.str();
7322 xmlOut.addTextElementToData(
"Error", ss.str());
7336 void ConfigurationGUISupervisor::handleGroupAliasesXML(
HttpXmlDocument& xmlOut,
7340 std::map<std::string, TableVersion> activeVersions = cfgMgr->
getActiveVersions();
7342 std::string groupAliasesTableName = ConfigurationManager::GROUP_ALIASES_TABLE_NAME;
7343 if(activeVersions.find(groupAliasesTableName) == activeVersions.end())
7345 __SUP_SS__ <<
"\nActive version of " << groupAliasesTableName <<
" missing! "
7346 << groupAliasesTableName
7347 <<
" is a required member of the Backbone table group."
7348 <<
"\n\nLikely you need to activate a valid Backbone table group."
7350 __SUP_COUT__ << ss.str();
7355 __SUP_COUT__ <<
"activeVersions[\"" << groupAliasesTableName
7356 <<
"\"]=" << activeVersions[groupAliasesTableName] << __E__;
7357 xmlOut.addTextElementToData(
"GroupAliasesTableName", groupAliasesTableName);
7358 xmlOut.addTextElementToData(
"GroupAliasesTableVersion",
7359 activeVersions[groupAliasesTableName].toString());
7361 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
7366 <<
" ==> " << numOfThreads <<
" threads for alias group loads." << __E__;
7368 if(numOfThreads < 2)
7370 std::string groupName, groupKey, groupComment, groupAuthor, groupCreateTime,
7372 for(
auto& aliasNodePair : aliasNodePairs)
7374 groupName = aliasNodePair.second.getNode(
"GroupName").getValueAsString();
7375 groupKey = aliasNodePair.second.getNode(
"GroupKey").getValueAsString();
7377 xmlOut.addTextElementToData(
"GroupAlias", aliasNodePair.first);
7378 xmlOut.addTextElementToData(
"GroupName", groupName);
7379 xmlOut.addTextElementToData(
"GroupKey", groupKey);
7380 xmlOut.addTextElementToData(
7382 aliasNodePair.second.getNode(TableViewColumnInfo::COL_NAME_COMMENT)
7383 .getValueAsString());
7387 ConfigurationManager::UNKNOWN_INFO;
7388 groupType = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
7405 __SUP_COUT_WARN__ <<
"Failed to load group '" << groupName <<
"("
7406 << groupKey <<
")' to extract group comment and type."
7409 xmlOut.addTextElementToData(
"GroupComment", groupComment);
7410 xmlOut.addTextElementToData(
"GroupType", groupType);
7415 int threadsLaunched = 0;
7416 int foundThreadIndex = 0;
7417 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
7418 for(
int i = 0; i < numOfThreads; ++i)
7419 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
7421 std::vector<std::shared_ptr<ots::GroupInfo>> sharedGroupInfoPtrs;
7422 std::string groupName, groupKey;
7424 for(
auto& aliasNodePair : aliasNodePairs)
7427 sharedGroupInfoPtrs.push_back(std::make_shared<ots::GroupInfo>());
7429 groupName = aliasNodePair.second.getNode(
"GroupName").getValueAsString();
7430 groupKey = aliasNodePair.second.getNode(
"GroupKey").getValueAsString();
7432 if(threadsLaunched >= numOfThreads)
7435 foundThreadIndex = -1;
7436 while(foundThreadIndex == -1)
7438 for(
int i = 0; i < numOfThreads; ++i)
7439 if(*(threadDone[i]))
7441 foundThreadIndex = i;
7444 if(foundThreadIndex == -1)
7446 __SUP_COUTT__ <<
"Waiting for available thread..." << __E__;
7450 threadsLaunched = numOfThreads - 1;
7452 __SUP_COUTT__ <<
"Starting load group thread... " << groupName <<
"("
7453 << groupKey <<
")" << __E__;
7454 *(threadDone[foundThreadIndex]) =
false;
7458 std::string theGroupName,
7460 std::shared_ptr<ots::GroupInfo> theGroupInfo,
7461 std::shared_ptr<std::atomic<bool>> theThreadDone) {
7471 sharedGroupInfoPtrs.back(),
7472 threadDone[foundThreadIndex])
7483 foundThreadIndex = -1;
7484 for(
int i = 0; i < numOfThreads; ++i)
7485 if(!*(threadDone[i]))
7487 foundThreadIndex = i;
7490 if(foundThreadIndex != -1)
7492 __SUP_COUTT__ <<
"Waiting for thread to finish... " << foundThreadIndex
7496 }
while(foundThreadIndex != -1);
7500 for(
auto& aliasNodePair : aliasNodePairs)
7502 groupName = aliasNodePair.second.getNode(
"GroupName").getValueAsString();
7503 groupKey = aliasNodePair.second.getNode(
"GroupKey").getValueAsString();
7504 xmlOut.addTextElementToData(
"GroupAlias", aliasNodePair.first);
7505 xmlOut.addTextElementToData(
"GroupName", groupName);
7506 xmlOut.addTextElementToData(
"GroupKey", groupKey);
7507 xmlOut.addTextElementToData(
7509 aliasNodePair.second.getNode(TableViewColumnInfo::COL_NAME_COMMENT)
7510 .getValueAsString());
7512 xmlOut.addTextElementToData(
"GroupComment",
7513 sharedGroupInfoPtrs[i]->latestKeyGroupComment_);
7514 xmlOut.addTextElementToData(
"GroupAuthor",
7515 sharedGroupInfoPtrs[i]->latestKeyGroupAuthor_);
7516 xmlOut.addTextElementToData(
7517 "GroupCreationTime", sharedGroupInfoPtrs[i]->latestKeyGroupCreationTime_);
7518 xmlOut.addTextElementToData(
7519 "GroupType", sharedGroupInfoPtrs[i]->latestKeyGroupTypeString_);
7538 void ConfigurationGUISupervisor::handleVersionAliasesXML(
HttpXmlDocument& xmlOut,
7542 std::map<std::string, TableVersion> activeVersions = cfgMgr->
getActiveVersions();
7544 std::string versionAliasesTableName =
7545 ConfigurationManager::VERSION_ALIASES_TABLE_NAME;
7546 if(activeVersions.find(versionAliasesTableName) == activeVersions.end())
7548 __SUP_SS__ <<
"Active version of VersionAliases missing!"
7549 <<
"Make sure you have a valid active Backbone Group." << __E__;
7550 xmlOut.addTextElementToData(
"Error", ss.str());
7553 __SUP_COUT__ <<
"activeVersions[\"" << versionAliasesTableName
7554 <<
"\"]=" << activeVersions[versionAliasesTableName] << __E__;
7555 xmlOut.addTextElementToData(
"VersionAliasesVersion",
7556 activeVersions[versionAliasesTableName].toString());
7558 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
7561 for(
auto& aliasNodePair : aliasNodePairs)
7565 xmlOut.addTextElementToData(
7567 aliasNodePair.second.getNode(
"VersionAlias").getValueAsString());
7568 xmlOut.addTextElementToData(
7569 "TableName", aliasNodePair.second.getNode(
"TableName").getValueAsString());
7570 xmlOut.addTextElementToData(
7571 "Version", aliasNodePair.second.getNode(
"Version").getValueAsString());
7572 xmlOut.addTextElementToData(
7574 aliasNodePair.second.getNode(TableViewColumnInfo::COL_NAME_COMMENT)
7575 .getValueAsString());
7585 void ConfigurationGUISupervisor::handleGetTableGroupTypeXML(
7589 std::string name, versionStr;
7590 auto c = tableList.find(
',', 0);
7593 while(c < tableList.length())
7596 name = tableList.substr(i, c - i);
7598 c = tableList.find(
',', i);
7599 if(c == std::string::npos)
7601 __SUP_SS__ <<
"Incomplete Table Name-Version pair!" << __E__;
7602 __SUP_COUT_ERR__ <<
"\n" << ss.str();
7603 xmlOut.addTextElementToData(
"Error", ss.str());
7607 versionStr = tableList.substr(i, c - i);
7609 c = tableList.find(
',', i);
7614 std::string groupTypeString =
"";
7620 xmlOut.addTextElementToData(
"TableGroupType", groupTypeString);
7622 catch(std::runtime_error& e)
7624 __SUP_SS__ <<
"Table group has invalid type! " << e.what() << __E__;
7625 __SUP_COUT__ <<
"\n" << ss.str();
7626 groupTypeString = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
7627 xmlOut.addTextElementToData(
"TableGroupType", groupTypeString);
7631 __SUP_SS__ <<
"Table group has invalid type! " << __E__;
7636 catch(
const std::exception& e)
7638 ss <<
"Exception message: " << e.what();
7643 __SUP_COUT__ <<
"\n" << ss.str();
7644 groupTypeString = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
7645 xmlOut.addTextElementToData(
"TableGroupType", groupTypeString);
7665 void ConfigurationGUISupervisor::handleTableGroupsXML(
HttpXmlDocument& xmlOut,
7669 __SUP_COUTT__ <<
"cfgMgr runtime=" << cfgMgr->runTimeSeconds() << __E__;
7675 if(!cfgMgr->getAllGroupInfo().size() ||
7676 cfgMgr->getAllGroupInfo().begin()->second.latestKeyGroupTypeString_ ==
"" ||
7677 cfgMgr->getAllGroupInfo().begin()->second.latestKeyGroupTypeString_ ==
7678 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN ||
7680 cfgMgr->getActiveGroupKey(ConfigurationManager::GroupType::CONTEXT_TYPE) !=
7681 TableGroupKey::INVALID &&
7682 cfgMgr->getAllGroupInfo().find(cfgMgr->getActiveGroupName(
7683 ConfigurationManager::GroupType::CONTEXT_TYPE)) !=
7684 cfgMgr->getAllGroupInfo().end() &&
7685 (cfgMgr->getAllGroupInfo()
7686 .at(cfgMgr->getActiveGroupName(
7687 ConfigurationManager::GroupType::CONTEXT_TYPE))
7688 .latestKeyGroupTypeString_ ==
"" ||
7689 cfgMgr->getAllGroupInfo()
7690 .at(cfgMgr->getActiveGroupName(
7691 ConfigurationManager::GroupType::CONTEXT_TYPE))
7692 .latestKeyGroupTypeString_ ==
7693 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN)) ||
7695 cfgMgr->getActiveGroupKey(
7696 ConfigurationManager::GroupType::CONFIGURATION_TYPE) !=
7697 TableGroupKey::INVALID &&
7698 cfgMgr->getAllGroupInfo().find(cfgMgr->getActiveGroupName(
7699 ConfigurationManager::GroupType::CONFIGURATION_TYPE)) !=
7700 cfgMgr->getAllGroupInfo().end() &&
7701 (cfgMgr->getAllGroupInfo()
7702 .at(cfgMgr->getActiveGroupName(
7703 ConfigurationManager::GroupType::CONFIGURATION_TYPE))
7704 .latestKeyGroupTypeString_ ==
"" ||
7705 cfgMgr->getAllGroupInfo()
7706 .at(cfgMgr->getActiveGroupName(
7707 ConfigurationManager::GroupType::CONFIGURATION_TYPE))
7708 .latestKeyGroupTypeString_ ==
7709 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN)))
7712 <<
"Group Info cache appears empty or stale. Attempting to regenerate..."
7722 const std::map<std::string, GroupInfo>& allGroupInfo = cfgMgr->getAllGroupInfo();
7724 __SUP_COUTT__ <<
"cfgMgr runtime=" << cfgMgr->runTimeSeconds() << __E__;
7727 std::string groupName;
7728 std::string groupString, groupTypeString, groupComment, groupCreationTime,
7730 for(
auto& groupInfo : allGroupInfo)
7732 groupName = groupInfo.first;
7733 if(groupInfo.second.keys_.size() == 0)
7735 __SUP_COUT__ <<
"Group name '" << groupName
7736 <<
"' found, but no keys so ignoring." << __E__;
7740 groupKey = *(groupInfo.second.keys_.rbegin());
7742 xmlOut.dataSs_ <<
"<TableGroupName value='" << groupName <<
"'/>" << __E__;
7743 xmlOut.dataSs_ <<
"<TableGroupKey value='" << groupKey <<
"'/>" << __E__;
7746 xmlOut.dataSs_ <<
"<TableGroupType value='"
7747 << groupInfo.second.latestKeyGroupTypeString_ <<
"'/>" << __E__;
7748 xmlOut.dataSs_ <<
"<TableGroupComment value='"
7750 groupInfo.second.latestKeyGroupComment_,
7753 xmlOut.dataSs_ <<
"<TableGroupAuthor value='"
7754 << groupInfo.second.latestKeyGroupAuthor_ <<
"'/>" << __E__;
7755 xmlOut.dataSs_ <<
"<TableGroupCreationTime value='"
7756 << groupInfo.second.latestKeyGroupCreationTime_ <<
"'/>" << __E__;
7774 xmlOut.dataSs_ <<
"<TableGroupMembers value=''>" << __E__;
7776 for(
auto& memberPair : groupInfo.second.latestKeyMemberMap_)
7778 xmlOut.dataSs_ <<
"\t<MemberName value='" << memberPair.first <<
"'/>"
7780 xmlOut.dataSs_ <<
"\t<MemberVersion value='" << memberPair.second <<
"'/>"
7787 xmlOut.dataSs_ <<
"</TableGroupMembers>" << __E__;
7792 for(
auto& keyInSet : groupInfo.second.keys_)
7794 if(keyInSet == groupKey)
7797 xmlOut.dataSs_ <<
"<TableGroupName value='" << groupName <<
"'/>" << __E__;
7798 xmlOut.dataSs_ <<
"<TableGroupKey value='" << keyInSet <<
"'/>" << __E__;
7803 bool loadingHistoricalInfo =
false;
7804 if(loadingHistoricalInfo)
7823 groupTypeString = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
7824 __SUP_COUT_WARN__ <<
"Failed to load group '" << groupName <<
"("
7826 <<
")' to extract group comment and type." << __E__;
7829 xmlOut.dataSs_ <<
"<TableGroupType value='" << groupTypeString <<
"'/>"
7831 xmlOut.dataSs_ <<
"<TableGroupComment value='"
7835 xmlOut.dataSs_ <<
"<TableGroupAuthor value='" << groupAuthor <<
"'/>"
7837 xmlOut.dataSs_ <<
"<TableGroupCreationTime value='" << groupCreationTime
7847 xmlOut.dataSs_ <<
"<TableGroupType value='"
7848 << groupInfo.second.latestKeyGroupTypeString_ <<
"'/>"
7850 xmlOut.dataSs_ <<
"<TableGroupComment value='"
7853 xmlOut.dataSs_ <<
"<TableGroupAuthor value='"
7856 xmlOut.dataSs_ <<
"<TableGroupCreationTime value='"
7873 xmlOut.dataSs_ <<
"<TableGroupMembers/>" << __E__;
7878 __SUP_COUTT__ << groupName <<
" runtime=" << cfgMgr->runTimeSeconds() << __E__;
7880 __SUP_COUTT__ <<
"cfgMgr runtime=" << cfgMgr->runTimeSeconds() << __E__;
7895 void ConfigurationGUISupervisor::handleTablesXML(
HttpXmlDocument& xmlOut,
7898 if(cfgMgr->getAllGroupInfo().size() == 0 || cfgMgr->
getActiveVersions().size() == 0)
7900 __SUP_COUT__ <<
"Table Info cache appears empty. Attempting to regenerate."
7910 xercesc::DOMElement* parentEl;
7911 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
7914 std::set<std::string, StringMacros::IgnoreCaseCompareStruct> orderedTableSet;
7915 for(
const auto& tablePair : allTableInfo)
7916 orderedTableSet.emplace(tablePair.first);
7920 __SUP_COUT__ <<
"# of tables found: " << allTableInfo.size() << __E__;
7922 std::map<std::string, std::map<std::string, TableVersion>> versionAliases =
7925 __SUP_COUT__ <<
"# of tables w/aliases: " << versionAliases.size() << __E__;
7927 for(
const auto& orderedTableName : orderedTableSet)
7930 std::map<std::string, TableInfo>::const_iterator it =
7931 allTableInfo.find(orderedTableName);
7932 if(it == allTableInfo.end())
7934 __SS__ <<
"Impossible missing table in map '" << orderedTableName <<
"'"
7943 xmlOut.addTextElementToData(
"TableName", it->first);
7944 parentEl = xmlOut.addTextElementToData(
"TableVersions",
"");
7947 if(versionAliases.find(it->first) != versionAliases.end())
7948 for(
auto& aliasVersion : versionAliases[it->first])
7949 if(it->second.versions_.find(aliasVersion.second) !=
7950 it->second.versions_.end())
7956 ConfigurationManager::ALIAS_VERSION_PREAMBLE + aliasVersion.first,
7974 for(
auto& version : it->second.versions_)
7990 void ConfigurationGUISupervisor::handleGetArtdaqNodeRecordsXML(
7993 const std::string& modifiedTables)
7995 __COUT__ <<
"Retrieving artdaq nodes..." << __E__;
7998 setupActiveTablesXML(
7999 xmlOut, cfgMgr,
"",
TableGroupKey(-1), modifiedTables,
false );
8001 std::map<std::string ,
8002 std::map<std::string , std::vector<std::string >>>
8003 nodeTypeToObjectMap;
8004 std::map<std::string , std::string >
8007 std::vector<std::string > artdaqSupervisorInfo;
8009 std::string artdaqSupervisorName;
8011 cfgMgr, nodeTypeToObjectMap, subsystemObjectMap, artdaqSupervisorInfo);
8013 if(artdaqSupervisorInfo.size() != 4 )
8015 __SUP_COUT__ <<
"No artdaq supervisor found." << __E__;
8019 __SUP_COUT__ <<
"========== "
8020 <<
"Found " << info.subsystems.size() <<
" subsystems." << __E__;
8022 unsigned int paramIndex = 0;
8024 auto parentEl = xmlOut.addTextElementToData(
"artdaqSupervisor",
8025 artdaqSupervisorInfo[paramIndex++]);
8027 std::string typeString =
"artdaqSupervisor";
8030 typeString +
"-status", artdaqSupervisorInfo[paramIndex++], parentEl);
8032 typeString +
"-contextAddress", artdaqSupervisorInfo[paramIndex++], parentEl);
8034 typeString +
"-contextPort", artdaqSupervisorInfo[paramIndex++], parentEl);
8036 for(
auto& subsystem : info.subsystems)
8038 typeString =
"subsystem";
8040 __SUP_COUT__ <<
"\t\t"
8041 <<
"Found " << typeString <<
" " << subsystem.first <<
" \t := '"
8042 << subsystem.second.label <<
"'" << __E__;
8046 typeString +
"-id", std::to_string(subsystem.first), parentEl);
8049 std::to_string(subsystem.second.sources.size()),
8054 std::to_string(subsystem.second.destination),
8059 __SUP_COUT__ <<
"========== "
8060 <<
"Found " << nodeTypeToObjectMap.size() <<
" process types." << __E__;
8062 for(
auto& nameTypePair : nodeTypeToObjectMap)
8064 typeString = nameTypePair.first;
8066 __SUP_COUT__ <<
"\t"
8067 <<
"Found " << nameTypePair.second.size() <<
" " << typeString
8070 for(
auto& artdaqNode : nameTypePair.second)
8072 __SUP_COUT__ <<
"\t\t"
8073 <<
"Found '" << artdaqNode.first <<
"' " << typeString << __E__;
8076 if(artdaqNode.second.size() < 2)
8078 __SUP_SS__ <<
"Impossible parameter size for node '" << artdaqNode.first
8079 <<
"' " << typeString <<
" - please notify admins!" << __E__;
8087 if(artdaqNode.second.size() > paramIndex)
8089 __SUP_COUTT__ <<
"\t\t\t"
8090 <<
"-multinode: " << artdaqNode.second[paramIndex] << __E__;
8092 typeString +
"-multinode", artdaqNode.second[paramIndex++], nodeEl);
8094 if(artdaqNode.second.size() > paramIndex)
8096 __SUP_COUTT__ <<
"\t\t\t"
8097 <<
"-nodefixedwidth: " << artdaqNode.second[paramIndex]
8100 artdaqNode.second[paramIndex++],
8103 if(artdaqNode.second.size() > paramIndex)
8105 __SUP_COUTT__ <<
"\t\t\t"
8106 <<
"-hostarray: " << artdaqNode.second[paramIndex] << __E__;
8108 typeString +
"-hostarray", artdaqNode.second[paramIndex++], nodeEl);
8110 if(artdaqNode.second.size() > paramIndex)
8112 __SUP_COUTT__ <<
"\t\t\t"
8113 <<
"-hostfixedwidth: " << artdaqNode.second[paramIndex]
8116 artdaqNode.second[paramIndex++],
8121 __SUP_COUTT__ <<
"\t\t\t"
8122 <<
"-status: " << artdaqNode.second[paramIndex] << __E__;
8124 typeString +
"-status", artdaqNode.second[paramIndex++], parentEl);
8125 __SUP_COUTT__ <<
"\t\t\t"
8126 <<
"-hostname: " << artdaqNode.second[paramIndex] << __E__;
8128 typeString +
"-hostname", artdaqNode.second[paramIndex++], parentEl);
8129 __SUP_COUTT__ <<
"\t\t\t"
8130 <<
"-subsystem: " << artdaqNode.second[paramIndex] << __E__;
8132 typeString +
"-subsystem", artdaqNode.second[paramIndex], parentEl);
8136 __SUP_COUT__ <<
"Done retrieving artdaq nodes." << __E__;
8147 void ConfigurationGUISupervisor::handleSaveArtdaqNodeRecordsXML(
8148 const std::string& nodeString,
8149 const std::string& subsystemString,
8152 const std::string& modifiedTables)
8154 __SUP_COUT__ <<
"Saving artdaq nodes..." << __E__;
8157 setupActiveTablesXML(
8158 xmlOut, cfgMgr,
"",
TableGroupKey(-1), modifiedTables,
false );
8161 std::map<std::string ,
8162 std::map<std::string , std::vector<std::string >>>
8163 nodeTypeToObjectMap;
8169 std::map<std::string , std::string >
8170 nodeTypeToStringMap;
8175 for(
auto& typePair : nodeTypeToStringMap)
8177 if(typePair.first ==
"")
8182 nodeTypeToObjectMap.emplace(
8184 std::map<std::string ,
8185 std::vector<std::string /*property*/>>()));
8187 std::map<std::string , std::string >
8188 nodeRecordToStringMap;
8191 typePair.second, nodeRecordToStringMap, {
';'}, {
'='});
8195 for(
auto& nodePair : nodeRecordToStringMap)
8197 if(nodePair.first ==
"")
8202 std::vector<std::string > nodePropertyVector;
8205 nodePair.second, nodePropertyVector, {
','});
8210 for(
unsigned int i = 0; i < nodePropertyVector.size(); ++i)
8215 nodePropertyVector[i] =
8219 nodeTypeToObjectMap[typePair.first].emplace(
8221 nodePropertyVector));
8227 std::map<std::string , std::string >
8234 std::map<std::string , std::string >
8235 tmpSubsystemObjectMap;
8237 subsystemString, tmpSubsystemObjectMap, {
';'}, {
':'});
8242 for(
auto& subsystemPair : tmpSubsystemObjectMap)
8247 subsystemObjectMap.emplace(
8254 cfgMgr, nodeTypeToObjectMap, subsystemObjectMap);
8256 __SUP_COUT__ <<
"Done saving artdaq nodes." << __E__;
8266 void ConfigurationGUISupervisor::handleLoadArtdaqNodeLayoutXML(
8270 const std::string& contextGroupName ,
8273 bool usingActiveGroups = (contextGroupName ==
"" || contextGroupKey.
isInvalid());
8276 const std::string& finalContextGroupName =
8278 ? cfgMgr->getActiveGroupName(ConfigurationManager::GroupType::CONTEXT_TYPE)
8282 ? cfgMgr->getActiveGroupKey(ConfigurationManager::GroupType::CONTEXT_TYPE)
8284 const std::string& finalConfigGroupName =
8285 cfgMgr->getActiveGroupName(ConfigurationManager::GroupType::CONFIGURATION_TYPE);
8287 cfgMgr->getActiveGroupKey(ConfigurationManager::GroupType::CONFIGURATION_TYPE);
8292 std::stringstream layoutPath;
8293 layoutPath << ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH << finalContextGroupName
8294 <<
"_" << finalContextGroupKey <<
"." << finalConfigGroupName <<
"_"
8295 << finalConfigGroupKey <<
".dat";
8297 fp = fopen(layoutPath.str().c_str(),
"r");
8300 __SUP_COUT__ <<
"Layout file not found for '" << finalContextGroupName <<
"("
8301 << finalContextGroupKey <<
") + " << finalConfigGroupName <<
"("
8302 << finalConfigGroupKey <<
")': " << layoutPath.
str() << __E__;
8306 __SUP_COUTV__(layoutPath.str());
8311 std::stringstream layoutPath;
8312 layoutPath << ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH << finalContextGroupName
8313 <<
"_" << finalContextGroupKey <<
".dat";
8314 __SUP_COUTV__(layoutPath.str());
8316 fp = fopen(layoutPath.str().c_str(),
"r");
8319 __SUP_COUT__ <<
"Layout file not found for '" << finalContextGroupName <<
"("
8320 << finalContextGroupKey <<
")': " << layoutPath.str() << __E__;
8324 __SUP_COUTV__(layoutPath.str());
8331 const size_t maxLineSz = 1000;
8332 char line[maxLineSz];
8333 if(!fgets(line, maxLineSz, fp))
8342 unsigned int rows, cols;
8344 sscanf(line,
"%u %u", &rows, &cols);
8346 __COUT__ <<
"Grid rows,cols = " << rows <<
"," << cols << __E__;
8348 xmlOut.addTextElementToData(
"grid-rows", std::to_string(rows));
8349 xmlOut.addTextElementToData(
"grid-cols", std::to_string(cols));
8352 char name[maxLineSz];
8353 char type[maxLineSz];
8355 while(fgets(line, maxLineSz, fp))
8358 sscanf(line,
"%s %s %u %u", type, name, &x, &y);
8360 xmlOut.addTextElementToData(
"node-type", type);
8361 xmlOut.addTextElementToData(
"node-name", name);
8362 xmlOut.addTextElementToData(
"node-x", std::to_string(x));
8363 xmlOut.addTextElementToData(
"node-y", std::to_string(y));
8377 void ConfigurationGUISupervisor::handleSaveArtdaqNodeLayoutXML(
8380 const std::string& layoutString,
8381 const std::string& contextGroupName,
8384 bool usingActiveGroups = (contextGroupName ==
"" || contextGroupKey.
isInvalid());
8386 const std::string& finalContextGroupName =
8388 ? cfgMgr->getActiveGroupName(ConfigurationManager::GroupType::CONTEXT_TYPE)
8392 ? cfgMgr->getActiveGroupKey(ConfigurationManager::GroupType::CONTEXT_TYPE)
8394 const std::string& finalConfigGroupName =
8395 cfgMgr->getActiveGroupName(ConfigurationManager::GroupType::CONFIGURATION_TYPE);
8397 cfgMgr->getActiveGroupKey(ConfigurationManager::GroupType::CONFIGURATION_TYPE);
8399 __SUP_COUTV__(layoutString);
8401 std::stringstream layoutPath;
8402 layoutPath << ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH << finalContextGroupName
8403 <<
"_" << finalContextGroupKey <<
"." << finalConfigGroupName <<
"_"
8404 << finalConfigGroupKey <<
".dat";
8405 __SUP_COUTV__(layoutPath.str());
8410 if(fields.size() < 2 || (fields.size() - 2) % 4 != 0)
8412 __SUP_SS__ <<
"Invalid layout string fields size of " << fields.size() << __E__;
8416 FILE* fp = fopen(layoutPath.str().c_str(),
"w");
8419 __SUP_SS__ <<
"Could not open layout file for writing for '"
8420 << finalContextGroupName <<
"(" << finalContextGroupKey <<
") + "
8421 << finalConfigGroupName <<
"(" << finalConfigGroupKey
8422 <<
")': " << layoutPath.
str() << __E__;
8429 fprintf(fp,
"%s %s\n", fields[0].c_str(), fields[1].c_str());
8432 for(
unsigned int i = 2; i < fields.size(); i += 4)
8435 fields[i + 0].c_str(),
8436 fields[i + 1].c_str(),
8437 fields[i + 2].c_str(),
8438 fields[i + 3].c_str());
8446 void ConfigurationGUISupervisor::handleOtherSubsystemActiveGroups(
8450 std::string targetSubsystem )
8456 cfgMgr->
getNode(ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE);
8459 for(
auto subsystem : children)
8461 __SUP_COUTV__(subsystem.first);
8465 std::string userPath =
8466 subsystem.second.getNode(
"SubsystemUserDataPath").getValue();
8467 __SUP_COUTV__(userPath);
8470 catch(
const std::runtime_error& e)
8472 __SUP_COUT__ <<
"Ignoring errors in handling other subsystem active groups "
8473 "(assuming the subsystem information map is not setup in "
8474 << ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE
8475 <<
") -- here is the error: \n"
8476 << e.what() << __E__;
8483 cfgMgr->
getNode(ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE);
8485 for(
auto subsystem : children)
8487 if(targetSubsystem !=
"" && targetSubsystem != subsystem.first)
8490 xercesc::DOMElement* parent =
8491 xmlOut.addTextElementToData(
"SubsystemName", subsystem.first);
8496 std::string filename, userDataPath;
8497 std::string username, hostname;
8499 std::map<std::string ,
8501 retMap = cfgMgr->getOtherSubsystemActiveTableGroups(
8502 subsystem.first, &userDataPath, &hostname, &username);
8504 for(
const auto& retPair : retMap)
8507 retPair.second.first,
8510 retPair.second.second.toString(),
8514 std::vector<std::string> filenameTypes = {
"Configured",
8518 "ActivatedBackbone",
8519 "ActivatedIterator"};
8521 std::vector<std::string> filenames = {
8522 FSM_LAST_CONFIGURED_GROUP_ALIAS_FILE,
8523 FSM_LAST_STARTED_GROUP_ALIAS_FILE,
8524 ConfigurationManager::LAST_ACTIVATED_CONFIG_GROUP_FILE,
8525 ConfigurationManager::LAST_ACTIVATED_CONTEXT_GROUP_FILE,
8526 ConfigurationManager::LAST_ACTIVATED_BACKBONE_GROUP_FILE,
8527 ConfigurationManager::LAST_ACTIVATED_ITERATOR_GROUP_FILE};
8529 std::string userPath =
8530 subsystem.second.getNode(
"SubsystemUserDataPath").getValue();
8532 std::string cmdResult;
8533 for(
unsigned int i = 0; i < filenames.size(); ++i)
8535 filename = userDataPath +
"/ServiceData/RunControlData/" + filenames[i];
8536 __SUP_COUTV__(filename);
8538 std::string tmpSubsystemFilename =
8539 ConfigurationManager::LAST_TABLE_GROUP_SAVE_PATH +
"/" + filenames[i] +
8540 "." + subsystem.first;
8541 __SUP_COUTV__(tmpSubsystemFilename);
8543 if(splitPath.size() == 2)
8547 (
"rm " + tmpSubsystemFilename +
" 2>/dev/null; scp " + username +
8548 "@" + hostname +
":" + filename +
" " + tmpSubsystemFilename +
8549 " 2>&1; cat " + tmpSubsystemFilename +
" 2>&1")
8553 (
"rm " + tmpSubsystemFilename +
" 2>/dev/null; scp " + hostname +
8554 ":" + filename +
" " + tmpSubsystemFilename +
" 2>&1; cat " +
8555 tmpSubsystemFilename +
" 2>&1")
8558 else if(splitPath.size() == 1)
8561 " 2>/dev/null; cp " + filename +
" " +
8562 tmpSubsystemFilename +
" 2>&1; cat " +
8563 tmpSubsystemFilename +
" 2>&1")
8567 __SUP_COUTV__(cmdResult);
8568 std::string timeString;
8571 filenames[i] +
"." + subsystem.first, timeString);
8575 "Last" + filenameTypes[i] +
"GroupName", theGroup.first, parent);
8577 theGroup.second.toString(),
8580 "Last" + filenameTypes[i] +
"GroupTime", timeString, parent);
8585 catch(
const std::runtime_error& e)
8588 <<
"An error occurred handling subsystem active groups (Please check the "
8589 "subsystem user data path information map setup in the Context group table "
8590 << ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE
8591 <<
") -- here is the error: \n"
8592 << e.what() << __E__;
8598 void ConfigurationGUISupervisor::handleGroupDiff(
8601 const std::string& groupName,
8604 const std::string& diffGroupNameInput )
8610 std::string diffGroupName;
8613 __SUP_COUT__ <<
"Differencing group " << groupName <<
"(" << groupKey
8614 <<
") with the active group." << __E__;
8617 if(diffGroupNameInput ==
"")
8618 diffGroupName = groupName;
8620 diffGroupName = diffGroupNameInput;
8622 __SUP_COUT__ <<
"Differencing group " << groupName <<
"(" << groupKey
8623 <<
") with group " << diffGroupName <<
"(" << diffKey <<
")"
8629 std::map<std::string ,
TableVersion > memberMap, diffMemberMap;
8630 std::string groupType, accumulateErrors;
8631 std::stringstream diffReport;
8632 bool noDifference =
true;
8651 std::map<std::string , std::pair<std::string, TableGroupKey>>
8658 __SUP_COUTV__(groupType);
8660 if(activeGroups.find(groupType) == activeGroups.end() ||
8661 activeGroups.at(groupType).first ==
"" ||
8662 activeGroups.at(groupType).second.isInvalid())
8664 __SUP_SS__ <<
"Could not find an active group of type '" << groupType
8665 <<
".' Please check the expected active configuration groups "
8666 "for errors (going to 'System View' of the Config App may "
8672 __SUP_COUT__ <<
"active " << groupType <<
" group is "
8673 << activeGroups.at(groupType).first <<
"("
8674 << activeGroups.at(groupType).second <<
")" << __E__;
8676 diffReport <<
"This difference report is between " << groupType
8677 <<
" group <b>'" << groupName <<
"(" << groupKey <<
")'</b>"
8678 <<
" and active group <b>'" << activeGroups.at(groupType).first
8679 <<
"(" << activeGroups.at(groupType).second <<
")'</b>." << __E__;
8682 activeGroups.at(groupType).second,
8692 diffReport <<
"\n\n"
8693 <<
"'" << groupName <<
"(" << groupKey <<
")' has <b>"
8694 << memberMap.size() <<
" member tables</b>, and "
8695 <<
"'" << activeGroups.at(groupType).first <<
"("
8696 << activeGroups.at(groupType).second <<
")' has <b>"
8697 << diffMemberMap.size() <<
" member tables</b>." << __E__;
8701 diffReport <<
"This difference report is between group <b>'" << groupName
8702 <<
"(" << groupKey <<
")'</b>"
8703 <<
" and group <b>'" << diffGroupName <<
"(" << diffKey
8704 <<
")'</b>." << __E__;
8717 diffReport <<
"\n\n"
8718 <<
"'" << groupName <<
"(" << groupKey <<
")' has <b>"
8719 << memberMap.size() <<
" member tables</b>, and "
8720 <<
"'" << diffGroupName <<
"(" << diffKey <<
")' has <b>"
8721 << diffMemberMap.size() <<
" member tables</b>." << __E__;
8726 diffReport <<
"<INDENT><ol>";
8728 unsigned int tableDifferences = 0;
8730 for(
auto& member : memberMap)
8732 if(diffMemberMap.find(member.first) == diffMemberMap.end())
8734 diffReport <<
"\n\n<li>"
8735 <<
"Table <b>" << member.first <<
"-v" << member.second
8736 <<
"</b> not found in active group."
8737 <<
"</li>" << __E__;
8738 noDifference =
false;
8743 __SUP_COUTT__ <<
"Comparing " << member.first <<
"-v" << member.second
8744 <<
" ... " << member.first <<
"-v"
8745 << diffMemberMap.at(member.first) << __E__;
8747 if(member.second == diffMemberMap.at(member.first))
8750 diffReport <<
"\n\n<li>"
8751 <<
"Table <b>" << member.first <<
" v" << member.second
8752 <<
"</b> in " << groupName <<
"(" << groupKey <<
")' ...vs... "
8753 <<
" <b>v" << diffMemberMap.at(member.first) <<
"</b> in "
8754 << diffGroupName <<
"(" << diffKey <<
")':" << __E__;
8758 diffReport <<
"<ul>";
8759 std::map<std::string , std::vector<std::string >>
8762 diffMemberMap.at(member.first),
8767 noDifference =
false;
8770 xmlOut.addTextElementToData(
"TableWithDiff", member.first);
8771 for(
auto& modifiedRecord : modifiedRecords)
8774 "RecordWithDiff", modifiedRecord.first, parentEl);
8775 for(
auto& modifiedColumn : modifiedRecord.second)
8777 "ColNameWithDiff", modifiedColumn, recordParentEl);
8780 diffReport <<
"</ul></li>";
8784 for(
auto& diffMember : diffMemberMap)
8786 if(memberMap.find(diffMember.first) == memberMap.end())
8789 diffReport <<
"\n\n<li>"
8790 <<
"Active Group Table <b>" << diffMember.first <<
"-v"
8791 << diffMember.second <<
"</b> not found in '" << groupName
8792 <<
"(" << groupKey <<
")'."
8793 <<
"</li>" << __E__;
8795 diffReport <<
"\n\n<li>" << diffGroupName <<
"(" << diffKey
8796 <<
") Table <b>" << diffMember.first <<
"-v"
8797 << diffMember.second <<
"</b> not found in '" << groupName
8798 <<
"(" << groupKey <<
")'."
8799 <<
"</li>" << __E__;
8801 noDifference =
false;
8806 diffReport <<
"\n</ol></INDENT>";
8811 diffReport <<
"\n\nNo difference found between "
8812 <<
"<b>'" << groupName <<
"(" << groupKey
8813 <<
")'</b> and active group "
8814 <<
"<b>'" << activeGroups.at(groupType).first <<
"("
8815 << activeGroups.at(groupType).second <<
")'</b>." << __E__;
8817 diffReport <<
"\n\n<b>" << tableDifferences
8818 <<
"</b> member table differences identified between "
8819 <<
"<b>'" << groupName <<
"(" << groupKey
8820 <<
")'</b> and active group "
8821 <<
"<b>'" << activeGroups.at(groupType).first <<
"("
8822 << activeGroups.at(groupType).second <<
")'</b>." << __E__;
8827 diffReport <<
"\n\nNo difference found between "
8828 <<
"<b>'" << groupName <<
"(" << groupKey
8829 <<
")'</b> and group "
8830 <<
"<b>'" << diffGroupName <<
"(" << diffKey <<
")'</b>."
8833 diffReport <<
"\n\n<b>" << tableDifferences
8834 <<
"</b> member table differences identified between "
8835 <<
"<b>'" << groupName <<
"(" << groupKey
8836 <<
")'</b> and group "
8837 <<
"<b>'" << diffGroupName <<
"(" << diffKey <<
")'</b>."
8841 xmlOut.addTextElementToData(
"NoDifference", noDifference ?
"1" :
"0");
8842 xmlOut.addTextElementToData(
"DiffReport", diffReport.str());
8844 catch(
const std::runtime_error& e)
8846 __SUP_COUT_ERR__ <<
"Caught error while differencing group " << groupName <<
"("
8847 << groupKey <<
") with group " << diffGroupName <<
"(" << diffKey
8848 <<
")" << __E__ << e.what() << __E__;
8855 void ConfigurationGUISupervisor::handleTableDiff(
HttpXmlDocument& xmlOut,
8857 const std::string& tableName,
8861 __SUP_COUT__ <<
"Differencing tableName " << tableName <<
" v" << vA <<
" with v"
8871 std::string localAccumulatedErrors =
"";
8875 &localAccumulatedErrors,
8878 if(localAccumulatedErrors !=
"")
8879 xmlOut.addTextElementToData(
"Error", localAccumulatedErrors);
8881 catch(std::runtime_error& e)
8883 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version " << vA;
8884 ss <<
"\n\n...Here is why it failed:\n\n" << e.what() << __E__;
8885 __SUP_COUT_ERR__ <<
"\n" << ss.str();
8887 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
8891 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version: " << vA << __E__;
8896 catch(
const std::exception& e)
8898 ss <<
"Exception message: " << e.what();
8904 __SUP_COUT_ERR__ <<
"\n" << ss.str();
8905 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
8911 std::string localAccumulatedErrors =
"";
8915 &localAccumulatedErrors,
8918 if(localAccumulatedErrors !=
"")
8919 xmlOut.addTextElementToData(
"Error", localAccumulatedErrors);
8921 catch(std::runtime_error& e)
8923 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version " << vB;
8924 ss <<
"\n\n...Here is why it failed:\n\n" << e.what() << __E__;
8925 __SUP_COUT_ERR__ <<
"\n" << ss.str();
8927 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
8931 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version: " << vB << __E__;
8936 catch(
const std::exception& e)
8938 ss <<
"Exception message: " << e.what();
8944 __SUP_COUT_ERR__ <<
"\n" << ss.str();
8945 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
8948 bool noDifference =
true;
8949 std::stringstream diffReport;
8951 diffReport <<
"This difference report is between table " << tableName <<
" v" << vA
8952 <<
" and v" << vB <<
"</b>." << __E__;
8954 diffReport <<
"<INDENT>";
8955 diffReport <<
"<ul>";
8956 std::map<std::string , std::vector<std::string >>
8959 noDifference =
false;
8960 diffReport <<
"</ul></INDENT>";
8962 xmlOut.addTextElementToData(
"NoDifference", noDifference ?
"1" :
"0");
8963 xmlOut.addTextElementToData(
"DiffReport", diffReport.str());
8969 void ConfigurationGUISupervisor::testXDAQContext()
8973 __SUP_COUT__ <<
"Attempting test activation of the context group." << __E__;
8976 catch(
const std::runtime_error& e)
8979 <<
"The test activation of the context group failed. Ignoring error: \n"
8980 << e.what() << __E__;
8984 __SUP_COUT_WARN__ <<
"The test activation of the context group failed. Ignoring."
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 clearAllCachedVersions(void)
const std::map< std::string, TableInfo > & getAllTableInfo(bool refresh=false, std::string *accumulatedWarnings=0, const std::string &errorFilterName="", bool getGroupKeys=false, bool getGroupInfo=false, bool initializeActiveGroups=false)
TableVersion copyViewToCurrentColumns(const std::string &tableName, TableVersion sourceVersion)
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)
const GroupInfo & getGroupInfo(const std::string &groupName)
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())
TableBase * getVersionedTableByName(const std::string &tableName, TableVersion version, bool looseColumnMatching=false, std::string *accumulatedErrors=0, bool getRawData=false)
static void loadTableGroupThread(ConfigurationManagerRW *cfgMgr, std::string groupName, ots::TableGroupKey groupKey, std::shared_ptr< ots::GroupInfo > theGroupInfo, std::shared_ptr< std::atomic< bool >> theThreadDone)
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 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)
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
static const std::set< std::string > contextMemberNames_
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
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
const std::string & getTableName(void) const
TableVersion createTemporaryView(TableVersion sourceViewVersion=TableVersion(), TableVersion destTemporaryViewVersion=TableVersion::getNextTemporaryVersion())
bool diffTwoVersions(TableVersion v1, TableVersion v2, std::stringstream *diffReport=0, std::map< std::string, std::vector< std::string >> *v1ModifiedRecords=0) const
TableVersion mergeViews(const TableView &sourceViewA, const TableView &sourceViewB, TableVersion destinationVersion, const std::string &author, const std::string &mergeApproach, std::map< std::pair< std::string, std::string >, std::string > &uidConversionMap, std::map< std::pair< std::string, std::pair< std::string, std::string > >, std::string > &groupidConversionMap, bool fillRecordConversionMaps, bool applyRecordConversionMaps, bool generateUniqueDataColumns=false, std::stringstream *mergeRepoert=nullptr)
static std::string convertToCaps(std::string &str, bool isConfigName=false)
TableView * getTemporaryView(TableVersion temporaryVersion)
const TableVersion & getViewVersion(void) const
void print(std::ostream &out=std::cout) const
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="")
bool isMockupVersion(void) const
std::string toString(void) const
bool isInvalid(void) const
bool isScratchVersion(void) const
bool isTemporaryVersion(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 & 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)
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)