Revision 45739 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultEditableFeatureAttributeDescriptor.java
DefaultEditableFeatureAttributeDescriptor.java | ||
---|---|---|
62 | 62 |
import org.gvsig.tools.evaluator.Evaluator; |
63 | 63 |
|
64 | 64 |
public class DefaultEditableFeatureAttributeDescriptor extends |
65 |
DefaultFeatureAttributeDescriptor implements |
|
66 |
EditableFeatureAttributeDescriptor { |
|
67 |
|
|
65 |
DefaultFeatureAttributeDescriptor implements
|
|
66 |
EditableFeatureAttributeDescriptor {
|
|
67 |
|
|
68 | 68 |
private static Logger logger = LoggerFactory.getLogger( |
69 |
DefaultEditableFeatureAttributeDescriptor.class); |
|
69 |
DefaultEditableFeatureAttributeDescriptor.class);
|
|
70 | 70 |
|
71 | 71 |
private final DefaultFeatureAttributeDescriptor source; |
72 | 72 |
private boolean hasStrongChanges; |
73 | 73 |
private String originalName = null; |
74 | 74 |
|
75 | 75 |
protected DefaultEditableFeatureAttributeDescriptor( |
76 |
DefaultFeatureAttributeDescriptor other) { |
|
76 |
DefaultFeatureAttributeDescriptor other) {
|
|
77 | 77 |
super(other); |
78 | 78 |
if (other instanceof DefaultEditableFeatureAttributeDescriptor) { |
79 |
DefaultEditableFeatureAttributeDescriptor other_edi =
|
|
80 |
(DefaultEditableFeatureAttributeDescriptor) other; |
|
79 |
DefaultEditableFeatureAttributeDescriptor other_edi |
|
80 |
= (DefaultEditableFeatureAttributeDescriptor) other;
|
|
81 | 81 |
originalName = other_edi.getOriginalName(); |
82 | 82 |
this.source = other_edi.getSource(); |
83 | 83 |
} else { |
... | ... | |
95 | 95 |
public DefaultFeatureAttributeDescriptor getSource() { |
96 | 96 |
return this.source; |
97 | 97 |
} |
98 |
|
|
98 |
|
|
99 | 99 |
public void fixAll() { |
100 | 100 |
super.fixAll(); |
101 | 101 |
} |
102 |
|
|
102 |
|
|
103 | 103 |
public void checkIntegrity() throws AttributeFeatureTypeIntegrityException { |
104 |
AttributeFeatureTypeIntegrityException ex =
|
|
105 |
new AttributeFeatureTypeIntegrityException(getName()); |
|
104 |
AttributeFeatureTypeIntegrityException ex |
|
105 |
= new AttributeFeatureTypeIntegrityException(getName());
|
|
106 | 106 |
if (this.size < 0) { |
107 | 107 |
ex.add(new AttributeFeatureTypeSizeException(this.size)); |
108 | 108 |
} |
109 | 109 |
|
110 |
if( this.dataType.isObject() && this.objectClass == null ) {
|
|
110 |
if (this.dataType.isObject() && this.objectClass == null) {
|
|
111 | 111 |
logger.warn("Incorrect data type object, objectClass is null."); |
112 | 112 |
ex.add(new AttributeFeatureTypeIntegrityException(this.name)); |
113 | 113 |
} |
114 |
|
|
114 |
|
|
115 | 115 |
// TODO: Add other integrity checks... |
116 |
|
|
117 | 116 |
if (ex.size() > 0) { |
118 | 117 |
throw ex; |
119 | 118 |
} |
... | ... | |
124 | 123 |
this.allowNull = allowNull; |
125 | 124 |
return this; |
126 | 125 |
} |
127 |
|
|
126 |
|
|
128 | 127 |
@Override |
129 | 128 |
public EditableForeingKey getForeingKey() { |
130 |
if( this.foreingKey==null ) {
|
|
129 |
if (this.foreingKey == null) {
|
|
131 | 130 |
this.foreingKey = new DefaultForeingKey(); |
132 | 131 |
this.foreingKey.setDescriptor(this); |
133 | 132 |
} |
... | ... | |
139 | 138 |
this.dataType = dataType; |
140 | 139 |
return this; |
141 | 140 |
} |
142 |
|
|
141 |
|
|
143 | 142 |
public EditableFeatureAttributeDescriptor setDataType(int type) { |
144 | 143 |
updateStrongChanges(this.dataType, type); |
145 | 144 |
this.dataType = ToolsLocator.getDataTypesManager().get(type); |
... | ... | |
147 | 146 |
} |
148 | 147 |
|
149 | 148 |
public EditableFeatureAttributeDescriptor setDefaultValue( |
150 |
Object defaultValue) { |
|
149 |
Object defaultValue) {
|
|
151 | 150 |
updateStrongChanges(this.defaultValue, defaultValue); |
152 | 151 |
this.defaultValue = defaultValue; |
153 | 152 |
return this; |
... | ... | |
157 | 156 |
this.avoidCachingAvailableValues = avoidCachingAvailableValues; |
158 | 157 |
return this; |
159 | 158 |
} |
160 |
|
|
159 |
|
|
161 | 160 |
public EditableFeatureAttributeDescriptor setEvaluator(Evaluator evaluator) { |
162 | 161 |
updateStrongChanges(this.evaluator, evaluator); |
163 | 162 |
this.evaluator = evaluator; |
... | ... | |
169 | 168 |
this.featureAttributeEmulator = featureAttributeEmulator; |
170 | 169 |
return this; |
171 | 170 |
} |
172 |
|
|
171 |
|
|
173 | 172 |
@Override |
174 | 173 |
public EditableFeatureAttributeDescriptor setFeatureAttributeEmulator(Expression expression) { |
175 |
if( ExpressionUtils.isPhraseEmpty(expression) ) {
|
|
176 |
this.setFeatureAttributeEmulator((FeatureAttributeEmulator)null); |
|
174 |
if (ExpressionUtils.isPhraseEmpty(expression)) {
|
|
175 |
this.setFeatureAttributeEmulator((FeatureAttributeEmulator) null);
|
|
177 | 176 |
return this; |
178 |
}
|
|
177 |
} |
|
179 | 178 |
FeatureAttributeEmulatorExpression emulator = DALLocator.getDataManager().createFeatureAttributeEmulatorExpression( |
180 | 179 |
this.getFeatureType(), |
181 | 180 |
expression |
... | ... | |
185 | 184 |
|
186 | 185 |
@Override |
187 | 186 |
public EditableFeatureAttributeDescriptor setFeatureAttributeEmulator(String expression) { |
188 |
if( StringUtils.isBlank(expression) ) {
|
|
189 |
this.setFeatureAttributeEmulator((FeatureAttributeEmulator)null); |
|
187 |
if (StringUtils.isBlank(expression)) {
|
|
188 |
this.setFeatureAttributeEmulator((FeatureAttributeEmulator) null);
|
|
190 | 189 |
return this; |
191 |
}
|
|
190 |
} |
|
192 | 191 |
return this.setFeatureAttributeEmulator(ExpressionUtils.createExpression(expression)); |
193 | 192 |
} |
194 |
|
|
193 |
|
|
195 | 194 |
@Override |
196 | 195 |
public EditableFeatureAttributeDescriptor setGeometryType(int type) { |
197 | 196 |
this.geometryType = type; |
198 |
if( this.geometrySubType == Geometry.SUBTYPES.UNKNOWN ) {
|
|
197 |
if (this.geometrySubType == Geometry.SUBTYPES.UNKNOWN) {
|
|
199 | 198 |
this.geometrySubType = Geometry.SUBTYPES.GEOM2D; |
200 | 199 |
} |
201 | 200 |
this.geomType = null; |
... | ... | |
209 | 208 |
} |
210 | 209 |
|
211 | 210 |
public EditableFeatureAttributeDescriptor setGeometryType( |
212 |
GeometryType geometryType) { |
|
211 |
GeometryType geometryType) {
|
|
213 | 212 |
updateStrongChanges(this.geomType, geometryType); |
214 | 213 |
this.geomType = geometryType; |
215 | 214 |
this.geometryType = this.geomType.getType(); |
... | ... | |
219 | 218 |
|
220 | 219 |
@Override |
221 | 220 |
public EditableFeatureAttributeDescriptor setGeometryType(String geometryType) { |
222 |
if( StringUtils.isBlank(geometryType) ) {
|
|
221 |
if (StringUtils.isBlank(geometryType)) {
|
|
223 | 222 |
throw new IllegalArgumentException("Invalid geometry type (null)"); |
224 | 223 |
} |
225 | 224 |
String separators = ":/-!;#@"; |
226 | 225 |
Character sep = null; |
227 | 226 |
for (char ch : separators.toCharArray()) { |
228 |
if( geometryType.indexOf(ch)>=0 ) {
|
|
227 |
if (geometryType.indexOf(ch) >= 0) {
|
|
229 | 228 |
sep = ch; |
230 | 229 |
break; |
231 | 230 |
} |
232 | 231 |
} |
233 |
if( sep == null ) {
|
|
234 |
throw new IllegalArgumentException("Invalid geometry type ("+geometryType+") can't find separator, format can be GEOMETRYTYPE["+separators+"]GEOMETRYSUBTYPE");
|
|
232 |
if (sep == null) {
|
|
233 |
throw new IllegalArgumentException("Invalid geometry type (" + geometryType + ") can't find separator, format can be GEOMETRYTYPE[" + separators + "]GEOMETRYSUBTYPE");
|
|
235 | 234 |
} |
236 |
String[] xx = geometryType.split("["+sep+"]");
|
|
235 |
String[] xx = geometryType.split("[" + sep + "]");
|
|
237 | 236 |
int theGeomType = GeometryUtils.getGeometryType(xx[0]); |
238 | 237 |
int theGeomSubtype = GeometryUtils.getGeometrySubtype(xx[1]); |
239 | 238 |
this.setGeometryType(theGeomType, theGeomSubtype); |
240 | 239 |
return this; |
241 | 240 |
} |
242 |
|
|
241 |
|
|
243 | 242 |
@Override |
244 | 243 |
public EditableFeatureAttributeDescriptor setGeometryType(int type, int subType) { |
245 | 244 |
this.geometryType = type; |
... | ... | |
249 | 248 |
} |
250 | 249 |
|
251 | 250 |
public EditableFeatureAttributeDescriptor setIsPrimaryKey( |
252 |
boolean isPrimaryKey) { |
|
251 |
boolean isPrimaryKey) {
|
|
253 | 252 |
updateStrongChanges(this.primaryKey, primaryKey); |
254 | 253 |
this.primaryKey = isPrimaryKey; |
255 | 254 |
return this; |
... | ... | |
262 | 261 |
} |
263 | 262 |
|
264 | 263 |
public EditableFeatureAttributeDescriptor setMaximumOccurrences( |
265 |
int maximumOccurrences) { |
|
264 |
int maximumOccurrences) {
|
|
266 | 265 |
updateStrongChanges(this.maximumOccurrences, maximumOccurrences); |
267 | 266 |
this.maximumOccurrences = maximumOccurrences; |
268 | 267 |
return this; |
269 | 268 |
} |
270 | 269 |
|
271 | 270 |
public EditableFeatureAttributeDescriptor setMinimumOccurrences( |
272 |
int minimumOccurrences) { |
|
271 |
int minimumOccurrences) {
|
|
273 | 272 |
updateStrongChanges(this.minimumOccurrences, minimumOccurrences); |
274 | 273 |
this.minimumOccurrences = minimumOccurrences; |
275 | 274 |
return this; |
... | ... | |
277 | 276 |
|
278 | 277 |
@Override |
279 | 278 |
public EditableFeatureAttributeDescriptor setName(String name) { |
280 |
if( StringUtils.equals(this.name, name) ) {
|
|
279 |
if (StringUtils.equals(this.name, name)) {
|
|
281 | 280 |
return this; |
282 | 281 |
} |
283 | 282 |
if (originalName == null) { |
... | ... | |
292 | 291 |
} |
293 | 292 |
return this; |
294 | 293 |
} |
295 |
|
|
294 |
|
|
296 | 295 |
public String getOriginalName() { |
297 | 296 |
return originalName; |
298 | 297 |
} |
... | ... | |
328 | 327 |
|
329 | 328 |
@Override |
330 | 329 |
public EditableFeatureAttributeDescriptor setSRS(String SRS) { |
331 |
if( StringUtils.isBlank(SRS) ) {
|
|
332 |
this.setSRS((IProjection)null); |
|
330 |
if (StringUtils.isBlank(SRS)) {
|
|
331 |
this.setSRS((IProjection) null);
|
|
333 | 332 |
return this; |
334 | 333 |
} |
335 | 334 |
SRS = SRS.replace('@', ':'); |
... | ... | |
337 | 336 |
this.setSRS(proj); |
338 | 337 |
return this; |
339 | 338 |
} |
340 |
|
|
339 |
|
|
341 | 340 |
public EditableFeatureAttributeDescriptor setInterval(Interval interval) { |
342 | 341 |
updateStrongChanges(this.getInterval(), interval); |
343 | 342 |
super.setInterval(interval); |
... | ... | |
356 | 355 |
|
357 | 356 |
@Override |
358 | 357 |
public EditableFeatureAttributeDescriptor setAdditionalInfo( |
359 |
String infoName, Object value) { |
|
358 |
String infoName, Object value) {
|
|
360 | 359 |
return this.setAdditionalInfo(infoName, Objects.toString(value, "")); |
361 | 360 |
} |
362 |
|
|
361 |
|
|
363 | 362 |
public EditableFeatureAttributeDescriptor setAdditionalInfo( |
364 |
String infoName, String value) { |
|
363 |
String infoName, String value) {
|
|
365 | 364 |
if (this.additionalInfo == null) { |
366 | 365 |
this.additionalInfo = new HashMap(); |
367 | 366 |
} |
... | ... | |
371 | 370 |
|
372 | 371 |
public EditableFeatureAttributeDescriptor setIsAutomatic(boolean isAutomatic) { |
373 | 372 |
this.isAutomatic = isAutomatic; |
374 |
if( isAutomatic ) {
|
|
373 |
if (isAutomatic) {
|
|
375 | 374 |
this.setReadOnly(true); |
376 | 375 |
} |
377 | 376 |
return this; |
378 | 377 |
} |
379 |
|
|
378 |
|
|
380 | 379 |
public EditableFeatureAttributeDescriptor setIsTime(boolean isTime) { |
381 | 380 |
updateStrongChanges(this.isTime, isTime); |
382 | 381 |
this.isTime = isTime; |
... | ... | |
393 | 392 |
this.indexed = isIndexed; |
394 | 393 |
return this; |
395 | 394 |
} |
396 |
|
|
395 |
|
|
397 | 396 |
public EditableFeatureAttributeDescriptor setAllowIndexDuplicateds(boolean allowDuplicateds) { |
398 | 397 |
updateStrongChanges(this.allowIndexDuplicateds, allowDuplicateds); |
399 | 398 |
this.allowIndexDuplicateds = allowDuplicateds; |
... | ... | |
413 | 412 |
} |
414 | 413 |
|
415 | 414 |
private void updateStrongChanges(int previous, int newvalue) { |
416 |
if( isComputed() ) {
|
|
415 |
if (isComputed()) {
|
|
417 | 416 |
return; |
418 | 417 |
} |
419 |
if( previous == newvalue ) {
|
|
418 |
if (previous == newvalue) {
|
|
420 | 419 |
return; |
421 | 420 |
} |
422 | 421 |
this.hasStrongChanges = true; |
423 | 422 |
} |
424 | 423 |
|
425 | 424 |
private void updateStrongChanges(DataType previous, int newvalue) { |
426 |
if( isComputed() ) {
|
|
425 |
if (isComputed()) {
|
|
427 | 426 |
return; |
428 | 427 |
} |
429 |
if( previous!=null ) {
|
|
430 |
if( previous.getType() == newvalue ) {
|
|
428 |
if (previous != null) {
|
|
429 |
if (previous.getType() == newvalue) {
|
|
431 | 430 |
return; |
432 | 431 |
} |
433 | 432 |
} |
... | ... | |
435 | 434 |
} |
436 | 435 |
|
437 | 436 |
private void updateStrongChanges(boolean previous, boolean newvalue) { |
438 |
if( isComputed() ) {
|
|
437 |
if (isComputed()) {
|
|
439 | 438 |
return; |
440 | 439 |
} |
441 |
if( previous == newvalue ) {
|
|
440 |
if (previous == newvalue) {
|
|
442 | 441 |
return; |
443 | 442 |
} |
444 | 443 |
this.hasStrongChanges = true; |
445 | 444 |
} |
446 | 445 |
|
447 | 446 |
private void updateStrongChanges(Object previous, Object newvalue) { |
448 |
if( isComputed() ) {
|
|
447 |
if (isComputed()) {
|
|
449 | 448 |
return; |
450 | 449 |
} |
451 |
if( Objects.equals(newvalue, previous) ) {
|
|
450 |
if (Objects.equals(newvalue, previous)) {
|
|
452 | 451 |
return; |
453 | 452 |
} |
454 | 453 |
this.hasStrongChanges = true; |
... | ... | |
456 | 455 |
|
457 | 456 |
@Override |
458 | 457 |
public EditableFeatureAttributeDescriptor setLocale(Locale locale) { |
459 |
if( locale == null ) {
|
|
460 |
this.locale = Locale.ENGLISH; |
|
461 |
} else { |
|
462 |
this.locale = locale; |
|
463 |
} |
|
464 |
this.coerceContext = null; |
|
465 |
this.mathContext = null; |
|
466 |
return this; |
|
458 |
if (locale == null) {
|
|
459 |
this.locale = Locale.ENGLISH;
|
|
460 |
} else {
|
|
461 |
this.locale = locale;
|
|
462 |
}
|
|
463 |
this.coerceContext = null;
|
|
464 |
this.mathContext = null;
|
|
465 |
return this;
|
|
467 | 466 |
} |
468 | 467 |
|
469 | 468 |
public EditableFeatureAttributeDescriptor setLocale(String locale) { |
470 |
Locale l; |
|
471 |
try { |
|
472 |
String s = DataTypeUtils.toString(locale, null); |
|
473 |
if( StringUtils.isBlank(s) ) { |
|
474 |
return this.setLocale((Locale)null); |
|
469 |
Locale l; |
|
470 |
try { |
|
471 |
String s = DataTypeUtils.toString(locale, null); |
|
472 |
if (StringUtils.isBlank(s)) { |
|
473 |
return this.setLocale((Locale) null); |
|
474 |
} |
|
475 |
l = new Locale(s); |
|
476 |
return this.setLocale(l); |
|
477 |
} catch (Exception ex) { |
|
478 |
return this.setLocale((Locale) null); |
|
475 | 479 |
} |
476 |
l = new Locale(s); |
|
477 |
return this.setLocale(l); |
|
478 |
} catch(Exception ex) { |
|
479 |
return this.setLocale((Locale)null); |
|
480 |
} |
|
481 | 480 |
} |
482 |
|
|
481 |
|
|
483 | 482 |
@Override |
484 | 483 |
public EditableFeatureAttributeDescriptor setRoundMode(int roundMode) { |
485 |
switch(roundMode) {
|
|
486 |
case BigDecimal.ROUND_UP: |
|
487 |
case BigDecimal.ROUND_DOWN: |
|
488 |
case BigDecimal.ROUND_CEILING: |
|
489 |
case BigDecimal.ROUND_FLOOR: |
|
490 |
case BigDecimal.ROUND_HALF_UP: |
|
491 |
case BigDecimal.ROUND_HALF_DOWN: |
|
492 |
case BigDecimal.ROUND_HALF_EVEN: |
|
493 |
case BigDecimal.ROUND_UNNECESSARY: |
|
494 |
this.roundMode = roundMode; |
|
495 |
this.coerceContext = null; |
|
496 |
this.mathContext = null; |
|
497 |
break; |
|
498 |
default: |
|
499 |
throw new IllegalArgumentException("round mode '"+roundMode+"' not valid.");
|
|
500 |
} |
|
501 |
return this; |
|
484 |
switch (roundMode) {
|
|
485 |
case BigDecimal.ROUND_UP:
|
|
486 |
case BigDecimal.ROUND_DOWN:
|
|
487 |
case BigDecimal.ROUND_CEILING:
|
|
488 |
case BigDecimal.ROUND_FLOOR:
|
|
489 |
case BigDecimal.ROUND_HALF_UP:
|
|
490 |
case BigDecimal.ROUND_HALF_DOWN:
|
|
491 |
case BigDecimal.ROUND_HALF_EVEN:
|
|
492 |
case BigDecimal.ROUND_UNNECESSARY:
|
|
493 |
this.roundMode = roundMode;
|
|
494 |
this.coerceContext = null;
|
|
495 |
this.mathContext = null;
|
|
496 |
break;
|
|
497 |
default:
|
|
498 |
throw new IllegalArgumentException("round mode '" + roundMode + "' not valid.");
|
|
499 |
}
|
|
500 |
return this;
|
|
502 | 501 |
} |
503 | 502 |
|
504 | 503 |
@Override |
505 | 504 |
public EditableFeatureAttributeDescriptor set(String name, Object value) { |
506 |
if( StringUtils.isBlank(name)) {
|
|
505 |
if (StringUtils.isBlank(name)) {
|
|
507 | 506 |
throw new IllegalArgumentException("Name can't be empty"); |
508 | 507 |
} |
509 |
String ss;
|
|
510 |
switch(name.trim().toLowerCase()) { |
|
508 |
String ss; |
|
509 |
switch (name.trim().toLowerCase()) {
|
|
511 | 510 |
case "isavoidcachingavailablevalues": |
512 | 511 |
case "avoidcachingavailablevalues": |
513 | 512 |
case "nocachingavailablevalues": |
... | ... | |
575 | 574 |
this.setScale(DataTypeUtils.toInteger(value, 10)); |
576 | 575 |
break; |
577 | 576 |
case "roundmode": |
578 |
this.setRoundMode(DataTypeUtils.toInteger(value, BigDecimal.ROUND_UNNECESSARY)); |
|
579 |
break; |
|
577 |
this.setRoundMode(DataTypeUtils.toInteger(value, BigDecimal.ROUND_UNNECESSARY));
|
|
578 |
break;
|
|
580 | 579 |
case "locale": |
581 |
this.setLocale(DataTypeUtils.toString(value, null)); |
|
582 |
break; |
|
580 |
this.setLocale(DataTypeUtils.toString(value, null));
|
|
581 |
break;
|
|
583 | 582 |
case "order": |
584 | 583 |
this.setOrder(DataTypeUtils.toInteger(value, 0)); |
585 | 584 |
break; |
... | ... | |
597 | 596 |
case "foreingkey.label": |
598 | 597 |
this.getForeingKey().setLabelFormula(DataTypeUtils.toString(value, "")); |
599 | 598 |
break; |
599 |
case "fk_closed": |
|
600 |
case "fk_closedlist": |
|
600 | 601 |
case "fk.closedlist": |
601 | 602 |
case "foreingkey_closedlist": |
602 | 603 |
case "foreingkey.closedlist": |
... | ... | |
626 | 627 |
case "type": |
627 | 628 |
case "datatype": |
628 | 629 |
ss = DataTypeUtils.toString(value, null); |
629 |
if( !StringUtils.isBlank(ss) ) {
|
|
630 |
if (!StringUtils.isBlank(ss)) {
|
|
630 | 631 |
this.setDataType(ToolsLocator.getDataTypesManager().getType(ss)); |
631 | 632 |
} |
632 | 633 |
break; |
634 |
case "defaultValue": |
|
635 |
this.defaultValue = value; |
|
636 |
break; |
|
633 | 637 |
default: |
634 |
throw new IllegalArgumentException("Name attribute '"+name+"' not valid.");
|
|
635 |
}
|
|
638 |
throw new IllegalArgumentException("Name attribute '" + name + "' not valid.");
|
|
639 |
} |
|
636 | 640 |
return this; |
637 | 641 |
} |
638 |
|
|
642 |
|
|
639 | 643 |
private int toRelation(Object value) { |
640 |
if (value == null) { |
|
641 |
return DynField.RELATION_TYPE_NONE; |
|
642 |
} |
|
643 |
Integer x = (Integer) DataTypeUtils.coerce(DataTypes.INT,value, null); |
|
644 |
if (x != null) { |
|
645 |
return x; |
|
646 |
} |
|
647 |
try { |
|
648 |
String s = value.toString().toUpperCase(); |
|
649 |
switch (s) { |
|
650 |
case "NONE": |
|
651 |
default: |
|
644 |
if (value == null) { |
|
652 | 645 |
return DynField.RELATION_TYPE_NONE; |
653 |
case "IDENTITY": |
|
654 |
return DynField.RELATION_TYPE_IDENTITY; |
|
655 |
case "COLLABORATION": |
|
656 |
return DynField.RELATION_TYPE_COLLABORATION; |
|
657 |
case "COMPOSITION": |
|
658 |
return DynField.RELATION_TYPE_COMPOSITION; |
|
659 |
case "AGGREGATE": |
|
660 |
return DynField.RELATION_TYPE_AGGREGATE; |
|
661 | 646 |
} |
662 |
} catch(Exception ex) { |
|
663 |
return DynField.RELATION_TYPE_NONE; |
|
664 |
} |
|
647 |
Integer x = (Integer) DataTypeUtils.coerce(DataTypes.INT, value, null); |
|
648 |
if (x != null) { |
|
649 |
return x; |
|
650 |
} |
|
651 |
try { |
|
652 |
String s = value.toString().toUpperCase(); |
|
653 |
switch (s) { |
|
654 |
case "NONE": |
|
655 |
default: |
|
656 |
return DynField.RELATION_TYPE_NONE; |
|
657 |
case "IDENTITY": |
|
658 |
return DynField.RELATION_TYPE_IDENTITY; |
|
659 |
case "COLLABORATION": |
|
660 |
return DynField.RELATION_TYPE_COLLABORATION; |
|
661 |
case "COMPOSITION": |
|
662 |
return DynField.RELATION_TYPE_COMPOSITION; |
|
663 |
case "AGGREGATE": |
|
664 |
return DynField.RELATION_TYPE_AGGREGATE; |
|
665 |
} |
|
666 |
} catch (Exception ex) { |
|
667 |
return DynField.RELATION_TYPE_NONE; |
|
668 |
} |
|
665 | 669 |
} |
666 | 670 |
|
667 |
@Override |
|
668 |
public EditableFeatureAttributeDescriptor setDisplaySize(int size) { |
|
669 |
this.displaySize = size; |
|
670 |
return this; |
|
671 |
} |
|
672 |
|
|
671 |
@Override |
|
672 |
public EditableFeatureAttributeDescriptor setDisplaySize(int size) { |
|
673 |
this.displaySize = size; |
|
674 |
return this; |
|
675 |
} |
|
676 |
|
|
677 |
@Override |
|
678 |
public EditableFeatureAttributeDescriptor setAvailableValuesFilter(Expression filter) { |
|
679 |
super.setAvailableValuesFilter(filter); |
|
680 |
return this; |
|
681 |
} |
|
682 |
|
|
673 | 683 |
private static class TheJsonSerializer implements JsonManager.JsonSerializer { |
674 |
|
|
675 |
public TheJsonSerializer() {
|
|
684 |
|
|
685 |
public TheJsonSerializer() { |
|
676 | 686 |
} |
677 | 687 |
|
678 | 688 |
@Override |
... | ... | |
689 | 699 |
|
690 | 700 |
@Override |
691 | 701 |
public JsonObjectBuilder toJsonBuilder(Object value) { |
692 |
return ((SupportToJson)value).toJsonBuilder(); |
|
702 |
return ((SupportToJson) value).toJsonBuilder();
|
|
693 | 703 |
} |
694 |
|
|
704 |
|
|
695 | 705 |
} |
696 |
|
|
706 |
|
|
697 | 707 |
@Override |
698 | 708 |
public EditableFeatureAttributeDescriptor setForeingkey( |
699 | 709 |
boolean isForeingkey, |
... | ... | |
701 | 711 |
String tableName, |
702 | 712 |
String codeName, |
703 | 713 |
String labelFormula |
704 |
) {
|
|
705 |
if( isForeingkey ) {
|
|
714 |
) { |
|
715 |
if (isForeingkey) {
|
|
706 | 716 |
EditableForeingKey fk = this.getForeingKey(); |
707 | 717 |
fk.setForeingKey(isForeingkey); |
708 | 718 |
fk.setClosedList(isClosedList); |
... | ... | |
711 | 721 |
fk.setLabelFormula(labelFormula); |
712 | 722 |
} else { |
713 | 723 |
this.foreingKey = null; |
714 |
}
|
|
724 |
} |
|
715 | 725 |
return this; |
716 | 726 |
} |
717 | 727 |
|
... | ... | |
724 | 734 |
public static void selfRegister() { |
725 | 735 |
Json.registerSerializer(new TheJsonSerializer()); |
726 | 736 |
} |
727 |
|
|
737 |
|
|
728 | 738 |
} |
Also available in: Unified diff