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

@ -20,8 +20,8 @@
explicitly state the permission, even if it is 'none'.
$Author: sb $
$Revision: 1.9 $
$Date: 2008-05-09 16:12:12 $
$Revision: 1.10 $
$Date: 2008-05-21 13:00:55 $
-->
<xsl:stylesheet version="1.0"
@ -41,6 +41,10 @@
-->
<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'"/>
<!-- a prefix to prepend to all tablenames -->
<xsl:param name="tablename-prefix"/>
@ -58,13 +62,13 @@
<xsl:comment>
***************************************************************************
*
* Application Description Language framework
* <xsl:value-of select="$product-version"/>
* ©2007 Cygnet Solutions Ltd
*
* THIS FILE IS AUTOMATICALLY GENERATED AND SHOULD NOT
* BE MANUALLY EDITED.
*
* Generated using adl2canonical.xslt <xsl:value-of select="substring('$Revision: 1.9 $', 12)"/>
* Generated using adl2canonical.xslt <xsl:value-of select="substring('$Revision: 1.10 $', 12)"/>
*
***************************************************************************
</xsl:comment>
@ -96,7 +100,8 @@
</xsl:attribute>
</xsl:if>
<xsl:message terminate="no">
ADL WARNING: [In entity '<xsl:value-of select="@name"/>']: '@natural-key' is deprecated - use the 'key' sub element instead</xsl:message>
ADL WARNING: [In entity '<xsl:value-of select="@name"/>']: '@natural-key' is deprecated - use the 'key' sub element instead
</xsl:message>
<entity>
<xsl:variable name="nkey" select="@natural-key"/>
<xsl:apply-templates select="@*"/>
@ -128,6 +133,7 @@
<xsl:comment>
entity <xsl:value-of select="@name"/> has no key - generating one
</xsl:comment>
<entity>
<!-- copy attributes through -->
<xsl:apply-templates select="@*"/>

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,21 +39,16 @@
<!-- 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"/>
@ -64,14 +59,14 @@
/* ---- [ 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,6 +77,7 @@ 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"/> {
@ -115,20 +111,25 @@ namespace <xsl:value-of select="$controllerns"/> {
<!-- 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"/>"),
</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,6 +201,34 @@ namespace <xsl:value-of select="$controllerns"/> {
}
}
<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;
@ -960,9 +993,11 @@ 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"/> */
<xsl:call-template name="menu">

View file

