db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brent Atkins" <Brent.Atk...@Pro-Sys.biz>
Subject RE: Another Question / Feature Request
Date Thu, 26 Feb 2004 16:22:32 GMT
Trever, as far as I know this cannot be currently done.

You do have an interesting point here though, that segues nicely into my own feature request
:-)

I finally got most of my Struts code to be automatically generated (I'll be submitting a Wiki
entry
when I finish it completely) and I've run into the same sort of problem.  I've got a number
of
columns that I need to validate, like phone numbers and zip codes and states, etc.

Now I'm not trying to get Torque's runtime to handle it like Trever is, (using Struts it would
violate MVC - business logic shouldn't be in the persistence tier) but I do want to pass my
Struts
code generator a few extra properties that currently aren't being held by Table or Column.
 Right
now I accomplish it with a pretty nasty hack (a bunch of if statements) that couples my code
in more
places than I would like.

Since Torque seems to store all of it's data as attributes in the schema (if I'm wrong, let
me know)
is seems that the space between <column> and </column> is being unused.  Perhaps
Torque would be
better equipped to handle custom needs if it allowed a person to insert key-value pairs into
the
schema that could be accessed during generation.

So instead of being limited to this...
<table name="company" idMethod="null" skipSql="false" abstract="false">
  <column name="companyPhone" required="true" type="VARCHAR" size="10" primaryKey="false"
autoIncrement="false" inheritance="false" />
</table>

You could add descriptors that help your own code generation...
<table name="company" idMethod="null" skipSql="false" abstract="false">
  <column name="companyPhone" required="true" type="VARCHAR" size="10" primaryKey="false"
autoIncrement="false" inheritance="false">
    type=phone
    areaCode=required
    howIsThisExample=reallyStupid
  </column>
</table>

It's a poor example (sadly, I couldn't think of a better one) but hopefully those of you who
currently generate other code with Torque can see the benefit to this extensibility.  Currently
I
have to change every template that has to process a phone number whenever I add a different
phone
field (ie. mobile, business, fax) where with this change I could just label each one in my
schema as
a type=phone and not have to change a single template (provided I wrote it well the first
time).

Just a thought...

And to the guy who thinks that Torque is too hard to use - it's worth it.  I now generate
95% of my
site from the schema using the Torque generators and my own templates.  If I could figure
out a way
to get it to generate images I'd be at 100% :-)  Don't let the high learning curve get to
you, it is
incredibly powerful once you figure it out.  But yeah, the docs could be better...oh well.

-----Original Message-----
From: Trever Shick [mailto:trevorshick@cox.net]
Sent: Wednesday, February 25, 2004 5:41 PM
To: torque-user@db.apache.org
Subject: Another Question / Feature Request


I have a class called Phone that parses and formats phone numbers.
I'd like to be able to specify:

<column name="home_phone" size="20" type="VARCHAR"
javaClass="com.tms.Phone"/>

or even:

<type name="PHONE" javaClass="com.tms.Phone"/>

<column name="home_phone" type="PHONE"/>

Is there a way to do this with the current version?
Is this something that will be added with the "domains" ?





--

Trever M. Shick


Sequoyah Technologies
2448 East 81st Street, Suite 2500
Tulsa, OK  74137

tshick@seqtek.com

CONFIDENTIALITY NOTE:   The information contained in this document and accompanying documents
is
legally privileged and confidential information intended only for the use of the individual
or
entity named herein.  If the reader of this transmittal is not the intended recipient, you
are
hereby notified that any use, dissemination, distribution, or copy of this information is
strictly
prohibited.  If you have received this transmittal and accompanying information in error,
please
immediately notify us by telephone and return the original document and accompanying information
to
us at the address above and destroy any copies received.  Thank You!



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



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


Mime
View raw message