Changeset 4632
- Timestamp:
- Nov 7, 2008, 2:46:52 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/Annotation.java
r4548 r4632 403 403 checkPermission(Permission.WRITE); 404 404 AnnotationType annotationType = getAnnotationType(); 405 if (unit == null) unit = annotationType.getDefaultUnit(); 406 UnitConverter converter = getUnitConverter(unit); 407 if (converter != null && value instanceof Number) 408 { 409 value = converter.convertToReferenceUnit(((Number)value).doubleValue()); 405 UnitConverter converter = null; 406 if (annotationType.supportUnits() && unit != null) 407 { 408 converter = getUnitConverter(unit); 409 if (converter != null && value instanceof Number) 410 { 411 value = converter.convertToReferenceUnit(((Number)value).doubleValue()); 412 } 410 413 } 411 414 annotationType.validateAnnotationValue(value); 412 if (unit != null) getData().setUnit(unit.getData()); 415 if (annotationType.supportUnits()) 416 { 417 getData().setUnit(unit == null ? annotationType.getData().getDefaultUnit() : unit.getData()); 418 } 413 419 getData().getValues().setSingleValue(Values.getDataValue(value)); 414 420 } … … 439 445 checkPermission(Permission.WRITE); 440 446 AnnotationType annotationType = getAnnotationType(); 441 if (unit == null) unit = annotationType.getDefaultUnit();442 447 int multiplicity = annotationType.getMultiplicity(); 443 448 if (multiplicity > 0 && values.size() > multiplicity) … … 445 450 throw new InvalidDataException("Too many values. Max "+multiplicity+" value(s) are allowed for this annotation type"); 446 451 } 447 UnitConverter converter = getUnitConverter(unit); 452 UnitConverter converter = null; 453 if (annotationType.supportUnits() && unit != null) 454 { 455 converter = getUnitConverter(unit); 456 } 448 457 List<Object> convertedValues = new ArrayList<Object>(values.size()); 449 458 Type valueType = getValueType(); … … 457 466 convertedValues.add(value); 458 467 } 459 if (unit != null) getData().setUnit(unit.getData()); 468 if (annotationType.supportUnits()) 469 { 470 getData().setUnit(unit == null ? annotationType.getData().getDefaultUnit() : unit.getData()); 471 } 460 472 getData().getValues().replaceValues(Values.getDataValues(convertedValues)); 461 473 }
Note: See TracChangeset
for help on using the changeset viewer.