Hi Brian,

> Smells like a gross hack to me...

Yes, indeed, it's a hack. :-) A "clean" way to do it is to add another
method findSuperclass(Classifier) to SimpleOOHelper. Inside the Velocity
script, you could then write: $transform.findSuperclass($class).

Sounds better, doesn't it? :-)

In AndroMDA 3.x with metamodel decorators, you will simply write:
$class.superclass - that's it.

Cheers...
Matthias

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf 
> Of Brian Topping
> Sent: Thursday, December 11, 2003 11:33 PM
> To: [EMAIL PROTECTED]
> Subject: [Andromda-devel] changes for hibernate entity inheritance
> 
> 
> I'm working with hibernate and have been wanting to have 
> AndroMDA generate classes of the form:
> 
> // the superclass does not use @hibernate.class
> public abstract Superclass {
>    /** @hibernate.id ... */
>    ....
> }
> 
> /** @hibernate.class */
> public Subclass extends Superclass {
>    // id is inherited from superclass
>    ....
> }
> 
> This works great for Hibernate and XDoclet, but AndroMDA 
> 2.1.1 doesn't deal with inheritance.  So I added the following code to
> AndroMDAGenTask.processModelElementWithOneTemplate():
> 
>   ...
>   velocityContext.put("class", modelElement);
>   // new code
>   if (modelElement instanceof Classifier) {
>   String superTypes = null;
>   for (Iterator it = ((Classifier)
> modelElement).getGeneralization().iterator();
>                 it.hasNext();) {
>     Generalization g = (Generalization) it.next();
>     if (superTypes == null) {
>       superTypes = g.getParent().getName();
>     } else {
>       // this should never get hit with a class.  Does 
> Classifier map to a Java
>       // class, or is it a super of both interface and class?
>       superTypes += ","+g.getParent().getName();
>     }
>   }
>   velocityContext.put("supertypes", superTypes);
>   }
>   ...
> 
> Smells like a gross hack to me (the Velocity context would 
> get pretty cluttered pretty quick), but maybe I'm being too 
> hard on myself.  Any Velocity pros want to comment?
> 
> Anyway, I have these additions if anyone is interested, there 
> may be more to come.
> 
> thanks,
> 
> -b
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program. 
> Does SourceForge.net help you be more productive?  Does it 
> help you create better code?  SHARE THE LOVE, and help us 
> help YOU!  Click Here: http://sourceforge.net/donate/ 
> _______________________________________________
> Andromda-devel mailing list [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/andromda-devel
> 
> 




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Andromda-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/andromda-devel

Reply via email to