This is a work-in-progress commit while trying to produce grand unified ADL.

Applied Sweepers /does/ build with this version; SRU still /does not/ build with
this version.
This commit is contained in:
sb 2008-05-21 13:00:55 +00:00
parent 1abaead774
commit be2cc24ea7
6 changed files with 1911 additions and 1893 deletions

View file

@ -9,8 +9,8 @@
Transform ADL into (partial) controller classes
$Author: sb $
$Revision: 1.29 $
$Date: 2008-05-19 14:49:18 $
$Revision: 1.30 $
$Date: 2008-05-21 13:00:56 $
-->
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
@ -39,39 +39,34 @@
<!-- Whether to authenticate at application or at database layer.
If not 'Application', then 'Database'. -->
<xsl:param name="authentication-layer" select="Application"/>
<!--
The convention to use for naming auto-generated abstract primary keys. Known values are
Id - the autogenerated primary key, if any, is called just 'Id'
Name - the autogenerated primary key has the same name as the entity
NameId - the name of the auto generated primary key is the name of the entity followed by 'Id'
Name_Id - the name of the auto generated primary key is the name of the entity followed by '_Id'
-->
<xsl:param name="abstract-key-name-convention" select="Id"/>
<!-- the name and version of the product being built -->
<xsl:param name="product-version" select="'Application Description Language Framework'"/>
<!-- bug 1800 : the name of the Velocity layout to use -->
<xsl:param name="layout-name" select="adl-default-layout"/>
<!-- bug 1800 : the name of the Velocity rescue view to use -->
<xsl:param name="rescue-name" select="adl-default-rescue"/>
<xsl:param name="rescue-name"/>
<!-- bug 1800 : the name of the area (i.e. URL path part) to use -->
<xsl:param name="area-name" select="auto"/>
<xsl:param name="area-name"/>
<xsl:template match="adl:application">
<xsl:call-template name="collection-factory"/>
<xsl:apply-templates select="adl:entity"/>
</xsl:template>
<xsl:template name="collection-factory">
<xsl:template name="collection-factory">
/* ---- [ cut here: next file '<xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller')"/>.auto.cs'] ---------------- */
//------------------------------------------------------------------
//
// Application Description Language framework
// <xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller')"/>.auto.cs
// <xsl:value-of select="$product-version"/>
// <xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller.auto.cs')"/>
//
// (c) 2007 Cygnet Solutions Ltd
//
// Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s
// Automatically generated from application description using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.29 $', 10)"/>
// Automatically generated abstract super class for controllers for the
// <xsl:value-of select="/adl:application/@name"/> application; generated using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.30 $', 10)"/>
//
// This file is automatically generated; DO NOT EDIT IT.
//
@ -82,53 +77,59 @@ using System.Data;
using System.Collections.Generic;
using NHibernate;
using NHibernate.Expression;
using Cygnet.Web.Controllers;
using <xsl:value-of select="$entityns"/>;
namespace <xsl:value-of select="$controllerns"/> {
/// &lt;summary&gt;
/// Automatically generated abstract super class for controllers for the
/// <xsl:value-of select="/adl:application/@name"/> application
///
/// DO NOT EDIT THIS FILE!
/// &lt;/summary&gt;
public abstract partial class <xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller')"/> : BaseController {
<xsl:for-each select="//adl:entity">
/// &lt;summary&gt;
/// Return a list of all instances of <xsl:value-of select="@name"/> for use in menus, etc;
/// &lt;/summary&gt;
protected IList&lt;<xsl:value-of select="concat( $entityns, '.', @name)"/>&gt; <xsl:value-of select="concat( 'FetchAll', @name)"/>( ISession hibernator) {
return hibernator.CreateCriteria(typeof(<xsl:value-of select="concat( $entityns, '.', @name)"/>))
<xsl:for-each select="descendant::adl:property[@distinct='user']">
.AddOrder( <xsl:value-of select="concat('new Order( &#34;', @name, '&#34;, true)')"/>)
</xsl:for-each>
.SetCacheable( true)
.SetCacheRegion( "<xsl:value-of select="/adl:application/@name"/>")
.List&lt;<xsl:value-of select="concat( $entityns, '.', @name)"/>&gt;();
}
/// &lt;summary&gt;
/// Automatically generated abstract super class for controllers for the
/// <xsl:value-of select="/adl:application/@name"/> application
///
/// DO NOT EDIT THIS FILE!
/// &lt;/summary&gt;
public abstract partial class <xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller')"/> : BaseController {
<xsl:for-each select="//adl:entity">
/// &lt;summary&gt;
/// Return a list of all instances of <xsl:value-of select="@name"/> for use in menus, etc;
/// &lt;/summary&gt;
protected IList&lt;<xsl:value-of select="concat( $entityns, '.', @name)"/>&gt; <xsl:value-of select="concat( 'FetchAll', @name)"/>( ISession hibernator) {
return hibernator.CreateCriteria(typeof(<xsl:value-of select="concat( $entityns, '.', @name)"/>))
<xsl:for-each select="descendant::adl:property[@distinct='user']">
.AddOrder( <xsl:value-of select="concat('new Order( &#34;', @name, '&#34;, true)')"/>)
</xsl:for-each>
.SetCacheable( true)
.SetCacheRegion( "<xsl:value-of select="/adl:application/@name"/>")
.List&lt;<xsl:value-of select="concat( $entityns, '.', @name)"/>&gt;();
}
</xsl:for-each>
</xsl:for-each>
}
}
</xsl:template>
}
</xsl:template>
<!-- Don't bother generating anything for foreign entities -->
<xsl:template match="adl:entity[@foreign='true']"/>
<xsl:template match="adl:entity">
<xsl:comment>Not generating controller for entity <xsl:value-of select="@name"/>,
as it has no forms, pages or lists.
</xsl:comment>
</xsl:template>
<xsl:template match="adl:entity[adl:form|adl:page|adl:list]">
/* ---- [ cut here: next file '<xsl:value-of select="@name"/>Controller.auto.cs'] ---------------- */
//------------------------------------------------------------------
//
// Application Description Language framework
// <xsl:value-of select="$product-version"/>
// <xsl:value-of select="@name"/>Controller.auto.cs
//
// (c) 2007 Cygnet Solutions Ltd
//
// Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s
// Automatically generated from application description using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.29 $', 10)"/>
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.30 $', 10)"/>
//
// This file is automatically generated; DO NOT EDIT IT.
//
@ -166,8 +167,12 @@ namespace <xsl:value-of select="$controllerns"/> {
/// DO NOT EDIT THIS FILE!
/// &lt;/summary&gt;
[
<xsl:if test="$layout-name">
Layout("<xsl:value-of select="$layout-name"/>"),
Rescue("<xsl:value-of select="$rescue-name"/>"),
</xsl:if>
<xsl:if test="$rescue-name">
Rescue("<xsl:value-of select="$rescue-name"/>"),
</xsl:if>
ControllerDetails("<xsl:value-of select="@name"/>", Area = "<xsl:value-of select="$area-name"/>"),
Helper(typeof(<xsl:value-of select="concat( @name, 'FieldHelper')"/>), "<xsl:value-of select="concat( @name, 'FieldHelper')"/>")
]
@ -196,7 +201,35 @@ namespace <xsl:value-of select="$controllerns"/> {
}
}
<xsl:if test="adl:form">
<xsl:if test="adl:property[@type='message']">
/// &lt;summary&gt;
/// Temporary hack to sort a problem with uninitialised messages
/// &lt;/summary&gt;
public void fixupMessages() {
ISession hibernator =
NHibernateHelper.GetCurrentSession( <xsl:if test="$authentication-layer = 'Database'">Session[ NHibernateHelper.USERTOKEN],
Session[NHibernateHelper.PASSTOKEN]</xsl:if>);
ICollection&lt;<xsl:value-of select="concat($entityns, '.', @name)"/>&gt; instances =
hibernator.CreateCriteria( typeof( <xsl:value-of select="concat($entityns, '.', @name)"/>))
.List&lt;<xsl:value-of select="concat($entityns, '.', @name)"/>&gt;();
foreach ( <xsl:value-of select="concat($entityns, '.', @name)"/> instance in instances) {
<xsl:for-each select="adl:property[@type='message']">
if ( <xsl:value-of select="concat( 'instance.', @name)"/> == null || <xsl:value-of select="concat( 'instance.', @name, '.MessageId')"/> == 0 ){
<xsl:value-of select="concat( 'instance.', @name)"/> = new Message();
hibernator.Save( <xsl:value-of select="concat( 'instance.', @name)"/>);
}
</xsl:for-each>
hibernator.Save( instance);
}
hibernator.Flush();
<xsl:if test="adl:list[@name='list']">
list();
</xsl:if>
}
</xsl:if>
<xsl:if test="adl:form">
<!-- unless there's at least one form, we won't generate a 'store' method -->
/// &lt;summary&gt;
/// Store the record represented by the parameters passed in an HTTP service
@ -960,23 +993,25 @@ namespace <xsl:value-of select="$controllerns"/> {
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
/* form menus */
<xsl:for-each select="$form//adl:field">
<xsl:variable name="propname" select="@property"/>
<xsl:choose>
<xsl:when test="parent::adl:auxlist"/>
<xsl:when test="$form/ancestor::adl:entity/adl:property[@name=$propname and @type='entity']">
/* produce a list of <xsl:value-of select="$form/ancestor::adl:entity/adl:property[@name=$propname]/@entity"/> to populate the select for <xsl:value-of select="$propname"/> */
/* produce a list of <xsl:value-of select="$form/ancestor::adl:entity/adl:property[@name=$propname]/@entity"/> to populate the select for <xsl:value-of select="$propname"/> */
<xsl:call-template name="menu">
<xsl:with-param name="property" select="$form/ancestor::adl:entity/adl:property[@name=$propname]"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$form/ancestor::adl:entity/adl:property[@name=$propname and @type='link']">
/* produce a list of <xsl:value-of select="$form/ancestor::adl:entity/adl:property[@name=$propname]/@entity"/> to populate the LHS of the shuffle for <xsl:value-of select="$propname"/> */
/* produce a list of <xsl:value-of select="$form/ancestor::adl:entity/adl:property[@name=$propname]/@entity"/> to populate the LHS of the shuffle for <xsl:value-of select="$propname"/> */
<xsl:call-template name="menu">
<xsl:with-param name="property" select="$form/ancestor::adl:entity/adl:property[@name=$propname]"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$form/ancestor::adl:entity/adl:property[@name=$propname and @type='list']">
/* produce a list of <xsl:value-of select="$form/ancestor::adl:entity/adl:property[@name=$propname]/@entity"/> to populate the multi-select for <xsl:value-of select="@name"/> */
/* produce a list of <xsl:value-of select="$form/ancestor::adl:entity/adl:property[@name=$propname]/@entity"/> to populate the multi-select for <xsl:value-of select="@name"/> */
<xsl:call-template name="menu">
<xsl:with-param name="property" select="$form/ancestor::adl:entity/adl:property[@name=$propname]"/>
</xsl:call-template>
@ -1026,7 +1061,7 @@ namespace <xsl:value-of select="$controllerns"/> {
<xsl:template name="menu">
<xsl:param name="property"/>
<xsl:variable name="entity" select="//adl:entity[@name=$property/@entity]"/>
<xsl:value-of select="concat('all_', $property/@name)"/> =
<xsl:value-of select="concat('all_', $property/@name)"/> =
<xsl:value-of select="concat( 'FetchAll', $entity/@name)"/>( NHibernateHelper.GetCurrentSession()),
</xsl:template>