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.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")
29 #define ARTDAQ_CONFIG_LAYOUTS_PATH \
30 std::string(__ENV__("SERVICE_DATA_PATH")) + "/ConfigurationGUI_artdaqLayouts/"
43 ConfigurationGUISupervisor::ConfigurationGUISupervisor(xdaq::ApplicationStub* stub)
44 : CoreSupervisorBase(stub)
46 __SUP_COUT__ <<
"Constructor started." << __E__;
48 INIT_MF(
"ConfigurationGUI");
51 mkdir(((std::string)ARTDAQ_CONFIG_LAYOUTS_PATH).c_str(), 0755);
54 __SUP_COUT__ <<
"Constructor complete." << __E__;
58 ConfigurationGUISupervisor::~ConfigurationGUISupervisor(
void) { destroy(); }
61 void ConfigurationGUISupervisor::init(
void)
63 __SUP_COUT__ <<
"Initializing..." << __E__;
65 __SUP_COUT__ <<
"Activating saved context, which may prepare for normal mode..."
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."
81 void ConfigurationGUISupervisor::destroy(
void)
84 for(std::map<std::string, ConfigurationManagerRW*>::iterator it =
85 userConfigurationManagers_.begin();
86 it != userConfigurationManagers_.end();
92 userConfigurationManagers_.clear();
96 if(ConfigurationInterface::getInstance(
true) != 0)
97 delete ConfigurationInterface::getInstance(
true);
101 void ConfigurationGUISupervisor::defaultPage(xgi::Input* in, xgi::Output* out)
103 cgicc::Cgicc cgiIn(in);
104 std::string configWindowName =
105 CgiDataUtilities::getData(cgiIn,
"configWindowName");
106 if(configWindowName ==
"tableEditor")
107 *out <<
"<!DOCTYPE HTML><html lang='en'><frameset col='100%' row='100%'><frame "
108 "src='/WebPath/html/ConfigurationTableEditor.html?urn="
109 << this->getApplicationDescriptor()->getLocalId() <<
"'></frameset></html>";
110 if(configWindowName ==
"iterate")
111 *out <<
"<!DOCTYPE HTML><html lang='en'><frameset col='100%' row='100%'><frame "
112 "src='/WebPath/html/Iterate.html?urn="
113 << this->getApplicationDescriptor()->getLocalId() <<
"'></frameset></html>";
115 *out <<
"<!DOCTYPE HTML><html lang='en'><frameset col='100%' row='100%'><frame "
116 "src='/WebPath/html/ConfigurationGUI.html?urn="
117 << this->getApplicationDescriptor()->getLocalId() <<
"'></frameset></html>";
123 void ConfigurationGUISupervisor::setSupervisorPropertyDefaults(
void)
125 CorePropertySupervisorBase::setSupervisorProperty(
126 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.UserPermissionsThreshold,
127 "*=10 | deleteTreeNodeRecords=255 | saveTableInfo=255 | "
128 "deleteTableInfo=255");
129 CorePropertySupervisorBase::setSupervisorProperty(
130 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.RequireUserLockRequestTypes,
137 void ConfigurationGUISupervisor::forceSupervisorPropertyValues()
139 CorePropertySupervisorBase::setSupervisorProperty(
140 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.AutomatedRequestTypes,
142 CorePropertySupervisorBase::setSupervisorProperty(
143 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.CheckUserLockRequestTypes,
148 void ConfigurationGUISupervisor::request(
const std::string& requestType,
150 HttpXmlDocument& xmlOut,
151 const WebUsers::RequestUserInfo& userInfo)
try
210 std::string refresh = CgiDataUtilities::getData(cgiIn,
"refresh");
214 ConfigurationManagerRW* cfgMgr = refreshUserSession(
215 userInfo.username_, userInfo.activeUserSessionIndex_, (refresh ==
"1"));
217 if(requestType ==
"saveTableInfo")
219 std::string tableName =
220 CgiDataUtilities::getData(cgiIn,
"tableName");
221 std::string columnCSV =
222 CgiDataUtilities::postData(cgiIn,
"columnCSV");
223 std::string allowOverwrite =
224 CgiDataUtilities::getData(cgiIn,
"allowOverwrite");
225 std::string tableDescription =
226 CgiDataUtilities::postData(cgiIn,
"tableDescription");
227 std::string columnChoicesCSV =
228 CgiDataUtilities::postData(cgiIn,
"columnChoicesCSV");
233 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
234 __SUP_COUT__ <<
"columnCSV: " << columnCSV << __E__;
235 __SUP_COUT__ <<
"tableDescription: " << tableDescription << __E__;
236 __SUP_COUT__ <<
"columnChoicesCSV: " << columnChoicesCSV << __E__;
237 __SUP_COUT__ <<
"allowOverwrite: " << allowOverwrite << __E__;
239 if(!allSupervisorInfo_.isWizardMode())
241 __SUP_SS__ <<
"Improper permissions for saving table info." << __E__;
242 xmlOut.addTextElementToData(
"Error", ss.str());
245 handleSaveTableInfoXML(xmlOut,
251 allowOverwrite ==
"1");
253 else if(requestType ==
"deleteTableInfo")
255 std::string tableName =
256 CgiDataUtilities::getData(cgiIn,
"tableName");
257 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
258 handleDeleteTableInfoXML(xmlOut, cfgMgr, tableName);
260 else if(requestType ==
"gatewayLaunchOTS" || requestType ==
"gatewayLaunchWiz" ||
261 requestType ==
"flattenToSystemAliases")
264 __SUP_COUT_WARN__ << requestType <<
" command received! " << __E__;
265 __MOUT_WARN__ << requestType <<
" command received! " << __E__;
268 __SUP_COUT_INFO__ <<
"Launching " << requestType <<
"... " << __E__;
270 __SUP_COUT__ <<
"Extracting target context hostnames... " << __E__;
271 std::vector<std::string> hostnames;
274 if(requestType ==
"flattenToSystemAliases" &&
275 CorePropertySupervisorBase::allSupervisorInfo_.isWizardMode())
277 hostnames.push_back(__ENV__(
"OTS_CONFIGURATION_WIZARD_SUPERVISOR_SERVER"));
278 __SUP_COUT__ <<
"hostname = " << hostnames.back() << __E__;
286 const XDAQContextTable* contextTable =
287 cfgMgr->__GET_CONFIG__(XDAQContextTable);
289 auto contexts = contextTable->getContexts();
291 for(
const auto& context : contexts)
298 for(i = 0; i < context.address_.size(); ++i)
299 if(context.address_[i] ==
'/')
301 hostnames.push_back(context.address_.substr(j));
302 __SUP_COUT__ <<
"hostname = " << hostnames.back() << __E__;
307 __SUP_SS__ <<
"The Configuration Manager could not be initialized to "
311 __SUP_COUT_ERR__ <<
"\n" << ss.str();
316 if(hostnames.size() == 0)
318 __SUP_SS__ <<
"No hostnames found to launch command '" + requestType +
319 "'... Is there a valid Context group activated?"
321 __SUP_COUT_ERR__ <<
"\n" << ss.str();
323 xmlOut.addTextElementToData(
"Error", ss.str());
326 for(
const auto& hostname : hostnames)
328 std::string fn = (std::string(__ENV__(
"SERVICE_DATA_PATH")) +
329 "/StartOTS_action_" + hostname +
".cmd");
330 FILE* fp = fopen(fn.c_str(),
"w");
333 if(requestType ==
"gatewayLaunchOTS")
334 fprintf(fp,
"LAUNCH_OTS");
335 else if(requestType ==
"gatewayLaunchWiz")
336 fprintf(fp,
"LAUNCH_WIZ");
337 else if(requestType ==
"flattenToSystemAliases")
339 fprintf(fp,
"FLATTEN_TO_SYSTEM_ALIASES");
347 __SUP_COUT_ERR__ <<
"Unable to open command file: " << fn << __E__;
400 else if(requestType ==
"versionTracking")
402 std::string type = CgiDataUtilities::getData(cgiIn,
"Type");
403 __SUP_COUT__ <<
"type: " << type << __E__;
406 xmlOut.addTextElementToData(
407 "versionTrackingStatus",
408 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
409 else if(type ==
"ON")
411 ConfigurationInterface::setVersionTrackingEnabled(
true);
412 xmlOut.addTextElementToData(
413 "versionTrackingStatus",
414 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
416 else if(type ==
"OFF")
418 ConfigurationInterface::setVersionTrackingEnabled(
false);
419 xmlOut.addTextElementToData(
420 "versionTrackingStatus",
421 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
424 else if(requestType ==
"getColumnTypes")
427 std::vector<std::string> allTypes = TableViewColumnInfo::getAllTypesForGUI();
428 std::vector<std::string> allDataTypes =
429 TableViewColumnInfo::getAllDataTypesForGUI();
430 std::map<std::pair<std::string, std::string>, std::string> allDefaults =
431 TableViewColumnInfo::getAllDefaultsForGUI();
433 for(
const auto& type : allTypes)
434 xmlOut.addTextElementToData(
"columnTypeForGUI", type);
435 for(
const auto& dataType : allDataTypes)
436 xmlOut.addTextElementToData(
"columnDataTypeForGUI", dataType);
438 for(
const auto& colDefault : allDefaults)
440 xmlOut.addTextElementToData(
"columnDefaultDataType", colDefault.first.first);
441 xmlOut.addTextElementToData(
"columnDefaultTypeFilter",
442 colDefault.first.second);
443 xmlOut.addTextElementToData(
"columnDefaultValue", colDefault.second);
446 else if(requestType ==
"getGroupAliases")
451 1 == CgiDataUtilities::getDataAsInt(cgiIn,
"reloadActiveGroups");
453 __SUP_COUT__ <<
"reloadActive: " << reloadActive << __E__;
454 bool wasError =
false;
459 cfgMgr->clearAllCachedVersions();
460 cfgMgr->restoreActiveTableGroups(
true);
462 catch(std::runtime_error& e)
464 __SUP_SS__ << (
"Error loading active groups!\n\n" + std::string(e.what()))
466 __SUP_COUT_ERR__ <<
"\n" << ss.str();
467 xmlOut.addTextElementToData(
"Error", ss.str());
472 __SUP_SS__ << (
"Error loading active groups!\n\n") << __E__;
473 __SUP_COUT_ERR__ <<
"\n" << ss.str();
474 xmlOut.addTextElementToData(
"Error", ss.str());
479 handleGroupAliasesXML(xmlOut, cfgMgr);
481 else if(requestType ==
"setGroupAliasInActiveBackbone")
483 std::string groupAlias =
484 CgiDataUtilities::getData(cgiIn,
"groupAlias");
485 std::string groupName = CgiDataUtilities::getData(cgiIn,
"groupName");
487 std::string groupKey = CgiDataUtilities::getData(cgiIn,
"groupKey");
489 __SUP_COUT__ <<
"groupAlias: " << groupAlias << __E__;
490 __SUP_COUT__ <<
"groupName: " << groupName << __E__;
491 __SUP_COUT__ <<
"groupKey: " << groupKey << __E__;
493 handleSetGroupAliasInBackboneXML(xmlOut,
497 TableGroupKey(groupKey),
500 else if(requestType ==
"setVersionAliasInActiveBackbone")
502 std::string versionAlias =
503 CgiDataUtilities::getData(cgiIn,
"versionAlias");
504 std::string tableName =
505 CgiDataUtilities::getData(cgiIn,
"tableName");
506 std::string version = CgiDataUtilities::getData(cgiIn,
"version");
508 __SUP_COUT__ <<
"versionAlias: " << versionAlias << __E__;
509 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
510 __SUP_COUT__ <<
"version: " << version << __E__;
512 handleSetVersionAliasInBackboneXML(xmlOut,
516 TableVersion(version),
519 else if(requestType ==
"setAliasOfGroupMembers")
521 std::string versionAlias =
522 CgiDataUtilities::getData(cgiIn,
"versionAlias");
523 std::string groupName = CgiDataUtilities::getData(cgiIn,
"groupName");
525 std::string groupKey = CgiDataUtilities::getData(cgiIn,
"groupKey");
527 __SUP_COUT__ <<
"versionAlias: " << versionAlias << __E__;
528 __SUP_COUT__ <<
"groupName: " << groupName << __E__;
529 __SUP_COUT__ <<
"groupKey: " << groupKey << __E__;
531 handleAliasGroupMembersInBackboneXML(xmlOut,
535 TableGroupKey(groupKey),
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 =
555 CgiDataUtilities::postData(cgiIn,
"tableList");
556 __SUP_COUT__ <<
"tableList: " << tableList << __E__;
558 handleGetTableGroupTypeXML(xmlOut, cfgMgr, tableList);
560 else if(requestType ==
"getTables")
562 std::string allowIllegalColumns =
563 CgiDataUtilities::getData(cgiIn,
"allowIllegalColumns");
565 __SUP_COUT__ <<
"allowIllegalColumns: " << allowIllegalColumns << __E__;
567 handleTablesXML(xmlOut, cfgMgr, allowIllegalColumns ==
"1");
569 else if(requestType ==
"getContextMemberNames")
571 std::set<std::string> members = cfgMgr->getContextMemberNames();
573 for(
auto& member : members)
574 xmlOut.addTextElementToData(
"ContextMember", member);
576 else if(requestType ==
"getBackboneMemberNames")
578 std::set<std::string> members = cfgMgr->getBackboneMemberNames();
580 for(
auto& member : members)
581 xmlOut.addTextElementToData(
"BackboneMember", member);
583 else if(requestType ==
"getIterateMemberNames")
585 std::set<std::string> members = cfgMgr->getIterateMemberNames();
587 for(
auto& member : members)
588 xmlOut.addTextElementToData(
"IterateMember", member);
590 else if(requestType ==
"getSpecificTableGroup")
592 std::string groupName = CgiDataUtilities::getData(cgiIn,
"groupName");
594 std::string groupKey = CgiDataUtilities::getData(cgiIn,
"groupKey");
596 __SUP_COUT__ <<
"groupName: " << groupName << __E__;
597 __SUP_COUT__ <<
"groupKey: " << groupKey << __E__;
599 ConfigurationSupervisorBase::handleGetTableGroupXML(
600 xmlOut, cfgMgr, groupName, TableGroupKey(groupKey));
602 else if(requestType ==
"saveNewTableGroup")
604 std::string groupName = CgiDataUtilities::getData(cgiIn,
"groupName");
606 bool ignoreWarnings =
607 CgiDataUtilities::getDataAsInt(cgiIn,
"ignoreWarnings");
608 bool allowDuplicates =
609 CgiDataUtilities::getDataAsInt(cgiIn,
"allowDuplicates");
610 bool lookForEquivalent =
611 CgiDataUtilities::getDataAsInt(cgiIn,
"lookForEquivalent");
612 std::string tableList =
613 CgiDataUtilities::postData(cgiIn,
"tableList");
614 std::string comment =
615 CgiDataUtilities::getData(cgiIn,
"groupComment");
617 __SUP_COUT__ <<
"saveNewTableGroup: " << groupName << __E__;
618 __SUP_COUT__ <<
"tableList: " << tableList << __E__;
619 __SUP_COUT__ <<
"ignoreWarnings: " << ignoreWarnings << __E__;
620 __SUP_COUT__ <<
"allowDuplicates: " << allowDuplicates << __E__;
621 __SUP_COUT__ <<
"lookForEquivalent: " << lookForEquivalent << __E__;
622 __SUP_COUT__ <<
"comment: " << comment << __E__;
624 ConfigurationSupervisorBase::handleCreateTableGroupXML(xmlOut,
633 else if(requestType ==
"getSpecificTable")
635 std::string tableName =
636 CgiDataUtilities::getData(cgiIn,
"tableName");
637 std::string versionStr = CgiDataUtilities::getData(cgiIn,
"version");
638 int dataOffset = CgiDataUtilities::getDataAsInt(cgiIn,
"dataOffset");
639 int chunkSize = CgiDataUtilities::getDataAsInt(cgiIn,
"chunkSize");
641 std::string allowIllegalColumns =
642 CgiDataUtilities::getData(cgiIn,
"allowIllegalColumns");
643 __SUP_COUT__ <<
"allowIllegalColumns: " << (allowIllegalColumns ==
"1") << __E__;
645 __SUP_COUT__ <<
"getSpecificTable: " << tableName <<
" versionStr: " << versionStr
646 <<
" chunkSize: " << chunkSize <<
" dataOffset: " << dataOffset
649 TableVersion version;
650 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->getAllTableInfo();
651 std::string versionAlias;
653 if(allTableInfo.find(tableName) != allTableInfo.end())
655 if(versionStr ==
"" &&
656 allTableInfo.at(tableName).versions_.size())
657 version = *(allTableInfo.at(tableName).versions_.rbegin());
658 else if(versionStr.find(ConfigurationManager::ALIAS_VERSION_PREAMBLE) == 0)
661 std::map<std::string ,
662 std::map<std::string , TableVersion>>
663 versionAliases = cfgMgr->getVersionAliases();
665 versionAlias = versionStr.substr(
666 ConfigurationManager::ALIAS_VERSION_PREAMBLE.size());
677 if(versionAliases.find(tableName) != versionAliases.end() &&
678 versionAliases[tableName].find(versionStr.substr(
679 ConfigurationManager::ALIAS_VERSION_PREAMBLE.size())) !=
680 versionAliases[tableName].end())
682 version = versionAliases[tableName][versionStr.substr(
683 ConfigurationManager::ALIAS_VERSION_PREAMBLE.size())];
684 __SUP_COUT__ <<
"version alias translated to: " << version << __E__;
689 << versionStr.substr(
690 ConfigurationManager::ALIAS_VERSION_PREAMBLE.size())
691 <<
"'was not found in active version aliases!" << __E__;
694 version = atoi(versionStr.c_str());
697 __SUP_COUT__ <<
"version: " << version << __E__;
699 handleGetTableXML(xmlOut,
702 TableVersion(version),
703 (allowIllegalColumns ==
"1"));
705 xmlOut.addTextElementToData(
"DefaultRowValue", userInfo.username_);
707 else if(requestType ==
"saveSpecificTable")
709 std::string tableName =
710 CgiDataUtilities::getData(cgiIn,
"tableName");
711 int version = CgiDataUtilities::getDataAsInt(cgiIn,
"version");
712 int dataOffset = CgiDataUtilities::getDataAsInt(cgiIn,
"dataOffset");
713 bool sourceTableAsIs =
714 CgiDataUtilities::getDataAsInt(cgiIn,
"sourceTableAsIs");
715 bool lookForEquivalent =
716 CgiDataUtilities::getDataAsInt(cgiIn,
"lookForEquivalent");
717 int temporary = CgiDataUtilities::getDataAsInt(cgiIn,
"temporary");
718 std::string comment =
719 CgiDataUtilities::getData(cgiIn,
"tableComment");
721 std::string data = CgiDataUtilities::postData(cgiIn,
"data");
725 __SUP_COUT__ <<
"tableName: " << tableName <<
" version: " << version
726 <<
" temporary: " << temporary <<
" dataOffset: " << dataOffset
728 __SUP_COUT__ <<
"comment: " << comment << __E__;
729 __SUP_COUT__ <<
"data: " << data << __E__;
730 __SUP_COUT__ <<
"sourceTableAsIs: " << sourceTableAsIs << __E__;
731 __SUP_COUT__ <<
"lookForEquivalent: " << lookForEquivalent << __E__;
733 ConfigurationSupervisorBase::handleCreateTableXML(xmlOut,
736 TableVersion(version),
745 else if(requestType ==
"clearTableTemporaryVersions")
747 std::string tableName =
748 CgiDataUtilities::getData(cgiIn,
"tableName");
749 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
753 cfgMgr->eraseTemporaryVersion(tableName);
755 catch(std::runtime_error& e)
757 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
758 xmlOut.addTextElementToData(
759 "Error",
"Error clearing temporary views!\n " + std::string(e.what()));
763 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
764 xmlOut.addTextElementToData(
"Error",
"Error clearing temporary views! ");
767 else if(requestType ==
"clearTableCachedVersions")
769 std::string tableName =
770 CgiDataUtilities::getData(cgiIn,
"tableName");
771 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
776 cfgMgr->clearAllCachedVersions();
778 cfgMgr->clearCachedVersions(tableName);
780 cfgMgr->getAllTableInfo(
true );
782 catch(std::runtime_error& e)
784 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
785 xmlOut.addTextElementToData(
786 "Error",
"Error clearing cached views!\n " + std::string(e.what()));
790 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
791 xmlOut.addTextElementToData(
"Error",
"Error clearing cached views! ");
794 else if(requestType ==
"getTreeView")
796 std::string tableGroup = CgiDataUtilities::getData(cgiIn,
"tableGroup");
797 std::string tableGroupKey = CgiDataUtilities::getData(cgiIn,
"tableGroupKey");
798 std::string startPath = CgiDataUtilities::postData(cgiIn,
"startPath");
799 std::string modifiedTables = CgiDataUtilities::postData(cgiIn,
"modifiedTables");
800 std::string filterList = CgiDataUtilities::postData(cgiIn,
"filterList");
801 int depth = CgiDataUtilities::getDataAsInt(cgiIn,
"depth");
802 bool hideStatusFalse = CgiDataUtilities::getDataAsInt(cgiIn,
"hideStatusFalse");
804 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
805 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
806 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
807 __SUP_COUT__ <<
"depth: " << depth << __E__;
808 __SUP_COUT__ <<
"hideStatusFalse: " << hideStatusFalse << __E__;
809 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
810 __SUP_COUT__ <<
"filterList: " << filterList << __E__;
812 handleFillTreeViewXML(xmlOut,
815 TableGroupKey(tableGroupKey),
822 else if(requestType ==
"getTreeNodeCommonFields")
824 std::string tableGroup = CgiDataUtilities::getData(cgiIn,
"tableGroup");
825 std::string tableGroupKey = CgiDataUtilities::getData(cgiIn,
"tableGroupKey");
826 std::string startPath = CgiDataUtilities::postData(cgiIn,
"startPath");
827 std::string modifiedTables = CgiDataUtilities::postData(cgiIn,
"modifiedTables");
828 std::string fieldList = CgiDataUtilities::postData(cgiIn,
"fieldList");
829 std::string recordList = CgiDataUtilities::postData(cgiIn,
"recordList");
830 int depth = CgiDataUtilities::getDataAsInt(cgiIn,
"depth");
832 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
833 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
834 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
835 __SUP_COUT__ <<
"depth: " << depth << __E__;
838 __SUP_COUT__ <<
"fieldList: " << fieldList << __E__;
839 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
840 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
842 handleFillTreeNodeCommonFieldsXML(xmlOut,
845 TableGroupKey(tableGroupKey),
852 else if(requestType ==
"getUniqueFieldValuesForRecords")
854 std::string tableGroup = CgiDataUtilities::getData(cgiIn,
"tableGroup");
855 std::string tableGroupKey = CgiDataUtilities::getData(cgiIn,
"tableGroupKey");
856 std::string startPath = CgiDataUtilities::postData(cgiIn,
"startPath");
857 std::string modifiedTables = CgiDataUtilities::postData(cgiIn,
"modifiedTables");
858 std::string fieldList = CgiDataUtilities::postData(cgiIn,
"fieldList");
859 std::string recordList = CgiDataUtilities::postData(cgiIn,
"recordList");
861 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
862 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
863 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
864 __SUP_COUT__ <<
"fieldList: " << fieldList << __E__;
865 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
866 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
868 handleFillUniqueFieldValuesForRecordsXML(xmlOut,
871 TableGroupKey(tableGroupKey),
877 else if(requestType ==
"getTreeNodeFieldValues")
879 std::string tableGroup = CgiDataUtilities::getData(cgiIn,
"tableGroup");
880 std::string tableGroupKey = CgiDataUtilities::getData(cgiIn,
"tableGroupKey");
881 std::string startPath = CgiDataUtilities::postData(cgiIn,
"startPath");
882 std::string modifiedTables = CgiDataUtilities::postData(cgiIn,
"modifiedTables");
883 std::string fieldList = CgiDataUtilities::postData(cgiIn,
"fieldList");
884 std::string recordList = CgiDataUtilities::postData(cgiIn,
"recordList");
886 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
887 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
888 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
889 __SUP_COUT__ <<
"fieldList: " << fieldList << __E__;
890 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
891 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
893 handleFillGetTreeNodeFieldValuesXML(xmlOut,
896 TableGroupKey(tableGroupKey),
902 else if(requestType ==
"setTreeNodeFieldValues")
904 std::string tableGroup = CgiDataUtilities::getData(cgiIn,
"tableGroup");
905 std::string tableGroupKey = CgiDataUtilities::getData(cgiIn,
"tableGroupKey");
906 std::string startPath = CgiDataUtilities::postData(cgiIn,
"startPath");
907 std::string modifiedTables = CgiDataUtilities::postData(cgiIn,
"modifiedTables");
908 std::string fieldList = CgiDataUtilities::postData(cgiIn,
"fieldList");
909 std::string recordList = CgiDataUtilities::postData(cgiIn,
"recordList");
910 std::string valueList = CgiDataUtilities::postData(cgiIn,
"valueList");
912 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
913 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
914 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
915 __SUP_COUT__ <<
"fieldList: " << fieldList << __E__;
916 __SUP_COUT__ <<
"valueList: " << valueList << __E__;
917 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
918 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
920 handleFillSetTreeNodeFieldValuesXML(xmlOut,
923 TableGroupKey(tableGroupKey),
931 else if(requestType ==
"addTreeNodeRecords")
933 std::string tableGroup = CgiDataUtilities::getData(cgiIn,
"tableGroup");
934 std::string tableGroupKey = CgiDataUtilities::getData(cgiIn,
"tableGroupKey");
935 std::string startPath = CgiDataUtilities::postData(cgiIn,
"startPath");
936 std::string modifiedTables = CgiDataUtilities::postData(cgiIn,
"modifiedTables");
937 std::string recordList = CgiDataUtilities::postData(cgiIn,
"recordList");
939 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
940 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
941 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
942 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
943 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
945 handleFillCreateTreeNodeRecordsXML(xmlOut,
948 TableGroupKey(tableGroupKey),
954 else if(requestType ==
"deleteTreeNodeRecords")
956 std::string tableGroup = CgiDataUtilities::getData(cgiIn,
"tableGroup");
957 std::string tableGroupKey = CgiDataUtilities::getData(cgiIn,
"tableGroupKey");
958 std::string startPath = CgiDataUtilities::postData(cgiIn,
"startPath");
959 std::string modifiedTables = CgiDataUtilities::postData(cgiIn,
"modifiedTables");
960 std::string recordList = CgiDataUtilities::postData(cgiIn,
"recordList");
962 __SUP_COUT__ <<
"tableGroup: " << tableGroup << __E__;
963 __SUP_COUT__ <<
"tableGroupKey: " << tableGroupKey << __E__;
964 __SUP_COUT__ <<
"startPath: " << startPath << __E__;
965 __SUP_COUT__ <<
"recordList: " << recordList << __E__;
966 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
968 handleFillDeleteTreeNodeRecordsXML(xmlOut,
971 TableGroupKey(tableGroupKey),
976 else if(requestType ==
"getArtdaqNodes")
978 std::string modifiedTables = CgiDataUtilities::postData(cgiIn,
"modifiedTables");
980 __SUP_COUTV__(modifiedTables);
982 handleGetArtdaqNodeRecordsXML(xmlOut, cfgMgr, modifiedTables);
984 else if(requestType ==
"loadArtdaqNodeLayout")
986 std::string contextGroupName =
987 CgiDataUtilities::getData(cgiIn,
"contextGroupName");
988 std::string contextGroupKey = CgiDataUtilities::getData(cgiIn,
"contextGroupKey");
990 __SUP_COUTV__(contextGroupName);
991 __SUP_COUTV__(contextGroupKey);
993 handleLoadArtdaqNodeLayoutXML(
994 xmlOut, cfgMgr, contextGroupName, TableGroupKey(contextGroupKey));
996 else if(requestType ==
"saveArtdaqNodeLayout")
998 std::string layout = CgiDataUtilities::postData(cgiIn,
"layout");
999 std::string contextGroupName =
1000 CgiDataUtilities::getData(cgiIn,
"contextGroupName");
1001 std::string contextGroupKey = CgiDataUtilities::getData(cgiIn,
"contextGroupKey");
1003 __SUP_COUTV__(layout);
1004 __SUP_COUTV__(contextGroupName);
1005 __SUP_COUTV__(contextGroupKey);
1007 handleSaveArtdaqNodeLayoutXML(
1008 xmlOut, cfgMgr, layout, contextGroupName, TableGroupKey(contextGroupKey));
1010 else if(requestType ==
"getAffectedActiveGroups")
1012 std::string groupName = CgiDataUtilities::getData(cgiIn,
"groupName");
1013 std::string groupKey = CgiDataUtilities::getData(cgiIn,
"groupKey");
1014 std::string modifiedTables = CgiDataUtilities::postData(cgiIn,
"modifiedTables");
1015 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
1016 __SUP_COUT__ <<
"groupName: " << groupName << __E__;
1017 __SUP_COUT__ <<
"groupKey: " << groupKey << __E__;
1019 handleGetAffectedGroupsXML(
1020 xmlOut, cfgMgr, groupName, TableGroupKey(groupKey), modifiedTables);
1022 else if(requestType ==
"saveTreeNodeEdit")
1024 std::string editNodeType = CgiDataUtilities::getData(cgiIn,
"editNodeType");
1025 std::string targetTable = CgiDataUtilities::getData(cgiIn,
"targetTable");
1026 std::string targetTableVersion =
1027 CgiDataUtilities::getData(cgiIn,
"targetTableVersion");
1028 std::string targetUID = CgiDataUtilities::getData(cgiIn,
"targetUID");
1029 std::string targetColumn = CgiDataUtilities::getData(cgiIn,
"targetColumn");
1030 std::string newValue = CgiDataUtilities::postData(cgiIn,
"newValue");
1032 __SUP_COUT__ <<
"editNodeType: " << editNodeType << __E__;
1033 __SUP_COUT__ <<
"targetTable: " << targetTable << __E__;
1034 __SUP_COUT__ <<
"targetTableVersion: " << targetTableVersion << __E__;
1035 __SUP_COUT__ <<
"targetUID: " << targetUID << __E__;
1036 __SUP_COUT__ <<
"targetColumn: " << targetColumn << __E__;
1037 __SUP_COUT__ <<
"newValue: " << newValue << __E__;
1039 handleSaveTreeNodeEditXML(xmlOut,
1042 TableVersion(targetTableVersion),
1044 StringMacros::decodeURIComponent(targetUID),
1045 StringMacros::decodeURIComponent(targetColumn),
1047 userInfo.username_);
1049 else if(requestType ==
"getLinkToChoices")
1051 std::string linkToTableName = CgiDataUtilities::getData(cgiIn,
"linkToTableName");
1052 std::string linkToTableVersion =
1053 CgiDataUtilities::getData(cgiIn,
"linkToTableVersion");
1054 std::string linkIdType = CgiDataUtilities::getData(cgiIn,
"linkIdType");
1055 std::string linkIndex = StringMacros::decodeURIComponent(
1056 CgiDataUtilities::getData(cgiIn,
"linkIndex"));
1057 std::string linkInitId = CgiDataUtilities::getData(cgiIn,
"linkInitId");
1059 __SUP_COUT__ <<
"linkToTableName: " << linkToTableName << __E__;
1060 __SUP_COUT__ <<
"linkToTableVersion: " << linkToTableVersion << __E__;
1061 __SUP_COUT__ <<
"linkIdType: " << linkIdType << __E__;
1062 __SUP_COUT__ <<
"linkIndex: " << linkIndex << __E__;
1063 __SUP_COUT__ <<
"linkInitId: " << linkInitId << __E__;
1065 handleGetLinkToChoicesXML(xmlOut,
1068 TableVersion(linkToTableVersion),
1073 else if(requestType ==
"activateTableGroup")
1075 std::string groupName = CgiDataUtilities::getData(cgiIn,
"groupName");
1076 std::string groupKey = CgiDataUtilities::getData(cgiIn,
"groupKey");
1077 bool ignoreWarnings = CgiDataUtilities::getDataAsInt(cgiIn,
"ignoreWarnings");
1079 __SUP_COUT__ <<
"Activating table: " << groupName <<
"(" << groupKey <<
")"
1081 __SUP_COUTV__(ignoreWarnings);
1084 xmlOut.addTextElementToData(
"AttemptedGroupActivation",
"1");
1085 xmlOut.addTextElementToData(
"AttemptedGroupActivationName", groupName);
1086 xmlOut.addTextElementToData(
"AttemptedGroupActivationKey", groupKey);
1090 std::string accumulatedErrors;
1095 cfgMgr->activateTableGroup(
1096 groupName, TableGroupKey(groupKey), &accumulatedErrors);
1098 if(accumulatedErrors !=
"")
1102 __SS__ <<
"Throwing exception on accumulated errors: "
1103 << accumulatedErrors << __E__;
1107 __COUT_WARN__ <<
"Ignoring warnings so ignoring this error:"
1108 << accumulatedErrors << __E__;
1109 __COUT_WARN__ <<
"Done ignoring the above error(s)." << __E__;
1112 catch(std::runtime_error& e)
1117 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
1118 xmlOut.addTextElementToData(
1120 "Error activating table group '" + groupName +
"(" + groupKey +
")" +
1121 ".' Please see details below:\n\n" + std::string(e.what()));
1122 __SUP_COUT_ERR__ <<
"Errors detected so de-activating group: " << groupName
1123 <<
" (" << groupKey <<
")" << __E__;
1126 cfgMgr->destroyTableGroup(groupName,
true);
1132 catch(cet::exception& e)
1138 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
1139 xmlOut.addTextElementToData(
"Error",
1140 "Error activating table group '" + groupName +
1141 "(" + groupKey +
")" +
"!'\n\n" +
1142 std::string(e.what()));
1143 __SUP_COUT_ERR__ <<
"Errors detected so de-activating group: " << groupName
1144 <<
" (" << groupKey <<
")" << __E__;
1147 cfgMgr->destroyTableGroup(groupName,
true);
1155 __SUP_COUT__ <<
"Unknown error detected!" << __E__;
1159 else if(requestType ==
"getActiveTableGroups")
1161 else if(requestType ==
"copyViewToCurrentColumns")
1163 std::string tableName =
1164 CgiDataUtilities::getData(cgiIn,
"tableName");
1165 std::string sourceVersion = CgiDataUtilities::getData(cgiIn,
"sourceVersion");
1167 __SUP_COUT__ <<
"tableName: " << tableName << __E__;
1168 __SUP_COUT__ <<
"sourceVersion: " << sourceVersion << __E__;
1169 __SUP_COUT__ <<
"userInfo.username_: " << userInfo.username_ << __E__;
1172 TableVersion newTemporaryVersion;
1176 newTemporaryVersion =
1177 cfgMgr->copyViewToCurrentColumns(tableName, TableVersion(sourceVersion));
1190 __SUP_COUT__ <<
"New temporary version = " << newTemporaryVersion << __E__;
1192 catch(std::runtime_error& e)
1194 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
1195 xmlOut.addTextElementToData(
"Error",
1196 "Error copying view from '" + tableName +
"_v" +
1197 sourceVersion +
"'! " +
1198 std::string(e.what()));
1202 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
1203 xmlOut.addTextElementToData(
1205 "Error copying view from '" + tableName +
"_v" + sourceVersion +
"'! ");
1208 handleGetTableXML(xmlOut, cfgMgr, tableName, newTemporaryVersion);
1210 else if(requestType ==
"getLastTableGroups")
1212 XDAQ_CONST_CALL xdaq::ApplicationDescriptor* gatewaySupervisor =
1213 allSupervisorInfo_.isWizardMode() ? allSupervisorInfo_.getWizardDescriptor()
1214 : allSupervisorInfo_.getGatewayDescriptor();
1216 std::string timeString;
1217 std::pair<std::string , TableGroupKey> theGroup =
1218 theRemoteWebUsers_.getLastConfigGroup(
1219 gatewaySupervisor,
"Configured", timeString);
1220 xmlOut.addTextElementToData(
"LastConfiguredGroupName", theGroup.first);
1221 xmlOut.addTextElementToData(
"LastConfiguredGroupKey", theGroup.second.toString());
1222 xmlOut.addTextElementToData(
"LastConfiguredGroupTime", timeString);
1223 theGroup = theRemoteWebUsers_.getLastConfigGroup(
1224 gatewaySupervisor,
"Started", timeString);
1225 xmlOut.addTextElementToData(
"LastStartedGroupName", theGroup.first);
1226 xmlOut.addTextElementToData(
"LastStartedGroupKey", theGroup.second.toString());
1227 xmlOut.addTextElementToData(
"LastStartedGroupTime", timeString);
1229 else if(requestType ==
"savePlanCommandSequence")
1231 std::string planName = CgiDataUtilities::getData(cgiIn,
"planName");
1232 std::string commands = CgiDataUtilities::postData(cgiIn,
"commands");
1234 std::string modifiedTables = CgiDataUtilities::postData(cgiIn,
"modifiedTables");
1235 std::string groupName = CgiDataUtilities::getData(cgiIn,
"groupName");
1236 std::string groupKey = CgiDataUtilities::getData(cgiIn,
"groupKey");
1238 __SUP_COUT__ <<
"modifiedTables: " << modifiedTables << __E__;
1239 __SUP_COUT__ <<
"planName: " << planName << __E__;
1240 __SUP_COUT__ <<
"commands: " << commands << __E__;
1241 __SUP_COUT__ <<
"groupName: " << groupName << __E__;
1242 __SUP_COUT__ <<
"groupKey: " << groupKey << __E__;
1244 handleSavePlanCommandSequenceXML(xmlOut,
1247 TableGroupKey(groupKey),
1253 else if(requestType ==
"mergeGroups")
1255 std::string groupANameContext =
1256 CgiDataUtilities::getData(cgiIn,
"groupANameContext");
1257 std::string groupAKeyContext =
1258 CgiDataUtilities::getData(cgiIn,
"groupAKeyContext");
1259 std::string groupBNameContext =
1260 CgiDataUtilities::getData(cgiIn,
"groupBNameContext");
1261 std::string groupBKeyContext =
1262 CgiDataUtilities::getData(cgiIn,
"groupBKeyContext");
1263 std::string groupANameConfig =
1264 CgiDataUtilities::getData(cgiIn,
"groupANameConfig");
1265 std::string groupAKeyConfig = CgiDataUtilities::getData(cgiIn,
"groupAKeyConfig");
1266 std::string groupBNameConfig =
1267 CgiDataUtilities::getData(cgiIn,
"groupBNameConfig");
1268 std::string groupBKeyConfig = CgiDataUtilities::getData(cgiIn,
"groupBKeyConfig");
1269 std::string mergeApproach = CgiDataUtilities::getData(cgiIn,
"mergeApproach");
1271 __SUP_COUTV__(groupANameContext);
1272 __SUP_COUTV__(groupAKeyContext);
1273 __SUP_COUTV__(groupBNameContext);
1274 __SUP_COUTV__(groupBKeyContext);
1275 __SUP_COUTV__(groupANameConfig);
1276 __SUP_COUTV__(groupAKeyConfig);
1277 __SUP_COUTV__(groupBNameConfig);
1278 __SUP_COUTV__(groupBKeyConfig);
1279 __SUP_COUTV__(mergeApproach);
1281 handleMergeGroupsXML(xmlOut,
1284 TableGroupKey(groupAKeyContext),
1286 TableGroupKey(groupBKeyContext),
1288 TableGroupKey(groupAKeyConfig),
1290 TableGroupKey(groupBKeyConfig),
1296 __SUP_SS__ <<
"requestType '" << requestType <<
"' request not recognized."
1298 __SUP_COUT__ <<
"\n" << ss.str();
1299 xmlOut.addTextElementToData(
"Error", ss.str());
1305 ConfigurationSupervisorBase::getConfigurationStatusXML(xmlOut, cfgMgr);
1330 catch(
const std::runtime_error& e)
1332 __SS__ <<
"A fatal error occurred while handling the request '" << requestType
1333 <<
".' Error: " << e.what() << __E__;
1334 __COUT_ERR__ <<
"\n" << ss.str();
1335 xmlOut.addTextElementToData(
"Error", ss.str());
1340 xmlOut.addTextElementToData(
1342 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
1346 __COUT_ERR__ <<
"Error getting version tracking status!" << __E__;
1351 __SS__ <<
"An unknown fatal error occurred while handling the request '"
1352 << requestType <<
".'" << __E__;
1353 __COUT_ERR__ <<
"\n" << ss.str();
1354 xmlOut.addTextElementToData(
"Error", ss.str());
1359 xmlOut.addTextElementToData(
1361 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
1365 __COUT_ERR__ <<
"Error getting version tracking status!" << __E__;
1377 void ConfigurationGUISupervisor::handleGetAffectedGroupsXML(
1378 HttpXmlDocument& xmlOut,
1379 ConfigurationManagerRW* cfgMgr,
1380 const std::string& rootGroupName,
1381 const TableGroupKey& rootGroupKey,
1382 const std::string& modifiedTables)
try
1392 std::map<std::string, std::pair<std::string, TableGroupKey>> consideredGroups =
1393 cfgMgr->getActiveTableGroups();
1397 if(consideredGroups[ConfigurationManager::ACTIVE_GROUP_NAME_CONTEXT]
1398 .second.isInvalid())
1400 __SUP_COUT__ <<
"Finding a context group to consider..." << __E__;
1401 if(cfgMgr->getFailedTableGroups().find(
1402 ConfigurationManager::ACTIVE_GROUP_NAME_CONTEXT) !=
1403 cfgMgr->getFailedTableGroups().end())
1405 consideredGroups[ConfigurationManager::ACTIVE_GROUP_NAME_CONTEXT] =
1406 cfgMgr->getFailedTableGroups().at(
1407 ConfigurationManager::ACTIVE_GROUP_NAME_CONTEXT);
1409 else if(cfgMgr->getFailedTableGroups().find(
1410 ConfigurationManager::ACTIVE_GROUP_NAME_UNKNOWN) !=
1411 cfgMgr->getFailedTableGroups().end())
1413 consideredGroups[ConfigurationManager::ACTIVE_GROUP_NAME_CONTEXT] =
1414 cfgMgr->getFailedTableGroups().at(
1415 ConfigurationManager::ACTIVE_GROUP_NAME_UNKNOWN);
1418 if(consideredGroups[ConfigurationManager::ACTIVE_GROUP_NAME_CONFIGURATION]
1419 .second.isInvalid())
1421 __SUP_COUT__ <<
"Finding a table group to consider..." << __E__;
1422 if(cfgMgr->getFailedTableGroups().find(
1423 ConfigurationManager::ACTIVE_GROUP_NAME_CONFIGURATION) !=
1424 cfgMgr->getFailedTableGroups().end())
1426 consideredGroups[ConfigurationManager::ACTIVE_GROUP_NAME_CONFIGURATION] =
1427 cfgMgr->getFailedTableGroups().at(
1428 ConfigurationManager::ACTIVE_GROUP_NAME_CONFIGURATION);
1430 else if(cfgMgr->getFailedTableGroups().find(
1431 ConfigurationManager::ACTIVE_GROUP_NAME_UNKNOWN) !=
1432 cfgMgr->getFailedTableGroups().end())
1434 consideredGroups[ConfigurationManager::ACTIVE_GROUP_NAME_CONFIGURATION] =
1435 cfgMgr->getFailedTableGroups().at(
1436 ConfigurationManager::ACTIVE_GROUP_NAME_UNKNOWN);
1440 __SUP_COUTV__(StringMacros::mapToString(consideredGroups));
1445 std::map<std::string , TableVersion > rootGroupMemberMap;
1447 cfgMgr->loadTableGroup(rootGroupName,
1450 &rootGroupMemberMap,
1458 const std::string& groupType = cfgMgr->getTypeNameOfGroup(rootGroupMemberMap);
1460 consideredGroups[groupType] =
1461 std::pair<std::string, TableGroupKey>(rootGroupName, rootGroupKey);
1463 catch(
const std::runtime_error& e)
1466 if(rootGroupName.size())
1468 __SUP_SS__ <<
"Failed to determine type of table group for " << rootGroupName
1469 <<
"(" << rootGroupKey <<
")! " << e.what() << __E__;
1470 __SUP_COUT_ERR__ <<
"\n" << ss.str();
1475 __SUP_COUT__ <<
"Did not modify considered active groups due to empty root group "
1476 "name - assuming this was intentional."
1482 if(rootGroupName.size())
1484 __SUP_COUT_ERR__ <<
"Failed to determine type of table group for "
1485 << rootGroupName <<
"(" << rootGroupKey <<
")!" << __E__;
1490 __SUP_COUT__ <<
"Did not modify considered active groups due to empty root group "
1491 "name - assuming this was intentional."
1495 std::map<std::string , TableVersion > modifiedTablesMap;
1496 std::map<std::string , TableVersion >::iterator
1497 modifiedTablesMapIt;
1499 std::istringstream f(modifiedTables);
1500 std::string table, version;
1501 while(getline(f, table,
','))
1503 getline(f, version,
',');
1504 modifiedTablesMap.insert(
1505 std::pair<std::string /*name*/, TableVersion /*version*/>(
1506 table, TableVersion(version)));
1508 __SUP_COUT__ << modifiedTables << __E__;
1509 for(
auto& pair : modifiedTablesMap)
1510 __SUP_COUT__ <<
"modified table " << pair.first <<
":" << pair.second
1515 xercesc::DOMElement* parentEl;
1516 std::string groupComment;
1517 for(
auto group : consideredGroups)
1519 if(group.second.second.isInvalid())
1522 __SUP_COUT__ <<
"Considering " << group.first <<
" group " << group.second.first
1523 <<
" (" << group.second.second <<
")" << __E__;
1527 std::map<std::string , TableVersion > memberMap;
1528 cfgMgr->loadTableGroup(group.second.first,
1529 group.second.second,
1539 __SUP_COUT__ <<
"groupComment = " << groupComment << __E__;
1541 for(
auto& table : memberMap)
1543 if((modifiedTablesMapIt = modifiedTablesMap.find(table.first)) !=
1546 table.second != (*modifiedTablesMapIt).second)
1548 __SUP_COUT__ <<
"Affected by " << (*modifiedTablesMapIt).first <<
":"
1549 << (*modifiedTablesMapIt).second << __E__;
1551 memberMap[table.first] = (*modifiedTablesMapIt).second;
1557 parentEl = xmlOut.addTextElementToData(
"AffectedActiveGroup",
"");
1558 xmlOut.addTextElementToParent(
"GroupName", group.second.first, parentEl);
1559 xmlOut.addTextElementToParent(
1560 "GroupKey", group.second.second.toString(), parentEl);
1561 xmlOut.addTextElementToParent(
"GroupComment", groupComment, parentEl);
1563 for(
auto& table : memberMap)
1565 xmlOut.addTextElementToParent(
"MemberName", table.first, parentEl);
1566 xmlOut.addTextElementToParent(
1567 "MemberVersion", table.second.toString(), parentEl);
1572 catch(std::runtime_error& e)
1574 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
1575 xmlOut.addTextElementToData(
1576 "Error",
"Error getting affected groups! " + std::string(e.what()));
1580 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
1581 xmlOut.addTextElementToData(
"Error",
"Error getting affected groups! ");
1592 void ConfigurationGUISupervisor::setupActiveTablesXML(
1593 HttpXmlDocument& xmlOut,
1594 ConfigurationManagerRW* cfgMgr,
1595 const std::string& groupName,
1596 const TableGroupKey& groupKey,
1597 const std::string& modifiedTables,
1599 bool doGetGroupInfo,
1600 std::map<std::string /*name*/, TableVersion /*version*/>* returnMemberMap,
1601 bool outputActiveTables,
1602 std::string* accumulatedErrors)
try
1607 xmlOut.addTextElementToData(
"tableGroup", groupName);
1608 xmlOut.addTextElementToData(
"tableGroupKey", groupKey.toString());
1610 bool usingActiveGroups = (groupName ==
"" || groupKey.isInvalid());
1613 if(usingActiveGroups || refreshAll)
1615 __SUP_COUT__ <<
"Refreshing all table info..." << __E__;
1616 cfgMgr->getAllTableInfo(
true, accumulatedErrors);
1618 if(accumulatedErrors && *accumulatedErrors !=
"")
1619 __SUP_COUTV__(*accumulatedErrors);
1622 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->getAllTableInfo(
false);
1624 std::map<std::string , TableVersion > modifiedTablesMap;
1625 std::map<std::string , TableVersion >::iterator
1626 modifiedTablesMapIt;
1628 if(usingActiveGroups)
1631 __SUP_COUT__ <<
"Using active groups." << __E__;
1635 __SUP_COUT__ <<
"Loading group '" << groupName <<
"(" << groupKey <<
")'"
1638 std::string groupComment, groupAuthor, configGroupCreationTime;
1641 cfgMgr->loadTableGroup(groupName,
1647 doGetGroupInfo ? &groupComment : 0,
1648 doGetGroupInfo ? &groupAuthor : 0,
1649 doGetGroupInfo ? &configGroupCreationTime : 0);
1653 xmlOut.addTextElementToData(
"configGroupComment", groupComment);
1654 xmlOut.addTextElementToData(
"configGroupAuthor", groupAuthor);
1655 xmlOut.addTextElementToData(
"configGroupCreationTime",
1656 configGroupCreationTime);
1659 if(accumulatedErrors && *accumulatedErrors !=
"")
1660 __SUP_COUTV__(*accumulatedErrors);
1665 std::istringstream f(modifiedTables);
1666 std::string table, version;
1667 while(getline(f, table,
','))
1669 getline(f, version,
',');
1670 modifiedTablesMap.insert(
1671 std::pair<std::string /*name*/, TableVersion /*version*/>(
1672 table, TableVersion(version)));
1675 for(
auto& pair : modifiedTablesMap)
1676 __SUP_COUT__ <<
"modified table " << pair.first <<
":" << pair.second
1681 std::map<std::string, TableVersion> allActivePairs = cfgMgr->getActiveVersions();
1682 xmlOut.addTextElementToData(
"DefaultNoLink",
1683 TableViewColumnInfo::DATATYPE_LINK_DEFAULT);
1684 for(
auto& activePair : allActivePairs)
1686 if(outputActiveTables)
1687 xmlOut.addTextElementToData(
"ActiveTableName", activePair.first);
1691 if((modifiedTablesMapIt = modifiedTablesMap.find(activePair.first)) !=
1692 modifiedTablesMap.end())
1694 __SUP_COUT__ <<
"Found modified table " << (*modifiedTablesMapIt).first
1695 <<
": trying... " << (*modifiedTablesMapIt).second << __E__;
1699 allTableInfo.at(activePair.first)
1700 .tablePtr_->setActiveView((*modifiedTablesMapIt).second);
1705 <<
"Modified table version v" << (*modifiedTablesMapIt).second
1706 <<
" failed. Reverting to v"
1707 << allTableInfo.at(activePair.first).tablePtr_->getView().getVersion()
1709 __SUP_COUT_WARN__ <<
"Warning detected!\n\n " << ss.str() << __E__;
1710 xmlOut.addTextElementToData(
1712 "Error setting up active tables!\n\n" + std::string(ss.str()));
1716 if(outputActiveTables)
1718 xmlOut.addTextElementToData(
"ActiveTableVersion",
1719 allTableInfo.at(activePair.first)
1720 .tablePtr_->getView()
1723 xmlOut.addTextElementToData(
1724 "ActiveTableComment",
1725 allTableInfo.at(activePair.first).tablePtr_->getView().getComment());
1734 catch(std::runtime_error& e)
1736 __SUP_SS__ << (
"Error setting up active tables!\n\n" + std::string(e.what()))
1738 __SUP_COUT_ERR__ <<
"\n" << ss.str();
1739 xmlOut.addTextElementToData(
"Error", ss.str());
1743 __SUP_SS__ << (
"Error setting up active tables!\n\n") << __E__;
1744 __SUP_COUT_ERR__ <<
"\n" << ss.str();
1745 xmlOut.addTextElementToData(
"Error", ss.str());
1764 void ConfigurationGUISupervisor::handleFillCreateTreeNodeRecordsXML(
1765 HttpXmlDocument& xmlOut,
1766 ConfigurationManagerRW* cfgMgr,
1767 const std::string& groupName,
1768 const TableGroupKey& groupKey,
1769 const std::string& startPath,
1770 const std::string& modifiedTables,
1771 const std::string& recordList,
1772 const std::string& author)
1775 setupActiveTablesXML(xmlOut,
1787 ConfigurationTree targetNode = cfgMgr->getNode(startPath);
1788 TableBase* table = cfgMgr->getTableByName(targetNode.getTableName());
1790 __SUP_COUT__ << table->getTableName() << __E__;
1791 TableVersion temporaryVersion;
1800 bool firstSave =
true;
1803 TableView backupView;
1807 std::istringstream f(recordList);
1808 std::string recordUID;
1811 while(getline(f, recordUID,
','))
1813 recordUID = StringMacros::decodeURIComponent(recordUID);
1815 __SUP_COUT__ <<
"recordUID " << recordUID << __E__;
1819 if(!(temporaryVersion = targetNode.getTableVersion())
1820 .isTemporaryVersion())
1822 __SUP_COUT__ <<
"Start version " << temporaryVersion << __E__;
1824 temporaryVersion = table->createTemporaryView(temporaryVersion);
1825 cfgMgr->saveNewTable(targetNode.getTableName(),
1830 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion
1834 __SUP_COUT__ <<
"Using temporary version " << temporaryVersion
1840 backupView.copy(table->getView(), temporaryVersion, author);
1849 unsigned int row = table->getViewP()->addRow(
1856 unsigned int col = table->getViewP()->getColStatus();
1857 table->getViewP()->setURIEncodedValue(
"1", row, col);
1864 table->getViewP()->setURIEncodedValue(
1865 recordUID, row, table->getViewP()->getColUID());
1873 table->getViewP()->init();
1877 __SUP_COUT_INFO__ <<
"Reverting to original view." << __E__;
1878 __SUP_COUT__ <<
"Before:" << __E__;
1879 table->getViewP()->print();
1880 table->getViewP()->copy(backupView, temporaryVersion, author);
1881 __SUP_COUT__ <<
"After:" << __E__;
1882 table->getViewP()->print();
1888 handleFillModifiedTablesXML(xmlOut, cfgMgr);
1890 catch(std::runtime_error& e)
1892 __SUP_SS__ << (
"Error creating new record(s)!\n\n" + std::string(e.what()))
1894 __SUP_COUT_ERR__ <<
"\n" << ss.str();
1895 xmlOut.addTextElementToData(
"Error", ss.str());
1899 __SUP_SS__ << (
"Error creating new record(s)!\n\n") << __E__;
1900 __SUP_COUT_ERR__ <<
"\n" << ss.str();
1901 xmlOut.addTextElementToData(
"Error", ss.str());
1908 void ConfigurationGUISupervisor::handleFillModifiedTablesXML(
1909 HttpXmlDocument& xmlOut, ConfigurationManagerRW* cfgMgr)
try
1912 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->getAllTableInfo();
1913 std::map<std::string, TableVersion> allActivePairs = cfgMgr->getActiveVersions();
1914 for(
auto& activePair : allActivePairs)
1916 xmlOut.addTextElementToData(
"NewActiveTableName", activePair.first);
1917 xmlOut.addTextElementToData(
"NewActiveTableVersion",
1918 allTableInfo.at(activePair.first)
1919 .tablePtr_->getView()
1922 xmlOut.addTextElementToData(
1923 "NewActiveTableComment",
1924 allTableInfo.at(activePair.first).tablePtr_->getView().getComment());
1927 catch(std::runtime_error& e)
1929 __SUP_SS__ << (
"Error!\n\n" + std::string(e.what())) << __E__;
1930 __SUP_COUT_ERR__ <<
"\n" << ss.str();
1931 xmlOut.addTextElementToData(
"Error", ss.str());
1935 __SUP_SS__ << (
"Error!\n\n") << __E__;
1936 __SUP_COUT_ERR__ <<
"\n" << ss.str();
1937 xmlOut.addTextElementToData(
"Error", ss.str());
1955 void ConfigurationGUISupervisor::handleFillDeleteTreeNodeRecordsXML(
1956 HttpXmlDocument& xmlOut,
1957 ConfigurationManagerRW* cfgMgr,
1958 const std::string& groupName,
1959 const TableGroupKey& groupKey,
1960 const std::string& startPath,
1961 const std::string& modifiedTables,
1962 const std::string& recordList)
1965 setupActiveTablesXML(xmlOut,
1977 ConfigurationTree targetNode = cfgMgr->getNode(startPath);
1978 TableBase* table = cfgMgr->getTableByName(targetNode.getTableName());
1980 __SUP_COUT__ << table->getTableName() << __E__;
1981 TableVersion temporaryVersion;
1990 bool firstSave =
true;
1994 std::istringstream f(recordList);
1995 std::string recordUID;
1998 while(getline(f, recordUID,
','))
2000 recordUID = StringMacros::decodeURIComponent(recordUID);
2002 __SUP_COUT__ <<
"recordUID " << recordUID << __E__;
2006 if(!(temporaryVersion = targetNode.getTableVersion())
2007 .isTemporaryVersion())
2009 __SUP_COUT__ <<
"Start version " << temporaryVersion << __E__;
2011 temporaryVersion = table->createTemporaryView(temporaryVersion);
2012 cfgMgr->saveNewTable(targetNode.getTableName(),
2017 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion
2021 __SUP_COUT__ <<
"Using temporary version " << temporaryVersion
2032 table->getViewP()->findRow(table->getViewP()->getColUID(), recordUID);
2033 table->getViewP()->deleteRow(row);
2038 table->getViewP()->init();
2040 handleFillModifiedTablesXML(xmlOut, cfgMgr);
2042 catch(std::runtime_error& e)
2044 __SUP_SS__ << (
"Error removing record(s)!\n\n" + std::string(e.what())) << __E__;
2045 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2046 xmlOut.addTextElementToData(
"Error", ss.str());
2050 __SUP_SS__ << (
"Error removing record(s)!\n\n") << __E__;
2051 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2052 xmlOut.addTextElementToData(
"Error", ss.str());
2073 void ConfigurationGUISupervisor::handleFillSetTreeNodeFieldValuesXML(
2074 HttpXmlDocument& xmlOut,
2075 ConfigurationManagerRW* cfgMgr,
2076 const std::string& groupName,
2077 const TableGroupKey& groupKey,
2078 const std::string& startPath,
2079 const std::string& modifiedTables,
2080 const std::string& recordList,
2081 const std::string& fieldList,
2082 const std::string& valueList,
2083 const std::string& author)
2086 setupActiveTablesXML(xmlOut,
2101 std::vector<std::string > fieldPaths;
2104 std::istringstream f(fieldList);
2105 std::string fieldPath;
2106 while(getline(f, fieldPath,
','))
2108 fieldPaths.push_back(StringMacros::decodeURIComponent(fieldPath));
2110 __SUP_COUT__ << fieldList << __E__;
2111 for(
const auto& field : fieldPaths)
2112 __SUP_COUT__ <<
"fieldPath " << field << __E__;
2115 std::vector<std::string > fieldValues;
2118 std::istringstream f(valueList);
2119 std::string fieldValue;
2120 while(getline(f, fieldValue,
','))
2122 fieldValues.push_back(
2128 if(valueList.size() && valueList[valueList.size() - 1] ==
',')
2129 fieldValues.push_back(
"");
2131 __SUP_COUT__ << valueList << __E__;
2132 for(
const auto& value : fieldValues)
2133 __SUP_COUT__ <<
"fieldValue " << value << __E__;
2136 if(fieldPaths.size() != fieldValues.size())
2139 __THROW__(ss.str() +
"Mismatch in fields and values array size!");
2145 TableVersion temporaryVersion;
2146 std::istringstream f(recordList);
2147 std::string recordUID;
2150 while(getline(f, recordUID,
','))
2152 recordUID = StringMacros::decodeURIComponent(recordUID);
2156 xercesc::DOMElement* parentEl =
2157 xmlOut.addTextElementToData(
"fieldValues", recordUID);
2160 for(i = 0; i < fieldPaths.size(); ++i)
2162 __SUP_COUT__ <<
"fieldPath " << fieldPaths[i] << __E__;
2163 __SUP_COUT__ <<
"fieldValue " << fieldValues[i] << __E__;
2167 ConfigurationTree targetNode =
2168 cfgMgr->getNode(startPath +
"/" + recordUID +
"/" + fieldPaths[i],
2203 __SUP_COUT__ <<
"Getting table " << targetNode.getFieldTableName()
2207 table = cfgMgr->getTableByName(
2208 targetNode.getFieldTableName());
2209 if(!(temporaryVersion = table->getViewP()->getVersion())
2210 .isTemporaryVersion())
2214 table->createTemporaryView(table->getViewP()->getVersion());
2215 cfgMgr->saveNewTable(table->getTableName(),
2220 __SUP_COUT__ <<
"Created temporary version "
2221 << table->getTableName() <<
"-v" << temporaryVersion
2225 __SUP_COUT__ <<
"Using temporary version " << table->getTableName()
2226 <<
"-v" << temporaryVersion << __E__;
2230 table->getViewP()->setURIEncodedValue(fieldValues[i],
2231 targetNode.getFieldRow(),
2232 targetNode.getFieldColumn(),
2241 handleFillModifiedTablesXML(xmlOut, cfgMgr);
2243 catch(std::runtime_error& e)
2245 __SUP_SS__ << (
"Error setting field values!\n\n" + std::string(e.what()))
2247 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2248 xmlOut.addTextElementToData(
"Error", ss.str());
2252 __SUP_SS__ << (
"Error setting field values!\n\n") << __E__;
2253 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2254 xmlOut.addTextElementToData(
"Error", ss.str());
2273 void ConfigurationGUISupervisor::handleFillGetTreeNodeFieldValuesXML(
2274 HttpXmlDocument& xmlOut,
2275 ConfigurationManagerRW* cfgMgr,
2276 const std::string& groupName,
2277 const TableGroupKey& groupKey,
2278 const std::string& startPath,
2279 const std::string& modifiedTables,
2280 const std::string& recordList,
2281 const std::string& fieldList)
2284 setupActiveTablesXML(xmlOut, cfgMgr, groupName, groupKey, modifiedTables);
2291 std::vector<std::string > fieldPaths;
2294 std::istringstream f(fieldList);
2295 std::string fieldPath;
2296 while(getline(f, fieldPath,
','))
2298 fieldPaths.push_back(StringMacros::decodeURIComponent(fieldPath));
2300 __SUP_COUT__ << fieldList << __E__;
2301 for(
auto& field : fieldPaths)
2302 __SUP_COUT__ <<
"fieldPath " << field << __E__;
2307 std::istringstream f(recordList);
2308 std::string recordUID;
2309 while(getline(f, recordUID,
','))
2311 recordUID = StringMacros::decodeURIComponent(recordUID);
2313 __SUP_COUT__ <<
"recordUID " << recordUID << __E__;
2315 xercesc::DOMElement* parentEl =
2316 xmlOut.addTextElementToData(
"fieldValues", recordUID);
2319 for(
const auto& fieldPath : fieldPaths)
2321 __SUP_COUT__ <<
"fieldPath " << fieldPath << __E__;
2323 ConfigurationTree node =
2324 cfgMgr->getNode(startPath +
"/" + recordUID +
"/" + fieldPath);
2326 xmlOut.addTextElementToParent(
"FieldPath", fieldPath, parentEl);
2328 xmlOut.addTextElementToParent(
2330 cfgMgr->getNode(startPath +
"/" + recordUID +
"/" + fieldPath)
2331 .getValueAsString(
true ),
2337 catch(std::runtime_error& e)
2339 __SUP_SS__ << (
"Error getting field values!\n\n" + std::string(e.what()))
2341 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2342 xmlOut.addTextElementToData(
"Error", ss.str());
2346 __SUP_SS__ << (
"Error getting field values!\n\n") << __E__;
2347 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2348 xmlOut.addTextElementToData(
"Error", ss.str());
2371 void ConfigurationGUISupervisor::handleFillTreeNodeCommonFieldsXML(
2372 HttpXmlDocument& xmlOut,
2373 ConfigurationManagerRW* cfgMgr,
2374 const std::string& groupName,
2375 const TableGroupKey& groupKey,
2376 const std::string& startPath,
2378 const std::string& modifiedTables,
2379 const std::string& recordList,
2380 const std::string& fieldList)
2383 setupActiveTablesXML(xmlOut, cfgMgr, groupName, groupKey, modifiedTables);
2387 xercesc::DOMElement* parentEl = xmlOut.addTextElementToData(
"fields", startPath);
2391 __SUP_SS__ <<
"Depth of search must be greater than 0." << __E__;
2392 __SUP_COUT__ << ss.str();
2401 std::vector<ConfigurationTree::RecordField> retFieldList;
2404 ConfigurationTree startNode = cfgMgr->getNode(startPath);
2405 if(startNode.isLinkNode() && startNode.isDisconnected())
2407 __SUP_SS__ <<
"Start path was a disconnected link node!" << __E__;
2408 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2414 std::vector<std::string > fieldAcceptList, fieldRejectList;
2419 std::istringstream f(fieldList);
2420 std::string fieldPath, decodedFieldPath;
2421 while(getline(f, fieldPath,
','))
2423 decodedFieldPath = StringMacros::decodeURIComponent(fieldPath);
2425 if(decodedFieldPath[0] ==
'!')
2426 fieldRejectList.push_back(decodedFieldPath.substr(1));
2428 fieldAcceptList.push_back(decodedFieldPath);
2430 __SUP_COUT__ << fieldList << __E__;
2431 for(
auto& field : fieldAcceptList)
2432 __SUP_COUT__ <<
"fieldAcceptList " << field << __E__;
2433 for(
auto& field : fieldRejectList)
2434 __SUP_COUT__ <<
"fieldRejectList " << field << __E__;
2438 std::vector<std::string > records;
2439 if(recordList ==
"*")
2442 records = startNode.getChildrenNames();
2443 __SUP_COUT__ <<
"Translating wildcard..." << __E__;
2444 for(
auto& record : records)
2445 __SUP_COUT__ <<
"recordList " << record << __E__;
2447 else if(recordList !=
"")
2451 std::istringstream f(recordList);
2452 std::string recordStr;
2453 while(getline(f, recordStr,
','))
2455 records.push_back(StringMacros::decodeURIComponent(recordStr));
2457 __SUP_COUT__ << recordList << __E__;
2458 for(
auto& record : records)
2459 __SUP_COUT__ <<
"recordList " << record << __E__;
2463 retFieldList = startNode.getCommonFields(
2464 records, fieldAcceptList, fieldRejectList, depth);
2467 xercesc::DOMElement* parentTypeEl;
2468 for(
const auto& fieldInfo : retFieldList)
2470 xmlOut.addTextElementToParent(
2471 "FieldTableName", fieldInfo.tableName_, parentEl);
2472 xmlOut.addTextElementToParent(
2473 "FieldColumnName", fieldInfo.columnName_, parentEl);
2474 xmlOut.addTextElementToParent(
2475 "FieldRelativePath", fieldInfo.relativePath_, parentEl);
2476 xmlOut.addTextElementToParent(
2477 "FieldColumnType", fieldInfo.columnInfo_->getType(), parentEl);
2478 xmlOut.addTextElementToParent(
2479 "FieldColumnDataType", fieldInfo.columnInfo_->getDataType(), parentEl);
2480 xmlOut.addTextElementToParent(
"FieldColumnDefaultValue",
2481 fieldInfo.columnInfo_->getDefaultValue(),
2485 xmlOut.addTextElementToParent(
"FieldColumnDataChoices",
"", parentEl);
2488 auto dataChoices = fieldInfo.columnInfo_->getDataChoices();
2489 xmlOut.addTextElementToParent(
2490 "FieldColumnDataChoice",
2491 fieldInfo.columnInfo_->getDefaultValue(),
2493 for(
const auto& dataChoice : dataChoices)
2494 xmlOut.addTextElementToParent(
2495 "FieldColumnDataChoice", dataChoice, parentTypeEl);
2498 catch(std::runtime_error& e)
2500 __SUP_SS__ << (
"Error getting common fields!\n\n" + std::string(e.what()))
2502 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2503 xmlOut.addTextElementToData(
"Error", ss.str());
2507 __SUP_SS__ << (
"Error getting common fields!\n\n") << __E__;
2508 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2509 xmlOut.addTextElementToData(
"Error", ss.str());
2541 void ConfigurationGUISupervisor::handleFillUniqueFieldValuesForRecordsXML(
2542 HttpXmlDocument& xmlOut,
2543 ConfigurationManagerRW* cfgMgr,
2544 const std::string& groupName,
2545 const TableGroupKey& groupKey,
2546 const std::string& startPath,
2547 const std::string& modifiedTables,
2548 const std::string& recordList,
2549 const std::string& fieldList)
2552 setupActiveTablesXML(xmlOut, cfgMgr, groupName, groupKey, modifiedTables);
2558 if(startPath ==
"/")
2561 ConfigurationTree startNode = cfgMgr->getNode(startPath);
2562 if(startNode.isLinkNode() && startNode.isDisconnected())
2564 __SUP_SS__ <<
"Start path was a disconnected link node!" << __E__;
2565 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2570 std::vector<std::string > records;
2571 if(recordList ==
"*")
2574 records = startNode.getChildrenNames();
2575 __SUP_COUT__ <<
"Translating wildcard..." << __E__;
2576 for(
auto& record : records)
2577 __SUP_COUT__ <<
"recordList " << record << __E__;
2579 else if(recordList !=
"")
2583 std::istringstream f(recordList);
2584 std::string recordStr;
2585 while(getline(f, recordStr,
','))
2587 records.push_back(StringMacros::decodeURIComponent(recordStr));
2589 __SUP_COUT__ << recordList << __E__;
2590 for(
auto& record : records)
2591 __SUP_COUT__ <<
"recordList " << record << __E__;
2596 std::vector<std::string > fieldsToGet;
2601 if(fieldList ==
"AUTO")
2606 __SUP_COUT__ <<
"Getting AUTO filter fields!" << __E__;
2608 std::vector<ConfigurationTree::RecordField> retFieldList;
2609 std::vector<std::string > fieldAcceptList,
2611 fieldRejectList.push_back(
"*" + TableViewColumnInfo::COL_NAME_COMMENT);
2612 retFieldList = startNode.getCommonFields(
2613 records, fieldAcceptList, fieldRejectList, 5,
true );
2615 for(
const auto& retField : retFieldList)
2616 fieldsToGet.push_back(retField.columnName_);
2620 std::istringstream f(fieldList);
2621 std::string fieldPath;
2622 while(getline(f, fieldPath,
','))
2624 fieldsToGet.push_back(StringMacros::decodeURIComponent(fieldPath));
2626 __SUP_COUTV__(fieldList);
2630 __SUP_COUTV__(StringMacros::vectorToString(fieldsToGet));
2634 ConfigurationTree startNode = cfgMgr->getNode(startPath);
2635 std::string fieldGroupIDChildLinkIndex;
2636 for(
auto& field : fieldsToGet)
2638 __SUP_COUTV__(field);
2640 xercesc::DOMElement* parentEl =
2641 xmlOut.addTextElementToData(
"field", field);
2647 std::set<std::string > uniqueValues =
2648 startNode.getUniqueValuesForField(
2649 records, field, &fieldGroupIDChildLinkIndex);
2651 if(fieldGroupIDChildLinkIndex !=
"")
2652 xmlOut.addTextElementToParent(
2653 "childLinkIndex", fieldGroupIDChildLinkIndex, parentEl);
2655 for(
auto& uniqueValue : uniqueValues)
2657 __SUP_COUT__ <<
"uniqueValue " << uniqueValue << __E__;
2659 xmlOut.addTextElementToParent(
"uniqueValue", uniqueValue, parentEl);
2664 catch(std::runtime_error& e)
2666 __SUP_SS__ << (
"Error getting common fields!\n\n" + std::string(e.what()))
2668 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2669 xmlOut.addTextElementToData(
"Error", ss.str());
2673 __SUP_SS__ << (
"Error getting common fields!\n\n") << __E__;
2674 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2675 xmlOut.addTextElementToData(
"Error", ss.str());
2699 void ConfigurationGUISupervisor::handleFillTreeViewXML(HttpXmlDocument& xmlOut,
2700 ConfigurationManagerRW* cfgMgr,
2701 const std::string& groupName,
2702 const TableGroupKey& groupKey,
2703 const std::string& startPath,
2705 bool hideStatusFalse,
2706 const std::string& modifiedTables,
2707 const std::string& filterList)
2738 bool usingActiveGroups = (groupName ==
"" || groupKey.isInvalid());
2739 std::map<std::string , TableVersion > memberMap;
2741 std::string accumulatedErrors =
"";
2744 setupActiveTablesXML(xmlOut,
2758 catch(
const std::runtime_error& e)
2760 __SS__ <<
"Error occured setting up active tables: " << e.what() << __E__;
2761 accumulatedErrors += ss.str();
2765 __SS__ <<
"Unknown error occured setting up active tables." << __E__;
2766 accumulatedErrors += ss.str();
2769 if(accumulatedErrors !=
"")
2771 xmlOut.addTextElementToData(
"Warning", accumulatedErrors);
2773 __SUP_COUT__ <<
"Active tables are setup. Warning string: '" << accumulatedErrors
2776 __SUP_COUT__ <<
"Active table versions: "
2777 << StringMacros::mapToString(cfgMgr->getActiveVersions()) << __E__;
2780 __SUP_COUT__ <<
"Active tables are setup. No issues found." << __E__;
2784 xercesc::DOMElement* parentEl = xmlOut.addTextElementToData(
"tree", startPath);
2789 std::vector<std::pair<std::string, ConfigurationTree>> rootMap;
2791 if(startPath ==
"/")
2795 std::string accumulateTreeErrs;
2797 if(usingActiveGroups)
2798 rootMap = cfgMgr->getChildren(0, &accumulateTreeErrs);
2800 rootMap = cfgMgr->getChildren(&memberMap, &accumulateTreeErrs);
2802 __SUP_COUT__ <<
"accumulateTreeErrs = " << accumulateTreeErrs << __E__;
2803 if(accumulateTreeErrs !=
"")
2804 xmlOut.addTextElementToData(
"TreeErrors", accumulateTreeErrs);
2808 ConfigurationTree startNode =
2809 cfgMgr->getNode(startPath,
true );
2810 if(startNode.isLinkNode() && startNode.isDisconnected())
2812 xmlOut.addTextElementToData(
"DisconnectedStartNode",
"1");
2817 std::map<std::string , std::string > filterMap;
2818 StringMacros::getMapFromString(
2821 std::set<char>({
';'}) ,
2822 std::set<char>({
'='}) );
2824 __COUTV__(StringMacros::mapToString(filterMap));
2826 rootMap = cfgMgr->getNode(startPath).getChildren(filterMap);
2829 for(
auto& treePair : rootMap)
2831 treePair.second, depth - 1, xmlOut, parentEl, hideStatusFalse);
2833 catch(std::runtime_error& e)
2835 __SUP_SS__ <<
"Error detected generating XML tree!\n\n " << e.what() << __E__;
2836 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2837 xmlOut.addTextElementToData(
"Error", ss.str());
2841 __SUP_SS__ <<
"Error detected generating XML tree!" << __E__;
2842 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2843 xmlOut.addTextElementToData(
"Error", ss.str());
2853 void ConfigurationGUISupervisor::recursiveTreeToXML(
const ConfigurationTree& t,
2855 HttpXmlDocument& xmlOut,
2856 xercesc::DOMElement* parentEl,
2857 bool hideStatusFalse)
2863 parentEl = xmlOut.addTextElementToParent(
"node", t.getValueName(), parentEl);
2864 xmlOut.addTextElementToParent(
"value", t.getValueAsString(), parentEl);
2865 parentEl = xmlOut.addTextElementToParent(
"valueType", t.getValueType(), parentEl);
2869 if(t.getValueType() == TableViewColumnInfo::TYPE_FIXED_CHOICE_DATA ||
2870 t.getValueType() == TableViewColumnInfo::TYPE_BITMAP_DATA)
2874 std::vector<std::string> choices = t.getFixedChoices();
2875 for(
const auto& choice : choices)
2876 xmlOut.addTextElementToParent(
"fixedChoice", choice, parentEl);
2887 parentEl = xmlOut.addTextElementToParent(
"node", t.getValueName(), parentEl);
2889 if(t.isDisconnected())
2891 __COUT__ << t.getValueName() << __E__;
2897 xmlOut.addTextElementToParent(
"valueType", t.getValueType(), parentEl);
2900 xmlOut.addTextElementToParent(
2901 (t.isGroupLinkNode() ?
"Group" :
"U") + std::string(
"ID"),
2902 t.getDisconnectedLinkID(),
2904 xmlOut.addTextElementToParent(
2905 "LinkTableName", t.getDisconnectedTableName(), parentEl);
2906 xmlOut.addTextElementToParent(
2907 "LinkIndex", t.getChildLinkIndex(), parentEl);
2910 xercesc::DOMElement* choicesParentEl =
2911 xmlOut.addTextElementToParent(
"fixedChoices",
"", parentEl);
2915 std::vector<std::string> choices = t.getFixedChoices();
2916 __COUT__ <<
"choices.size() " << choices.size() << __E__;
2918 for(
const auto& choice : choices)
2919 xmlOut.addTextElementToParent(
"fixedChoice", choice, choicesParentEl);
2931 xmlOut.addTextElementToParent(
2932 (t.isGroupLinkNode() ?
"Group" :
"U") + std::string(
"ID"),
2933 t.getValueAsString(),
2936 xmlOut.addTextElementToParent(
"LinkTableName", t.getTableName(), parentEl);
2937 xmlOut.addTextElementToParent(
"LinkIndex", t.getChildLinkIndex(), parentEl);
2941 xercesc::DOMElement* choicesParentEl =
2942 xmlOut.addTextElementToParent(
"fixedChoices",
"", parentEl);
2943 std::vector<std::string> choices = t.getFixedChoices();
2947 for(
const auto& choice : choices)
2948 xmlOut.addTextElementToParent(
"fixedChoice", choice, choicesParentEl);
2953 bool returnNode =
true;
2959 t.getNode(TableViewColumnInfo::COL_NAME_STATUS).getValue(returnNode);
2968 xmlOut.addTextElementToParent(
"node", t.getValueAsString(), parentEl);
2977 auto C = t.getChildren();
2980 c.second, depth - 1, xmlOut, parentEl, hideStatusFalse);
2992 void ConfigurationGUISupervisor::handleGetLinkToChoicesXML(
2993 HttpXmlDocument& xmlOut,
2994 ConfigurationManagerRW* cfgMgr,
2995 const std::string& linkToTableName,
2996 const TableVersion& linkToTableVersion,
2997 const std::string& linkIdType,
2998 const std::string& linkIndex,
2999 const std::string& linkInitId)
try
3011 const std::string& tableName = linkToTableName;
3012 const TableVersion& version = linkToTableVersion;
3013 TableBase* table = cfgMgr->getTableByName(tableName);
3016 table->setActiveView(version);
3020 __SUP_COUT__ <<
"Failed to find stored version, so attempting to load version: "
3021 << version << __E__;
3022 cfgMgr->getVersionedTableByName(tableName, version);
3025 if(version != table->getViewVersion())
3027 __SUP_SS__ <<
"Target table version (" << version
3028 <<
") is not the currently active version (" << table->getViewVersion()
3029 <<
". Try refreshing the tree." << __E__;
3030 __SUP_COUT_WARN__ << ss.str();
3034 __SUP_COUT__ <<
"Active version is " << table->getViewVersion() << __E__;
3036 if(linkIdType ==
"UID")
3039 unsigned int col = table->getView().getColUID();
3040 for(
unsigned int row = 0; row < table->getView().getNumberOfRows(); ++row)
3041 xmlOut.addTextElementToData(
"linkToChoice",
3042 table->getView().getDataView()[row][col]);
3044 else if(linkIdType ==
"GroupID")
3050 __SUP_COUTV__(linkIndex);
3051 __SUP_COUTV__(linkInitId);
3053 std::set<std::string> setOfGroupIDs =
3054 table->getView().getSetOfGroupIDs(linkIndex);
3059 bool foundInitId =
false;
3060 for(
const auto& groupID : setOfGroupIDs)
3062 if(!foundInitId && linkInitId == groupID)
3065 xmlOut.addTextElementToData(
"linkToChoice", groupID);
3069 xmlOut.addTextElementToData(
"linkToChoice", linkInitId);
3072 unsigned int col = table->getView().getColUID();
3073 for(
unsigned int row = 0; row < table->getView().getNumberOfRows(); ++row)
3075 xmlOut.addTextElementToData(
"groupChoice",
3076 table->getView().getDataView()[row][col]);
3077 if(table->getView().isEntryInGroup(row, linkIndex, linkInitId))
3078 xmlOut.addTextElementToData(
"groupMember",
3079 table->getView().getDataView()[row][col]);
3084 __SUP_SS__ <<
"Unrecognized linkIdType '" << linkIdType <<
".'" << __E__;
3088 catch(std::runtime_error& e)
3090 __SUP_SS__ <<
"Error detected saving tree node!\n\n " << e.what() << __E__;
3091 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
3092 xmlOut.addTextElementToData(
"Error", ss.str());
3096 __SUP_SS__ <<
"Error detected saving tree node!\n\n " << __E__;
3097 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
3098 xmlOut.addTextElementToData(
"Error", ss.str());
3103 void ConfigurationGUISupervisor::handleMergeGroupsXML(
3104 HttpXmlDocument& xmlOut,
3105 ConfigurationManagerRW* cfgMgr,
3106 const std::string& groupANameContext,
3107 const TableGroupKey& groupAKeyContext,
3108 const std::string& groupBNameContext,
3109 const TableGroupKey& groupBKeyContext,
3110 const std::string& groupANameConfig,
3111 const TableGroupKey& groupAKeyConfig,
3112 const std::string& groupBNameConfig,
3113 const TableGroupKey& groupBKeyConfig,
3114 const std::string& author,
3115 const std::string& mergeApproach)
try
3117 __SUP_COUT__ <<
"Merging context group pair " << groupANameContext <<
" ("
3118 << groupAKeyContext <<
") & " << groupBNameContext <<
" ("
3119 << groupBKeyContext <<
") and table group pair " << groupANameConfig
3120 <<
" (" << groupAKeyConfig <<
") & " << groupBNameConfig <<
" ("
3121 << groupBKeyConfig <<
") with approach '" << mergeApproach << __E__;
3137 if(!(mergeApproach ==
"Rename" || mergeApproach ==
"Replace" ||
3138 mergeApproach ==
"Skip"))
3140 __SS__ <<
"Error! Invalid merge approach '" << mergeApproach <<
".'" << __E__;
3144 std::map<std::string , TableVersion > memberMapAContext,
3145 memberMapBContext, memberMapAConfig, memberMapBConfig;
3148 bool skippingContextPair =
false;
3149 bool skippingConfigPair =
false;
3150 if(groupANameContext.size() == 0 || groupANameContext[0] ==
' ' ||
3151 groupBNameContext.size() == 0 || groupBNameContext[0] ==
' ')
3153 skippingContextPair =
true;
3154 __SUP_COUTV__(skippingContextPair);
3156 if(groupANameConfig.size() == 0 || groupANameConfig[0] ==
' ' ||
3157 groupBNameConfig.size() == 0 || groupBNameConfig[0] ==
' ')
3159 skippingConfigPair =
true;
3160 __SUP_COUTV__(skippingConfigPair);
3164 if(!skippingContextPair)
3166 cfgMgr->loadTableGroup(groupANameContext,
3178 __SUP_COUTV__(StringMacros::mapToString(memberMapAContext));
3180 cfgMgr->loadTableGroup(groupBNameContext,
3193 __SUP_COUTV__(StringMacros::mapToString(memberMapBContext));
3197 if(!skippingConfigPair)
3199 cfgMgr->loadTableGroup(groupANameConfig,
3211 __SUP_COUTV__(StringMacros::mapToString(memberMapAConfig));
3213 cfgMgr->loadTableGroup(groupBNameConfig,
3226 __SUP_COUTV__(StringMacros::mapToString(memberMapBConfig));
3234 std::map<std::pair<std::string , std::string >,
3238 std::pair<std::string ,
3239 std::pair<std::string , std::string >>,
3241 groupidConversionMap;
3245 for(
unsigned int i = 0; i < 2; ++i)
3247 if(i == 0 && mergeApproach !=
"Rename")
3251 for(
unsigned int j = 0; j < 2; ++j)
3253 if(j == 0 && skippingContextPair)
3255 __COUT__ <<
"Skipping context pair..." << __E__;
3258 else if(j == 1 && skippingConfigPair)
3260 __COUT__ <<
"Skipping table pair..." << __E__;
3264 std::map<std::string , TableVersion >& memberMapAref =
3265 j == 0 ? memberMapAContext : memberMapAConfig;
3267 std::map<std::string , TableVersion >& memberMapBref =
3268 j == 0 ? memberMapBContext : memberMapBConfig;
3271 __COUT__ <<
"Context pair..." << __E__;
3273 __COUT__ <<
"Table pair..." << __E__;
3275 __COUT__ <<
"Starting member map B scan." << __E__;
3276 for(
const auto bkey : memberMapBref)
3278 __SUP_COUTV__(bkey.first);
3280 if(memberMapAref.find(bkey.first) == memberMapAref.end())
3283 memberMapAref[bkey.first] = bkey.second;
3285 else if(memberMapAref[bkey.first] != bkey.second)
3288 __SUP_COUTV__(memberMapAref[bkey.first]);
3289 __SUP_COUTV__(bkey.second);
3292 TableBase* table = cfgMgr->getTableByName(bkey.first);
3294 __SUP_COUT__ <<
"Got table." << __E__;
3296 TableVersion newVersion = table->mergeViews(
3298 ->getVersionedTableByName(bkey.first,
3299 memberMapAref[bkey.first])
3301 cfgMgr->getVersionedTableByName(bkey.first, bkey.second)
3307 groupidConversionMap,
3310 table->getTableName() ==
3311 ConfigurationManager::
3312 XDAQ_APPLICATION_TABLE_NAME
3318 __SUP_COUTV__(newVersion);
3325 ConfigurationSupervisorBase::saveModifiedVersionXML(
3336 catch(std::runtime_error& e)
3339 <<
"There was an error saving the '"
3340 << table->getTableName()
3341 <<
"' merge result to a persistent table version. "
3342 <<
"Perhaps you can modify this table in one of the "
3343 "groups to resolve this issue, and then re-merge."
3344 << __E__ << e.what();
3348 __SUP_COUTV__(newVersion);
3350 memberMapAref[bkey.first] = newVersion;
3359 if(!skippingContextPair)
3361 __SUP_COUT__ <<
"New context member map complete." << __E__;
3362 __SUP_COUTV__(StringMacros::mapToString(memberMapAContext));
3365 TableGroupKey newKeyContext = cfgMgr->saveNewTableGroup(
3368 "Merger of group " + groupANameContext +
" (" + groupAKeyContext.toString() +
3369 ") and " + groupBNameContext +
" (" + groupBKeyContext.toString() +
").");
3372 xmlOut.addTextElementToData(
"ContextGroupName", groupANameContext);
3373 xmlOut.addTextElementToData(
"ContextGroupKey", newKeyContext.toString());
3375 if(!skippingConfigPair)
3377 __SUP_COUT__ <<
"New table member map complete." << __E__;
3378 __SUP_COUTV__(StringMacros::mapToString(memberMapAConfig));
3381 TableGroupKey newKeyConfig = cfgMgr->saveNewTableGroup(
3384 "Merger of group " + groupANameConfig +
" (" + groupAKeyConfig.toString() +
3385 ") and " + groupBNameConfig +
" (" + groupBKeyConfig.toString() +
").");
3388 xmlOut.addTextElementToData(
"ConfigGroupName", groupANameConfig);
3389 xmlOut.addTextElementToData(
"ConfigGroupKey", newKeyConfig.toString());
3393 catch(std::runtime_error& e)
3395 __SUP_SS__ <<
"Error merging context group pair " << groupANameContext <<
" ("
3396 << groupAKeyContext <<
") & " << groupBNameContext <<
" ("
3397 << groupBKeyContext <<
") and table group pair " << groupANameConfig
3398 <<
" (" << groupAKeyConfig <<
") & " << groupBNameConfig <<
" ("
3399 << groupBKeyConfig <<
") with approach '" << mergeApproach <<
"': \n\n"
3400 << e.what() << __E__;
3401 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
3402 xmlOut.addTextElementToData(
"Error", ss.str());
3406 __SUP_SS__ <<
"Unknown error merging context group pair " << groupANameContext <<
" ("
3407 << groupAKeyContext <<
") & " << groupBNameContext <<
" ("
3408 << groupBKeyContext <<
") and table group pair " << groupANameConfig
3409 <<
" (" << groupAKeyConfig <<
") & " << groupBNameConfig <<
" ("
3410 << groupBKeyConfig <<
") with approach '" << mergeApproach <<
".' \n\n";
3411 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
3412 xmlOut.addTextElementToData(
"Error", ss.str());
3417 void ConfigurationGUISupervisor::handleSavePlanCommandSequenceXML(
3418 HttpXmlDocument& xmlOut,
3419 ConfigurationManagerRW* cfgMgr,
3420 const std::string& groupName,
3421 const TableGroupKey& groupKey,
3422 const std::string& modifiedTables,
3423 const std::string& author,
3424 const std::string& planName,
3425 const std::string& commandString)
try
3427 __MOUT__ <<
"handleSavePlanCommandSequenceXML" << __E__;
3430 setupActiveTablesXML(xmlOut,
3440 TableEditStruct planTable(IterateTable::PLAN_TABLE,
3442 TableEditStruct targetTable(IterateTable::TARGET_TABLE,
3446 std::map<std::string, TableEditStruct> commandTypeToCommandTableMap;
3447 for(
const auto& commandPair : IterateTable::commandToTableMap_)
3448 if(commandPair.second !=
"")
3449 commandTypeToCommandTableMap.emplace(std::pair<std::string, TableEditStruct>(
3450 commandPair.first, TableEditStruct(commandPair.second, cfgMgr)));
3466 std::string groupName = planName +
"-Plan";
3467 __SUP_COUT__ <<
"Handling commands for group " << groupName << __E__;
3469 unsigned int groupIdCol =
3470 planTable.tableView_->findCol(IterateTable::planTableCols_.GroupID_);
3471 unsigned int cmdTypeCol =
3472 planTable.tableView_->findCol(IterateTable::planTableCols_.CommandType_);
3474 unsigned int targetGroupIdCol =
3475 targetTable.tableView_->findCol(IterateTable::targetCols_.GroupID_);
3476 unsigned int targetTableCol =
3477 targetTable.tableView_->findCol(IterateTable::targetCols_.TargetLink_);
3478 unsigned int targetUIDCol =
3479 targetTable.tableView_->findCol(IterateTable::targetCols_.TargetLinkUID_);
3481 std::string groupLinkIndex =
3482 planTable.tableView_->getColumnInfo(groupIdCol).getChildLinkIndex();
3483 __SUP_COUT__ <<
"groupLinkIndex: " << groupLinkIndex << __E__;
3485 std::pair<
unsigned int ,
unsigned int > commandUidLink;
3488 planTable.tableView_->getChildLink(
3489 planTable.tableView_->findCol(IterateTable::planTableCols_.CommandLink_),
3494 unsigned int cmdRow, cmdCol;
3495 std::string targetGroupName;
3499 std::string targetUID, cmdType;
3501 for(
unsigned int row = 0; row < planTable.tableView_->getNumberOfRows();
3504 targetUID = planTable.tableView_
3505 ->getDataView()[row][planTable.tableView_->getColUID()];
3506 __SUP_COUT__ <<
"targetUID: " << targetUID << __E__;
3509 if(planTable.tableView_->isEntryInGroup(row, groupLinkIndex, groupName))
3511 __SUP_COUT__ <<
"Removing." << __E__;
3515 cmdType = planTable.tableView_->getDataView()[row][cmdTypeCol];
3516 if(commandTypeToCommandTableMap.find(cmdType) !=
3517 commandTypeToCommandTableMap
3521 commandTypeToCommandTableMap[cmdType].tableView_->findRow(
3522 commandTypeToCommandTableMap[cmdType]
3523 .tableView_->getColUID(),
3524 planTable.tableView_
3525 ->getDataView()[row][commandUidLink.second]);
3533 commandTypeToCommandTableMap[cmdType].tableView_->findCol(
3534 IterateTable::commandTargetCols_.TargetsLinkGroupID_);
3536 commandTypeToCommandTableMap[cmdType]
3537 .tableView_->getDataView()[cmdRow][cmdCol];
3539 for(
unsigned int trow = 0;
3540 trow < targetTable.tableView_->getNumberOfRows();
3544 if(targetTable.tableView_->isEntryInGroup(
3546 commandTypeToCommandTableMap[cmdType]
3547 .tableView_->getColumnInfo(cmdCol)
3548 .getChildLinkIndex(),
3551 __SUP_COUT__ <<
"Removing target." << __E__;
3553 if(targetTable.tableView_->removeRowFromGroup(
3564 __SUP_COUT__ <<
"No targets." << __E__;
3569 commandTypeToCommandTableMap[cmdType].tableView_->deleteRow(
3572 commandTypeToCommandTableMap[cmdType].modified_ =
true;
3576 if(planTable.tableView_->removeRowFromGroup(
3577 row, groupIdCol, groupName,
true ))
3586 std::vector<IterateTable::Command> commands;
3591 std::istringstream f(commandString);
3592 std::string commandSubString, paramSubString, paramValue;
3594 while(getline(f, commandSubString,
';'))
3597 std::istringstream g(commandSubString);
3600 while(getline(g, paramSubString,
','))
3605 if(paramSubString !=
"type")
3607 __SUP_SS__ <<
"Invalid command sequence" << __E__;
3611 commands.push_back(IterateTable::Command());
3613 getline(g, paramValue,
',');
3616 commands.back().type_ = paramValue;
3620 getline(g, paramValue,
',');
3624 commands.back().params_.emplace(
3625 std::pair<std::string ,
3628 StringMacros::decodeURIComponent(paramValue)));
3637 __SUP_COUT__ <<
"commands size " << commands.size() << __E__;
3644 unsigned int row, tgtRow;
3645 unsigned int targetIndex;
3646 std::string targetStr, cmdUID;
3648 for(
auto& command : commands)
3650 __SUP_COUT__ <<
"command " << command.type_ << __E__;
3651 __SUP_COUT__ <<
"table " << IterateTable::commandToTableMap_.at(command.type_)
3655 row = planTable.tableView_->addRow(
3656 author,
true ,
"planCommand");
3657 planTable.tableView_->addRowToGroup(row, groupIdCol, groupName);
3660 planTable.tableView_->setURIEncodedValue(command.type_, row, cmdTypeCol);
3663 planTable.tableView_->setValueAsString(
3664 "1", row, planTable.tableView_->getColStatus());
3667 if(commandTypeToCommandTableMap.find(command.type_) !=
3668 commandTypeToCommandTableMap.end())
3671 __SUP_COUT__ <<
"table "
3672 << commandTypeToCommandTableMap[command.type_].tableName_
3678 cmdRow = commandTypeToCommandTableMap[command.type_].tableView_->addRow(
3679 author,
true , command.type_ +
"_COMMAND_");
3685 for(
auto& param : command.params_)
3687 __SUP_COUT__ <<
"\t param " << param.first <<
" : " << param.second
3690 if(param.first == IterateTable::targetParams_.Tables_)
3692 __SUP_COUT__ <<
"\t\t found target tables" << __E__;
3693 std::istringstream f(param.second);
3696 while(getline(f, targetStr,
'='))
3698 __SUP_COUT__ <<
"\t\t targetStr = " << targetStr << __E__;
3699 if(!command.targets_.size() ||
3700 command.targets_.back().table_ !=
"")
3702 __SUP_COUT__ <<
"\t\t make targetStr = " << targetStr
3705 command.addTarget();
3706 command.targets_.back().table_ = targetStr;
3709 command.targets_[targetIndex++].table_ = targetStr;
3715 if(param.first == IterateTable::targetParams_.UIDs_)
3717 __SUP_COUT__ <<
"\t\t found target UIDs" << __E__;
3718 std::istringstream f(param.second);
3721 while(getline(f, targetStr,
'='))
3723 __SUP_COUT__ <<
"\t\t targetStr = " << targetStr << __E__;
3724 if(!command.targets_.size() ||
3725 command.targets_.back().UID_ !=
"")
3727 __SUP_COUT__ <<
"\t\t make targetStr = " << targetStr
3730 command.addTarget();
3731 command.targets_.back().UID_ = targetStr;
3734 command.targets_[targetIndex++].UID_ = targetStr;
3740 commandTypeToCommandTableMap[command.type_].tableView_->findCol(
3743 __SUP_COUT__ <<
"param col " << cmdCol << __E__;
3745 commandTypeToCommandTableMap[command.type_]
3746 .tableView_->setURIEncodedValue(param.second, cmdRow, cmdCol);
3750 commandTypeToCommandTableMap[command.type_].tableView_->getDataView()
3751 [cmdRow][commandTypeToCommandTableMap[command.type_]
3752 .tableView_->getColUID()];
3754 if(command.targets_.size())
3758 __SUP_COUT__ <<
"targets found for command UID=" << cmdUID << __E__;
3762 commandTypeToCommandTableMap[command.type_].tableView_->findCol(
3763 IterateTable::commandTargetCols_.TargetsLink_);
3764 commandTypeToCommandTableMap[command.type_]
3765 .tableView_->setValueAsString(
3766 IterateTable::TARGET_TABLE, cmdRow, cmdCol);
3769 commandTypeToCommandTableMap[command.type_].tableView_->findCol(
3770 IterateTable::commandTargetCols_.TargetsLinkGroupID_);
3771 commandTypeToCommandTableMap[command.type_]
3772 .tableView_->setValueAsString(
3773 cmdUID +
"_Targets", cmdRow, cmdCol);
3777 for(
const auto& target : command.targets_)
3779 __SUP_COUT__ << target.table_ <<
" " << target.UID_ << __E__;
3782 tgtRow = targetTable.tableView_->addRow(
3783 author,
true ,
"commandTarget");
3784 targetTable.tableView_->addRowToGroup(
3785 tgtRow, targetGroupIdCol, cmdUID +
"_Targets");
3788 targetTable.tableView_->setValueAsString(
3789 target.table_, tgtRow, targetTableCol);
3792 targetTable.tableView_->setValueAsString(
3793 target.UID_, tgtRow, targetUIDCol);
3798 planTable.tableView_->setValueAsString(
3799 commandTypeToCommandTableMap[command.type_].tableName_,
3801 commandUidLink.first);
3802 planTable.tableView_->setValueAsString(
3803 cmdUID, row, commandUidLink.second);
3805 __SUP_COUT__ <<
"linked to uid = " << cmdUID << __E__;
3807 commandTypeToCommandTableMap[command.type_].modified_ =
true;
3815 planTable.tableView_->print();
3816 planTable.tableView_->init();
3818 __SUP_COUT__ <<
"requestType tables:" << __E__;
3820 for(
auto& modifiedConfig : commandTypeToCommandTableMap)
3822 modifiedConfig.second.tableView_->print();
3823 modifiedConfig.second.tableView_->init();
3826 targetTable.tableView_->print();
3827 targetTable.tableView_->init();
3832 __SUP_COUT__ <<
"Handling command table errors while saving. Erasing all newly "
3838 if(planTable.createdTemporaryVersion_)
3840 __SUP_COUT__ <<
"Erasing temporary version " << planTable.tableName_ <<
"-v"
3841 << planTable.temporaryVersion_ << __E__;
3843 cfgMgr->eraseTemporaryVersion(planTable.tableName_,
3844 planTable.temporaryVersion_);
3847 if(targetTable.createdTemporaryVersion_)
3849 __SUP_COUT__ <<
"Erasing temporary version " << targetTable.tableName_ <<
"-v"
3850 << targetTable.temporaryVersion_ << __E__;
3852 cfgMgr->eraseTemporaryVersion(targetTable.tableName_,
3853 targetTable.temporaryVersion_);
3856 for(
auto& modifiedConfig : commandTypeToCommandTableMap)
3858 if(modifiedConfig.second
3859 .createdTemporaryVersion_)
3861 __SUP_COUT__ <<
"Erasing temporary version "
3862 << modifiedConfig.second.tableName_ <<
"-v"
3863 << modifiedConfig.second.temporaryVersion_ << __E__;
3865 cfgMgr->eraseTemporaryVersion(modifiedConfig.second.tableName_,
3866 modifiedConfig.second.temporaryVersion_);
3877 TableVersion finalVersion = ConfigurationSupervisorBase::saveModifiedVersionXML(
3880 planTable.tableName_,
3881 planTable.originalVersion_,
3884 planTable.temporaryVersion_,
3887 __SUP_COUT__ <<
"Final plan version is " << planTable.tableName_ <<
"-v"
3888 << finalVersion << __E__;
3890 finalVersion = ConfigurationSupervisorBase::saveModifiedVersionXML(
3893 targetTable.tableName_,
3894 targetTable.originalVersion_,
3897 targetTable.temporaryVersion_,
3900 __SUP_COUT__ <<
"Final target version is " << targetTable.tableName_ <<
"-v"
3901 << finalVersion << __E__;
3903 for(
auto& modifiedConfig : commandTypeToCommandTableMap)
3905 if(!modifiedConfig.second.modified_)
3907 if(modifiedConfig.second
3908 .createdTemporaryVersion_)
3910 __SUP_COUT__ <<
"Erasing unmodified temporary version "
3911 << modifiedConfig.second.tableName_ <<
"-v"
3912 << modifiedConfig.second.temporaryVersion_ << __E__;
3914 cfgMgr->eraseTemporaryVersion(modifiedConfig.second.tableName_,
3915 modifiedConfig.second.temporaryVersion_);
3920 finalVersion = ConfigurationSupervisorBase::saveModifiedVersionXML(
3923 modifiedConfig.second.tableName_,
3924 modifiedConfig.second.originalVersion_,
3926 modifiedConfig.second.table_,
3927 modifiedConfig.second.temporaryVersion_,
3930 __SUP_COUT__ <<
"Final version is " << modifiedConfig.second.tableName_ <<
"-v"
3931 << finalVersion << __E__;
3934 handleFillModifiedTablesXML(xmlOut, cfgMgr);
3936 catch(std::runtime_error& e)
3938 __SUP_SS__ <<
"Error detected saving Iteration Plan!\n\n " << e.what() << __E__;
3939 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
3940 xmlOut.addTextElementToData(
"Error", ss.str());
3944 __SUP_SS__ <<
"Error detected saving Iteration Plan!\n\n " << __E__;
3945 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
3946 xmlOut.addTextElementToData(
"Error", ss.str());
3959 void ConfigurationGUISupervisor::handleSaveTreeNodeEditXML(HttpXmlDocument& xmlOut,
3960 ConfigurationManagerRW* cfgMgr,
3961 const std::string& tableName,
3962 TableVersion version,
3963 const std::string& type,
3964 const std::string& uid,
3965 const std::string& colName,
3966 const std::string& newValue,
3967 const std::string& author)
try
3969 __SUP_COUT__ <<
"table " << tableName <<
"(" << version <<
")" << __E__;
3976 TableBase* table = cfgMgr->getTableByName(tableName);
3979 table->setActiveView(version);
3983 if(version.isTemporaryVersion())
3986 __SUP_COUT__ <<
"Failed to find stored version, so attempting to load version: "
3987 << version << __E__;
3988 cfgMgr->getVersionedTableByName(tableName, version);
3991 __SUP_COUT__ <<
"Active version is " << table->getViewVersion() << __E__;
3993 if(version != table->getViewVersion())
3995 __SUP_SS__ <<
"Target table version (" << version
3996 <<
") is not the currently active version (" << table->getViewVersion()
3997 <<
". Try refreshing the tree." << __E__;
4001 unsigned int col = -1;
4002 if(type ==
"uid" || type ==
"delete-uid")
4003 col = table->getView().getColUID();
4004 else if(type ==
"link-UID" || type ==
"link-GroupID" || type ==
"value" ||
4005 type ==
"value-groupid" || type ==
"value-bool" || type ==
"value-bitmap")
4006 col = table->getView().findCol(colName);
4007 else if(type ==
"table" || type ==
"link-comment" || type ==
"table-newGroupRow" ||
4008 type ==
"table-newUIDRow" || type ==
"table-newRow")
4012 __SUP_SS__ <<
"Impossible! Unrecognized edit type: " << type << __E__;
4017 if(type ==
"table" || type ==
"link-comment")
4020 if(table->getView().isURIEncodedCommentTheSame(newValue))
4022 __SUP_SS__ <<
"Comment '" << newValue
4023 <<
"' is the same as the current comment. No need to save change."
4039 TableVersion temporaryVersion = table->createTemporaryView(version);
4041 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion << __E__;
4043 TableView* cfgView = table->getTemporaryView(temporaryVersion);
4050 if(type ==
"table" || type ==
"link-comment")
4053 cfgView->setURIEncodedComment(newValue);
4055 else if(type ==
"table-newRow" || type ==
"table-newUIDRow")
4058 unsigned int row = cfgView->addRow(author,
true );
4063 col = cfgView->getColStatus();
4064 cfgView->setValueAsString(
"1", row, col);
4071 cfgView->setURIEncodedValue(newValue, row, cfgView->getColUID());
4073 else if(type ==
"table-newGroupRow")
4076 unsigned int row = cfgView->addRow(author,
true );
4079 unsigned int csvIndex = newValue.find(
',');
4081 std::string linkIndex = newValue.substr(0, csvIndex);
4082 std::string groupId = newValue.substr(csvIndex + 1);
4085 csvIndex = groupId.find(
',');
4086 std::string newRowUID = groupId.substr(csvIndex + 1);
4087 groupId = groupId.substr(0, csvIndex);
4089 __SUP_COUT__ <<
"newValue " << linkIndex <<
"," << groupId <<
"," << newRowUID
4093 cfgView->setURIEncodedValue(newRowUID, row, cfgView->getColUID());
4096 col = cfgView->getColLinkGroupID(linkIndex);
4099 cfgView->setURIEncodedValue(groupId, row, col);
4104 col = cfgView->getColStatus();
4105 cfgView->setValueAsString(
"1", row, col);
4111 else if(type ==
"delete-uid")
4114 unsigned int row = cfgView->findRow(col, uid);
4115 cfgView->deleteRow(row);
4117 else if(type ==
"uid" || type ==
"value" || type ==
"value-groupid" ||
4118 type ==
"value-bool" || type ==
"value-bitmap")
4120 unsigned int row = cfgView->findRow(cfgView->getColUID(), uid);
4121 if(!cfgView->setURIEncodedValue(newValue, row, col, author))
4124 __SUP_SS__ <<
"Value '" << newValue
4125 <<
"' is the same as the current value. No need to save "
4126 "change to tree node."
4131 else if(type ==
"link-UID" || type ==
"link-GroupID")
4134 std::pair<
unsigned int ,
unsigned int > linkPair;
4135 if(!cfgView->getChildLink(col, isGroup, linkPair))
4138 __SUP_SS__ <<
"Col '" << colName <<
"' is not a link column." << __E__;
4142 __SUP_COUT__ <<
"linkPair " << linkPair.first <<
"," << linkPair.second
4145 std::string linkIndex = cfgView->getColumnInfo(col).getChildLinkIndex();
4147 __SUP_COUT__ <<
"linkIndex " << linkIndex << __E__;
4150 unsigned int csvIndexStart = 0, csvIndex = newValue.find(
',');
4152 std::string newTable = newValue.substr(csvIndexStart, csvIndex);
4153 csvIndexStart = csvIndex + 1;
4154 csvIndex = newValue.find(
',', csvIndexStart);
4155 std::string newLinkId = newValue.substr(
4160 __SUP_COUT__ <<
"newValue " << newTable <<
"," << newLinkId << __E__;
4163 unsigned int row = cfgView->findRow(cfgView->getColUID(), uid);
4164 bool changed =
false;
4165 if(!cfgView->setURIEncodedValue(newTable, row, linkPair.first, author))
4168 __SUP_COUT__ <<
"Value '" << newTable
4169 <<
"' is the same as the current value." << __E__;
4174 if(!cfgView->setURIEncodedValue(newLinkId, row, linkPair.second, author))
4177 __SUP_COUT__ <<
"Value '" << newLinkId
4178 <<
"' is the same as the current value." << __E__;
4186 if(type ==
"link-GroupID")
4188 bool secondaryChanged =
false;
4193 __SUP_COUT__ <<
"No changes to primary view. Erasing temporary table."
4195 table->eraseView(temporaryVersion);
4203 ConfigurationSupervisorBase::saveModifiedVersionXML(
4216 catch(std::runtime_error&
4219 __SUP_COUT__ <<
"Caught error while editing main table. Erasing "
4220 "temporary version."
4222 table->eraseView(temporaryVersion);
4226 xmlOut.addTextElementToData(
4228 "Error saving primary tree node! " + std::string(e.what()));
4238 csvIndexStart = csvIndex + 1;
4239 csvIndex = newValue.find(
',', csvIndexStart);
4240 version = TableVersion(newValue.substr(
4241 csvIndexStart, csvIndex - csvIndexStart));
4244 if(newTable == TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
4252 table = cfgMgr->getTableByName(newTable);
4255 table->setActiveView(version);
4259 __SUP_COUT__ <<
"Failed to find stored version, so attempting to "
4261 << version << __E__;
4262 cfgMgr->getVersionedTableByName(newTable, version);
4265 __SUP_COUT__ <<
"Active version is " << table->getViewVersion() << __E__;
4267 if(version != table->getViewVersion())
4269 __SUP_SS__ <<
"Target table version (" << version
4270 <<
") is not the currently active version ("
4271 << table->getViewVersion() <<
". Try refreshing the tree."
4277 temporaryVersion = table->createTemporaryView(version);
4279 __SUP_COUT__ <<
"Created temporary version " << temporaryVersion << __E__;
4281 cfgView = table->getTemporaryView(temporaryVersion);
4284 col = cfgView->getColLinkGroupID(linkIndex);
4286 __SUP_COUT__ <<
"target col " << col << __E__;
4289 std::vector<std::string> memberUIDs;
4292 csvIndexStart = csvIndex + 1;
4293 csvIndex = newValue.find(
',', csvIndexStart);
4294 memberUIDs.push_back(
4295 newValue.substr(csvIndexStart, csvIndex - csvIndexStart));
4296 __SUP_COUT__ <<
"memberUIDs: " << memberUIDs.back() << __E__;
4297 }
while(csvIndex != (
unsigned int)std::string::npos);
4307 std::string targetUID;
4308 bool shouldBeInGroup;
4309 bool defaultIsInGroup =
4313 for(
unsigned int row = 0; row < cfgView->getNumberOfRows(); ++row)
4315 targetUID = cfgView->getDataView()[row][cfgView->getColUID()];
4316 __SUP_COUT__ <<
"targetUID: " << targetUID << __E__;
4318 shouldBeInGroup =
false;
4319 for(
unsigned int i = 0; i < memberUIDs.size(); ++i)
4320 if(targetUID == memberUIDs[i])
4323 shouldBeInGroup =
true;
4327 isInGroup = cfgView->isEntryInGroup(row, linkIndex, newLinkId);
4330 if(shouldBeInGroup && !isInGroup)
4332 __SUP_COUT__ <<
"Changed YES: " << row << __E__;
4333 secondaryChanged =
true;
4335 cfgView->addRowToGroup(row, col, newLinkId);
4338 else if(!shouldBeInGroup && isInGroup)
4340 __SUP_COUT__ <<
"Changed NO: " << row << __E__;
4341 secondaryChanged =
true;
4343 cfgView->removeRowFromGroup(row, col, newLinkId);
4345 else if(targetUID ==
4346 cfgView->getDefaultRowValues()[cfgView->getColUID()] &&
4350 defaultIsInGroup =
true;
4355 if(!secondaryChanged)
4358 <<
"No changes to secondary view. Erasing temporary table."
4360 table->eraseView(temporaryVersion);
4368 ConfigurationSupervisorBase::saveModifiedVersionXML(
4381 catch(std::runtime_error&
4384 __SUP_COUT__ <<
"Caught error while editing secondary table. "
4385 "Erasing temporary version."
4387 table->eraseView(temporaryVersion);
4388 secondaryChanged =
false;
4391 xmlOut.addTextElementToData(
4393 "Error saving secondary tree node! " + std::string(e.what()));
4401 if(0 && !changed && !secondaryChanged && !defaultIsInGroup)
4403 __SUP_SS__ <<
"Link to table '" << newTable <<
"', linkID '"
4405 <<
"', and selected group members are the same as the "
4407 <<
"No need to save changes to tree." << __E__;
4413 else if(0 && !changed)
4418 __SUP_SS__ <<
"Link to table '" << newTable <<
"' and linkID '"
4420 <<
"' are the same as the current values. No need to save "
4421 "change to tree node."
4431 __SUP_COUT__ <<
"Caught error while editing. Erasing temporary version." << __E__;
4432 table->eraseView(temporaryVersion);
4436 ConfigurationSupervisorBase::saveModifiedVersionXML(
4446 catch(std::runtime_error& e)
4448 __SUP_SS__ <<
"Error saving tree node! " << e.what() << __E__;
4449 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
4450 xmlOut.addTextElementToData(
"Error", ss.str());
4454 __SUP_SS__ <<
"Unknown Error saving tree node! " << __E__;
4455 __SUP_COUT_ERR__ <<
"\n" << ss.str() << __E__;
4456 xmlOut.addTextElementToData(
"Error", ss.str());
4500 void ConfigurationGUISupervisor::handleGetTableXML(HttpXmlDocument& xmlOut,
4501 ConfigurationManagerRW* cfgMgr,
4502 const std::string& tableName,
4503 TableVersion version,
4504 bool allowIllegalColumns)
try
4506 char tmpIntStr[100];
4507 xercesc::DOMElement *parentEl, *subparentEl;
4509 std::string accumulatedErrors =
"";
4511 __COUTV__(allowIllegalColumns);
4513 if(allowIllegalColumns)
4514 xmlOut.addTextElementToData(
"allowIllegalColumns",
"1");
4516 const std::map<std::string, TableInfo>&
4518 cfgMgr->getAllTableInfo(allowIllegalColumns,
4519 allowIllegalColumns ? &accumulatedErrors : 0,
4522 TableBase* table = cfgMgr->getTableByName(tableName);
4526 xmlOut.addTextElementToData(
"ExistingTableNames",
4527 TableViewColumnInfo::DATATYPE_LINK_DEFAULT);
4528 for(
auto& configPair : allTableInfo)
4530 xmlOut.addTextElementToData(
"ExistingTableNames", configPair.first);
4531 if(configPair.first == tableName &&
4532 configPair.second.versions_.find(version) == configPair.second.versions_.end())
4534 __SUP_COUT__ <<
"Version not found, so using mockup." << __E__;
4535 version = TableVersion();
4539 xmlOut.addTextElementToData(
"TableName", tableName);
4540 xmlOut.addTextElementToData(
"TableDescription",
4541 table->getTableDescription());
4548 std::map<std::string , TableVersion >>
4553 versionAliases = cfgMgr->getVersionAliases();
4554 for(
const auto& aliases : versionAliases)
4555 for(
const auto& alias : aliases.second)
4556 __SUP_COUT__ <<
"ALIAS: " << aliases.first <<
" " << alias.first
4557 <<
" ==> " << alias.second << __E__;
4559 catch(
const std::runtime_error& e)
4561 __SUP_COUT__ <<
"Could not get backbone information for version aliases: "
4562 << e.what() << __E__;
4565 auto tableIterator = versionAliases.find(tableName);
4567 parentEl = xmlOut.addTextElementToData(
"TableVersions",
"");
4568 for(
const TableVersion& v : allTableInfo.at(tableName).versions_)
4571 xmlOut.addTextElementToParent(
"Version", v.toString(), parentEl);
4573 if(tableIterator != versionAliases.end())
4576 for(
const auto& aliasPair : tableIterator->second)
4584 if(v == aliasPair.second)
4586 __SUP_COUT__ <<
"Found Alias " << aliasPair.second <<
" --> "
4587 << aliasPair.first << __E__;
4588 xmlOut.addTextElementToParent(
4589 "VersionAlias", aliasPair.first, subparentEl);
4599 TableView* cfgViewPtr;
4600 if(version.isInvalid())
4602 cfgViewPtr = table->getMockupViewP();
4610 std::string localAccumulatedErrors =
"";
4613 ->getVersionedTableByName(tableName,
4615 allowIllegalColumns ,
4616 &localAccumulatedErrors)
4619 if(localAccumulatedErrors !=
"")
4620 xmlOut.addTextElementToData(
"Error", localAccumulatedErrors);
4622 catch(std::runtime_error& e)
4624 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version " << version
4625 <<
"... defaulting to mock-up! " << __E__;
4626 ss <<
"\n\n...Here is why it failed:\n\n" << e.what() << __E__;
4628 __SUP_COUT_ERR__ <<
"\n" << ss.str();
4629 version = TableVersion();
4630 cfgViewPtr = table->getMockupViewP();
4632 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
4636 __SUP_SS__ <<
"Failed to get table " << tableName <<
" version: " << version
4637 <<
"... defaulting to mock-up! "
4638 <<
"(You may want to try again to see what was partially loaded "
4639 "into cache before failure. "
4640 <<
"If you think, the failure is due to a column name change, "
4641 <<
"you can also try to Copy the failing view to the new column "
4643 <<
"'Copy and Move' functionality.)" << __E__;
4645 __SUP_COUT_ERR__ <<
"\n" << ss.str();
4646 version = TableVersion();
4647 cfgViewPtr = table->getMockupViewP();
4649 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + ss.str());
4652 xmlOut.addTextElementToData(
"TableVersion", version.toString());
4655 xercesc::DOMElement* choicesParentEl;
4656 parentEl = xmlOut.addTextElementToData(
"CurrentVersionColumnHeaders",
"");
4658 std::vector<TableViewColumnInfo> colInfo = cfgViewPtr->getColumnsInfo();
4660 for(
int i = 0; i < (int)colInfo.size(); ++i)
4668 xmlOut.addTextElementToParent(
"ColumnHeader", colInfo[i].getName(), parentEl);
4669 xmlOut.addTextElementToParent(
"ColumnType", colInfo[i].getType(), parentEl);
4670 xmlOut.addTextElementToParent(
4671 "ColumnDataType", colInfo[i].getDataType(), parentEl);
4673 choicesParentEl = xmlOut.addTextElementToParent(
"ColumnChoices",
"", parentEl);
4675 if(colInfo[i].getType() == TableViewColumnInfo::TYPE_FIXED_CHOICE_DATA ||
4676 colInfo[i].getType() == TableViewColumnInfo::TYPE_BITMAP_DATA ||
4677 colInfo[i].isChildLink())
4679 for(
auto& choice : colInfo[i].getDataChoices())
4680 xmlOut.addTextElementToParent(
"ColumnChoice", choice, choicesParentEl);
4687 if(version.isInvalid())
4690 catch(std::runtime_error& e)
4693 __THROW__(e.what() + std::string(
"\n\n") + accumulatedErrors);
4700 parentEl = xmlOut.addTextElementToData(
"CurrentVersionRows",
"");
4702 for(
int r = 0; r < (int)cfgViewPtr->getNumberOfRows(); ++r)
4706 sprintf(tmpIntStr,
"%d", r);
4707 xercesc::DOMElement* tmpParentEl =
4708 xmlOut.addTextElementToParent(
"Row", tmpIntStr, parentEl);
4710 for(
int c = 0; c < (int)cfgViewPtr->getNumberOfColumns(); ++c)
4712 if(colInfo[c].getDataType() == TableViewColumnInfo::DATATYPE_TIME)
4714 std::string timeAsString;
4715 cfgViewPtr->getValue(timeAsString, r, c);
4716 xmlOut.addTextElementToParent(
"Entry", timeAsString, tmpParentEl);
4719 xmlOut.addTextElementToParent(
4720 "Entry", cfgViewPtr->getDataView()[r][c], tmpParentEl);
4725 xmlOut.addTextElementToData(
"TableComment", cfgViewPtr->getComment());
4726 xmlOut.addTextElementToData(
"TableAuthor", cfgViewPtr->getAuthor());
4727 xmlOut.addTextElementToData(
"TableCreationTime",
4728 std::to_string(cfgViewPtr->getCreationTime()));
4729 xmlOut.addTextElementToData(
"TableLastAccessTime",
4730 std::to_string(cfgViewPtr->getLastAccessTime()));
4733 std::vector<std::string> defaultRowValues = cfgViewPtr->getDefaultRowValues();
4735 for(
unsigned int c = 0; c < defaultRowValues.size() - 2; ++c)
4740 xmlOut.addTextElementToData(
"DefaultRowValue", defaultRowValues[c]);
4743 if(accumulatedErrors !=
"")
4745 __SUP_SS__ << (std::string(
"Column errors were allowed for this request, so "
4746 "maybe you can ignore this, ") +
4747 "but please note the following errors:\n" + accumulatedErrors)
4749 __SUP_COUT_ERR__ << ss.str();
4750 xmlOut.addTextElementToData(
"Error", ss.str());
4752 else if(!version.isTemporaryVersion() &&
4754 (cfgViewPtr->getDataColumnSize() != cfgViewPtr->getNumberOfColumns() ||
4755 cfgViewPtr->getSourceColumnMismatch() !=
4758 __SUP_SS__ <<
"\n\nThere were warnings found when loading the table " << tableName
4759 <<
":v" << version <<
". Please see the details below:\n\n"
4760 <<
"The source column size was found to be "
4761 << cfgViewPtr->getDataColumnSize()
4762 <<
", and the current number of columns for this table is "
4763 << cfgViewPtr->getNumberOfColumns() <<
". This resulted in a count of "
4764 << cfgViewPtr->getSourceColumnMismatch()
4765 <<
" source column mismatches, and a count of "
4766 << cfgViewPtr->getSourceColumnMissing() <<
" table entries missing in "
4767 << cfgViewPtr->getNumberOfRows() <<
" row(s) of data." << __E__;
4769 const std::set<std::string> srcColNames = cfgViewPtr->getSourceColumnNames();
4770 ss <<
"\n\nSource column names in ALPHABETICAL order were as follows:\n";
4772 std::string preIndexStr =
"";
4773 for(
auto& srcColName : srcColNames)
4775 ss <<
"\n\t" << preIndexStr << index <<
". " << srcColName;
4786 std::set<std::string> destColNames = cfgViewPtr->getColumnStorageNames();
4787 ss <<
"\n\nCurrent table column names in ALPHABETICAL order are as follows:\n";
4790 for(
auto& destColName : destColNames)
4792 ss <<
"\n\t" << preIndexStr << index <<
". " << destColName;
4803 __SUP_COUT__ <<
"\n" << ss.str();
4804 xmlOut.addTextElementToData(
"TableWarnings", ss.str());
4808 catch(std::runtime_error& e)
4810 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
4811 xmlOut.addTextElementToData(
"Error",
"Error getting view! " + std::string(e.what()));
4815 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
4816 xmlOut.addTextElementToData(
"Error",
"Error getting view! ");
4830 ConfigurationManagerRW* ConfigurationGUISupervisor::refreshUserSession(
4831 std::string username, uint64_t activeSessionIndex,
bool refresh)
4834 activeSessionIndex =
4837 std::stringstream ssMapKey;
4838 ssMapKey << username <<
":" << activeSessionIndex;
4839 std::string mapKey = ssMapKey.str();
4840 __SUP_COUT__ <<
"Table Session: " << mapKey
4841 <<
" ... out of size: " << userConfigurationManagers_.size() << __E__;
4843 time_t now = time(0);
4846 if(userConfigurationManagers_.find(mapKey) == userConfigurationManagers_.end())
4848 __SUP_COUT_INFO__ <<
"Creating new Configuration Manager." << __E__;
4849 userConfigurationManagers_[mapKey] =
new ConfigurationManagerRW(username);
4854 userConfigurationManagers_[mapKey]->getAllTableInfo(
4857 else if(userLastUseTime_.find(mapKey) == userLastUseTime_.end())
4859 __SUP_SS__ <<
"Fatal error managing userLastUseTime_!" << __E__;
4860 __SUP_COUT_ERR__ <<
"\n" << ss.str();
4863 else if(refresh || (now - userLastUseTime_[mapKey]) >
4864 CONFIGURATION_MANAGER_REFRESH_THRESHOLD)
4868 __SUP_COUT_INFO__ <<
"Refreshing all table info." << __E__;
4869 userConfigurationManagers_[mapKey]->getAllTableInfo(
true);
4878 userLastUseTime_[mapKey] = now;
4881 for(std::map<std::string, time_t>::iterator it = userLastUseTime_.begin();
4882 it != userLastUseTime_.end();
4884 if(now - it->second > CONFIGURATION_MANAGER_EXPIRATION_TIME)
4886 __SUP_COUT__ << now <<
":" << it->second <<
" = " << now - it->second
4888 delete userConfigurationManagers_[it->first];
4889 if(!(userConfigurationManagers_.erase(it->first)))
4891 __SUP_SS__ <<
"Fatal error erasing configuration manager by key!"
4893 __SUP_COUT_ERR__ <<
"\n" << ss.str();
4896 userLastUseTime_.erase(it);
4898 it = userLastUseTime_.begin();
4903 return userConfigurationManagers_[mapKey];
4911 void ConfigurationGUISupervisor::handleDeleteTableInfoXML(HttpXmlDocument& xmlOut,
4912 ConfigurationManagerRW* cfgMgr,
4913 std::string& tableName)
4915 if(0 == rename((TABLE_INFO_PATH + tableName + TABLE_INFO_EXT).c_str(),
4916 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused").c_str()))
4917 __SUP_COUT_INFO__ << (
"Table Info File successfully renamed: " +
4918 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused"))
4922 __SUP_COUT_ERR__ << (
"Error renaming file to " +
4923 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused"))
4926 xmlOut.addTextElementToData(
4928 (
"Error renaming Table Info File to " +
4929 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused")));
4934 cfgMgr->getAllTableInfo(
true);
4944 void ConfigurationGUISupervisor::handleSaveTableInfoXML(
4945 HttpXmlDocument& xmlOut,
4946 ConfigurationManagerRW* cfgMgr,
4947 std::string& tableName,
4948 const std::string& data,
4949 const std::string& tableDescription,
4950 const std::string& columnChoicesCSV,
4951 bool allowOverwrite)
4955 std::string capsName;
4958 capsName = TableBase::convertToCaps(tableName,
true);
4960 catch(std::runtime_error& e)
4962 xmlOut.addTextElementToData(
"Error", e.what());
4968 FILE* fp = fopen((TABLE_INFO_PATH + tableName + TABLE_INFO_EXT).c_str(),
"r");
4972 xmlOut.addTextElementToData(
"TableName", tableName);
4973 xmlOut.addTextElementToData(
"OverwriteError",
"1");
4974 xmlOut.addTextElementToData(
4976 "File already exists! ('" +
4977 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT) +
"')");
4982 __SUP_COUT__ <<
"capsName=" << capsName << __E__;
4983 __SUP_COUT__ <<
"tableName=" << tableName << __E__;
4984 __SUP_COUT__ <<
"tableDescription=" << tableDescription << __E__;
4985 __SUP_COUT__ <<
"columnChoicesCSV=" << columnChoicesCSV << __E__;
4988 std::stringstream outss;
4990 outss <<
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n";
4991 outss <<
"\t<ROOT xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
4992 "xsi:noNamespaceSchemaLocation=\"TableInfo.xsd\">\n";
4993 outss <<
"\t\t<TABLE Name=\"" << tableName <<
"\">\n";
4994 outss <<
"\t\t\t<VIEW Name=\"" << capsName
4995 <<
"\" Type=\"File,Database,DatabaseTest\" Description=\"" << tableDescription
5001 int j = data.find(
',', i);
5002 int k = data.find(
';', i);
5004 std::istringstream columnChoicesISS(columnChoicesCSV);
5005 std::string columnChoicesString;
5006 std::string columnType;
5008 while(k != (
int)(std::string::npos))
5011 columnType = data.substr(i, j - i);
5012 outss <<
"\t\t\t\t<COLUMN Type=\"";
5013 outss << columnType;
5016 j = data.find(
',', i);
5019 outss <<
"\" \t Name=\"";
5020 capsName = data.substr(i, j - i);
5022 outss <<
"\" \t StorageName=\"";
5026 outss << TableBase::convertToCaps(capsName);
5028 catch(std::runtime_error& e)
5030 xmlOut.addTextElementToData(
"Error",
5031 std::string(
"For column name '") +
5032 data.substr(i, j - i) +
"' - " + e.what());
5037 j = data.find(
',', i);
5040 outss <<
"\" \t DataType=\"";
5041 outss << data.substr(i, k - i);
5044 getline(columnChoicesISS, columnChoicesString,
';');
5046 outss <<
"\" \t DataChoices=\"";
5047 outss << columnChoicesString;
5053 j = data.find(
',', i);
5054 k = data.find(
';', i);
5057 outss <<
"\t\t\t</VIEW>\n";
5058 outss <<
"\t\t</TABLE>\n";
5059 outss <<
"\t</ROOT>\n";
5061 __SUP_COUT__ << outss.str() << __E__;
5063 FILE* fp = fopen((TABLE_INFO_PATH + tableName + TABLE_INFO_EXT).c_str(),
"w");
5066 xmlOut.addTextElementToData(
"Error",
5067 "Failed to open destination Table Info file:" +
5068 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT));
5072 fprintf(fp,
"%s", outss.str().c_str());
5077 std::string accumulatedErrors =
"";
5078 cfgMgr->getAllTableInfo(
true, &accumulatedErrors, tableName);
5081 if(accumulatedErrors !=
"")
5083 __SUP_SS__ << (
"The new version of the '" + tableName +
5084 "' table column info was saved, however errors were detected "
5085 "reading back the table '" +
5086 tableName +
"' after the save attempt:\n\n" + accumulatedErrors)
5089 __SUP_COUT_ERR__ << ss.str() << __E__;
5090 xmlOut.addTextElementToData(
"Error", ss.str());
5102 rename((TABLE_INFO_PATH + tableName + TABLE_INFO_EXT).c_str(),
5103 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused").c_str()))
5105 << (
"File successfully renamed: " +
5106 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused"))
5111 << (
"Error renaming file to " +
5112 (TABLE_INFO_PATH + tableName + TABLE_INFO_EXT +
".unused"))
5116 cfgMgr->getAllTableInfo(
true);
5122 handleGetTableXML(xmlOut, cfgMgr, tableName, TableVersion());
5126 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->getAllTableInfo();
5129 __SUP_COUT_INFO__ <<
"Looking for errors in all table column info..." << __E__;
5130 for(
const auto& cfgInfo : allTableInfo)
5134 cfgMgr->getTableByName(cfgInfo.first)->getMockupViewP()->init();
5136 catch(std::runtime_error& e)
5138 __SUP_COUT_WARN__ <<
"\n\n##############################################\n"
5139 <<
"Error identified in column info of table '"
5140 << cfgInfo.first <<
"':\n\n"
5141 << e.what() <<
"\n\n"
5155 void ConfigurationGUISupervisor::handleSetGroupAliasInBackboneXML(
5156 HttpXmlDocument& xmlOut,
5157 ConfigurationManagerRW* cfgMgr,
5158 const std::string& groupAlias,
5159 const std::string& groupName,
5160 TableGroupKey groupKey,
5161 const std::string& author)
try
5163 cfgMgr->loadConfigurationBackbone();
5164 std::map<std::string, TableVersion> activeVersions = cfgMgr->getActiveVersions();
5166 const std::string groupAliasesTableName =
5167 ConfigurationManager::GROUP_ALIASES_TABLE_NAME;
5168 if(activeVersions.find(groupAliasesTableName) == activeVersions.end())
5170 __SUP_SS__ <<
"Active version of " << groupAliasesTableName <<
" missing!"
5172 xmlOut.addTextElementToData(
"Error", ss.str());
5177 const std::set<std::string> backboneMembers = cfgMgr->getBackboneMemberNames();
5178 for(
auto& memberName : backboneMembers)
5180 __SUP_COUT__ <<
"activeVersions[\"" << memberName
5181 <<
"\"]=" << activeVersions[memberName] << __E__;
5183 xmlOut.addTextElementToData(
"oldBackboneName", memberName);
5184 xmlOut.addTextElementToData(
"oldBackboneVersion",
5185 activeVersions[memberName].toString());
5192 TableBase* table = cfgMgr->getTableByName(groupAliasesTableName);
5193 TableVersion originalVersion = activeVersions[groupAliasesTableName];
5194 TableVersion temporaryVersion = table->createTemporaryView(originalVersion);
5196 __SUP_COUT__ <<
"\t\t temporaryVersion: " << temporaryVersion << __E__;
5197 bool isDifferent =
false;
5201 TableView* configView = table->getTemporaryView(temporaryVersion);
5203 unsigned int col = configView->findCol(
"GroupKeyAlias");
5207 unsigned int row = -1;
5211 row = configView->findRow(col, groupAlias);
5216 if(row == (
unsigned int)-1)
5219 row = configView->addRow();
5222 col = configView->findCol(TableViewColumnInfo::COL_NAME_COMMENT);
5223 configView->setValue(
5224 "This Group Alias was automatically setup by the server.", row, col);
5225 col = configView->findCol(
"GroupKeyAlias");
5226 configView->setValue(groupAlias, row, col);
5229 __SUP_COUT__ <<
"\t\t row: " << row << __E__;
5231 col = configView->findCol(
"GroupName");
5233 __SUP_COUT__ <<
"\t\t groupName: " << groupName <<
" vs "
5234 << configView->getDataView()[row][col] << __E__;
5235 if(groupName != configView->getDataView()[row][col])
5237 configView->setValue(groupName, row, col);
5241 col = configView->findCol(
"GroupKey");
5242 __SUP_COUT__ <<
"\t\t groupKey: " << groupKey <<
" vs "
5243 << configView->getDataView()[row][col] << __E__;
5244 if(groupKey.toString() != configView->getDataView()[row][col])
5246 configView->setValue(groupKey.toString(), row, col);
5252 configView->setValue(author, row, configView->findCol(
"Author"));
5253 configView->setValue(
5254 time(0), row, configView->findCol(
"RecordInsertionTime"));
5259 __SUP_COUT_ERR__ <<
"Error editing Group Alias view!" << __E__;
5262 table->eraseView(temporaryVersion);
5266 TableVersion newAssignedVersion;
5269 __SUP_COUT__ <<
"\t\t**************************** Save as new table version"
5277 newAssignedVersion = ConfigurationSupervisorBase::saveModifiedVersionXML(
5280 table->getTableName(),
5291 <<
"\t\t**************************** Using the existing table version"
5295 table->eraseView(temporaryVersion);
5296 newAssignedVersion = activeVersions[groupAliasesTableName];
5298 xmlOut.addTextElementToData(
"savedName", groupAliasesTableName);
5299 xmlOut.addTextElementToData(
"savedVersion", newAssignedVersion.toString());
5302 __SUP_COUT__ <<
"\t\t newAssignedVersion: " << newAssignedVersion << __E__;
5304 catch(std::runtime_error& e)
5306 __SUP_COUT_ERR__ <<
"Error detected!\n\n " << e.what() << __E__;
5307 xmlOut.addTextElementToData(
5308 "Error",
"Error saving new Group Alias view!\n " + std::string(e.what()));
5312 __SUP_COUT_ERR__ <<
"Error detected!\n\n " << __E__;
5313 xmlOut.addTextElementToData(
"Error",
"Error saving new Group Alias view! ");
5324 void ConfigurationGUISupervisor::handleSetVersionAliasInBackboneXML(
5325 HttpXmlDocument& xmlOut,
5326 ConfigurationManagerRW* cfgMgr,
5327 const std::string& versionAlias,
5328 const std::string& tableName,
5329 TableVersion version,
5330 const std::string& author)
try
5332 cfgMgr->loadConfigurationBackbone();
5333 std::map<std::string, TableVersion> activeVersions = cfgMgr->getActiveVersions();
5335 const std::string versionAliasesTableName =
5336 ConfigurationManager::VERSION_ALIASES_TABLE_NAME;
5337 if(activeVersions.find(versionAliasesTableName) == activeVersions.end())
5339 __SUP_SS__ <<
"Active version of " << versionAliasesTableName <<
" missing!"
5341 xmlOut.addTextElementToData(
"Error", ss.str());
5346 const std::set<std::string> backboneMembers = cfgMgr->getBackboneMemberNames();
5347 for(
auto& memberName : backboneMembers)
5349 __SUP_COUT__ <<
"activeVersions[\"" << memberName
5350 <<
"\"]=" << activeVersions[memberName] << __E__;
5352 xmlOut.addTextElementToData(
"oldBackboneName", memberName);
5353 xmlOut.addTextElementToData(
"oldBackboneVersion",
5354 activeVersions[memberName].toString());
5361 TableBase* table = cfgMgr->getTableByName(versionAliasesTableName);
5362 TableVersion originalVersion = activeVersions[versionAliasesTableName];
5363 TableVersion temporaryVersion = table->createTemporaryView(originalVersion);
5365 __SUP_COUT__ <<
"\t\t temporaryVersion: " << temporaryVersion << __E__;
5367 bool isDifferent =
false;
5371 TableView* configView = table->getTemporaryView(temporaryVersion);
5374 unsigned int col2 = configView->findCol(
"VersionAlias");
5375 unsigned int col3 = configView->findCol(
"TableName");
5379 unsigned int row = -1;
5384 unsigned int tmpRow = -1;
5387 tmpRow = configView->findRow(col3, tableName, tmpRow + 1);
5388 }
while(configView->getDataView()[tmpRow][col2] != versionAlias);
5395 if(row == (
unsigned int)-1)
5398 row = configView->addRow();
5401 col = configView->findCol(TableViewColumnInfo::COL_NAME_COMMENT);
5402 configView->setValue(
5403 std::string(
"Entry was added by server in ") +
5404 "ConfigurationGUISupervisor::setVersionAliasInActiveBackbone().",
5408 col = configView->findCol(
"VersionAliasUID");
5409 configView->setValue(
5410 tableName.substr(0, tableName.rfind(
"Table")) + versionAlias, row, col);
5412 configView->setValue(versionAlias, row, col2);
5413 configView->setValue(tableName, row, col3);
5416 __SUP_COUT__ <<
"\t\t row: " << row << __E__;
5418 col = configView->findCol(
"Version");
5419 __SUP_COUT__ <<
"\t\t version: " << version <<
" vs "
5420 << configView->getDataView()[row][col] << __E__;
5421 if(version.toString() != configView->getDataView()[row][col])
5423 configView->setValue(version.toString(), row, col);
5429 configView->setValue(author, row, configView->findCol(
"Author"));
5430 configView->setValue(
5431 time(0), row, configView->findCol(
"RecordInsertionTime"));
5436 __SUP_COUT_ERR__ <<
"Error editing Version Alias view!" << __E__;
5439 table->eraseView(temporaryVersion);
5443 TableVersion newAssignedVersion;
5446 __SUP_COUT__ <<
"\t\t**************************** Save as new table version"
5452 newAssignedVersion = ConfigurationSupervisorBase::saveModifiedVersionXML(
5455 table->getTableName(),
5465 __SUP_COUT__ <<
"\t\t**************************** Using existing table version"
5469 table->eraseView(temporaryVersion);
5470 newAssignedVersion = activeVersions[versionAliasesTableName];
5472 xmlOut.addTextElementToData(
"savedName", versionAliasesTableName);
5473 xmlOut.addTextElementToData(
"savedVersion", newAssignedVersion.toString());
5476 __SUP_COUT__ <<
"\t\t newAssignedVersion: " << newAssignedVersion << __E__;
5478 catch(std::runtime_error& e)
5480 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
5481 xmlOut.addTextElementToData(
5482 "Error",
"Error saving new Version Alias view!\n " + std::string(e.what()));
5486 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
5487 xmlOut.addTextElementToData(
"Error",
"Error saving new Version Alias view! ");
5496 void ConfigurationGUISupervisor::handleAliasGroupMembersInBackboneXML(
5497 HttpXmlDocument& xmlOut,
5498 ConfigurationManagerRW* cfgMgr,
5499 const std::string& versionAlias,
5500 const std::string& groupName,
5501 TableGroupKey groupKey,
5502 const std::string& author)
try
5504 cfgMgr->loadConfigurationBackbone();
5505 std::map<std::string, TableVersion> activeVersions = cfgMgr->getActiveVersions();
5507 const std::string versionAliasesTableName =
5508 ConfigurationManager::VERSION_ALIASES_TABLE_NAME;
5509 if(activeVersions.find(versionAliasesTableName) == activeVersions.end())
5511 __SUP_SS__ <<
"Active version of " << versionAliasesTableName <<
" missing!"
5513 xmlOut.addTextElementToData(
"Error", ss.str());
5518 const std::set<std::string> backboneMembers = cfgMgr->getBackboneMemberNames();
5519 for(
auto& memberName : backboneMembers)
5521 __SUP_COUT__ <<
"activeVersions[\"" << memberName
5522 <<
"\"]=" << activeVersions[memberName] << __E__;
5524 xmlOut.addTextElementToData(
"oldBackboneName", memberName);
5525 xmlOut.addTextElementToData(
"oldBackboneVersion",
5526 activeVersions[memberName].toString());
5533 TableBase* table = cfgMgr->getTableByName(versionAliasesTableName);
5534 TableVersion temporaryVersion =
5535 table->createTemporaryView(activeVersions[versionAliasesTableName]);
5537 __SUP_COUT__ <<
"\t\t temporaryVersion: " << temporaryVersion << __E__;
5539 TableView* configView = table->getTemporaryView(temporaryVersion);
5542 bool isDifferent =
false;
5545 std::map<std::string , TableVersion > memberMap;
5548 cfgMgr->loadTableGroup(groupName,
5561 xmlOut.addTextElementToData(
5563 "Table group \"" + TableGroupKey::getFullGroupString(groupName, groupKey) +
5564 "\" can not be retrieved!");
5569 unsigned int col2 = configView->findCol(
"VersionAlias");
5570 unsigned int col3 = configView->findCol(
"TableName");
5572 for(
auto& memberPair : memberMap)
5574 bool thisMemberIsDifferent =
false;
5575 unsigned int row = -1;
5577 __SUP_COUT__ <<
"Adding alias for " << memberPair.first <<
"_v"
5578 << memberPair.second <<
" to " << versionAlias << __E__;
5584 unsigned int tmpRow = -1;
5587 tmpRow = configView->findRow(col3, memberPair.first, tmpRow + 1);
5590 }
while(configView->getDataView()[tmpRow][col2] != versionAlias);
5597 if(row == (
unsigned int)-1)
5599 thisMemberIsDifferent =
true;
5600 row = configView->addRow();
5603 col = configView->findCol(TableViewColumnInfo::COL_NAME_COMMENT);
5604 configView->setValue(
5605 std::string(
"Entry was added by server in ") +
5606 "ConfigurationGUISupervisor::setVersionAliasInActiveBackbone().",
5610 col = configView->getColUID();
5611 configView->setValue(
5612 memberPair.first.substr(0, memberPair.first.rfind(
"Table")) +
5617 configView->setValue(versionAlias, row, col2);
5618 configView->setValue(memberPair.first, row, col3);
5623 col = configView->findCol(
"Version");
5627 if(memberPair.second.toString() != configView->getDataView()[row][col])
5629 configView->setValue(memberPair.second.toString(), row, col);
5630 thisMemberIsDifferent =
true;
5633 if(thisMemberIsDifferent)
5635 configView->setValue(author, row, configView->findCol(
"Author"));
5636 configView->setValue(
5637 time(0), row, configView->findCol(
"RecordInsertionTime"));
5640 if(thisMemberIsDifferent)
5646 TableVersion newAssignedVersion;
5649 __SUP_COUT__ <<
"\t\t**************************** Save v" << temporaryVersion
5650 <<
" as new table version" << __E__;
5652 newAssignedVersion =
5653 cfgMgr->saveNewTable(versionAliasesTableName, temporaryVersion);
5657 __SUP_COUT__ <<
"\t\t**************************** Using existing table version"
5661 table->eraseView(temporaryVersion);
5662 newAssignedVersion = activeVersions[versionAliasesTableName];
5665 xmlOut.addTextElementToData(
"savedName", versionAliasesTableName);
5666 xmlOut.addTextElementToData(
"savedVersion", newAssignedVersion.toString());
5667 __SUP_COUT__ <<
"\t\t Resulting Version: " << newAssignedVersion << __E__;
5669 catch(std::runtime_error& e)
5671 __SUP_COUT__ <<
"Error detected!\n\n " << e.what() << __E__;
5672 xmlOut.addTextElementToData(
5673 "Error",
"Error saving new Version Alias view!\n " + std::string(e.what()));
5677 __SUP_COUT__ <<
"Error detected!\n\n " << __E__;
5678 xmlOut.addTextElementToData(
"Error",
"Error saving new Version Alias view! ");
5692 void ConfigurationGUISupervisor::handleGroupAliasesXML(HttpXmlDocument& xmlOut,
5693 ConfigurationManagerRW* cfgMgr)
5695 cfgMgr->loadConfigurationBackbone();
5696 std::map<std::string, TableVersion> activeVersions = cfgMgr->getActiveVersions();
5698 std::string groupAliasesTableName = ConfigurationManager::GROUP_ALIASES_TABLE_NAME;
5699 if(activeVersions.find(groupAliasesTableName) == activeVersions.end())
5701 __SUP_SS__ <<
"\nActive version of " << groupAliasesTableName <<
" missing! "
5702 << groupAliasesTableName
5703 <<
" is a required member of the Backbone table group."
5704 <<
"\n\nLikely you need to activate a valid Backbone table group."
5706 xmlOut.addTextElementToData(
"Error", ss.str());
5709 __SUP_COUT__ <<
"activeVersions[\"" << groupAliasesTableName
5710 <<
"\"]=" << activeVersions[groupAliasesTableName] << __E__;
5711 xmlOut.addTextElementToData(
"GroupAliasesTableName", groupAliasesTableName);
5712 xmlOut.addTextElementToData(
"GroupAliasesTableVersion",
5713 activeVersions[groupAliasesTableName].toString());
5715 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
5716 cfgMgr->getNode(groupAliasesTableName).getChildren();
5718 std::string groupName, groupKey, groupComment, groupType;
5719 for(
auto& aliasNodePair : aliasNodePairs)
5721 groupName = aliasNodePair.second.getNode(
"GroupName").getValueAsString();
5722 groupKey = aliasNodePair.second.getNode(
"GroupKey").getValueAsString();
5724 xmlOut.addTextElementToData(
"GroupAlias", aliasNodePair.first);
5725 xmlOut.addTextElementToData(
"GroupName", groupName);
5726 xmlOut.addTextElementToData(
"GroupKey", groupKey);
5727 xmlOut.addTextElementToData(
5729 aliasNodePair.second.getNode(TableViewColumnInfo::COL_NAME_COMMENT)
5730 .getValueAsString());
5734 groupType =
"Invalid";
5737 cfgMgr->loadTableGroup(groupName,
5738 TableGroupKey(groupKey),
5751 __SUP_COUT_WARN__ <<
"Failed to load group '" << groupName <<
"(" << groupKey
5752 <<
")' to extract group comment and type." << __E__;
5754 xmlOut.addTextElementToData(
"GroupComment", groupComment);
5755 xmlOut.addTextElementToData(
"GroupType", groupType);
5770 void ConfigurationGUISupervisor::handleVersionAliasesXML(HttpXmlDocument& xmlOut,
5771 ConfigurationManagerRW* cfgMgr)
5773 cfgMgr->loadConfigurationBackbone();
5774 std::map<std::string, TableVersion> activeVersions = cfgMgr->getActiveVersions();
5776 std::string versionAliasesTableName =
5777 ConfigurationManager::VERSION_ALIASES_TABLE_NAME;
5778 if(activeVersions.find(versionAliasesTableName) == activeVersions.end())
5780 __SUP_SS__ <<
"Active version of VersionAliases missing!"
5781 <<
"Make sure you have a valid active Backbone Group." << __E__;
5782 xmlOut.addTextElementToData(
"Error", ss.str());
5785 __SUP_COUT__ <<
"activeVersions[\"" << versionAliasesTableName
5786 <<
"\"]=" << activeVersions[versionAliasesTableName] << __E__;
5787 xmlOut.addTextElementToData(
"VersionAliasesVersion",
5788 activeVersions[versionAliasesTableName].toString());
5790 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
5791 cfgMgr->getNode(versionAliasesTableName).getChildren();
5793 for(
auto& aliasNodePair : aliasNodePairs)
5797 xmlOut.addTextElementToData(
5799 aliasNodePair.second.getNode(
"VersionAlias").getValueAsString());
5800 xmlOut.addTextElementToData(
5801 "TableName", aliasNodePair.second.getNode(
"TableName").getValueAsString());
5802 xmlOut.addTextElementToData(
5803 "Version", aliasNodePair.second.getNode(
"Version").getValueAsString());
5804 xmlOut.addTextElementToData(
5806 aliasNodePair.second.getNode(TableViewColumnInfo::COL_NAME_COMMENT)
5807 .getValueAsString());
5817 void ConfigurationGUISupervisor::handleGetTableGroupTypeXML(
5818 HttpXmlDocument& xmlOut, ConfigurationManagerRW* cfgMgr,
const std::string& tableList)
5820 std::map<std::string , TableVersion > memberMap;
5821 std::string name, versionStr;
5822 auto c = tableList.find(
',', 0);
5825 while(c < tableList.length())
5828 name = tableList.substr(i, c - i);
5830 c = tableList.find(
',', i);
5831 if(c == std::string::npos)
5833 __SUP_SS__ <<
"Incomplete Table Name-Version pair!" << __E__;
5834 __SUP_COUT_ERR__ <<
"\n" << ss.str();
5835 xmlOut.addTextElementToData(
"Error", ss.str());
5839 versionStr = tableList.substr(i, c - i);
5841 c = tableList.find(
',', i);
5843 memberMap[name] = TableVersion(versionStr);
5846 std::string groupTypeString =
"";
5851 groupTypeString = cfgMgr->getTypeNameOfGroup(memberMap);
5852 xmlOut.addTextElementToData(
"TableGroupType", groupTypeString);
5854 catch(std::runtime_error& e)
5856 __SUP_SS__ <<
"Table group has invalid type! " << e.what() << __E__;
5857 __SUP_COUT__ <<
"\n" << ss.str();
5858 groupTypeString =
"Invalid";
5859 xmlOut.addTextElementToData(
"TableGroupType", groupTypeString);
5863 __SUP_SS__ <<
"Table group has invalid type! " << __E__;
5864 __SUP_COUT__ <<
"\n" << ss.str();
5865 groupTypeString =
"Invalid";
5866 xmlOut.addTextElementToData(
"TableGroupType", groupTypeString);
5886 void ConfigurationGUISupervisor::handleTableGroupsXML(HttpXmlDocument& xmlOut,
5887 ConfigurationManagerRW* cfgMgr,
5890 xercesc::DOMElement* parentEl;
5894 if(!cfgMgr->getAllGroupInfo()
5897 __SUP_COUT__ <<
"Cache is empty? Attempting to regenerate." << __E__;
5898 cfgMgr->getAllTableInfo(
true );
5901 const std::map<std::string, GroupInfo>& allGroupInfo = cfgMgr->getAllGroupInfo();
5921 TableGroupKey groupKey;
5922 std::string groupName;
5923 std::string groupString, groupTypeString, groupComment, groupCreationTime,
5925 for(
auto& groupInfo : allGroupInfo)
5927 groupName = groupInfo.first;
5928 if(groupInfo.second.keys_.size() == 0)
5930 __SUP_COUT__ <<
"Group name '" << groupName
5931 <<
"' found, but no keys so ignoring." << __E__;
5935 groupKey = *(groupInfo.second.keys_.rbegin());
5937 xmlOut.addTextElementToData(
"TableGroupName", groupName);
5938 xmlOut.addTextElementToData(
"TableGroupKey", groupKey.toString());
5941 xmlOut.addTextElementToData(
"TableGroupType",
5942 groupInfo.second.latestKeyGroupTypeString_);
5943 xmlOut.addTextElementToData(
"TableGroupComment",
5944 groupInfo.second.latestKeyGroupComment_);
5945 xmlOut.addTextElementToData(
"TableGroupAuthor",
5946 groupInfo.second.latestKeyGroupAuthor_);
5947 xmlOut.addTextElementToData(
"TableGroupCreationTime",
5948 groupInfo.second.latestKeyGroupCreationTime_);
5961 parentEl = xmlOut.addTextElementToData(
"TableGroupMembers",
"");
6001 for(
auto& memberPair : groupInfo.second.latestKeyMemberMap_)
6005 xmlOut.addTextElementToParent(
"MemberName", memberPair.first, parentEl);
6006 xmlOut.addTextElementToParent(
6007 "MemberVersion", memberPair.second.toString(), parentEl);
6013 for(
auto& keyInSet : groupInfo.second.keys_)
6015 if(keyInSet == groupKey)
6017 xmlOut.addTextElementToData(
"TableGroupName", groupName);
6018 xmlOut.addTextElementToData(
"TableGroupKey", keyInSet.toString());
6021 xmlOut.addTextElementToData(
"TableGroupType",
6022 groupInfo.second.latestKeyGroupTypeString_);
6023 xmlOut.addTextElementToData(
"TableGroupComment",
6024 groupInfo.second.latestKeyGroupComment_);
6025 xmlOut.addTextElementToData(
"TableGroupAuthor",
6026 groupInfo.second.latestKeyGroupAuthor_);
6027 xmlOut.addTextElementToData(
"TableGroupCreationTime",
6028 groupInfo.second.latestKeyGroupCreationTime_);
6032 xmlOut.addTextElementToData(
"TableGroupMembers",
"");
6035 bool loadingHistoricalInfo =
false;
6036 if(loadingHistoricalInfo)
6041 cfgMgr->loadTableGroup(groupName,
6055 groupTypeString =
"Invalid";
6057 <<
"Failed to load group '" << groupName <<
"(" << keyInSet
6058 <<
")' to extract group comment and type." << __E__;
6061 xmlOut.addTextElementToData(
"TableGroupType", groupTypeString);
6062 xmlOut.addTextElementToData(
"TableGroupComment", groupComment);
6063 xmlOut.addTextElementToData(
"TableGroupAuthor", groupAuthor);
6064 xmlOut.addTextElementToData(
"TableGroupCreationTime",
6085 void ConfigurationGUISupervisor::handleTablesXML(HttpXmlDocument& xmlOut,
6086 ConfigurationManagerRW* cfgMgr,
6087 bool allowIllegalColumns)
6089 xercesc::DOMElement* parentEl;
6091 std::string accumulatedErrors =
"";
6092 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->getAllTableInfo(
6093 allowIllegalColumns,
6094 allowIllegalColumns ? &accumulatedErrors
6096 std::map<std::string, TableInfo>::const_iterator it = allTableInfo.begin();
6098 __SUP_COUT__ <<
"# of tables found: " << allTableInfo.size() << __E__;
6100 std::map<std::string, std::map<std::string, TableVersion>> versionAliases =
6101 cfgMgr->getVersionAliases();
6103 __SUP_COUT__ <<
"# of tables w/aliases: " << versionAliases.size() << __E__;
6105 while(it != allTableInfo.end())
6114 xmlOut.addTextElementToData(
"TableName", it->first);
6115 parentEl = xmlOut.addTextElementToData(
"TableVersions",
"");
6118 if(versionAliases.find(it->first) != versionAliases.end())
6119 for(
auto& aliasVersion : versionAliases[it->first])
6120 if(it->second.versions_.find(aliasVersion.second) !=
6121 it->second.versions_.end())
6125 xmlOut.addTextElementToParent(
6127 ConfigurationManager::ALIAS_VERSION_PREAMBLE + aliasVersion.first,
6145 for(
auto& version : it->second.versions_)
6146 if(!version.isScratchVersion())
6147 xmlOut.addTextElementToParent(
"Version", version.toString(), parentEl);
6152 if(accumulatedErrors !=
"")
6153 xmlOut.addTextElementToData(
6155 std::string(
"Column errors were allowed for this request, ") +
6156 "but please note the following errors:\n" + accumulatedErrors);
6166 void ConfigurationGUISupervisor::handleGetArtdaqNodeRecordsXML(
6167 HttpXmlDocument& xmlOut,
6168 ConfigurationManagerRW* cfgMgr,
6169 const std::string& modifiedTables)
6171 __COUT__ <<
"Getting artdaq nodes..." << __E__;
6174 setupActiveTablesXML(xmlOut, cfgMgr,
"", TableGroupKey(-1), modifiedTables);
6176 const XDAQContextTable* contextTable = cfgMgr->__GET_CONFIG__(XDAQContextTable);
6180 std::vector<const XDAQContextTable::XDAQContext*> artdaqContexts[] = {
6181 contextTable->getARTDAQSupervisorContexts()
6185 const ARTDAQTableBase::ARTDAQAppType artdaqProcessTypes[] = {
6186 ARTDAQTableBase::ARTDAQAppType::BoardReader,
6187 ARTDAQTableBase::ARTDAQAppType::EventBuilder,
6188 ARTDAQTableBase::ARTDAQAppType::DataLogger,
6189 ARTDAQTableBase::ARTDAQAppType::Dispatcher
6192 std::string typeString;
6193 for(
unsigned int i = 0; i < 1 ; ++i)
6198 typeString =
"artdaqSupervisor";
6205 __SUP_SS__ <<
"Illegal impossible type!";
6210 __COUT__ << typeString <<
" size = " << artdaqContexts[i].size() << __E__;
6212 for(
auto& artdaqContext : artdaqContexts[i])
6214 __SUP_COUTV__(artdaqContext->contextUID_);
6215 __SUP_COUTV__(artdaqContext->applications_.size());
6217 for(
auto& artdaqApp : artdaqContext->applications_)
6219 __SUP_COUTV__(artdaqApp.applicationUID_);
6222 auto parentEl = xmlOut.addTextElementToData(typeString, artdaqApp.applicationUID_);
6224 xmlOut.addTextElementToParent(typeString +
"-contextAddress",
6225 artdaqContext->address_, parentEl);
6226 xmlOut.addTextElementToParent(typeString +
"-contextPort",
6227 std::to_string(artdaqContext->port_),
6231 ARTDAQTableBase::SubsystemInfo> subsystems;
6232 std::map<ARTDAQTableBase::ARTDAQAppType,
6233 std::list<ARTDAQTableBase::ProcessInfo>> processes;
6235 ARTDAQTableBase::extractArtdaqInfo(
6236 XDAQContextTable::getSupervisorConfigNode(cfgMgr,
6237 artdaqContext->contextUID_,
6238 artdaqApp.applicationUID_),
6243 __SUP_COUT__ <<
"========== " <<
6244 "Found " << subsystems.size() <<
" subsystems." << __E__;
6246 for(
auto& subsystem : subsystems)
6248 const std::string subtypeString =
"subsystem";
6250 __SUP_COUT__ <<
"\t\t" <<
"Found " << subtypeString <<
6251 " " << subsystem.first <<
6252 " \t := '" << subsystem.second.label <<
"'" << __E__;
6254 xmlOut.addTextElementToParent(subtypeString +
"-name",
6255 subsystem.second.label,
6257 xmlOut.addTextElementToParent(subtypeString +
"-id",
6258 std::to_string(subsystem.first),
6262 xmlOut.addTextElementToParent(subtypeString +
"-sourcesCount",
6263 std::to_string(subsystem.second.sources.size()),
6267 xmlOut.addTextElementToParent(subtypeString +
"-destination",
6268 std::to_string(subsystem.second.destination),
6273 __SUP_COUT__ <<
"========== " <<
6274 "Found " << processes.size() <<
" process types." << __E__;
6276 for(
unsigned int i = 0; i < 4 ; ++i)
6278 const std::string& subtypeString = ARTDAQTableBase::getTypeString(
6279 artdaqProcessTypes[i]);
6281 auto it = processes.find(artdaqProcessTypes[i]);
6282 if(it == processes.end())
6284 __SUP_COUT__ <<
"\t" <<
"Found 0 " << subtypeString << __E__;
6287 __SUP_COUT__ <<
"\t" <<
"Found " << it->second.size() <<
" " <<
6288 subtypeString <<
"(s)" << __E__;
6290 for(
auto& artdaqProcess : it->second)
6293 __SUP_COUT__ <<
"\t\t" <<
"Found '" << artdaqProcess.label <<
"' " <<
6294 subtypeString << __E__;
6296 xmlOut.addTextElementToParent(subtypeString +
"-name",
6297 artdaqProcess.label,
6299 xmlOut.addTextElementToParent(subtypeString +
"-hostname",
6300 artdaqProcess.hostname,
6302 xmlOut.addTextElementToParent(subtypeString +
"-subsystem",
6303 std::to_string(artdaqProcess.subsystem),
6313 __SUP_COUT__ <<
"Done getting artdaq nodes." << __E__;
6324 void ConfigurationGUISupervisor::handleLoadArtdaqNodeLayoutXML(
6325 HttpXmlDocument& xmlOut,
6326 ConfigurationManagerRW* cfgMgr,
6327 const std::string& contextGroupName ,
6328 const TableGroupKey& contextGroupKey )
6330 bool usingActiveGroups = (contextGroupName ==
"" || contextGroupKey.isInvalid());
6332 const std::string& finalContextGroupName =
6334 ? cfgMgr->getActiveGroupName(ConfigurationManager::ACTIVE_GROUP_NAME_CONTEXT)
6336 const TableGroupKey& finalContextGroupKey =
6338 ? cfgMgr->getActiveGroupKey(ConfigurationManager::ACTIVE_GROUP_NAME_CONTEXT)
6341 std::stringstream layoutPath;
6342 layoutPath << ARTDAQ_CONFIG_LAYOUTS_PATH << finalContextGroupName <<
"_"
6343 << finalContextGroupKey <<
".dat";
6344 __SUP_COUTV__(layoutPath.str());
6346 FILE* fp = fopen(layoutPath.str().c_str(),
"r");
6349 __SUP_COUT__ <<
"Layout file not found for '" << finalContextGroupName <<
"("
6350 << finalContextGroupKey <<
")'" << __E__;
6358 const size_t maxLineSz = 1000;
6359 char line[maxLineSz];
6360 if(!fgets(line, maxLineSz, fp))
6369 unsigned int rows, cols;
6371 sscanf(line,
"%u %u", &rows, &cols);
6373 __COUT__ <<
"Grid rows,cols = " << rows <<
"," << cols << __E__;
6375 xmlOut.addTextElementToData(
"grid-rows", std::to_string(rows));
6376 xmlOut.addTextElementToData(
"grid-cols", std::to_string(cols));
6379 char name[maxLineSz];
6380 char type[maxLineSz];
6382 while(fgets(line, maxLineSz, fp))
6385 sscanf(line,
"%s %s %u %u", type, name, &x, &y);
6387 xmlOut.addTextElementToData(
"node-type", type);
6388 xmlOut.addTextElementToData(
"node-name", name);
6389 xmlOut.addTextElementToData(
"node-x", std::to_string(x));
6390 xmlOut.addTextElementToData(
"node-y", std::to_string(y));
6404 void ConfigurationGUISupervisor::handleSaveArtdaqNodeLayoutXML(
6405 HttpXmlDocument& xmlOut,
6406 ConfigurationManagerRW* cfgMgr,
6407 const std::string& layoutString,
6408 const std::string& contextGroupName,
6409 const TableGroupKey& contextGroupKey)
6411 bool usingActiveGroups = (contextGroupName ==
"" || contextGroupKey.isInvalid());
6413 const std::string& finalContextGroupName =
6415 ? cfgMgr->getActiveGroupName(ConfigurationManager::ACTIVE_GROUP_NAME_CONTEXT)
6417 const TableGroupKey& finalContextGroupKey =
6419 ? cfgMgr->getActiveGroupKey(ConfigurationManager::ACTIVE_GROUP_NAME_CONTEXT)
6422 __SUP_COUTV__(layoutString);
6424 std::stringstream layoutPath;
6425 layoutPath << ARTDAQ_CONFIG_LAYOUTS_PATH << finalContextGroupName <<
"_"
6426 << finalContextGroupKey <<
".dat";
6427 __SUP_COUTV__(layoutPath.str());
6429 std::vector<std::string> fields = StringMacros::getVectorFromString(layoutString);
6430 __SUP_COUTV__(StringMacros::vectorToString(fields));
6432 if(fields.size() < 2 || (fields.size() - 2) % 4 != 0)
6434 __SUP_SS__ <<
"Invalid layout string fields size of " << fields.size() << __E__;
6438 FILE* fp = fopen(layoutPath.str().c_str(),
"w");
6441 __SUP_SS__ <<
"Could not open layout file for writing for '"
6442 << finalContextGroupName <<
"(" << finalContextGroupKey <<
")'"
6450 fprintf(fp,
"%s %s\n", fields[0].c_str(), fields[1].c_str());
6453 for(
unsigned int i = 2; i < fields.size(); i += 4)
6456 fields[i + 0].c_str(),
6457 fields[i + 1].c_str(),
6458 fields[i + 2].c_str(),
6459 fields[i + 3].c_str());
6468 void ConfigurationGUISupervisor::testXDAQContext()
6472 __SUP_COUT__ <<
"Attempting test activation of the context group." << __E__;
6473 ConfigurationManager cfgMgr;
6475 catch(
const std::runtime_error& e)
6478 <<
"The test activation of the context group failed. Ignoring error: \n"
6479 << e.what() << __E__;
6483 __SUP_COUT_WARN__ <<
"The test activation of the context group failed. Ignoring."
static xdaq::Application * instantiate(xdaq::ApplicationStub *s)