> -----Original Message-----
> From: John McNally [mailto:[EMAIL PROTECTED]]

> yes, the spaces are there for efficiency.  can you explain why this
> causes you problems with specific example?  I don't want to 
> change this,
> but if you make a good enough case for it, you might manage 
> to persuade
> me.  Not sure about others, of course.

This is because it feels weird to fill the table with spaces for some of the
comparison types and I don't like harcoding things :-)

Note an issue though, another indirection table can be made if there is a
need to...no big deal.

Another point... I feel the need to have a complex metadata description
(relation between fields and table), for example it could be interesting to
have something like:

PersonPeerMapBuilder.getColumnByField("address.city"); 

with a "NumberKey Person.getAddressId()" or such...and it goes from
MapBuilder to MapBuilder to retrieve the appropriate columns. Is it a weird
idea ? If no do you have an idea of how to do it ?

For now I did a simple thing, in the MapBuilder.vm I added 4 methods: 2
static and 2 instances, the instance are there for convenience so that I
have a generic way to use the map builder w/o using reflection to call the
static fields.

Of course it is not complete and does not work for joins... it is just plain
simple stupid for now.

public class ${table.JavaName}MapBuilder implements IMetadataMap, MapBuilder
[...]

    /**
     * return the field mapped to a given column name.
     * @param column the name of the column (case-sensitive).
     * @return the name of the associated field or <tt>null</tt> if it does
not exist.
     */
    public static String getFieldByColumn(String column){
#foreach ($col in $table.Columns)
    #set ( $tfc=$table.JavaName )
    #set ( $cfc=$col.JavaName )
        if ( get${tfc}_${cfc}().equals(column) ){
            return "$cfc";
        }
#end
        return null;
    }


    /**
     * return the column mapped to a given field name.
     * @param column the name of the field (case-sensitive).
     * @return the name of the associated column or <tt>null</tt> if it does
not exist.
     */
    public static String getColumnByField(String field) {
#foreach ($col in $table.Columns)
    #set ( $tfc=$table.JavaName )
    #set ( $cfc=$col.JavaName )
        if ( "${cfc}".equals(field) ){
            return get${tfc}_${cfc}();
        }
#end
        return null;
    }

    // @see com.imediation.commons.om.IMetadataMap
    // @see #getFieldByColumn(String)
    public String getField(String column){
        return ${table.JavaName}MapBuilder.getFieldByColumn(column);
    }
    
    // @see com.imediation.commons.om.IMetadataMap
    // @see #getColumnByField(String)
    public String getColumn(String field){
        return ${table.JavaName}MapBuilder.getColumnByField(field);
    }

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to