org.apache.click.extras.cayenne
Class CayenneUtils

java.lang.Object
  extended by org.apache.click.extras.cayenne.CayenneUtils

public final class CayenneUtils
extends Object

Provides Cayenne DataObject utility methods to looking up object by their primary key.

This class was derived from the Cayenne DataObjectUtils class.


Constructor Summary
CayenneUtils()
           
 
Method Summary
static void applyMetaData(Form form, Class<?> dataObjectClass)
          Applies the DataObject class validation database meta data to the form fields.
static org.apache.cayenne.ObjectId createObjectId(org.apache.cayenne.ObjectContext objectContext, Class dataObjectClass, Object pk)
          Create a new ObjectId for the given ObjectContext, data object class and primary key.
static org.apache.cayenne.DataObject getObjectForPK(org.apache.cayenne.ObjectContext objectContext, Class dataObjectClass, Object pk)
          Return the DataObject for the given context, data object class and primary key value.
static Class getPkClass(org.apache.cayenne.ObjectContext objectContext, Class dataObjectClass)
          Return the primary key class for the given DataObject class.
static String getPkName(org.apache.cayenne.ObjectContext objectContext, Class dataObjectClass)
          Return the database primary key column name for the given data object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CayenneUtils

public CayenneUtils()
Method Detail

applyMetaData

public static void applyMetaData(Form form,
                                 Class<?> dataObjectClass)
Applies the DataObject class validation database meta data to the form fields.

The field validation attributes include:

Parameters:
form - the form which fields to apply metadata to
dataObjectClass - the dataObject class which metadata to apply

createObjectId

public static org.apache.cayenne.ObjectId createObjectId(org.apache.cayenne.ObjectContext objectContext,
                                                         Class dataObjectClass,
                                                         Object pk)
Create a new ObjectId for the given ObjectContext, data object class and primary key.

Parameters:
objectContext - the Cayenne ObjectContext
dataObjectClass - the class of the Cayenne DataObject
pk - the data object primary key
Returns:
a new Cayenne ObjectId

getObjectForPK

public static org.apache.cayenne.DataObject getObjectForPK(org.apache.cayenne.ObjectContext objectContext,
                                                           Class dataObjectClass,
                                                           Object pk)
Return the DataObject for the given context, data object class and primary key value. This method will refresh the

Parameters:
objectContext - the Cayenne ObjectContext for the data object
dataObjectClass - the class of the Cayenne DataObject
pk - the primary key of the DataObject
Returns:
the resolved DataObject value for the primary key

getPkClass

public static Class getPkClass(org.apache.cayenne.ObjectContext objectContext,
                               Class dataObjectClass)
Return the primary key class for the given DataObject class.

Parameters:
objectContext - the Cayenne ObjectContext for the data object
dataObjectClass - the DataObject class to get the primary key for
Returns:
the primary key class for the given DataObject class

getPkName

public static String getPkName(org.apache.cayenne.ObjectContext objectContext,
                               Class dataObjectClass)
Return the database primary key column name for the given data object.

Parameters:
objectContext - the Cayenne ObjectContext for the data object
dataObjectClass - the class of the data object
Returns:
the primary key column name