From: Anjo K. <an...@us...> - 2005-08-31 15:21:43
|
Update of /cvsroot/wonder/Wonder/Common/Frameworks/ERExtensions/Sources/er/extensions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16032/ERExtensions/Sources/er/extensions Modified Files: ERXDatabaseContextDelegate.java Log Message: more readable GID when we have binary keys Index: ERXDatabaseContextDelegate.java =================================================================== RCS file: /cvsroot/wonder/Wonder/Common/Frameworks/ERExtensions/Sources/er/extensions/ERXDatabaseContextDelegate.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** ERXDatabaseContextDelegate.java 19 Aug 2005 08:58:22 -0000 1.23 --- ERXDatabaseContextDelegate.java 31 Aug 2005 15:21:29 -0000 1.24 *************** *** 7,17 **** package er.extensions; ! import java.io.*; ! import java.sql.*; ! import java.util.*; ! import com.webobjects.eoaccess.*; ! import com.webobjects.eocontrol.*; ! import com.webobjects.foundation.*; /** --- 7,34 ---- package er.extensions; ! import java.io.File; ! import java.io.IOException; ! import java.sql.Connection; ! import java.util.Enumeration; ! import com.webobjects.eoaccess.EOAdaptor; ! import com.webobjects.eoaccess.EOAdaptorChannel; ! import com.webobjects.eoaccess.EOAttribute; ! import com.webobjects.eoaccess.EODatabaseChannel; ! import com.webobjects.eoaccess.EODatabaseContext; ! import com.webobjects.eoaccess.EOEntity; ! import com.webobjects.eoaccess.EOGeneralAdaptorException; ! import com.webobjects.eoaccess.EOObjectNotAvailableException; ! import com.webobjects.eoaccess.EOSQLExpression; ! import com.webobjects.eocontrol.EOEditingContext; ! import com.webobjects.eocontrol.EOEnterpriseObject; ! import com.webobjects.eocontrol.EOFetchSpecification; ! import com.webobjects.eocontrol.EOGlobalID; ! import com.webobjects.eocontrol.EOKeyGlobalID; ! import com.webobjects.eocontrol.EOSharedEditingContext; ! import com.webobjects.foundation.NSArray; ! import com.webobjects.foundation.NSDictionary; ! import com.webobjects.foundation.NSTimestamp; ! import com.webobjects.foundation.NSTimestampFormatter; /** *************** *** 131,135 **** } } ! throw new EOObjectNotAvailableException("No " + (object!=null ? object.getClass().getName() : "N/A") + " found with globalID: " + gid); } --- 148,172 ---- } } ! String gidString; ! if(gid instanceof EOKeyGlobalID) { ! // ak: when you use 24 byte PKs, the output is unreadable otherwise ! EOKeyGlobalID kgid = (EOKeyGlobalID)gid; ! gidString = "<" + kgid.entityName() + ": [" ; ! EOEntity entity = ERXEOAccessUtilities.entityNamed(null, kgid.entityName()); ! NSArray pks = entity.primaryKeyAttributes(); ! NSArray values = kgid.keyValuesArray(); ! EOSQLExpression expression = context.database().adaptor().expressionFactory().expressionForEntity(entity); ! for(int i = 0; i < pks.count(); i++) { ! Object value = values.objectAtIndex(i); ! EOAttribute attribute = (EOAttribute) pks.objectAtIndex(i); ! gidString += attribute.name() + ": \'" + expression.formatValueForAttribute(value, attribute) + "\'" ! + (i == pks.count() - 1 ? "" : ", "); ! } ! gidString += "] >"; ! ! } else { ! gidString = gid.toString(); ! } ! throw new EOObjectNotAvailableException("No " + (object!=null ? object.getClass().getName() : "N/A") + " found with globalID: " + gidString); } |