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

Revision 619, 9.0 KB checked in by jls17, 5 years ago (diff)
  • archive target forms are now documented as "Archive" on the schema detail page
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        REFM_SCHEMA_ARCHIVE_SOURCE,
92
93        // basic workflow references
94        REFM_RUNIF,
95        REFM_CONTROLFIELD,
96        REFM_FOCUSFIELD,
97
98        // workflow action references
99        REFM_PUSHFIELD_IF,
100        REFM_PUSHFIELD_SERVER,
101        REFM_PUSHFIELD_FORM,
102        REFM_PUSHFIELD_TARGET,
103        REFM_PUSHFIELD_VALUE,
104        REFM_PUSHFIELD_TARGET_MATCHING,
105        REFM_PUSHFIELD_VALUE_MATCHING,
106        REFM_PUSHFIELD_HOVERFIELD,
107        REFM_SETFIELDS_SERVER,
108        REFM_SETFIELDS_FORM,
109        REFM_SETFIELDS_QUALIFICATION,
110        REFM_SETFIELDS_TARGET,
111        REFM_SETFIELDS_VALUE,
112        REFM_SETFIELDS_TARGET_MATCHING,
113        REFM_SETFIELDS_VALUE_MATCHING,
114        REFM_SETFIELDS_SQL_QUALIFICATION,
115        REFM_SETFIELDS_WS_INPUT,
116        REFM_SETFIELDS_WS_OUTPUT,
117        REFM_SETFIELDS_HOVERFIELD,
118        REFM_SETFIELDS_FILTERAPI_INPUT,
119        REFM_SETFIELDS_FILTERAPI_PLUGINNAME,
120        REFM_OPENWINDOW_SERVER,
121        REFM_OPENWINDOW_FORM,
122        REFM_OPENWINDOW_VIEW,
123        REFM_OPENWINDOW_LOCATION,
124        REFM_OPENWINDOW_REPORTTYPE,
125        REFM_OPENWINDOW_REPORTNAME,
126        REFM_OPENWINDOW_REPORTDESTINATION,
127        REFM_OPENWINDOW_QUALIFICATION,
128        REFM_OPENWINDOW_SORTBY,
129        REFM_OPENWINDOW_ENTRYIDS,
130        REFM_OPENWINDOW_QUERYOVERRIDE,
131        REFM_OPENWINDOW_CHARENC,
132        REFM_OPENWINDOW_TARGET,
133        REFM_OPENWINDOW_VALUE,
134        REFM_OPENWINDOW_HOVERFIELD,
135        REFM_SERVICE_SERVER,
136        REFM_SERVICE_FORM,
137        REFM_SERVICE_CALL,
138        REFM_SERVICE_REQUESTID,
139        REFM_SERVICE_TARGET,
140        REFM_SERVICE_VALUE,
141        REFM_SERVICE_HOVERFIELD,
142        REFM_RUN_PROCESS,
143        REFM_DELETE_ENTRY_ACTION,
144        REFM_MESSAGE,
145        REFM_CHANGEFIELD,
146        REFM_CHANGEFIELD_OF_FIELDS_VALUE,
147        REFM_CHANGEFIELD_LABEL,
148        REFM_DIRECTSQL,
149        REFM_CALLCUIDE_SERVER,
150        REFM_CALLGUIDE_NAME,
151        REFM_CALLGUIDE_TABLELOOP,
152        REFM_GOTO,
153        REFM_CHARMENU_LABELFIELD,
154        REFM_CHARMENU_VALUE,
155        REFM_CHARMENU_QUALIFICATION,
156        REFM_CHARMENU_SQL,
157        REFM_CHARMENU_FORM,
158        REFM_CHARMENU_SERVER,
159        REFM_NOTIFY_TEXT,
160        REFM_NOTIFY_USER,
161        REFM_NOTIFY_SUBJECT,
162        REFM_NOTIFY_FIELDLIST,
163        REFM_NOTIFY_MAILBOX,
164        REFM_NOTIFY_FROM,
165        REFM_NOTIFY_REPLYTO,
166        REFM_NOTIFY_CC,
167        REFM_NOTIFY_BCC,
168        REFM_NOTIFY_ORG,
169        REFM_NOTIFY_TEMPL_HEADER,
170        REFM_NOTIFY_TEMPL_CONTENT,
171        REFM_NOTIFY_TEMPL_FOOTER,
172        REFM_MACRO,
173
174        // field refs
175        REFM_TABLEFIELD_SERVER,
176        REFM_TABLEFIELD_FORM,
177        REFM_TABLEFIELD_COLUMN,
178        REFM_TABLEFIELD_QUALIFICATION,
179
180        // webservice
181        REFM_WEBSERVICE_PROPERTY,
182        REFM_WEBSERVICE_OPERATION,
183        REFM_WEBSERVICE_FIELDMAP,
184
185        // image refs
186        REFM_BACKGROUND_IMAGE,
187        REFM_TITLE_BAR_ICON,
188        REFM_VUI_BACKGROUND,
189        REFM_PACKINGLIST,
190
191        // menu references
192        REFM_FIELD_CHARMENU,
193};
194
195// maybe there is a better place for the following enums and functions //
196
197// if or else mode enum
198enum IfElseState
199{
200        IES_IF,
201        IES_ELSE,
202};
203
204// returns string of the if/else state
205const char* IfElse(IfElseState state);
206
207enum ServiceMappingMode
208{
209        SMM_INPUT,
210        SMM_OUTPUT,
211};
212
213enum OpenWindowMode
214{
215        OWM_OPEN,
216        OWM_CLOSE,
217};
218
219// class for storing references
220class CRefItem
221{
222public:
223        CRefItem();     // constructor for reference to nothing
224        CRefItem(const CARServerObject& obj, int dMessage);
225        CRefItem(const CARServerObject& obj, int IfOrElse, int nAction, int dMessage);
226        CRefItem(Context &context, int dMessage);
227        CRefItem(const CRefItem& copyFrom, int dMessage); // to copy the referenced object, but change the message at the same time
228        // the following constructor is for openwindow-action references
229        CRefItem(const CARServerObject& obj, int IfOrElse, int nAction, int OpenOrClose, int dMessage);
230        ~CRefItem(void) { }
231
232public:
233        // returns a value to identify the reference class .. see REF_ITEM_TYPE_...
234        //int GetReferenceType();
235        // returns the message id of the description
236        int GetMessageId() const { return messageId; }
237        int GetObjectId() const { return objectId; }
238        int GetSubObjectId() const { return subObjectId; }
239
240        bool operator==(const CRefItem &r);
241
242        // for reference table output we need ...
243
244        // returns the referenced xml object type (AR_STRUCT_ITEM_XML_...)
245        int GetObjectType() const;
246        // returns the name of the referenced object
247        string GetObjectName() const;
248        // returns the enabled state of the referenced object
249        unsigned int GetObjectEnabled(bool &supportsEnabled) const; // supportsEnabled is set to false, if the object doesn't support the enabled/disabled state
250        // returns the enabled state of the referenced object
251        unsigned int GetObjectEnabled() const;
252        // returns the description text of the reference
253        string GetDescription(int rootLevel) const;
254        // writes the description text to an output stream
255        void GetDescription(std::ostream& strm, int rootLevel) const;
256        // returns the order of AL or FLT or -1 if the object doesnt have a order number
257        int GetObjectOrder() const;
258        // return the execute-on string of the object (in a single line)
259        string GetObjectExecuteOn() const;
260
261        // additional public helpers
262        const char* IfElse() const;
263        int ActionIndex() const;
264
265private:
266        void Init(const CARServerObject& obj, int IfOrElse, int nAction, int dMessage);
267
268        // output helper functions
269        const char* OpenClose() const;
270        const char* ServiceInfo() const;
271        string LinkToSchemaIndex(int rootLevel) const;
272        string LinkToSchemaResultList(int rootLevel) const;
273        string LinkToSchemaSortList(int rootLevel) const;
274        string LinkToSchema(int rootLevel) const;
275        void LinkToColumnParent(std::ostream& strm, int rootLevel) const;
276
277protected:
278        int arsStructItemType;
279        int objectId;
280        int subObjectId;
281        int actionIndex;
282        int messageId;
283};
284
285typedef vector<CRefItem> CRefItemList;
Note: See TracBrowser for help on using the repository browser.