Example usage for org.springframework.data.mapping PersistentProperty getName

List of usage examples for org.springframework.data.mapping PersistentProperty getName

Introduction

In this page you can find the example usage for org.springframework.data.mapping PersistentProperty getName.

Prototype

String getName();

Source Link

Document

The name of the property

Usage

From source file:org.lightadmin.core.view.tags.form.DomainTypeElementsTag.java

@Override
public void doTag() throws JspException, IOException {

    DomainTypeBasicConfiguration domainTypeConfiguration = configuration.forDomainType(domainType);
    Assert.notNull(domainTypeConfiguration, "<domainTypeConfiguration> not found for association");

    // TODO: Implement configurable ordering
    List allElements = domainTypeConfiguration.getRepository().findAll();
    allElements = sortByNaturalOrder(allElements, domainTypeConfiguration);

    PersistentProperty idAttribute = domainTypeConfiguration.getPersistentEntity().getIdProperty();
    EntityNameExtractor<Object> nameExtractor = domainTypeConfiguration.getEntityConfiguration()
            .getNameExtractor();//from  w  ww.j a  v  a 2  s  .  co  m
    JspContext jspContext = getJspContext();
    JspFragment tagBody = getJspBody();
    for (Object element : allElements) {
        BeanWrapper beanWrapper = new DirectFieldAccessFallbackBeanWrapper(element);

        jspContext.setAttribute(idVar, beanWrapper.getPropertyValue(idAttribute.getName()));
        jspContext.setAttribute(stringRepresentationVar,
                exceptionAwareNameExtractor(nameExtractor, domainTypeConfiguration).apply(element));
        tagBody.invoke(null);
    }
}

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.  j a v  a2 s .  c  o  m

    if (persistentProperty.isCollectionLike()) {
        return associatedPersistentEntities(association, instance);
    }

    Object associationValue = beanWrapper(instance).getPropertyValue(persistentProperty.getName());

    return associatedPersistentEntity(persistentProperty, associationValue);
}