org.codehaus.groovy.grails.commons
Class GrailsDomainConfigurationUtil

java.lang.Object
  extended by org.codehaus.groovy.grails.commons.GrailsDomainConfigurationUtil

public class GrailsDomainConfigurationUtil
extends Object

Utility methods used in configuring the Grails Hibernate integration.

Author:
Graeme Rocher

Field Summary
static String PROPERTY_NAME
           
 
Constructor Summary
GrailsDomainConfigurationUtil()
           
 
Method Summary
static void configureDomainClassRelationships(GrailsClass[] domainClasses, Map<?,?> domainMap)
          Configures the relationships between domain classes after they have been all loaded.
static Map<String,ConstrainedProperty> evaluateConstraints(Class<?> theClass)
          Evaluates the constraints closure to build the list of constraints
static Map<String,ConstrainedProperty> evaluateConstraints(Class<?> theClass, GrailsDomainClassProperty[] properties)
          Evaluates the constraints closure to build the list of constraints.
static Map<String,ConstrainedProperty> evaluateConstraints(Class<?> theClass, GrailsDomainClassProperty[] properties, Map<String,Object> defaultConstraints)
          Evaluates the constraints closure to build the list of constraints
static Map<String,ConstrainedProperty> evaluateConstraints(Object instance)
          Evaluates the constraints closure to build the list of constraints.
static Map<String,ConstrainedProperty> evaluateConstraints(Object instance, GrailsDomainClassProperty[] properties)
          Evaluates the constraints closure to build the list of constraints.
static Map<String,ConstrainedProperty> evaluateConstraints(Object instance, GrailsDomainClassProperty[] properties, Map<String,Object> defaultConstraints)
          Evaluates the constraints closure to build the list of constraints
static Serializable getAssociationIdentifier(Object target, String propertyName, GrailsDomainClass referencedDomainClass)
           
static Map<?,?> getAssociationMap(Class<?> domainClass)
          Returns the association map for the specified domain class
static Map<?,?> getMappedByMap(Class<?> domainClass)
          Retrieves the mappedBy map for the specified class.
static String getMappingFileName(String className)
          Returns the ORM framework's mapping file name for the specified class name.
static LinkedList<?> getSuperClassChain(Class<?> theClass)
           
static boolean isBasicType(Class<?> propType)
           
static boolean isBasicType(GrailsDomainClassProperty prop)
          Establish whether it's a basic type.
static boolean isNotConfigurational(PropertyDescriptor descriptor)
          Checks whether is property is configurational.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_NAME

public static final String PROPERTY_NAME
See Also:
Constant Field Values
Constructor Detail

GrailsDomainConfigurationUtil

public GrailsDomainConfigurationUtil()
Method Detail

getAssociationIdentifier

public static Serializable getAssociationIdentifier(Object target,
                                                    String propertyName,
                                                    GrailsDomainClass referencedDomainClass)

configureDomainClassRelationships

public static void configureDomainClassRelationships(GrailsClass[] domainClasses,
                                                     Map<?,?> domainMap)
Configures the relationships between domain classes after they have been all loaded.

Parameters:
domainClasses - The domain classes to configure relationships for
domainMap - The domain class map

getMappingFileName

public static String getMappingFileName(String className)
Returns the ORM framework's mapping file name for the specified class name.

Parameters:
className - The class name of the mapped file
Returns:
The mapping file name

getAssociationMap

public static Map<?,?> getAssociationMap(Class<?> domainClass)
Returns the association map for the specified domain class

Parameters:
domainClass - the domain class
Returns:
The association map

getMappedByMap

public static Map<?,?> getMappedByMap(Class<?> domainClass)
Retrieves the mappedBy map for the specified class.

Parameters:
domainClass - The domain class
Returns:
The mappedBy map

isBasicType

public static boolean isBasicType(GrailsDomainClassProperty prop)
Establish whether it's a basic type.

Parameters:
prop - The domain class property
Returns:
True if it is basic

isBasicType

public static boolean isBasicType(Class<?> propType)

isNotConfigurational

public static boolean isNotConfigurational(PropertyDescriptor descriptor)
Checks whether is property is configurational.

Parameters:
descriptor - The descriptor
Returns:
True if it is configurational

evaluateConstraints

public static Map<String,ConstrainedProperty> evaluateConstraints(Object instance,
                                                                  GrailsDomainClassProperty[] properties,
                                                                  Map<String,Object> defaultConstraints)
Evaluates the constraints closure to build the list of constraints

Parameters:
instance - The instance to evaluate constraints for
properties - The properties of the instance
defaultConstraints - A map that defines the default constraints
Returns:
A Map of constraints

evaluateConstraints

public static Map<String,ConstrainedProperty> evaluateConstraints(Class<?> theClass,
                                                                  GrailsDomainClassProperty[] properties,
                                                                  Map<String,Object> defaultConstraints)
Evaluates the constraints closure to build the list of constraints

Parameters:
theClass - The domain class to evaluate constraints for
properties - The properties of the instance
defaultConstraints - A map that defines the default constraints
Returns:
A Map of constraints

evaluateConstraints

public static Map<String,ConstrainedProperty> evaluateConstraints(Object instance,
                                                                  GrailsDomainClassProperty[] properties)
Evaluates the constraints closure to build the list of constraints.

Parameters:
instance - The instance to evaluate constraints for
properties - The properties of the instance
Returns:
A Map of constraints When the bean cannot be introspected

evaluateConstraints

public static Map<String,ConstrainedProperty> evaluateConstraints(Object instance)
Evaluates the constraints closure to build the list of constraints.

Parameters:
instance - The instance to evaluate constraints for
Returns:
A Map of constraints When the bean cannot be introspected

evaluateConstraints

public static Map<String,ConstrainedProperty> evaluateConstraints(Class<?> theClass)
Evaluates the constraints closure to build the list of constraints

Parameters:
theClass - The class to evaluate constraints for
Returns:
A Map of constraints When the bean cannot be introspected

evaluateConstraints

public static Map<String,ConstrainedProperty> evaluateConstraints(Class<?> theClass,
                                                                  GrailsDomainClassProperty[] properties)
Evaluates the constraints closure to build the list of constraints.

Parameters:
theClass - The class to evaluate constraints for
Returns:
A Map of constraints When the bean cannot be introspected

getSuperClassChain

public static LinkedList<?> getSuperClassChain(Class<?> theClass)