Bug #7370
TypeFactory.convertTypeFromType does not use xmlValue comparisons for Enum conversions
0%
Description
DataONE enumeration elements are defined by the schema, and are the "canonical" representations. But, due to Java Enum convention of all-capping constants and how our classes are built, the xmlValue is only accessible via the xmlValue() method, which is not a standard method for Enums. This requires the convertTypeFromType method to add class-specific logic for comparing using the xmlValue.
For V2, we can get away with a "equalsIgnoreCase", because the only Enum that would undergo conversion is the v1.Event class. However, that would not work for the v1.Permission class, where CHANGE_PERMISSION constant's xmlValue is "changePermission".
A couple solution options:
1. create an xmlEnum interface that defines the xmlValue method that all DataONE Enum classes extend, and convert can leverage
2. special-case handle all of the DataONE Enums in the conversion method
3. override the toString method of DataONE Enums to return the xmlValue.
Related issues
History
#1 Updated by Rob Nahf over 9 years ago
- Related to Bug #7363: CN.getLogRecords returns 0 result added