1 #include "otsdaq/CoreSupervisors/ConfigurationSupervisorBase.h"
2 #include "otsdaq/TablePlugins/XDAQContextTable/XDAQContextTable.h"
11 std::map<std::string , std::pair<std::string ,
TableGroupKey>>
14 for(
auto& type : activeGroupMap)
16 xmlOut.addTextElementToData(type.first +
"-ActiveGroupName", type.second.first);
17 xmlOut.addTextElementToData(type.first +
"-ActiveGroupKey",
18 type.second.second.toString());
25 std::string groupAliasesTableName =
26 ConfigurationManager::GROUP_ALIASES_TABLE_NAME;
27 if(activeVersions.find(groupAliasesTableName) != activeVersions.end())
30 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
33 std::string groupName, groupKey, groupComment, groupType;
34 std::string activeGroupName, activeGroupKey;
35 for(
auto& type : activeGroupMap)
37 activeGroupName = type.second.first;
38 activeGroupKey = type.second.second.toString();
39 for(
auto& aliasNodePair : aliasNodePairs)
42 aliasNodePair.second.getNode(
"GroupName").getValueAsString();
44 aliasNodePair.second.getNode(
"GroupKey").getValueAsString();
45 if(groupName == activeGroupName && groupKey == activeGroupKey)
47 xmlOut.addTextElementToData(type.first +
"-ActiveGroupAlias",
58 __COUT__ <<
"Ignoring failure getting alias for active groups" << __E__;
62 xmlOut.addTextElementToData(
64 ConfigurationInterface::isVersionTrackingEnabled() ?
"ON" :
"OFF");
66 xmlOut.addTextElementToData(
"configUsername", username);
80 const std::string& tableName,
83 const std::string& data,
84 const int& dataOffset,
85 const std::string& author,
86 const std::string& comment,
88 bool lookForEquivalent)
112 TableBase* table = cfgMgr->getTableByName(tableName);
121 table->getMockupViewP()->getNumberOfColumns() ||
122 table->getViewP()->getSourceColumnMismatch() != 0)
124 __COUT__ <<
"table->getViewP()->getNumberOfColumns() "
125 << table->getViewP()->getNumberOfColumns() << __E__;
126 __COUT__ <<
"table->getMockupViewP()->getNumberOfColumns() "
127 << table->getMockupViewP()->getNumberOfColumns() << __E__;
128 __COUT__ <<
"table->getViewP()->getSourceColumnMismatch() "
129 << table->getViewP()->getSourceColumnMismatch() << __E__;
131 <<
"Source view v" << version
132 <<
" has a mismatch in the number of columns, so using mockup as source."
138 bool ignoreDuplicates =
false;
140 table->getViewP()->getSourceColumnNames().size() !=
143 __COUT__ <<
"table->getViewP()->getNumberOfColumns() "
144 << table->getViewP()->getNumberOfColumns() << __E__;
145 __COUTV__(table->getViewP()->getSourceColumnNames().size());
147 <<
"Source view v" << version
148 <<
" has a mismatch in the number of columns, so forcing new version saved."
150 ignoreDuplicates =
true;
156 __COUT__ <<
"\t\ttemporaryVersion: " << temporaryVersion << __E__;
169 __COUT__ <<
"Data was the same, but columns have changed!" << __E__;
170 __COUTV__(sourceTableAsIs);
171 __COUTV__(lookForEquivalent);
175 __COUT__ <<
"Table comment was set to:\n\t" << cfgView->getComment() << __E__;
179 __COUT__ <<
"Caught error while editing. Erasing temporary version." << __E__;
180 table->eraseView(temporaryVersion);
191 ConfigurationInterface::isVersionTrackingEnabled())
198 __SS__ <<
"No rows were modified! No reason to fill a view with same content."
200 __COUT_ERR__ <<
"\n" << ss.str();
202 table->eraseView(temporaryVersion);
206 __COUT__ <<
"This was interpreted as an attempt to create a blank table."
209 __COUT__ <<
"This was interpreted as an attempt to make a persistent "
210 "version of the scratch table."
215 __THROW__(ss.str() +
"impossible!");
220 __COUT__ <<
"Allowing the static data because this is converting from "
221 "temporary to persistent version."
224 else if(retVal < 0 && !ConfigurationInterface::isVersionTrackingEnabled())
226 __COUT__ <<
"Allowing the static data because version tracking is OFF." << __E__;
230 __SS__ <<
"This should not be possible! Fatal error." << __E__;
232 table->eraseView(temporaryVersion);
246 lookForEquivalent || sourceTableAsIs );
248 if(ignoreDuplicates && sourceTableAsIs)
250 table = cfgMgr->getTableByName(tableName);
251 table->eraseView(newVersion);
254 catch(std::runtime_error& e)
256 __SS__ <<
"Error saving new table!\n\n " << e.what() << __E__;
257 __COUT__ <<
"\n" << ss.str() << __E__;
258 xmlOut.addTextElementToData(
"Error", ss.str());
262 __SS__ <<
"Error saving new table!" << __E__;
267 catch(
const std::exception& e)
269 ss <<
"Exception message: " << e.what();
274 __COUT__ <<
"\n" << ss.str() << __E__;
275 xmlOut.addTextElementToData(
"Error", ss.str());
286 const std::string& tableName,
291 bool ignoreDuplicates,
292 bool lookForEquivalent)
294 bool foundEquivalent;
300 temporaryModifiedVersion,
305 xmlOut.addTextElementToData(
"savedName", tableName);
306 xmlOut.addTextElementToData(
"savedVersion", newAssignedVersion.
toString());
310 xmlOut.addTextElementToData(
"foundEquivalentVersion",
"1");
311 xmlOut.addTextElementToData(tableName +
"_foundEquivalentVersion",
"1");
313 return newAssignedVersion;
338 const std::string& groupName,
339 const std::string& tableList,
340 bool allowDuplicates,
342 const std::string& groupComment,
343 bool lookForEquivalent)
346 __COUTT__ <<
"handleCreateTableGroupXML start runtime=" << cfgMgr->runTimeSeconds()
349 xmlOut.addTextElementToData(
"AttemptedNewGroupName", groupName);
353 std::string accumulatedWarnings;
354 const std::map<std::string, TableInfo>& allTableInfo =
356 if(!allTableInfo.size())
358 &accumulatedWarnings,
364 __COUT_WARN__ <<
"Ignoring these errors: " << accumulatedWarnings << __E__;
367 __COUTT__ <<
"handleCreateTableGroupXML loaded runtime=" << cfgMgr->runTimeSeconds()
370 std::map<std::string ,
379 std::map<std::string , std::string > memberTableAliases;
381 std::string name, versionStr, alias;
383 auto c = tableList.find(
',', 0);
386 while(c < tableList.length())
389 name = tableList.substr(i, c - i);
391 c = tableList.find(
',', i);
392 if(c == std::string::npos)
394 __SS__ <<
"Incomplete Table Name-Version pair!" << __E__;
395 __COUT_ERR__ <<
"\n" << ss.str();
396 xmlOut.addTextElementToData(
"Error", ss.str());
400 versionStr = tableList.substr(i, c - i);
402 c = tableList.find(
',', i);
408 if(versionStr.find(ConfigurationManager::ALIAS_VERSION_PREAMBLE) == 0)
411 versionStr.substr(ConfigurationManager::ALIAS_VERSION_PREAMBLE.size());
413 __COUT__ <<
"Found alias " << name <<
" " << versionStr << __E__;
416 if(versionAliases.find(name) != versionAliases.end() &&
417 versionAliases[name].find(alias) != versionAliases[name].end())
419 version = versionAliases[name][alias];
420 __COUT__ << name <<
" version alias '" << alias
421 <<
"'translated to: " << version << __E__;
423 memberTableAliases[name] = alias;
427 __SS__ <<
"version alias '"
428 << versionStr.substr(
429 ConfigurationManager::ALIAS_VERSION_PREAMBLE.size())
430 <<
"' was not found in active version aliases! Please check your "
433 __COUT_ERR__ <<
"\n" << ss.str();
434 xmlOut.addTextElementToData(
"Error", ss.str());
443 __SS__ <<
"Groups can not be created using temporary member tables. "
444 <<
"Table member '" << name <<
"' with temporary version '" << version
445 <<
"' is illegal." << __E__;
446 xmlOut.addTextElementToData(
"Error", ss.str());
451 if(allTableInfo.find(name) == allTableInfo.end())
453 __SS__ <<
"Groups can not be created using mock-up member tables of "
455 <<
"Table member '" << name <<
"' is not defined." << __E__;
456 xmlOut.addTextElementToData(
"Error", ss.str());
463 TableBase* table = cfgMgr->getTableByName(name);
466 __COUT__ <<
"\t\ttemporaryVersion: " << temporaryVersion << __E__;
469 __COUT__ <<
"Creating version from mock-up for name: " << name
470 <<
" inputVersionStr: " << versionStr << __E__;
474 ->setComment(
"Auto-generated from mock-up.");
488 __COUT__ <<
"Using mockup version: " << version << __E__;
492 groupMembers[name] = version;
495 __COUTT__ <<
"handleCreateTableGroupXML tables saved runtime="
496 << cfgMgr->runTimeSeconds() << __E__;
502 __COUT__ <<
"Checking for duplicate groups..." << __E__;
506 cfgMgr->
findTableGroup(groupName, groupMembers, memberTableAliases);
507 __COUTT__ <<
"handleCreateTableGroupXML group duplicates checked runtime="
508 << cfgMgr->runTimeSeconds() << __E__;
512 xmlOut.addTextElementToData(
"TableGroupName", groupName);
513 xmlOut.addTextElementToData(
"TableGroupKey", foundKey.
toString());
515 if(lookForEquivalent)
517 __COUT__ <<
"Found equivalent group key (" << foundKey <<
") for "
518 << groupName <<
"." << __E__;
520 xmlOut.addTextElementToData(
"foundEquivalentKey",
"1");
533 __COUT__ <<
"Treating duplicate group as error." << __E__;
534 __SS__ << (
"Failed to create table group: " + groupName +
535 ". It is a duplicate of an existing group key (" +
537 __COUT_ERR__ << ss.str() << __E__;
538 xmlOut.addTextElementToData(
"Error", ss.str());
543 __COUT__ <<
"Check for duplicate groups complete." << __E__;
547 __COUT_WARN__ <<
"Ignoring errors looking for duplicate groups! Proceeding "
548 "with new group creation."
558 std::string accumulateErrors =
"";
559 for(
auto& groupMemberPair : groupMembers)
562 cfgMgr->getTableByName(groupMemberPair.first)->getViewP();
564 cfgViewPtr->getSourceColumnMismatch() !=
568 __SS__ <<
"\n\nThere were errors found in loading a member table "
569 << groupMemberPair.first <<
":v" << cfgViewPtr->getVersion()
570 <<
". Please see the details below:\n\n"
571 << cfgViewPtr->getMismatchColumnInfo();
573 __COUT_ERR__ <<
"\n" << ss.str();
574 xmlOut.addTextElementToData(
"Error", ss.str());
579 catch(std::runtime_error& e)
581 __SS__ <<
"Failed to create table group: " << groupName
582 <<
".\nThere were problems loading the chosen members:\n\n"
583 << e.what() << __E__;
584 __COUT_ERR__ <<
"\n" << ss.str();
585 xmlOut.addTextElementToData(
"Error", ss.str());
590 __SS__ <<
"Failed to create table group: " << groupName << __E__;
595 catch(
const std::exception& e)
597 ss <<
"Exception message: " << e.what();
602 __COUT_ERR__ <<
"\n" << ss.str();
603 xmlOut.addTextElementToData(
"Error", ss.str());
607 __COUTT__ <<
"handleCreateTableGroupXML group members init checked runtime="
608 << cfgMgr->runTimeSeconds() << __E__;
611 std::string accumulateTreeErrs;
612 cfgMgr->
getChildren(&groupMembers, &accumulateTreeErrs);
613 if(accumulateTreeErrs !=
"")
615 __COUT_WARN__ <<
"\n" << accumulateTreeErrs << __E__;
618 xmlOut.addTextElementToData(
"TreeErrors", accumulateTreeErrs);
623 __COUTT__ <<
"handleCreateTableGroupXML tree checked runtime="
624 << cfgMgr->runTimeSeconds() << __E__;
629 __COUT__ <<
"Saving new group..." << __E__;
631 groupName, groupMembers, groupComment, &memberTableAliases);
633 catch(std::runtime_error& e)
635 __SS__ <<
"Failed to create table group: " << groupName << __E__;
636 ss <<
"\n\n" << e.what() << __E__;
637 __COUT_ERR__ << ss.str();
638 xmlOut.addTextElementToData(
"Error", ss.str());
643 __SS__ <<
"Failed to create table group: " << groupName << __E__;
648 catch(
const std::exception& e)
650 ss <<
"Exception message: " << e.what();
655 __COUT_ERR__ << ss.str();
656 xmlOut.addTextElementToData(
"Error", ss.str());
660 __COUTT__ <<
"handleCreateTableGroupXML group saved runtime="
661 << cfgMgr->runTimeSeconds() << __E__;
664 __COUT__ <<
"Loading new table group..." << __E__;
666 xmlOut, cfgMgr, groupName, newKey, ignoreWarnings,
true );
668 __COUTT__ <<
"handleCreateTableGroupXML end runtime=" << cfgMgr->runTimeSeconds()
672 catch(std::runtime_error& e)
674 __SS__ <<
"Error saving table group!\n\n " << e.what() << __E__;
675 __COUT_ERR__ <<
"\n" << ss.str() << __E__;
676 xmlOut.addTextElementToData(
"Error", ss.str());
680 __SS__ <<
"Error saving table group!" << __E__;
685 catch(
const std::exception& e)
687 ss <<
"Exception message: " << e.what();
692 __COUT_ERR__ <<
"\n" << ss.str() << __E__;
693 xmlOut.addTextElementToData(
"Error", ss.str());
724 const std::string& groupName,
726 bool ignoreWarnings ,
731 xercesc::DOMElement *parentEl, *configEl;
754 __COUTTV__(cacheOnly);
758 auto SpanToXML = [](
auto const& sortedKeys,
auto& xmlOut) {
760 size_t lo = -1, hi = -1;
761 for(
auto& keyInOrder : sortedKeys)
765 hi = lo = keyInOrder.key();
768 else if(hi + 1 == keyInOrder.key())
770 hi = keyInOrder.key();
776 xmlOut.addNumberElementToData(
"HistoricalTableGroupKey", lo);
778 xmlOut.addTextElementToData(
779 "HistoricalTableGroupKey",
780 "_" + std::to_string(lo) +
"_" + std::to_string(hi));
781 hi = lo = keyInOrder.key();
787 xmlOut.addNumberElementToData(
"HistoricalTableGroupKey", lo);
789 xmlOut.addTextElementToData(
790 "HistoricalTableGroupKey",
791 "_" + std::to_string(lo) +
"_" + std::to_string(hi));
794 auto vSpanToXML = [](
auto const& sortedKeys,
auto& xmlOut,
auto& configEl) {
796 size_t lo = -1, hi = -1;
797 for(
auto& keyInOrder : sortedKeys)
801 hi = lo = keyInOrder.version();
804 else if(hi + 1 == keyInOrder.version())
806 hi = keyInOrder.version();
812 xmlOut.addNumberElementToParent(
"TableExistingVersion", lo, configEl);
815 "TableExistingVersion",
816 "_" + std::to_string(lo) +
"_" + std::to_string(hi),
818 hi = lo = keyInOrder.version();
824 xmlOut.addNumberElementToParent(
"TableExistingVersion", lo, configEl);
827 "TableExistingVersion",
828 "_" + std::to_string(lo) +
"_" + std::to_string(hi),
836 const std::set<TableGroupKey>& sortedKeys = groupInfo.getKeys();
840 __COUTT__ <<
"Active groups: "
842 __COUTT__ <<
"Active tables: "
848 sortedKeys.find(groupKey) == sortedKeys.end() ||
849 sortedKeys.size() < 2))
852 if(!groupKey.
isInvalid() || sortedKeys.size() == 0)
855 std::string accumulatedWarnings;
856 __COUTT__ <<
"Attempting full table refresh (assuming cache not yet "
861 &accumulatedWarnings,
866 __COUTT__ <<
"After full table refresh (assuming cache not yet "
867 "established) so ignoring these errors: "
868 << accumulatedWarnings << __E__;
873 const std::set<TableGroupKey>& sortedKeys2 =
874 groupInfo2.getKeys();
876 if(sortedKeys2.find(groupKey) == sortedKeys2.end())
878 __SS__ <<
"Group key " << groupKey <<
" was not found for group '"
879 << groupName <<
"!'" << __E__;
880 ss <<
"Her are the found " << sortedKeys2.size() <<
" '" << groupName
881 <<
"' keys: " << __E__;
882 for(
auto& keyInOrder : sortedKeys2)
883 ss <<
"\t" << keyInOrder << __E__;
884 __COUT_WARN__ <<
"\n" << ss.str() << __E__;
886 SpanToXML(sortedKeys2, xmlOut);
890 if(sortedKeys.size())
891 groupKey = *sortedKeys.rbegin();
893 <<
"Group key requested was invalid or not found, going with latest "
894 << groupKey << __E__;
897 SpanToXML(sortedKeys, xmlOut);
903 SpanToXML(sortedKeys, xmlOut);
909 <<
"There are no active tables. Attempting to initialize active groups."
912 std::string tmpAccumulateWarnings;
915 &tmpAccumulateWarnings);
916 __COUTT__ <<
"Now Active tables: "
918 __COUTT__ <<
"Ingoring warnings during init of active groups: "
919 << tmpAccumulateWarnings << __E__;
923 xmlOut.addTextElementToData(
"TableGroupName", groupName);
924 xmlOut.addTextElementToData(
"TableGroupKey", groupKey.
toString());
926 parentEl = xmlOut.addTextElementToData(
"TableGroupMembers",
"");
930 std::map<std::string , std::string > groupMemberAliases;
932 __COUT__ <<
"groupName=" << groupName << __E__;
933 __COUT__ <<
"groupKey=" << groupKey << __E__;
935 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
936 std::map<std::string, TableInfo>::const_iterator it;
942 std::string groupAuthor, groupComment, groupCreationTime, groupTypeString;
943 std::string accumulateTreeErrors;
945 __COUTV__(ignoreWarnings);
952 &accumulateTreeErrors,
958 &groupMemberAliases);
960 if(accumulateTreeErrors !=
"")
962 __COUTV__(accumulateTreeErrors);
963 xmlOut.addTextElementToData(
"TreeErrors", accumulateTreeErrors);
966 xmlOut.addTextElementToData(
"TableGroupAuthor", groupAuthor);
967 xmlOut.addTextElementToData(
"TableGroupComment", groupComment);
968 xmlOut.addTextElementToData(
"TableGroupCreationTime", groupCreationTime);
969 xmlOut.addTextElementToData(
"TableGroupType", groupTypeString);
971 catch(
const std::runtime_error& e)
973 __SS__ <<
"Table group \"" + groupName +
"(" + groupKey.
toString() +
")" +
974 "\" members can not be loaded!\n\n" + e.what()
976 __COUT_ERR__ << ss.str();
977 xmlOut.addTextElementToData(
"Error", ss.str());
982 __SS__ <<
"Table group \"" + groupName +
"(" + groupKey.
toString() +
")" +
983 "\" members can not be loaded!"
989 catch(
const std::exception& e)
991 ss <<
"Exception message: " << e.what();
996 __COUT_ERR__ << ss.str();
997 xmlOut.addTextElementToData(
"Error", ss.str());
1003 std::map<std::string, std::map<std::string, TableVersion>> versionAliases =
1006 __COUT__ <<
"# of table version aliases: " << versionAliases.size() << __E__;
1009 for(
auto& memberPair : memberMap)
1014 if(groupMemberAliases.find(memberPair.first) != groupMemberAliases.end())
1017 ConfigurationManager::ALIAS_VERSION_PREAMBLE +
1018 groupMemberAliases[memberPair.first],
1022 "MemberVersion", memberPair.second.toString(), parentEl);
1024 it = allTableInfo.find(memberPair.first);
1025 if(it == allTableInfo.end())
1028 xmlOut.addTextElementToData(
1029 "Error",
"Table \"" + memberPair.first +
"\" can not be retrieved!");
1034 "MemberComment", it->second.tablePtr_->getView().getComment(), parentEl);
1036 if(versionAliases.find(it->first) != versionAliases.end())
1037 for(
auto& aliasVersion : versionAliases[it->first])
1039 "TableExistingVersion",
1040 ConfigurationManager::ALIAS_VERSION_PREAMBLE + aliasVersion.first,
1043 vSpanToXML(it->second.versions_, xmlOut, configEl);
1093 catch(std::runtime_error& e)
1095 __SS__ << (
"Error getting table group!\n\n" + std::string(e.what())) << __E__;
1096 __COUT_ERR__ <<
"\n" << ss.str();
1097 xmlOut.addTextElementToData(
"Error", ss.str());
1101 __SS__ << (
"Error getting table group!\n\n") << __E__;
1106 catch(
const std::exception& e)
1108 ss <<
"Exception message: " << e.what();
1113 __COUT_ERR__ <<
"\n" << ss.str();
1114 xmlOut.addTextElementToData(
"Error", ss.str());
1118 bool ConfigurationSupervisorBase::handleAddDesktopIconXML(
1121 const std::string& iconCaption,
1122 const std::string& iconAltText,
1123 const std::string& iconFolderPath,
1124 const std::string& iconImageURL,
1125 const std::string& iconWindowURL,
1126 const std::string& iconPermissions,
1127 std::string windowLinkedApp ,
1128 unsigned int windowLinkedAppLID ,
1129 bool enforceOneWindowInstance ,
1130 const std::string& windowParameters )
1135 const std::string& author = cfgMgr->
getUsername();
1138 __COUTV__(iconCaption);
1139 __COUTV__(iconAltText);
1140 __COUTV__(iconFolderPath);
1141 __COUTV__(iconImageURL);
1142 __COUTV__(iconWindowURL);
1143 __COUTV__(iconPermissions);
1144 __COUTV__(windowLinkedApp);
1145 __COUTV__(windowLinkedAppLID);
1146 __COUTV__(enforceOneWindowInstance);
1148 __COUTV__(windowParameters);
1163 ConfigurationManager::LoadGroupType::
1164 ONLY_BACKBONE_OR_CONTEXT_TYPES
1167 const std::string backboneGroupName =
1168 cfgMgr->getActiveGroupName(ConfigurationManager::GroupType::BACKBONE_TYPE);
1170 GroupEditStruct contextGroupEdit(ConfigurationManager::GroupType::CONTEXT_TYPE,
1181 DesktopIconTable::ICON_TABLE,
true );
1182 TableEditStruct& parameterTable = contextGroupEdit.getTableEditStruct(
1183 DesktopIconTable::PARAMETER_TABLE,
true );
1185 ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME);
1191 std::string iconUID =
"";
1194 for(
unsigned int i = 0; i < decodedCaption.size(); ++i)
1195 if((decodedCaption[i] >=
'a' && decodedCaption[i] <=
'z') ||
1196 (decodedCaption[i] >=
'A' && decodedCaption[i] <=
'Z') ||
1197 (decodedCaption[i] >=
'0' && decodedCaption[i] <=
'9'))
1198 iconUID += decodedCaption[i];
1201 row = iconTable.tableView_->
addRow(
1202 author,
true ,
"generatedIcon" + iconUID);
1204 iconTable.tableView_->getDataView()[row][iconTable.tableView_->
getColUID()];
1217 iconTable.tableView_->
findCol(DesktopIconTable::COL_CAPTION));
1222 iconTable.tableView_->
findCol(DesktopIconTable::COL_ALTERNATE_TEXT));
1225 enforceOneWindowInstance ?
"1" :
"0",
1227 iconTable.tableView_->
findCol(DesktopIconTable::COL_FORCE_ONLY_ONE_INSTANCE));
1232 iconTable.tableView_->
findCol(DesktopIconTable::COL_PERMISSIONS));
1237 iconTable.tableView_->
findCol(DesktopIconTable::COL_IMAGE_URL));
1242 iconTable.tableView_->
findCol(DesktopIconTable::COL_WINDOW_CONTENT_URL));
1247 iconTable.tableView_->
findCol(DesktopIconTable::COL_FOLDER_PATH));
1250 if(windowLinkedAppLID > 0)
1252 __COUTV__(windowLinkedAppLID);
1254 int appRow = appTable.tableView_->
findRow(
1255 appTable.tableView_->
findCol(XDAQContextTable::colApplication_.colId_),
1256 windowLinkedAppLID);
1259 ->getDataView()[appRow][appTable.tableView_->
getColUID()];
1260 __COUT__ <<
"Found app by LID: " << windowLinkedApp << __E__;
1263 if(windowLinkedApp !=
"" && windowLinkedApp !=
"undefined" &&
1264 windowLinkedApp != TableViewColumnInfo::DATATYPE_STRING_DEFAULT)
1269 __COUTV__(windowLinkedApp);
1271 if(!windowLinkedAppLID)
1277 appTable.tableView_->
getColUID(), windowLinkedApp);
1279 catch(
const std::runtime_error& e)
1284 int appRow = appTable.tableView_->
findRow(
1286 XDAQContextTable::colApplication_.colClass_),
1290 ->getDataView()[appRow][appTable.tableView_->
getColUID()];
1296 <<
"Failed to create an icon linking to XDAQ Supervisor app '"
1298 <<
".' Please make sure the Supervisor exists in the "
1299 << ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME
1301 <<
"\n\nThe following error occurred: " << e.what() << __E__;
1302 appTable.tableView_->print(ss);
1307 __COUTV__(windowLinkedApp);
1310 ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME,
1312 iconTable.tableView_->
findCol(DesktopIconTable::COL_APP_LINK));
1316 iconTable.tableView_->
findCol(DesktopIconTable::COL_APP_LINK_UID));
1320 std::map<std::string, std::string> parameters;
1322 __COUTV__(windowParameters);
1326 if(parameters.size())
1330 DesktopIconTable::PARAMETER_TABLE,
1332 iconTable.tableView_->
findCol(DesktopIconTable::COL_PARAMETER_LINK));
1335 iconUID +
"_Parameters",
1337 iconTable.tableView_->
findCol(DesktopIconTable::COL_PARAMETER_LINK_GID));
1341 unsigned int gidCol =
1342 parameterTable.tableView_->
findCol(DesktopIconTable::COL_PARAMETER_GID);
1345 std::vector<
unsigned int > rowsInGroup =
1347 gidCol, iconUID +
"_Parameters" );
1352 for(
unsigned int r = rowsInGroup.size() - 1; r < rowsInGroup.size(); --r)
1356 iconUID +
"_Parameters" ,
1360 for(
const auto& parameter : parameters)
1363 row = parameterTable.tableView_->
addRow(
1364 author,
true ,
"generatedParameter");
1371 iconUID +
"_Parameters", row, gidCol);
1376 parameterTable.tableView_->
findCol(
1377 DesktopIconTable::COL_PARAMETER_KEY));
1382 parameterTable.tableView_->
findCol(
1383 DesktopIconTable::COL_PARAMETER_VALUE));
1386 std::stringstream ss;
1387 parameterTable.tableView_->print(ss);
1388 __COUT__ << ss.str();
1390 parameterTable.tableView_
1395 std::stringstream ss;
1396 iconTable.tableView_->print(ss);
1397 __COUT__ << ss.str();
1399 iconTable.tableView_->
init();
1403 __COUT__ <<
"Icon table errors while saving. Erasing all newly "
1404 "created table versions."
1410 __COUT__ <<
"Edits complete for new desktop icon, now making persistent tables."
1424 bool foundEquivalentContextKey;
1426 bool foundEquivalentBackboneKey;
1428 contextGroupEdit.saveChanges(contextGroupEdit.originalGroupName_,
1430 &foundEquivalentContextKey,
1435 &foundEquivalentBackboneKey);
1437 xmlOut.addTextElementToData(
"contextGroupName", contextGroupEdit.originalGroupName_);
1438 xmlOut.addTextElementToData(
"contextGroupKey", newContextKey.
toString());
1440 xmlOut.addTextElementToData(
"backboneGroupName", backboneGroupName);
1441 xmlOut.addTextElementToData(
"backboneGroupKey", newBackboneKey.
toString());
1448 catch(std::runtime_error& e)
1450 __SS__ <<
"Error adding Desktop Icon!\n\n " << e.what() << __E__;
1451 __COUT__ <<
"\n" << ss.str() << __E__;
1452 xmlOut.addTextElementToData(
"Error", ss.str());
1457 __SS__ <<
"Error adding Desktop Icon!" << __E__;
1462 catch(
const std::exception& e)
1464 ss <<
"Exception message: " << e.what();
1469 __COUT__ <<
"\n" << ss.str() << __E__;
1470 xmlOut.addTextElementToData(
"Error", ss.str());
1475 void ConfigurationSupervisorBase::recursiveCopyTreeUIDNode(
1478 std::map<std::string /*modified table*/, TableVersion /* modified version */>&
1480 const unsigned int startingDepth,
1481 const unsigned int depth,
1482 const unsigned int numberOfInstances,
1484 const std::string& uidToCopy)
1487 __COUTV__(startingDepth);
1489 __COUTV__(numberOfInstances);
1510 unsigned int col = cfgView->
getColUID();
1511 unsigned int row = cfgView->
findRow(col, uidToCopy);
1513 __COUT__ <<
"Copying " << cfgView->getTableName() <<
" v" << cfgView->getVersion()
1514 <<
" row=" << row <<
" record=" << uidToCopy
1515 <<
" instances=" << numberOfInstances << __E__;
1532 std::string tableName =
"secondary";
1535 TableBase* table = cfgMgr->getTableByName(tableName);
1538 table->setActiveView(version);
1542 if(version.isTemporaryVersion())
1545 __COUT__ <<
"Failed to find stored version, so attempting to "
1547 << tableName <<
" v" << version << __E__;
1551 __COUT__ << tableName <<
" active version is " << table->
getViewVersion() << __E__;
1555 __SS__ <<
"Target table version (" << version
1556 <<
") is not the currently active version (" << table->
getViewVersion()
1557 <<
"). Try refreshing the tree." << __E__;
1572 __COUT__ <<
"Created temporary version " << temporaryVersion << __E__;
1585 __COUT__ <<
"Caught error while editing. Erasing temporary version." << __E__;
1586 table->eraseView(temporaryVersion);
1600 catch(std::runtime_error& e)
1602 __SS__ << (
"Error copying tree target '" + uidToCopy +
"' at depth " +
1603 std::to_string(startingDepth - depth) +
" in table '" +
1604 cfgView->getTableName() +
".' " + std::string(e.what()))
1606 __COUT__ <<
"\n" << ss.str() << __E__;
1607 xmlOut.addTextElementToData(
"Error", ss.str());
1611 __SS__ << (
"Error copying tree target '" + uidToCopy +
"' at depth " +
1612 std::to_string(startingDepth - depth) +
" in table '" +
1613 cfgView->getTableName() +
".' ")
1619 catch(
const std::exception& e)
1621 ss <<
"Exception message: " << e.what();
1626 __COUT__ <<
"\n" << ss.str() << __E__;
1627 xmlOut.addTextElementToData(
"Error", ss.str());
TableGroupKey findTableGroup(const std::string &groupName, const std::map< std::string, TableVersion > &groupMembers, const std::map< std::string, std::string > &groupAliases=std::map< std::string, std::string >())
const GroupInfo & getGroupInfo(const std::string &groupName, bool attemptToReloadKeys=false)
public group cache handling
const std::map< std::string, TableInfo > & getAllTableInfo(bool refresh=false, std::string *accumulatedWarnings=0, const std::string &errorFilterName="", bool getGroupKeys=false, bool getGroupInfo=false, bool initializeActiveGroups=false)
void loadTableGroup(const std::string &tableGroupName, const TableGroupKey &tableGroupKey, bool doActivate=false, std::map< std::string, TableVersion > *groupMembers=0, ProgressBar *progressBar=0, std::string *accumulateWarnings=0, std::string *groupComment=0, std::string *groupAuthor=0, std::string *groupCreateTime=0, bool doNotLoadMember=false, std::string *groupTypeString=0, std::map< std::string, std::string > *groupAliases=0, ConfigurationManager::LoadGroupType groupTypeToLoad=ConfigurationManager::LoadGroupType::ALL_TYPES, bool ignoreVersionTracking=false)
TableGroupKey saveNewTableGroup(const std::string &groupName, std::map< std::string, TableVersion > &groupMembers, const std::string &groupComment=TableViewColumnInfo::DATATYPE_COMMENT_DEFAULT, std::map< std::string, std::string > *groupAliases=0)
modifiers of a table group based on alias, e.g. "Physics"
TableVersion saveModifiedVersion(const std::string &tableName, TableVersion originalVersion, bool makeTemporary, TableBase *config, TableVersion temporaryModifiedVersion, bool ignoreDuplicates=false, bool lookForEquivalent=false, bool *foundEquivalent=nullptr)
const std::string & getUsername(void) const
Getters.
std::map< std::string, std::map< std::string, TableVersion > > getVersionAliases(void) const
TableBase * getVersionedTableByName(const std::string &tableName, TableVersion version, bool looseColumnMatching=false, std::string *accumulatedErrors=0, bool getRawData=false)
void restoreActiveTableGroups(bool throwErrors=false, const std::string &pathToActiveGroupsFile="", ConfigurationManager::LoadGroupType onlyLoadIfBackboneOrContext=ConfigurationManager::LoadGroupType::ALL_TYPES, std::string *accumulatedWarnings=0)
std::map< std::string, std::pair< std::string, TableGroupKey > > getActiveTableGroups(void) const
void loadMemberMap(const std::map< std::string, TableVersion > &memberMap, std::string *accumulateWarnings=0)
std::map< std::string, TableVersion > getActiveVersions(void) const
getActiveVersions
ConfigurationTree getNode(const std::string &nodeString, bool doNotThrowOnBrokenUIDLinks=false) const
"root/parent/parent/"
void init(std::string *accumulatedErrors=0, bool initForWriteAccess=false, std::string *accumulatedWarnings=0)
std::vector< std::pair< std::string, ConfigurationTree > > getChildren(std::map< std::string, TableVersion > *memberMap=0, std::string *accumulatedTreeErrors=0) const
static void getConfigurationStatusXML(HttpXmlDocument &xmlOut, ConfigurationManagerRW *cfgMgr, const std::string &username)
getConfigurationStatusXML
static void handleGetTableGroupXML(HttpXmlDocument &xmlOut, ConfigurationManagerRW *cfgMgr, const std::string &groupName, TableGroupKey groupKey, bool ignoreWarnings=false, bool cacheOnly=false)
static TableVersion saveModifiedVersionXML(HttpXmlDocument &xmlOut, ConfigurationManagerRW *cfgMgr, const std::string &tableName, TableVersion originalVersion, bool makeTemporary, TableBase *config, TableVersion temporaryModifiedVersion, bool ignoreDuplicates=false, bool lookForEquivalent=false)
static void handleCreateTableXML(HttpXmlDocument &xmlOut, ConfigurationManagerRW *cfgMgr, const std::string &tableName, TableVersion version, bool makeTemporary, const std::string &data, const int &dataOffset, const std::string &author, const std::string &comment, bool sourceTableAsIs, bool lookForEquivalent)
static void handleCreateTableGroupXML(HttpXmlDocument &xmlOut, ConfigurationManagerRW *cfgMgr, const std::string &groupName, const std::string &configList, bool allowDuplicates=false, bool ignoreWarnings=false, const std::string &groupComment="", bool lookForEquivalent=false)
std::vector< std::pair< std::string, ConfigurationTree > > getChildren(std::map< std::string, std::string > filterMap=std::map< std::string, std::string >(), bool byPriority=false, bool onlyStatusTrue=false) const
TableVersion createTemporaryView(TableVersion sourceViewVersion=TableVersion(), TableVersion destTemporaryViewVersion=TableVersion::getNextTemporaryVersion())
source of -1, from MockUp, else from valid view version
TableView * getTemporaryView(TableVersion temporaryVersion)
const TableVersion & getViewVersion(void) const
always the active one
std::string toString(void) const
toString
bool isInvalid(void) const
isInvalid
bool isMockupVersion(void) const
std::string toString(void) const
toString
bool isInvalid(void) const
isInvalid
bool isScratchVersion(void) const
bool isTemporaryVersion(void) const
unsigned int findRow(unsigned int col, const T &value, unsigned int offsetRow=0, bool doNotThrow=false) const
< in included .icc source
void setValueAsString(const std::string &value, unsigned int row, unsigned int col)
unsigned int getColStatus(void) const
bool removeRowFromGroup(const unsigned int &row, const unsigned int &col, const std::string &groupID, bool deleteRowIfNoGroupLeft=false)
unsigned int copyRows(const std::string &author, const TableView &src, unsigned int srcOffsetRow=0, unsigned int srcRowsToCopy=(unsigned int) -1, unsigned int destOffsetRow=(unsigned int) -1, unsigned char generateUniqueDataColumns=false, const std::string &baseNameAutoUID="")
std::vector< unsigned int > getGroupRows(const unsigned int groupIdCol, const std::string &groupID, bool onlyStatusTrue=false, bool orderedByPriority=false) const
unsigned int getDataColumnSize(void) const
getDataColumnSize
unsigned int getColUID(void) const
bool setURIEncodedValue(const std::string &value, const unsigned int &row, const unsigned int &col, const std::string &author="")
int fillFromEncodedCSV(const std::string &data, const int &dataOffset=0, const std::string &author="")
unsigned int findCol(const std::string &name) const
void setURIEncodedComment(const std::string &uriComment)
unsigned int addRow(const std::string &author="", unsigned char incrementUniqueData=false, const std::string &baseNameAutoUID="", unsigned int rowToAdd=(unsigned int) -1, std::string childLinkIndex="", std::string groupId="")
xercesc::DOMElement * addTextElementToParent(const std::string &childName, const std::string &childText, xercesc::DOMElement *parent)
static std::string setToString(const std::set< T > &setToReturn, const std::string &delimeter=", ")
setToString ~
static std::string vectorToString(const std::vector< T > &setToReturn, const std::string &delimeter=", ")
vectorToString ~
static std::string mapToString(const std::map< std::string, T > &mapToReturn, const std::string &primaryDelimeter=", ", const std::string &secondaryDelimeter=": ")
static void getMapFromString(const std::string &inputString, std::map< S, T > &mapToReturn, const std::set< char > &pairPairDelimiter={',', '|', '&'}, const std::set< char > &nameValueDelimiter={'=', ':'}, const std::set< char > &whitespace={' ', '\t', '\n', '\r'})
getMapFromString ~
static std::string decodeURIComponent(const std::string &data)