source: branches/work_304/util/RefItem.h @ 365

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