[hibernate-commits] Hibernate SVN: r10547 - in trunk/HibernateExt/tools/src: java/org/hibernate/tool/hbm2x java/org/hibernate/tool/hbm2x/doc java/org/hibernate/tool/hbm2x/visitor templates/doc templates/doc/entities templates/doc/tables templates/dot

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue Oct 3 19:50:12 EDT 2006


Author: max.andersen at jboss.com
Date: 2006-10-03 19:50:05 -0400 (Tue, 03 Oct 2006)
New Revision: 10547

Modified:
   trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java
   trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java
   trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/XMLPrettyPrinter.java
   trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocFileManager.java
   trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/jtidy.properties
   trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/EntityNameFromValueVisitor.java
   trunk/HibernateExt/tools/src/templates/doc/entities/summary.ftl
   trunk/HibernateExt/tools/src/templates/doc/index.html
   trunk/HibernateExt/tools/src/templates/doc/tables/summary.ftl
   trunk/HibernateExt/tools/src/templates/dot/entitygraph.dot.ftl
Log:
HBX-773  generate a clickable map to navigate from graph to documentation
HBX-771 Add graphical views based on graphviz to the DocExporter

Modified: trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java	2006-10-03 22:21:15 UTC (rev 10546)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java	2006-10-03 23:50:05 UTC (rev 10547)
@@ -16,14 +16,23 @@
 import org.hibernate.engine.query.sql.NativeSQLQueryJoinReturn;
 import org.hibernate.engine.query.sql.NativeSQLQueryReturn;
 import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn;
+import org.hibernate.mapping.Any;
+import org.hibernate.mapping.Array;
+import org.hibernate.mapping.Bag;
 import org.hibernate.mapping.Collection;
 import org.hibernate.mapping.Column;
+import org.hibernate.mapping.Component;
+import org.hibernate.mapping.DependantValue;
 import org.hibernate.mapping.Formula;
+import org.hibernate.mapping.IdentifierBag;
 import org.hibernate.mapping.JoinedSubclass;
+import org.hibernate.mapping.List;
 import org.hibernate.mapping.ManyToOne;
 import org.hibernate.mapping.OneToMany;
+import org.hibernate.mapping.OneToOne;
 import org.hibernate.mapping.PersistentClass;
 import org.hibernate.mapping.PersistentClassVisitor;
+import org.hibernate.mapping.PrimitiveArray;
 import org.hibernate.mapping.Property;
 import org.hibernate.mapping.RootClass;
 import org.hibernate.mapping.SimpleValue;
@@ -31,9 +40,11 @@
 import org.hibernate.mapping.Subclass;
 import org.hibernate.mapping.UnionSubclass;
 import org.hibernate.mapping.Value;
+import org.hibernate.mapping.ValueVisitor;
 import org.hibernate.persister.entity.JoinedSubclassEntityPersister;
 import org.hibernate.persister.entity.SingleTableEntityPersister;
 import org.hibernate.persister.entity.UnionSubclassEntityPersister;
+import org.hibernate.tool.hbm2x.visitor.EntityNameFromValueVisitor;
 import org.hibernate.tool.hbm2x.visitor.HBMTagForPersistentClassVisitor;
 import org.hibernate.tool.hbm2x.visitor.HBMTagForValueVisitor;
 
@@ -346,4 +357,8 @@
 		Boolean object = (Boolean) clazz.accept( new HasEntityPersisterVisitor( name ) );
 		return object.booleanValue();
 	}
+
+	public String getHibernateTypeName(Property p) {
+		return (String) p.getValue().accept(new EntityNameFromValueVisitor());
+	}
 }

