Return-Path: Delivered-To: apmail-click-commits-archive@www.apache.org Received: (qmail 87245 invoked from network); 19 Jan 2011 22:28:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 19 Jan 2011 22:28:12 -0000 Received: (qmail 83782 invoked by uid 500); 19 Jan 2011 22:28:12 -0000 Delivered-To: apmail-click-commits-archive@click.apache.org Received: (qmail 83757 invoked by uid 500); 19 Jan 2011 22:28:11 -0000 Mailing-List: contact commits-help@click.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: click-dev@click.apache.org Delivered-To: mailing list commits@click.apache.org Received: (qmail 83748 invoked by uid 99); 19 Jan 2011 22:28:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Jan 2011 22:28:11 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Jan 2011 22:28:10 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 955AB2388A36; Wed, 19 Jan 2011 22:27:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1061031 - in /click/trunk/click: documentation/docs/roadmap-changes.html extras/src/org/apache/click/extras/cayenne/CayenneTemplate.java Date: Wed, 19 Jan 2011 22:27:50 -0000 To: commits@click.apache.org From: sabob@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110119222750.955AB2388A36@eris.apache.org> Author: sabob Date: Wed Jan 19 22:27:50 2011 New Revision: 1061031 URL: http://svn.apache.org/viewvc?rev=1061031&view=rev Log: Align CayenneTemplate generics with Cayenne's DataContext. CLK-751 Modified: click/trunk/click/documentation/docs/roadmap-changes.html click/trunk/click/extras/src/org/apache/click/extras/cayenne/CayenneTemplate.java Modified: click/trunk/click/documentation/docs/roadmap-changes.html URL: http://svn.apache.org/viewvc/click/trunk/click/documentation/docs/roadmap-changes.html?rev=1061031&r1=1061030&r2=1061031&view=diff ============================================================================== --- click/trunk/click/documentation/docs/roadmap-changes.html (original) +++ click/trunk/click/documentation/docs/roadmap-changes.html Wed Jan 19 22:27:50 2011 @@ -357,6 +357,10 @@ Fixed table headers that used incorrect [CLK-241].
  • + Fixed CayenneTemplate generics to align with Cayenne DataContext + [CLK-750]. +
  • +
  • Fixed readonly CheckList to use disabled attribute, same as Checkbox does [CLK-751].
  • Modified: click/trunk/click/extras/src/org/apache/click/extras/cayenne/CayenneTemplate.java URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/cayenne/CayenneTemplate.java?rev=1061031&r1=1061030&r2=1061031&view=diff ============================================================================== --- click/trunk/click/extras/src/org/apache/click/extras/cayenne/CayenneTemplate.java (original) +++ click/trunk/click/extras/src/org/apache/click/extras/cayenne/CayenneTemplate.java Wed Jan 19 22:27:50 2011 @@ -65,10 +65,10 @@ public class CayenneTemplate { * Instantiates new object and registers it with itself. Object class must * have a default constructor. * - * @param dataObjectClass the data object class to create and register - * @return the new registered data object + * @param persistentClass the persistent object class to create and register + * @return the new registered persistent object */ - protected DataObject newObject(Class dataObjectClass) { + protected T newObject(Class dataObjectClass) { return getDataContext().newObject(dataObjectClass); } @@ -76,11 +76,13 @@ public class CayenneTemplate { * Instantiates new object and registers it with itself. Object class must * have a default constructor. * - * @param dataObjectClass the data object class to create and register - * @return the new registered data object + * @deprecated since 2.3.0, use {@link #newObject(java.lang.Class)} instead. + * + * @param persistentClass the persistent object class to create and register + * @return the new registered persistent object */ - protected DataObject createAndRegisterNewObject(Class dataObjectClass) { - return getDataContext().newObject(dataObjectClass); + protected T createAndRegisterNewObject(Class persistentClass) { + return getDataContext().newObject(persistentClass); } /** @@ -107,26 +109,27 @@ public class CayenneTemplate { } /** - * Find the data object for the specified class, property name and property - * value, or null if no data object was found. + * Find the persistent object for the specified class, property name and property + * value, or null if no persistent object was found. * - * @param dataObjectClass the data object class to find + * @param persistentClass the persistent object class to find * @param property the name of the property * @param value the value of the property - * @return the data object for the specified class, property name and property value - * @throws RuntimeException if more than one data object was identified for the - * given property name and value + * @return the persistent object for the specified class, property name and + * property value + * @throws RuntimeException if more than one persistent object was identified + * for the given property name and value */ - protected DataObject findObject(Class dataObjectClass, String property, + protected T findObject(Class persistentClass, String property, Object value) { - List list = performQuery(dataObjectClass, property, value); + List list = performQuery(persistentClass, property, value); if (list.size() == 1) { - return (DataObject) list.get(0); + return (T) list.get(0); } else if (list.size() > 1) { - String msg = "SelectQuery for " + dataObjectClass.getName() + String msg = "SelectQuery for " + persistentClass.getName() + " where " + property + " equals " + value + " returned " + list.size() + " rows"; throw new RuntimeException(msg); @@ -174,37 +177,37 @@ public class CayenneTemplate { * class and the primary key. This method will perform a database query * and refresh the object cache. * - * @param doClass the data object class to retrieve + * @param persistentClass the persistent object class to retrieve * @param id the data object primary key * @return the data object for the given class and id */ - protected DataObject getObjectForPK(Class doClass, Object id) { - return getObjectForPK(doClass, id, true); + protected T getObjectForPK(Class persistentClass, Object id) { + return getObjectForPK(persistentClass, id, true); } /** - * Perform a query returning the data object specified by the + * Perform a query returning the persistent object specified by the * class and the primary key value. If the refresh parameter is true a * database query will be performed, otherwise the a query against the * object cache will be performed first. * - * @param dataObjectClass the data object class to retrieve - * @param id the data object primary key + * @param persistentClass the persistent object class to retrieve + * @param id the persistent object primary key * @param refresh the refresh the object cache mode - * @return the data object for the given class and id + * @return the persistent object for the given class and id */ - protected DataObject getObjectForPK(Class dataObjectClass, Object id, boolean refresh) { - Validate.notNull(dataObjectClass, "Null dataObjectClass parameter."); + protected T getObjectForPK(Class persistentClass, Object id, boolean refresh) { + Validate.notNull(persistentClass, "Null persistentClass parameter."); ObjEntity objEntity = - getDataContext().getEntityResolver().lookupObjEntity(dataObjectClass); + getDataContext().getEntityResolver().lookupObjEntity(persistentClass); if (objEntity == null) { throw new CayenneRuntimeException("Unmapped DataObject Class: " - + dataObjectClass.getName()); + + persistentClass.getName()); } - String pkName = getPkName(dataObjectClass); + String pkName = getPkName(persistentClass); ObjectId objectId = new ObjectId(objEntity.getName(), pkName, id); @@ -212,24 +215,24 @@ public class CayenneTemplate { ObjectIdQuery objectIdQuery = new ObjectIdQuery(objectId, false, refreshMode); - return (DataObject) DataObjectUtils.objectForQuery(getDataContext(), objectIdQuery); + return (T) DataObjectUtils.objectForQuery(getDataContext(), objectIdQuery); } /** * Return the database primary key column name for the given data object. * - * @param dataObjectClass the class of the data object + * @param persistentClass the class of the persistent object * @return the primary key column name */ - protected String getPkName(Class dataObjectClass) { - Validate.notNull(dataObjectClass, "Null dataObjectClass parameter."); + protected String getPkName(Class persistentClass) { + Validate.notNull(persistentClass, "Null persistentClass parameter."); ObjEntity objEntity = - getDataContext().getEntityResolver().lookupObjEntity(dataObjectClass); + getDataContext().getEntityResolver().lookupObjEntity(persistentClass); if (objEntity == null) { throw new CayenneRuntimeException("Unmapped DataObject Class: " - + dataObjectClass.getName()); + + persistentClass.getName()); } DbEntity dbEntity = objEntity.getDbEntity();