86 |
86 |
import org.slf4j.Logger;
|
87 |
87 |
import org.slf4j.LoggerFactory;
|
88 |
88 |
import org.gvsig.tools.dataTypes.CoercionContext;
|
|
89 |
import org.gvsig.tools.dataTypes.DataType.NumberPrecisionAndScale;
|
89 |
90 |
|
90 |
91 |
@SuppressWarnings("UseSpecificCatch")
|
91 |
92 |
public class DefaultFeatureAttributeDescriptor implements
|
92 |
93 |
FeatureAttributeDescriptor, Persistent, DynField_v2, DynField_LabelAttribute {
|
93 |
94 |
|
94 |
|
protected static final Logger LOGGER = LoggerFactory.getLogger(DefaultFeatureAttributeDescriptor.class);
|
95 |
|
|
96 |
|
protected boolean allowNull;
|
97 |
|
protected DataType dataType;
|
98 |
|
protected String dataProfile;
|
99 |
|
protected DateFormat dateFormat;
|
100 |
|
protected Object defaultValue;
|
101 |
|
protected int index;
|
102 |
|
protected int maximumOccurrences;
|
103 |
|
protected int minimumOccurrences;
|
104 |
|
protected int size;
|
105 |
|
protected String name;
|
106 |
|
protected Class objectClass;
|
107 |
|
protected int precision;
|
108 |
|
protected int scale;
|
109 |
|
protected int roundMode;
|
110 |
|
protected Evaluator evaluator;
|
111 |
|
protected boolean primaryKey;
|
112 |
|
protected boolean readOnly;
|
113 |
|
protected IProjection SRS;
|
114 |
|
protected GeometryType geomType;
|
115 |
|
protected int geometryType;
|
116 |
|
protected int geometrySubType;
|
117 |
|
protected Map additionalInfo;
|
118 |
|
protected boolean isAutomatic;
|
119 |
|
protected boolean isTime = false;
|
120 |
|
protected Interval interval;
|
121 |
|
protected FeatureAttributeGetter featureAttributeGetter = null;
|
122 |
|
protected FeatureAttributeEmulator featureAttributeEmulator = null;
|
123 |
|
protected boolean indexed = false;
|
124 |
|
protected boolean isIndexAscending = true;
|
125 |
|
protected boolean allowIndexDuplicateds = true;
|
|
95 |
protected static final Logger LOGGER = LoggerFactory.getLogger(DefaultFeatureAttributeDescriptor.class);
|
126 |
96 |
|
127 |
|
protected DynObjectValueItem[] availableValues;
|
128 |
|
private Map<Object,String> labelOfValueMap; // No persistente
|
129 |
|
protected String description;
|
130 |
|
protected Object minValue;
|
131 |
|
protected Object maxValue;
|
132 |
|
protected String label;
|
133 |
|
protected String shortLabel;
|
134 |
|
protected int order;
|
135 |
|
protected boolean hidden;
|
136 |
|
protected String groupName;
|
137 |
|
protected Tags tags = new DefaultTags();
|
138 |
|
private DynMethod availableValuesMethod;
|
139 |
|
private DynMethod calculateMethod;
|
140 |
|
private WeakReference typeRef;
|
141 |
|
protected DefaultForeingKey foreingKey = null;
|
142 |
|
|
143 |
|
protected CoercionContext coerceContext = null; // not persistent
|
144 |
|
protected MathContext mathContext = null; // not persistent
|
145 |
|
|
146 |
|
private int relationType = RELATION_TYPE_NONE;
|
147 |
|
protected Locale locale;
|
|
97 |
protected boolean allowNull;
|
|
98 |
protected DataType dataType;
|
|
99 |
protected String dataProfile;
|
|
100 |
protected DateFormat dateFormat;
|
|
101 |
protected Object defaultValue;
|
|
102 |
protected int index;
|
|
103 |
protected int maximumOccurrences;
|
|
104 |
protected int minimumOccurrences;
|
|
105 |
protected int size;
|
|
106 |
protected String name;
|
|
107 |
protected Class objectClass;
|
|
108 |
protected int precision;
|
|
109 |
protected int scale;
|
|
110 |
protected int roundMode;
|
|
111 |
protected Evaluator evaluator;
|
|
112 |
protected boolean primaryKey;
|
|
113 |
protected boolean readOnly;
|
|
114 |
protected IProjection SRS;
|
|
115 |
protected GeometryType geomType;
|
|
116 |
protected int geometryType;
|
|
117 |
protected int geometrySubType;
|
|
118 |
protected Map additionalInfo;
|
|
119 |
protected boolean isAutomatic;
|
|
120 |
protected boolean isTime = false;
|
|
121 |
protected Interval interval;
|
|
122 |
protected FeatureAttributeGetter featureAttributeGetter = null;
|
|
123 |
protected FeatureAttributeEmulator featureAttributeEmulator = null;
|
|
124 |
protected boolean indexed = false;
|
|
125 |
protected boolean isIndexAscending = true;
|
|
126 |
protected boolean allowIndexDuplicateds = true;
|
148 |
127 |
|
149 |
|
public DefaultFeatureAttributeDescriptor() {
|
150 |
|
// Usada en la persistencia
|
151 |
|
}
|
|
128 |
protected DynObjectValueItem[] availableValues;
|
|
129 |
private Map<Object, String> labelOfValueMap; // No persistente
|
|
130 |
protected String description;
|
|
131 |
protected Object minValue;
|
|
132 |
protected Object maxValue;
|
|
133 |
protected String label;
|
|
134 |
protected String shortLabel;
|
|
135 |
protected int order;
|
|
136 |
protected boolean hidden;
|
|
137 |
protected String groupName;
|
|
138 |
protected Tags tags = new DefaultTags();
|
|
139 |
private DynMethod availableValuesMethod;
|
|
140 |
private DynMethod calculateMethod;
|
|
141 |
private WeakReference typeRef;
|
|
142 |
protected DefaultForeingKey foreingKey = null;
|
152 |
143 |
|
153 |
|
protected DefaultFeatureAttributeDescriptor(FeatureType type) {
|
154 |
|
this();
|
|
144 |
protected CoercionContext coerceContext = null; // not persistent
|
|
145 |
protected MathContext mathContext = null; // not persistent
|
|
146 |
|
|
147 |
private int relationType = RELATION_TYPE_NONE;
|
|
148 |
protected Locale locale;
|
|
149 |
|
|
150 |
public DefaultFeatureAttributeDescriptor() {
|
|
151 |
// Usada en la persistencia
|
|
152 |
}
|
|
153 |
|
|
154 |
protected DefaultFeatureAttributeDescriptor(FeatureType type) {
|
|
155 |
this();
|
155 |
156 |
// LOGGER.info(String.format("Created FeatureAttributeDescriptor [%08x].", this.hashCode()));
|
156 |
|
setFeatureType(type);
|
157 |
|
this.allowNull = true;
|
158 |
|
this.dataType = null;
|
159 |
|
this.dateFormat = null;
|
160 |
|
this.defaultValue = null;
|
161 |
|
this.index = -1;
|
162 |
|
this.maximumOccurrences = 0;
|
163 |
|
this.minimumOccurrences = 0;
|
164 |
|
this.size = 0;
|
165 |
|
this.name = null;
|
166 |
|
this.objectClass = null;
|
167 |
|
this.precision = 0;
|
168 |
|
this.scale = 0;
|
169 |
|
this.roundMode = BigDecimal.ROUND_HALF_UP;
|
170 |
|
this.evaluator = null;
|
171 |
|
this.primaryKey = false;
|
172 |
|
this.readOnly = false;
|
173 |
|
this.SRS = null;
|
174 |
|
this.geometryType = Geometry.TYPES.NULL;
|
175 |
|
this.geometrySubType = Geometry.SUBTYPES.UNKNOWN;
|
176 |
|
this.additionalInfo = null;
|
177 |
|
this.isAutomatic = false;
|
178 |
|
this.hidden = false;
|
179 |
|
this.relationType = RELATION_TYPE_NONE;
|
180 |
|
this.locale = Locale.ENGLISH;
|
181 |
|
}
|
|
157 |
setFeatureType(type);
|
|
158 |
this.allowNull = true;
|
|
159 |
this.dataType = null;
|
|
160 |
this.dateFormat = null;
|
|
161 |
this.defaultValue = null;
|
|
162 |
this.index = -1;
|
|
163 |
this.maximumOccurrences = 0;
|
|
164 |
this.minimumOccurrences = 0;
|
|
165 |
this.size = 0;
|
|
166 |
this.name = null;
|
|
167 |
this.objectClass = null;
|
|
168 |
this.precision = 0;
|
|
169 |
this.scale = 0;
|
|
170 |
this.roundMode = BigDecimal.ROUND_HALF_UP;
|
|
171 |
this.evaluator = null;
|
|
172 |
this.primaryKey = false;
|
|
173 |
this.readOnly = false;
|
|
174 |
this.SRS = null;
|
|
175 |
this.geometryType = Geometry.TYPES.NULL;
|
|
176 |
this.geometrySubType = Geometry.SUBTYPES.UNKNOWN;
|
|
177 |
this.additionalInfo = null;
|
|
178 |
this.isAutomatic = false;
|
|
179 |
this.hidden = false;
|
|
180 |
this.relationType = RELATION_TYPE_NONE;
|
|
181 |
this.locale = Locale.ENGLISH;
|
|
182 |
}
|
182 |
183 |
|
183 |
|
protected DefaultFeatureAttributeDescriptor(
|
184 |
|
DefaultFeatureAttributeDescriptor other
|
185 |
|
) {
|
186 |
|
this();
|
187 |
|
copyFrom(other);
|
|
184 |
protected DefaultFeatureAttributeDescriptor(
|
|
185 |
DefaultFeatureAttributeDescriptor other
|
|
186 |
) {
|
|
187 |
this();
|
|
188 |
copyFrom(other);
|
188 |
189 |
// LOGGER.info(String.format("Created FeatureAttributeDescriptor [%08x] [%s] (copy).", this.hashCode(), this.name));
|
|
190 |
}
|
|
191 |
|
|
192 |
@Override
|
|
193 |
public void copyFrom(DynField other1) {
|
|
194 |
if (!(other1 instanceof DefaultFeatureAttributeDescriptor)) {
|
|
195 |
throw new IllegalArgumentException("Can't copy from a non DefaultFeatureAttributeDescriptor");
|
189 |
196 |
}
|
190 |
|
|
191 |
|
@Override
|
192 |
|
public void copyFrom(DynField other1) {
|
193 |
|
if( !(other1 instanceof DefaultFeatureAttributeDescriptor) ) {
|
194 |
|
throw new IllegalArgumentException("Can't copy from a non DefaultFeatureAttributeDescriptor");
|
195 |
|
}
|
196 |
|
DefaultFeatureAttributeDescriptor other = (DefaultFeatureAttributeDescriptor) other1;
|
197 |
|
this.typeRef = other.typeRef;
|
198 |
|
this.allowNull = other.allowNull;
|
199 |
|
this.dataType = other.dataType;
|
200 |
|
this.dateFormat = other.dateFormat;
|
201 |
|
this.defaultValue = other.defaultValue;
|
202 |
|
this.index = other.index;
|
203 |
|
this.maximumOccurrences = other.maximumOccurrences;
|
204 |
|
this.minimumOccurrences = other.minimumOccurrences;
|
205 |
|
this.size = other.size;
|
206 |
|
this.name = other.name;
|
207 |
|
this.objectClass = other.objectClass;
|
208 |
|
this.precision = other.precision;
|
209 |
|
this.scale = other.scale;
|
210 |
|
this.roundMode = other.roundMode;
|
211 |
|
this.evaluator = other.evaluator;
|
212 |
|
this.primaryKey = other.primaryKey;
|
213 |
|
this.readOnly = other.readOnly;
|
214 |
|
this.SRS = other.SRS;
|
215 |
|
this.geometryType = other.geometryType;
|
216 |
|
this.geometrySubType = other.geometrySubType;
|
217 |
|
this.geomType = other.geomType;
|
218 |
|
if (other.additionalInfo != null) {
|
219 |
|
Iterator iter = other.additionalInfo.entrySet().iterator();
|
220 |
|
Map.Entry entry;
|
221 |
|
this.additionalInfo = new HashMap();
|
222 |
|
while (iter.hasNext()) {
|
223 |
|
entry = (Entry) iter.next();
|
224 |
|
this.additionalInfo.put(entry.getKey(), entry.getValue());
|
225 |
|
}
|
226 |
|
} else {
|
227 |
|
this.additionalInfo = null;
|
228 |
|
}
|
229 |
|
this.isAutomatic = other.isAutomatic;
|
230 |
|
this.isTime = other.isTime;
|
231 |
|
this.featureAttributeEmulator = other.featureAttributeEmulator;
|
232 |
|
this.indexed = other.indexed;
|
233 |
|
this.isIndexAscending = other.isIndexAscending;
|
234 |
|
this.allowIndexDuplicateds = other.allowIndexDuplicateds;
|
235 |
|
this.hidden = other.hidden;
|
236 |
|
this.dataProfile = other.dataProfile;
|
237 |
|
|
238 |
|
this.availableValues = other.availableValues;
|
239 |
|
this.description = other.description;
|
240 |
|
this.minValue = other.minValue;
|
241 |
|
this.maxValue = other.maxValue;
|
242 |
|
this.label = other.label;
|
243 |
|
this.order = other.order;
|
244 |
|
this.groupName = other.groupName;
|
245 |
|
if( other.tags==null ) {
|
246 |
|
this.tags = null;
|
247 |
|
} else {
|
248 |
|
try {
|
249 |
|
this.tags = (Tags) other.tags.clone();
|
250 |
|
} catch (Exception ex) {
|
251 |
|
}
|
252 |
|
}
|
253 |
|
this.foreingKey = null;
|
254 |
|
if( other.foreingKey!=null ) {
|
255 |
|
try {
|
256 |
|
this.foreingKey = (DefaultForeingKey) other.foreingKey.clone();
|
257 |
|
} catch (CloneNotSupportedException ex) {
|
258 |
|
}
|
259 |
|
}
|
260 |
|
if( this.foreingKey!=null ) {
|
261 |
|
this.foreingKey.setDescriptor(this);
|
262 |
|
}
|
263 |
|
|
264 |
|
// TODO: ? Habria que clonarlos ?
|
265 |
|
this.availableValuesMethod = other.availableValuesMethod;
|
266 |
|
this.calculateMethod = other.calculateMethod;
|
267 |
|
this.relationType = other.relationType;
|
268 |
|
this.locale = other.locale;
|
|
197 |
DefaultFeatureAttributeDescriptor other = (DefaultFeatureAttributeDescriptor) other1;
|
|
198 |
this.typeRef = other.typeRef;
|
|
199 |
this.allowNull = other.allowNull;
|
|
200 |
this.dataType = other.dataType;
|
|
201 |
this.dateFormat = other.dateFormat;
|
|
202 |
this.defaultValue = other.defaultValue;
|
|
203 |
this.index = other.index;
|
|
204 |
this.maximumOccurrences = other.maximumOccurrences;
|
|
205 |
this.minimumOccurrences = other.minimumOccurrences;
|
|
206 |
this.size = other.size;
|
|
207 |
this.name = other.name;
|
|
208 |
this.objectClass = other.objectClass;
|
|
209 |
this.precision = other.precision;
|
|
210 |
this.scale = other.scale;
|
|
211 |
this.roundMode = other.roundMode;
|
|
212 |
this.evaluator = other.evaluator;
|
|
213 |
this.primaryKey = other.primaryKey;
|
|
214 |
this.readOnly = other.readOnly;
|
|
215 |
this.SRS = other.SRS;
|
|
216 |
this.geometryType = other.geometryType;
|
|
217 |
this.geometrySubType = other.geometrySubType;
|
|
218 |
this.geomType = other.geomType;
|
|
219 |
if (other.additionalInfo != null) {
|
|
220 |
Iterator iter = other.additionalInfo.entrySet().iterator();
|
|
221 |
Map.Entry entry;
|
|
222 |
this.additionalInfo = new HashMap();
|
|
223 |
while (iter.hasNext()) {
|
|
224 |
entry = (Entry) iter.next();
|
|
225 |
this.additionalInfo.put(entry.getKey(), entry.getValue());
|
|
226 |
}
|
|
227 |
} else {
|
|
228 |
this.additionalInfo = null;
|
269 |
229 |
}
|
270 |
|
|
271 |
|
public void setFeatureType(FeatureType type) {
|
272 |
|
// Usada en la persistencia
|
273 |
|
if( type == null ) {
|
274 |
|
this.typeRef = null;
|
275 |
|
} else {
|
276 |
|
this.typeRef = new WeakReference(type);
|
277 |
|
// LOGGER.info(String.format("FeatureAttributeDescriptor[%08x] set FeatureType [%08x], ref [%08x].", this.hashCode(), type.hashCode(), typeRef.hashCode()));
|
278 |
|
}
|
279 |
|
}
|
280 |
|
|
281 |
|
@Override
|
282 |
|
public String getDataTypeName() {
|
283 |
|
if (this.getDataType() == null) {
|
284 |
|
return "(unknow)";
|
285 |
|
}
|
286 |
|
return this.getDataType().getName();
|
287 |
|
}
|
|
230 |
this.isAutomatic = other.isAutomatic;
|
|
231 |
this.isTime = other.isTime;
|
|
232 |
this.featureAttributeEmulator = other.featureAttributeEmulator;
|
|
233 |
this.indexed = other.indexed;
|
|
234 |
this.isIndexAscending = other.isIndexAscending;
|
|
235 |
this.allowIndexDuplicateds = other.allowIndexDuplicateds;
|
|
236 |
this.hidden = other.hidden;
|
|
237 |
this.dataProfile = other.dataProfile;
|
288 |
238 |
|
289 |
|
@Override
|
290 |
|
public DefaultFeatureAttributeDescriptor getCopy() {
|
291 |
|
return new DefaultFeatureAttributeDescriptor(this);
|
|
239 |
this.availableValues = other.availableValues;
|
|
240 |
this.description = other.description;
|
|
241 |
this.minValue = other.minValue;
|
|
242 |
this.maxValue = other.maxValue;
|
|
243 |
this.label = other.label;
|
|
244 |
this.order = other.order;
|
|
245 |
this.groupName = other.groupName;
|
|
246 |
if (other.tags == null) {
|
|
247 |
this.tags = null;
|
|
248 |
} else {
|
|
249 |
try {
|
|
250 |
this.tags = (Tags) other.tags.clone();
|
|
251 |
} catch (Exception ex) {
|
|
252 |
}
|
292 |
253 |
}
|
293 |
|
|
294 |
|
@Override
|
295 |
|
public Object clone() throws CloneNotSupportedException {
|
296 |
|
return new DefaultFeatureAttributeDescriptor(this);
|
|
254 |
this.foreingKey = null;
|
|
255 |
if (other.foreingKey != null) {
|
|
256 |
try {
|
|
257 |
this.foreingKey = (DefaultForeingKey) other.foreingKey.clone();
|
|
258 |
} catch (CloneNotSupportedException ex) {
|
|
259 |
}
|
297 |
260 |
}
|
298 |
|
|
299 |
|
@Override
|
300 |
|
public boolean allowNull() {
|
301 |
|
return allowNull;
|
|
261 |
if (this.foreingKey != null) {
|
|
262 |
this.foreingKey.setDescriptor(this);
|
302 |
263 |
}
|
303 |
264 |
|
304 |
|
public Locale getLocale() {
|
305 |
|
return this.locale;
|
306 |
|
}
|
307 |
|
|
308 |
|
@Override
|
309 |
|
public DataType getDataType() {
|
310 |
|
if (featureAttributeGetter != null) {
|
311 |
|
return featureAttributeGetter.getDataType();
|
312 |
|
}
|
313 |
|
return this.dataType;
|
314 |
|
}
|
|
265 |
// TODO: ? Habria que clonarlos ?
|
|
266 |
this.availableValuesMethod = other.availableValuesMethod;
|
|
267 |
this.calculateMethod = other.calculateMethod;
|
|
268 |
this.relationType = other.relationType;
|
|
269 |
this.locale = other.locale;
|
|
270 |
}
|
315 |
271 |
|
316 |
|
public FeatureAttributeDescriptor setDataType(int type) {
|
317 |
|
this.dataType = ToolsLocator.getDataTypesManager().get(type);
|
318 |
|
return this;
|
|
272 |
public void setFeatureType(FeatureType type) {
|
|
273 |
// Usada en la persistencia
|
|
274 |
if (type == null) {
|
|
275 |
this.typeRef = null;
|
|
276 |
} else {
|
|
277 |
this.typeRef = new WeakReference(type);
|
|
278 |
// LOGGER.info(String.format("FeatureAttributeDescriptor[%08x] set FeatureType [%08x], ref [%08x].", this.hashCode(), type.hashCode(), typeRef.hashCode()));
|
319 |
279 |
}
|
|
280 |
}
|
320 |
281 |
|
321 |
|
@Override
|
322 |
|
public DateFormat getDateFormat() {
|
323 |
|
return this.dateFormat;
|
|
282 |
@Override
|
|
283 |
public String getDataTypeName() {
|
|
284 |
if (this.getDataType() == null) {
|
|
285 |
return "(unknow)";
|
324 |
286 |
}
|
|
287 |
return this.getDataType().getName();
|
|
288 |
}
|
325 |
289 |
|
326 |
|
@Override
|
327 |
|
public Object getDefaultValue() {
|
328 |
|
return this.defaultValue;
|
329 |
|
}
|
|
290 |
@Override
|
|
291 |
public DefaultFeatureAttributeDescriptor getCopy() {
|
|
292 |
return new DefaultFeatureAttributeDescriptor(this);
|
|
293 |
}
|
330 |
294 |
|
331 |
|
@Override
|
332 |
|
public Object getDefaultValueCoerced() {
|
333 |
|
try {
|
334 |
|
Object value = this.defaultValue;
|
335 |
|
if( value == null ) {
|
336 |
|
return null;
|
337 |
|
}
|
338 |
|
if( ExpressionUtils.isDynamicText(value.toString()) ) {
|
339 |
|
value = ExpressionUtils.evaluateDynamicText(value.toString());
|
340 |
|
}
|
341 |
|
return this.getDataType().coerce(value);
|
342 |
|
} catch (CoercionException ex) {
|
343 |
|
return null;
|
344 |
|
}
|
345 |
|
}
|
|
295 |
@Override
|
|
296 |
public Object clone() throws CloneNotSupportedException {
|
|
297 |
return new DefaultFeatureAttributeDescriptor(this);
|
|
298 |
}
|
346 |
299 |
|
347 |
|
@Override
|
348 |
|
public Evaluator getEvaluator() {
|
349 |
|
return this.evaluator;
|
350 |
|
}
|
|
300 |
@Override
|
|
301 |
public boolean allowNull() {
|
|
302 |
return allowNull;
|
|
303 |
}
|
351 |
304 |
|
352 |
|
@Override
|
353 |
|
public int getGeometryType() {
|
354 |
|
if( this.dataType.getType()!=DataTypes.GEOMETRY ) {
|
355 |
|
return Geometry.TYPES.UNKNOWN;
|
356 |
|
}
|
357 |
|
return this.geometryType;
|
358 |
|
}
|
|
305 |
public Locale getLocale() {
|
|
306 |
return this.locale;
|
|
307 |
}
|
359 |
308 |
|
360 |
|
@Override
|
361 |
|
public int getGeometrySubType() {
|
362 |
|
if( this.dataType.getType()!=DataTypes.GEOMETRY ) {
|
363 |
|
return Geometry.SUBTYPES.UNKNOWN;
|
364 |
|
}
|
365 |
|
return this.geometrySubType;
|
|
309 |
@Override
|
|
310 |
public DataType getDataType() {
|
|
311 |
if (featureAttributeGetter != null) {
|
|
312 |
return featureAttributeGetter.getDataType();
|
366 |
313 |
}
|
|
314 |
return this.dataType;
|
|
315 |
}
|
367 |
316 |
|
368 |
|
@Override
|
369 |
|
public GeometryType getGeomType() {
|
370 |
|
if( this.dataType.getType()!=DataTypes.GEOMETRY ) {
|
371 |
|
return null;
|
372 |
|
}
|
373 |
|
if (this.geomType == null) {
|
374 |
|
try {
|
375 |
|
this.geomType
|
376 |
|
= GeometryLocator.getGeometryManager().getGeometryType(
|
377 |
|
this.geometryType, this.geometrySubType);
|
378 |
|
} catch (GeometryException e) {
|
379 |
|
throw new RuntimeException(
|
380 |
|
"Error getting geometry type with type = "
|
381 |
|
+ this.geometryType + ", subtype = "
|
382 |
|
+ this.geometrySubType, e);
|
383 |
|
}
|
384 |
|
}
|
385 |
|
return this.geomType;
|
386 |
|
}
|
|
317 |
public FeatureAttributeDescriptor setDataType(int type) {
|
|
318 |
this.dataType = ToolsLocator.getDataTypesManager().get(type);
|
|
319 |
return this;
|
|
320 |
}
|
387 |
321 |
|
388 |
|
@Override
|
389 |
|
public int getIndex() {
|
390 |
|
return this.index;
|
391 |
|
}
|
|
322 |
@Override
|
|
323 |
public DateFormat getDateFormat() {
|
|
324 |
return this.dateFormat;
|
|
325 |
}
|
392 |
326 |
|
393 |
|
protected FeatureAttributeDescriptor setIndex(int index) {
|
394 |
|
this.index = index;
|
395 |
|
return this;
|
|
327 |
@Override
|
|
328 |
public Object getDefaultValue() {
|
|
329 |
return this.defaultValue;
|
|
330 |
}
|
|
331 |
|
|
332 |
@Override
|
|
333 |
public Object getDefaultValueCoerced() {
|
|
334 |
try {
|
|
335 |
Object value = this.defaultValue;
|
|
336 |
if (value == null) {
|
|
337 |
return null;
|
|
338 |
}
|
|
339 |
if (ExpressionUtils.isDynamicText(value.toString())) {
|
|
340 |
value = ExpressionUtils.evaluateDynamicText(value.toString());
|
|
341 |
}
|
|
342 |
return this.getDataType().coerce(value);
|
|
343 |
} catch (CoercionException ex) {
|
|
344 |
return null;
|
396 |
345 |
}
|
|
346 |
}
|
397 |
347 |
|
398 |
|
@Override
|
399 |
|
public int getMaximumOccurrences() {
|
400 |
|
return this.maximumOccurrences;
|
|
348 |
@Override
|
|
349 |
public Evaluator getEvaluator() {
|
|
350 |
return this.evaluator;
|
|
351 |
}
|
|
352 |
|
|
353 |
@Override
|
|
354 |
public int getGeometryType() {
|
|
355 |
if (this.dataType.getType() != DataTypes.GEOMETRY) {
|
|
356 |
return Geometry.TYPES.UNKNOWN;
|
401 |
357 |
}
|
|
358 |
return this.geometryType;
|
|
359 |
}
|
402 |
360 |
|
403 |
|
@Override
|
404 |
|
public int getMinimumOccurrences() {
|
405 |
|
return this.minimumOccurrences;
|
|
361 |
@Override
|
|
362 |
public int getGeometrySubType() {
|
|
363 |
if (this.dataType.getType() != DataTypes.GEOMETRY) {
|
|
364 |
return Geometry.SUBTYPES.UNKNOWN;
|
406 |
365 |
}
|
|
366 |
return this.geometrySubType;
|
|
367 |
}
|
407 |
368 |
|
408 |
|
@Override
|
409 |
|
public String getName() {
|
410 |
|
return this.name;
|
|
369 |
@Override
|
|
370 |
public GeometryType getGeomType() {
|
|
371 |
if (this.dataType.getType() != DataTypes.GEOMETRY) {
|
|
372 |
return null;
|
411 |
373 |
}
|
412 |
|
|
413 |
|
public FeatureAttributeDescriptor setName(String name) {
|
414 |
|
// LOGGER.info(String.format("FeatureAttributeDescriptor[%08x] set name [%s].", this.hashCode(), name));
|
415 |
|
this.name = name;
|
416 |
|
return this;
|
|
374 |
if (this.geomType == null) {
|
|
375 |
try {
|
|
376 |
this.geomType
|
|
377 |
= GeometryLocator.getGeometryManager().getGeometryType(
|
|
378 |
this.geometryType, this.geometrySubType);
|
|
379 |
} catch (GeometryException e) {
|
|
380 |
throw new RuntimeException(
|
|
381 |
"Error getting geometry type with type = "
|
|
382 |
+ this.geometryType + ", subtype = "
|
|
383 |
+ this.geometrySubType, e);
|
|
384 |
}
|
417 |
385 |
}
|
418 |
|
|
419 |
|
@Override
|
420 |
|
public Class getObjectClass() {
|
421 |
|
if (getDataType().getType() == DataTypes.OBJECT) {
|
422 |
|
return objectClass;
|
423 |
|
}
|
424 |
|
return getDataType().getDefaultClass();
|
425 |
|
}
|
|
386 |
return this.geomType;
|
|
387 |
}
|
426 |
388 |
|
427 |
|
@Override
|
428 |
|
public int getPrecision() {
|
429 |
|
return this.precision;
|
430 |
|
}
|
|
389 |
@Override
|
|
390 |
public int getIndex() {
|
|
391 |
return this.index;
|
|
392 |
}
|
431 |
393 |
|
432 |
|
@Override
|
433 |
|
public int getScale() {
|
434 |
|
return this.scale;
|
435 |
|
}
|
|
394 |
protected FeatureAttributeDescriptor setIndex(int index) {
|
|
395 |
this.index = index;
|
|
396 |
return this;
|
|
397 |
}
|
436 |
398 |
|
437 |
|
@Override
|
438 |
|
public Coercion getCoercion() {
|
439 |
|
return this.getDataType().getCoercion();
|
|
399 |
@Override
|
|
400 |
public int getMaximumOccurrences() {
|
|
401 |
return this.maximumOccurrences;
|
|
402 |
}
|
|
403 |
|
|
404 |
@Override
|
|
405 |
public int getMinimumOccurrences() {
|
|
406 |
return this.minimumOccurrences;
|
|
407 |
}
|
|
408 |
|
|
409 |
@Override
|
|
410 |
public String getName() {
|
|
411 |
return this.name;
|
|
412 |
}
|
|
413 |
|
|
414 |
public FeatureAttributeDescriptor setName(String name) {
|
|
415 |
// LOGGER.info(String.format("FeatureAttributeDescriptor[%08x] set name [%s].", this.hashCode(), name));
|
|
416 |
this.name = name;
|
|
417 |
return this;
|
|
418 |
}
|
|
419 |
|
|
420 |
@Override
|
|
421 |
public Class getObjectClass() {
|
|
422 |
if (getDataType().getType() == DataTypes.OBJECT) {
|
|
423 |
return objectClass;
|
440 |
424 |
}
|
441 |
|
|
442 |
|
@Override
|
443 |
|
public MathContext getMathContext() {
|
444 |
|
if( this.mathContext==null ) {
|
445 |
|
if( this.getDataType().isNumeric() ) {
|
446 |
|
this.mathContext = new MathContext(
|
447 |
|
this.getPrecision(),
|
448 |
|
RoundingMode.valueOf(this.getRoundMode())
|
449 |
|
);
|
450 |
|
} else {
|
451 |
|
this.mathContext = MathContext.UNLIMITED;
|
452 |
|
}
|
|
425 |
return getDataType().getDefaultClass();
|
|
426 |
}
|
|
427 |
|
|
428 |
@Override
|
|
429 |
public int getPrecision() {
|
|
430 |
return this.precision;
|
|
431 |
}
|
|
432 |
|
|
433 |
@Override
|
|
434 |
public int getScale() {
|
|
435 |
return this.scale;
|
|
436 |
}
|
|
437 |
|
|
438 |
@Override
|
|
439 |
public Coercion getCoercion() {
|
|
440 |
return this.getDataType().getCoercion();
|
|
441 |
}
|
|
442 |
|
|
443 |
@Override
|
|
444 |
public MathContext getMathContext() {
|
|
445 |
if (this.mathContext == null) {
|
|
446 |
if (this.getDataType().isNumeric()) {
|
|
447 |
this.mathContext = new MathContext(
|
|
448 |
this.getPrecision(),
|
|
449 |
RoundingMode.valueOf(this.getRoundMode())
|
|
450 |
);
|
|
451 |
} else {
|
|
452 |
this.mathContext = MathContext.UNLIMITED;
|
453 |
453 |
}
|
454 |
|
return this.mathContext;
|
455 |
454 |
}
|
456 |
|
|
457 |
|
@Override
|
458 |
|
public CoercionContext getCoercionContext() {
|
459 |
|
if( this.coerceContext==null ) {
|
460 |
|
if( this.getDataType().isNumeric() ) {
|
461 |
|
this.coerceContext = DataTypeUtils.coerceContextDecimal(
|
462 |
|
this.getLocale(),
|
463 |
|
this.getPrecision(),
|
464 |
|
this.getScale(),
|
465 |
|
this.getRoundMode()
|
466 |
|
);
|
467 |
|
} else {
|
468 |
|
this.coerceContext = DataTypeUtils.coerceContextLocale(
|
469 |
|
this.getLocale()
|
470 |
|
);
|
471 |
|
}
|
|
455 |
return this.mathContext;
|
|
456 |
}
|
|
457 |
|
|
458 |
@Override
|
|
459 |
public CoercionContext getCoercionContext() {
|
|
460 |
if (this.coerceContext == null) {
|
|
461 |
if (this.getDataType().isNumeric()) {
|
|
462 |
this.coerceContext = DataTypeUtils.coerceContextDecimal(
|
|
463 |
this.getLocale(),
|
|
464 |
this.getPrecision(),
|
|
465 |
this.getScale(),
|
|
466 |
this.getRoundMode()
|
|
467 |
);
|
|
468 |
} else {
|
|
469 |
this.coerceContext = DataTypeUtils.coerceContextLocale(
|
|
470 |
this.getLocale()
|
|
471 |
);
|
472 |
472 |
}
|
473 |
|
return this.coerceContext;
|
474 |
473 |
}
|
475 |
|
|
476 |
|
public int getRoundMode() {
|
477 |
|
return this.roundMode;
|
|
474 |
return this.coerceContext;
|
|
475 |
}
|
|
476 |
|
|
477 |
@Override
|
|
478 |
public int getRoundMode() {
|
|
479 |
return this.roundMode;
|
|
480 |
}
|
|
481 |
|
|
482 |
@Override
|
|
483 |
public IProjection getSRS() {
|
|
484 |
return this.SRS;
|
|
485 |
}
|
|
486 |
|
|
487 |
@Override
|
|
488 |
public Interval getInterval() {
|
|
489 |
return this.interval;
|
|
490 |
}
|
|
491 |
|
|
492 |
public IProjection getSRS(WeakReference storeRef) {
|
|
493 |
if (this.SRS == null) {
|
|
494 |
FeatureStore store = (FeatureStore) storeRef.get();
|
|
495 |
this.SRS = (IProjection) store.getDynValue(DataStore.METADATA_CRS);
|
478 |
496 |
}
|
479 |
|
|
480 |
|
@Override
|
481 |
|
public IProjection getSRS() {
|
482 |
|
return this.SRS;
|
483 |
|
}
|
|
497 |
return this.SRS;
|
|
498 |
}
|
484 |
499 |
|
485 |
|
@Override
|
486 |
|
public Interval getInterval() {
|
487 |
|
return this.interval;
|
|
500 |
@Override
|
|
501 |
public int getSize() {
|
|
502 |
return this.size;
|
|
503 |
}
|
|
504 |
|
|
505 |
@Override
|
|
506 |
public boolean isPrimaryKey() {
|
|
507 |
return this.primaryKey;
|
|
508 |
}
|
|
509 |
|
|
510 |
@Override
|
|
511 |
public boolean isReadOnly() {
|
|
512 |
if (this.readOnly) {
|
|
513 |
return true;
|
488 |
514 |
}
|
|
515 |
return this.isComputed();
|
|
516 |
}
|
489 |
517 |
|
490 |
|
public IProjection getSRS(WeakReference storeRef) {
|
491 |
|
if( this.SRS==null ) {
|
492 |
|
FeatureStore store = (FeatureStore) storeRef.get();
|
493 |
|
this.SRS = (IProjection) store.getDynValue(DataStore.METADATA_CRS);
|
494 |
|
}
|
495 |
|
return this.SRS;
|
|
518 |
@Override
|
|
519 |
public Object getAdditionalInfo(String infoName) {
|
|
520 |
if (this.additionalInfo == null) {
|
|
521 |
return null;
|
496 |
522 |
}
|
|
523 |
return this.additionalInfo.get(infoName);
|
|
524 |
}
|
497 |
525 |
|
|
526 |
@Override
|
|
527 |
public boolean isAutomatic() {
|
|
528 |
return this.isAutomatic;
|
|
529 |
}
|
498 |
530 |
|
499 |
|
@Override
|
500 |
|
public int getSize() {
|
501 |
|
return this.size;
|
|
531 |
@Override
|
|
532 |
public boolean equals(Object obj) {
|
|
533 |
if (this == obj) {
|
|
534 |
return true;
|
502 |
535 |
}
|
|
536 |
if (!(obj instanceof DefaultFeatureAttributeDescriptor)) {
|
|
537 |
return false;
|
|
538 |
}
|
|
539 |
DefaultFeatureAttributeDescriptor other
|
|
540 |
= (DefaultFeatureAttributeDescriptor) obj;
|
503 |
541 |
|
504 |
|
@Override
|
505 |
|
public boolean isPrimaryKey() {
|
506 |
|
return this.primaryKey;
|
|
542 |
if (this.allowNull != other.allowNull) {
|
|
543 |
return false;
|
507 |
544 |
}
|
508 |
545 |
|
509 |
|
@Override
|
510 |
|
public boolean isReadOnly() {
|
511 |
|
if (this.readOnly) {
|
512 |
|
return true;
|
513 |
|
}
|
514 |
|
return this.isComputed();
|
|
546 |
if (this.index != other.index) {
|
|
547 |
return false;
|
515 |
548 |
}
|
516 |
549 |
|
517 |
|
@Override
|
518 |
|
public Object getAdditionalInfo(String infoName) {
|
519 |
|
if (this.additionalInfo == null) {
|
520 |
|
return null;
|
521 |
|
}
|
522 |
|
return this.additionalInfo.get(infoName);
|
|
550 |
if (!Objects.equals(this.name, other.name)) {
|
|
551 |
return false;
|
523 |
552 |
}
|
524 |
553 |
|
525 |
|
@Override
|
526 |
|
public boolean isAutomatic() {
|
527 |
|
return this.isAutomatic;
|
|
554 |
if (this.getDataType() != other.getDataType()) {
|
|
555 |
return false;
|
528 |
556 |
}
|
529 |
557 |
|
530 |
|
@Override
|
531 |
|
public boolean equals(Object obj) {
|
532 |
|
if (this == obj) {
|
533 |
|
return true;
|
534 |
|
}
|
535 |
|
if (!(obj instanceof DefaultFeatureAttributeDescriptor)) {
|
536 |
|
return false;
|
537 |
|
}
|
538 |
|
DefaultFeatureAttributeDescriptor other
|
539 |
|
= (DefaultFeatureAttributeDescriptor) obj;
|
|
558 |
if (this.size != other.size) {
|
|
559 |
return false;
|
|
560 |
}
|
540 |
561 |
|
541 |
|
if (this.allowNull != other.allowNull) {
|
542 |
|
return false;
|
543 |
|
}
|
|
562 |
if (!Objects.equals(this.defaultValue, other.defaultValue)) {
|
|
563 |
return false;
|
|
564 |
}
|
544 |
565 |
|
545 |
|
if (this.index != other.index) {
|
546 |
|
return false;
|
547 |
|
}
|
|
566 |
if (this.primaryKey != other.primaryKey) {
|
|
567 |
return false;
|
|
568 |
}
|
548 |
569 |
|
549 |
|
if (!Objects.equals(this.name, other.name)) {
|
550 |
|
return false;
|
551 |
|
}
|
|
570 |
if (this.isAutomatic != other.isAutomatic) {
|
|
571 |
return false;
|
|
572 |
}
|
552 |
573 |
|
553 |
|
if (this.getDataType() != other.getDataType()) {
|
554 |
|
return false;
|
555 |
|
}
|
|
574 |
if (this.readOnly != other.readOnly) {
|
|
575 |
return false;
|
|
576 |
}
|
556 |
577 |
|
557 |
|
if (this.size != other.size) {
|
558 |
|
return false;
|
559 |
|
}
|
|
578 |
if (this.precision != other.precision) {
|
|
579 |
return false;
|
|
580 |
}
|
560 |
581 |
|
561 |
|
if (!Objects.equals(this.defaultValue, other.defaultValue)) {
|
562 |
|
return false;
|
563 |
|
}
|
|
582 |
if (this.maximumOccurrences != other.maximumOccurrences) {
|
|
583 |
return false;
|
|
584 |
}
|
564 |
585 |
|
565 |
|
if (this.primaryKey != other.primaryKey) {
|
566 |
|
return false;
|
567 |
|
}
|
|
586 |
if (this.minimumOccurrences != other.minimumOccurrences) {
|
|
587 |
return false;
|
|
588 |
}
|
568 |
589 |
|
569 |
|
if (this.isAutomatic != other.isAutomatic) {
|
570 |
|
return false;
|
571 |
|
}
|
|
590 |
if (this.geometryType != other.geometryType) {
|
|
591 |
return false;
|
|
592 |
}
|
572 |
593 |
|
573 |
|
if (this.readOnly != other.readOnly) {
|
574 |
|
return false;
|
575 |
|
}
|
|
594 |
if (this.geometrySubType != other.geometrySubType) {
|
|
595 |
return false;
|
|
596 |
}
|
576 |
597 |
|
577 |
|
if (this.precision != other.precision) {
|
578 |
|
return false;
|
579 |
|
}
|
|
598 |
if (!Objects.equals(this.evaluator, other.evaluator)) {
|
|
599 |
return false;
|
|
600 |
}
|
580 |
601 |
|
581 |
|
if (this.maximumOccurrences != other.maximumOccurrences) {
|
582 |
|
return false;
|
583 |
|
}
|
|
602 |
if (!Objects.equals(this.featureAttributeEmulator, other.featureAttributeEmulator)) {
|
|
603 |
return false;
|
|
604 |
}
|
584 |
605 |
|
585 |
|
if (this.minimumOccurrences != other.minimumOccurrences) {
|
586 |
|
return false;
|
587 |
|
}
|
|
606 |
if (!Objects.equals(this.SRS, other.SRS)) {
|
|
607 |
return false;
|
|
608 |
}
|
588 |
609 |
|
589 |
|
if (this.geometryType != other.geometryType) {
|
590 |
|
return false;
|
591 |
|
}
|
|
610 |
if (!Objects.equals(this.dateFormat, other.dateFormat)) {
|
|
611 |
return false;
|
|
612 |
}
|
592 |
613 |
|
593 |
|
if (this.geometrySubType != other.geometrySubType) {
|
594 |
|
return false;
|
595 |
|
}
|
|
614 |
if (!Objects.equals(this.objectClass, other.objectClass)) {
|
|
615 |
return false;
|
|
616 |
}
|
596 |
617 |
|
597 |
|
if (!Objects.equals(this.evaluator, other.evaluator)) {
|
598 |
|
return false;
|
599 |
|
}
|
|
618 |
if (!Objects.equals(this.dataProfile, other.dataProfile)) {
|
|
619 |
return false;
|
|
620 |
}
|
600 |
621 |
|
601 |
|
if (!Objects.equals(this.featureAttributeEmulator, other.featureAttributeEmulator)) {
|
602 |
|
return false;
|
603 |
|
}
|
|
622 |
return true;
|
|
623 |
}
|
604 |
624 |
|
605 |
|
if (!Objects.equals(this.SRS, other.SRS)) {
|
606 |
|
return false;
|
607 |
|
}
|
|
625 |
@Override
|
|
626 |
public void loadFromState(PersistentState state)
|
|
627 |
throws PersistenceException {
|
|
628 |
allowNull = state.getBoolean("allowNull");
|
|
629 |
dataType = ToolsLocator.getDataTypesManager().get(state.getInt("dataType"));
|
|
630 |
dataProfile = state.getString("dataProfile");
|
608 |
631 |
|
609 |
|
if (!Objects.equals(this.dateFormat, other.dateFormat)) {
|
610 |
|
return false;
|
611 |
|
}
|
|
632 |
// FIXME: dateFormat;
|
|
633 |
try {
|
|
634 |
defaultValue = dataType.coerce(state.get("defaultValue"));
|
|
635 |
} catch (CoercionException ex) {
|
|
636 |
}
|
612 |
637 |
|
613 |
|
if (!Objects.equals(this.objectClass, other.objectClass)) {
|
614 |
|
return false;
|
615 |
|
}
|
|
638 |
index = state.getInt("index");
|
|
639 |
maximumOccurrences = state.getInt("maximumOccurrences");
|
|
640 |
minimumOccurrences = state.getInt("minimumOccurrences");
|
|
641 |
size = state.getInt("size");
|
|
642 |
name = state.getString("name");
|
|
643 |
try {
|
|
644 |
String objectClassName = state.getString("objectClass");
|
|
645 |
if (!StringUtils.isBlank(objectClassName)) {
|
|
646 |
objectClass = Class.forName(objectClassName);
|
|
647 |
}
|
|
648 |
} catch (Throwable e) {
|
|
649 |
LOGGER.warn("Can't restore the objectClass of the FeatureAttributreDescriptor", e);
|
|
650 |
}
|
|
651 |
precision = state.getInt("precision");
|
|
652 |
scale = state.getInt("scale");
|
|
653 |
roundMode = state.getInt("roundMode");
|
|
654 |
String locale_s = state.getString("locale");
|
|
655 |
locale = StringUtils.isBlank(locale_s) ? null : Locale.forLanguageTag(locale_s);
|
|
656 |
evaluator = (Evaluator) state.get("evaluator");
|
|
657 |
primaryKey = state.getBoolean("primaryKey");
|
|
658 |
readOnly = state.getBoolean("readOnly");
|
|
659 |
SRS = (IProjection) state.get("SRS");
|
|
660 |
geometryType = state.getInt("geometryType");
|
|
661 |
geometrySubType = state.getInt("geometrySubType");
|
|
662 |
if (geometryType != Geometry.TYPES.UNKNOWN
|
|
663 |
&& geometrySubType != Geometry.SUBTYPES.UNKNOWN) {
|
|
664 |
geomType = GeometryUtils.getGeometryType(
|
|
665 |
geometryType,
|
|
666 |
geometrySubType
|
|
667 |
);
|
|
668 |
}
|
|
669 |
// additionalInfo = (Map) state.get("aditionalInfo");
|
|
670 |
isAutomatic = state.getBoolean("isAutomatic");
|
|
671 |
isTime = state.getBoolean("isTime");
|
|
672 |
if (state.hasValue("intervalStart")) {
|
|
673 |
long intervalStart = state.getLong("interval_start");
|
|
674 |
long intervalEnd = state.getLong("interval_end");
|
|
675 |
interval = TimeSupportLocator.getManager().createRelativeInterval(intervalStart, intervalEnd);
|
|
676 |
} else {
|
|
677 |
interval = null;
|
|
678 |
}
|
|
679 |
featureAttributeEmulator = (FeatureAttributeEmulator) state.get("featureAttributeEmulator");
|
|
680 |
indexed = state.getBoolean("indexed");
|
|
681 |
isIndexAscending = state.getBoolean("isIndexAscending");
|
|
682 |
allowIndexDuplicateds = state.getBoolean("allowIndexDuplicateds");
|
616 |
683 |
|
617 |
|
if (!Objects.equals(this.dataProfile, other.dataProfile)) {
|
618 |
|
return false;
|
619 |
|
}
|
620 |
|
|
621 |
|
return true;
|
|
684 |
Map<String, Object> values = state.getMap("availableValues");
|
|
685 |
if (values == null || values.isEmpty()) {
|
|
686 |
this.availableValues = null;
|
|
687 |
} else {
|
|
688 |
this.availableValues = new DynObjectValueItem[values.size()];
|
|
689 |
int n = 0;
|
|
690 |
for (Entry<String, Object> entry : values.entrySet()) {
|
|
691 |
this.availableValues[n++] = new DynObjectValueItem(entry.getValue(), entry.getKey());
|
|
692 |
}
|
622 |
693 |
}
|
623 |
694 |
|
624 |
|
@Override
|
625 |
|
public void loadFromState(PersistentState state)
|
626 |
|
throws PersistenceException {
|
627 |
|
allowNull = state.getBoolean("allowNull");
|
628 |
|
dataType = ToolsLocator.getDataTypesManager().get(state.getInt("dataType"));
|
629 |
|
dataProfile = state.getString("dataProfile");
|
630 |
|
|
631 |
|
// FIXME: dateFormat;
|
632 |
|
try {
|
633 |
|
defaultValue = dataType.coerce(state.get("defaultValue"));
|
634 |
|
} catch (CoercionException ex) {
|
635 |
|
}
|
|
695 |
description = state.getString("description");
|
|
696 |
minValue = state.get("minValue");
|
|
697 |
maxValue = state.get("maxValue");
|
|
698 |
label = state.getString("label");
|
|
699 |
order = state.getInt("order");
|
|
700 |
hidden = state.getBoolean("hidden");
|
|
701 |
groupName = state.getString("groupName");
|
|
702 |
relationType = state.getInt("relationType");
|
636 |
703 |
|
637 |
|
index = state.getInt("index");
|
638 |
|
maximumOccurrences = state.getInt("maximumOccurrences");
|
639 |
|
minimumOccurrences = state.getInt("minimumOccurrences");
|
640 |
|
size = state.getInt("size");
|
641 |
|
name = state.getString("name");
|
642 |
|
try {
|
643 |
|
String objectClassName = state.getString("objectClass");
|
644 |
|
if( !StringUtils.isBlank(objectClassName) ) {
|
645 |
|
objectClass = Class.forName(objectClassName);
|
646 |
|
}
|
647 |
|
} catch (Throwable e) {
|
648 |
|
LOGGER.warn("Can't restore the objectClass of the FeatureAttributreDescriptor", e);
|
649 |
|
}
|
650 |
|
precision = state.getInt("precision");
|
651 |
|
scale = state.getInt("scale");
|
652 |
|
roundMode = state.getInt("roundMode");
|
653 |
|
String locale_s = state.getString("locale");
|
654 |
|
locale = StringUtils.isBlank(locale_s)? null:Locale.forLanguageTag(locale_s);
|
655 |
|
evaluator = (Evaluator) state.get("evaluator");
|
656 |
|
primaryKey = state.getBoolean("primaryKey");
|
657 |
|
readOnly = state.getBoolean("readOnly");
|
658 |
|
SRS = (IProjection) state.get("SRS");
|
659 |
|
geometryType = state.getInt("geometryType");
|
660 |
|
geometrySubType = state.getInt("geometrySubType");
|
661 |
|
if( geometryType!=Geometry.TYPES.UNKNOWN &&
|
662 |
|
geometrySubType!=Geometry.SUBTYPES.UNKNOWN ) {
|
663 |
|
geomType = GeometryUtils.getGeometryType(
|
664 |
|
geometryType,
|
665 |
|
geometrySubType
|
666 |
|
);
|
667 |
|
}
|
668 |
|
// additionalInfo = (Map) state.get("aditionalInfo");
|
669 |
|
isAutomatic = state.getBoolean("isAutomatic");
|
670 |
|
isTime = state.getBoolean("isTime");
|
671 |
|
if( state.hasValue("intervalStart") ) {
|
672 |
|
long intervalStart = state.getLong("interval_start");
|
673 |
|
long intervalEnd = state.getLong("interval_end");
|
674 |
|
interval = TimeSupportLocator.getManager().createRelativeInterval(intervalStart, intervalEnd);
|
675 |
|
} else {
|
676 |
|
interval = null;
|
677 |
|
}
|
678 |
|
featureAttributeEmulator = (FeatureAttributeEmulator) state.get("featureAttributeEmulator");
|
679 |
|
indexed = state.getBoolean("indexed");
|
680 |
|
isIndexAscending = state.getBoolean("isIndexAscending");
|
681 |
|
allowIndexDuplicateds = state.getBoolean("allowIndexDuplicateds");
|
682 |
|
|
683 |
|
Map<String,Object> values = state.getMap("availableValues");
|
684 |
|
if( values == null || values.isEmpty() ) {
|
685 |
|
this.availableValues = null;
|
686 |
|
} else {
|
687 |
|
this.availableValues = new DynObjectValueItem[values.size()];
|
688 |
|
int n = 0;
|
689 |
|
for (Entry<String, Object> entry : values.entrySet()) {
|
690 |
|
this.availableValues[n++] = new DynObjectValueItem(entry.getValue(), entry.getKey());
|
691 |
|
}
|
692 |
|
}
|
693 |
|
|
694 |
|
description = state.getString("description");
|
695 |
|
minValue = state.get("minValue");
|
696 |
|
maxValue = state.get("maxValue");
|
697 |
|
label = state.getString("label");
|
698 |
|
order = state.getInt("order");
|
699 |
|
hidden = state.getBoolean("hidden");
|
700 |
|
groupName = state.getString("groupName");
|
701 |
|
relationType = state.getInt("relationType");
|
702 |
|
|
703 |
|
foreingKey = (DefaultForeingKey) state.get("foreingKey");
|
704 |
|
if( foreingKey!=null ) {
|
705 |
|
this.foreingKey.setDescriptor(this);
|
706 |
|
}
|
707 |
|
tags = (Tags) state.get("tags");
|
708 |
|
if( tags == null ) {
|
709 |
|
this.tags = new DefaultTags();
|
710 |
|
}
|
|
704 |
foreingKey = (DefaultForeingKey) state.get("foreingKey");
|
|
705 |
if (foreingKey != null) {
|
|
706 |
this.foreingKey.setDescriptor(this);
|
711 |
707 |
}
|
|
708 |
tags = (Tags) state.get("tags");
|
|
709 |
if (tags == null) {
|
|
710 |
this.tags = new DefaultTags();
|
|
711 |
}
|
|
712 |
}
|
712 |
713 |
|
713 |
|
@Override
|
714 |
|
public void saveToState(PersistentState state) throws PersistenceException {
|
715 |
|
state.set("allowNull", allowNull);
|
716 |
|
state.set("dataType", dataType.getType());
|
717 |
|
state.set("dataProfile", dataProfile);
|
718 |
|
|
|
714 |
@Override
|
|
715 |
public void saveToState(PersistentState state) throws PersistenceException {
|
|
716 |
state.set("allowNull", allowNull);
|
|
717 |
state.set("dataType", dataType.getType());
|
|
718 |
state.set("dataProfile", dataProfile);
|
|
719 |
|
719 |
720 |
// FIXME: dateFormat;
|
|
721 |
state.set("defaultValue", Objects.toString(defaultValue, null));
|
720 |
722 |
|
721 |
|
state.set("defaultValue", Objects.toString(defaultValue, null));
|
|
723 |
state.set("index", index);
|
|
724 |
state.set("maximumOccurrences", maximumOccurrences);
|
|
725 |
state.set("minimumOccurrences", minimumOccurrences);
|
|
726 |
state.set("size", size);
|
|
727 |
state.set("name", name);
|
|
728 |
state.set("objectClass", objectClass == null ? null : objectClass.getName());
|
|
729 |
state.set("precision", precision);
|
|
730 |
state.set("scale", scale);
|
|
731 |
state.set("roundMode", roundMode);
|
|
732 |
state.set("locale", this.locale == null ? null : this.locale.toLanguageTag());
|
|
733 |
state.set("evaluator", evaluator);
|
722 |
734 |
|
723 |
|
state.set("index", index);
|
724 |
|
state.set("maximumOccurrences", maximumOccurrences);
|
725 |
|
state.set("minimumOccurrences", minimumOccurrences);
|
726 |
|
state.set("size", size);
|
727 |
|
state.set("name", name);
|
728 |
|
state.set("objectClass", objectClass==null? null:objectClass.getName());
|
729 |
|
state.set("precision", precision);
|
730 |
|
state.set("scale", scale);
|
731 |
|
state.set("roundMode", roundMode);
|
732 |
|
state.set("locale", this.locale==null? null:this.locale.toLanguageTag());
|
733 |
|
state.set("evaluator", evaluator);
|
734 |
|
|
735 |
|
state.set("primaryKey", primaryKey);
|
736 |
|
state.set("readOnly", readOnly);
|
737 |
|
state.set("SRS", SRS);
|
738 |
|
GeometryType theGeomType = this.getGeomType();
|
739 |
|
if( theGeomType==null ) {
|
740 |
|
state.set("geometryType", Geometry.TYPES.UNKNOWN);
|
741 |
|
state.set("geometrySubType", Geometry.SUBTYPES.UNKNOWN);
|
742 |
|
} else {
|
743 |
|
state.set("geometryType", theGeomType.getType());
|
744 |
|
state.set("geometrySubType", theGeomType.getSubType());
|
745 |
|
}
|
|
735 |
state.set("primaryKey", primaryKey);
|
|
736 |
state.set("readOnly", readOnly);
|
|
737 |
state.set("SRS", SRS);
|
|
738 |
GeometryType theGeomType = this.getGeomType();
|
|
739 |
if (theGeomType == null) {
|
|
740 |
state.set("geometryType", Geometry.TYPES.UNKNOWN);
|
|
741 |
state.set("geometrySubType", Geometry.SUBTYPES.UNKNOWN);
|
|
742 |
} else {
|
|
743 |
state.set("geometryType", theGeomType.getType());
|
|
744 |
state.set("geometrySubType", theGeomType.getSubType());
|
|
745 |
}
|
746 |
746 |
|
747 |
747 |
// FIXME: additionalInfo
|
|
748 |
state.set("isAutomatic", isAutomatic);
|
|
749 |
state.set("isTime", isTime);
|
|
750 |
if (this.interval == null) {
|
|
751 |
state.setNull("interval_start");
|
|
752 |
state.setNull("interval_end");
|
|
753 |
} else {
|
|
754 |
state.set("interval_start", ((RelativeInterval) interval).getStart().toMillis());
|
|
755 |
state.set("interval_end", ((RelativeInterval) interval).getEnd().toMillis());
|
|
756 |
}
|
|
757 |
state.set("SRS", SRS);
|
748 |
758 |
|
749 |
|
state.set("isAutomatic", isAutomatic);
|
750 |
|
state.set("isTime", isTime);
|
751 |
|
if( this.interval==null ) {
|
752 |
|
state.setNull("interval_start");
|
753 |
|
state.setNull("interval_end");
|
754 |
|
} else {
|
755 |
|
state.set("interval_start", ((RelativeInterval)interval).getStart().toMillis());
|
756 |
|
state.set("interval_end", ((RelativeInterval)interval).getEnd().toMillis());
|
757 |
|
}
|
758 |
|
state.set("SRS", SRS);
|
759 |
|
|
760 |
759 |
// FIXME: featureAttributeGetter
|
|
760 |
if (featureAttributeEmulator instanceof Persistent) {
|
|
761 |
state.set("featureAttributeEmulator", featureAttributeEmulator);
|
|
762 |
} else {
|
|
763 |
state.setNull("featureAttributeEmulator");
|
|
764 |
}
|
761 |
765 |
|
762 |
|
if( featureAttributeEmulator instanceof Persistent ) {
|
763 |
|
state.set("featureAttributeEmulator", featureAttributeEmulator);
|
764 |
|
} else {
|
765 |
|
state.setNull("featureAttributeEmulator");
|
766 |
|
}
|
|
766 |
state.set("indexed", indexed);
|
|
767 |
state.set("isIndexAscending", isIndexAscending);
|
|
768 |
state.set("allowIndexDuplicateds", allowIndexDuplicateds);
|
767 |
769 |
|
768 |
|
state.set("indexed", indexed);
|
769 |
|
state.set("isIndexAscending", isIndexAscending);
|
770 |
|
state.set("allowIndexDuplicateds", allowIndexDuplicateds);
|
771 |
|
|
772 |
|
if( this.availableValues==null ) {
|
773 |
|
state.setNull("availableValues");
|
774 |
|
} else {
|
775 |
|
Map<String,Object> values = new LinkedHashMap<>();
|
776 |
|
for (DynObjectValueItem value : availableValues) {
|
777 |
|
values.put(value.getLabel(),value.getValue());
|
778 |
|
}
|
779 |
|
state.set("availableValues", values);
|
780 |
|
}
|
781 |
|
state.set("description", description);
|
782 |
|
state.set("minValue", minValue);
|
783 |
|
state.set("maxValue", maxValue);
|
784 |
|
state.set("label", label);
|
785 |
|
state.set("order", order);
|
786 |
|
state.set("hidden", hidden);
|
787 |
|
state.set("groupName", groupName);
|
788 |
|
state.set("relationType",relationType);
|
789 |
|
|
790 |
|
state.set("foreingKey" ,this.foreingKey);
|
791 |
|
state.set("tags" ,this.tags);
|
792 |
|
|
|
770 |
if (this.availableValues == null) {
|
|
771 |
state.setNull("availableValues");
|
|
772 |
} else {
|
|
773 |
Map<String, Object> values = new LinkedHashMap<>();
|
|
774 |
for (DynObjectValueItem value : availableValues) {
|
|
775 |
values.put(value.getLabel(), value.getValue());
|
|
776 |
}
|
|
777 |
state.set("availableValues", values);
|
793 |
778 |
}
|
794 |
|
|
795 |
|
private static final String FEATATTRDESC_PERSISTENCE_DEFINITION_NAME = "FeatureAttributeDescriptor";
|
|
779 |
state.set("description", description);
|
|
780 |
state.set("minValue", minValue);
|
|
781 |
state.set("maxValue", maxValue);
|
|
782 |
state.set("label", label);
|
|
783 |
state.set("order", order);
|
|
784 |
state.set("hidden", hidden);
|
|
785 |
state.set("groupName", groupName);
|
|
786 |
state.set("relationType", relationType);
|
796 |
787 |
|
797 |
|
public static void registerPersistenceDefinition() {
|
798 |
|
PersistenceManager manager = ToolsLocator.getPersistenceManager();
|
799 |
|
|
|
788 |
state.set("foreingKey", this.foreingKey);
|
|
789 |
state.set("tags", this.tags);
|
800 |
790 |
|
801 |
|
if (manager.getDefinition(FEATATTRDESC_PERSISTENCE_DEFINITION_NAME)
|
802 |
|
== null) {
|
803 |
|
DynStruct definition = manager.addDefinition(DefaultFeatureAttributeDescriptor.class,
|
804 |
|
FEATATTRDESC_PERSISTENCE_DEFINITION_NAME,
|
805 |
|
FEATATTRDESC_PERSISTENCE_DEFINITION_NAME
|
806 |
|
+ " persistent definition",
|
807 |
|
null,
|
808 |
|
null
|
809 |
|
);
|
810 |
|
definition.addDynFieldBoolean("allowNull");
|
811 |
|
definition.addDynFieldInt("dataType");
|
812 |
|
definition.addDynFieldString("dataProfile");
|
|
791 |
}
|
|
792 |
|
|
793 |
private static final String FEATATTRDESC_PERSISTENCE_DEFINITION_NAME = "FeatureAttributeDescriptor";
|
|
794 |
|
|
795 |
public static void registerPersistenceDefinition() {
|
|
796 |
PersistenceManager manager = ToolsLocator.getPersistenceManager();
|
|
797 |
|
|
798 |
if (manager.getDefinition(FEATATTRDESC_PERSISTENCE_DEFINITION_NAME)
|
|
799 |
== null) {
|
|
800 |
DynStruct definition = manager.addDefinition(DefaultFeatureAttributeDescriptor.class,
|
|
801 |
FEATATTRDESC_PERSISTENCE_DEFINITION_NAME,
|
|
802 |
FEATATTRDESC_PERSISTENCE_DEFINITION_NAME
|
|
803 |
+ " persistent definition",
|
|
804 |
null,
|
|
805 |
null
|
|
806 |
);
|
|
807 |
definition.addDynFieldBoolean("allowNull");
|
|
808 |
definition.addDynFieldInt("dataType");
|
|
809 |
definition.addDynFieldString("dataProfile");
|
813 |
810 |
// definition.addDynFieldString("dateFormat");
|
814 |
|
definition.addDynFieldString("defaultValue");
|
815 |
|
definition.addDynFieldInt("index");
|
816 |
|
definition.addDynFieldInt("maximumOccurrences");
|
817 |
|
definition.addDynFieldInt("minimumOccurrences");
|
818 |
|
definition.addDynFieldInt("size");
|
819 |
|
definition.addDynFieldString("name");
|
820 |
|
definition.addDynFieldString("objectClass");
|
821 |
|
definition.addDynFieldInt("precision");
|
822 |
|
definition.addDynFieldInt("scale");
|
823 |
|
definition.addDynFieldInt("roundMode");
|
824 |
|
definition.addDynFieldString("locale");
|
825 |
|
definition.addDynFieldObject("evaluator")
|
826 |
|
.setClassOfValue(Evaluator.class);
|
827 |
|
definition.addDynFieldBoolean("primaryKey");
|
828 |
|
definition.addDynFieldBoolean("readOnly");
|
829 |
|
definition.addDynFieldObject("SRS")
|
830 |
|
.setClassOfValue(IProjection.class);
|
831 |
|
definition.addDynFieldInt("geometryType");
|
832 |
|
definition.addDynFieldInt("geometrySubType");
|
|
811 |
definition.addDynFieldString("defaultValue");
|
|
812 |
definition.addDynFieldInt("index");
|
|
813 |
definition.addDynFieldInt("maximumOccurrences");
|
|
814 |
definition.addDynFieldInt("minimumOccurrences");
|
|
815 |
definition.addDynFieldInt("size");
|
|
816 |
definition.addDynFieldString("name");
|
|
817 |
definition.addDynFieldString("objectClass");
|
|
818 |
definition.addDynFieldInt("precision");
|
|
819 |
definition.addDynFieldInt("scale");
|
|
820 |
definition.addDynFieldInt("roundMode");
|
|
821 |
definition.addDynFieldString("locale");
|
|
822 |
definition.addDynFieldObject("evaluator")
|
|
823 |
.setClassOfValue(Evaluator.class);
|
|
824 |
definition.addDynFieldBoolean("primaryKey");
|
|
825 |
definition.addDynFieldBoolean("readOnly");
|
|
826 |
definition.addDynFieldObject("SRS")
|
|
827 |
.setClassOfValue(IProjection.class);
|
|
828 |
definition.addDynFieldInt("geometryType");
|
|
829 |
definition.addDynFieldInt("geometrySubType");
|
833 |
830 |
// definition.addDynFieldMap("additionalInfo");
|
834 |
|
definition.addDynFieldBoolean("isAutomatic");
|
835 |
|
definition.addDynFieldBoolean("isTime");
|
836 |
|
definition.addDynFieldLong("interval_start");
|
837 |
|
definition.addDynFieldLong("interval_end");
|
838 |
|
definition.addDynFieldObject("featureAttributeEmulator")
|
839 |
|
.setClassOfValue(FeatureAttributeEmulator.class);
|
840 |
|
definition.addDynFieldBoolean("indexed");
|
841 |
|
definition.addDynFieldBoolean("isIndexAscending");
|
842 |
|
definition.addDynFieldBoolean("allowIndexDuplicateds");
|
843 |
|
definition.addDynFieldMap("availableValues")
|
844 |
|
.setClassOfItems(Object.class);
|
845 |
|
definition.addDynFieldString("description");
|
846 |
|
definition.addDynFieldObject("minValue");
|
847 |
|
definition.addDynFieldObject("maxValue");
|
848 |
|
definition.addDynFieldString("label");
|
849 |
|
definition.addDynFieldInt("order");
|
850 |
|
definition.addDynFieldBoolean("hidden");
|
851 |
|
definition.addDynFieldString("groupName");
|
852 |
|
definition.addDynFieldInt("relationType");
|
853 |
|
|
854 |
|
definition.addDynFieldObject("foreingKey")
|
855 |
|
.setClassOfValue(DefaultForeingKey.class);
|
856 |
|
|
857 |
|
definition.addDynFieldObject("tags")
|
858 |
|
.setClassOfValue(Tags.class);
|
859 |
|
|
860 |
|
}
|
|
831 |
definition.addDynFieldBoolean("isAutomatic");
|
|
832 |
definition.addDynFieldBoolean("isTime");
|
|
833 |
definition.addDynFieldLong("interval_start");
|
|
834 |
definition.addDynFieldLong("interval_end");
|
|
835 |
definition.addDynFieldObject("featureAttributeEmulator")
|
|
836 |
.setClassOfValue(FeatureAttributeEmulator.class);
|
|
837 |
definition.addDynFieldBoolean("indexed");
|
|
838 |
definition.addDynFieldBoolean("isIndexAscending");
|
|
839 |
definition.addDynFieldBoolean("allowIndexDuplicateds");
|
|
840 |
definition.addDynFieldMap("availableValues")
|
|
841 |
.setClassOfItems(Object.class);
|
|
842 |
definition.addDynFieldString("description");
|
|
843 |
definition.addDynFieldObject("minValue");
|
|
844 |
definition.addDynFieldObject("maxValue");
|
|
845 |
definition.addDynFieldString("label");
|
|
846 |
definition.addDynFieldInt("order");
|
|
847 |
definition.addDynFieldBoolean("hidden");
|
|
848 |
definition.addDynFieldString("groupName");
|
|
849 |
definition.addDynFieldInt("relationType");
|
|
850 |
|
|
851 |
definition.addDynFieldObject("foreingKey")
|
|
852 |
.setClassOfValue(DefaultForeingKey.class);
|
|
853 |
|
|
854 |
definition.addDynFieldObject("tags")
|
|
855 |
.setClassOfValue(Tags.class);
|
|
856 |
|
861 |
857 |
}
|
|
858 |
}
|
862 |
859 |
|
863 |
|
|
864 |
|
/*
|
|
860 |
/*
|
865 |
861 |
* Start of DynField interface Implementation
|
866 |
862 |
*
|
867 |
|
*/
|
|
863 |
*/
|
|
864 |
@Override
|
|
865 |
public Tags getTags() {
|
|
866 |
return tags;
|
|
867 |
}
|
868 |
868 |
|
869 |
|
@Override
|
870 |
|
public Tags getTags() {
|
871 |
|
return tags;
|
|
869 |
@Override
|
|
870 |
public DynObjectValueItem[] getAvailableValues() {
|
|
871 |
if (this.availableValues == null) {
|
|
872 |
if (this.isForeingKey() && this.foreingKey.isClosedList()) {
|
|
873 |
return this.foreingKey.getAvailableValues(null);
|
|
874 |
}
|
872 |
875 |
}
|
|
876 |
return this.availableValues;
|
|
877 |
}
|
873 |
878 |
|
874 |
|
@Override
|