otsdaq_utilities  v2_03_00
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  void handleGetTableGroupTypeXML(HttpXmlDocument& xmldoc,
74  ConfigurationManagerRW* cfgMgr,
75  const std::string& configList);
76  void handleCreateTableGroupXML(HttpXmlDocument& xmldoc,
77  ConfigurationManagerRW* cfgMgr,
78  const std::string& groupName,
79  const std::string& configList,
80  bool allowDuplicates = false,
81  bool ignoreWarnings = false,
82  const std::string& groupComment = "",
83  bool lookForEquivalent = false);
84 
85  void handleTablesXML(HttpXmlDocument& xmldoc,
86  ConfigurationManagerRW* cfgMgr,
87  bool allowIllegalColumns);
88  void handleGetTableXML(HttpXmlDocument& xmldoc,
89  ConfigurationManagerRW* cfgMgr,
90  const std::string& tableName,
91  TableVersion version,
92  bool allowIllegalColumns = false);
93  void handleCreateTableXML(HttpXmlDocument& xmldoc,
94  ConfigurationManagerRW* cfgMgr,
95  const std::string& tableName,
96  TableVersion version,
97  bool makeTemporary,
98  const std::string& data,
99  const int& dataOffset,
100  const std::string& author,
101  const std::string& comment,
102  bool sourceTableAsIs,
103  bool lookForEquivalent);
104 
105  void setupActiveTablesXML(
106  HttpXmlDocument& xmldoc,
107  ConfigurationManagerRW* cfgMgr,
108  const std::string& groupName,
109  const TableGroupKey& groupKey,
110  const std::string& modifiedTables,
111  bool refreshAll = true,
112  bool getGroupInfo = false,
113  std::map<std::string /*name*/, TableVersion /*version*/>* returnMemberMap = 0,
114  bool outputActiveTables = true,
115  std::string* accumulatedErrors = 0);
116  void handleFillTreeViewXML(HttpXmlDocument& xmldoc,
117  ConfigurationManagerRW* cfgMgr,
118  const std::string& groupName,
119  const TableGroupKey& groupKey,
120  const std::string& startPath,
121  unsigned int depth,
122  bool hideStatusFalse,
123  const std::string& modifiedTables,
124  const std::string& filterList);
125  static void recursiveTreeToXML(const ConfigurationTree& t,
126  unsigned int depth,
127  HttpXmlDocument& xmldoc,
128  DOMElement* parentEl,
129  bool hideStatusFalse);
130  void handleFillTreeNodeCommonFieldsXML(HttpXmlDocument& xmldoc,
131  ConfigurationManagerRW* cfgMgr,
132  const std::string& groupName,
133  const TableGroupKey& groupKey,
134  const std::string& startPath,
135  unsigned int depth,
136  const std::string& modifiedTables,
137  const std::string& recordList,
138  const std::string& fieldList);
139  void handleFillUniqueFieldValuesForRecordsXML(HttpXmlDocument& xmldoc,
140  ConfigurationManagerRW* cfgMgr,
141  const std::string& groupName,
142  const TableGroupKey& groupKey,
143  const std::string& startPath,
144  const std::string& modifiedTables,
145  const std::string& recordList,
146  const std::string& fieldList);
147  void handleFillGetTreeNodeFieldValuesXML(HttpXmlDocument& xmldoc,
148  ConfigurationManagerRW* cfgMgr,
149  const std::string& groupName,
150  const TableGroupKey& groupKey,
151  const std::string& startPath,
152  const std::string& modifiedTables,
153  const std::string& recordList,
154  const std::string& fieldList);
155  void handleFillSetTreeNodeFieldValuesXML(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& fieldList,
163  const std::string& valueList,
164  const std::string& author);
165  void handleFillCreateTreeNodeRecordsXML(HttpXmlDocument& xmldoc,
166  ConfigurationManagerRW* cfgMgr,
167  const std::string& groupName,
168  const TableGroupKey& groupKey,
169  const std::string& startPath,
170  const std::string& modifiedTables,
171  const std::string& recordList,
172  const std::string& author);
173  void handleFillDeleteTreeNodeRecordsXML(HttpXmlDocument& xmldoc,
174  ConfigurationManagerRW* cfgMgr,
175  const std::string& groupName,
176  const TableGroupKey& groupKey,
177  const std::string& startPath,
178  const std::string& modifiedTables,
179  const std::string& recordList);
180  void handleFillModifiedTablesXML(HttpXmlDocument& xmldoc,
181  ConfigurationManagerRW* cfgMgr);
182 
183  void handleSaveTreeNodeEditXML(HttpXmlDocument& xmldoc,
184  ConfigurationManagerRW* cfgMgr,
185  const std::string& tableName,
186  TableVersion version,
187  const std::string& type,
188  const std::string& uid,
189  const std::string& column,
190  const std::string& newValue,
191  const std::string& author);
192  void handleGetAffectedGroupsXML(HttpXmlDocument& xmldoc,
193  ConfigurationManagerRW* cfgMgr,
194  const std::string& rootGroupName,
195  const TableGroupKey& rootGroupKey,
196  const std::string& modifiedTables);
197  void handleGetLinkToChoicesXML(HttpXmlDocument& xmldoc,
198  ConfigurationManagerRW* cfgMgr,
199  const std::string& linkToTableName,
200  const TableVersion& linkToTableVersion,
201  const std::string& linkIdType,
202  const std::string& linkIndex,
203  const std::string& linkInitId);
204 
205  void handleSavePlanCommandSequenceXML(HttpXmlDocument& xmldoc,
206  ConfigurationManagerRW* cfgMgr,
207  const std::string& groupName,
208  const TableGroupKey& groupKey,
209  const std::string& modifiedTables,
210  const std::string& author,
211  const std::string& planName,
212  const std::string& commandString);
213 
214  void handleMergeGroupsXML(HttpXmlDocument& xmlOut,
215  ConfigurationManagerRW* cfgMgr,
216  const std::string& groupANameContext,
217  const TableGroupKey& groupAKeyContext,
218  const std::string& groupBNameContext,
219  const TableGroupKey& groupBKeyContext,
220  const std::string& groupANameConfig,
221  const TableGroupKey& groupAKeyConfig,
222  const std::string& groupBNameConfig,
223  const TableGroupKey& groupBKeyConfig,
224  const std::string& author,
225  const std::string& mergeApproach);
226 
227  TableVersion saveModifiedVersionXML(HttpXmlDocument& xmldoc,
228  ConfigurationManagerRW* cfgMgr,
229  const std::string& tableName,
230  TableVersion originalVersion,
231  bool makeTemporary,
232  TableBase* config,
233  TableVersion temporaryModifiedVersion,
234  bool ignoreDuplicates = false,
235  bool lookForEquivalent = false);
236 
237  void testXDAQContext(void);
238 
239  enum
240  {
241  CONFIGURATION_MANAGER_EXPIRATION_TIME = 60 * 60 * 1, // 1 hour, in seconds
242  CONFIGURATION_MANAGER_REFRESH_THRESHOLD = 60 * 15, // 15 minutes, in seconds
243  };
244 
245  ConfigurationManagerRW* refreshUserSession(std::string username,
246  uint64_t activeSessionIndex,
247  bool refresh);
248  std::map<std::string, ConfigurationManagerRW*> userConfigurationManagers_;
249  std::map<std::string, time_t> userLastUseTime_;
250 };
251 
252 } // end ots namespace
253 
254 #endif
static xdaq::Application * instantiate(xdaq::ApplicationStub *s)