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

Reply via email to