otsdaq_utilities  v2_05_02_indev
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 
11 // ConfigurationGUISupervisor
12 // This class handles the user requests to read and write the Configuration Tree.
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; // override to force supervisor property values (and ignore user settings)
29 
30  private:
31  void handleSaveTableInfoXML (
32  HttpXmlDocument& xmldoc,
33  ConfigurationManagerRW* cfgMgr,
34  std::string& tableName,
35  const std::string& columnCSV,
36  const std::string& tableDescription,
37  const std::string& columnChoicesCSV,
38  bool allowOverwrite = false);
39  void handleDeleteTableInfoXML (
40  HttpXmlDocument& xmldoc,
41  ConfigurationManagerRW* cfgMgr,
42  std::string& tableName);
43 
44  void handleGroupAliasesXML (HttpXmlDocument& xmldoc, ConfigurationManagerRW* cfgMgr);
45  void handleSetGroupAliasInBackboneXML (HttpXmlDocument& xmldoc,
46  ConfigurationManagerRW* cfgMgr,
47  const std::string& groupAlias,
48  const std::string& groupName,
49  TableGroupKey groupKey,
50  const std::string& author);
51  void handleSetVersionAliasInBackboneXML (HttpXmlDocument& xmldoc,
52  ConfigurationManagerRW* cfgMgr,
53  const std::string& versionAlias,
54  const std::string& tableName,
55  TableVersion version,
56  const std::string& author);
57  void handleAliasGroupMembersInBackboneXML(HttpXmlDocument& xmldoc,
58  ConfigurationManagerRW* cfgMgr,
59  const std::string& versionAlias,
60  const std::string& groupName,
61  TableGroupKey groupKey,
62  const std::string& author);
63  void handleVersionAliasesXML (HttpXmlDocument& xmldoc, ConfigurationManagerRW* cfgMgr);
64  void handleTableGroupsXML (HttpXmlDocument& xmldoc,
65  ConfigurationManagerRW* cfgMgr,
66  bool returnMembers);
67  void handleGetTableGroupTypeXML (HttpXmlDocument& xmldoc,
68  ConfigurationManagerRW* cfgMgr,
69  const std::string& configList);
70 
71  void handleTablesXML (HttpXmlDocument& xmldoc,
72  ConfigurationManagerRW* cfgMgr,
73  bool allowIllegalColumns);
74  void handleGetTableXML (HttpXmlDocument& xmldoc,
75  ConfigurationManagerRW* cfgMgr,
76  const std::string& tableName,
77  TableVersion version,
78  bool allowIllegalColumns = false);
79 
80  void setupActiveTablesXML (
81  HttpXmlDocument& xmldoc,
82  ConfigurationManagerRW* cfgMgr,
83  const std::string& groupName,
84  const TableGroupKey& groupKey,
85  const std::string& modifiedTables,
86  bool refreshAll = true,
87  bool getGroupInfo = false,
88  std::map<std::string /*name*/, TableVersion /*version*/>* returnMemberMap = 0,
89  bool outputActiveTables = true,
90  std::string* accumulatedErrors = 0);
91  void handleFillTreeViewXML (HttpXmlDocument& xmldoc,
92  ConfigurationManagerRW* cfgMgr,
93  const std::string& groupName,
94  const TableGroupKey& groupKey,
95  const std::string& startPath,
96  unsigned int depth,
97  bool hideStatusFalse,
98  const std::string& modifiedTables,
99  const std::string& filterList);
100  static void recursiveTreeToXML (const ConfigurationTree& t,
101  unsigned int depth,
102  HttpXmlDocument& xmldoc,
103  DOMElement* parentEl,
104  bool hideStatusFalse);
105  void handleFillTreeNodeCommonFieldsXML (HttpXmlDocument& xmldoc,
106  ConfigurationManagerRW* cfgMgr,
107  const std::string& groupName,
108  const TableGroupKey& groupKey,
109  const std::string& startPath,
110  unsigned int depth,
111  const std::string& modifiedTables,
112  const std::string& recordList,
113  const std::string& fieldList);
114  void handleFillUniqueFieldValuesForRecordsXML(HttpXmlDocument& xmldoc,
115  ConfigurationManagerRW* cfgMgr,
116  const std::string& groupName,
117  const TableGroupKey& groupKey,
118  const std::string& startPath,
119  const std::string& modifiedTables,
120  const std::string& recordList,
121  const std::string& fieldList);
122  void handleFillGetTreeNodeFieldValuesXML (HttpXmlDocument& xmldoc,
123  ConfigurationManagerRW* cfgMgr,
124  const std::string& groupName,
125  const TableGroupKey& groupKey,
126  const std::string& startPath,
127  const std::string& modifiedTables,
128  const std::string& recordList,
129  const std::string& fieldList);
130  void handleFillSetTreeNodeFieldValuesXML (HttpXmlDocument& xmldoc,
131  ConfigurationManagerRW* cfgMgr,
132  const std::string& groupName,
133  const TableGroupKey& groupKey,
134  const std::string& startPath,
135  const std::string& modifiedTables,
136  const std::string& recordList,
137  const std::string& fieldList,
138  const std::string& valueList,
139  const std::string& author);
140  void handleFillCreateTreeNodeRecordsXML (HttpXmlDocument& xmldoc,
141  ConfigurationManagerRW* cfgMgr,
142  const std::string& groupName,
143  const TableGroupKey& groupKey,
144  const std::string& startPath,
145  const std::string& modifiedTables,
146  const std::string& recordList,
147  const std::string& author);
148  void handleFillDeleteTreeNodeRecordsXML (HttpXmlDocument& xmldoc,
149  ConfigurationManagerRW* cfgMgr,
150  const std::string& groupName,
151  const TableGroupKey& groupKey,
152  const std::string& startPath,
153  const std::string& modifiedTables,
154  const std::string& recordList);
155  void handleFillRenameTreeNodeRecordsXML (HttpXmlDocument& xmldoc,
156  ConfigurationManagerRW* cfgMgr,
157  const std::string& groupName,
158  const TableGroupKey& groupKey,
159  const std::string& startPath,
160  const std::string& modifiedTables,
161  const std::string& recordList,
162  const std::string& newRecordList);
163  void handleFillCopyTreeNodeRecordsXML (HttpXmlDocument& xmldoc,
164  ConfigurationManagerRW* cfgMgr,
165  const std::string& groupName,
166  const TableGroupKey& groupKey,
167  const std::string& startPath,
168  const std::string& modifiedTables,
169  const std::string& recordList,
170  unsigned int numberOfCopies = 1);
171  void handleFillModifiedTablesXML (HttpXmlDocument& xmldoc, ConfigurationManagerRW* cfgMgr);
172 
173  void handleSaveTreeNodeEditXML (HttpXmlDocument& xmldoc,
174  ConfigurationManagerRW* cfgMgr,
175  const std::string& tableName,
176  TableVersion version,
177  const std::string& type,
178  const std::string& uid,
179  const std::string& column,
180  const std::string& newValue,
181  const std::string& author);
182  void handleGetAffectedGroupsXML (HttpXmlDocument& xmldoc,
183  ConfigurationManagerRW* cfgMgr,
184  const std::string& rootGroupName,
185  const TableGroupKey& rootGroupKey,
186  const std::string& modifiedTables);
187  void handleGetLinkToChoicesXML (HttpXmlDocument& xmldoc,
188  ConfigurationManagerRW* cfgMgr,
189  const std::string& linkToTableName,
190  const TableVersion& linkToTableVersion,
191  const std::string& linkIdType,
192  const std::string& linkIndex,
193  const std::string& linkInitId);
194 
195  void handleSavePlanCommandSequenceXML (
196  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 (
206  HttpXmlDocument& xmlOut,
207  ConfigurationManagerRW* cfgMgr,
208  const std::string& groupANameContext,
209  const TableGroupKey& groupAKeyContext,
210  const std::string& groupBNameContext,
211  const TableGroupKey& groupBKeyContext,
212  const std::string& groupANameConfig,
213  const TableGroupKey& groupAKeyConfig,
214  const std::string& groupBNameConfig,
215  const TableGroupKey& groupBKeyConfig,
216  const std::string& author,
217  const std::string& mergeApproach);
218 
219 
220  void handleGetArtdaqNodeRecordsXML (
221  HttpXmlDocument& xmlOut,
222  ConfigurationManagerRW* cfgMgr,
223  const std::string& modifiedTables);
224  void handleSaveArtdaqNodeRecordsXML (
225  const std::string& nodeString,
226  const std::string& subsystemString,
227  HttpXmlDocument& xmlOut,
228  ConfigurationManagerRW* cfgMgr,
229  const std::string& modifiedTables);
230  void handleLoadArtdaqNodeLayoutXML (
231  HttpXmlDocument& xmlOut,
232  ConfigurationManagerRW* cfgMgr,
233  const std::string& contextGroupName = "",
234  const TableGroupKey& contextGroupKey = TableGroupKey());
235  void handleSaveArtdaqNodeLayoutXML (
236  HttpXmlDocument& xmlOut,
237  ConfigurationManagerRW* cfgMgr,
238  const std::string& layoutString,
239  const std::string& contextGroupName = "",
240  const TableGroupKey& contextGroupKey = TableGroupKey());
241 
242  void testXDAQContext (void);
243 
244  enum
245  {
246  CONFIGURATION_MANAGER_EXPIRATION_TIME = 60 * 60 * 1, // 1 hour, in seconds
247  CONFIGURATION_MANAGER_REFRESH_THRESHOLD = 60 * 15, // 15 minutes, in seconds
248  };
249 
250  ConfigurationManagerRW* refreshUserSession(std::string username,
251  uint64_t activeSessionIndex,
252  bool refresh);
253  std::map<std::string, ConfigurationManagerRW*> userConfigurationManagers_;
254  std::map<std::string, time_t> userLastUseTime_;
255 };
256 
257 // clang-format on
258 } // end ots namespace
259 
260 #endif
static xdaq::Application * instantiate(xdaq::ApplicationStub *s)