Changeset 2402


Ignore:
Timestamp:
11/01/09 13:33:29 (2 years ago)
Author:
mswertz
Message:

enhancement: added generator for csv documentation.

Location:
molgenis/3.3/src/org/molgenis
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • molgenis/3.3/src/org/molgenis/Molgenis.java

    r2347 r2402  
    3939import org.molgenis.generators.db.PStatementMapperGen; 
    4040import org.molgenis.generators.db.ViewMapperGen; 
     41import org.molgenis.generators.doc.CsvDocGen; 
    4142import org.molgenis.generators.doc.DotDocGen; 
    4243import org.molgenis.generators.doc.DotDocMinimalGen; 
     
    117118                generators.add(new EntityModelDocGen()); 
    118119                generators.add(new DotDocGen()); 
     120                generators.add(new CsvDocGen()); 
    119121                generators.add(new DotDocMinimalGen()); 
    120122                generators.add(new ObjectModelDocGen()); 
  • molgenis/3.3/src/org/molgenis/generators/doc/CsvDocGen.java

    r2315 r2402  
    3131                Map<String, Object> templateArgs = createTemplateArguments(options); 
    3232 
    33                 File target = new File(this.getDocumentationPath( options ) +"/tab-delimited-format.html");              
     33                File target = new File(this.getDocumentationPath( options ) +"/tab-format-reference.html");              
    3434                target.getParentFile().mkdirs(); 
    3535                 
  • molgenis/3.3/src/org/molgenis/generators/doc/CsvDocGen.java.ftl

    r1851 r2402  
    66                </#if> 
    77                <#if item?is_hash> 
    8                         <#local result = result + item.name> 
     8                        <#local result = result + item.name?lower_case> 
    99                <#else> 
    10                         <#local result = result + "'"+item+"'"> 
     10                        <#local result = result + "'"+item?lower_case+"'"> 
    1111                </#if> 
    1212        </#list> 
    1313        <#return result> 
    1414</#function> 
     15 
     16<#macro render_field field> 
     17        <tr> 
     18                <td width="150">${field.name?lower_case}<#if field.type == "xref" || field.type =="mref">_${field.getXRefLabelString()?lower_case}</#if></td> 
     19                <td width="50">${field.type}</td> 
     20                <td width="20"><#if !field.isNillable() && !field.isAuto()>Y<#else>&nbsp;</#if></td> 
     21                <td><#if field.type == "xref" || field.type =="mref"> Reference to a value in column '${field.getXRefLabelString()?lower_case}' in ${field.getXRefEntity()?lower_case}.txt</a>.  
     22                <#if field.type="mref">Multiple references can be added separated by '|'.</#if><#else>${field.description}</#if></td> 
     23        </tr>    
     24</#macro> 
     25 
     26 
     27<#macro render_entity entity> 
     28<h3>${entity.name?lower_case}.txt file</h3>  
     29<p>${entity.description}The file ${entity.name?lower_case}.txt can have the following fields:</p> 
     30<table width="100%" cellspacing="0" border="1" bordercolor="#000000"> 
     31        <!-- table header --> 
     32        <tr> 
     33                <th>column name</th> 
     34                <th>type</th> 
     35                <th>required?</th> 
     36                <th>description</th> 
     37        </tr> 
     38         
     39        <!-- all required fields --> 
     40<#list entity.allFields as field><#if field.name != "type" && !field.isNillable() && !field.isAuto()> 
     41        <@render_field field/> 
     42</#if></#list> 
     43        <!-- all optional fields --> 
     44<#list entity.allFields as field><#if field.name != "type" && (field.isNillable() || field.isAuto())> 
     45        <@render_field field/> 
     46</#if></#list> 
     47</table> 
     48        <!-- all the uniques --> 
     49<#assign index = 0> 
     50<#list entity.allKeys as key> 
     51        <#if key.fields?size &gt; 1> 
     52Note that values in the combined columns (${csv(key.fields)}) should be unique.<br/> 
     53        <#else> 
     54Note that values in column ${csv(key.fields)} should unique.<br/> 
     55        </#if> 
     56</#list> 
     57</#macro>        
     58 
    1559<html> 
    1660 
    1761<head> 
    18         <title>Database-schema: ${model.name}</title> 
     62        <title>${model.name} TAB format reference documentation</title> 
    1963         
    2064        <meta name="keywords"                   content=""> 
     
    58102 
    59103<body> 
    60 <h1>Database schema <a name="_top_of_page">"${model.name}"</a></h1> 
    61 <p>Notes: 
     104<h1>TAB format reference documentation</h1> 
     105<#if model.getDBDescription()?exists><p>${model.getDBDescription()}</p></#if> 
     106<p> 
     107This document describes what columns will be parsed by the ${model.name} CsvImport and CsvExport programs, as well as the upload options in the user interface.  
     108Note that this is autogenerated documentation; more files may be recognized by handwritten extensions.The following files are recognized (grouped by topic):</p> 
     109<!-- per module --> 
     110<#list model.modules as module> 
     111<p><b>${module.name}</b> package: 
    62112<ul> 
    63 <li/>"Extends" means that an entity has the same fields as the enitity it extends, plus some more. An entity can extend only one other entity. 
    64 <li/>"Implements" means that an entity adds the fields of the "interface" entity to its own. An entity can implement many other entities. 
    65 <li/>The root of an "extends" tree comes with an "Interface" tabel to manage the primary keys for the whole inheritance tree. 
    66 <li/>Link entities are generated for "mrefs", that are foreignkeys in a many-to-many relationship. 
    67 <li/>Each entity will translate to a table, with the exception of "interfaces". 
     113<#list module.entities as entity><#if !entity.abstract && !entity.association> 
     114<li><a href="#${entity.name}">${entity.name?lower_case}.txt</a> 
     115</#if></#list> 
    68116</ul> 
    69 <h2>Entities:</h2> 
    70 <ol> 
    71 <#list model.entities as entity> 
    72 <li><a href="#${entity.name}">${entity.name}</a> 
     117</p> 
    73118</#list> 
    74 </ol> 
    75 <#list model.entities as entity> 
    76 <h2>Table: <a name="${entity.name}">${entity.name}</a><#if entity.isAbstract()> (interface).</#if>  
    77 </h2> 
    78 <p>${entity.description}</p> 
    79 <table width="100%" cellspacing="0" border="1" bordercolor="#000000"> 
    80         <!-- table header --> 
    81         <tr><th class="tablehead" colspan="6">${entity.name}<#if entity.hasAncestor()> extends ${entity.getAncestor().getName()}</#if> 
    82 <#if entity.hasImplements()> implements ${csv(entity.getImplements())}</#if></th></tr>   
    83         <!-- column headers --> 
    84         <tr> 
    85                 <th>attribute</th> 
    86                 <th>type</th> 
    87                 <th>NULL?</th> 
    88                 <th>AUTO?</th> 
    89                 <th>constraints</th> 
    90                 <th>description</th> 
    91         </tr> 
    92          
    93         <!-- all the fields --> 
    94 <#list entity.fields as field> 
    95         <tr> 
    96                 <td width="150">${field.name}</td> 
    97                 <td width="50">${field.type}</td> 
    98                 <td width="20"><#if field.isNillable()>Y<#else>&nbsp;</#if></td> 
    99                 <td width="20"><#if field.isAuto()>Y<#else>&nbsp;</#if></td> 
    100                 <td width=""> 
    101 <#if field.type == "enum"> 
    102                 ENUM options: ${csv( field.getEnumOptions() )} 
    103 <#elseif field.type=="xref"> 
    104                 References(${field.getXRefEntity()}) 
    105 <#elseif field.type=="mref"> 
    106                 References(${field.getXRefEntity()}) via linktable.      
    107 <#else> 
    108                 &nbsp; 
    109 </#if>                           
    110                 </td> 
    111                 <td>${field.description}</td> 
    112         </tr> 
    113 </#list> 
    114          
    115         <!-- all the uniques --> 
    116 <#assign index = 0> 
    117 <#list entity.keys as key> 
    118         <tr> 
    119                 <td colspan="5"><#if index == 0>Primary key<#else>Secondary key</#if>(${csv(key.fields)})</td> 
    120                 <#assign index = index + 1> 
    121                 <td>&nbsp;</td> 
    122         </tr> 
    123 </#list> 
    124         <!-- all the indices --> 
    125 <#--list entity.indices as index> 
    126         <tr> 
    127                 <td>Index</td> 
    128                 <td>${index.getName()}</td> 
    129                 <td colspan="2"><#list index.getFields() as field>${field.getName()}, </#list></td> 
    130         </tr> 
    131 </#list--> 
    132          
    133 </table> 
    134 <a href="#_top_of_page">go to top</a> 
    135 <p /> 
     119Below, the columns for each of these file types are detailed: 
     120 
     121 
     122<!-- entities inside modules --> 
     123<#list model.modules as module> 
     124<h2>${module.name} package</h2> 
     125<#if module.description?exists><p>${module.description}</p></#if> 
     126<#list module.entities as entity><#if !entity.abstract && !entity.association> 
     127<@render_entity entity/> 
     128</#if></#list> 
    136129</#list> 
    137130 
  • molgenis/3.3/src/org/molgenis/model/MolgenisModelParser.java

    r2317 r2402  
    773773 
    774774                // construct 
    775                 Module module = new Module(element.getAttribute("name"), model); 
     775                Module module = new Module(model.getName()+"."+element.getAttribute("name"), model); 
    776776 
    777777                // DESCRIPTION 
     
    790790                        Element elem = (Element) elements.item(j); 
    791791                        Entity e = parseEntity(model, elem); 
    792                         e.setNamespace(e.getNamespace() + "." + module.getName()); 
     792                        e.setNamespace(module.getName()); 
    793793                        module.getEntities().add(e); 
    794794                        e.setModule(module); 
Note: See TracChangeset for help on using the changeset viewer.