otsdaq-utilities  3.08.00
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 
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  const std::string& filterStartTime,
72  const std::string& filterEndTime,
73  const std::string& filterMode = "created" /* "created" or "loaded" */);
74  void handleGetTableXML (HttpXmlDocument& xmldoc,
75  ConfigurationManagerRW* cfgMgr,
76  const std::string& tableName,
77  TableVersion version,
78  bool allowIllegalColumns = false,
79  bool getRawData = false,
80  bool descriptionOnly = false);
81 
82  void setupActiveTablesXML (HttpXmlDocument& xmldoc,
83  ConfigurationManagerRW* cfgMgr,
84  const std::string& groupName,
85  const TableGroupKey& groupKey,
86  const std::string& modifiedTables,
87  bool refreshAll = true,
88  bool getGroupInfo = false,
89  std::map<std::string /*name*/,
90  TableVersion /*version*/>* returnMemberMap = 0,
91  bool outputActiveTables = true,
92  std::string* accumulatedErrors = 0);
93  void handleFillTreeViewXML (HttpXmlDocument& xmldoc,
94  ConfigurationManagerRW* cfgMgr,
95  const std::string& groupName,
96  const TableGroupKey& groupKey,
97  const std::string& startPath,
98  unsigned int depth,
99  bool hideStatusFalse,
100  const std::string& modifiedTables,
101  const std::string& filterList,
102  const std::string& diffGroupName = "",
103  const TableGroupKey& diffGroupKey = TableGroupKey());
104  static void recursiveTreeToXML (const ConfigurationTree& t,
105  unsigned int depth,
106  HttpXmlDocument& xmldoc,
107  DOMElement* parentEl,
108  bool hideStatusFalse,
109  std::optional<std::reference_wrapper<const ConfigurationTree>> diffTree = std::nullopt);
110  void handleFillTreeNodeCommonFieldsXML (HttpXmlDocument& xmldoc,
111  ConfigurationManagerRW* cfgMgr,
112  const std::string& groupName,
113  const TableGroupKey& groupKey,
114  const std::string& startPath,
115  unsigned int depth,
116  const std::string& modifiedTables,
117  const std::string& recordList,
118  const std::string& fieldList);
119  void handleFillUniqueFieldValuesForRecordsXML(HttpXmlDocument& xmldoc,
120  ConfigurationManagerRW* cfgMgr,
121  const std::string& groupName,
122  const TableGroupKey& groupKey,
123  const std::string& startPath,
124  const std::string& modifiedTables,
125  const std::string& recordList,
126  const std::string& fieldList);
127  void handleFillGetTreeNodeFieldValuesXML (HttpXmlDocument& xmldoc,
128  ConfigurationManagerRW* cfgMgr,
129  const std::string& groupName,
130  const TableGroupKey& groupKey,
131  const std::string& startPath,
132  const std::string& modifiedTables,
133  const std::string& recordList,
134  const std::string& fieldList);
135  void handleFillSetTreeNodeFieldValuesXML (HttpXmlDocument& xmldoc,
136  ConfigurationManagerRW* cfgMgr,
137  const std::string& groupName,
138  const TableGroupKey& groupKey,
139  const std::string& startPath,
140  const std::string& modifiedTables,
141  const std::string& recordList,
142  const std::string& fieldList,
143  const std::string& valueList,
144  const std::string& author);
145  void handleFillCreateTreeNodeRecordsXML (HttpXmlDocument& xmldoc,
146  ConfigurationManagerRW* cfgMgr,
147  const std::string& groupName,
148  const TableGroupKey& groupKey,
149  const std::string& startPath,
150  const std::string& modifiedTables,
151  const std::string& recordList,
152  const std::string& author);
153  void handleFillDeleteTreeNodeRecordsXML (HttpXmlDocument& xmldoc,
154  ConfigurationManagerRW* cfgMgr,
155  const std::string& groupName,
156  const TableGroupKey& groupKey,
157  const std::string& startPath,
158  const std::string& modifiedTables,
159  const std::string& recordList);
160  void handleFillRenameTreeNodeRecordsXML (HttpXmlDocument& xmldoc,
161  ConfigurationManagerRW* cfgMgr,
162  const std::string& groupName,
163  const TableGroupKey& groupKey,
164  const std::string& startPath,
165  const std::string& modifiedTables,
166  const std::string& recordList,
167  const std::string& newRecordList);
168  void handleFillCopyTreeNodeRecordsXML (HttpXmlDocument& xmldoc,
169  ConfigurationManagerRW* cfgMgr,
170  const std::string& groupName,
171  const TableGroupKey& groupKey,
172  const std::string& startPath,
173  const std::string& modifiedTables,
174  const std::string& recordList,
175  unsigned int numberOfCopies = 1);
176  void handleFillModifiedTablesXML (HttpXmlDocument& xmldoc, ConfigurationManagerRW* cfgMgr);
177 
178  void handleSaveTreeNodeEditXML (HttpXmlDocument& xmldoc,
179  ConfigurationManagerRW* cfgMgr,
180  const std::string& tableName,
181  TableVersion version,
182  const std::string& type,
183  const std::string& uid,
184  const std::string& column,
185  const std::string& newValue,
186  const std::string& author);
187  void handleGetAffectedGroupsXML (HttpXmlDocument& xmldoc,
188  ConfigurationManagerRW* cfgMgr,
189  const std::string& rootGroupName,
190  const TableGroupKey& rootGroupKey,
191  const std::string& modifiedTables);
192  void handleGetLinkToChoicesXML (HttpXmlDocument& xmldoc,
193  ConfigurationManagerRW* cfgMgr,
194  const std::string& linkToTableName,
195  const TableVersion& linkToTableVersion,
196  const std::string& linkIdType,
197  const std::string& linkIndex,
198  const std::string& linkInitId);
199 
200  void handleSavePlanCommandSequenceXML (HttpXmlDocument& xmldoc,
201  ConfigurationManagerRW* cfgMgr,
202  const std::string& groupName,
203  const TableGroupKey& groupKey,
204  const std::string& modifiedTables,
205  const std::string& author,
206  const std::string& planName,
207  const std::string& commandString);
208 
209  void handleMergeGroupsXML (HttpXmlDocument& xmlOut,
210  ConfigurationManagerRW* cfgMgr,
211  const std::string& groupANameContext,
212  const TableGroupKey& groupAKeyContext,
213  const std::string& groupBNameContext,
214  const TableGroupKey& groupBKeyContext,
215  const std::string& groupANameConfig,
216  const TableGroupKey& groupAKeyConfig,
217  const std::string& groupBNameConfig,
218  const TableGroupKey& groupBKeyConfig,
219  const std::string& author,
220  const std::string& mergeApproach);
221 
222 
223  void handleGetArtdaqNodeRecordsXML (HttpXmlDocument& xmlOut,
224  ConfigurationManagerRW* cfgMgr,
225  const std::string& modifiedTables);
226  void handleSaveArtdaqNodeRecordsXML (const std::string& nodeString,
227  const std::string& subsystemString,
228  HttpXmlDocument& xmlOut,
229  ConfigurationManagerRW* cfgMgr,
230  const std::string& modifiedTables);
231  void handleLoadArtdaqNodeLayoutXML (HttpXmlDocument& xmlOut,
232  ConfigurationManager* cfgMgr,
233  const std::string& contextGroupName = "",
234  const TableGroupKey& contextGroupKey = TableGroupKey()) const;
235  void handleSaveArtdaqNodeLayoutXML (HttpXmlDocument& xmlOut,
236  ConfigurationManagerRW* cfgMgr,
237  const std::string& layoutString,
238  const std::string& contextGroupName = "",
239  const TableGroupKey& contextGroupKey = TableGroupKey());
240  void handleOtherSubsystemActiveGroups (HttpXmlDocument& xmlOut,
241  ConfigurationManagerRW* cfgMgr,
242  bool getFullList,
243  std::string targetSubsystem = "");
244  void handleGroupDiff (HttpXmlDocument& xmlOut,
245  ConfigurationManagerRW* cfgMgr,
246  const std::string& groupName,
247  const TableGroupKey& groupKey,
248  const TableGroupKey& diffKey = TableGroupKey(),
249  const std::string& diffGroupName = "");
250  void handleTableDiff (HttpXmlDocument& xmlOut,
251  ConfigurationManagerRW* cfgMgr,
252  const std::string& tableName,
253  const TableVersion& vA,
254  const TableVersion& vB);
255  void handleSearchFieldInGroupXML (HttpXmlDocument& xmlOut,
256  ConfigurationManagerRW* cfgMgr,
257  const std::string& searchText,
258  const bool activeGroupsOnly,
259  const std::string& groupType,
260  const std::string& optionGroups,
261  const std::string& versionsToCheck);
262  void handleSearchFieldInTableXML( HttpXmlDocument& xmlOut,
263  ConfigurationManagerRW* cfgMgr,
264  const std::string& searchText,
265  const std::string& tableName,
266  const std::string& searchVersionToCheck,
267  bool activeTablesOnly);
268 
269  void testXDAQContext (void);
270 
271  enum
272  {
273  CONFIGURATION_MANAGER_EXPIRATION_TIME = 60 * 60 * 24 * 2,
274  CONFIGURATION_MANAGER_REFRESH_THRESHOLD = 60 * 60 * 24,
275  };
276 
277  ConfigurationManagerRW* refreshUserSession (std::string username,
278  bool refresh);
279 
280  std::map<std::string, ConfigurationManagerRW*> userConfigurationManagers_;
281  std::map<std::string, time_t> userLastUseTime_;
282 };
283 
284 // clang-format on
285 } // namespace ots
286 
287 #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)