Source code: com/flexstor/ejb/bucket/persist/ServerBucketExtendData.java
1 /*
2 * ServerBucketExtendData.java
3 *
4 * Copyright $Date: 2003/08/11 02:22:43 $ 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.ejb.bucket.persist;
12
13 import java.util.Vector;
14
15 import com.flexstor.common.data.ejb.Data;
16 import com.flexstor.ejb.field.persist.ServerFieldExtendData;
17
18 /**
19 * This is the client data object for state information
20 * pertaining to a DisguiseBucket.
21 *
22 *
23 * @author Daniel J. Nickel 2/10/99
24 * @version $Id: ServerBucketExtendData.java,v 1.3 2003/08/11 02:22:43 aleric Exp $
25 * @since FlexDB 3.0
26 * @see com.flexstor.ejb.dataobject.Data
27 * @see com.flexstor.ejb.dataobject.LookupData
28 */
29
30 public class ServerBucketExtendData
31 extends Data
32 {
33 public static final String IDENTIFIER="$Id: ServerBucketExtendData.java,v 1.3 2003/08/11 02:22:43 aleric Exp $";
34
35 /**
36 * Identifier (Primary Key)
37 *
38 * @since FlexDB 3.0
39 */
40 protected int id = 0;
41
42 /**
43 * What did the client name this bucket
44 *
45 * @since FlexDB 3.0
46 * @see java.util.String
47 */
48 protected String label = null;
49
50 /**
51 * Level of this bucket
52 *
53 * @since FlexDB 3.0
54 */
55 protected int level;
56
57
58 /**
59 * The disguise_fields for this object
60 *
61 * @since FlexDB 3.0
62 * @see com.flexstor.ejb.dataobject.ServerFieldExtendData
63 */
64 protected Vector bucketFields = null;
65
66 /**
67 * The bucket name
68 *
69 * @since FlexDB 3.0
70 * @see java.util.Vector
71 * @see com.flexstor.ejb.dataobject.properties
72 */
73 protected String bucketName = null;
74
75 /**
76 * Bucket Type - Use BucketData Contants
77 *
78 * @see com.flexstor.ejb.dataobject.BucketData
79 */
80 protected int bucketType;
81
82 /**
83 * Will get the Id of the field
84 *
85 * @return int
86 * @since FlexDB 3.0
87 */
88
89 public int getId()
90 {
91 return id;
92 }
93
94 /**
95 * Will set the Id of the field
96 *
97 * @param int - unique row_id
98 * @since FlexDB 3.0
99 */
100
101 public void setId( int id )
102 {
103 this.id = id;
104 }
105
106 /**
107 * Will get the Label of the field
108 *
109 * @return java.lang.String
110 * @since FlexDB 3.0
111 * @see java.lang.String
112 */
113
114 public String getLabel()
115 {
116 return label;
117 }
118
119 /**
120 * Will get the Label of the field
121 *
122 * @return java.lang.String
123 * @since FlexDB 3.0
124 * @see java.lang.String
125 */
126
127 public void setLabel( String label )
128 {
129 this.label = label;
130 }
131
132 /**
133 * Get the level for this bucket.
134 *
135 * @return int - level
136 * @since FlexDB 3.0
137 */
138
139 public int getLevel()
140 {
141 return level;
142 }
143
144 /**
145 * Get the level for this bucket.
146 *
147 * @param int - level
148 * @since FlexDB 3.0
149 */
150
151 public void setLevel( int level )
152 {
153 this.level = level;
154 }
155
156 /**
157 * This will get the Disguise Fields for this object.
158 *
159 * @return java.util.Vector
160 * @since FlexDB 3.0
161 * @see com.flexstor.ejb.dataobject.ServerFieldExtendData
162 */
163
164 public Vector getFieldDataObjects()
165 {
166 return bucketFields;
167 }
168
169 /**
170 * This will get the Disguise Fields for this object.
171 *
172 * @param java.util.Vector - list of fields
173 * @since FlexDB 3.0
174 * @see com.flexstor.ejb.dataobject.ServerFieldExtendData
175 */
176
177 public void setFieldDataObjects( Vector v )
178 {
179 bucketFields = v;
180 }
181
182 /**
183 * Get Bucket Type
184 *
185 */
186 public int getBucketType()
187 {
188 return bucketType;
189 }
190
191 /**
192 * Set Bucket Type
193 *
194 */
195 public void setBucketType( int type )
196 {
197 bucketType = type;
198 }
199
200 /**
201 * Get Bucket Name
202 *
203 */
204 public String getBucketName()
205 {
206 return bucketName;
207 }
208
209 /**
210 * Set Bucket Name
211 *
212 */
213 public void setBucketName( String name )
214 {
215 bucketName = name;
216 }
217
218 /**
219 * This will return fields that are system required
220 *
221 * @return Vector of ServerFieldExtendData object
222 */
223 public Vector getSystemFields()
224 {
225 Vector fields = null;
226
227 if ( bucketFields == null )
228 return null;
229
230 int iVectorLen = bucketFields.size();
231
232 for ( int iPos1 = 0; iPos1 < iVectorLen ; iPos1++ )
233 {
234 ServerFieldExtendData dis1 = (ServerFieldExtendData) bucketFields.elementAt(iPos1);
235
236 if ( dis1.isSystemRequired() )
237 {
238 if ( fields == null )
239 fields = new Vector();
240
241 fields.addElement( dis1 );
242 }
243 }
244
245 return fields;
246 }
247
248 /**
249 * This will return fields that are not system required
250 *
251 * @return Vector of ServerFieldExtendData object
252 */
253 public Vector getNonSystemFields()
254 {
255 Vector fields = null;
256
257 if ( bucketFields == null )
258 return null;
259
260 int iVectorLen = bucketFields.size();
261
262 for ( int iPos1 = 0; iPos1 < iVectorLen ; iPos1++ )
263 {
264 ServerFieldExtendData dis1 = (ServerFieldExtendData) bucketFields.elementAt(iPos1);
265
266 if ( ! dis1.isSystemRequired() )
267 {
268 if ( fields == null )
269 fields = new Vector();
270
271 fields.addElement( dis1 );
272 }
273 }
274
275 return fields;
276 }
277
278 /**
279 * This is a helper function that will
280 * take the display fields and order them
281 * by position. It uses a bubble sort algorithm
282 * which is slow for large Vectors, but should be
283 * acceptable because of the small number of
284 * displayable fields for a layout.
285 *
286 * @return boolean
287 * @since FlexDB 3.0
288 */
289 public boolean orderFields()
290 {
291 int iVectorLen = 0;
292
293 if ( bucketFields == null )
294 return true;
295
296 iVectorLen = bucketFields.size();
297
298 for ( int iPos1 = 0; iPos1 < iVectorLen ; iPos1++ )
299 {
300
301 for ( int iPos2 = iPos1 + 1 ; iPos2 < iVectorLen ; iPos2++ )
302 {
303 ServerFieldExtendData dis1 = (ServerFieldExtendData) bucketFields.elementAt(iPos1);
304 ServerFieldExtendData dis2 = (ServerFieldExtendData) bucketFields.elementAt(iPos2);
305
306 if ( dis1.getPosition() > dis2.getPosition() )
307 {
308 bucketFields.setElementAt( dis2 , iPos1 );
309 bucketFields.setElementAt( dis1 , iPos2 );
310 }
311
312 }
313 }
314
315 return true;
316 }
317
318 }