List of usage examples for org.springframework.data.mapping PersistentProperty getName
String getName();
From source file:org.lightadmin.core.storage.strategy.file.ReferenceFilePathResolver.java
private Object getPropertyValue(Object entity, PersistentProperty persistentProperty) { BeanWrapper beanWrapper = new DirectFieldAccessFallbackBeanWrapper(entity); return beanWrapper.getPropertyValue(persistentProperty.getName()); }
From source file:org.lightadmin.core.web.json.JsonConfigurationMetadata.java
public JsonConfigurationMetadata addPersistentProperty(PersistentProperty persistentProperty) { String persistentPropertyName = persistentProperty.getName(); addProperty(persistentPropertyName, newProperty(persistentProperty, persistentPropertyName)); return this; }
From source file:org.lightadmin.core.web.json.JsonConfigurationMetadata.java
public JsonConfigurationMetadata addAssociationProperty(Association association, Link restTemplateLink) { PersistentProperty persistentProperty = association.getInverse(); addProperty(persistentProperty.getName(), newAssociationProperty(persistentProperty, persistentProperty.getName(), restTemplateLink)); return this; }
From source file:org.lightadmin.core.web.support.FileResourceLoader.java
public void downloadFile(Object entity, PersistentProperty<?> persistentProperty, HttpServletResponse response) throws IOException { final long size = fileResourceStorage.copy(entity, persistentProperty, response.getOutputStream()); final String eTag = eTag(entity.getClass(), persistentProperty.getName(), size); addImageResourceHeaders(response, octetStreamResponseHeader(APPLICATION_OCTET_STREAM, size, eTag)); }
From source file:org.lightadmin.core.config.domain.unit.processor.EmptyConfigurationUnitPostProcessor.java
private void addField(PersistentProperty<?> property, FieldSetConfigurationUnitBuilder fieldSetConfigurationUnitBuilder) { if (isSupportedAttributeType(PersistentPropertyType.forPersistentProperty(property))) { fieldSetConfigurationUnitBuilder.field(property.getName()).caption(capitalize(property.getName())); }/*from w w w . j a va2 s . com*/ }
From source file:org.lightadmin.core.web.json.JsonConfigurationMetadata.java
public JsonConfigurationMetadata addAssociationProperty(Association association, Link restTemplateLink, DomainConfigurationUnitType unitType) { PersistentProperty persistentProperty = association.getInverse(); String persistentPropertyName = persistentProperty.getName(); addDynamicProperty(persistentPropertyName, newAssociationProperty(persistentProperty, persistentPropertyName, restTemplateLink), unitType); return this; }
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.web.json.JsonConfigurationMetadata.java
public JsonConfigurationMetadata addPersistentProperty(PersistentFieldMetadata persistentField, DomainConfigurationUnitType unitType) { PersistentProperty persistentProperty = persistentField.getPersistentProperty(); String persistentPropertyName = persistentProperty.getName(); String persistentPropertyTitle = persistentField.getName(); addDynamicProperty(persistentPropertyName, newProperty(persistentProperty, persistentPropertyTitle), unitType);//ww w . j a va 2 s. co m return this; }
From source file:org.lightadmin.core.web.json.JsonConfigurationMetadata.java
public JsonConfigurationMetadata addPersistentProperty(PersistentProperty persistentProperty, DomainConfigurationUnitType unitType) { String persistentPropertyName = persistentProperty.getName(); addDynamicProperty(persistentPropertyName, newProperty(persistentProperty, persistentPropertyName), unitType);/*from w w w . ja v a2 s . co m*/ return this; }
From source file:org.lightadmin.core.persistence.support.DynamicDomainObjectMerger.java
/** * Merges the given target object into the source one. * * @param from can be {@literal null}. * @param target can be {@literal null}. * @param nullPolicy how to handle {@literal null} values in the source object. *//*from w w w .jav a 2 s .c om*/ @Override public void merge(final Object from, final Object target, final NullHandlingPolicy nullPolicy) { if (from == null || target == null) { return; } final BeanWrapper fromWrapper = beanWrapper(from); final BeanWrapper targetWrapper = beanWrapper(target); final DomainTypeAdministrationConfiguration domainTypeAdministrationConfiguration = configuration .forManagedDomainType(target.getClass()); final PersistentEntity<?, ?> entity = domainTypeAdministrationConfiguration.getPersistentEntity(); entity.doWithProperties(new SimplePropertyHandler() { @Override public void doWithPersistentProperty(PersistentProperty<?> persistentProperty) { Object sourceValue = fromWrapper.getPropertyValue(persistentProperty.getName()); Object targetValue = targetWrapper.getPropertyValue(persistentProperty.getName()); if (entity.isIdProperty(persistentProperty)) { return; } if (nullSafeEquals(sourceValue, targetValue)) { return; } if (propertyIsHiddenInFormView(persistentProperty, domainTypeAdministrationConfiguration)) { return; } if (nullPolicy == APPLY_NULLS || sourceValue != null) { targetWrapper.setPropertyValue(persistentProperty.getName(), sourceValue); } } }); entity.doWithAssociations(new SimpleAssociationHandler() { @Override @SuppressWarnings("unchecked") public void doWithAssociation(Association<? extends PersistentProperty<?>> association) { PersistentProperty<?> persistentProperty = association.getInverse(); Object fromValue = fromWrapper.getPropertyValue(persistentProperty.getName()); Object targetValue = targetWrapper.getPropertyValue(persistentProperty.getName()); if (propertyIsHiddenInFormView(persistentProperty, domainTypeAdministrationConfiguration)) { return; } if ((fromValue == null && nullPolicy == APPLY_NULLS)) { targetWrapper.setPropertyValue(persistentProperty.getName(), fromValue); } if (persistentProperty.isCollectionLike()) { Collection<Object> sourceCollection = (Collection) fromValue; Collection<Object> targetCollection = (Collection) targetValue; Collection<Object> candidatesForAddition = candidatesForAddition(sourceCollection, targetCollection, persistentProperty); Collection<Object> candidatesForRemoval = candidatesForRemoval(sourceCollection, targetCollection, persistentProperty); removeReferencedItems(targetCollection, candidatesForRemoval); addReferencedItems(targetCollection, candidatesForAddition); return; } if (!nullSafeEquals(fromValue, targetWrapper.getPropertyValue(persistentProperty.getName()))) { targetWrapper.setPropertyValue(persistentProperty.getName(), fromValue); } } }); }