1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.caleigo.core;
19
20 /*** The IFieldDescriptor inteface defines entity fields (often corresponds to
21 * columns in relational databases) and their properties in the CEL framework.
22 * Note tha fields are aware of what entity descriptor the are part of and
23 * the relations they are a component in.
24 *
25 * @author Dennis Zikovic
26 * @version 1.00
27 *
28 *//*
29 *
30 * WHEN WHO WHY & WHAT
31 * ------------------------------------------------------------------------------
32 * 2001-03-12 Dennis Zikovic Creation
33 */
34 public interface IFieldDescriptor extends java.io.Serializable
35 {
36
37
38 /*** Constant used to define that the field is a part of the entity´s
39 * identity (primary key in a relational database). Note that an entity
40 * can have multiple identity fields. All entities in the cel framework
41 * must have atleast one identity field.
42 */
43 public static final int IDENTITY_FIELD = 0x0001;
44
45 /*** Constant used to define the natural order for the entities it is
46 * a part of. If no natural order field is defined the identity field
47 * will be used for natural order.
48 */
49 public static final int NATURAL_ORDER = 0x0002;
50
51 /*** Constant used to define if the field is required and allows null values
52 * or not. The view layer will for instance use this flag to validate the
53 * data null values according to this flag.
54 */
55 public static final int REQUIRED = 0x0004;
56
57 /*** Constant used to state if the field is a preferred field to qualify on.
58 * It is normally used to state if the underlaying database has an index
59 * on the field.
60 */
61 public static final int INDEXED = 0x0008;
62
63 /*** Flag that states if the field is autogenerated or not. Fields with this
64 * flag should never have values edited by the end-user.
65 */
66 public static final int AUTOGEN = 0x0010;
67
68 /*** This flag states if the field is suitable name field to define the
69 * identity of the entity it is a part of for the end-user. If no name
70 * field is defined the identity field then no reference mapping will be
71 * done for the end-user in the view layer. An etity may only have one
72 * name field.
73 */
74 public static final int NAME_FIELD = 0x1000;
75
76 /*** This flag states that the field is suitable for limited overview of
77 * the entity it is a part of. It is used in the view layer to define what
78 * fields that by default should be displayed in lists and in qualifier
79 * views. An entity should normally have less the five overview fields.
80 */
81 public static final int OVERVIEW_FIELD = 0x2000;
82
83 /*** This flag states if the field is suitable hint field for the entity it
84 * is a part of for the end-user. If no hint field is defined then no hints
85 * will be automatically displayed for the end-user in the view layer.
86 * An etity may only have one hint field.
87 */
88 public static final int HINT_FIELD = 0x4000;
89
90 /*** This flag defines the field as hidden meaning that data of the fields
91 * type should never be displayed for the end-user.
92 */
93 public static final int HIDDEN_FIELD = 0x8000;
94
95 /*** This flag defines the field as read-only meaning that data of the
96 * fields type should never be edited by the end-user.
97 */
98 public static final int READ_ONLY_FIELD = 0x0100;
99
100
101
102 /*** Return the code name for the field. The code name should be used for
103 * programitic identification. This is safer and recomended compared to
104 * the use of field indexes. The code name is also the name of the data
105 * property for the field in enities.
106 */
107 public String getCodeName();
108
109 /*** Returns the source name for the field. The source name is an identifier
110 * for the field in the data service layer.
111 */
112 public String getSourceName();
113
114 /*** Returns the display name for the field. The reurned value has been
115 * passed through the ResourceProvider to allow localisation.
116 */
117 public String getDisplayName();
118
119 /*** Returns the data type for the field.
120 */
121 public DataType getDataType();
122
123 /*** Returns the length of the data type if the type is a scalar type.
124 */
125 public int getLength();
126
127 /*** Return the default value for the field or null if none is set.
128 * This defayult value will automaticalli be set as the default value
129 * for created entities tha the field is part of.
130 */
131 public Object getDefaultValue();
132
133 /*** Access method that returns true if the field is a part of the entity´s
134 * identity (primary key in a relational database). Note that an entity
135 * can have multiple identity fields. All entities in the cel framework
136 * must have atleast one identity field.
137 */
138 public boolean isIdentityField();
139
140 /*** Access method that returns true if the field is the natural order
141 * field for the entities it is a part of. If no natural order field is
142 * defined the identity field will be used for natural order.
143 */
144 public boolean isNaturalOrder();
145
146 /*** Access method that returns true if the field is required and allows
147 * null values or not. The view layer will for instance use this flag
148 * to validate the data null values according to this flag.
149 */
150 public boolean isRequired();
151
152 /*** Access method that returns true if the field is a preferred field to
153 * qualify on. It is normally used to state if the underlaying database
154 * has an index on the field.
155 */
156 public boolean isIndexed();
157
158 /*** Access method that returns true if the field is autogenerated or not.
159 * Fields with this flag should never have values edited by the end-user.
160 */
161 public boolean isAutoGenerated();
162
163 /*** Access method that returns true if the field is suitable name field
164 * to define the identify of the entity it is a part of for the end-user.
165 * If no name field is defined the identity field then no reference mapping
166 * will be done for the end-user in the view layer. An etity may only have
167 * one name field.
168 */
169 public boolean isNameField();
170
171 /*** Access method that returns true if the field is suitable for limited
172 * overview of the entity it is a part of. It is used in the view layer to
173 * define what fields that by default should be displayed in lists and in
174 * qualifier views. An entity should normally have less the five overview
175 * fields.
176 */
177 public boolean isOverviewField();
178
179 /*** Access method that returns true if the field is a suitable hint field
180 * for the entity it is a part of for the end-user. If no hint field is
181 * defined then no hints will be automatically displayed for the end-user
182 * in the view layer. An etity may only have one hint field.
183 */
184 public boolean isHintField();
185
186 /*** Access method that returns true if the field is hidden, meaning that
187 * data of the fields type should never be displayed for the end-user.
188 */
189 public boolean isHiddenField();
190
191 /*** Access method that returns true if the field as read-only meaning
192 * that data of the fields type should never be edited by the end-user.
193 */
194 public boolean isReadOnly();
195
196 /*** Access method that returns true if the field is apart of an entity
197 * reference.
198 */
199 public boolean isReferenceField();
200
201 /*** Access method that returns the entity descriptor that the described
202 * field is part of.
203 */
204 public IEntityDescriptor getEntityDescriptor();
205
206 /*** This method returns true if the called field descriptor can validate
207 * data described by the field in the context of the provided IDataProvider
208 * object. The minimum requiriment is that described field data can be
209 * provided but in some cases other data resources is also required.
210 */
211 public boolean canValidate(IDataProvider dataProvider);
212
213 /*** This method validates the provided data object as described by the
214 * called field descriptor in the context of the provided IDataProvider
215 * object.
216 */
217 public ValidationResult validateData(Object data, IDataProvider dataProvider);
218
219 /*** Access method that returns the field relation that the called field
220 * is a reference to. If the called field descriptor is not a reference
221 * field then null is returned.
222 */
223 public IFieldRelation getReferenceFieldRelation();
224
225 /*** Access method that returns an iterator for all IFieldRelation
226 * objects that the called field descripyor is a part of.
227 */
228 public java.util.Iterator getFieldRelations();
229 }