commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james_strac...@yahoo.co.uk>
Subject Re: Torque OM Betwixt and general use
Date Fri, 14 Jun 2002 04:14:57 GMT
Hi Christine

I'm not totally sure from your example that betwixt was or wasn't using the
.betwixt file. You could turn on commons-logging to debug and you'll see
what .betwixt files it loads. If you don't have log4j or logkit on your
classpath and are not on JDK1.4 then there's a description of how to do this
here...

http://nagoya.apache.org/gump/javadoc/jakarta-commons/logging/dist/docs/api/
org/apache/commons/logging/impl/SimpleLog.html

Also you could try the following .betwixt file, which will use attributes
for all properties of your Knowledge object

<?xml version="1.0" encoding="UTF-8" ?>
<info primitiveTypes="element">
  <element name="KnowledgeObject">
    <addDefaults/>
</info>

James
----- Original Message -----
From: "Christine Keim" <impulse2@ycn.com>
To: <commons-dev@jakarta.apache.org>
Sent: Thursday, June 13, 2002 11:30 PM
Subject: Torque OM Betwixt and general use


Hello,

since there is no commons-user-List, i'll try my luck here.
I am using Turbine along with Torque as an OM-Tool.
Some data of an object generated with Torque should be stored in a XML-DB
(Xindice, to be ecaxt).
Now i thought i might use betwixt to map the wanted attributes to a nice XML
and put it in the DB.
Now i first wanted to look at the example of betwixt, for some reason i
can't (ant failes
the build cause it doesn't find
org.apache.commons.betwixt.strategy.NameMapper, which is in the
source-directory, but not in the jar - why's that? ).
Well, after that i tried to figure it out, and i now have a prettyprinted
XML from the OM-Class,
though there's all attributes in it. Probably i'm using it all wrong, but
the documentation is rather
short, so i ought someone here could provide me with some insight ^^ (pretty
please)

my OM-Class is named KnowledgeObject and to test it i want to generate an
xml just with the
subject and description attribute in it. I made a
KnowledgeObject.betwixt-File which looks this way:

<?xml version="1.0" encoding="UTF-8" ?>
<KnowledgeObject primitiveTypes="attribute">
  <element name="subject" property="subject"/>
  <element name="description" property="description"/>
</<KnowledgeObject >

and i put that in the class-directory, actually exaclty in the directory the
om-Class also is (KnowledgeObject.class)
In the Class KnowledgeObjectPeer i made a new method which should also
create the xml from the OM-Class.

    public static ObjectKey doInsert(Criteria criteria, KnowledgeObject ko)
throws Exception
    {
// insert the data in the relational DB
        ObjectKey result =  BaseKnowledgeObjectPeer.doInsert(criteria);
        ko.setPrimaryKey(result);

// Use Betwixt to create an XML file from the Knowledge Object
        BeanWriter beanWriter = new BeanWriter(System.out);
        beanWriter.enablePrettyPrint();
        beanWriter.write(ko);
    } // doInsert

Now this produces some nice looking XML, though i only want something like
this to be created
(and i thought with the betwixt-file i ruled it).

<KnowledgeObject id="2">
  <subject>Subject</subject>
  <description>Description</description>
</KnowledgeObject

How do i tell the BeanWriter to use the betwixt-file? There is no error
thrown, so i think it doesn't use
the betwixt file at all ... ^^;;

tia, Christine Keim


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message