otsdaq_utilities  v2_04_01
ConfigurationGUISupervisor.h
1 #ifndef _ots_ConfigurationGUISupervisor_h_
2 #define _ots_ConfigurationGUISupervisor_h_
3 
4 #include "otsdaq-core/ConfigurationInterface/ConfigurationManagerRW.h"
5 #include "otsdaq-core/CoreSupervisors/CoreSupervisorBase.h"
6 
7 namespace ots
8 {
9 // ConfigurationGUISupervisor
10 // This class handles the user requests to read and write the Configuration Tree.
11 class ConfigurationGUISupervisor : public CoreSupervisorBase
12 {
13  public:
14  static xdaq::Application* instantiate(xdaq::ApplicationStub* s);
15 
16  ConfigurationGUISupervisor(xdaq::ApplicationStub* s);
17  virtual ~ConfigurationGUISupervisor(void);
18 
19  void init(void);
20  void destroy(void);
21 
22  virtual void defaultPage(xgi::Input* in, xgi::Output* out) override;
23  virtual void request(const std::string& requestType,
24  cgicc::Cgicc& cgiIn,
25  HttpXmlDocument& xmlOut,
26  const WebUsers::RequestUserInfo& userInfo) override;
27 
28  virtual void setSupervisorPropertyDefaults(void) override;
29  virtual void forceSupervisorPropertyValues(void) override; // override to force
30  // supervisor property
31  // values (and ignore user
32  // settings)
33 
34  private:
35  void handleSaveTableInfoXML(HttpXmlDocument& xmldoc,
36  ConfigurationManagerRW* cfgMgr,
37  std::string& tableName,
38  const std::string& columnCSV,
39  const std::string& tableDescription,
40  const std::string& columnChoicesCSV,
41  bool allowOverwrite = false);
42  void handleDeleteTableInfoXML(HttpXmlDocument& xmldoc,
43  ConfigurationManagerRW* cfgMgr,
44  std::string& tableName);
45 
46  void handleGroupAliasesXML(HttpXmlDocument& xmldoc, ConfigurationManagerRW* cfgMgr);
47  void handleSetGroupAliasInBackboneXML(HttpXmlDocument& xmldoc,
48  ConfigurationManagerRW* cfgMgr,
49  const std::string& groupAlias,
50  const std::string& groupName,
51  TableGroupKey groupKey,
52  const std::string& author);
53  void handleSetVersionAliasInBackboneXML(HttpXmlDocument& xmldoc,
54  ConfigurationManagerRW* cfgMgr,
55  const std::string& versionAlias,
56  const std::string& tableName,
57  TableVersion version,
58  const std::string& author);
59  void handleAliasGroupMembersInBackboneXML(HttpXmlDocument& xmldoc,
60  ConfigurationManagerRW* cfgMgr,
61  const std::string& versionAlias,
62  const std::string& groupName,
63  TableGroupKey groupKey,
64  const std::string& author);
65  void handleVersionAliasesXML(HttpXmlDocument& xmldoc, ConfigurationManagerRW* cfgMgr);
66  void handleTableGroupsXML(HttpXmlDocument& xmldoc,
67  ConfigurationManagerRW* cfgMgr,
68  bool returnMembers);
69  void handleGetTableGroupXML(HttpXmlDocument& xmldoc,
70  ConfigurationManagerRW* cfgMgr,
71  const std::string& groupName,
72  TableGroupKey groupKey,
73  bool ignoreWarnings = false);
74  void handleGetTableGroupTypeXML(HttpXmlDocument& xmldoc,
75  ConfigurationManagerRW* cfgMgr,
76  const std::string& configList);
77  void handleCreateTableGroupXML(HttpXmlDocument& xmldoc,
78  ConfigurationManagerRW* cfgMgr,
79  const std::string& groupName,
80  const std::string& configList,
81  bool allowDuplicates = false,
82  bool ignoreWarnings = false,
83  const std::string& groupComment = "",
84  bool lookForEquivalent = false);
85 
86  void handleTablesXML(HttpXmlDocument& xmldoc,
87  ConfigurationManagerRW* cfgMgr,
88  bool allowIllegalColumns);
89  void handleGetTableXML(HttpXmlDocument& xmldoc,
90  ConfigurationManagerRW* cfgMgr,
91  const std::string& tableName,
92  TableVersion version,
93  bool allowIllegalColumns = false);
94  void handleCreateTableXML(HttpXmlDocument& xmldoc,
95  ConfigurationManagerRW* cfgMgr,
96  const std::string& tableName,
97  TableVersion version,
98  bool makeTemporary,
99  const std::string& data,
100  const int& dataOffset,
101  const std::string& author,
102  const std::string& comment,
103  bool sourceTableAsIs,
104  bool lookForEquivalent);
105 
106  void setupActiveTablesXML(
107  HttpXmlDocument& xmldoc,
108  ConfigurationManagerRW* cfgMgr,
109  const std::string& groupName,
110  const TableGroupKey& groupKey,
111  const std::string& modifiedTables,
112  bool refreshAll = true,
113  bool getGroupInfo = false,
114  std::map<std::string /*name*/, TableVersion /*version*/>* returnMemberMap = 0,
115  bool outputActiveTables = true,
116  std::string* accumulatedErrors = 0);
117  void handleFillTreeViewXML(HttpXmlDocument& xmldoc,
118  ConfigurationManagerRW* cfgMgr,
119  const std::string& groupName,
120  const TableGroupKey& groupKey,
121  const std::string& startPath,
122  unsigned int depth,
123  bool hideStatusFalse,
124  const std::string& modifiedTables,
125  const std::string& filterList);
126  static void recursiveTreeToXML(const ConfigurationTree& t,
127  unsigned int depth,
128  HttpXmlDocument& xmldoc,
129  DOMElement* parentEl,
130  bool hideStatusFalse);
131  void handleFillTreeNodeCommonFieldsXML(HttpXmlDocument& xmldoc,
132  ConfigurationManagerRW* cfgMgr,
133  const std::string& groupName,
134  const TableGroupKey& groupKey,
135  const std::string& startPath,
136  unsigned int depth,
137  const std::string& modifiedTables,
138  const std::string& recordList,
139  const std::string& fieldList);
140  void handleFillUniqueFieldValuesForRecordsXML(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& fieldList);
148  void handleFillGetTreeNodeFieldValuesXML(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  const std::string& fieldList);
156  void handleFillSetTreeNodeFieldValuesXML(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& fieldList,
164  const std::string& valueList,
165  const std::string& author);
166  void handleFillCreateTreeNodeRecordsXML(HttpXmlDocument& xmldoc,
167  ConfigurationManagerRW* cfgMgr,
168  const std::string& groupName,
169  const TableGroupKey& groupKey,
170  const std::string& startPath,
171  const std::string& modifiedTables,
172  const std::string& recordList,
173  const std::string& author);
174  void handleFillDeleteTreeNodeRecordsXML(HttpXmlDocument& xmldoc,
175  ConfigurationManagerRW* cfgMgr,
176  const std::string& groupName,
177  const TableGroupKey& groupKey,
178  const std::string& startPath,
179  const std::string& modifiedTables,
180  const std::string& recordList);
181  void handleFillModifiedTablesXML(HttpXmlDocument& xmldoc,
182  ConfigurationManagerRW* cfgMgr);
183 
184  void handleSaveTreeNodeEditXML(HttpXmlDocument& xmldoc,
185  ConfigurationManagerRW* cfgMgr,
186  const std::string& tableName,
187  TableVersion version,
188  const std::string& type,
189  const std::string& uid,
190  const std::string& column,
191  const std::string& newValue,
192  const std::string& author);
193  void handleGetAffectedGroupsXML(HttpXmlDocument& xmldoc,
194  ConfigurationManagerRW* cfgMgr,
195  const std::string& rootGroupName,
196  const TableGroupKey& rootGroupKey,
197  const std::string& modifiedTables);
198  void handleGetLinkToChoicesXML(HttpXmlDocument& xmldoc,
199  ConfigurationManagerRW* cfgMgr,
200  const std::string& linkToTableName,
201  const TableVersion& linkToTableVersion,
202  const std::string& linkIdType,
203  const std::string& linkIndex,
204  const std::string& linkInitId);
205 
206  void handleSavePlanCommandSequenceXML(HttpXmlDocument& xmldoc,
207  ConfigurationManagerRW* cfgMgr,
208  const std::string& groupName,
209  const TableGroupKey& groupKey,
210  const std::string& modifiedTables,
211  const std::string& author,
212  const std::string& planName,
213  const std::string& commandString);
214 
215  void handleMergeGroupsXML(HttpXmlDocument& xmlOut,
216  ConfigurationManagerRW* cfgMgr,
217  const std::string& groupANameContext,
218  const TableGroupKey& groupAKeyContext,
219  const std::string& groupBNameContext,
220  const TableGroupKey& groupBKeyContext,
221  const std::string& groupANameConfig,
222  const TableGroupKey& groupAKeyConfig,
223  const std::string& groupBNameConfig,
224  const TableGroupKey& groupBKeyConfig,
225  const std::string& author,
226  const std::string& mergeApproach);
227 
228  TableVersion saveModifiedVersionXML(HttpXmlDocument& xmldoc,
229  ConfigurationManagerRW* cfgMgr,
230  const std::string& tableName,
231  TableVersion originalVersion,
232  bool makeTemporary,
233  TableBase* config,
234  TableVersion temporaryModifiedVersion,
235  bool ignoreDuplicates = false,
236  bool lookForEquivalent = false);
237 
238  void testXDAQContext(void);
239 
240  enum
241  {
242  CONFIGURATION_MANAGER_EXPIRATION_TIME = 60 * 60 * 1, // 1 hour, in seconds
243  CONFIGURATION_MANAGER_REFRESH_THRESHOLD = 60 * 15, // 15 minutes, in seconds
244  };
245 
246  ConfigurationManagerRW* refreshUserSession(std::string username,
247  uint64_t activeSessionIndex,
248  bool refresh);
249  std::map<std::string, ConfigurationManagerRW*> userConfigurationManagers_;
250  std::map<std::string, time_t> userLastUseTime_;
251 };
252 
253 } // end ots namespace
254 
255 #endif
static xdaq::Application * instantiate(xdaq::ApplicationStub *s)