You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Birgit Linner <bi...@ovsag.de> on 2004/08/17 11:13:08 UTC

[betwixt] mapID Problems

Hi everybody!

I`m new to betwixt and want to use it to dump and import our database
tables.
Dumping is ok, altough I have some questions, too.
The problem is, that every reference to other objects is null when I read
the XML file.
( I have defined: beanReader.getBindingConfiguration().setMapIDs(true); )



I have the following structure in the XML File:


----------------------- dump.xml ----------------------------------
<ArrayList>
	<ArrayList>
		<Person id="1"..... />
		...
	</ArrayList>
	...
	<ArrayList>
		<Projekt id="12"...>
        		<manager idref="13"/>   --> Reference to Person
     		</Projekt>
	</ArrayList>
---------------------------------------------------------------------



I am reading the XML file with this Reader (btw: I`m also new to Digester
and tried a bit to get the ArrayList structure out of the file, I got no
result when only using beanReader.registerBeanClass(...) ):



-------------------- Dumper.java ------------------------------------
StringReader xmlReader = new StringReader("dump.xml");
BeanReader beanReader = new BeanReader();
beanReader.getXMLIntrospector().setWrapCollectionsInElement(false);
beanReader.getXMLIntrospector().setAttributesForPrimitives(true);
beanReader.getBindingConfiguration().setMapIDs(true);
beanReader.registerBeanClass("ArrayList", ArrayList.class);
beanReader.addObjectCreate("ArrayList/ArrayList", ArrayList.class);
beanReader.addSetNext("ArrayList/ArrayList", "add");
beanReader.registerBeanClass("ArrayList/ArrayList/Person", Person.class);
beanReader.addSetNext("ArrayList/ArrayList/Person", "add");
beanReader.registerBeanClass("ArrayList/ArrayList/Role", Role.class);
beanReader.addSetNext("ArrayList/ArrayList/Role", "add");
beanReader.registerBeanClass("ArrayList/ArrayList/Arbeitszeit",
Arbeitszeit.class);
beanReader.addSetNext("ArrayList/ArrayList/Arbeitszeit", "add");
beanReader.registerBeanClass("ArrayList/ArrayList/Projekt", Projekt.class);
beanReader.addSetNext("ArrayList/ArrayList/Projekt", "add");
Object result = beanReader.parse(new File("dump.xml"));
------------------------------------------------------------------------


With this configuration I get an ArrayList with ArrayLists.. and so on,
but - how mentioned above - the idref is null:


---------------------- OUTPUT -----------------------------------------
Projekt:
  id     ="0"
  manager=null
  name   ="Projekt1"
-----------------------------------------------------------------------

Is there anything I forgot? Or am I doing something wrong? I`d really
appreciate a tip!


Another question about wrinting a bean to XML:
I`d like to rename my ArrayLists (only for better reading), e.g. the
root-ArrayList to "Data" and the inner ones to "persons", "project" etc.
Is this possible? I tried, but always get empty tags (also with using
class-property in element-tag). But this is only "nice to have"...

Thanks in advance!

Have a nice day!

Birgit






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


Re: Urgent:::commons-email

Posted by Marty Phee <mp...@jump-technologies.com>.
Download the souce code.  It looks like they should be InternetAddress objects 
in the collection and not strings.


