Package org.codehaus.groovy.grails.commons

Examples of org.codehaus.groovy.grails.commons.GrailsDomainClass


        viewNameParts = splitViewName(viewName);
    }

    View v = scaffoldedViews.get(viewName);
        if (v == null) {
      GrailsDomainClass domainClass = scaffoldedDomains.get(viewNameParts[0]);
      if (domainClass != null) {
        String viewCode = null;
        try {
          viewCode = generateViewSource(viewNameParts[1], domainClass);
        }
View Full Code Here


     * @param application the GrailsApplication
     * @return the Compass aliases for the hierarchy
     */
    public static String[] getPolyMappingAliases(Compass compass, Class clazz, GrailsApplication application) {
        List grailsDomainClasses = Arrays.asList(application.getArtefacts(DomainClassArtefactHandler.TYPE));
        GrailsDomainClass grailsDomainClass = GrailsDomainClassUtils.getGrailsDomainClass(clazz, grailsDomainClasses);
        Collection clazzes = new HashSet(GrailsDomainClassUtils.getClazzes(grailsDomainClass.getSubClasses()));
        clazzes.add(clazz);
        return CompassMappingUtils.getMappingAliases(compass, clazzes);
    }
View Full Code Here

        return domainClassPropertyMappingFactory.getGrailsDomainClassPropertyMapping(property, searchableClasses);
    }

    protected List getInheritedPropertyMappings(GrailsDomainClass grailsDomainClass, Collection searchableGrailsDomainClasses, List excludedProperties) {
        List parentMappedProperties = new ArrayList();
        GrailsDomainClass superClass = GrailsDomainClassUtils.getSuperClass(grailsDomainClass, searchableGrailsDomainClasses);
        while (superClass != null) {
            List parentClassPropertyMappings = parent.getCompassClassPropertyMappings(superClass, searchableGrailsDomainClasses, SearchableUtils.getSearchablePropertyValue(superClass), excludedProperties);
            SearchableGrailsDomainClassCompassMappingUtils.mergePropertyMappings(parentMappedProperties, parentClassPropertyMappings);
            superClass = GrailsDomainClassUtils.getSuperClass(superClass, searchableGrailsDomainClasses);
        }
View Full Code Here

        else {
            Class clazz = (Class) options.get("class");
            setAliases(compass, clazz, compassQuery, grailsApplication);

            List grailsDomainClasses = Arrays.asList(grailsApplication.getArtefacts(DomainClassArtefactHandler.TYPE));
            GrailsDomainClass grailsDomainClass = GrailsDomainClassUtils.getGrailsDomainClass(clazz, grailsDomainClasses);
            Set subClasses = grailsDomainClass.getSubClasses();
            setPolyClassFilter(this, compassSession, compassQuery, clazz, subClasses);
        }

        return compassQuery;
    }
View Full Code Here

                    Set aliases = new HashSet();
                    Class clazz = propertyMapping.getPropertyType();
                    aliases.add(((CompassClassMapping) mappingByClass.get(clazz)).getAlias());
                    GrailsDomainClassProperty domainClassProperty = GrailsDomainClassUtils.getGrailsDomainClassProperty(grailsDomainClasses, mappedClass, propertyMapping.getPropertyName());

                    GrailsDomainClass dc = domainClassProperty.getReferencedDomainClass();
                    if (dc == null) {
                        Class elementClass = SearchableUtils.getElementClass(domainClassProperty);
                        dc = GrailsDomainClassUtils.getGrailsDomainClass(elementClass, grailsDomainClasses);

                        if (dc == null) {
                            LOG.warn("Cannot find domain class for property '" + domainClassProperty.getName() +
                                    "' of class '" + domainClassProperty.getDomainClass().getFullName());
                            continue;
                        }
                    }
                    Collection clazzes = GrailsDomainClassUtils.getClazzes(dc.getSubClasses());
                    for (Iterator citer = clazzes.iterator(); citer.hasNext(); ) {
                        CompassClassMapping mapping = (CompassClassMapping) mappingByClass.get(citer.next());
                        if (mapping != null) {
                            aliases.add(mapping.getAlias());
                        }
View Full Code Here

     * @param grailsDomainClasses all GrailsDomainClasses
     * @return true if the given class is an embedded property of another class
     */
    public static boolean isEmbeddedPropertyOfOtherDomainClass(GrailsDomainClass grailsDomainClass, Collection grailsDomainClasses) {
        for (Iterator iter = grailsDomainClasses.iterator(); iter.hasNext(); ) {
            GrailsDomainClass other = (GrailsDomainClass) iter.next();
            if (grailsDomainClass == other) {
                continue;
            }
            GrailsDomainClassProperty[] domainClassProperties = other.getProperties();
            for (int i = 0; i < domainClassProperties.length; i++) {
                GrailsDomainClass referencedDomainClass = domainClassProperties[i].getReferencedDomainClass();
                if (referencedDomainClass != null && referencedDomainClass == grailsDomainClass && domainClassProperties[i].isEmbedded()) {
                    return true;
                }
            }
        }
View Full Code Here

     */
    public static Collection getGrailsDomainClasses(GrailsApplication application) {
        Assert.notNull(application, "GrailsApplication cannot be null");
        Set domainClasses = new HashSet();
        for (int i = 0, max = application.getArtefacts(DomainClassArtefactHandler.TYPE).length; i < max; i++) {
            GrailsDomainClass grailsDomainClass = (GrailsDomainClass) application.getArtefacts(DomainClassArtefactHandler.TYPE)[i];
            domainClasses.add(grailsDomainClass);
        }
        return domainClasses;
    }
View Full Code Here

        Object instance = null;
        Collection domainClasses = SearchableUtils.getGrailsDomainClasses(grailsApplication);
        for (Iterator iter = argv.iterator(); iter.hasNext(); ) {
            Object obj = iter.next();
            for (Iterator di = domainClasses.iterator(); di.hasNext(); ) {
                GrailsDomainClass gdc = (GrailsDomainClass) di.next();
                if (obj.getClass().equals(gdc.getClazz())) {
                    instance = obj;
                    break;
                }
            }
        }
View Full Code Here

     * @return null if the given class has no parent or the parent is not in the collection
     */
    public static GrailsDomainClass getSuperClass(GrailsDomainClass grailsDomainClass, Collection grailsDomainClasses) {
        Set candidates = new HashSet();
        for (Iterator iter = grailsDomainClasses.iterator(); iter.hasNext(); ) {
            GrailsDomainClass gdc = (GrailsDomainClass) iter.next();
            if (gdc.getSubClasses().contains(grailsDomainClass)) {
                candidates.add(gdc);
            }
        }
        if (candidates.isEmpty()) {
            return null;
        }
        while (candidates.size() > 1) {
            Set copy = new HashSet(candidates);
            for (Iterator iter = copy.iterator(); iter.hasNext(); ) {
                GrailsDomainClass supsup = (GrailsDomainClass) iter.next();
                boolean remove = false;
                for (Iterator iter2 = candidates.iterator(); iter2.hasNext(); ) {
                    GrailsDomainClass sup = (GrailsDomainClass) iter2.next();
                    if (supsup.getSubClasses().contains(sup)) {
                        remove = true;
                        break;
                    }
                }
View Full Code Here

     * @return
     */
    public static Collection getSuperClasses(GrailsDomainClass grailsDomainClass, Collection grailsDomainClasses) {
        Set superClasses = new HashSet();
        do {
            GrailsDomainClass superClass = getSuperClass(grailsDomainClass, grailsDomainClasses);
            if (superClass != null) {
                superClasses.add(superClass);
            }
            grailsDomainClass = superClass;
        } while (grailsDomainClass != null);
View Full Code Here

TOP

Related Classes of org.codehaus.groovy.grails.commons.GrailsDomainClass

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.