public class OxmModelValidator {
public enum Metadata {
- NODE_TYPE("aai-node-type"),
- URI("aai-uri"),
- CREATED_TS("aai-created-ts"),
- UPDATED_TS("aai-last-mod-ts"),
- SOT("source-of-truth"),
+ NODE_TYPE("aai-node-type"),
+ URI("aai-uri"),
+ CREATED_TS("aai-created-ts"),
+ UPDATED_TS("aai-last-mod-ts"),
+ SOT("source-of-truth"),
LAST_MOD_SOT("last-mod-source-of-truth");
private final String propName;
}
final DynamicType modelObjectType = jaxbContext.getDynamicType(
CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, type)));
+ final DynamicType reservedObjectType = jaxbContext.getDynamicType("ReservedPropNames");
for (String key : filter.keySet()) {
String keyJavaName = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, key);
- if (modelObjectType.getDescriptor().getMappingForAttributeName(keyJavaName) != null) {
+ DatabaseMapping mapping = modelObjectType.getDescriptor().getMappingForAttributeName(keyJavaName);
+
+ // Try both the model for the specified type and the reserved properties for our key
+ if (mapping == null) {
+ mapping = reservedObjectType.getDescriptor().getMappingForAttributeName(keyJavaName);
+ }
+ if (mapping != null) {
try {
- DatabaseMapping mapping = modelObjectType.getDescriptor().getMappingForAttributeName(keyJavaName);
Object value = CrudServiceUtil.validateFieldType(filter.get(key), mapping.getField().getType());
result.put(key, value);
} catch (Exception ex) {
vertex.getProperties().get(Metadata.NODE_TYPE.propertyName()) != null
? vertex.getProperties().get(Metadata.NODE_TYPE.propertyName()).toString() : vertex.getType()));
final DynamicType modelObjectType = jaxbContext.getDynamicType(modelObjectClass);
+ final DynamicType reservedObjectType = jaxbContext.getDynamicType("ReservedPropNames");
for (String key : vertex.getProperties().keySet()) {
DatabaseField field = getDatabaseField(key, modelObjectType);
+ if (field == null) {
+ field = getDatabaseField(key, reservedObjectType);
+ }
if (field != null) {
- if (!Metadata.isProperty(key)) {
- modelVertexBuilder.property(key, vertex.getProperties().get(key));
- }
+ modelVertexBuilder.property(key, vertex.getProperties().get(key));
}
}