Modified: trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java	2006-10-03 22:21:15 UTC (rev 10546)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java	2006-10-03 23:50:05 UTC (rev 10547)
@@ -1,18 +1,23 @@
 package org.hibernate.tool.hbm2x;
 
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileReader;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import org.hibernate.HibernateException;
 import org.hibernate.cfg.Configuration;
 import org.hibernate.mapping.Table;
 import org.hibernate.tool.hbm2x.doc.DocFile;
 import org.hibernate.tool.hbm2x.doc.DocFileManager;
 import org.hibernate.tool.hbm2x.doc.DocHelper;
 import org.hibernate.tool.hbm2x.pojo.POJOClass;
+import org.hibernate.util.StringHelper;
 
 /**
  * Exporter implementation that creates Hibernate Documentation.
@@ -47,67 +52,67 @@
     /**
      * Template used for the index of the table documentation.
      */
-    private static final String VM_TABLES_INDEX = "doc/tables/index.ftl";
+    private static final String FTL_TABLES_INDEX = "doc/tables/index.ftl";
     
     /**
      * Template used for index of the entity documentation
      */
-    private static final String VM_ENTITIES_INDEX = "doc/entities/index.ftl";
+    private static final String FTL_ENTITIES_INDEX = "doc/entities/index.ftl";
     
     /**
      * Template used for the Classes Summary
      */
-    private static final String VM_ENTITIES_SUMMARY = "doc/entities/summary.ftl";
+    private static final String FTL_ENTITIES_SUMMARY = "doc/entities/summary.ftl";
     
     /**
      * Template used for Class details
      */
-    private static final String VM_ENTITIES_ENTITY = "doc/entities/entity.ftl";
+    private static final String FTL_ENTITIES_ENTITY = "doc/entities/entity.ftl";
     
     /**
      * Template used to create the Package List
      */
-    private static final String VM_ENTITIES_PACKAGE_LIST = "doc/entities/package-list.ftl";
+    private static final String FTL_ENTITIES_PACKAGE_LIST = "doc/entities/package-list.ftl";
     
     /**
      * Template used to create the list of all Classes
      */
-    private static final String VM_ENTITIES_ENTITY_LIST = "doc/entities/allEntity-list.ftl";
+    private static final String FTL_ENTITIES_ENTITY_LIST = "doc/entities/allEntity-list.ftl";
     
     /**
      * Template used to create List of Classes specific to packages.
      */
-    private static final String VM_ENTITIES_PERPACKAGE_ENTITY_LIST = "doc/entities/perPackageEntity-list.ftl";
+    private static final String FTL_ENTITIES_PERPACKAGE_ENTITY_LIST = "doc/entities/perPackageEntity-list.ftl";
     
     /**
      * Template used to show the specific package details
      */
-    private static final String VM_ENTITIES_PACKAGE_SUMMARY = "doc/entities/package-summary.ftl";
+    private static final String FTL_ENTITIES_PACKAGE_SUMMARY = "doc/entities/package-summary.ftl";
 
     /**
      * Template used for the Tables Summary.
      */
-    private static final String VM_TABLES_SUMMARY = "doc/tables/summary.ftl";
+    private static final String FTL_TABLES_SUMMARY = "doc/tables/summary.ftl";
 
     /**
      * Template used for table lists.
      */
-    private static final String VM_TABLES_TABLE_LIST = "doc/tables/table-list.ftl";
+    private static final String FTL_TABLES_TABLE_LIST = "doc/tables/table-list.ftl";
 
     /**
      * Template used for schema lists.
      */
-    private static final String VM_TABLES_SCHEMA_LIST = "doc/tables/schema-list.ftl";
+    private static final String FTL_TABLES_SCHEMA_LIST = "doc/tables/schema-list.ftl";
 
     /**
      * Template used for Schema Summary.
      */
-    private static final String VM_TABLES_SCHEMA_SUMMARY = "doc/tables/schema-summary.ftl";
+    private static final String FTL_TABLES_SCHEMA_SUMMARY = "doc/tables/schema-summary.ftl";
 
     /**
      * Template used for the Table Details.
      */
