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

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