List of usage examples for org.springframework.data.mapping PersistentProperty getOwner
PersistentEntity<?, P> getOwner();
From source file:org.lightadmin.core.web.support.DynamicRepositoryEntityLinks.java
public Link linkForFilePropertyLink(Object instance, PersistentProperty persistentProperty) { PersistentEntity persistentEntity = persistentProperty.getOwner(); Serializable id = idValue(instance, persistentEntity); return delegate.linkForSingleResource(persistentEntity.getType(), id).slash(persistentProperty.getName()) .slash("file").withSelfRel(); }
From source file:org.lightadmin.core.storage.FileManipulationStrategyFactory.java
public FileManipulationStrategy createForFileProperty(PersistentProperty persistentProperty) { PersistentEntity persistentEntity = persistentProperty.getOwner(); if (isOfBinaryFileType(persistentProperty)) { return createBinaryFileManipulationStrategy(); }// w w w .j a va 2 s .c o m if (isOfFileReferenceType(persistentProperty)) { return createReferenceFileManipulationStrategy(persistentEntity); } return NOOP_FILE_MANIPULATION_STRATEGY; }
From source file:org.lightadmin.core.web.support.DynamicPersistentEntityResourceProcessor.java
private Object associationPropertyValue(Association association, Object instance) { PersistentProperty persistentProperty = association.getInverse(); PersistentEntity persistentEntity = persistentProperty.getOwner(); if (persistentProperty.isMap()) { return null; }/*from w w w .jav a 2 s. c om*/ if (persistentProperty.isCollectionLike()) { return associatedPersistentEntities(association, instance); } Object associationValue = beanWrapper(instance).getPropertyValue(persistentProperty.getName()); return associatedPersistentEntity(persistentProperty, associationValue); }
From source file:org.springframework.data.rest.webmvc.alps.RootResourceInformationToAlpsDescriptorConverter.java
private List<Descriptor> buildPropertyDescriptors(final Class<?> type, String baseRel) { final PersistentEntity<?, ?> entity = persistentEntities.getPersistentEntity(type); final List<Descriptor> propertyDescriptors = new ArrayList<Descriptor>(); final JacksonMetadata jackson = new JacksonMetadata(mapper, type); final ResourceMetadata metadata = associations.getMetadataFor(entity.getType()); entity.doWithProperties(new SimplePropertyHandler() { @Override// w ww. j a va 2s. c o m public void doWithPersistentProperty(PersistentProperty<?> property) { BeanPropertyDefinition propertyDefinition = jackson.getDefinitionFor(property); ResourceMapping propertyMapping = metadata.getMappingFor(property); if (propertyDefinition != null) { if (property.isIdProperty() && !configuration.isIdExposedFor(property.getOwner().getType())) { return; } propertyDescriptors.add(// descriptor(). // type(Type.SEMANTIC).// name(propertyDefinition.getName()).// doc(getDocFor(propertyMapping.getDescription(), property)).// build()); } } }); entity.doWithAssociations(new SimpleAssociationHandler() { @Override public void doWithAssociation(Association<? extends PersistentProperty<?>> association) { PersistentProperty<?> property = association.getInverse(); if (!jackson.isExported(property) || !associations.isLinkableAssociation(property)) { return; } ResourceMapping mapping = metadata.getMappingFor(property); DescriptorBuilder builder = descriptor().// name(mapping.getRel()).doc(getDocFor(mapping.getDescription())); ResourceMetadata targetTypeMetadata = associations.getMetadataFor(property.getActualType()); String href = ProfileController.getPath(configuration, targetTypeMetadata) + "#" + getRepresentationDescriptorId(targetTypeMetadata); Link link = new Link(href).withSelfRel(); builder.// type(Type.SAFE).// rt(link.getHref()); propertyDescriptors.add(builder.build()); } }); return propertyDescriptors; }