tdaq-develop-2025-02-12
ConfigurationGUISupervisor.h
1 #ifndef _ots_ConfigurationGUISupervisor_h_
2 #define _ots_ConfigurationGUISupervisor_h_
3 
4 #include "otsdaq/ConfigurationInterface/ConfigurationManagerRW.h"
5 #include "otsdaq/CoreSupervisors/CoreSupervisorBase.h"
6 
7 namespace ots
8 {
9 // clang-format off
10 
13 class ConfigurationGUISupervisor : public CoreSupervisorBase
14 {
15  public:
16  static xdaq::Application* instantiate(xdaq::ApplicationStub* s);
17 
18  ConfigurationGUISupervisor (xdaq::ApplicationStub* s);
19  virtual ~ConfigurationGUISupervisor (void);
20 
21  void init (void);
22  void destroy (void);
23 
24  virtual void defaultPage (xgi::Input* in, xgi::Output* out) override;
25  virtual void request (const std::string& requestType,cgicc::Cgicc& cgiIn, HttpXmlDocument& xmlOut, const WebUsers::RequestUserInfo& userInfo) override;
26 
27  virtual void setSupervisorPropertyDefaults (void) override;
28  virtual void forceSupervisorPropertyValues (void) override;
29 
30  private:
31  void handleSaveTableInfoXML (HttpXmlDocument& xmldoc,
32  ConfigurationManagerRW* cfgMgr,
33  std::string& tableName,
34  const std::string& columnCSV,
35  const std::string& tableDescription,
36  const std::string& columnChoicesCSV,
37  bool allowOverwrite = false);
38  void handleDeleteTableInfoXML (HttpXmlDocument& xmldoc,
39  ConfigurationManagerRW* cfgMgr,
40  std::string& tableName);
41 
42  void handleGroupAliasesXML (HttpXmlDocument& xmldoc, ConfigurationManagerRW* cfgMgr);
43  void handleSetGroupAliasInBackboneXML (HttpXmlDocument& xmldoc,
44  ConfigurationManagerRW* cfgMgr,
45  const std::string& groupAliasCSV,
46  const std::string& groupNameCSV,
47  const std::string& groupKeyCSV,
48  const std::string& author);
49  void handleSetTableAliasInBackboneXML (HttpXmlDocument& xmldoc,
50  ConfigurationManagerRW* cfgMgr,
51  const std::string& versionAlias,
52  const std::string& tableName,
53  TableVersion version,
54  const std::string& author);
55  void handleAliasGroupMembersInBackboneXML (HttpXmlDocument& xmldoc,
56  ConfigurationManagerRW* cfgMgr,
57  const std::string& versionAlias,
58  const std::string& groupName,
59  TableGroupKey groupKey,
60  const std::string& author);
61  void handleVersionAliasesXML (HttpXmlDocument& xmldoc, ConfigurationManagerRW* cfgMgr);
62  void handleTableGroupsXML (HttpXmlDocument& xmldoc,
63  ConfigurationManagerRW* cfgMgr,
64  bool returnMembers);
65  void handleGetTableGroupTypeXML (HttpXmlDocument& xmldoc,
66  ConfigurationManagerRW* cfgMgr,
67  const std::string& configList);
68 
69  void handleTablesXML (HttpXmlDocument& xmldoc,
70  ConfigurationManagerRW* cfgMgr);
71  void handleGetTableXML (HttpXmlDocument& xmldoc,
72  ConfigurationManagerRW* cfgMgr,
73  const std::string& tableName,
74  TableVersion version,
75  bool allowIllegalColumns = false,
76  bool getRawData = false);
77 
78  void setupActiveTablesXML (HttpXmlDocument& xmldoc,
79  ConfigurationManagerRW* cfgMgr,
80  const std::string& groupName,
81  const TableGroupKey& groupKey,
82  const std::string& modifiedTables,
83  bool refreshAll = true,
84  bool getGroupInfo = false,
85  std::map<std::string /*name*/,
86  TableVersion /*version*/>* returnMemberMap = 0,
87  bool outputActiveTables = true,
88  std::string* accumulatedErrors = 0);
89  void handleFillTreeViewXML (HttpXmlDocument& xmldoc,
90  ConfigurationManagerRW* cfgMgr,
91  const std::string& groupName,
92  const TableGroupKey& groupKey,
93  const std::string& startPath,
94  unsigned int depth,
95  bool hideStatusFalse,
96  const std::string& modifiedTables,
97  const std::string& filterList,
98  const std::string& diffGroupName = "",
99  const TableGroupKey& diffGroupKey = TableGroupKey());
100  static void recursiveTreeToXML (const ConfigurationTree& t,
101  unsigned int depth,
102  HttpXmlDocument& xmldoc,
103  DOMElement* parentEl,
104  bool hideStatusFalse,
105  std::optional<std::reference_wrapper<const ConfigurationTree>> diffTree = std::nullopt);
106  void handleFillTreeNodeCommonFieldsXML (HttpXmlDocument& xmldoc,
107  ConfigurationManagerRW* cfgMgr,
108  const std::string& groupName,
109  const TableGroupKey& groupKey,
110  const std::string& startPath,
111  unsigned int depth,
112  const std::string& modifiedTables,
113  const std::string& recordList,
114  const std::string& fieldList);
115  void handleFillUniqueFieldValuesForRecordsXML(HttpXmlDocument& xmldoc,
116  ConfigurationManagerRW* cfgMgr,
117  const std::string& groupName,
118  const TableGroupKey& groupKey,
119  const std::string& startPath,
120  const std::string& modifiedTables,
121  const std::string& recordList,
122  const std::string& fieldList);
123  void handleFillGetTreeNodeFieldValuesXML (HttpXmlDocument& xmldoc,
124  ConfigurationManagerRW* cfgMgr,
125  const std::string& groupName,
126  const TableGroupKey& groupKey,
127  const std::string& startPath,
128  const std::string& modifiedTables,
129  const std::string& recordList,
130  const std::string& fieldList);
131  void handleFillSetTreeNodeFieldValuesXML (HttpXmlDocument& xmldoc,
132  ConfigurationManagerRW* cfgMgr,
133  const std::string& groupName,
134  const TableGroupKey& groupKey,
135  const std::string& startPath,
136  const std::string& modifiedTables,
137  const std::string& recordList,
138  const std::string& fieldList,
139  const std::string& valueList,
140  const std::string& author);
141  void handleFillCreateTreeNodeRecordsXML (HttpXmlDocument& xmldoc,
142  ConfigurationManagerRW* cfgMgr,
143  const std::string& groupName,
144  const TableGroupKey& groupKey,
145  const std::string& startPath,
146  const std::string& modifiedTables,
147  const std::string& recordList,
148  const std::string& author);
149  void handleFillDeleteTreeNodeRecordsXML (HttpXmlDocument& xmldoc,
150  ConfigurationManagerRW* cfgMgr,
151  const std::string& groupName,
152  const TableGroupKey& groupKey,
153  const std::string& startPath,
154  const std::string& modifiedTables,
155  const std::string& recordList);
156  void handleFillRenameTreeNodeRecordsXML (HttpXmlDocument& xmldoc,
157  ConfigurationManagerRW* cfgMgr,
158  const std::string& groupName,
159  const TableGroupKey& groupKey,
160  const std::string& startPath,
161  const std::string& modifiedTables,
162  const std::string& recordList,
163  const std::string& newRecordList);
164  void handleFillCopyTreeNodeRecordsXML (HttpXmlDocument& xmldoc,
165  ConfigurationManagerRW* cfgMgr,
166  const std::string& groupName,
167  const TableGroupKey& groupKey,
168  const std::string& startPath,
169  const std::string& modifiedTables,
170  const std::string& recordList,
171  unsigned int numberOfCopies = 1);
172  void handleFillModifiedTablesXML (HttpXmlDocument& xmldoc, ConfigurationManagerRW* cfgMgr);
173 
174  void handleSaveTreeNodeEditXML (HttpXmlDocument& xmldoc,
175  ConfigurationManagerRW* cfgMgr,
176  const std::string& tableName,
177  TableVersion version,
178  const std::string& type,
179  const std::string& uid,
180  const std::string& column,
181  const std::string& newValue,
182  const std::string& author);
183  void handleGetAffectedGroupsXML (HttpXmlDocument& xmldoc,
184  ConfigurationManagerRW* cfgMgr,
185  const std::string& rootGroupName,
186  const TableGroupKey& rootGroupKey,
187  const std::string& modifiedTables);
188  void handleGetLinkToChoicesXML (HttpXmlDocument& xmldoc,
189  ConfigurationManagerRW* cfgMgr,
190  const std::string& linkToTableName,
191  const TableVersion& linkToTableVersion,
192  const std::string& linkIdType,
193  const std::string& linkIndex,
194  const std::string& linkInitId);
195 
196  void handleSavePlanCommandSequenceXML (HttpXmlDocument& xmldoc,
197  ConfigurationManagerRW* cfgMgr,
198  const std::string& groupName,
199  const TableGroupKey& groupKey,
200  const std::string& modifiedTables,
201  const std::string& author,
202  const std::string& planName,
203  const std::string& commandString);
204 
205  void handleMergeGroupsXML (HttpXmlDocument& xmlOut,
206  ConfigurationManagerRW* cfgMgr,
207  const std::string& groupANameContext,
208  const TableGroupKey& groupAKeyContext,
209  const std::string& groupBNameContext,
210  const TableGroupKey& groupBKeyContext,
211  const std::string& groupANameConfig,
212  const TableGroupKey& groupAKeyConfig,
213  const std::string& groupBNameConfig,
214  const TableGroupKey& groupBKeyConfig,
215  const std::string& author,
216  const std::string& mergeApproach);
217 
218 
219  void handleGetArtdaqNodeRecordsXML (HttpXmlDocument& xmlOut,
220  ConfigurationManagerRW* cfgMgr,
221  const std::string& modifiedTables);
222  void handleSaveArtdaqNodeRecordsXML (const std::string& nodeString,
223  const std::string& subsystemString,
224  HttpXmlDocument& xmlOut,
225  ConfigurationManagerRW* cfgMgr,
226  const std::string& modifiedTables);
227  void handleLoadArtdaqNodeLayoutXML (HttpXmlDocument& xmlOut,
228  ConfigurationManager* cfgMgr,
229  const std::string& contextGroupName = "",
230  const TableGroupKey& contextGroupKey = TableGroupKey()) const;
231  void handleSaveArtdaqNodeLayoutXML (HttpXmlDocument& xmlOut,
232  ConfigurationManagerRW* cfgMgr,
233  const std::string& layoutString,
234  const std::string& contextGroupName = "",
235  const TableGroupKey& contextGroupKey = TableGroupKey());
236  void handleOtherSubsystemActiveGroups (HttpXmlDocument& xmlOut,
237  ConfigurationManagerRW* cfgMgr,
238  bool getFullList,
239  std::string targetSubsystem = "");
240  void handleGroupDiff (HttpXmlDocument& xmlOut,
241  ConfigurationManagerRW* cfgMgr,
242  const std::string& groupName,
243  const TableGroupKey& groupKey,
244  const TableGroupKey& diffKey = TableGroupKey(),
245  const std::string& diffGroupName = "");
246  void handleTableDiff (HttpXmlDocument& xmlOut,
247  ConfigurationManagerRW* cfgMgr,
248  const std::string& tableName,
249  const TableVersion& vA,
250  const TableVersion& vB);
251 
252 
253 
254  void testXDAQContext (void);
255 
256  enum
257  {
258  CONFIGURATION_MANAGER_EXPIRATION_TIME = 60 * 60 * 1,
259  CONFIGURATION_MANAGER_REFRESH_THRESHOLD = 60 * 15,
260  };
261 
262  ConfigurationManagerRW* refreshUserSession (std::string username,
263  bool refresh);
264 
265  std::map<std::string, ConfigurationManagerRW*> userConfigurationManagers_;
266  std::map<std::string, time_t> userLastUseTime_;
267 };
268 
269 // clang-format on
270 } // namespace ots
271 
272 #endif
virtual void forceSupervisorPropertyValues(void) override
override to force supervisor property values (and ignore user settings)
virtual void setSupervisorPropertyDefaults(void) override
ConfigurationGUISupervisor(xdaq::ApplicationStub *s)
static xdaq::Application * instantiate(xdaq::ApplicationStub *s)