source: branches/work_311/core/ARSchema.cpp @ 616

Revision 616, 9.2 KB checked in by jls17, 5 years ago (diff)
  • added support for audit forms on the schema list page
Line 
1//Copyright (C) 2009 Stefan Nerlich | stefan.nerlich@hotmail.com
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#include "stdafx.h"
18#include "ARSchema.h"
19#include "../lists/ARSchemaList.h"
20#include "ARField.h"
21#include "ARVui.h"
22#include "../ARInside.h"
23
24CARSchema::CARSchema()
25: CARServerObject(-1)
26{
27}
28
29CARSchema::CARSchema(int insideId)
30: CARServerObject(insideId)
31{       
32}
33
34CARSchema::CARSchema(const string& schemaName)
35: CARServerObject(-1)
36{
37        insideId = CARInside::GetInstance()->schemaList.Find(schemaName.c_str());
38}
39
40CARSchema::~CARSchema(void)
41{
42}
43
44bool CARSchema::Exists() const
45{
46        return (insideId >= 0 && (unsigned int)insideId < CARInside::GetInstance()->schemaList.GetCount());
47}
48
49bool CARSchema::IsClonable() const
50{
51        return true;
52}
53
54CARServerObject* CARSchema::Clone() const
55{
56        return new CARSchema(*this);
57}
58
59string CARSchema::WebAlias()
60{
61        stringstream strm;
62        strm.str("");
63
64        try
65        {
66                const ARPropList& propList = this->GetPropList();
67                for(unsigned int i=0; i < propList.numItems; ++i)
68                {
69                        if (propList.props[i].prop == AR_OPROP_FORM_NAME_WEB_ALIAS)
70                        {
71                                if(propList.props[i].value.dataType == AR_DATA_TYPE_CHAR && propList.props[i].value.u.charVal != NULL)
72                                {
73                                        strm << propList.props[i].value.u.charVal;
74                                        break;
75                                }
76                        }
77                }
78        }
79        catch(exception& e)
80        {
81                cout << "EXCEPTION enumerating web alias: " << e.what() << endl;
82        }
83
84        return strm.str();
85}
86
87string CARSchema::GetName()
88{
89        return CARInside::GetInstance()->schemaList.SchemaGetName(GetInsideId());
90}
91
92string CARSchema::GetName() const
93{
94        return CARInside::GetInstance()->schemaList.SchemaGetName(GetInsideId());
95}
96
97string CARSchema::GetNameFirstChar()
98{
99        return CARObject::GetNameFirstChar(CARInside::GetInstance()->schemaList.SchemaGetName(GetInsideId()));
100}
101
102bool CARSchema::NameStandardFirstChar()
103{
104        return CARObject::NameStandardFirstChar(GetNameFirstChar());
105}
106
107const char* CARSchema::GetHelpText() const
108{
109        return CARInside::GetInstance()->schemaList.SchemaGetHelptext(GetInsideId());
110}
111
112ARTimestamp CARSchema::GetTimestamp() const
113{
114        return CARInside::GetInstance()->schemaList.SchemaGetTimestamp(GetInsideId());
115}
116
117const ARAccessNameType& CARSchema::GetOwner() const
118{
119        return CARInside::GetInstance()->schemaList.SchemaGetOwner(GetInsideId());
120}
121
122const ARAccessNameType& CARSchema::GetLastChanged() const
123{
124        return CARInside::GetInstance()->schemaList.SchemaGetModifiedBy(GetInsideId());
125}
126
127const char* CARSchema::GetChangeDiary() const
128{
129        return CARInside::GetInstance()->schemaList.SchemaGetChangeDiary(GetInsideId());
130}
131
132const ARNameType& CARSchema::GetARName() const
133{
134        return CARInside::GetInstance()->schemaList.SchemaGetName(GetInsideId());
135}
136
137const ARCompoundSchema& CARSchema::GetCompound() const
138{
139        return CARInside::GetInstance()->schemaList.SchemaGetCompound(GetInsideId());
140}
141
142const ARPermissionList& CARSchema::GetPermissions() const
143{
144        return CARInside::GetInstance()->schemaList.SchemaGetPermissions(GetInsideId());
145}
146
147const ARInternalIdList& CARSchema::GetSubadmins() const
148{
149        return CARInside::GetInstance()->schemaList.SchemaGetSubadmins(GetInsideId());
150}
151
152const AREntryListFieldList& CARSchema::GetResultFields() const
153{
154        return CARInside::GetInstance()->schemaList.SchemaGetResultFields(GetInsideId());
155}
156
157const ARSortList& CARSchema::GetSortList() const
158{
159        return CARInside::GetInstance()->schemaList.SchemaGetSortList(GetInsideId());
160}
161
162const ARIndexList& CARSchema::GetIndexList() const
163{
164        return CARInside::GetInstance()->schemaList.SchemaGetIndexList(GetInsideId());
165}
166
167const ARArchiveInfoStruct& CARSchema::GetArchiveInfo() const
168{
169        return CARInside::GetInstance()->schemaList.SchemaGetArchiveInfo(GetInsideId());
170}
171
172const ARAuditInfoStruct& CARSchema::GetAuditInfo() const
173{
174        return CARInside::GetInstance()->schemaList.SchemaGetAuditInfo(GetInsideId());
175}
176
177const ARNameType& CARSchema::GetDefaultVUI() const
178{
179        return CARInside::GetInstance()->schemaList.SchemaGetDefaultVUI(GetInsideId());
180}
181
182const ARPropList& CARSchema::GetPropList() const
183{
184        return CARInside::GetInstance()->schemaList.SchemaGetPropList(GetInsideId());
185}
186
187const string& CARSchema::GetAppRefName() const
188{
189        return CARInside::GetInstance()->schemaList.SchemaGetAppRefName(GetInsideId());
190}
191
192void CARSchema::SetAppRefName(const string& appName)
193{
194        return CARInside::GetInstance()->schemaList.SchemaSetAppRefName(GetInsideId(), appName);
195}
196
197int CARSchema::GetDbTableId() const
198{
199        return CARInside::GetInstance()->schemaList.SchemaGetDbTableId(GetInsideId());
200}
201
202const ARNameType& CARSchema::GetDbViewName() const
203{
204        return CARInside::GetInstance()->schemaList.SchemaGetDbViewName(GetInsideId());
205}
206
207const ARNameType& CARSchema::GetDbShViewName() const
208{
209        return CARInside::GetInstance()->schemaList.SchemaGetDbShViewName(GetInsideId());
210}
211
212CARFieldList* CARSchema::GetFields()
213{
214        return CARInside::GetInstance()->schemaList.SchemaGetFields(GetInsideId());
215}
216
217CARVUIList* CARSchema::GetVUIs()
218{
219        return CARInside::GetInstance()->schemaList.SchemaGetVUIs(GetInsideId());
220}
221
222void CARSchema::AddFilter(const CARFilter &filter)
223{
224        CARInside::GetInstance()->schemaList.SchemaAddFilter(GetInsideId(), filter);
225}
226
227void CARSchema::AddActiveLink(const CARActiveLink& actlink)
228{
229        CARInside::GetInstance()->schemaList.SchemaAddActiveLink(GetInsideId(), actlink);
230}
231
232void CARSchema::AddEscalation(const CAREscalation& escalation)
233{
234        CARInside::GetInstance()->schemaList.SchemaAddEscalation(GetInsideId(), escalation);
235}
236
237void CARSchema::AddActLinkGuide(const CARContainer& alGuide)
238{
239        CARInside::GetInstance()->schemaList.SchemaAddActLinkGuide(GetInsideId(), alGuide);
240}
241
242void CARSchema::AddFilterGuide(const CARContainer& fltGuide)
243{
244        CARInside::GetInstance()->schemaList.SchemaAddFilterGuide(GetInsideId(), fltGuide);
245}
246
247void CARSchema::AddPackingList(const CARContainer &packList)
248{
249        CARInside::GetInstance()->schemaList.SchemaAddPackingList(GetInsideId(), packList);
250}
251
252void CARSchema::AddWebservice(const CARContainer& webservice)
253{
254        CARInside::GetInstance()->schemaList.SchemaAddWebservice(GetInsideId(), webservice);
255}
256
257void CARSchema::AddMissingFieldReference(int fieldId, const CRefItem &refItem)
258{
259        CARInside::GetInstance()->schemaList.SchemaAddMissingFieldReference(GetInsideId(), fieldId, refItem);
260}
261
262const CARSchema::MissingReferenceList* CARSchema::GetMissingReferences()
263{
264        return CARInside::GetInstance()->schemaList.SchemaGetMissingReferences(GetInsideId());
265}
266
267const CARSchemaList::ObjectRefList& CARSchema::GetActiveLinks()
268{
269        return CARInside::GetInstance()->schemaList.SchemaGetALReferences(GetInsideId());
270}
271
272const CARSchemaList::ObjectRefList& CARSchema::GetFilters()
273{
274        return CARInside::GetInstance()->schemaList.SchemaGetFilterReferences(GetInsideId());
275}
276
277const CARSchemaList::ObjectRefList& CARSchema::GetEscalations()
278{
279        return CARInside::GetInstance()->schemaList.SchemaGetEscalationReferences(GetInsideId());
280}
281
282const CARSchemaList::ObjectRefList& CARSchema::GetActLinkGuides()
283{
284        return CARInside::GetInstance()->schemaList.SchemaGetActLinkGuideReferences(GetInsideId());
285}
286
287const CARSchemaList::ObjectRefList& CARSchema::GetFilterGuides()
288{
289        return CARInside::GetInstance()->schemaList.SchemaGetFilterGuideReferences(GetInsideId());
290}
291
292const CARSchemaList::ObjectRefList& CARSchema::GetPackingLists()
293{
294        return CARInside::GetInstance()->schemaList.SchemaGetPackingListReferences(GetInsideId());
295}
296
297const CARSchemaList::ObjectRefList& CARSchema::GetWebservices()
298{
299        return CARInside::GetInstance()->schemaList.SchemaGetWebserviceReferences(GetInsideId());
300}
301
302void CARSchema::AddReference(const CRefItem &refItem)
303{
304        return CARInside::GetInstance()->schemaList.AddReference(GetInsideId(), refItem);
305}
306
307bool CARSchema::ReferenceExists(const CRefItem &refItem) const
308{
309        return CARInside::GetInstance()->schemaList.ReferenceExists(GetInsideId(), refItem);
310}
311
312const CARSchema::ReferenceList& CARSchema::GetReferences() const
313{
314        return CARInside::GetInstance()->schemaList.GetReferences(GetInsideId());
315}
316
317bool CARSchema::IsAuditTarget()
318{
319        const ReferenceList &references = GetReferences();
320        CARSchema::ReferenceList::const_iterator curIt = references.begin();
321        CARSchema::ReferenceList::const_iterator endIt = references.end();
322
323        for (; curIt != endIt; ++curIt)
324        {
325                if (curIt->GetMessageId() == REFM_SCHEMA_AUDIT_SOURCE)
326                        return true;
327        }
328        return false;
329}
330
331unsigned int CARSchema::GetInternalSchemaType()
332{
333        unsigned int schemaType = GetCompound().schemaType;
334
335        if (IsAuditTarget())
336        {
337                schemaType = AR_SCHEMA_AUDIT;
338        }
339
340        return schemaType;
341}
Note: See TracBrowser for help on using the repository browser.