commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrick.Grim...@xtl.com
Subject Scripting Suggestion?
Date Wed, 10 Sep 2008 11:37:43 GMT

Yesterday I successfully implemented my first digester class and it works great,
just like I would want it to.  Now I need to take my XML file a step further by
including some form of scripting.  My XML file is basically used to map tables
and fields between 2 datasources so that my java process can pull from one and
dump to the other.  The issue however is that the columns in the target
datasource are all string columns and my source data columns aren't always
string columns and are sometimes also longer in length than the target columns.
My process will have logic to determine the source datatype and convert it to a
proper string, I just don't want to create methods for each field that might
need to be substringed before inserting into the target datasource because I
want the java process to be independent of the actual data it's processing,
hence the XML file.  It's not enough to say I can just check the length of the
target column and substring the source accordingly, because the result might not
be what I want, ie: a boolean won't automatically convert to Y or N which my
target datasource wants.  Does anybody have any suggestions?  Thanks in advance.

Here's a sample of what my XML file might look like:

<harvester>
      <datasources>
            <datasource>
                  <name>source</name>
                  <driver>some.driver</driver>
                  <url>the.url</url>
                  <username></username>
                  <password></password>
            </datasource>
            <datasource>
                  <name>destination</name>
                  <driver>some.driver</driver>
                  <url>the.url</url>
                  <username></username>
                  <password></password>
            </datasource>
      </datasources>

      <tables>
            <table>
                  <sourceTable>tableName</sourceTable>
                  <destTable>tableName</destTable>
                  <fields>
                        <field>
                              <sourceField>fieldName</sourceField>
                              <destField>fieldName</destField>
                              <transformSource>
                                    <!-- would like some kind of script here
                                    to say how to convert/trim the source value
-->
                              </transformSource>
                        </field>
                        <field>
                              <sourceField>fieldName</sourceField>
                              <destField>fieldName</destField>
                        </field>
                        <field>
                              <sourceField>fieldName</sourceField>
                              <destField>fieldName</destField>
                        </field>
                  </fields>
            </table>
      </tables>
</harvester>
(Embedded image moved to file: pic15141.jpg)

Mime
View raw message