Quite a lot more improvement on robustness and formatting

This commit is contained in:
sb 2008-05-09 16:12:12 +00:00
parent 0e392e6bb3
commit 7642f0bf02
4 changed files with 995 additions and 949 deletions

View file

@ -20,8 +20,8 @@
explicitly state the permission, even if it is 'none'. explicitly state the permission, even if it is 'none'.
$Author: sb $ $Author: sb $
$Revision: 1.8 $ $Revision: 1.9 $
$Date: 2008-02-28 14:52:08 $ $Date: 2008-05-09 16:12:12 $
--> -->
<xsl:stylesheet version="1.0" <xsl:stylesheet version="1.0"
@ -64,7 +64,7 @@
* THIS FILE IS AUTOMATICALLY GENERATED AND SHOULD NOT * THIS FILE IS AUTOMATICALLY GENERATED AND SHOULD NOT
* BE MANUALLY EDITED. * BE MANUALLY EDITED.
* *
* Generated using adl2canonical.xslt <xsl:value-of select="substring('$Revision: 1.8 $', 12)"/> * Generated using adl2canonical.xslt <xsl:value-of select="substring('$Revision: 1.9 $', 12)"/>
* *
*************************************************************************** ***************************************************************************
</xsl:comment> </xsl:comment>
@ -407,14 +407,15 @@
NOTE that n-to-n properties cannot currently be user-distinct and are NOTE that n-to-n properties cannot currently be user-distinct and are
therefore not inspected --> therefore not inspected -->
<xsl:template name="unroll-user-distinct"> <xsl:template name="unroll-user-distinct">
<xsl:for-each select="ancestor::adl:entity/descendant::adl:property[@distinct='user']"> <xsl:for-each select="ancestor::adl:entity/descendant::adl:property[@distinct='user' or @distinct='all']">
<field> <field>
<xsl:attribute name="property"> <xsl:attribute name="property">
<xsl:value-of select="@name"/> <xsl:value-of select="@name"/>
</xsl:attribute> </xsl:attribute>
<xsl:apply-templates select="adl:prompt"/>
<xsl:apply-templates select="adl:help"/>
</field> </field>
</xsl:for-each> </xsl:for-each>
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

View file

