Source code: com/flexstor/common/data/ejb/disguise/DisguiseData.java
1 /*
2 * DisguiseData.java
3 *
4 * Copyright $Date: 2003/08/11 02:22:35 $ FLEXSTOR.net Inc.
5 *
6 * This work is licensed for use and distribution under license terms found at
7 * http://www.flexstor.org/license.html
8 *
9 */
10
11 package com.flexstor.common.data.ejb.disguise;
12
13 import java.util.Vector;
14
15 import com.flexstor.common.constants.UserGroupDataTypesI;
16 import com.flexstor.common.data.ejb.Data;
17 import com.flexstor.common.data.ejb.application.ApplicationData;
18 import com.flexstor.common.data.ejb.property.PropertyData;
19 import com.flexstor.common.data.ejb.where.RestrictiveWhereData;
20 import com.flexstor.common.keys.ejb.ApplicationKey;
21 import com.flexstor.common.keys.ejb.DisguiseKey;
22
23 /**
24 * This is the dataobject used to retrieve information
25 * for a particular Disguise. It is used exclusively
26 * by the client.
27 *
28 * This object is normally created by the Bean after
29 * a user request.
30 *
31 * @author Daniel Nickel
32 * @version 1.0, 04/19/99
33 *
34 * @see com.flexstor.ejb.disguise.persist.DisguisePersist
35 * @see com.flexstor.ejb.disguise.dataobject.DisguiseDataBuild
36 *
37 * @since FLEXSTOR.db 3.0
38 *
39 */
40
41 public class DisguiseData
42 extends Data
43 {
44
45 public final static String IDENTIFIER="$Id: DisguiseData.java,v 1.4 2003/08/11 02:22:35 aleric Exp $";
46
47 // User defined label for the Disguise
48 protected String label = null;
49
50 // This is a collection of Report Refs
51 protected Vector reports = null;
52
53 // This is a collection of Export Refs
54 protected Vector exports = null;
55
56 // This is the DisguiseKey for this Data Object
57 protected DisguiseKey key = null;
58
59 // This is a Privilege Object or a Privilege Key depending upon load
60 protected Vector privileges = null;
61
62 // This is a collection of Display Objects
63 protected Vector displays = null;
64
65 // This is an Instance of the application data or Reference Key
66 protected ApplicationData application = null;
67 protected ApplicationKey appKey = null;
68 protected String appName = null;
69
70 // At present this is unsupported
71 // This is a boolean whether to send all info
72 // to a client (Not references)
73 // At present we send ALL info to client
74 protected boolean bLoad = false;
75
76 // Boolean to tell whether disguise is valid or not
77 protected boolean valid = true;
78
79 // ID of the disguise
80 protected int id = 0;
81
82 // Disguise Bucket Objects
83 protected Vector disguiseBuckets = null;
84
85 // Classify
86 protected boolean classify = false;
87
88 /**
89 * Properties of all fields
90 *
91 * @since FlexDB 3.0
92 */
93 protected Vector properties = new Vector();
94
95
96 // Is there bucket elements with this disguise
97 public boolean containElementBucket = false;
98
99 // Does it have an asset bucket
100 public boolean containAssetBucket = false;
101
102 /**
103 * Holds PrivAssetData objects (Asset Privileges) for this disguise
104 */
105 protected Vector vAssetPrivileges;
106
107 /**
108 * Holds the RestrictiveWhereData object for this disguise
109 */
110 protected RestrictiveWhereData whereData;
111
112 /**
113 * Constructor : Create an Empty Disguise Data Object
114 *
115 */
116
117 public DisguiseData()
118 {
119 super();
120 }
121
122 /**
123 * Constructor : Set the label for the Disguise
124 *
125 * @param sLabel java.lang.String Name of a particular Disguise
126 */
127
128 public DisguiseData(String sLabel)
129 {
130 super();
131 label = sLabel;
132 }
133
134 /**
135 * Retrieve the label for the disguise.
136 *
137 * @return java.lang.String
138 */
139
140 public String getName()
141 {
142 return label;
143 }
144
145 /**
146 * Retrieve the Application Name for this Disguise
147 *
148 * @return java.lang.String
149 */
150
151 public String getAppName()
152 {
153 return appName;
154 }
155
156 /**
157 * Do we load everything? Or just references.
158 * <br>
159 *
160 * @return true if we load everything on startup
161 * <br> false if we do not load everything
162 */
163
164 public boolean loadOnStartup()
165 {
166 return bLoad;
167 }
168
169 /**
170 * Retrieve the Identifier for this Disguise.
171 *
172 * @return int The id for this disguise
173 */
174
175 public int getId()
176 {
177 return id;
178 }
179
180 /**
181 * This will return a Vector of DisplayData Objects
182 * for this disguise.
183 *
184 *
185 * @return java.util.Vector list of Display Data Objects
186 *
187 * @see com.flexstor.ejb.dataobject.DisplayData
188 */
189
190 public Vector getDisplayDataObjects()
191 {
192 return displays;
193 }
194
195
196 /**
197 * This will return an application Data Object
198 * associated with this disguise.
199 *
200 * @return ApplicationData If Object has association
201 * <br><b>null</b> If this disguise has no application
202 *
203 * @see com.flexstor.ejb.dataobject.ApplicationData
204 */
205
206 public ApplicationData getApplicationDataObject()
207 {
208 return application;
209 }
210
211 /**
212 * This will set an application data object for this disguise.
213 * Note that if the user updates this Object, this application
214 * will be persisted with this disguise. This means that the Application
215 * Data Object must contain a valid ApplicationKey.
216 *
217 * @return boolean
218 */
219
220 public boolean setApplicationDataObject(ApplicationData dat)
221 {
222 application = dat;
223 appKey = dat.getKey();
224 return true;
225 }
226
227 /**
228 * This will return an ApplicationKey for the application
229 * associated with this disguise.
230 *
231 * @return com.flexstor.ejb.key.ApplicationKey Key for App
232 */
233
234 public ApplicationKey getApplicationKey()
235 {
236 return appKey;
237 }
238
239 /**
240 * This will let the client know whether a Disguise is valid or not.
241 * The criteria is if the DisplayField names are equal
242 * to the fielnames the DisplayFields reference.
243 *
244 * @return true if valid
245 * <br> false if not valid
246 */
247
248 public boolean isValidDisguise()
249 {
250 return valid;
251 }
252
253 /**
254 * This will get Privilege Objects for a disguise
255 *
256 * @return Vector list of RolePrivilegeData
257 * @exception java.rmi.RemoteException
258 * @see com.flexstor.ejb.dataobject.RolePrivilegeData
259 */
260
261 public Vector getPrivilegeDataObjects()
262 {
263 return privileges;
264 }
265
266
267 /**
268 * This will return a Vector of Report Template
269 * Data Objects associated with this Disguise.
270 *
271 * @return java.util.Vector List of ReportTemplateData
272 * @see com.flexstor.ejb.dataobject.ReportTemplateData
273 */
274
275 public Vector getReportTemplateDataObjects()
276 {
277 return reports;
278 }
279
280
281 /**
282 * Returns a collection of Export Template Data Objects
283 * associated with this Disguise.
284 *
285 * @return java.util.Vector List of Export Template Data Objects
286 * @see com.flexstor.ejb.dataobject.ExportTemplateData
287 */
288
289 public Vector getExportTemplateDataObjects()
290 {
291 return exports;
292 }
293
294 /**
295 * Returns a collection of DisguiseBuckets
296 * for this disguise.
297 *
298 * @return java.util.Vector List of DisguiseBucketData Objects
299 */
300 public Vector getDisguiseBucketDataObjects()
301 {
302 return disguiseBuckets;
303 }
304
305 public void setKey( DisguiseKey key )
306 {
307 this.key = key;
308 }
309
310 /**
311 * Get DisguiseKey associated with this object.
312 * In order to persist this object, key has to be valid!
313 *
314 * @return com.flexstor.ejb.key.DisguiseKey
315 * <br>null if no key assigned
316 */
317 public DisguiseKey getKey()
318 {
319 return key;
320 }
321
322 /**
323 * Check whether the classify flag is true
324 *
325 * @return true - if classified
326 */
327 public boolean isClassifiedDisguise()
328 {
329 return classify;
330 }
331
332
333 /**
334 * This tells if a disguise has an element bucket
335 *
336 * @return boolean - true if has element bucket
337 */
338 public boolean hasElement()
339 {
340 return containElementBucket;
341 }
342
343
344 /**
345 * This tells if a disguise has an Asset bucket
346 *
347 * @return boolean - true if has Asset bucket
348 */
349 public boolean hasAsset()
350 {
351 return containAssetBucket;
352 }
353
354
355 /**
356 * This will return a list of properties.
357 *
358 * @return java.util.Vector - A list of PropertyData objects
359 */
360 public Vector getPropertyDataObjects()
361 {
362 return properties;
363 }
364
365 /**
366 * Get property where it accepts a property String and returns the
367 * value
368 *
369 * @return String - Value
370 */
371 public String getProperty( String key )
372 {
373 if ( properties == null )
374 return null;
375
376 for ( int i = 0; i < properties.size() ; i++ )
377 {
378 PropertyData _dat = (PropertyData)properties.elementAt( i );
379
380 if ( _dat.getPropertyKey().compareTo( key ) == 0 )
381 return _dat.getPropertyValue();
382 }
383
384 return null;
385 }
386
387 public void setAssetPrivileges( Vector vAssetPrivileges )
388 {
389 this.vAssetPrivileges = vAssetPrivileges;
390 setModifiedState( new Integer(UserGroupDataTypesI.PRIVILEGE), Boolean.TRUE );
391 }
392
393 public Vector getAssetPrivileges()
394 {
395 return vAssetPrivileges;
396 }
397
398 public void setWhereData( RestrictiveWhereData whereData )
399 {
400 this.whereData = whereData;
401 setModifiedState( new Integer(UserGroupDataTypesI.WHERE), Boolean.TRUE );
402 }
403
404 public RestrictiveWhereData getWhereData()
405 {
406 return whereData;
407 }
408 }