source: branches/work_311/util/RefItem.h @ 614

Revision 614, 9.0 KB checked in by jls17, 5 years ago (diff)
  • creating a reference between audit target and audit source form
Line 
1//Copyright (C) 2010 John Luthgers | jls17
2//
3//This file is part of ARInside.
4//
5//    ARInside is free software: you can redistribute it and/or modify
6//    it under the terms of the GNU General Public License as published by
7//    the Free Software Foundation, version 2 of the License.
8//
9//    ARInside is distributed in the hope that it will be useful,
10//    but WITHOUT ANY WARRANTY; without even the implied warranty of
11//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12//    GNU General Public License for more details.
13//
14//    You should have received a copy of the GNU General Public License
15//    along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
16
17#pragma once
18
19/*
20 * Storing references
21 * ==================
22 *
23 * The old referencing object stored some redundant informations as well as the description text
24 * of the reference. The problem with the description text is, that it could contain html-links
25 * to other pages. If such a reference is not put on the desired page (sub-dir-level), e.g. the
26 * "Missing Fields Validator", the contained html-link becomes invalid.
27 * There are two solutions to this problem:
28 *   a) all pages that would display that reference have to be in the same sub-dir level (all
29 *      links become valid this way)
30 *   b) the description is generated when the reference is placed on a page (the correct sub-dir
31 *      level can be used during description-text generation)
32 *
33 * Solution b) has another advantage. Because the text is not stored within the reference (just
34 * a message identifier) the memory usage of the reference object is reduced. On bigger servers
35 * this can become a huge benefit.
36 *
37 * Data storage the "old way"
38 * ==========================
39 * The old object stored the following data:
40 *      int arsStructItemType;
41 *      string fromName;
42 *      int fromFieldId;        // use this to create a reference between two field (e.g. a field used as column in a table); fromName should hold the schema name in this case
43 *      string description;
44 *      int fieldInsideId;
45 *      int schemaInsideId;
46 *
47 * Because ARInside organizes all internal ARSystem data wihtin lists and uses array-index-like
48 * ids to access those lists, it just needs a type and a id to reference the same object again.
49 * So storing the fromName is not the best choise, because later you have to lookup the object
50 * by its name again, which costs more than direct access by list-index.
51 *
52 * New Data storage
53 * ================
54 * Now we store the following data to support all kinds of references:
55 *      int arsStructItemType;
56 *      int objectId;
57 *      int subObjectId;
58 *      int actionIndex;
59 *      int messageId;
60 *
61 * So this uses 20 bytes per references. 50000 references would need only 1MB of memory. How the
62 * above listed variables "subObjectId" and "actionIndex" are used, depends on the messageId.
63 *
64 */
65
66// forward declaration
67class CARServerObject;
68class Context;
69
70// Reference Types ////////////////////////////////////////////////////////////
71// this values are returned by CRefItem::GetReferenceType to identify the
72// underlying object type in case its necessary to cast to the real class.
73const unsigned int REF_ITEM_TYPE_SERVEROBJECT = 1;
74const unsigned int REF_ITEM_TYPE_WORKFLOW_ACTION = 2;
75const unsigned int REF_ITEM_TYPE_OLD = 999; // just for compatibility; remove it later
76
77// Messages ///////////////////////////////////////////////////////////////////
78enum ReferenceMessages
79{
80        REFM_NONE = 0,
81
82        // schema refs
83        REFM_SCHEMA_INDEX,
84        REFM_SCHEMA_RESULTLIST,
85        REFM_SCHEMA_SORTLIST,
86        REFM_SCHEMA_JOIN_QUALIFICATION,
87        REFM_SCHEMA_AUDIT_QUALIFICATION,
88        REFM_SCHEMA_ARCHIVE_QUALIFICATION,
89        REFM_SCHEMA_FTS_WEIGHTED_RELEVANCY_FIELD,
90        REFM_SCHEMA_AUDIT_SOURCE,
91
92        // basic workflow references
93        REFM_RUNIF,
94        REFM_CONTROLFIELD,
95        REFM_FOCUSFIELD,
96
97        // workflow action references
98        REFM_PUSHFIELD_IF,
99        REFM_PUSHFIELD_SERVER,
100        REFM_PUSHFIELD_FORM,
101        REFM_PUSHFIELD_TARGET,
102        REFM_PUSHFIELD_VALUE,
103        REFM_PUSHFIELD_TARGET_MATCHING,
104        REFM_PUSHFIELD_VALUE_MATCHING,
105        REFM_PUSHFIELD_HOVERFIELD,
106        REFM_SETFIELDS_SERVER,
107        REFM_SETFIELDS_FORM,
108        REFM_SETFIELDS_QUALIFICATION,
109        REFM_SETFIELDS_TARGET,
110        REFM_SETFIELDS_VALUE,
111        REFM_SETFIELDS_TARGET_MATCHING,
112        REFM_SETFIELDS_VALUE_MATCHING,
113        REFM_SETFIELDS_SQL_QUALIFICATION,
114        REFM_SETFIELDS_WS_INPUT,
115        REFM_SETFIELDS_WS_OUTPUT,
116        REFM_SETFIELDS_HOVERFIELD,
117        REFM_SETFIELDS_FILTERAPI_INPUT,
118        REFM_SETFIELDS_FILTERAPI_PLUGINNAME,
119        REFM_OPENWINDOW_SERVER,
120        REFM_OPENWINDOW_FORM,
121        REFM_OPENWINDOW_VIEW,
122        REFM_OPENWINDOW_LOCATION,
123        REFM_OPENWINDOW_REPORTTYPE,
124        REFM_OPENWINDOW_REPORTNAME,
125        REFM_OPENWINDOW_REPORTDESTINATION,
126        REFM_OPENWINDOW_QUALIFICATION,
127        REFM_OPENWINDOW_SORTBY,
128        REFM_OPENWINDOW_ENTRYIDS,
129        REFM_OPENWINDOW_QUERYOVERRIDE,
130        REFM_OPENWINDOW_CHARENC,
131        REFM_OPENWINDOW_TARGET,
132        REFM_OPENWINDOW_VALUE,
133        REFM_OPENWINDOW_HOVERFIELD,
134        REFM_SERVICE_SERVER,
135        REFM_SERVICE_FORM,
136        REFM_SERVICE_CALL,
137        REFM_SERVICE_REQUESTID,
138        REFM_SERVICE_TARGET,
139        REFM_SERVICE_VALUE,
140        REFM_SERVICE_HOVERFIELD,
141        REFM_RUN_PROCESS,
142        REFM_DELETE_ENTRY_ACTION,
143        REFM_MESSAGE,
144        REFM_CHANGEFIELD,
145        REFM_CHANGEFIELD_OF_FIELDS_VALUE,
146        REFM_CHANGEFIELD_LABEL,
147        REFM_DIRECTSQL,
148        REFM_CALLCUIDE_SERVER,
149        REFM_CALLGUIDE_NAME,
150        REFM_CALLGUIDE_TABLELOOP,
151        REFM_GOTO,
152        REFM_CHARMENU_LABELFIELD,
153        REFM_CHARMENU_VALUE,
154        REFM_CHARMENU_QUALIFICATION,
155        REFM_CHARMENU_SQL,
156        REFM_CHARMENU_FORM,
157        REFM_CHARMENU_SERVER,
158        REFM_NOTIFY_TEXT,
159        REFM_NOTIFY_USER,
160        REFM_NOTIFY_SUBJECT,
161        REFM_NOTIFY_FIELDLIST,
162        REFM_NOTIFY_MAILBOX,
163        REFM_NOTIFY_FROM,
164        REFM_NOTIFY_REPLYTO,
165        REFM_NOTIFY_CC,
166        REFM_NOTIFY_BCC,
167        REFM_NOTIFY_ORG,
168        REFM_NOTIFY_TEMPL_HEADER,
169        REFM_NOTIFY_TEMPL_CONTENT,
170        REFM_NOTIFY_TEMPL_FOOTER,
171        REFM_MACRO,
172
173        // field refs
174        REFM_TABLEFIELD_SERVER,
175        REFM_TABLEFIELD_FORM,
176        REFM_TABLEFIELD_COLUMN,
177        REFM_TABLEFIELD_QUALIFICATION,
178
179        // webservice
180        REFM_WEBSERVICE_PROPERTY,
181        REFM_WEBSERVICE_OPERATION,
182        REFM_WEBSERVICE_FIELDMAP,
183
184        // image refs
185        REFM_BACKGROUND_IMAGE,
186        REFM_TITLE_BAR_ICON,
187        REFM_VUI_BACKGROUND,
188        REFM_PACKINGLIST,
189
190        // menu references
191        REFM_FIELD_CHARMENU,
192};
193
194// maybe there is a better place for the following enums and functions //
195
196// if or else mode enum
197enum IfElseState
198{
199        IES_IF,
200        IES_ELSE,
201};
202
203// returns string of the if/else state
204const char* IfElse(IfElseState state);
205
206enum ServiceMappingMode
207{
208        SMM_INPUT,
209        SMM_OUTPUT,
210};
211
212enum OpenWindowMode
213{
214        OWM_OPEN,
215        OWM_CLOSE,
216};
217
218// class for storing references
219class CRefItem
220{
221public:
222        CRefItem();     // constructor for reference to nothing
223        CRefItem(const CARServerObject& obj, int dMessage);
224        CRefItem(const CARServerObject& obj, int IfOrElse, int nAction, int dMessage);
225        CRefItem(Context &context, int dMessage);
226        CRefItem(const CRefItem& copyFrom, int dMessage); // to copy the referenced object, but change the message at the same time
227        // the following constructor is for openwindow-action references
228        CRefItem(const CARServerObject& obj, int IfOrElse, int nAction, int OpenOrClose, int dMessage);
229        ~CRefItem(void) { }
230
231public:
232        // returns a value to identify the reference class .. see REF_ITEM_TYPE_...
233        //int GetReferenceType();
234        // returns the message id of the description
235        int GetMessageId() const { return messageId; }
236        int GetObjectId() const { return objectId; }
237        int GetSubObjectId() const { return subObjectId; }
238
239        bool operator==(const CRefItem &r);
240
241        // for reference table output we need ...
242
243        // returns the referenced xml object type (AR_STRUCT_ITEM_XML_...)
244        int GetObjectType() const;
245        // returns the name of the referenced object
246        string GetObjectName() const;
247        // returns the enabled state of the referenced object
248        unsigned int GetObjectEnabled(bool &supportsEnabled) const; // supportsEnabled is set to false, if the object doesn't support the enabled/disabled state
249        // returns the enabled state of the referenced object
250        unsigned int GetObjectEnabled() const;
251        // returns the description text of the reference
252        string GetDescription(int rootLevel) const;
253        // writes the description text to an output stream
254        void GetDescription(std::ostream& strm, int rootLevel) const;
255        // returns the order of AL or FLT or -1 if the object doesnt have a order number
256        int GetObjectOrder() const;
257        // return the execute-on string of the object (in a single line)
258        string GetObjectExecuteOn() const;
259
260        // additional public helpers
261        const char* IfElse() const;
262        int ActionIndex() const;
263
264private:
265        void Init(const CARServerObject& obj, int IfOrElse, int nAction, int dMessage);
266
267        // output helper functions
268        const char* OpenClose() const;
269        const char* ServiceInfo() const;
270        string LinkToSchemaIndex(int rootLevel) const;
271        string LinkToSchemaResultList(int rootLevel) const;
272        string LinkToSchemaSortList(int rootLevel) const;
273        string LinkToSchema(int rootLevel) const;
274        void LinkToColumnParent(std::ostream& strm, int rootLevel) const;
275
276protected:
277        int arsStructItemType;
278        int objectId;
279        int subObjectId;
280        int actionIndex;
281        int messageId;
282};
283
284typedef vector<CRefItem> CRefItemList;
Note: See TracBrowser for help on using the repository browser.