db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Fischer (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (TORQUE-26) Add SetBy* methods that match the GetBy* methods to the OM classes
Date Thu, 15 Jun 2006 13:03:31 GMT
     [ http://issues.apache.org/jira/browse/TORQUE-26?page=all ]
     
Thomas Fischer resolved TORQUE-26:
----------------------------------

    Resolution: Fixed
     Assign To: Thomas Fischer

Committed patch, with the following changes
- removed the restriction that protected columns cannot be set by the new methods. "protected"
only means that the column's getters and setters are not public but protected. This was mainly
doen for people using inheritance, so that they can override the protected methods by public
methods only in selected subclasses
- replaced tabs by spaces in the velocity templates. Please, next time do not use tabs in
the velocityx templates. Tabs mess up the code and are thus evil.

> Add SetBy* methods that match the GetBy* methods to the OM classes
> ------------------------------------------------------------------
>
>          Key: TORQUE-26
>          URL: http://issues.apache.org/jira/browse/TORQUE-26
>      Project: Torque
>         Type: New Feature

>   Components: Runtime, Generator, Test Project
>     Versions: 3.2
>     Reporter: CG Monroe
>     Assignee: Thomas Fischer
>      Fix For: 3.2.1
>  Attachments: BaseObjectSetByMethods-Changelog.txt, BaseObjectSetByMethods.zip
>
> The attached source zip adds setBy* methods that match the existing  getBy* 
> methods in the Generated OM record classes.  These have the signatures of:
>  
>     public boolean setByName( String fieldName, Object value ) 
>                                         throws IllegalArgumentException 
>     public boolean setByPeerName( String fieldName, Object value ) 
>                                         throws IllegalArgumentException 
>     public boolean setByPositon( int position, Object value ) 
>                                         throws IllegalArgumentException 
>  
> The boolean will be false if the field can't be set (unknown name or
> field is protected, i.e. readOnly ).  IllegalArgumentExceptions will be 
> thrown if the Object does not match the fields required type.  The 
> implimentations handle conversion to primitive if needed.
>  
> The BaseObject runtime class now has matching setBy* methods 
> that throw "not implemented" exceptions.
>  
> Generation of these methods can be turned on and off by the 
> existing torque.addGetByNameMethod option.  Just because it's easy
> and doesn't impact the build properties. Should there be yet another 
> option or should this option name change?
>  
> 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 
> 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<Field> method. This
> will allow values to be set, if you have a runtime determined field name and
> a BaseObject handle.
>  
> For example, suppose there is the need for a generic import function to 
> 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:
>  
> void convert( List mixedListOfOldRecords, String newDBName ) {
> ...
>     <iterate over mixedListOfRecords>
>     ...
>     BaseObject oldRecord = mixedListOfOldRecords.get(x);
>     String tableName = oldRecord.getTableMap().getName();
>     ...
>     DatabaseMap dMap = Torque.getDatabaseMap(newDBName);
>     dMap.initialize();
>     TableMap tMap = dMap.getTable(tableName);
>     BaseObject newRecord = tMap.getOMClass().newInstance();
>     ColumnMaps[] columns = tMap.getColumns();
>     <iterate over columns>
>         ...
>         String fieldName = column.getJavaName();
>         Object value = oldRecord.getByName(fieldName);
>         newRecord.setByName(fieldName, value);
>     ... 
>  
> Note that mixedListOfOldRecords could be created with all required
> foreign key records as well as sub-records.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message