Package org.grails.core.util

Examples of org.grails.core.util.ClassPropertyFetcher


     *
     * @param domainClass the domain class
     * @return The association map
     */
    public static Map<?, ?> getAssociationMap(Class<?> domainClass) {
        ClassPropertyFetcher cpf = ClassPropertyFetcher.forClass(domainClass);

        Map<?, ?> associationMap = cpf.getPropertyValue(GrailsDomainClassProperty.HAS_MANY, Map.class);
        if (associationMap == null) {
            associationMap = Collections.EMPTY_MAP;
        }
        return associationMap;
    }
View Full Code Here


     *
     * @param domainClass The domain class
     * @return The mappedBy map
     */
    public static Map<?, ?> getMappedByMap(Class<?> domainClass) {
        ClassPropertyFetcher cpf = ClassPropertyFetcher.forClass(domainClass);

        Map<?, ?> mappedByMap = cpf.getPropertyValue(GrailsDomainClassProperty.MAPPED_BY, Map.class);
        if (mappedByMap == null) {
            return Collections.EMPTY_MAP;
        }
        return mappedByMap;
    }
View Full Code Here

        }

        Class<?> theClass = getClazz();
        while (theClass != Object.class) {
            theClass = theClass.getSuperclass();
            ClassPropertyFetcher propertyFetcher = ClassPropertyFetcher.forClass(theClass);
            Map superRelationshipMap = propertyFetcher.getStaticPropertyValue(propertyName, Map.class);
            if (superRelationshipMap != null && !superRelationshipMap.equals(configurationMap)) {
                configurationMap.putAll(superRelationshipMap);
            }
        }
        return configurationMap;
View Full Code Here

     * @param property The property
     * @param relatedClassType The related type
     */
    @SuppressWarnings("unchecked")
    private void establishOwnerOfManyToMany(DefaultGrailsDomainClassProperty property, Class<?> relatedClassType) {
        ClassPropertyFetcher cpf = ClassPropertyFetcher.forClass(relatedClassType);
        Object relatedBelongsTo = cpf.getPropertyValue(GrailsDomainClassProperty.BELONGS_TO);
        boolean owningSide = false;
        boolean relatedOwner = isOwningSide(relatedClassType, owners);
        final Class<?> propertyClass = property.getDomainClass().getClazz();
        if (relatedBelongsTo instanceof Collection) {
            final Collection associatedOwners = (Collection)relatedBelongsTo;
View Full Code Here

    private List getTransients() {
        List allTransientProps = new ArrayList();

        List<Class<?>> allClasses = getAllDomainClassesInHierarchy();
        for (Class currentClass : allClasses) {
            ClassPropertyFetcher propertyFetcher = ClassPropertyFetcher.forClass(currentClass);
            Object transientProperty = propertyFetcher.getPropertyValue(TRANSIENT, false);
            if (transientProperty instanceof List) {
                List transientList = (List) transientProperty;
                allTransientProps.addAll(transientList);
            }
        }
View Full Code Here

    protected Object extractValue(Object domainObject, GrailsDomainClassProperty property) {
        if(domainObject instanceof GroovyObject) {
            return ((GroovyObject)domainObject).getProperty(property.getName());
        }
        else {
            ClassPropertyFetcher propertyFetcher = ClassPropertyFetcher.forClass(domainObject.getClass());
            return propertyFetcher.getPropertyValue(domainObject, property.getName());
        }
    }
View Full Code Here

            GrailsDomainClass referencedDomainClass) throws ConverterException {
        Object idValue;
        if (proxyHandler instanceof EntityProxyHandler) {
            idValue = ((EntityProxyHandler) proxyHandler).getProxyIdentifier(refObj);
            if (idValue == null) {
                ClassPropertyFetcher propertyFetcher = ClassPropertyFetcher.forClass(refObj.getClass());
                idValue = propertyFetcher.getPropertyValue(refObj, idProperty.getName());
            }
        }
        else {
            ClassPropertyFetcher propertyFetcher = ClassPropertyFetcher.forClass(refObj.getClass());
            idValue = propertyFetcher.getPropertyValue(refObj, idProperty.getName());
        }
        xml.attribute(GrailsDomainClassProperty.IDENTITY,String.valueOf(idValue));
    }
View Full Code Here

TOP

Related Classes of org.grails.core.util.ClassPropertyFetcher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.