bug 1802 : adl2controllerclasses.xslt was generating collections for every menu a form might need, not for every menu the form did need. This had severe performance penalties. Sorted.

This commit is contained in:
sb 2008-04-18 09:27:29 +00:00
parent 4efb909880
commit 7e8fcf62f5
2 changed files with 81 additions and 27 deletions

View file

@ -9,8 +9,8 @@
Transform ADL into (partial) controller classes
$Author: sb $
$Revision: 1.21 $
$Date: 2008-04-17 17:33:16 $
$Revision: 1.22 $
$Date: 2008-04-18 09:27:29 $
-->
<!-- 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
// Automatically generated from application description using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.21 $', 10)"/>
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.22 $', 10)"/>
//
// 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
// Automatically generated from application description using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.21 $', 10)"/>
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.22 $', 10)"/>
//
// This file is automatically generated; DO NOT EDIT IT.
//
@ -195,7 +195,7 @@ namespace <xsl:value-of select="$controllerns"/> {
if ( record == null) {
/* it seems to be new, create persistent object */
AssertUserCanCreate()
AssertUserCanCreate();
try {
record = new <xsl:value-of select="concat($entityns, '.', @name)"/>(<xsl:for-each select="adl:key/adl:property">
<xsl:variable name="basetype">
@ -405,8 +405,8 @@ namespace <xsl:value-of select="$controllerns"/> {
</xsl:if>);
}
<xsl:call-template name="menus">
<xsl:with-param name="entity" select="."/>
<xsl:call-template name="formmenus">
<xsl:with-param name="form" select="adl:form[position()=1]"/>
</xsl:call-template>
RenderViewWithFailover("<xsl:value-of select="concat( adl:form[position()=1]/@name, '.vm')"/>",
"<xsl:value-of select="concat( adl:form[position()=1]/@name, '.auto.vm')"/>");
@ -595,8 +595,8 @@ namespace <xsl:value-of select="$controllerns"/> {
ISession hibernator =
NHibernateHelper.GetCurrentSession( <xsl:if test="$authentication-layer = 'Database'">Session[ NHibernateHelper.USERTOKEN],
Session[NHibernateHelper.PASSTOKEN]</xsl:if>);
<xsl:call-template name="menus">
<xsl:with-param name="entity" select="ancestor::adl:entity"/>
<xsl:call-template name="formmenus">
<xsl:with-param name="form" select="."/>
</xsl:call-template>
<xsl:if test="$authentication-layer = 'Database'">
@ -692,8 +692,8 @@ namespace <xsl:value-of select="$controllerns"/> {
</xsl:if>
PropertyBag["instance"] = record;
<xsl:call-template name="menus">
<xsl:with-param name="entity" select=".."/>
<xsl:call-template name="formmenus">
<xsl:with-param name="form" select="."/>
</xsl:call-template>
RenderViewWithFailover("<xsl:value-of select="concat( @name, '.vm')"/>", "<xsl:value-of select="concat( @name, '.auto.vm')"/>");
}
@ -716,7 +716,46 @@ namespace <xsl:value-of select="$controllerns"/> {
/* <xsl:apply-templates/> */
</xsl:template>
<xsl:template name="menus">
<!-- produce all menus for a given form: harder, but more efficient -->
<xsl:template name="formmenus">
<xsl:param name="form"/>
<xsl:choose>
<xsl:when test="$form/@properties = 'all'">
<xsl:call-template name="entitymenus">
<xsl:with-param name="entity" select="$form/ancestor::adl:entity"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$form//field">
<xsl:variable name="propname" select="@property"/>
<xsl:choose>
<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="@name"/> */
<xsl:call-template name="menu">
<xsl:with-param name="property" select="$form/ancestor::adl:entity/adl:property[@name=$propname]"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$form/ancestor::adl:entity/adl:property[@name=$propname and @type='link']">
/* produce a list of <xsl:value-of select="$form/ancestor::adl:entity/adl:property[@name=$propname]/@entity"/> to populate the LHS of the shuffle for <xsl:value-of select="@name"/> */
<xsl:call-template name="menu">
<xsl:with-param name="property" select="$form/ancestor::adl:entity/adl:property[@name=$propname]"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$form/ancestor::adl:entity/adl:property[@name=$propname and @type='list']">
/* produce a list of <xsl:value-of select="$form/ancestor::adl:entity/adl:property[@name=$propname]/@entity"/> to populate the multi-select for <xsl:value-of select="@name"/> */
<xsl:call-template name="menu">
<xsl:with-param name="property" select="$form/ancestor::adl:entity/adl:property[@name=$propname]"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- produce all menus for a given entity: easier, but less efficient -->
<xsl:template name="entitymenus">
<xsl:param name="entity"/>
/* there's no way I can find of producing a set of just those entities
* we'll need menus for. So we set up variables for all the menus we might