@SuppressWarnings("unchecked") private Document mapSchemaObject(@Nullable PersistentEntity<?, MongoPersistentProperty> entity, Document source) { Document sink = new Document(source); if (source.containsKey(REQUIRED_FIELD)) { sink.replace(REQUIRED_FIELD, mapRequiredProperties(entity, source.get(REQUIRED_FIELD, Collection.class))); } if (source.containsKey(PROPERTIES_FIELD)) { sink.replace(PROPERTIES_FIELD, mapProperties(entity, source.get(PROPERTIES_FIELD, Document.class))); } mapEnumValuesIfNecessary(sink); return sink; }
private Document mapProperty(@Nullable PersistentEntity<?, MongoPersistentProperty> entity, String sourceFieldName, Document source) { Document sink = new Document(source); if (entity != null && sink.containsKey(Type.objectType().representation())) { MongoPersistentProperty property = entity.getPersistentProperty(sourceFieldName); if (property != null && property.isEntity()) { sink = mapSchemaObject(mappingContext.getPersistentEntity(property.getActualType()), source); } } return mapEnumValuesIfNecessary(sink); }
@SuppressWarnings("unchecked") private Document mapSchemaObject(@Nullable PersistentEntity<?, MongoPersistentProperty> entity, Document source) { Document sink = new Document(source); if (source.containsKey(REQUIRED_FIELD)) { sink.replace(REQUIRED_FIELD, mapRequiredProperties(entity, source.get(REQUIRED_FIELD, Collection.class))); } if (source.containsKey(PROPERTIES_FIELD)) { sink.replace(PROPERTIES_FIELD, mapProperties(entity, source.get(PROPERTIES_FIELD, Document.class))); } mapEnumValuesIfNecessary(sink); return sink; }
private Document mapProperty(@Nullable PersistentEntity<?, MongoPersistentProperty> entity, String sourceFieldName, Document source) { Document sink = new Document(source); if (entity != null && sink.containsKey(Type.objectType().representation())) { MongoPersistentProperty property = entity.getPersistentProperty(sourceFieldName); if (property != null && property.isEntity()) { sink = mapSchemaObject(mappingContext.getPersistentEntity(property.getActualType()), source); } } return mapEnumValuesIfNecessary(sink); }