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)
103 cfgMgr->getVersionedTableByName(tableName, version);
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 if(accumulatedWarnings.size())
365 __COUT_WARN__ <<
"Ignoring these errors: " << accumulatedWarnings << __E__;
369 __COUTT__ <<
"handleCreateTableGroupXML loaded runtime=" << cfgMgr->runTimeSeconds()
372 std::map<std::string ,
381 std::map<std::string , std::string > memberTableAliases;
383 std::string name, versionStr, alias;
385 auto c = tableList.find(
',', 0);
388 while(c < tableList.length())
391 name = tableList.substr(i, c - i);
393 c = tableList.find(
',', i);
394 if(c == std::string::npos)
396 __SS__ <<
"Incomplete Table Name-Version pair!" << __E__;
397 __COUT_ERR__ <<
"\n" << ss.str();
398 xmlOut.addTextElementToData(
"Error", ss.str());
402 versionStr = tableList.substr(i, c - i);
404 c = tableList.find(
',', i);
410 if(versionStr.find(ConfigurationManager::ALIAS_VERSION_PREAMBLE) == 0)
413 versionStr.substr(ConfigurationManager::ALIAS_VERSION_PREAMBLE.size());
415 __COUT__ <<
"Found alias " << name <<
" " << versionStr << __E__;
418 if(versionAliases.find(name) != versionAliases.end() &&
419 versionAliases[name].find(alias) != versionAliases[name].end())
421 version = versionAliases[name][alias];
422 __COUT__ << name <<
" version alias '" << alias
423 <<
"'translated to: " << version << __E__;
425 memberTableAliases[name] = alias;
429 __SS__ <<
"version alias '"
430 << versionStr.substr(
431 ConfigurationManager::ALIAS_VERSION_PREAMBLE.size())
432 <<
"' was not found in active version aliases! Please check your "
435 __COUT_ERR__ <<
"\n" << ss.str();
436 xmlOut.addTextElementToData(
"Error", ss.str());
445 __SS__ <<
"Groups can not be created using temporary member tables. "
446 <<
"Table member '" << name <<
"' with temporary version '" << version
447 <<
"' is illegal." << __E__;
448 xmlOut.addTextElementToData(
"Error", ss.str());
453 if(allTableInfo.find(name) == allTableInfo.end())
455 __SS__ <<
"Groups can not be created using mock-up member tables of "
457 <<
"Table member '" << name <<
"' is not defined." << __E__;
458 xmlOut.addTextElementToData(
"Error", ss.str());
465 TableBase* table = cfgMgr->getTableByName(name);
468 __COUT__ <<
"\t\ttemporaryVersion: " << temporaryVersion << __E__;
471 __COUT__ <<
"Creating version from mock-up for name: " << name
472 <<
" inputVersionStr: " << versionStr << __E__;
476 ->setComment(
"Auto-generated from mock-up.");
490 __COUT__ <<
"Using mockup version: " << version << __E__;
494 groupMembers[name] = version;
497 __COUTT__ <<
"handleCreateTableGroupXML tables saved runtime="
498 << cfgMgr->runTimeSeconds() << __E__;
504 __COUT__ <<
"Checking for duplicate groups..." << __E__;
508 cfgMgr->
findTableGroup(groupName, groupMembers, memberTableAliases);
509 __COUTT__ <<
"handleCreateTableGroupXML group duplicates checked runtime="
510 << cfgMgr->runTimeSeconds() << __E__;
514 xmlOut.addTextElementToData(
"TableGroupName", groupName);
515 xmlOut.addTextElementToData(
"TableGroupKey", foundKey.
toString());
517 if(lookForEquivalent)
519 __COUT__ <<
"Found equivalent group key (" << foundKey <<
") for "
520 << groupName <<
"." << __E__;
522 xmlOut.addTextElementToData(
"foundEquivalentKey",
"1");
535 __COUT__ <<
"Treating duplicate group as error." << __E__;
536 __SS__ << (
"Failed to create table group: " + groupName +
537 ". It is a duplicate of an existing group key (" +
539 __COUT_ERR__ << ss.str() << __E__;
540 xmlOut.addTextElementToData(
"Error", ss.str());
545 __COUT__ <<
"Check for duplicate groups complete." << __E__;
549 __COUT_WARN__ <<
"Ignoring errors looking for duplicate groups! Proceeding "
550 "with new group creation."
560 std::string accumulateErrors =
"";
561 for(
auto& groupMemberPair : groupMembers)
564 cfgMgr->getTableByName(groupMemberPair.first)->getViewP();
566 cfgViewPtr->getSourceColumnMismatch() !=
570 __SS__ <<
"\n\nThere were errors found in loading a member table "
571 << groupMemberPair.first <<
":v" << cfgViewPtr->getVersion()
572 <<
". Please see the details below:\n\n"
573 << cfgViewPtr->getMismatchColumnInfo();
575 __COUT_ERR__ <<
"\n" << ss.str();
576 xmlOut.addTextElementToData(
"Error", ss.str());
581 catch(std::runtime_error& e)
583 __SS__ <<
"Failed to create table group: " << groupName
584 <<
".\nThere were problems loading the chosen members:\n\n"
585 << e.what() << __E__;
586 __COUT_ERR__ <<
"\n" << ss.str();
587 xmlOut.addTextElementToData(
"Error", ss.str());
592 __SS__ <<
"Failed to create table group: " << groupName << __E__;
597 catch(
const std::exception& e)
599 ss <<
"Exception message: " << e.what();
604 __COUT_ERR__ <<
"\n" << ss.str();
605 xmlOut.addTextElementToData(
"Error", ss.str());
609 __COUTT__ <<
"handleCreateTableGroupXML group members init checked runtime="
610 << cfgMgr->runTimeSeconds() << __E__;
613 std::string accumulateTreeErrs;
614 cfgMgr->
getChildren(&groupMembers, &accumulateTreeErrs);
615 if(accumulateTreeErrs !=
"")
617 __COUT_WARN__ <<
"\n" << accumulateTreeErrs << __E__;
620 xmlOut.addTextElementToData(
"TreeErrors", accumulateTreeErrs);
625 __COUTT__ <<
"handleCreateTableGroupXML tree checked runtime="
626 << cfgMgr->runTimeSeconds() << __E__;
631 __COUT__ <<
"Saving new group..." << __E__;
633 groupName, groupMembers, groupComment, &memberTableAliases);
635 catch(std::runtime_error& e)
637 __SS__ <<
"Failed to create table group: " << groupName << __E__;
638 ss <<
"\n\n" << e.what() << __E__;
639 __COUT_ERR__ << ss.str();
640 xmlOut.addTextElementToData(
"Error", ss.str());
645 __SS__ <<
"Failed to create table group: " << groupName << __E__;
650 catch(
const std::exception& e)
652 ss <<
"Exception message: " << e.what();
657 __COUT_ERR__ << ss.str();
658 xmlOut.addTextElementToData(
"Error", ss.str());
662 __COUTT__ <<
"handleCreateTableGroupXML group saved runtime="
663 << cfgMgr->runTimeSeconds() << __E__;
666 __COUT__ <<
"Loading new table group..." << __E__;
668 xmlOut, cfgMgr, groupName, newKey, ignoreWarnings,
true );
670 __COUTT__ <<
"handleCreateTableGroupXML end runtime=" << cfgMgr->runTimeSeconds()
674 catch(std::runtime_error& e)
676 __SS__ <<
"Error saving table group!\n\n " << e.what() << __E__;
677 __COUT_ERR__ <<
"\n" << ss.str() << __E__;
678 xmlOut.addTextElementToData(
"Error", ss.str());
682 __SS__ <<
"Error saving table group!" << __E__;
687 catch(
const std::exception& e)
689 ss <<
"Exception message: " << e.what();
694 __COUT_ERR__ <<
"\n" << ss.str() << __E__;
695 xmlOut.addTextElementToData(
"Error", ss.str());
726 const std::string& groupName,
728 bool ignoreWarnings ,
733 xercesc::DOMElement *parentEl, *configEl;
756 __COUTTV__(cacheOnly);
760 auto SpanToXML = [](
auto const& sortedKeys,
auto& xmlOut) {
762 size_t lo = -1, hi = -1;
763 for(
auto& keyInOrder : sortedKeys)
767 hi = lo = keyInOrder.key();
770 else if(hi + 1 == keyInOrder.key())
772 hi = keyInOrder.key();
778 xmlOut.addNumberElementToData(
"HistoricalTableGroupKey", lo);
780 xmlOut.addTextElementToData(
781 "HistoricalTableGroupKey",
782 "_" + std::to_string(lo) +
"_" + std::to_string(hi));
783 hi = lo = keyInOrder.key();
789 xmlOut.addNumberElementToData(
"HistoricalTableGroupKey", lo);
791 xmlOut.addTextElementToData(
792 "HistoricalTableGroupKey",
793 "_" + std::to_string(lo) +
"_" + std::to_string(hi));
796 auto vSpanToXML = [](
auto const& sortedKeys,
auto& xmlOut,
auto& configEl) {
798 size_t lo = -1, hi = -1;
799 for(
auto& keyInOrder : sortedKeys)
803 hi = lo = keyInOrder.version();
806 else if(hi + 1 == keyInOrder.version())
808 hi = keyInOrder.version();
814 xmlOut.addNumberElementToParent(
"TableExistingVersion", lo, configEl);
817 "TableExistingVersion",
818 "_" + std::to_string(lo) +
"_" + std::to_string(hi),
820 hi = lo = keyInOrder.version();
826 xmlOut.addNumberElementToParent(
"TableExistingVersion", lo, configEl);
829 "TableExistingVersion",
830 "_" + std::to_string(lo) +
"_" + std::to_string(hi),
838 const std::set<TableGroupKey>& sortedKeys = groupInfo.getKeys();
842 __COUTT__ <<
"Active groups: "
844 __COUTT__ <<
"Active tables: "
850 sortedKeys.find(groupKey) == sortedKeys.end() ||
851 sortedKeys.size() < 2))
854 if(!groupKey.
isInvalid() || sortedKeys.size() == 0)
857 std::string accumulatedWarnings;
858 __COUTT__ <<
"Attempting full table refresh (assuming cache not yet "
863 &accumulatedWarnings,
868 __COUTT__ <<
"After full table refresh (assuming cache not yet "
869 "established) so ignoring these errors: "
870 << accumulatedWarnings << __E__;
875 const std::set<TableGroupKey>& sortedKeys2 =
876 groupInfo2.getKeys();
878 if(sortedKeys2.find(groupKey) == sortedKeys2.end())
880 __SS__ <<
"Group key " << groupKey <<
" was not found for group '"
881 << groupName <<
"!'" << __E__;
882 ss <<
"Her are the found " << sortedKeys2.size() <<
" '" << groupName
883 <<
"' keys: " << __E__;
884 for(
auto& keyInOrder : sortedKeys2)
885 ss <<
"\t" << keyInOrder << __E__;
886 __COUT_WARN__ <<
"\n" << ss.str() << __E__;
888 SpanToXML(sortedKeys2, xmlOut);
892 if(sortedKeys.size())
893 groupKey = *sortedKeys.rbegin();
895 <<
"Group key requested was invalid or not found, going with latest "
896 << groupKey << __E__;
899 SpanToXML(sortedKeys, xmlOut);
905 SpanToXML(sortedKeys, xmlOut);
911 <<
"There are no active tables. Attempting to initialize active groups."
914 std::string tmpAccumulateWarnings;
917 &tmpAccumulateWarnings);
918 __COUTT__ <<
"Now Active tables: "
920 __COUTT__ <<
"Ingoring warnings during init of active groups: "
921 << tmpAccumulateWarnings << __E__;
925 xmlOut.addTextElementToData(
"TableGroupName", groupName);
926 xmlOut.addTextElementToData(
"TableGroupKey", groupKey.
toString());
928 parentEl = xmlOut.addTextElementToData(
"TableGroupMembers",
"");
932 std::map<std::string , std::string > groupMemberAliases;
934 __COUT__ <<
"groupName=" << groupName << __E__;
935 __COUT__ <<
"groupKey=" << groupKey << __E__;
937 const std::map<std::string, TableInfo>& allTableInfo = cfgMgr->
getAllTableInfo();
938 std::map<std::string, TableInfo>::const_iterator it;
944 std::string groupAuthor, groupComment, groupCreationTime, groupTypeString;
945 std::string accumulateTreeErrors;
947 __COUTV__(ignoreWarnings);
954 &accumulateTreeErrors,
960 &groupMemberAliases);
962 if(accumulateTreeErrors !=
"")
964 __COUTV__(accumulateTreeErrors);
965 xmlOut.addTextElementToData(
"TreeErrors", accumulateTreeErrors);
968 xmlOut.addTextElementToData(
"TableGroupAuthor", groupAuthor);
969 xmlOut.addTextElementToData(
"TableGroupComment", groupComment);
970 xmlOut.addTextElementToData(
"TableGroupCreationTime", groupCreationTime);
971 xmlOut.addTextElementToData(
"TableGroupType", groupTypeString);
973 catch(
const std::runtime_error& e)
975 __SS__ <<
"Table group \"" + groupName +
"(" + groupKey.
toString() +
")" +
976 "\" members can not be loaded!\n\n" + e.what()
978 __COUT_ERR__ << ss.str();
979 xmlOut.addTextElementToData(
"Error", ss.str());
984 __SS__ <<
"Table group \"" + groupName +
"(" + groupKey.
toString() +
")" +
985 "\" members can not be loaded!"
991 catch(
const std::exception& e)
993 ss <<
"Exception message: " << e.what();
998 __COUT_ERR__ << ss.str();
999 xmlOut.addTextElementToData(
"Error", ss.str());
1005 std::map<std::string ,
1009 __COUT__ <<
"# of table version aliases: " << versionAliases.size() << __E__;
1012 for(
auto& memberPair : memberMap)
1017 if(groupMemberAliases.find(memberPair.first) != groupMemberAliases.end())
1021 ConfigurationManager::ALIAS_VERSION_PREAMBLE +
1022 groupMemberAliases[memberPair.first],
1026 "ProvenanceMemberVersion", memberPair.second.toString(), configEl);
1029 auto vit = versionAliases.find(memberPair.first);
1030 if(vit == versionAliases.end() ||
1031 vit->second.find(groupMemberAliases[memberPair.first]) ==
1032 vit->second.end() ||
1033 vit->second[groupMemberAliases[memberPair.first]] !=
1037 __SS__ <<
"Warning: Version alias mismatch with active Backbone! <b>\"" +
1038 groupName +
"(" + groupKey.
toString() +
")" +
1039 "\"</b> group member table <b>'"
1040 << memberPair.first <<
"'</b> is using version alias <b>'"
1041 << groupMemberAliases[memberPair.first] <<
"'</b>";
1042 if(vit == versionAliases.end() ||
1043 vit->second.find(groupMemberAliases[memberPair.first]) ==
1046 ss <<
" which no longer has a valid translation in the active "
1048 <<
" The original provenance version is <b>" << memberPair.first
1049 <<
"-v" << memberPair.second
1050 <<
"</b>.\n\nPlease consider whether this is an issue, or if you "
1051 "should first recreate this group with updated Backbone table "
1052 "alias translations before activating.";
1061 ss <<
" which translates to <b>" << memberPair.first <<
"-v"
1062 << vit->second[groupMemberAliases[memberPair.first]]
1063 <<
"</b> with current active Backbone group."
1064 <<
" There is a mismatch with the original provenance version of "
1066 << memberPair.first <<
"-v" << memberPair.second
1067 <<
"</b>.\n\nPlease consider whether this is an issue, or if you "
1068 "should first recreate this group with updated Backbone table "
1069 "alias translations before activating."
1074 "ActiveBackboneAliasVersion",
1075 vit->second[groupMemberAliases[memberPair.first]].toString(),
1078 __COUT_WARN__ <<
"\n" << ss.str() << __E__;
1079 xmlOut.addTextElementToData(
"Warning", ss.str());
1083 __COUT__ <<
"\"" + groupName +
"(" + groupKey.
toString() +
")" +
1084 "\" group member table '"
1085 << memberPair.first <<
"' is using version alias '"
1086 << groupMemberAliases[memberPair.first]
1087 <<
"' which currently matches the active Backbone translation "
1089 << memberPair.second <<
" = v"
1090 << vit->second[groupMemberAliases[memberPair.first]] << __E__;
1095 "MemberVersion", memberPair.second.toString(), parentEl);
1097 it = allTableInfo.find(memberPair.first);
1098 if(it == allTableInfo.end())
1101 xmlOut.addTextElementToData(
1102 "Error",
"Table \"" + memberPair.first +
"\" can not be retrieved!");
1107 "MemberComment", it->second.tablePtr_->getView().getComment(), parentEl);
1109 if(versionAliases.find(it->first) != versionAliases.end())
1110 for(
auto& aliasVersion : versionAliases[it->first])
1112 "TableExistingVersion",
1113 ConfigurationManager::ALIAS_VERSION_PREAMBLE + aliasVersion.first,
1116 vSpanToXML(it->second.versions_, xmlOut, configEl);
1120 catch(std::runtime_error& e)
1122 __SS__ << (
"Error getting table group!\n\n" + std::string(e.what())) << __E__;
1123 __COUT_ERR__ <<
"\n" << ss.str();
1124 xmlOut.addTextElementToData(
"Error", ss.str());
1128 __SS__ << (
"Error getting table group!\n\n") << __E__;
1133 catch(
const std::exception& e)
1135 ss <<
"Exception message: " << e.what();
1140 __COUT_ERR__ <<
"\n" << ss.str();
1141 xmlOut.addTextElementToData(
"Error", ss.str());
1145 bool ConfigurationSupervisorBase::handleAddDesktopIconXML(
1148 const std::string& iconCaption,
1149 const std::string& iconAltText,
1150 const std::string& iconFolderPath,
1151 const std::string& iconImageURL,
1152 const std::string& iconWindowURL,
1153 const std::string& iconPermissions,
1154 std::string windowLinkedApp ,
1155 unsigned int windowLinkedAppLID ,
1156 bool enforceOneWindowInstance ,
1157 const std::string& windowParameters )
1162 const std::string& author = cfgMgr->
getUsername();
1165 __COUTV__(iconCaption);
1166 __COUTV__(iconAltText);
1167 __COUTV__(iconFolderPath);
1168 __COUTV__(iconImageURL);
1169 __COUTV__(iconWindowURL);
1170 __COUTV__(iconPermissions);
1171 __COUTV__(windowLinkedApp);
1172 __COUTV__(windowLinkedAppLID);
1173 __COUTV__(enforceOneWindowInstance);
1175 __COUTV__(windowParameters);
1190 ConfigurationManager::LoadGroupType::
1191 ONLY_BACKBONE_OR_CONTEXT_TYPES
1194 const std::string backboneGroupName =
1195 cfgMgr->getActiveGroupName(ConfigurationManager::GroupType::BACKBONE_TYPE);
1197 GroupEditStruct contextGroupEdit(ConfigurationManager::GroupType::CONTEXT_TYPE,
1208 DesktopIconTable::ICON_TABLE,
true );
1209 TableEditStruct& parameterTable = contextGroupEdit.getTableEditStruct(
1210 DesktopIconTable::PARAMETER_TABLE,
true );
1212 ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME);
1218 std::string iconUID =
"";
1221 for(
unsigned int i = 0; i < decodedCaption.size(); ++i)
1222 if((decodedCaption[i] >=
'a' && decodedCaption[i] <=
'z') ||
1223 (decodedCaption[i] >=
'A' && decodedCaption[i] <=
'Z') ||
1224 (decodedCaption[i] >=
'0' && decodedCaption[i] <=
'9'))
1225 iconUID += decodedCaption[i];
1228 row = iconTable.tableView_->
addRow(
1229 author,
true ,
"generatedIcon" + iconUID);
1231 iconTable.tableView_->getDataView()[row][iconTable.tableView_->
getColUID()];
1244 iconTable.tableView_->
findCol(DesktopIconTable::COL_CAPTION));
1249 iconTable.tableView_->
findCol(DesktopIconTable::COL_ALTERNATE_TEXT));
1252 enforceOneWindowInstance ?
"1" :
"0",
1254 iconTable.tableView_->
findCol(DesktopIconTable::COL_FORCE_ONLY_ONE_INSTANCE));
1259 iconTable.tableView_->
findCol(DesktopIconTable::COL_PERMISSIONS));
1264 iconTable.tableView_->
findCol(DesktopIconTable::COL_IMAGE_URL));
1269 iconTable.tableView_->
findCol(DesktopIconTable::COL_WINDOW_CONTENT_URL));
1274 iconTable.tableView_->
findCol(DesktopIconTable::COL_FOLDER_PATH));
1277 if(windowLinkedAppLID > 0)
1279 __COUTV__(windowLinkedAppLID);
1281 int appRow = appTable.tableView_->
findRow(
1282 appTable.tableView_->
findCol(XDAQContextTable::colApplication_.colId_),
1283 windowLinkedAppLID);
1286 ->getDataView()[appRow][appTable.tableView_->
getColUID()];
1287 __COUT__ <<
"Found app by LID: " << windowLinkedApp << __E__;
1290 if(windowLinkedApp !=
"" && windowLinkedApp !=
"undefined" &&
1291 windowLinkedApp != TableViewColumnInfo::DATATYPE_STRING_DEFAULT)
1296 __COUTV__(windowLinkedApp);
1298 if(!windowLinkedAppLID)
1304 appTable.tableView_->
getColUID(), windowLinkedApp);
1306 catch(
const std::runtime_error& e)
1311 int appRow = appTable.tableView_->
findRow(
1313 XDAQContextTable::colApplication_.colClass_),
1317 ->getDataView()[appRow][appTable.tableView_->
getColUID()];
1323 <<
"Failed to create an icon linking to XDAQ Supervisor app '"
1325 <<
".' Please make sure the Supervisor exists in the "
1326 << ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME
1328 <<
"\n\nThe following error occurred: " << e.what() << __E__;
1329 appTable.tableView_->print(ss);
1334 __COUTV__(windowLinkedApp);
1337 ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME,
1339 iconTable.tableView_->
findCol(DesktopIconTable::COL_APP_LINK));
1343 iconTable.tableView_->
findCol(DesktopIconTable::COL_APP_LINK_UID));
1347 std::map<std::string, std::string> parameters;
1349 __COUTV__(windowParameters);
1353 if(parameters.size())
1357 DesktopIconTable::PARAMETER_TABLE,
1359 iconTable.tableView_->
findCol(DesktopIconTable::COL_PARAMETER_LINK));
1362 iconUID +
"_Parameters",
1364 iconTable.tableView_->
findCol(DesktopIconTable::COL_PARAMETER_LINK_GID));
1368 unsigned int gidCol =
1369 parameterTable.tableView_->
findCol(DesktopIconTable::COL_PARAMETER_GID);
1372 std::vector<
unsigned int > rowsInGroup =
1374 gidCol, iconUID +
"_Parameters" );
1379 for(
unsigned int r = rowsInGroup.size() - 1; r < rowsInGroup.size(); --r)
1383 iconUID +
"_Parameters" ,
1387 for(
const auto& parameter : parameters)
1390 row = parameterTable.tableView_->
addRow(
1391 author,
true ,
"generatedParameter");
1398 iconUID +
"_Parameters", row, gidCol);
1403 parameterTable.tableView_->
findCol(
1404 DesktopIconTable::COL_PARAMETER_KEY));
1409 parameterTable.tableView_->
findCol(
1410 DesktopIconTable::COL_PARAMETER_VALUE));
1413 std::stringstream ss;
1414 parameterTable.tableView_->print(ss);
1415 __COUT__ << ss.str();
1417 parameterTable.tableView_
1422 std::stringstream ss;
1423 iconTable.tableView_->print(ss);
1424 __COUT__ << ss.str();
1426 iconTable.tableView_->
init();
1430 __COUT__ <<
"Icon table errors while saving. Erasing all newly "
1431 "created table versions."
1437 __COUT__ <<
"Edits complete for new desktop icon, now making persistent tables."
1451 bool foundEquivalentContextKey;
1453 bool foundEquivalentBackboneKey;
1455 contextGroupEdit.saveChanges(contextGroupEdit.originalGroupName_,
1457 &foundEquivalentContextKey,
1462 &foundEquivalentBackboneKey);
1464 xmlOut.addTextElementToData(
"contextGroupName", contextGroupEdit.originalGroupName_);
1465 xmlOut.addTextElementToData(
"contextGroupKey", newContextKey.
toString());
1467 xmlOut.addTextElementToData(
"backboneGroupName", backboneGroupName);
1468 xmlOut.addTextElementToData(
"backboneGroupKey", newBackboneKey.
toString());
1475 catch(std::runtime_error& e)
1477 __SS__ <<
"Error adding Desktop Icon!\n\n " << e.what() << __E__;
1478 __COUT__ <<
"\n" << ss.str() << __E__;
1479 xmlOut.addTextElementToData(
"Error", ss.str());
1484 __SS__ <<
"Error adding Desktop Icon!" << __E__;
1489 catch(
const std::exception& e)
1491 ss <<
"Exception message: " << e.what();
1496 __COUT__ <<
"\n" << ss.str() << __E__;
1497 xmlOut.addTextElementToData(
"Error", ss.str());
1502 void ConfigurationSupervisorBase::recursiveCopyTreeUIDNode(
1505 std::map<std::string /*modified table*/, TableVersion /* modified version */>&
1507 const unsigned int startingDepth,
1508 const unsigned int depth,
1509 const unsigned int numberOfInstances,
1511 const std::string& uidToCopy)
1514 __COUTV__(startingDepth);
1516 __COUTV__(numberOfInstances);
1537 unsigned int col = cfgView->
getColUID();
1538 unsigned int row = cfgView->
findRow(col, uidToCopy);
1540 __COUT__ <<
"Copying " << cfgView->getTableName() <<
" v" << cfgView->getVersion()
1541 <<
" row=" << row <<
" record=" << uidToCopy
1542 <<
" instances=" << numberOfInstances << __E__;
1559 std::string tableName =
"secondary";
1562 TableBase* table = cfgMgr->getTableByName(tableName);
1565 table->setActiveView(version);
1569 if(version.isTemporaryVersion())
1572 __COUT__ <<
"Failed to find stored version, so attempting to "
1574 << tableName <<
" v" << version << __E__;
1575 cfgMgr->getVersionedTableByName(tableName, version);
1578 __COUT__ << tableName <<
" active version is " << table->
getViewVersion() << __E__;
1582 __SS__ <<
"Target table version (" << version
1583 <<
") is not the currently active version (" << table->
getViewVersion()
1584 <<
"). Try refreshing the tree." << __E__;
1599 __COUT__ <<
"Created temporary version " << temporaryVersion << __E__;
1612 __COUT__ <<
"Caught error while editing. Erasing temporary version." << __E__;
1613 table->eraseView(temporaryVersion);
1627 catch(std::runtime_error& e)
1629 __SS__ << (
"Error copying tree target '" + uidToCopy +
"' at depth " +
1630 std::to_string(startingDepth - depth) +
" in table '" +
1631 cfgView->getTableName() +
".' " + std::string(e.what()))
1633 __COUT__ <<
"\n" << ss.str() << __E__;
1634 xmlOut.addTextElementToData(
"Error", ss.str());
1638 __SS__ << (
"Error copying tree target '" + uidToCopy +
"' at depth " +
1639 std::to_string(startingDepth - depth) +
" in table '" +
1640 cfgView->getTableName() +
".' ")
1646 catch(
const std::exception& e)
1648 ss <<
"Exception message: " << e.what();
1653 __COUT__ <<
"\n" << ss.str() << __E__;
1654 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
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)
defines used also by OtsConfigurationWizardSupervisor
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)