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

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

Introduction

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

Prototype

boolean isAssociation();

Source Link

Document

Returns whether the property is an Association .

Usage

From source file:org.lightadmin.core.persistence.metamodel.PersistentPropertyType.java

public static PersistentPropertyType forPersistentProperty(PersistentProperty persistentProperty) {
    final Class<?> attrType = persistentProperty.getType();

    if (persistentProperty.isAnnotationPresent(Embedded.class)
            || persistentProperty.isAnnotationPresent(EmbeddedId.class)) {
        return PersistentPropertyType.EMBEDDED;
    }// ww w .  ja v  a 2  s  . c o  m

    if (persistentProperty.isAssociation()) {
        if (persistentProperty.isCollectionLike()) {
            return PersistentPropertyType.ASSOC_MULTI;
        }
        return PersistentPropertyType.ASSOC;
    }

    if (persistentProperty.isMap()) {
        return PersistentPropertyType.MAP;
    }

    if (ClassUtils.isAssignable(Enum.class, attrType)) {
        return ENUM;
    }

    if (forType(attrType) == STRING && persistentProperty.isAnnotationPresent(FileReference.class)) {
        return PersistentPropertyType.FILE;
    }

    if (isOfDateType(persistentProperty)) {
        return DATE;
    }

    if (isOfTimeType(persistentProperty)) {
        return TIME;
    }

    if (isOfDateTimeType(persistentProperty)) {
        return DATE_TIME;
    }

    return forType(attrType);
}

From source file:org.lightadmin.core.web.json.DomainTypeToJsonMetadataConverter.java

private void addPersistentProperty(PersistentFieldMetadata field, String unitType,
        JsonConfigurationMetadata jsonConfigurationMetadata) {
    PersistentProperty persistentProperty = field.getPersistentProperty();
    if (persistentProperty.isAssociation()) {
        jsonConfigurationMetadata.addAssociationProperty(field, associationRestLinkTemplate(persistentProperty),
                unitType.toString());//from www . j  av a  2 s  .c  o m
    } else {
        jsonConfigurationMetadata.addPersistentProperty(field, unitType.toString());
    }
}