fix: xsd:string and PRIMITVE datatypes fix#180
Conversation
| default CIMSDataType buildDataType(DataTypeDTO dto) { | ||
| URI uri; | ||
| if (dto.getType() == DataTypeDTO.Type.PRIMITIVE) { | ||
| if (dto.getPrefix().equalsIgnoreCase(XSD.getURI())) { |
There was a problem hiding this comment.
DataTypeDTO.prefix comes from URI, which splits on #.
So any datatype with a URI that uses / as separator (i.e. http://example.com/test) throws NullPointerException.
Safe guard it:
| if (dto.getPrefix().equalsIgnoreCase(XSD.getURI())) { | |
| if (XSD.getURI().equalsIgnoreCase(dto.getPrefix())) { |
| if (dto.getDataType() == null || dto.getDataType().getLabel() == null) { | ||
| return null; | ||
| } | ||
| if (dto.getDataType().getType() != DataTypeDTO.Type.PRIMITIVE) { |
There was a problem hiding this comment.
Should we also add a prefix-based check here. A PRIMITIVE with a non-XSD prefix whose label collides with a real XSD type name (e.g. label "string") gets normalized to xsd:string here.
Is that intended?
| while (typeListIterator.hasNext()) { | ||
| var dt = typeListIterator.next(); | ||
| if (dt.getURI().equalsIgnoreCase(xsdUri)) { | ||
| if (primitiveDatatypeClassLabel.equals("string") |
There was a problem hiding this comment.
This "string" special case is undocumented and untested.
Future reader has no way to know why string alone needs exact matching while very other label is case-insensitive.
Add a comment why.
Maybe add unit test for XSDDatatypeMapper covering string and String.
Summary
fixes that xsd:string was converted to xsd:String and that PRIMITIVE datatypes were converted to xsd datatypes
Related Issues
Checklist
git commit -s) for DCOTesting Notes