@ -8,8 +8,8 @@
Transform ADL into entity classes
$Author: sb $
$Revision: 1.13 $
$Date: 2008-05-09 16:12:12 $
$Revision: 1.14 $
$Date: 2008-05-21 13:00:56 $
-->
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
@ -32,21 +32,16 @@
client's locale -->
<xsl:param name="locale" select="en-UK"/>
<!--
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 C# namespace within which I shall generate controllers -->
<xsl:param name="controllerns" select="Unset"/>
<!-- The C# namespace within which I shall generate entities -->
<xsl:param name="entityns" select="Unset"/>
<!-- the name and version of the product being built -->
<xsl:param name="product-version" select="'Application Description Language Framework'"/>
<xsl:template match="adl:application">
<xsl:apply-templates select="adl:entity"/>
</xsl:template>
@ -55,44 +50,18 @@
<xsl:template match="adl:entity[@foreign='true']"/>
<xsl:template match="adl:entity">
<!-- what's all this about? the objective is to get the revision number of the
transform into the output, /without/ getting that revision number overwritten
with the revision number of the generated file if the generated file is
stored to CVS -->
<xsl:variable name="transform-rev1"
select="substring( '$Revision: 1.13 $', 11)"/>
<xsl:variable name="transform-revision"
select="substring( $transform-rev1, 0, string-length( $transform-rev1) - 1)"/>
<xsl:variable name="keyfield">
<xsl:choose>
<xsl:when test="$abstract-key-name-convention='Name'">
<xsl:value-of select="@name"/>
</xsl:when>
<xsl:when test="$abstract-key-name-convention = 'NameId'">
<xsl:value-of select="concat( @name, 'Id')"/>
</xsl:when>
<xsl:when test="$abstract-key-name-convention = 'Name_Id'">
<xsl:value-of select="concat( @name, '_Id')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'Id'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
/* ---- [ cut here: next file '<xsl:value-of select="@name"/>.auto.cs'] ---------------- */
//-------------------------------------------------------------
//
// Application Description Language framework
// <xsl:value-of select="$product-version"/>
// <xsl:value-of select="@name"/>.auto.cs
//
// (c)2007 Cygnet Solutions Ltd
//
// Automatically generated from application description using
// adl2entityclass.xsl revision <xsl:value-of select="$transform-revision"/>
// adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.14 $', 10)"/>
//
// This file is automatically generated; DO NOT EDIT IT.
//
@ -114,7 +83,7 @@
/// &lt;/summary&gt;
/// &lt;remarks&gt;
/// Automatically generated from description of entity <xsl:value-of select="@name"/>
/// using adl2entityclass.xsl revision <xsl:value-of select="$transform-revision"/>.
/// using adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.14 $', 10)"/>.
/// Note that manually maintained parts of this class may be defined in
/// a separate file called <xsl:value-of select="@name"/>.manual.cs, q.v.
///
@ -152,6 +121,7 @@
<xsl:if test="not( position() = last())">, </xsl:if>
</xsl:for-each>){
<xsl:call-template name="initialise-lists"/>
<xsl:call-template name="initialise-messages"/>
<xsl:for-each select="adl:key/adl:property">
this.<xsl:value-of select="@name"/> = <xsl:value-of select="@name"/>;
@ -160,40 +130,10 @@
</xsl:when>
<xsl:otherwise>
/// &lt;summary&gt;
/// Auto-generated one-arg constructor; initialises Id slot and also all
/// one-to-many slots
/// &lt;/summary&gt;
public <xsl:value-of select="@name"/>( int key)
{
<xsl:call-template name="initialise-lists"/>
<xsl:value-of select="concat( ' _', $keyfield)"/> = key;
}
/// &lt;summary&gt;
/// Auto-generated iv for Id (abstract primary key) slot
/// &lt;/summary&gt;
private int <xsl:value-of select="concat( ' _', $keyfield)"/> = -1;
/// &lt;summary&gt;
/// Auto-generated property for Id (abstract primary key) slot
/// &lt;/summary&gt;
public virtual int <xsl:value-of select="$keyfield"/>
{
get { return <xsl:value-of select="concat( ' _', $keyfield)"/>; }
set { <xsl:value-of select="concat( ' _', $keyfield)"/> = value; }
}
/// &lt;summary&gt;
/// Auto-generated overridden property for the Key slot, maps onto
/// <xsl:value-of select="concat( ' _', $keyfield)"/>
/// &lt;/summary&gt;
[Obsolete]
public override int Key
{
get { return <xsl:value-of select="concat( ' _', $keyfield)"/>; }
}
<xsl:message terminate="yes">
ADL: ERROR: Entity '<xsl:value-of select="@name"/>' has no key. Was the
canonicalise stage missed in the build process?
</xsl:message>
</xsl:otherwise>
</xsl:choose>
/// &lt;summary&gt;
@ -282,6 +222,7 @@
<xsl:when test="@cascade='all'"/>
<xsl:when test="@cascade='all-delete-orphan'"/>
<xsl:when test="@cascade='delete'"/>
<xsl:when test="@concrete='false'"/>
<xsl:otherwise>
if ( <xsl:value-of select="concat( ' _', @name)"/> != null &amp;&amp; <xsl:value-of select="concat( ' _', @name)"/>.Count > 0) {
bob.AppendFormat("Cannot delete this <xsl:value-of select="../@name"/> as it has {0} dependent <xsl:value-of select="@name"/>; ", <xsl:value-of select="concat( ' _', @name)"/>.Count);
@ -490,17 +431,21 @@
</xsl:if>
</xsl:template>
<xsl:template name="initialise-lists">
<!-- initialise all cocrete lists and links -->
<xsl:for-each select="property[@type='list']">
<xsl:template name="initialise-messages">
<!-- each IV of type message needs to be initialised -->
<xsl:for-each select="adl:property[@type='message']">
<xsl:choose>
<xsl:when test="@concrete='false'"/>
<xsl:otherwise>
<xsl:value-of select="concat( ' _', @name)"/> = new HashedSet&lt;<xsl:value-of select="@entity"/>&gt;();
<xsl:value-of select="concat( ' _', @name)"/> = new Message();
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:for-each select="property[@type='link']">
</xsl:template>
<xsl:template name="initialise-lists">
<!-- initialise all concrete lists and links -->
<xsl:for-each select="adl:property[@type='list' or @type='link']">
<xsl:choose>
<xsl:when test="@concrete='false'"/>
<xsl:otherwise>

View file

@ -12,20 +12,14 @@
Transform ADL to Hibernate
$Author: sb $
$Revision: 1.10 $
$Revision: 1.11 $
-->
<!--
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"/>
<xsl:param name="namespace"/>
<xsl:param name="assembly"/>
<xsl:param name="database"/>
<!-- the name and version of the product being built -->
<xsl:param name="product-version" select="'Application Description Language Framework'"/>
<xsl:output indent="no" method="xml" encoding="UTF-8"/>
<!-- NOTE! indent="no" because hibernate falls over if there is whitespace inside
@ -121,7 +115,7 @@
<xsl:comment>
***************************************************************************
*
* Application Description Language framework
* <xsl:value-of select="$product-version"/>
* <xsl:value-of select="@name"/>.auto.hbm.xml
*
* ©2007 Cygnet Solutions Ltd
@ -129,7 +123,7 @@
* THIS FILE IS AUTOMATICALLY GENERATED AND SHOULD NOT
* BE MANUALLY EDITED.
*
* Generated using adl2hibernate.xslt revision <xsl:value-of select="substring('$Revision: 1.10 $', 12)"/>
* Generated using adl2hibernate.xslt revision <xsl:value-of select="substring('$Revision: 1.11 $', 12)"/>
*
***************************************************************************
</xsl:comment>
@ -316,6 +310,9 @@
</xsl:template>
<xsl:template match="adl:property[@type='message']">
<xsl:choose>
<xsl:when test="@concrete='false'"/>
<xsl:otherwise>
<many-to-one class="Message">
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
@ -328,6 +325,8 @@
</xsl:attribute>
</xsl:if>
</many-to-one>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="adl:property[@type='entity']">
@ -360,6 +359,9 @@
</one-to-one>
</xsl:when>
<xsl:otherwise -->
<xsl:choose>
<xsl:when test="@concrete='false'"/>
<xsl:otherwise>
<many-to-one>
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
@ -387,11 +389,14 @@
</xsl:choose>
<xsl:apply-templates select="adl:documentation"/>
</many-to-one>
<!-- /xsl:otherwise>
</xsl:choose -->
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="adl:property[@type='list']">
<xsl:choose>
<xsl:when test="@concrete='false'"/>
<xsl:otherwise>
<xsl:variable name="farent" select="@entity"/>
<xsl:variable name="nearent" select="ancestor::adl:entity/@name"/>
<xsl:variable name="farkey">
@ -418,10 +423,12 @@
<xsl:apply-templates select="adl:documentation"/>
<!-- careful with reformatting here:
'The element cannot contain white space. Content model is empty.' -->
<key><xsl:attribute name="column">
<key>
<xsl:attribute name="column">
<!-- this is the name of the farside foreign key field which points to me -->
<xsl:value-of select="$farkey"/>
</xsl:attribute></key>
</xsl:attribute>
</key>
<one-to-many>
<xsl:attribute name="class">
<xsl:value-of select="@entity"/>
@ -436,10 +443,15 @@
</xsl:when>
</xsl:choose>
</set>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="adl:property[@type='link']">
<!-- a property of type 'link' maps on to a Hibernate set -->
<xsl:choose>
<xsl:when test="@concrete='false'"/>
<xsl:otherwise>
<xsl:variable name="comparison">
<xsl:call-template name="stringcompare">
<xsl:with-param name="node1" select="../@name"/>
@ -486,6 +498,8 @@
</xsl:attribute>
</many-to-many>
</set>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="adl:property">

View file

@ -12,7 +12,7 @@
Convert ADL to MS-SQL
$Author: sb $
$Revision: 1.12 $
$Revision: 1.13 $
-->
<xsl:output indent="no" encoding="UTF-8" method="text"/>
@ -27,6 +27,8 @@
-->
<xsl:param name="abstract-key-name-convention" select="Id"/>
<xsl:param name="database"/>
<!-- the name and version of the product being built -->
<xsl:param name="product-version" select="'Application Description Language Framework'"/>
<!-- define upper and lower case letters to enable case conversion -->
<xsl:variable name="ucase">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
@ -98,10 +100,10 @@
<xsl:template match="adl:application">
-------------------------------------------------------------------------------------------------
--
-- Application Description Language framework
-- <xsl:value-of select="$product-version"/>
--
-- Database for application <xsl:value-of select="@name"/> version <xsl:value-of select="@version"/>
-- Generated for MS-SQL 2000+ using adl2mssql.xslt <xsl:value-of select="substring('$Revision: 1.12 $', 12)"/>
-- Generated for MS-SQL 2000+ using adl2mssql.xslt <xsl:value-of select="substring('$Revision: 1.13 $', 12)"/>
--
-- Code generator (c) 2007 Cygnet Solutions Ltd
--

View file

@ -13,8 +13,8 @@
Transform ADL into velocity view templates
$Author: sb $
$Revision: 1.20 $
$Date: 2008-05-19 15:25:06 $
$Revision: 1.21 $
$Date: 2008-05-21 13:00:57 $
-->
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
Whitespace (or lack of it) is significant! -->
@ -43,6 +43,10 @@
<!-- the maximum width, in characters, we're prepared to allocate to widgets -->
<xsl:param name="max-widget-width" select="40"/>
<!-- the name and version of the product being built -->
<xsl:param name="product-version" select="'Application Description Language Framework'"/>
<!-- the current state of play is that we can only generate views with permissions for one group.
TODO: this isn't how it's supposed to be. It's supposed to be that at service time the system
checks which groups the current user is member of, and renders each widget with the most relaxed
@ -57,7 +61,7 @@
If you are going to use a non-default layout, however, you're responsible
for making sure it loads all the scripts, etc, that an ADL controller
expects. -->
<xsl:param name="layout-name" select="adl-default-layout"/>
<xsl:param name="layout-name"/>
<!-- bug 1800 : the name of the area (i.e. URL path part) to use -->
<xsl:param name="area-name" select="auto"/>
@ -79,12 +83,13 @@
<!-- Don't bother generating anything for foreign entities -->
<xsl:template match="adl:entity">
<xsl:comment>Layout is <xsl:value-of select="$layout-name"/></xsl:comment>
<xsl:choose>
<xsl:when test="$layout-name = 'adl-default-layout'">
<xsl:apply-templates select="." mode="empty-layout"/>
<xsl:when test="$layout-name">
<xsl:apply-templates select="." mode="non-empty-layout"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="." mode="non-empty-layout"/>
<xsl:apply-templates select="." mode="empty-layout"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
@ -109,10 +114,12 @@
</xsl:text>
#set( $title = "<xsl:value-of select="concat( 'Really delete ', @name)"/> $instance.UserIdentifier")
<xsl:comment>
<xsl:value-of select="$product-version"/>
Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>,
generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.20 $', 10)"/>
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.21 $', 10)"/>
</xsl:comment>
<xsl:call-template name="maybe-delete">
<xsl:with-param name="entity" select="."/>
@ -147,7 +154,7 @@
Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>,
generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.20 $', 10)"/>
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.21 $', 10)"/>
</xsl:comment>
<xsl:call-template name="install-scripts"/>
</head>
@ -230,10 +237,12 @@
<xsl:text>
</xsl:text>
<xsl:comment>
<xsl:value-of select="$product-version"/>
Auto generated Velocity <xsl:value-of select="@name"/> form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.20 $', 10)"/>
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.21 $', 10)"/>
</xsl:comment>
#capturefor( title)
#if ( $instance)
@ -353,12 +362,12 @@
<title>$!title</title>
<xsl:call-template name="head"/>
<xsl:comment>
Application Description Language framework
<xsl:value-of select="$product-version"/>
Auto generated Velocity form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL.
Generated using adl2views.xsl <xsl:value-of select="substring( '$Revision: 1.20 $', 10)"/>
Generated using adl2views.xsl <xsl:value-of select="substring( '$Revision: 1.21 $', 10)"/>
</xsl:comment>
<xsl:call-template name="install-scripts"/>
<script type='text/javascript' language='JavaScript1.2'>
@ -655,156 +664,23 @@
<xsl:choose>
<xsl:when test="@properties='listed'">
<xsl:call-template name="list2">
<xsl:with-param name="entity" select="$farent"/>
<xsl:comment>auxlist for with listed fields</xsl:comment>
<xsl:call-template name="internal-with-fields-list">
<xsl:with-param name="entity" select="//adl:entity[@name=$farent]"/>
<xsl:with-param name="fields" select="adl:field"/>
<xsl:with-param name="instance-list" select="concat( 'instance.', $listprop)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="fields">
<xsl:for-each select="$farent//adl:property[(@distinct='user' or @distinct='all') and not( @type='link' or @type='list')]">
<adl:field>
<xsl:attribute name="property">
<xsl:value-of select="@name"/>
</xsl:attribute>
</adl:field>
</xsl:for-each>
</xsl:variable>
<xsl:call-template name="list2">
<xsl:with-param name="entity" select="$farent"/>
<xsl:with-param name="fields" select="msxsl:node-set( $fields)"/>
<xsl:comment>auxlist with computed fields</xsl:comment>
<xsl:call-template name="internal-with-properties-list">
<xsl:with-param name="entity" select="//adl:entity[@name=$farent]"/>
<xsl:with-param name="properties" select="//adl:entity[@name=$farent]//adl:property[(@distinct='user' or @distinct='all') and not( @type='link' or @type='list')]"/>
<xsl:with-param name="instance-list" select="concat( 'instance.', $listprop)"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</td>
<xsl:choose>
<xsl:when test="@properties='listed'">
<tr>
<xsl:for-each select="adl:field">
<xsl:variable name="fieldprop" select="@property"/>
<th>
<!-- Getting the prompt for the field from a property of another entity is a bit
complex... -->
<xsl:call-template name="showprompt">
<xsl:with-param name="node" select="//adl:entity[@name=$farent]//adl:property[@name=$fieldprop]"/>
<xsl:with-param name="fallback" select="@property"/>
</xsl:call-template>
</th>
</xsl:for-each>
<th>
-
</th>
</tr>
#if ( $instance)
#foreach( $item in $instance.<xsl:value-of select="@property"/>)
#if ( $velocityCount % 2 == 0)
#set( $oddity = "even")
#else
#set( $oddity = "odd")
#end
<tr class="$oddity">
<xsl:for-each select="adl:field">
<xsl:variable name="fieldprop" select="@property"/>
<td>
<xsl:choose>
<xsl:when test="//adl:entity[@name=$farent]//adl:property[@name=$fieldprop]/@type='entity'">
#if ( $item.<xsl:value-of select="@property"/>)
$item.<xsl:value-of select="@property"/>.UserIdentifier
#end
</xsl:when>
<xsl:when test="//adl:entity[@name=$farent]//adl:property[@name=$fieldprop]/adl:option">
<!-- if we can get a prompt value for the option, it would be better to
show it than the raw value-->
<xsl:for-each select="//adl:entity[@name=$farent]//adl:property[@name=$fieldprop]/adl:option">
#if ( $item.<xsl:value-of select="$fieldprop"/> == '<xsl:value-of select="@value"/>')
<xsl:call-template name="showprompt">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="fallback" select="@value"/>
</xsl:call-template>
#end
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
$!item.<xsl:value-of select="@property"/>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:for-each>
<td>
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat( $action, '.rails?', $farid, '=$item.', $farid)"/>
</xsl:attribute>
Edit!
</a>
</td>
</tr>
#end <!-- foreach -->
#end <!-- if ($instance) -->
</xsl:when>
<xsl:otherwise>
<!-- properties not listed, so therefore presumably all. -->
<tr>
<xsl:for-each select="//adl:entity[@name=$farent]//adl:property[@distinct='user' or @distinct='all']">
<th>
<xsl:call-template name="showprompt">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="fallback" select="@name"/>
</xsl:call-template>
</th>
</xsl:for-each>
<th>-</th>
</tr>
#if ( $instance)
#foreach( $item in $instance.<xsl:value-of select="@property"/>)
#if ( $velocityCount % 2 == 0)
#set( $oddity = "even")
#else
#set( $oddity = "odd")
#end
<tr class="$oddity">
<xsl:for-each select="//adl:entity[@name=$farent]//adl:property[@distinct='user' or @distinct='all']">
<td>
<xsl:variable name="fieldprop" select="@name"/>
<xsl:choose>
<xsl:when test="@type='entity'">
#if ( $item.<xsl:value-of select="@name"/>)
$item.<xsl:value-of select="@name"/>.UserIdentifier
#end
</xsl:when>
<xsl:when test="adl:option">
<!-- if we can get a prompt value for the option, it would be better to
show it than the raw value-->
<xsl:for-each select="adl:option">
#if ( $item.<xsl:value-of select="$fieldprop"/> == '<xsl:value-of select="@value"/>')
<xsl:call-template name="showprompt">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="fallback" select="@value"/>
</xsl:call-template>
#end
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
$!item.<xsl:value-of select="@name"/>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:for-each>
<td>
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat( $action, '.rails?', $farid, '=$item.', $farid)"/>
</xsl:attribute>
Edit!
</a>
</td>
</tr>
#end <!-- foreach -->
#end <!-- if ( $instance)-->
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="adl:verb">
@ -1112,6 +988,15 @@
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:comment>
<xsl:value-of select="$product-version"/>
Auto generated Velocity list for <xsl:value-of select="@name"/>,
generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.21 $', 10)"/>
</xsl:comment>
#capturefor( title)
<xsl:value-of select="normalize-space( concat( 'List ', $withpluralsuffix))"/>
#end
@ -1155,10 +1040,11 @@
<title>$!title</title>
<xsl:call-template name="head"/>
<xsl:comment>
<xsl:value-of select="$product-version"/>
Auto generated Velocity list for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL.
Generated using adl2listview.xsl <xsl:value-of select="substring( '$Revision: 1.20 $', 10)"/>
Generated using adl2listview.xsl <xsl:value-of select="substring( '$Revision: 1.21 $', 10)"/>
</xsl:comment>
<xsl:call-template name="install-scripts"/>
</head>
@ -1212,42 +1098,29 @@
<xsl:attribute name="action">
<xsl:value-of select="concat( $list/@name, '.rails')"/>
</xsl:attribute>
<xsl:choose>
<xsl:when test="$list/@properties='listed'">
<xsl:call-template name="list2">
<xsl:call-template name="internal-with-fields-list">
<xsl:with-param name="entity" select="$list/ancestor::adl:entity"/>
<xsl:with-param name="fields" select="$list/adl:field"/>
<xsl:with-param name="can-search" select="'true'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="fields">
<xsl:for-each select="$list/ancestor::adl:entity//adl:property[(@distinct='user' or @distinct='all') and not( @type='link' or @type='list')]">
<adl:field>
<xsl:attribute name="property">
<xsl:value-of select="@name"/>
</xsl:attribute>
</adl:field>
</xsl:for-each>
</xsl:variable>
<xsl:call-template name="list2">
<xsl:with-param name="entity" select="$list/ancestor::adl:entity"/>
<xsl:with-param name="fields" select="msxsl:node-set( $fields)"/>
<xsl:with-param name="can-search" select="'true'"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</form>
</div>
</xsl:template>
<xsl:template name="list2">
<!-- a node-list of entities of type field, each indicating a property of the same entity -->
<xsl:template name="internal-with-fields-list">
<!-- a node-list of entities of type 'adl:field' or 'adl:field', each indicating a property
of the same entity, to be shown in columns of this list -->
<xsl:param name="fields"/>
<!-- the entity on which the properties for all those fields can be found -->
<!-- the entity of type 'adl:entity' on which the properties for all those fields can be found -->
<xsl:param name="entity"/>
<!-- NOTE NOTE NOTE: To be searchable, the list2 must not only be called with can-search
<!-- the name of the list of instances of this entity, available to Velocity at runtime
as an ICollection, which is to be layed out in this list -->
<xsl:param name="instance-list" select="'instances'"/>
<!-- NOTE NOTE NOTE: To be searchable, internal-with-fields-list must not only be called with can-search
equal to 'true', but also within a form! -->
<!-- NOTE NOTE NOTE: It's obvious that internal-with-fields-list and internal-with-properties-list
ought to be replaced with a single template, but that template proves to be extremely hard to get
right -->
<xsl:param name="can-search"/>
<table>
<tr>
@ -1270,7 +1143,7 @@
<xsl:for-each select="$fields">
<td class="search">
<xsl:variable name="pname" select="@property"/>
<xsl:variable name="property" select="$entity/adl:property[@name=$pname]"/>
<xsl:variable name="property" select="$entity//adl:property[@name=$pname]"/>
<xsl:variable name="size">
<xsl:choose>
<xsl:when test="$property/@type='string'">
@ -1293,13 +1166,13 @@
<xsl:if test="$size != 0">
<input>
<xsl:attribute name="name">
<xsl:value-of select="concat('search_',$pname)"/>
<xsl:value-of select="concat('search_',$property/@name)"/>
</xsl:attribute>
<xsl:attribute name="size">
<xsl:value-of select="$size"/>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="concat( '$!search_', $pname)"/>
<xsl:value-of select="concat( '$!search_', $property/@name)"/>
</xsl:attribute>
</input>
</xsl:if>
@ -1307,7 +1180,7 @@
</xsl:for-each>
</tr>
</xsl:if>
#foreach( $instance in $instances)
#foreach( <xsl:value-of select="concat( '$', $entity/@name)"/> in <xsl:value-of select="concat('$', $instance-list)"/>)
#if ( $velocityCount % 2 == 0)
#set( $oddity = "even")
#else
@ -1315,27 +1188,30 @@
#end
<tr class="$oddity">
<xsl:for-each select="$fields">
<xsl:variable name="propname" select="@property"/>
<xsl:variable name="property" select="$entity//adl:property[@name=$propname]"/>
<xsl:variable name="pname" select="@property"/>
<xsl:variable name="property" select="$entity//adl:property[@name=$pname]"/>
<td>
<xsl:choose>
<xsl:when test="not( $property/@name)">
<!-- shouldn't happen. There is definitely a bug here, because it does happen - but it shouldn't -->
</xsl:when>
<xsl:when test="$property/@type = 'date'">
#if ( $instance.<xsl:value-of select="@property"/>)
$instance.<xsl:value-of select="@property"/>.ToString( 'd')
#if ( <xsl:value-of select="concat( '$', $entity/@name, '.', $property/@name)"/>)
<xsl:value-of select="concat( '$', $entity/@name, '.', $property/@name)"/>.ToString( 'd')
#end
</xsl:when>
<xsl:when test="$property/@type='message'">
#if ( $instance.<xsl:value-of select="@property"/>)
$t.Msg( $instance.<xsl:value-of select="@property"/>)
#if ( <xsl:value-of select="concat( '$', $entity/@name, '.', $property/@name)"/>)
$t.Msg( <xsl:value-of select="concat( '$', $entity/@name, '.', $property/@name)"/>)
#end
</xsl:when>
<xsl:when test="$property/@type='entity'">
#if( $instance.<xsl:value-of select="@property"/>)
$instance.<xsl:value-of select="@property"/>.UserIdentifier
#if( <xsl:value-of select="concat( '$', $entity/@name, '.', $property/@name)"/>)
<xsl:value-of select="concat( '$', $entity/@name, '.', $property/@name, '.UserIdentifier')"/>
#end
</xsl:when>
<xsl:otherwise>
$!instance.<xsl:value-of select="@property"/>
<xsl:value-of select="concat( '$!', $entity/@name, '.', $property/@name)"/>
</xsl:otherwise>
</xsl:choose>
</td>
@ -1352,10 +1228,10 @@
</xsl:variable>
<xsl:choose>
<xsl:when test="@type='entity'">
<xsl:value-of select="concat( $sep, @name, '_Value=$instance.', @name, '_Value')"/>
<xsl:value-of select="concat( $sep, @name, '_Value=$', $entity/@name, '.', @name, '_Value')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat( $sep, @name, '=$instance.', @name)"/>
<xsl:value-of select="concat( $sep, @name, '=$', $entity/@name, '.', @name)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
@ -1377,6 +1253,146 @@
</table>
</xsl:template>
<xsl:template name="internal-with-properties-list">
<!-- a node-list of entities of type 'adl:property', each a property of the same entity, to be shown
in columns of this list -->
<xsl:param name="properties"/>
<!-- the entity of type 'adl:entity' on which the properties for all those fields can be found -->
<xsl:param name="entity"/>
<!-- the name of the list of instances of this entity, available to Velocity at runtime
as an ICollection, which is to be layed out in this list -->
<xsl:param name="instance-list" select="'instances'"/>
<!-- NOTE NOTE NOTE: To be searchable, internal-with-properties-list must not only be called with can-search
equal to 'true', but also within a form! -->
<!-- NOTE NOTE NOTE: It's obvious that internal-with-fields-list and internal-with-properties-list
ought to be replaced with a single template, but that template proves to be extremely hard to get
right -->
<xsl:param name="can-search"/>
<table>
<tr>
<xsl:for-each select="$properties">
<th>
<xsl:call-template name="showprompt">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="fallback" select="@name"/>
<xsl:with-param name="entity" select="$entity"/>
<xsl:with-param name="locale" select="$locale"/>
</xsl:call-template>
</th>
</xsl:for-each>
<xsl:for-each select="$entity/adl:form">
<th>-</th>
</xsl:for-each>
</tr>
<xsl:if test="$can-search = 'true'">
<tr class="search">
<xsl:for-each select="$properties">
<td class="search">
<xsl:variable name="size">
<xsl:choose>
<xsl:when test="@type='string'">
<xsl:choose>
<xsl:when test="@size &gt; 20">20</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@size"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="@type='integer'">8</xsl:when>
<xsl:when test="@type='real'">8</xsl:when>
<xsl:when test="@type='money'">8</xsl:when>
<!-- xsl:when test="@type='message'">20</xsl:when doesn't work yet -->
<xsl:when test="@type='text'">20</xsl:when>
<!-- xsl:when test="@type='enity'">20</xsl:when doesn't work yet -->
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="$size != 0">
<input>
<xsl:attribute name="name">
<xsl:value-of select="concat('search_', @name)"/>
</xsl:attribute>
<xsl:attribute name="size">
<xsl:value-of select="$size"/>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="concat( '$!search_', @name)"/>
</xsl:attribute>
</input>
</xsl:if>
</td>
</xsl:for-each>
</tr>
</xsl:if>
#foreach( <xsl:value-of select="concat( '$', $entity/@name)"/> in <xsl:value-of select="concat('$', $instance-list)"/>)
#if ( $velocityCount % 2 == 0)
#set( $oddity = "even")
#else
#set( $oddity = "odd")
#end
<tr class="$oddity">
<xsl:for-each select="$properties">
<td>
<xsl:choose>
<xsl:when test="@type = 'date'">
#if ( <xsl:value-of select="concat( '$', $entity/@name, '.', @name)"/>)
<xsl:value-of select="concat( '$', $entity/@name, '.', @name)"/>.ToString( 'd')
#end
</xsl:when>
<xsl:when test="@type='message'">
#if ( <xsl:value-of select="concat( '$', $entity/@name, '.', @name)"/>)
$t.Msg( <xsl:value-of select="concat( '$', $entity/@name, '.', @name)"/>)
#end
</xsl:when>
<xsl:when test="@type='entity'">
#if( <xsl:value-of select="concat( '$', $entity/@name, '.', @name)"/>)
<xsl:value-of select="concat( '$', $entity/@name, '.', @name, '.UserIdentifier')"/>
#end
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat( '$!', $entity/@name, '.', @name)"/>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:for-each>
<xsl:variable name="keys">
<!-- assemble keys in a Velocity-friendly format, then splice it into
the HREF below -->
<xsl:for-each select="$entity/adl:key/adl:property">
<xsl:variable name="sep">
<xsl:choose>
<xsl:when test="position()=1">?</xsl:when>
<xsl:otherwise>&amp;</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="@type='entity'">
<xsl:value-of select="concat( $sep, @name, '_Value=$', $entity/@name, '.', @name, '_Value')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat( $sep, @name, '=$', $entity/@name, '.', @name)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="$entity/adl:form">
<!-- by default create a link to each form declared for the entity.
We probably need a means of overriding this -->
<td>
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat( @name, '.rails', $keys)"/>
</xsl:attribute>
<xsl:value-of select="@name"/>!
</a>
</td>
</xsl:for-each>
</tr>
#end
</table>
</xsl:template>
<!-- overall page layout -->
<xsl:template match="adl:content"/>