Changeset 538 for trunk/grails-app/domain
- Timestamp:
- Jun 7, 2010, 4:39:11 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/studycapturing/TemplateEntity.groovy
r536 r538 21 21 Map templateDoubleFields = [:] 22 22 Map templateDateFields = [:] 23 Map templateRelTimeFields = [:] // Contains relative times in seconds 23 24 25 // N.B. If you try to set Long.MIN_VALUE for a reltime field, an error will occur 26 // However, this will never occur in practice: this value represents 3 bilion centuries 27 Map templateRelTimeFields = [:] // Contains relative times in seconds 24 28 Map templateFileFields = [:] // Contains filenames 25 29 Map templateTermFields = [:] … … 209 213 def error = false 210 214 fields.each { key, value -> 211 if (value && value.class != long) { 215 if( value && value == Long.MIN_VALUE ) { 216 error = true 217 errors.rejectValue( 218 'templateRelTimeFields', 219 'templateEntity.typeMismatch.reltime', 220 [key, value] as Object[], 221 'Value cannot be parsed for property {0}' 222 ) 223 } else if (value && value.class != long) { 212 224 try { 213 225 fields[key] = (value as long) … … 423 435 // 424 436 if (field.type == TemplateFieldType.RELTIME && value != null && value.class == String) { 425 // A string was given, attempt to transform it into a timespan 426 value = RelTime.parseRelTime(value).getValue(); 437 // A string was given, attempt to transform it into a timespan 438 // If it cannot be parsed, set the lowest possible value of Long. 439 // The validator method will raise an error 440 // 441 // N.B. If you try to set Long.MIN_VALUE itself, an error will occur 442 // However, this will never occur: this value represents 3 bilion centuries 443 try { 444 value = RelTime.parseRelTime(value).getValue(); 445 } catch( IllegalArgumentException e ) { 446 value = Long.MIN_VALUE; 447 } 427 448 } 428 449
Note: See TracChangeset
for help on using the changeset viewer.