Return-Path: Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: (qmail 17489 invoked from network); 25 May 2006 15:27:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 25 May 2006 15:27:24 -0000 Received: (qmail 7767 invoked by uid 500); 25 May 2006 15:27:23 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 7749 invoked by uid 500); 25 May 2006 15:27:23 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Apache Torque Developers List" Reply-To: "Apache Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 7738 invoked by uid 99); 25 May 2006 15:27:23 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 May 2006 08:27:23 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of Greg.Monroe@dukece.com designates 65.112.55.73 as permitted sender) Received: from [65.112.55.73] (HELO mail.dukece.com) (65.112.55.73) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 May 2006 08:27:22 -0700 Received: from dukece-mail3.dukece.com ([192.168.1.222]) by mail.dukece.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 25 May 2006 11:27:21 -0400 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Content-Class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C6800F.AAB798B4" Subject: SetByName, SetByPeerName, SetByPostion support / Generic String to Column Object utility class. Date: Thu, 25 May 2006 11:26:59 -0400 Message-ID: <8F5843B903F59D4C8C6806BB49A39119C74A66@dukece-mail3.dukece.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: SetByName, SetByPeerName, SetByPostion support / Generic String to Column Object utility class. Thread-Index: AcaAD6ps6nblHLeLRHGEb5VQs5UtUg== From: "Greg Monroe" To: X-OriginalArrivalTime: 25 May 2006 15:27:21.0796 (UTC) FILETIME=[B77D8840:01C6800F] X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------_=_NextPart_001_01C6800F.AAB798B4 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Just a quick heads up/RFC about a couple of minor enhancements that=20 I'll be submitting via JIRA once I get The Enhanced Database Mapping=20 [Jira - Torque22] issues resolved (Working thru your list slowly=20 Thomas.. 8-) ). =20 The first one is to add functions to matching setBy* methods that match the=20 existing getBy* methods in the Generated record classes. These will have the signatures of: =20 public boolean setByName( String fieldName, Object value )=20 throws IllegalArgumentException=20 public boolean setByPeerName( String fieldName, Object value )=20 throws IllegalArgumentException=20 public boolean setByPositon( int position, Object value )=20 throws IllegalArgumentException=20 =20 The boolean will be false if the field can't be set (unknown name or field is protected, i.e. readOnly ). IllegalArgumentExceptions will be=20 thrown if the Object does not match the fields required type. The=20 implimentations handle conversion to primative if needed. =20 The BaseObject methods will be "not implemented" exception stubs. =20 Currently, generation of these methods can be turned on and off by the=20 existing torque.addGetByNameMethod option. Just because it's easy and doesn't impact the build properties. Should there be yet another=20 option or should this option name change? =20 The reason for this is to make it possible to have methods who's parameters specify BaseObject fully interact with ANY record object. Currently, the=20 only way to set values in a record using a BaseObject defined variable is to do a compile time cast and call the appropriate set method. This will allow values to be set, if you have a runtime determined field name and a BaseObject handle. =20 For example, suppose there is the need for a generic import function to=20 support something like XML import 8-), or CSV or just transfering records from one database schema (Torque or Physical) to another with a matching or improved/new revision schema. With this, you can do things like: =20 void convert( List mixedListOfOldRecords, String newDBName ) { ... ... BaseObject oldRecord =3D mixedListOfOldRecords.get(x); String tableName =3D oldRecord.getTableMap().getName(); ... DatabaseMap dMap =3D Torque.getDatabaseMap(newDBName); dMap.initialize(); TableMap tMap =3D dMap.getTable(tableName); BaseObject newRecord =3D tMap.getOMClass().newInstance(); ColumnMaps[] columns =3D tMap.getColumns(); ... String fieldName =3D column.getJavaName(); Object value =3D oldRecord.getByName(fieldName); newRecord.setByName(fieldName, value); ...=20 =20 Note that mixedListOfOldRecords could be created with all required foreign key records as well as sub-records. =20 The second minor enhancement is a utility class that will handle converting=20 data between String values and object values. It will have some methods like: =20 public Object getObjectValue( String peerName, String value ) throws IllegalArgumentException. public Object getStringValue( BaseObject record, String peerName )... =20 The getObjectValue will return an object that matches the specified column's type. This is useful just about anytime you are dealing=20 with string input (like from XML imports or user forms). =20 The getStringValue is probably less useful but makes for symmetry. The one big benefit I can see would be that we could centralize the problems with=20 converting from Date object to (and from) Strings. =20 Have I totally confused everyone now? =20 TIA =20 Greg =20 Greg Monroe (919)680-5050 C&IS Solutions Team Lead Duke Corporate Education, Inc. 333 Liggett St. Durham, NC 27701 =20 Duke CE Privacy Statement Please be advised that this e-mail and any files transmitted with it are = confidential communication or may otherwise be privileged or = confidential and are intended solely for the individual or entity to = whom they are addressed. If you are not the intended recipient you may = not rely on the contents of this email or any attachments, and we ask = that you please not read, copy or retransmit this communication, but = reply to the sender and destroy the email, its contents, and all copies = thereof immediately. Any unauthorized dissemination, distribution or = copying of this communication is strictly prohibited. ------_=_NextPart_001_01C6800F.AAB798B4--