On Tuesday 17 August 2004 04:27 pm, rose maria wrote:
> Hi,
> I was able to send a mail by using SimpleEmail class
> of commons-email when i used the following code
>
> 		SimpleEmail email = new SimpleEmail();
> 		email.setDebug(true);
> 		email.setHostName("test.myhost.com");
>
>       ---->>>>
> email.addTo("jinimaria@yahoo.com,Maria");
>
> 		email.setFrom("me@mycompany.com", "Me");
> 		email.setMsg("This is a simple test For mail");
> 		email.send();
>
> but it is not working when i tried to use with a
> Collection that is  i replaced "addTo" with "setTo".It
> is not
> giving any error.Code is as folloing
>
> 	  	Collection c = new ArrayList();
> 	  	c.add("jinimaria@yahoo.com");
> 		email.setDebug(true);
> 		email.setHostName("test.myhost.com");
>       ---->>>>	email.setTo(c);
> 		email.setFrom("me@mycompany.com", "Me");
> 		email.setMsg("This is a simple test For
> collection");
> 		email.send();
>    Am i missing somthing here.Itried both with
> commons-email-0.1-dev.jar and
> commons-email-SNAPSHOT.jar
>
>    Please include a code snippet if you have any...
>
>    Your help would be greatly appreciated.
>
>    Thanks
>    Maria
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org

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


Urgent:::commons-email

Posted by rose maria <ji...@yahoo.com>.
Hi,
I was able to send a mail by using SimpleEmail class 
of commons-email when i used the following code
 
		SimpleEmail email = new SimpleEmail();
		email.setDebug(true);
		email.setHostName("test.myhost.com");
		
      ---->>>>
email.addTo("jinimaria@yahoo.com,Maria");   
		
		email.setFrom("me@mycompany.com", "Me");
		email.setMsg("This is a simple test For mail");
		email.send();

but it is not working when i tried to use with a
Collection that is  i replaced "addTo" with "setTo".It
is not
giving any error.Code is as folloing

	  	Collection c = new ArrayList(); 
	  	c.add("jinimaria@yahoo.com");
		email.setDebug(true);
		email.setHostName("test.myhost.com");
      ---->>>>	email.setTo(c);
		email.setFrom("me@mycompany.com", "Me");
		email.setMsg("This is a simple test For
collection");
		email.send();
   Am i missing somthing here.Itried both with
commons-email-0.1-dev.jar and
commons-email-SNAPSHOT.jar
   
   Please include a code snippet if you have any...
      
   Your help would be greatly appreciated.
   
   Thanks
   Maria
		

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


AW: [betwixt] mapID Problems

Posted by Birgit Linner <bi...@ovsag.de>.
Hi Robert!
Thank you for answering!

I really don't want to use digester rules ;-) But if I do not, I don't get
the ArrayLists back from BeanReader. The output shows, that the content is
read, but I get nothing back... only if I add digester rules. Looks like
otherwise the objects are "hanging in the air"..

Can the digester rules be the reason, why references are null and ids=0?

Thanks and a nice evening!

Birgit

-----Ursprungliche Nachricht-----
Von: robert burrell donkin [mailto:robertburrelldonkin@blueyonder.co.uk]
Gesendet: Dienstag, 17. August 2004 23:15
An: Jakarta Commons Users List
Betreff: Re: [betwixt] mapID Problems


hi Birgit

though you can mix digester rules with betwixt, this is an advanced
topic. i'd suggest that you'd be better letting betwixt do the whole of
your mapping initially.

if you want to vary your mapping of beans into elements, i'd suggest
reading up on dot betwixt files.

- robert

On 17 Aug 2004, at 10:13, Birgit Linner wrote:

> Hi everybody!
>
> I`m new to betwixt and want to use it to dump and import our database
> tables.
> Dumping is ok, altough I have some questions, too.
> The problem is, that every reference to other objects is null when I
> read
> the XML file.
> ( I have defined:
> beanReader.getBindingConfiguration().setMapIDs(true); )
>
>
>
> I have the following structure in the XML File:
>
>
> ----------------------- dump.xml ----------------------------------
> <ArrayList>
> 	<ArrayList>
> 		<Person id="1"..... />
> 		...
> 	</ArrayList>
> 	...
> 	<ArrayList>
> 		<Projekt id="12"...>
>         		<manager idref="13"/>   --> Reference to Person
>      		</Projekt>
> 	</ArrayList>
> ---------------------------------------------------------------------
>
>
>
> I am reading the XML file with this Reader (btw: I`m also new to
> Digester
> and tried a bit to get the ArrayList structure out of the file, I got
> no
> result when only using beanReader.registerBeanClass(...) ):
>
>
>
> -------------------- Dumper.java ------------------------------------
> StringReader xmlReader = new StringReader("dump.xml");
> BeanReader beanReader = new BeanReader();
> beanReader.getXMLIntrospector().setWrapCollectionsInElement(false);
> beanReader.getXMLIntrospector().setAttributesForPrimitives(true);
> beanReader.getBindingConfiguration().setMapIDs(true);
> beanReader.registerBeanClass("ArrayList", ArrayList.class);
> beanReader.addObjectCreate("ArrayList/ArrayList", ArrayList.class);
> beanReader.addSetNext("ArrayList/ArrayList", "add");
> beanReader.registerBeanClass("ArrayList/ArrayList/Person",
> Person.class);
> beanReader.addSetNext("ArrayList/ArrayList/Person", "add");
> beanReader.registerBeanClass("ArrayList/ArrayList/Role", Role.class);
> beanReader.addSetNext("ArrayList/ArrayList/Role", "add");
> beanReader.registerBeanClass("ArrayList/ArrayList/Arbeitszeit",
> Arbeitszeit.class);
> beanReader.addSetNext("ArrayList/ArrayList/Arbeitszeit", "add");
> beanReader.registerBeanClass("ArrayList/ArrayList/Projekt",
> Projekt.class);
> beanReader.addSetNext("ArrayList/ArrayList/Projekt", "add");
> Object result = beanReader.parse(new File("dump.xml"));
> -----------------------------------------------------------------------
> -
>
>
> With this configuration I get an ArrayList with ArrayLists.. and so on,
> but - how mentioned above - the idref is null:
>
>
> ---------------------- OUTPUT -----------------------------------------
> Projekt:
>   id     ="0"
>   manager=null
>   name   ="Projekt1"
> -----------------------------------------------------------------------
>
> Is there anything I forgot? Or am I doing something wrong? I`d really
> appreciate a tip!
>
>
> Another question about wrinting a bean to XML:
> I`d like to rename my ArrayLists (only for better reading), e.g. the
> root-ArrayList to "Data" and the inner ones to "persons", "project"
> etc.
> Is this possible? I tried, but always get empty tags (also with using
> class-property in element-tag). But this is only "nice to have"...
>
> Thanks in advance!
>
> Have a nice day!
>
> Birgit
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>


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





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


Re: [betwixt] mapID Problems

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
hi Birgit

though you can mix digester rules with betwixt, this is an advanced  
topic. i'd suggest that you'd be better letting betwixt do the whole of  
your mapping initially.

if you want to vary your mapping of beans into elements, i'd suggest  
reading up on dot betwixt files.

- robert

On 17 Aug 2004, at 10:13, Birgit Linner wrote:

> Hi everybody!
>
> I`m new to betwixt and want to use it to dump and import our database
> tables.
> Dumping is ok, altough I have some questions, too.
> The problem is, that every reference to other objects is null when I  
> read
> the XML file.
> ( I have defined:  
> beanReader.getBindingConfiguration().setMapIDs(true); )
>
>
>
> I have the following structure in the XML File:
>
>
> ----------------------- dump.xml ----------------------------------
> <ArrayList>
> 	<ArrayList>
> 		<Person id="1"..... />
> 		...
> 	</ArrayList>
> 	...
> 	<ArrayList>
> 		<Projekt id="12"...>
>         		<manager idref="13"/>   --> Reference to Person
>      		</Projekt>
> 	</ArrayList>
> ---------------------------------------------------------------------
>
>
>
> I am reading the XML file with this Reader (btw: I`m also new to  
> Digester
> and tried a bit to get the ArrayList structure out of the file, I got  
> no
> result when only using beanReader.registerBeanClass(...) ):
>
>
>
> -------------------- Dumper.java ------------------------------------
> StringReader xmlReader = new StringReader("dump.xml");
> BeanReader beanReader = new BeanReader();
> beanReader.getXMLIntrospector().setWrapCollectionsInElement(false);
> beanReader.getXMLIntrospector().setAttributesForPrimitives(true);
> beanReader.getBindingConfiguration().setMapIDs(true);
> beanReader.registerBeanClass("ArrayList", ArrayList.class);
> beanReader.addObjectCreate("ArrayList/ArrayList", ArrayList.class);
> beanReader.addSetNext("ArrayList/ArrayList", "add");
> beanReader.registerBeanClass("ArrayList/ArrayList/Person",  
> Person.class);
> beanReader.addSetNext("ArrayList/ArrayList/Person", "add");
> beanReader.registerBeanClass("ArrayList/ArrayList/Role", Role.class);
> beanReader.addSetNext("ArrayList/ArrayList/Role", "add");
> beanReader.registerBeanClass("ArrayList/ArrayList/Arbeitszeit",
> Arbeitszeit.class);
> beanReader.addSetNext("ArrayList/ArrayList/Arbeitszeit", "add");
> beanReader.registerBeanClass("ArrayList/ArrayList/Projekt",  
> Projekt.class);
> beanReader.addSetNext("ArrayList/ArrayList/Projekt", "add");
> Object result = beanReader.parse(new File("dump.xml"));
> ----------------------------------------------------------------------- 
> -
>
>
> With this configuration I get an ArrayList with ArrayLists.. and so on,
> but - how mentioned above - the idref is null:
>
>
> ---------------------- OUTPUT -----------------------------------------
> Projekt:
>   id     ="0"
>   manager=null
>   name   ="Projekt1"
> -----------------------------------------------------------------------
>
> Is there anything I forgot? Or am I doing something wrong? I`d really
> appreciate a tip!
>
>
> Another question about wrinting a bean to XML:
> I`d like to rename my ArrayLists (only for better reading), e.g. the
> root-ArrayList to "Data" and the inner ones to "persons", "project"  
> etc.
> Is this possible? I tried, but always get empty tags (also with using
> class-property in element-tag). But this is only "nice to have"...
>
> Thanks in advance!
>
> Have a nice day!
>
> Birgit
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>


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