Tuesday, July 7, 2009
Using GraphViz to automatically Diagram your Grails Domain Model
I'm working on a feature that automatically diagrams the Domain model stored in Grails, similar to the method prototyped by the Curious Bunny here. His example works pretty well for a simple model, but begins to break down due to a seeming Grails limitation.
In my model, I have a Party, Organization and Company class. Company extends Organization, Organization extends Party.
Party <--- Organization < --- Company Inside of my Controller that produces the Graph, I iterate through a classes subclasses like so:
domainClass.subClasses.each {subClass ->
out.println """"$domainClass.name" -> "$subClass.name" """
}
This works ok, but when this is run on Company, both Party and Organization are in the set. In a UML diagram, I don't really want both of them, I only want one of them. I.e. it produces a diagram that is more cluttered than it needs to be.
This diagram represents a simplified subset of my domain, based off the Party Pattern Archetype in the book: Enterprise Patterns and MDA: Building Better Software with Archetype Patterns and UML
Notice the redundant inheritance.
Anybody know how to only get direct subclasses, instead of recursive subclasses?
Subscribe to:
Posts (Atom)