-    private static final String VM_TABLES_TABLE = "doc/tables/table.ftl";
+    private static final String FTL_TABLES_TABLE = "doc/tables/table.ftl";
 
     /**
      * Doc helper.
@@ -142,8 +147,10 @@
 
 	public void doStart() throws ExporterException {
         generateCommmonAndAssets();
+        
+        boolean graphsGenerated = generateDot();
         generateTablesIndex();
-        generateTablesSummary();
+        generateTablesSummary(graphsGenerated);
         generateTablesDetails();
         generateTablesAllSchemasList();
         generateTablesAllTablesList();
@@ -151,14 +158,117 @@
         generateTablesSchemaDetailedInfo();
         
         generateEntitiesIndex();
-        generatePackageSummary();
+        generatePackageSummary(graphsGenerated);
         generateEntitiesDetails();
         generateEntitiesAllPackagesList();
         generateEntitiesAllEntitiesList();
         generateEntitiesPackageEntityList();
         generateEntitiesPackageDetailedInfo();
+        
+        
     }
 
+	private boolean generateDot() {
+		String cmd = getProperties().getProperty( "dot.executable" );
+		
+		if(StringHelper.isNotEmpty( cmd )) {
+			try {
+				GenericExporter exporter = new GenericExporter(getConfiguration(), getOutputDirectory());
+				exporter.setTemplateName( "dot/entitygraph.dot.ftl" );
+				exporter.setFilePattern( "entities/entitygraph.dot" );
+				exporter.setArtifactCollector( getArtifactCollector() );
+				exporter.setProperties( getProperties() );
+				exporter.setTemplatePath( getTemplatePaths() );
+				exporter.start();
+
+				exporter.setTemplateName( "dot/tablegraph.dot.ftl" );
+				exporter.setFilePattern( "tables/tablegraph.dot" );
+				exporter.setProperties( getProperties() );
+				exporter.start();
+				
+				dotToFile( cmd, new File(getOutputDirectory(), "entities/entitygraph.dot").toString(), new File(getOutputDirectory(), "entities/entitygraph.png").toString());
+				dotToFile( cmd, new File(getOutputDirectory(), "entities/entitygraph.dot").toString(), new File(getOutputDirectory(), "entities/entitygraph.svg").toString());
+				dotToFile( cmd, new File(getOutputDirectory(), "entities/entitygraph.dot").toString(), new File(getOutputDirectory(), "entities/entitygraph.cmap").toString());
+				
+				dotToFile( cmd, new File(getOutputDirectory(), "tables/tablegraph.dot").toString(), new File(getOutputDirectory(), "tables/tablegraph.png").toString());
+				dotToFile( cmd, new File(getOutputDirectory(), "tables/tablegraph.dot").toString(), new File(getOutputDirectory(), "tables/tablegraph.svg").toString());
+				dotToFile( cmd, new File(getOutputDirectory(), "tables/tablegraph.dot").toString(), new File(getOutputDirectory(), "tables/tablegraph.cmap").toString());
+			
+				return true;
+
+			}
+			catch (IOException e) {
+				throw new HibernateException("Problem while generating DOT graph for Configuration", e);
+			}
+		} else {
+			log.info( "Skipping entitygraph creation since dot.executable is empty or not-specified." );
+			return false;
+		}
+	}
+
+	public static final String OS_NAME = System.getProperty("os.name");    
+    public static final boolean IS_LINUX = OS_NAME.startsWith("Linux");    
+	
+	private String escape(String fileName){
+		
+		// Linux does not need " " around file names
+		if (IS_LINUX){
+			return fileName;
+		}
+		
+		// Windows needs " " around file names; actually we do not 
+		// need it always, only when spaces are present;
+		// but it does not hurt to usem them always
+		return "\"" + fileName + "\"";
+		
+	}
+	
+	private void dotToFile(String dotExeFileName, String dotFileName, String outFileName) throws IOException {
+
+		//
+		// dot.exe works by taking *.dot file and piping 
+		// results into another file, for example:
+		// d:\graphviz-1.12\bin\dot.exe -Tgif c:\temp\ManualDraw.dot > c:\temp\ManualDraw.gif
+		// so we follow that model here and read stdout until EOF
+		// 
+	
+		final String exeCmd = 
+			escape(dotExeFileName) + 
+			" -T" + getFormatForFile(outFileName) + " " + 
+			escape(dotFileName) +
+			" -o " + 
+			escape(outFileName);			
+	
+		Process p = Runtime.getRuntime().exec(exeCmd);
+		//p.getErrorStream().
+		try {
+			log.debug( "Executing: " + exeCmd );
+//			 Get the input stream and read from it
+	        InputStream in = p.getErrorStream();
+	        int c;
+	        while ((c = in.read()) != -1) {
+	            System.out.print((char)c);
+	        }
+	        in.close();
+			int i = p.waitFor( );
+			if(i!=0) {
+				//TODO: dump system.err
+				log.error("Error " + i + " while executing: " + exeCmd);				
+			}
+		} catch(Exception ie){
+			log.error( "Error while executing: " + exeCmd, ie );
+		}
+	}		
+
+	private String getFormatForFile(String outFileName){
+		int idx = outFileName.lastIndexOf(".");
+		if (idx == -1 || idx == outFileName.length() - 1){
+			throw new IllegalArgumentException("Can't determine file name extention for file name " + outFileName); 
+		}
+		return outFileName.substring(idx + 1);
+	}
+	
+
 	protected void setupContext() {
 		getProperties().put("jdk5", "" + useJdk5());
 		super.setupContext();
@@ -207,7 +317,7 @@
         Map parameters = new HashMap();
         parameters.put("docFile", docFile);
 
-        processTemplate(parameters, VM_TABLES_INDEX, file);
+        processTemplate(parameters, FTL_TABLES_INDEX, file);
     }
     
     /**
@@ -218,28 +328,51 @@
     	File file = docFile.getFile();
     	Map parameters = new HashMap();
     	parameters.put("docFile", docFile);
-    	processTemplate(parameters, VM_ENTITIES_INDEX, file );
+    	processTemplate(parameters, FTL_ENTITIES_INDEX, file );
     }
 
     /**
      * Generate a file with an summary of all the tables.
+     * @param graphsGenerated 
      */