@ -9,8 +9,8 @@
Transform ADL into (partial) controller classes Transform ADL into (partial) controller classes
$Author: sb $ $Author: sb $
$Revision: 1.23 $ $Revision: 1.24 $
$Date: 2008-05-08 17:26:44 $ $Date: 2008-05-09 16:12:12 $
--> -->
<!-- WARNING WARNING WARNING: Do NOT reformat this file! <!-- WARNING WARNING WARNING: Do NOT reformat this file!
@ -71,7 +71,7 @@
// //
// Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s // Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s
// Automatically generated from application description using // Automatically generated from application description using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.23 $', 10)"/> // adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.24 $', 10)"/>
// //
// This file is automatically generated; DO NOT EDIT IT. // This file is automatically generated; DO NOT EDIT IT.
// //
@ -128,7 +128,7 @@ namespace <xsl:value-of select="$controllerns"/> {
// //
// Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s // Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s
// Automatically generated from application description using // Automatically generated from application description using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.23 $', 10)"/> // adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.24 $', 10)"/>
// //
// This file is automatically generated; DO NOT EDIT IT. // This file is automatically generated; DO NOT EDIT IT.
// //
@ -164,8 +164,10 @@ namespace <xsl:value-of select="$controllerns"/> {
/// ///
/// DO NOT EDIT THIS FILE! /// DO NOT EDIT THIS FILE!
/// &lt;/summary&gt; /// &lt;/summary&gt;
[ Layout("<xsl:value-of select="$layout-name"/>"), Rescue("<xsl:value-of select="$rescue-name"/>"), [ Layout("<xsl:value-of select="$layout-name"/>"),
ControllerDetails("<xsl:value-of select="@name"/>", Area = "<xsl:value-of select="$area-name"/>")] Rescue("<xsl:value-of select="$rescue-name"/>"),
ControllerDetails("<xsl:value-of select="@name"/>",
Area = "<xsl:value-of select="$area-name"/>")]
public partial class <xsl:value-of select="@name"/>Controller : <xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller')"/> { public partial class <xsl:value-of select="@name"/>Controller : <xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller')"/> {
<xsl:if test="adl:form"> <xsl:if test="adl:form">
@ -182,27 +184,27 @@ namespace <xsl:value-of select="$controllerns"/> {
NHibernateHelper.GetCurrentSession( <xsl:if test="$authentication-layer = 'Database'">Session[ NHibernateHelper.USERTOKEN], NHibernateHelper.GetCurrentSession( <xsl:if test="$authentication-layer = 'Database'">Session[ NHibernateHelper.USERTOKEN],
Session[NHibernateHelper.PASSTOKEN]</xsl:if>); Session[NHibernateHelper.PASSTOKEN]</xsl:if>);
List&lt;string&gt; messages = new List&lt;string&gt;(); List&lt;string&gt; messages = new List&lt;string&gt;();
// A 'newborn' instance can be updated even if the current user doesn't have /* A 'newborn' instance can be updated even if the current user doesn't have
// update permissions, seeing that we use an update operation to set the * update permissions, seeing that we use an update operation to set the
// field values and save the entity. * field values and save the entity. */
Boolean isnewborn = false; Boolean isnewborn = false;
<xsl:call-template name="fetch-instance"> /* the instance (record) of type <xsl:value-of select="@name"/> we're dealing with */
<xsl:with-param name="entity" select="."/> <xsl:value-of select="concat($entityns, '.', @name)"/> record = null;
<xsl:with-param name="initialise-locals" select="'true'"/>
</xsl:call-template>
try { try {
<xsl:if test="adl:property[@distinct='system' or @distinct='all']"> <xsl:if test="adl:property[@distinct='system' or @distinct='all']">
/* declare a list of <xsl:value-of select="@name"/> to use in /* a criteria object to use in distinctness checks */
* distinctness checks */ ICriteria matchCriteria = null;
IList&lt;<xsl:value-of select="@name"/>&gt; matches = null;
</xsl:if> </xsl:if>
record = FetchRecord( hibernator);
<xsl:apply-templates select="descendant::adl:property"/> <xsl:apply-templates select="descendant::adl:property"/>
if ( HasNoErrors()) {
if ( record == null) { if ( record == null) {
/* it seems to be new, create persistent object */ /* it seems to be new, create persistent object - if the user is permitted to */
AssertUserCanCreate(); AssertUserCanCreate();
try { try {
@ -239,7 +241,7 @@ namespace <xsl:value-of select="$controllerns"/> {
} }
catch ( FormatException) { catch ( FormatException) {
/* failed to parse a number - not wholly unexpected, since it's most likely /* failed to parse a number - not wholly unexpected, since it's most likely
that an empty string was passed in */ * that an empty string was passed in */
record = new <xsl:value-of select="concat($entityns, '.', @name)"/>(); record = new <xsl:value-of select="concat($entityns, '.', @name)"/>();
} }
catch ( NullReferenceException) { catch ( NullReferenceException) {
@ -255,12 +257,15 @@ namespace <xsl:value-of select="$controllerns"/> {
ITransaction tx = null; ITransaction tx = null;
if ( ! isnewborn) { if ( ! isnewborn) {
// isnewborn cannot be true unless we've already checked user can create /* isnewborn cannot be true unless we've already checked user can create
// so no need to do it again here * so no need to do it again here */
AssertUserCanUpdate(); AssertUserCanUpdate();
} }
try { try {
/* begin our atomic transaction */
tx = hibernator.BeginTransaction();
/* actually update the record */ /* actually update the record */
BindObjectInstance( record, ParamStore.Form, "instance"); BindObjectInstance( record, ParamStore.Form, "instance");
@ -287,7 +292,6 @@ namespace <xsl:value-of select="$controllerns"/> {
} }
</xsl:for-each> </xsl:for-each>
</xsl:if> </xsl:if>
<xsl:for-each select="descendant::adl:property[@type='entity']"> <xsl:for-each select="descendant::adl:property[@type='entity']">
/* for properties of type 'entity', it should not be necessary to do anything /* for properties of type 'entity', it should not be necessary to do anything
* special - BindObjectInstance /should/ do it all. Unfortunately it sometimes * special - BindObjectInstance /should/ do it all. Unfortunately it sometimes
@ -299,7 +303,7 @@ namespace <xsl:value-of select="$controllerns"/> {
{ {
record.<xsl:value-of select="@name"/> = <xsl:call-template name="fetch-property-instance"> record.<xsl:value-of select="@name"/> = <xsl:call-template name="fetch-property-instance">
<xsl:with-param name="property" select="."/> <xsl:with-param name="property" select="."/>
<xsl:with-param name="valuename" select="concat( 'instance.', @name)"/> <xsl:with-param name="valuename" select="@name"/>
</xsl:call-template>; </xsl:call-template>;
} }
</xsl:when> </xsl:when>
@ -356,19 +360,18 @@ namespace <xsl:value-of select="$controllerns"/> {
foreach ( string index in <xsl:value-of select="concat(@name, 'Values')"/>) foreach ( string index in <xsl:value-of select="concat(@name, 'Values')"/>)
{ {
<!-- TODO: this could definitely be made more efficient -->
if ( index.Equals( itemId)) if ( index.Equals( itemId))
{ {
found = true; found = true;
break; break;
} }
} } /* foreach ( string index... */
if ( ! found) if ( ! found)
{ {
record.<xsl:value-of select="@name"/>.Remove( item); record.<xsl:value-of select="@name"/>.Remove( item);
} }
} /* foreach ( string index... */ } /* foreach ( <xsl:value-of select="@entity"/> item ... */
/* then add any on the included list which are not already members */ /* then add any on the included list which are not already members */
foreach ( string index in <xsl:value-of select="concat(@name, 'Values')"/>) foreach ( string index in <xsl:value-of select="concat(@name, 'Values')"/>)
@ -403,6 +406,7 @@ namespace <xsl:value-of select="$controllerns"/> {
else { else {
throw new ApplicationException( String.Format( "No record of type <xsl:value-of select="@name"/> with the key values supplied was found")); throw new ApplicationException( String.Format( "No record of type <xsl:value-of select="@name"/> with the key values supplied was found"));
} }
} /* if ( HasNoErrors()) */
} /* try */ } /* try */
catch ( DataSuitabilityException dse) catch ( DataSuitabilityException dse)
{ {
@ -419,21 +423,16 @@ namespace <xsl:value-of select="$controllerns"/> {
PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN]; PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN];
</xsl:if> </xsl:if>
if ( HasNoErrors()) if ( ! HasNoErrors())
{ {
/* the session may be polluted; create a new session */ /* the session may be polluted; create a new session */
NHibernateHelper.CloseSession(); NHibernateHelper.CloseSession();
hibernator = NHibernateHelper.GetCurrentSession(<xsl:if test="$authentication-layer = 'Database'"> hibernator = NHibernateHelper.GetCurrentSession(<xsl:if test="$authentication-layer = 'Database'">
Session[ NHibernateHelper.USERTOKEN], Session[ NHibernateHelper.USERTOKEN],
Session[NHibernateHelper.PASSTOKEN] Session[NHibernateHelper.PASSTOKEN]</xsl:if>);
</xsl:if>);
<xsl:call-template name="fetch-instance"> record = FetchRecord( hibernator);
<xsl:with-param name="entity" select="."/> } /* if ( ! HasNoErrors()) */
<xsl:with-param name="initialise-locals" select="'false'"/>
</xsl:call-template>
}
<xsl:call-template name="formmenus"> <xsl:call-template name="formmenus">
<xsl:with-param name="form" select="adl:form[position()=1]"/> <xsl:with-param name="form" select="adl:form[position()=1]"/>
</xsl:call-template> </xsl:call-template>
@ -455,19 +454,13 @@ namespace <xsl:value-of select="$controllerns"/> {
NHibernateHelper.GetCurrentSession( <xsl:if test="$authentication-layer = 'Database'">Session[ NHibernateHelper.USERTOKEN], NHibernateHelper.GetCurrentSession( <xsl:if test="$authentication-layer = 'Database'">Session[ NHibernateHelper.USERTOKEN],
Session[NHibernateHelper.PASSTOKEN]</xsl:if>); Session[NHibernateHelper.PASSTOKEN]</xsl:if>);
string reallydelete = Params["reallydelete"]; if ( "true".Equals( Params["reallydelete"]))
if ( "true".Equals( reallydelete))
{ {
<xsl:call-template name="fetch-instance"> <xsl:value-of select="concat($entityns, '.', @name)"/> record = FetchRecord( hibernator);
<xsl:with-param name="entity" select="."/>
<xsl:with-param name="initialise-locals" select="'true'"/>
</xsl:call-template>
if ( record != null) if ( record != null)
{ {
hibernator.Delete( record); hibernator.Delete( record);
hibernator.Flush(); hibernator.Flush();
} }
else else
@ -524,52 +517,96 @@ namespace <xsl:value-of select="$controllerns"/> {
RenderViewWithFailover(view + ".vm", view + ".auto.vm"); RenderViewWithFailover(view + ".vm", view + ".auto.vm");
} }
</xsl:if> </xsl:if>
/// &lt;summary&gt;
/// Fetch the record represented by the values in the current Form
/// &lt;/summary&gt;
protected <xsl:value-of select="concat($entityns, '.', @name)"/> FetchRecord(ISession hibernator) {
/* the instance (record) of type <xsl:value-of select="@name"/> we're dealing with */
<xsl:value-of select="concat($entityns, '.', @name)"/> record = null;
/* whether we have valid values for all the key fields */
bool allkeys = true;
/* check whether values for all key slots have been passed in; if so, we're probably dealing with an
* existing record */
<xsl:for-each select="adl:key/adl:property">
if ( String.IsNullOrEmpty( Form["<xsl:value-of select="concat( 'instance.', @name)"/>"])) {
allkeys = false;
} else if ( "<xsl:value-of select="concat('$instance.', @name)"/>".Equals( Form["<xsl:value-of select="concat( 'instance.', @name)"/>"])) {
/* nasty artefact of NVelocity forms - default 'null value' is dollar followed by fieldname */
allkeys = false;
}
</xsl:for-each>
if ( allkeys){
/* it's (probably) existing, retrieve it */
record = hibernator.CreateCriteria(typeof(<xsl:value-of select="concat( $entityns, '.', @name)"/>))
<xsl:for-each select="adl:key/adl:property">
<xsl:variable name="basetype">
<xsl:call-template name="base-type">
<xsl:with-param name="property" select="."/>
</xsl:call-template>
</xsl:variable>
.Add( Expression.Eq( "<xsl:value-of select="@name"/>", <xsl:choose>
<xsl:when test="$basetype='integer'">
Int32.Parse( Form[ "<xsl:value-of select="concat( 'instance.', @name)"/>"])
</xsl:when>
<xsl:when test="$basetype='entity'">
<!-- Maybe TODO: this doesn't work recursively - if an entity has a key which is an entity
and the key of that entity is an entity, you're on your own, mate! -->
<xsl:variable name="keyentity" select="@entity"/>
<xsl:variable name="keyenttype">
<xsl:call-template name="primary-key-csharp-type">
<xsl:with-param name="entity" select="//adl:entity[@name=$keyentity]"/>
</xsl:call-template>
</xsl:variable>
hibernator.CreateCriteria( typeof( <xsl:value-of select="$keyenttype"/>))
.Add(Expression.Eq( "<xsl:value-of select="//adl:entity[@name=$keyentity]/adl:key/adl:property[position()=1]/@name"/>",<xsl:choose>
<xsl:when test="$keyenttype = 'int'">
Int32.Parse( Form[ "<xsl:value-of select="concat( 'instance.', @name)"/>"])
</xsl:when>
<xsl:otherwise>
Form[ "<xsl:value-of select="concat( 'instance.', @name)"/>"]
</xsl:otherwise>
</xsl:choose>))
.UniqueResult&lt;<xsl:value-of select="$keyenttype"/>&gt;()
</xsl:when>
<xsl:otherwise>
Form[ "<xsl:value-of select="concat( 'instance.', @name)"/>"]
</xsl:otherwise>
</xsl:choose>))
</xsl:for-each>
.UniqueResult&lt;<xsl:value-of select="concat( $entityns, '.', @name)"/>&gt;();
}
return record;
}
} }
} }
/* ---- [ cut here: next file 'junk'] ------------------------- */ /* ---- [ cut here: next file 'junk'] ------------------------- */
</xsl:template> </xsl:template>
<xsl:template match="adl:property[@required='true']"> <xsl:template match="adl:property">
if ( Form[ "<xsl:value-of select="concat( 'instance.', @name)"/>" ] == null) <xsl:if test="@required='true'">
if ( String.IsNullOrEmpty( Form[ "<xsl:value-of select="concat( 'instance.', @name)"/>" ]))
{ {
AddError( <xsl:choose> AddError( <xsl:choose>
<xsl:when test="adl:ifmissing[@locale=$locale]"> <xsl:when test="adl:ifmissing[@locale=$locale]">
<xsl:apply-templates select="adl:ifmissing[@locale=$locale]"/> <xsl:apply-templates select="adl:ifmissing[@locale=$locale]"/>
</xsl:when> </xsl:when>
<xsl:otherwise>"You must supply a value for <xsl:value-of select="@name"/>"</xsl:otherwise> <xsl:otherwise>
"You must supply a value for <xsl:value-of select="@name"/>"
</xsl:otherwise>
</xsl:choose>); </xsl:choose>);
} }
</xsl:if>
<xsl:choose> <xsl:if test="@distinct='system' or @distinct='all'">
<xsl:when test="adl:property[@distinct='system']">
<xsl:call-template name="check-property-value-distinct"> <xsl:call-template name="check-property-value-distinct">
<xsl:with-param name="property" select="."/> <xsl:with-param name="property" select="."/>
</xsl:call-template> </xsl:call-template>
</xsl:when> </xsl:if>
<xsl:when test="adl:property[@distinct='all']">
<xsl:call-template name="check-property-value-distinct">
<xsl:with-param name="property" select="."/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:template> </xsl:template>
<xsl:template match="adl:property[@distinct='system']">
<xsl:call-template name="check-property-value-distinct">
<xsl:with-param name="property" select="."/>
</xsl:call-template>
</xsl:template>
<xsl:template match="adl:property[@distinct='all']">
<xsl:call-template name="check-property-value-distinct">
<xsl:with-param name="property" select="."/>
</xsl:call-template>
</xsl:template>
<!-- suppress properties otherwise -->
<xsl:template match="adl:property"/>
<xsl:template match="adl:ifmissing"> <xsl:template match="adl:ifmissing">
"<xsl:value-of select="normalize-space(.)"/>" "<xsl:value-of select="normalize-space(.)"/>"
</xsl:template> </xsl:template>
@ -600,7 +637,7 @@ namespace <xsl:value-of select="$controllerns"/> {
if ( command.Equals( "<xsl:value-of select="@verb"/>")) if ( command.Equals( "<xsl:value-of select="@verb"/>"))
{ {
/* NOTE: You must write an implementation of this verb in a /* NOTE: You must write an implementation of this verb in a
manually maintained partial class file for this class */ * manually maintained partial class file for this class */
<xsl:value-of select="@verb"/>(); <xsl:value-of select="@verb"/>();
} }
else else
@ -611,10 +648,7 @@ namespace <xsl:value-of select="$controllerns"/> {
NHibernateHelper.GetCurrentSession( <xsl:if test="$authentication-layer = 'Database'">Session[ NHibernateHelper.USERTOKEN], NHibernateHelper.GetCurrentSession( <xsl:if test="$authentication-layer = 'Database'">Session[ NHibernateHelper.USERTOKEN],
Session[NHibernateHelper.PASSTOKEN]</xsl:if>); Session[NHibernateHelper.PASSTOKEN]</xsl:if>);
<xsl:call-template name="fetch-instance"> <xsl:value-of select="concat($entityns, '.', ancestor::adl:entity/@name)"/> record = FetchRecord( hibernator);
<xsl:with-param name="entity" select="ancestor::adl:entity"/>
<xsl:with-param name="initialise-locals" select="'true'"/>
</xsl:call-template>
<xsl:if test="$authentication-layer = 'Database'"> <xsl:if test="$authentication-layer = 'Database'">
PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN]; PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN];
@ -783,21 +817,17 @@ namespace <xsl:value-of select="$controllerns"/> {
</xsl:when> </xsl:when>
<xsl:when test="$property/@distinct = 'system' or $property/@distinct='all'"> <xsl:when test="$property/@distinct = 'system' or $property/@distinct='all'">
/* <xsl:value-of select="$property/@name"/> should be distinct: check that it is */ /* <xsl:value-of select="$property/@name"/> should be distinct: check that it is */
matches = matchCriteria =
hibernator.CreateCriteria(typeof(<xsl:value-of select="$property/ancestor::adl:entity/@name"/>)) hibernator.CreateCriteria(typeof(<xsl:value-of select="$property/ancestor::adl:entity/@name"/>));
<xsl:choose>
<xsl:when test="$basetype='string'"> matchCriteria.Add(Expression.Eq("<xsl:value-of select="$property/@name"/>", <xsl:choose>
.Add(Expression.Eq("<xsl:value-of select="$property/@name"/>", Form["<xsl:value-of select="concat('instance.', $property/@name)"/>"])) <xsl:when test="$basetype='string'">Form["<xsl:value-of select="concat('instance.', $property/@name)"/>"]</xsl:when>
</xsl:when> <xsl:when test="$basetype='integer'">Int32.Parse( Form["<xsl:value-of select="concat('instance.', $property/@name)"/>"])</xsl:when>
<xsl:when test="$basetype='integer'">
.Add(Expression.Eq("<xsl:value-of select="$property/@name"/>", Int32.Parse( Form["<xsl:value-of select="concat('instance.', $property/@name)"/>"])))
</xsl:when>
<xsl:when test="$basetype='entity'"> <xsl:when test="$basetype='entity'">
.Add(Expression.Eq("<xsl:value-of select="$property/@name"/>",
<xsl:call-template name="fetch-property-instance"> <xsl:call-template name="fetch-property-instance">
<xsl:with-param name="property" select="."/> <xsl:with-param name="property" select="."/>
<xsl:with-param name="valuename" select="adl:property[position()=1]/@name"/> <xsl:with-param name="valuename" select="adl:property[position()=1]/@name"/>
</xsl:call-template>)) </xsl:call-template>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:message terminate="yes"> <xsl:message terminate="yes">
@ -805,30 +835,33 @@ namespace <xsl:value-of select="$controllerns"/> {
with base type <xsl:value-of select="$basetype"/> with base type <xsl:value-of select="$basetype"/>
</xsl:message> </xsl:message>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>));
<xsl:for-each select="$property/ancestor::adl:entity/adl:key">
.Add(Expression.Not(Expression.Eq("<xsl:value-of select="adl:property[position()=1]/@name"/>",<xsl:choose> if ( record != null) {
<xsl:when test="@type='entity'"> /* i.e. we do have values for each of our key fields... */
<xsl:for-each select="$property/ancestor::adl:entity/adl:key/adl:property[position()=1]">
<xsl:variable name="keybasetype">
<xsl:call-template name="base-type">
<xsl:with-param name="property" select="."/>
</xsl:call-template>
</xsl:variable>
matchCriteria.Add(Expression.Not(Expression.Eq("<xsl:value-of select="@name"/>",<xsl:choose>
<xsl:when test="$keybasetype='entity'">
<xsl:call-template name="fetch-property-instance"> <xsl:call-template name="fetch-property-instance">
<!-- recurse --> <!-- recurse -->
<xsl:with-param name="property" select="."/> <xsl:with-param name="property" select="."/>
<xsl:with-param name="valuename" select="adl:property[position()=1]/@name"/> <xsl:with-param name="valuename" select="@name"/>
</xsl:call-template> </xsl:call-template>
</xsl:when> </xsl:when>
<xsl:when test="@type='integer'"> <xsl:when test="$keybasetype='integer'">Int32.Parse( Form["<xsl:value-of select="concat( 'instance.', @name)"/>"])</xsl:when>
Int32.Parse( Form["<xsl:value-of select="adl:property[position()=1]/@name"/>"]) <xsl:otherwise>Form["<xsl:value-of select="concat( 'instance.', @name)"/>"]</xsl:otherwise>
</xsl:when> </xsl:choose>)));
<xsl:otherwise>
Form["<xsl:value-of select="adl:property[position()=1]/@name"/>"]
</xsl:otherwise>
</xsl:choose>)))
</xsl:for-each> </xsl:for-each>
.List&lt;<xsl:value-of select="$property/ancestor::adl:entity/@name"/>&gt;(); }
if ( matches.Count > 0) if ( matchCriteria.List&lt;<xsl:value-of select="$property/ancestor::adl:entity/@name"/>&gt;().Count > 0)
{ {
throw new AddError(
DataNotDistinctException(
String.Format("There is already a {0} with the {1} '{2}'", String.Format("There is already a {0} with the {1} '{2}'",
"<xsl:value-of select="$property/ancestor::adl:entity/@name"/>", "<xsl:value-of select="$property/@name"/>", Form["<xsl:value-of select="concat('instance.', $property/@name)"/>"])); "<xsl:value-of select="$property/ancestor::adl:entity/@name"/>", "<xsl:value-of select="$property/@name"/>", Form["<xsl:value-of select="concat('instance.', $property/@name)"/>"]));
} }
@ -979,71 +1012,18 @@ namespace <xsl:value-of select="$controllerns"/> {
hibernator.CreateCriteria(typeof(<xsl:value-of select="concat( $entityns, '.', $property/@entity)"/>)) hibernator.CreateCriteria(typeof(<xsl:value-of select="concat( $entityns, '.', $property/@entity)"/>))
<xsl:for-each select="//adl:entity[@name=$property/@entity]/adl:key/adl:property"> <xsl:for-each select="//adl:entity[@name=$property/@entity]/adl:key/adl:property">
.Add(Expression.Eq("<xsl:value-of select="@name"/>",<xsl:choose> .Add(Expression.Eq("<xsl:value-of select="@name"/>",<xsl:choose>
<xsl:when test="@type='entity'"><xsl:call-template name="fetch-property-instance"> <xsl:when test="@type='entity'">
<xsl:call-template name="fetch-property-instance">
<!-- recurse --> <!-- recurse -->
<xsl:with-param name="property" select="."/> <xsl:with-param name="property" select="."/>
<xsl:with-param name="valuename" select="$valuename"/> <xsl:with-param name="valuename" select="$valuename"/>
</xsl:call-template></xsl:when> </xsl:call-template>
<xsl:when test="@type='integer'">Int32.Parse( Form["<xsl:value-of select="$valuename"/>"])</xsl:when> </xsl:when>
<xsl:otherwise>Form["<xsl:value-of select="$valuename"/>"]</xsl:otherwise> <xsl:when test="@type='integer'">Int32.Parse( Form["<xsl:value-of select="concat( 'instance.', $valuename)"/>"])</xsl:when>
<xsl:otherwise>Form["<xsl:value-of select="concat( 'instance.', $valuename)"/>"]</xsl:otherwise>
</xsl:choose>)) </xsl:choose>))
</xsl:for-each> </xsl:for-each>
.UniqueResult&lt;<xsl:value-of select="concat( $entityns, '.', @entity)"/>&gt;() .UniqueResult&lt;<xsl:value-of select="concat( $entityns, '.', @entity)"/>&gt;()
</xsl:template> </xsl:template>
<!-- this is essentially just a macro and doesn't really do anything clever.
It finds the current instance of the entity for which this is the controller,
and returns it as the value of a variable (which must have been previously
declared) called 'record' -->
<xsl:template name="fetch-instance">
<xsl:param name="entity"/>
<xsl:param name="initialise-locals" select="'false'"/>
/* check whether values for all key slots have been passed in; if so, we're probably dealing with an
* existing record */
<xsl:if test="$initialise-locals = 'true'">
/* the instance (record) of type <xsl:value-of select="$entity/@name"/> we're dealing with */
<xsl:value-of select="concat($entityns, '.', $entity/@name)"/> record = null;
/* whether we have valid values for all the key fields */
bool allkeys = true;
</xsl:if>
<xsl:for-each select="$entity/adl:key/adl:property">
if ( String.IsNullOrEmpty( Form["<xsl:value-of select="concat( 'instance.', @name)"/>"])) {
allkeys = false;
}
else if ( "<xsl:value-of select="concat('$instance.', @name)"/>".Equals( Form["<xsl:value-of select="concat( 'instance.', @name)"/>"])) {
/* nasty artefact of NVelocity forms - default 'null value' is dollar followed by fieldname */
allkeys = false;
}
</xsl:for-each>
if ( allkeys){
/* it's (probably) existing, retrieve it */
record = hibernator.CreateCriteria(typeof(<xsl:value-of select="concat( $entityns, '.', $entity/@name)"/>))
<xsl:for-each select="$entity/adl:key/adl:property">
<xsl:variable name="basetype">
<xsl:call-template name="base-type">
<xsl:with-param name="property" select="."/>
</xsl:call-template>
</xsl:variable>
.Add( Expression.Eq( "<xsl:value-of select="@name"/>", <xsl:choose>
<xsl:when test="$basetype='integer'">Int32.Parse( Form[ "<xsl:value-of select="concat( 'instance.', @name)"/>"])</xsl:when>
<xsl:when test="$basetype='entity'">
<!-- Maybe TODO: this doesn't work recursively - if an entity has a key which is an entity
and the key of that entity is an entity, you're on your own, mate! -->
<xsl:variable name="keyentity" select="@entity"/>
<xsl:variable name="keyenttype">
<xsl:call-template name="primary-key-csharp-type">
<xsl:with-param name="entity" select="//adl:entity[@name=$keyentity]"/>
</xsl:call-template>
</xsl:variable>
hibernator.CreateCriteria( typeof( <xsl:value-of select="$keyenttype"/>))
.Add(Expression.Eq( "<xsl:value-of select="//adl:entity[@name=$keyentity]/adl:key/adl:property[position()=1]/@name"/>",<xsl:choose>
<xsl:when test="$keyenttype = 'int'">Int32.Parse( Form[ "<xsl:value-of select="concat( 'instance.', @name)"/>"])</xsl:when>
<xsl:otherwise>Form[ "<xsl:value-of select="concat( 'instance.', @name)"/>"]</xsl:otherwise></xsl:choose>))
.UniqueResult&lt;<xsl:value-of select="$keyenttype"/>&gt;()</xsl:when>
<xsl:otherwise>Form[ "<xsl:value-of select="concat( 'instance.', @name)"/>"]</xsl:otherwise></xsl:choose>))
</xsl:for-each>
.UniqueResult&lt;<xsl:value-of select="concat( $entityns, '.', $entity/@name)"/>&gt;();
}
</xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

View file

@ -8,8 +8,8 @@
Transform ADL into entity classes Transform ADL into entity classes
$Author: sb $ $Author: sb $
$Revision: 1.12 $ $Revision: 1.13 $
$Date: 2008-03-12 13:46:10 $ $Date: 2008-05-09 16:12:12 $
--> -->
<!-- WARNING WARNING WARNING: Do NOT reformat this file! <!-- WARNING WARNING WARNING: Do NOT reformat this file!
@ -61,7 +61,7 @@
stored to CVS --> stored to CVS -->
<xsl:variable name="transform-rev1" <xsl:variable name="transform-rev1"
select="substring( '$Revision: 1.12 $', 11)"/> select="substring( '$Revision: 1.13 $', 11)"/>
<xsl:variable name="transform-revision" <xsl:variable name="transform-revision"
select="substring( $transform-rev1, 0, string-length( $transform-rev1) - 1)"/> select="substring( $transform-rev1, 0, string-length( $transform-rev1) - 1)"/>
@ -220,8 +220,8 @@
get { get {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
<xsl:choose> <xsl:choose>
<xsl:when test="descendant::adl:property[@distinct='user']"> <xsl:when test="descendant::adl:property[@distinct='user' or @distinct='all']">
<xsl:for-each select="descendant::adl:property[@distinct='user']"> <xsl:for-each select="descendant::adl:property[@distinct='user' or @distinct='all']">
<xsl:choose> <xsl:choose>
<xsl:when test="@type='message'"> <xsl:when test="@type='message'">
if ( <xsl:value-of select="@name"/> != null) if ( <xsl:value-of select="@name"/> != null)

View file

@ -12,8 +12,8 @@
Transform ADL into velocity view templates Transform ADL into velocity view templates
$Author: sb $ $Author: sb $
$Revision: 1.15 $ $Revision: 1.16 $
$Date: 2008-04-18 10:06:47 $ $Date: 2008-05-09 16:12:12 $
--> -->
<!-- WARNING WARNING WARNING: Do NOT reformat this file! <!-- WARNING WARNING WARNING: Do NOT reformat this file!
Whitespace (or lack of it) is significant! --> Whitespace (or lack of it) is significant! -->
@ -29,7 +29,13 @@
<xsl:param name="locale" select="en-UK"/> <xsl:param name="locale" select="en-UK"/>
<!-- whether or not to auto-generate site navigation - by default, don't --> <!-- whether or not to auto-generate site navigation - by default, don't -->
<xsl:param name="generate-site-navigation"/> <xsl:param name="generate-site-navigation" select="'false'"/>
<!-- whether or not to layout errors - they may be in the default layout -->
<xsl:param name="show-errors" select="'false'"/>
<!-- whether or not to layout messages - they may be in the default layout -->
<xsl:param name="show-messages" select="'false'"/>
<!-- the current state of play is that we can only generate views with permissions for one group. <!-- 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 TODO: this isn't how it's supposed to be. It's supposed to be that at service time the system
@ -46,9 +52,14 @@
for making sure it loads all the scripts, etc, that an ADL controller for making sure it loads all the scripts, etc, that an ADL controller
expects. --> expects. -->
<xsl:param name="layout-name" select="adl-default-layout"/> <xsl:param name="layout-name" select="adl-default-layout"/>
<!-- bug 1800 : the name of the area (i.e. URL path part) to use -->
<xsl:param name="area-name" select="auto"/>
<xsl:template match="adl:application"> <xsl:template match="adl:application">
<output> <output>
<!-- 'output' is a dummy wrapper root tag to make the entire output work as
an XML document; the actual output later gets cut into chunks and the
wrapper tag is discarded. -->
<xsl:apply-templates select="adl:entity"/> <xsl:apply-templates select="adl:entity"/>
<!-- make sure extraneous junk doesn't get into the last file generated, <!-- make sure extraneous junk doesn't get into the last file generated,
by putting it into a separate file --> by putting it into a separate file -->
@ -71,7 +82,7 @@
</xsl:template> </xsl:template>
<!-- generate views for an entity, assuming a non-empty layout - i.e. <!-- generate views for an entity, assuming a non-empty layout - i.e.
I'm not responsible for head, or for the body tag --> I'm not responsible for the html, the head, or for the body tag -->
<xsl:template match="adl:entity" mode="non-empty-layout"> <xsl:template match="adl:entity" mode="non-empty-layout">
<xsl:variable name="keyfield"> <xsl:variable name="keyfield">
<xsl:choose> <xsl:choose>
@ -93,14 +104,15 @@
Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>, Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>,
generated from ADL. generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.15 $', 10)"/> Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.16 $', 10)"/>
</xsl:comment> </xsl:comment>
<xsl:call-template name="maybe-delete"> <xsl:call-template name="maybe-delete">
<xsl:with-param name="entity" select="."/> <xsl:with-param name="entity" select="."/>
</xsl:call-template> </xsl:call-template>
</xsl:template> </xsl:template>
<!-- generate views for an entity, assuming a non-empty layout --> <!-- generate views for an entity, assuming an empty layout
(i.e. I'm responsible for html, head and body tags) -->
<xsl:template match="adl:entity" mode="empty-layout"> <xsl:template match="adl:entity" mode="empty-layout">
<xsl:variable name="keyfield"> <xsl:variable name="keyfield">
<xsl:choose> <xsl:choose>
@ -115,7 +127,9 @@
<xsl:apply-templates select="adl:list" mode="empty-layout"/> <xsl:apply-templates select="adl:list" mode="empty-layout"/>
<xsl:text> <xsl:text>
</xsl:text> </xsl:text>
<xsl:comment> [ cut here: next file '<xsl:value-of select="concat( @name, '/maybedelete.auto.vm')"/>' ] </xsl:comment> <xsl:comment>
[ cut here: next file '<xsl:value-of select="concat( @name, '/maybedelete.auto.vm')"/>' ]
</xsl:comment>
<xsl:text> <xsl:text>
</xsl:text> </xsl:text>
<html> <html>
@ -127,7 +141,7 @@
Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>, Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>,
generated from ADL. generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.15 $', 10)"/> Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.16 $', 10)"/>
</xsl:comment> </xsl:comment>
<xsl:call-template name="install-scripts"/> <xsl:call-template name="install-scripts"/>
</head> </head>
@ -213,7 +227,7 @@
Auto generated Velocity <xsl:value-of select="@name"/> form for <xsl:value-of select="ancestor::adl:entity/@name"/>, Auto generated Velocity <xsl:value-of select="@name"/> form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL. generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.15 $', 10)"/> Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.16 $', 10)"/>
</xsl:comment> </xsl:comment>
#capturefor( title) #capturefor( title)
#if ( $instance) #if ( $instance)
@ -223,6 +237,7 @@
#end #end
#end #end
#capturefor( headextras) #capturefor( headextras)
<xsl:call-template name="head"/>
<script type='text/javascript' language='JavaScript1.2'> <script type='text/javascript' language='JavaScript1.2'>
var panes = new Array( <xsl:for-each select='adl:fieldgroup'> var panes = new Array( <xsl:for-each select='adl:fieldgroup'>
"<xsl:value-of select='@name'/>"<xsl:choose> "<xsl:value-of select='@name'/>"<xsl:choose>
@ -294,9 +309,11 @@
#capturefor(bodyattributes) #capturefor(bodyattributes)
onload="performInitialisation()" onload="performInitialisation()"
#end #end
<xsl:call-template name="top"/>
<xsl:call-template name="form-content"> <xsl:call-template name="form-content">
<xsl:with-param name="form" select="."/> <xsl:with-param name="form" select="."/>
</xsl:call-template> </xsl:call-template>
<xsl:call-template name="foot"/>
</xsl:template> </xsl:template>
<xsl:template match="adl:form" mode="empty-layout"> <xsl:template match="adl:form" mode="empty-layout">
@ -334,7 +351,7 @@
Auto generated Velocity form for <xsl:value-of select="ancestor::adl:entity/@name"/>, Auto generated Velocity form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL. generated from ADL.
Generated using adl2views.xsl <xsl:value-of select="substring( '$Revision: 1.15 $', 10)"/> Generated using adl2views.xsl <xsl:value-of select="substring( '$Revision: 1.16 $', 10)"/>
</xsl:comment> </xsl:comment>
<xsl:call-template name="install-scripts"/> <xsl:call-template name="install-scripts"/>
<script type='text/javascript' language='JavaScript1.2'> <script type='text/javascript' language='JavaScript1.2'>
@ -421,26 +438,32 @@
<xsl:param name="form"/> <xsl:param name="form"/>
<xsl:variable name="formname" select="$form/@name"/> <xsl:variable name="formname" select="$form/@name"/>
<div class="content"> <div class="content">
<xsl:if test="$show-errors = 'true'">
#if ( $errors) #if ( $errors)
#if ( $errors.Count != 0) #if ( $errors.Count != 0)
<ul class="errors"> <ul class="errors">
#foreach($e in $errors) #foreach($e in $errors)
#if($e.Message)
<li>$t.Error($e)</li>
#else
<li>$t.Enc($e)</li> <li>$t.Enc($e)</li>
#end #end
#end
</ul> </ul>
#end #end
#end #end
</xsl:if>
<xsl:if test="$show-messages = 'true'">
#if( $messages) #if( $messages)
#if ( $messages.Count != 0) #if ( $messages.Count != 0)
<div class="information"> <ul class="information">
#foreach ( $message in $messages) #foreach ( $message in $messages)
<p> <li>$message</li>
$message
</p>
#end #end
</div> </ul>
#end #end
#end #end
</xsl:if>
<form method="post" onsubmit="invokeSubmitHandlers( this)"> <form method="post" onsubmit="invokeSubmitHandlers( this)">
<xsl:attribute name="action"> <xsl:attribute name="action">
<xsl:value-of select="concat( $formname, 'SubmitHandler.rails')"/> <xsl:value-of select="concat( $formname, 'SubmitHandler.rails')"/>
@ -478,6 +501,7 @@
switchtab( '<xsl:value-of select="@name"/>'); return false; switchtab( '<xsl:value-of select="@name"/>'); return false;
</xsl:attribute> </xsl:attribute>
<xsl:call-template name="showprompt"> <xsl:call-template name="showprompt">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="fallback" select="@name"/> <xsl:with-param name="fallback" select="@name"/>
</xsl:call-template> </xsl:call-template>
</a> </a>
@ -548,6 +572,7 @@
</xsl:attribute> </xsl:attribute>
<h3> <h3>
<xsl:call-template name="showprompt"> <xsl:call-template name="showprompt">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="fallback" select="@name"/> <xsl:with-param name="fallback" select="@name"/>
</xsl:call-template> </xsl:call-template>
</h3> </h3>
@ -650,6 +675,7 @@
<xsl:for-each select="//adl:entity[@name=$farent]//adl:property[@name=$fieldprop]/adl:option"> <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"/>') #if ( $item.<xsl:value-of select="$fieldprop"/> == '<xsl:value-of select="@value"/>')
<xsl:call-template name="showprompt"> <xsl:call-template name="showprompt">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="fallback" select="@value"/> <xsl:with-param name="fallback" select="@value"/>
</xsl:call-template> </xsl:call-template>
#end #end
@ -676,16 +702,12 @@
<xsl:otherwise> <xsl:otherwise>
<!-- properties not listed, so therefore presumably all. --> <!-- properties not listed, so therefore presumably all. -->
<tr> <tr>
<xsl:for-each select="//adl:entity[@name=$farent]//adl:property[@distinct='user']"> <xsl:for-each select="//adl:entity[@name=$farent]//adl:property[@distinct='user' or @distinct='all']">
<th> <th>
<xsl:choose> <xsl:call-template name="showprompt">
<xsl:when test="adl:prompt[@locale=$locale]"> <xsl:with-param name="node" select="."/>
<xsl:value-of select="adl:prompt[@locale=$locale]/@prompt"/> <xsl:with-param name="fallback" select="@name"/>
</xsl:when> </xsl:call-template>
<xsl:otherwise>
<xsl:value-of select="@name"/>
</xsl:otherwise>
</xsl:choose>
</th> </th>
</xsl:for-each> </xsl:for-each>
<th>-</th> <th>-</th>
@ -698,7 +720,7 @@
#set( $oddity = "odd") #set( $oddity = "odd")
#end #end
<tr class="$oddity"> <tr class="$oddity">
<xsl:for-each select="//adl:entity[@name=$farent]//adl:property[@distinct='user']"> <xsl:for-each select="//adl:entity[@name=$farent]//adl:property[@distinct='user' or @distinct='all']">
<td> <td>
<xsl:variable name="fieldprop" select="@name"/> <xsl:variable name="fieldprop" select="@name"/>
<xsl:choose> <xsl:choose>
@ -713,6 +735,7 @@
<xsl:for-each select="adl:option"> <xsl:for-each select="adl:option">
#if ( $item.<xsl:value-of select="$fieldprop"/> == '<xsl:value-of select="@value"/>') #if ( $item.<xsl:value-of select="$fieldprop"/> == '<xsl:value-of select="@value"/>')
<xsl:call-template name="showprompt"> <xsl:call-template name="showprompt">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="fallback" select="@value"/> <xsl:with-param name="fallback" select="@value"/>
</xsl:call-template> </xsl:call-template>
#end #end
@ -763,6 +786,7 @@
<xsl:value-of select="@verb"/> <xsl:value-of select="@verb"/>
</xsl:attribute> </xsl:attribute>
<xsl:call-template name="showprompt"> <xsl:call-template name="showprompt">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="fallback" select="@verb"/> <xsl:with-param name="fallback" select="@verb"/>
</xsl:call-template> </xsl:call-template>
</button> </button>
@ -802,6 +826,7 @@
</xsl:attribute> </xsl:attribute>
<td class="label"> <td class="label">
${FormHelper.LabelFor( "instance.<xsl:value-of select="@name"/>", "<xsl:call-template name="showprompt"> ${FormHelper.LabelFor( "instance.<xsl:value-of select="@name"/>", "<xsl:call-template name="showprompt">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="fallback" select="@name"/> <xsl:with-param name="fallback" select="@name"/>
</xsl:call-template>")} </xsl:call-template>")}
</td> </td>
@ -840,6 +865,7 @@
</xsl:attribute> </xsl:attribute>
<td class="label" rowspan="2"> <td class="label" rowspan="2">
${FormHelper.LabelFor( "instance.<xsl:value-of select="@name"/>", "<xsl:call-template name="showprompt"> ${FormHelper.LabelFor( "instance.<xsl:value-of select="@name"/>", "<xsl:call-template name="showprompt">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="fallback" select="@name"/> <xsl:with-param name="fallback" select="@name"/>
</xsl:call-template>")} </xsl:call-template>")}
</td> </td>
@ -906,14 +932,10 @@
<xsl:value-of select="$oddness"/> <xsl:value-of select="$oddness"/>
</xsl:attribute> </xsl:attribute>
<td class="label" rowspan="2"> <td class="label" rowspan="2">
${FormHelper.LabelFor( "instance.<xsl:value-of select="@name"/>", "<xsl:choose> ${FormHelper.LabelFor( "instance.<xsl:value-of select="@name"/>", "<xsl:call-template name="showprompt">
<xsl:when test="adl:prompt[@locale = $locale]"> <xsl:with-param name="node" select="."/>
<xsl:apply-templates select="adl:prompt[@locale = $locale]"/> <xsl:with-param name="fallback" select="@name"/>
</xsl:when> </xsl:call-template>")}
<xsl:otherwise>
<xsl:value-of select="@name"/>
</xsl:otherwise>
</xsl:choose>")}
</td> </td>
<td class="widget" colspan="2"> <td class="widget" colspan="2">
${FormHelper.TextArea( "instance.<xsl:value-of select="@name"/>", "%{rows='8', cols='60', title='<xsl:value-of select="$if-missing"/>'}")} ${FormHelper.TextArea( "instance.<xsl:value-of select="@name"/>", "%{rows='8', cols='60', title='<xsl:value-of select="$if-missing"/>'}")}
@ -1249,14 +1271,10 @@
<xsl:attribute name="value"> <xsl:attribute name="value">
<xsl:value-of select="@value"/> <xsl:value-of select="@value"/>
</xsl:attribute> </xsl:attribute>
<xsl:choose> <xsl:call-template name="showprompt">
<xsl:when test="adl:prompt[@locale=$locale]"> <xsl:with-param name="node" select="."/>
<xsl:value-of select="adl:prompt[@locale=$locale]/@prompt"/> <xsl:with-param name="fallback" select="@value"/>
</xsl:when> </xsl:call-template>
<xsl:otherwise>
<xsl:value-of select="@value"/>
</xsl:otherwise>
</xsl:choose>
</option> </option>
</xsl:template> </xsl:template>
@ -1286,9 +1304,14 @@
#capturefor( title) #capturefor( title)
<xsl:value-of select="normalize-space( concat( 'List ', $withpluralsuffix))"/> <xsl:value-of select="normalize-space( concat( 'List ', $withpluralsuffix))"/>
#end #end
#capturefor( headextras)
<xsl:call-template name="head"/>
#end
<xsl:call-template name="top"/>
<xsl:call-template name="list"> <xsl:call-template name="list">
<xsl:with-param name="list" select="."/> <xsl:with-param name="list" select="."/>
</xsl:call-template> </xsl:call-template>
<xsl:call-template name="foot"/>
</xsl:template> </xsl:template>
<!-- layout of a list assuming an empty layout --> <!-- layout of a list assuming an empty layout -->
@ -1300,7 +1323,8 @@
<xsl:text> <xsl:text>
</xsl:text> </xsl:text>
<xsl:variable name="withpluralsuffix"> <xsl:variable name="withpluralsuffix">
<!-- English-laguage syntactic sugar of entity name --> <!-- English-laguage syntactic sugar of entity name. TODO (bug 1896): This really /must/ not be here.
some means of doing i18n syntactic sugar needs to be spliced in. -->
<xsl:choose> <xsl:choose>
<xsl:when test="../@name='Person'">People</xsl:when> <xsl:when test="../@name='Person'">People</xsl:when>
<xsl:when test="starts-with( substring(../@name, string-length(../@name) ), 's')"> <xsl:when test="starts-with( substring(../@name, string-length(../@name) ), 's')">
@ -1323,7 +1347,7 @@
Auto generated Velocity list for <xsl:value-of select="ancestor::adl:entity/@name"/>, Auto generated Velocity list for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL. generated from ADL.
Generated using adl2listview.xsl <xsl:value-of select="substring( '$Revision: 1.15 $', 10)"/> Generated using adl2listview.xsl <xsl:value-of select="substring( '$Revision: 1.16 $', 10)"/>
</xsl:comment> </xsl:comment>
<xsl:call-template name="install-scripts"/> <xsl:call-template name="install-scripts"/>
</head> </head>
@ -1393,14 +1417,10 @@
<th> <th>
<xsl:variable name="pname" select="@property"/> <xsl:variable name="pname" select="@property"/>
<xsl:variable name="property" select="$list/ancestor::adl:entity//adl:property[@name=$pname]"/> <xsl:variable name="property" select="$list/ancestor::adl:entity//adl:property[@name=$pname]"/>
<xsl:choose> <xsl:call-template name="showprompt">
<xsl:when test="$property/adl:prompt[@locale=$locale]"> <xsl:with-param name="node" select="$property"/>
<xsl:value-of select="$property/adl:prompt[@locale=$locale]/@prompt"/> <xsl:with-param name="fallback" select="@property"/>
</xsl:when> </xsl:call-template>
<xsl:otherwise>
<xsl:value-of select="@property"/>
</xsl:otherwise>
</xsl:choose>
</th> </th>
</xsl:for-each> </xsl:for-each>
<xsl:for-each select="$list/ancestor::adl:entity/adl:form"> <xsl:for-each select="$list/ancestor::adl:entity/adl:form">
@ -1478,16 +1498,12 @@
<xsl:otherwise> <xsl:otherwise>
<!-- properties are not 'listed' --> <!-- properties are not 'listed' -->
<tr> <tr>
<xsl:for-each select="$list/ancestor::adl:entity//adl:property[@distinct='user' and not( @type='link' or @type='list')]"> <xsl:for-each select="$list/ancestor::adl:entity//adl:property[(@distinct='user' or @distinct='all') and not( @type='link' or @type='list')]">
<th> <th>
<xsl:choose> <xsl:call-template name="showprompt">
<xsl:when test="adl:prompt[@locale=$locale]"> <xsl:with-param name="node" select="."/>
<xsl:value-of select="adl:prompt[@locale=$locale]/@prompt"/> <xsl:with-param name="fallback" select="@name"/>
</xsl:when> </xsl:call-template>
<xsl:otherwise>
<xsl:value-of select="@name"/>
</xsl:otherwise>
</xsl:choose>
</th> </th>
</xsl:for-each> </xsl:for-each>
<xsl:for-each select="$list/ancestor::adl:entity/adl:form"> <xsl:for-each select="$list/ancestor::adl:entity/adl:form">
@ -1501,7 +1517,7 @@
#set( $oddity = "odd") #set( $oddity = "odd")
#end #end
<tr class="$oddity"> <tr class="$oddity">
<xsl:for-each select="$list/ancestor::adl:entity//adl:property[@distinct='user']"> <xsl:for-each select="$list/ancestor::adl:entity//adl:property[@distinct='user' or @distinct='all']">
<td> <td>
<xsl:choose> <xsl:choose>
<xsl:when test="@type = 'date'"> <xsl:when test="@type = 'date'">
@ -1586,17 +1602,65 @@
${ScriptsHelper.InstallScript( "Panes")} ${ScriptsHelper.InstallScript( "Panes")}
</xsl:template> </xsl:template>
<xsl:template match="navigation">
foobar!
</xsl:template>
<xsl:template match="adl:navigation">
<xsl:variable name="pagename" select="@name"/>
<ul class="generatednav">
<xsl:choose>
<xsl:when test="@include='list'">
<xsl:for-each select="//adl:entity[adl:list[@name=$pagename]]">
<li>
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat( '$siteRoot', '/', $area-name, '/', @name, '/', adl:list[position()=1]/@name, '.rails')"/>
</xsl:attribute>
<xsl:value-of select="@name"/>
</a>
</li>
</xsl:for-each>
</xsl:when>
<xsl:when test="@include='form'">
<xsl:for-each select="//adl:entity[adl:form[@name=$pagename]]">
<li>
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat( '$siteRoot', '/', $area-name, '/', @name, '/', adl:list[position()=1]/@name, '.rails')"/>
</xsl:attribute>
<xsl:value-of select="@name"/>
</a>
</li>
</xsl:for-each>
</xsl:when>
<xsl:when test="@include='page'">
<xsl:for-each select="//adl:entity[adl:page[@name=$pagename]]">
<li>
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat( '$siteRoot', '/', $area-name, '/', @name, '/', adl:list[position()=1]/@name, '.rails')"/>
</xsl:attribute>
<xsl:value-of select="@name"/>
</a>
</li>
</xsl:for-each>
</xsl:when>
</xsl:choose>
</ul>
</xsl:template>
<xsl:template name="head"> <xsl:template name="head">
<xsl:choose> <xsl:choose>
<xsl:when test="adl:head"> <xsl:when test="adl:head">
<xsl:for-each select="adl:head/*"> <xsl:for-each select="adl:head/*">
<xsl:copy-of select="."/> <xsl:apply-templates select="."/>
</xsl:for-each> </xsl:for-each>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:for-each select="//adl:content/adl:head/*"> <xsl:for-each select="//adl:content/adl:head/*">
<xsl:copy-of select="."/> <xsl:apply-templates select="."/>
</xsl:for-each> </xsl:for-each>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
@ -1606,22 +1670,22 @@
<xsl:choose> <xsl:choose>
<xsl:when test="adl:top"> <xsl:when test="adl:top">
<xsl:for-each select="adl:top/*"> <xsl:for-each select="adl:top/*">
<xsl:copy-of select="."/> <xsl:apply-templates select="."/>
</xsl:for-each> </xsl:for-each>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:for-each select="//adl:content/adl:top/*"> <xsl:for-each select="//adl:content/adl:top/*">
<xsl:copy-of select="."/> <xsl:apply-templates select="."/>
</xsl:for-each> </xsl:for-each>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:if test="$generate-site-navigation"> <xsl:if test="$generate-site-navigation = 'true'">
<ul class="generatednav"> <ul class="generatednav">
<xsl:for-each select="//adl:entity[adl:list[@name='list']]"> <xsl:for-each select="//adl:entity[adl:list[@name='list']]">
<li> <li>
<a> <a>
<xsl:attribute name="href"> <xsl:attribute name="href">
<xsl:value-of select="concat( '$siteRoot', '/auto/', @name, '/', adl:list[position()=1]/@name, '.rails')"/> <xsl:value-of select="concat( '$siteRoot', '/', $area-name, '/', @name, '/', adl:list[position()=1]/@name, '.rails')"/>
</xsl:attribute> </xsl:attribute>
<xsl:value-of select="@name"/> <xsl:value-of select="@name"/>
</a> </a>
@ -1635,12 +1699,12 @@
<xsl:choose> <xsl:choose>
<xsl:when test="adl:foot"> <xsl:when test="adl:foot">
<xsl:for-each select="adl:foot/*"> <xsl:for-each select="adl:foot/*">
<xsl:copy-of select="."/> <xsl:apply-templates select="."/>
</xsl:for-each> </xsl:for-each>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:for-each select="//adl:content/adl:foot/*"> <xsl:for-each select="//adl:content/adl:foot/*">
<xsl:copy-of select="."/> <xsl:apply-templates select="."/>
</xsl:for-each> </xsl:for-each>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
@ -1652,6 +1716,7 @@
<xsl:template name="showprompt"> <xsl:template name="showprompt">
<xsl:param name="fallback" select="Unknown"/> <xsl:param name="fallback" select="Unknown"/>
<xsl:param name="node" select="."/> <xsl:param name="node" select="."/>
<xsl:param name="locale" select="'en-GB'"/>
<xsl:choose> <xsl:choose>
<xsl:when test="$node/adl:prompt[@locale=$locale]"> <xsl:when test="$node/adl:prompt[@locale=$locale]">
<xsl:value-of select="$node/adl:prompt[@locale=$locale][1]/@prompt"/> <xsl:value-of select="$node/adl:prompt[@locale=$locale][1]/@prompt"/>