Reusing the transformer of the DAO

Discuss the Spring cartridge here

Reusing the transformer of the DAO

Postby gehel » Wed 17. Aug 2005, 09:19

I have a value object the is composed of a few other VO. When implementing the tranformer for it, I'd like to reuse the transformer that I already have for the composing VO. Not very clear explanation, I agree ...

Let's say I have an entity A that is composed of an entity B and an entity C
Code: Select all
B<----<>A<>---->C

Each of these entities have value objects, let's call them VA, VB and VC. The value object VA is composed of VB and VC
Code: Select all
VB<----<>VA<>---->VC

Transforming VB and VC is already done, so when I write the transform method for VA, I'd like to reuse the other transforms. They are public methods on the DAO so it should be possible, but how should I access an instance of the other DAO from A's DAO ?

Rereading that, it still sounds a bit confused ... but I hope you can understand what I mean ...

Thanks for your answers !
Jabber : gehel@amessage.ch (feel free to contact me)
next project : http://rwanda.ledcom.ch
gehel
Experienced Member
 
Posts: 352
Joined: Fri 13. May 2005, 12:08
Location: Geneva - Switzerland

Postby wouter.zoons » Wed 17. Aug 2005, 09:40

your first sentence is the one that's most clear

to access a DAO from another DAO just draw a dependency from the first DAO's entity to the second one, then you'll be able to do this in your first DAO:

Code: Select all
First <<Entity>> -----> Second <<Entity>>


Code: Select all
FirstDao.getSecondDao()
Wouter Zoons - wouter [at] andromda [dot] org
http://www.andromda.org/ - http://draftdog.blogspot.com/
wouter.zoons
AndroMDA Admin
 
Posts: 4137
Joined: Fri 6. May 2005, 18:29
Location: Brussels, Belgium

Postby gehel » Wed 17. Aug 2005, 09:54

Congratulations for understanding what I meant ! And thanks a lot for the answer, I was sure there was an easy way to do it ...
Thanks !
Jabber : gehel@amessage.ch (feel free to contact me)
next project : http://rwanda.ledcom.ch
gehel
Experienced Member
 
Posts: 352
Joined: Fri 13. May 2005, 12:08
Location: Geneva - Switzerland

One more thing...

Postby wciesiel » Fri 19. Aug 2005, 10:57

I use one more pattern - if there are VOs inheriting from each other (for example. MyEntityDetailedDto inheriting from MyEntitySimpleDto I use utility class DtoPopulator with methods:

Code: Select all
public static MyEnitytySimpleDto populateMyEntitySimpleDto(MyEntity entity, MyEntitySimpleDto toPopulate) {
  // fill simple fields from entity
  return toPopulate;
}

public static MyEntityDetailedDto populateMyEntityDetailedDto(MyEntity entity, MyEntityDetailedDto toPopulate) {
  toPopulate = populateMyEntitySimpleDto(entity, toPopulate);
  // fill detailed fields
}



it's quite usefull ;-)
wciesiel
 
Posts: 95
Joined: Mon 13. Jun 2005, 21:44


Return to Spring cartridge

Who is online

Users browsing this forum: No registered users and 0 guests

cron