-    public void generateTablesSummary() {
+    public void generateTablesSummary(boolean graphsGenerated) {
         DocFile docFile = docFileManager.getTableSummaryDocFile();
 
         File file = docFileManager.getTableSummaryDocFile().getFile();
 
         Map parameters = new HashMap();
         parameters.put("docFile", docFile);
+        parameters.put( "graphsGenerated", Boolean.valueOf( graphsGenerated ) );
+        if(graphsGenerated) {
+        	StringBuffer sb = new StringBuffer();
+        	String fileName = "tables/tablegraph.cmap";
+        	appendFile( sb, fileName );
+            parameters.put( "tablegrapharea", sb );
+        }
+        
+        processTemplate(parameters, FTL_TABLES_SUMMARY, file);
+    }
 
-        processTemplate(parameters, VM_TABLES_SUMMARY, file);
-    }
+	private void appendFile(StringBuffer sb, String fileName) {
+		try {
+			BufferedReader in = new BufferedReader(new FileReader(new File(getOutputDirectory(), fileName)));
+		    String str;
+		    
+		    while ((str = in.readLine()) != null) {
+		        sb.append(str);
+		        sb.append(System.getProperty("line.separator"));
+		    }
+		    
+		    in.close();
+		} catch (IOException e) {
+		}
+	}
     
     /**
      * Generate summary (summaty.html) to show all the packages 
      *
      */
-    public void generatePackageSummary(){
+    public void generatePackageSummary(boolean graphsGenerated){
     	DocFile docFile = docFileManager.getClassSummaryFile(); 
     	File file = docFile.getFile();
     	
@@ -250,8 +383,15 @@
         //Remove All Classes
         list.remove(0);
         parameters.put("packageList", list );
-        
-    	processTemplate(parameters, VM_ENTITIES_SUMMARY, file);
+        parameters.put( "graphsGenerated", Boolean.valueOf( graphsGenerated ) );
+        if(graphsGenerated) {
+        	StringBuffer sb = new StringBuffer();
+        	String fileName = "entities/entitygraph.cmap";
+        	appendFile( sb, fileName );
+            parameters.put( "entitygrapharea", sb );
+        }
+
+    	processTemplate(parameters, FTL_ENTITIES_SUMMARY, file);
     }
 
     /**
@@ -270,7 +410,7 @@
             	parameters.put("docFile", docFile);
             	parameters.put("table", table);
 
-            	processTemplate(parameters, VM_TABLES_TABLE, file);
+            	processTemplate(parameters, FTL_TABLES_TABLE, file);
             }
         }
     }
@@ -291,7 +431,7 @@
     		Map parameters = new HashMap();
     		parameters.put("docFile", docFile);
     		parameters.put("class", pcObj);    		
-    		processTemplate(parameters, VM_ENTITIES_ENTITY, file);
+    		processTemplate(parameters, FTL_ENTITIES_ENTITY, file);
     	}
     }
     
@@ -312,7 +452,7 @@
         list.remove(0);
         parameters.put("packageList", list );
 
-        processTemplate(parameters, VM_ENTITIES_PACKAGE_LIST, file);
+        processTemplate(parameters, FTL_ENTITIES_PACKAGE_LIST, file);
     } 
     
     /**
@@ -329,7 +469,7 @@
         parameters.put("title", "All Entities");
         parameters.put("classList", docHelper.getClasses());  
 
-        processTemplate(parameters, VM_ENTITIES_ENTITY_LIST, file);
+        processTemplate(parameters, FTL_ENTITIES_ENTITY_LIST, file);
     }
     
     /**
@@ -350,7 +490,7 @@
                 parameters.put("docFile", docFile);
                 parameters.put("title", packageName);
                 parameters.put("classList", docHelper.getClasses(packageName));
-                processTemplate(parameters, VM_ENTITIES_PERPACKAGE_ENTITY_LIST, file);
+                processTemplate(parameters, FTL_ENTITIES_PERPACKAGE_ENTITY_LIST, file);
             	
             }
 
@@ -375,7 +515,7 @@
             parameters.put("package", packageName);           
             parameters.put("classList", docHelper.getClasses(packageName));                       
 
-            processTemplate(parameters, VM_ENTITIES_PACKAGE_SUMMARY,
+            processTemplate(parameters, FTL_ENTITIES_PACKAGE_SUMMARY,
                     summaryDocFile.getFile() );
         }
     }    
@@ -393,7 +533,7 @@
         parameters.put("title", "Schema List");
         parameters.put("schemaList", docHelper.getSchemas() );
 
-        processTemplate(parameters, VM_TABLES_SCHEMA_LIST, file);
+        processTemplate(parameters, FTL_TABLES_SCHEMA_LIST, file);
     }
 
     /**
@@ -409,7 +549,7 @@
         parameters.put("title", "All Tables");
         parameters.put("tableList", docHelper.getTables() );
 
-        processTemplate(parameters, VM_TABLES_TABLE_LIST, file);
+        processTemplate(parameters, FTL_TABLES_TABLE_LIST, file);
     }
 
     public void generateTablesSchemaTableList() {
@@ -427,7 +567,7 @@
             parameters.put("title", "Tables for " + schemaName);
             parameters.put("tableList", docHelper.getTables(schemaName) );
 
-            processTemplate(parameters, VM_TABLES_TABLE_LIST, file);
+            processTemplate(parameters, FTL_TABLES_TABLE_LIST, file);
         }
     }
 
@@ -446,7 +586,7 @@
             parameters.put("docFile", summaryDocFile);
             parameters.put("schema", schemaName);
 
-            processTemplate(parameters, VM_TABLES_SCHEMA_SUMMARY,
+            processTemplate(parameters, FTL_TABLES_SCHEMA_SUMMARY,
                     summaryDocFile.getFile() );
 
             DocFile tableListDocFile = docFileManager.getSchemaSummaryDocFile(schemaName);
@@ -455,8 +595,10 @@
             parameters.put("docFile", tableListDocFile);
             parameters.put("schema", schemaName);
 
-            processTemplate(parameters, VM_TABLES_SCHEMA_SUMMARY,
+            processTemplate(parameters, FTL_TABLES_SCHEMA_SUMMARY,
                     tableListDocFile.getFile() );
+            
+            //processTemplate( new HashMap(), templateName, outputFile );
         }
     }
 

Modified: trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/XMLPrettyPrinter.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/XMLPrettyPrinter.java	2006-10-03 22:21:15 UTC (rev 10546)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/XMLPrettyPrinter.java	2006-10-03 23:50:05 UTC (rev 10547)
@@ -17,7 +17,6 @@
 import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.io.Writer;
-import java.util.Arrays;
 import java.util.Properties;
 
 import org.apache.commons.logging.Log;

Modified: trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocFileManager.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocFileManager.java	2006-10-03 22:21:15 UTC (rev 10546)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocFileManager.java	2006-10-03 23:50:05 UTC (rev 10547)
@@ -132,6 +132,10 @@
      * Map with package class lists DocFiles keyed by package name
      */
     private Map packageEntityListDocFile = new HashMap();
+
+    public DocFolder getRootDocFolder() {
+		return rootDocFolder;
+	}
     
     /**
      * Constructor.

Modified: trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/jtidy.properties
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/jtidy.properties	2006-10-03 22:21:15 UTC (rev 10546)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/jtidy.properties	2006-10-03 23:50:05 UTC (rev 10547)
@@ -6,4 +6,5 @@
 clean=yes
 output-xml=yes
 input-xml=yes
-show-warnings=yes
\ No newline at end of file
+show-warnings=yes
+trim-empty-elements=yes
\ No newline at end of file

Modified: trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/EntityNameFromValueVisitor.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/EntityNameFromValueVisitor.java	2006-10-03 22:21:15 UTC (rev 10546)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/EntityNameFromValueVisitor.java	2006-10-03 23:50:05 UTC (rev 10547)
@@ -1,8 +1,16 @@
 package org.hibernate.tool.hbm2x.visitor;
 
+import org.hibernate.mapping.Array;
+import org.hibernate.mapping.Bag;
+import org.hibernate.mapping.Collection;
+import org.hibernate.mapping.Component;
+import org.hibernate.mapping.List;
 import org.hibernate.mapping.ManyToOne;
+import org.hibernate.mapping.Map;
 import org.hibernate.mapping.OneToMany;
 import org.hibernate.mapping.OneToOne;
+import org.hibernate.mapping.PrimitiveArray;
+import org.hibernate.mapping.SimpleValue;
 import org.hibernate.mapping.ToOne;
 
 public class EntityNameFromValueVisitor extends DefaultValueVisitor {
@@ -26,5 +34,39 @@
 	public Object accept(OneToMany value) {
 		return value.getAssociatedClass().getEntityName();
 	}
-		
+	
+	public Object acceptCollection(Collection c) {
+		return c.getElement().accept( this );
+	}
+	
+	public Object accept(Bag o) {
+		return acceptCollection( o );
+	}
+	
+	public Object accept(List o) {
+		return acceptCollection( o );
+	}
+	
+	public Object accept(Map o) {
+		return acceptCollection( o );
+	}
+	
+	public Object accept(Array o) {
+		return acceptCollection( o );
+	}
+	
+	public Object accept(PrimitiveArray o) {
+		return acceptCollection( o );
+	}
+	
+	public Object accept(SimpleValue o) {
+		return null; // TODO: return o.getTypeName() ? (it is not an association)
+	}
+	
+	public Object accept(Component component) {
+		if(component.isDynamic()) {
+			return null; //"java.util.Map"; (not an association)
+		}
+		return component.getComponentClassName();
+	}
 }

Modified: trunk/HibernateExt/tools/src/templates/doc/entities/summary.ftl
===================================================================
--- trunk/HibernateExt/tools/src/templates/doc/entities/summary.ftl	2006-10-03 22:21:15 UTC (rev 10546)
+++ trunk/HibernateExt/tools/src/templates/doc/entities/summary.ftl	2006-10-03 23:50:05 UTC (rev 10547)
@@ -14,6 +14,15 @@
 
 <H1>Hibernate Mapping Documentation</H1>
 
+<#if graphsGenerated>
+<p>
+ <img src="entitygraph.png" usemap="#entitygraph"/>
+  <map name="entitygraph">
+  ${entitygrapharea}
+ </map>
+</p>
+</#if>
+
 <H2>List of Packages</H2>
 
 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0">

Modified: trunk/HibernateExt/tools/src/templates/doc/index.html
===================================================================
--- trunk/HibernateExt/tools/src/templates/doc/index.html	2006-10-03 22:21:15 UTC (rev 10546)
+++ trunk/HibernateExt/tools/src/templates/doc/index.html	2006-10-03 23:50:05 UTC (rev 10547)
@@ -12,7 +12,7 @@
 
 <FRAMESET rows="50px,80%">
 	<FRAME src="header.html" name="headerFrame" title="Header">
-	<FRAME src="tables/index.html" name="mainFrame" title="Main">
+	<FRAME src="entities/index.html" name="mainFrame" title="Main">
 	<NOFRAMES>
 		<H2>Frame Alert</H2>
 		This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web browser.

Modified: trunk/HibernateExt/tools/src/templates/doc/tables/summary.ftl
===================================================================
--- trunk/HibernateExt/tools/src/templates/doc/tables/summary.ftl	2006-10-03 22:21:15 UTC (rev 10546)
+++ trunk/HibernateExt/tools/src/templates/doc/tables/summary.ftl	2006-10-03 23:50:05 UTC (rev 10547)
@@ -14,6 +14,15 @@
 
 <H1>Hibernate Mapping Documentation</H1>
 
+<#if graphsGenerated>
+<p>
+ <img src="tablegraph.png" usemap="#tablegraph"/>
+ <map name="tablegraph">
+  ${tablegrapharea}
+ </map>
+</p>
+</#if>
+
 <H2>List of Tables by Schema</H2>
 
 <#foreach schema in dochelper.tablesBySchema.keySet()>

Modified: trunk/HibernateExt/tools/src/templates/dot/entitygraph.dot.ftl
===================================================================
--- trunk/HibernateExt/tools/src/templates/dot/entitygraph.dot.ftl	2006-10-03 22:21:15 UTC (rev 10546)
+++ trunk/HibernateExt/tools/src/templates/dot/entitygraph.dot.ftl	2006-10-03 23:50:05 UTC (rev 10547)
@@ -23,10 +23,10 @@
 
 <#foreach entity in cfg.classMappings> 
   /* Node ${entity.entityName} */
-  <@nodeName entity.entityName/> [ label = "<@propertyLabels name=entity.entityName properties=entity.propertyIterator/>" ]  
+  <@nodeName entity.entityName/> [ label = "<@propertyLabels name=entity.entityName properties=entity.propertyIterator/>", URL="${entity.entityName?replace(".","/")}.html" ]
   /* Subclass edges for ${entity.entityName} */
   <#foreach subclass in entity.getDirectSubclasses()>
-     <@nodeName subclass.entityName/> -> <@nodeName entity.entityName/>  [ weight="10", arrowhead="onormal" ]
+     <@nodeName subclass.entityName/> -> <@nodeName entity.entityName/>  [ weight="10", arrowhead="onormal"  ]
   </#foreach>
   
   <@propertyEdges root=entity.entityName?replace(".","_dot_") properties=entity.propertyIterator/>     




More information about the hibernate-commits mailing list