Integration of all the good features from the SRU branch, plus much beneficial refactoring.

This commit is contained in:
sb 2008-05-19 14:49:18 +00:00
parent 41f45eb3cd
commit cde22a9e96
2 changed files with 392 additions and 295 deletions

View file

@ -9,8 +9,8 @@
Transform ADL into (partial) controller classes
$Author: sb $
$Revision: 1.28 $
$Date: 2008-05-16 15:26:20 $
$Revision: 1.29 $
$Date: 2008-05-19 14:49:18 $
-->
<!-- 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.28 $', 10)"/>
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.29 $', 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.28 $', 10)"/>
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.29 $', 10)"/>
//
// This file is automatically generated; DO NOT EDIT IT.
//
@ -531,10 +531,51 @@ namespace <xsl:value-of select="$controllerns"/> {
ISession hibernator =
NHibernateHelper.GetCurrentSession( <xsl:if test="$authentication-layer = 'Database'">Session[ NHibernateHelper.USERTOKEN],
Session[NHibernateHelper.PASSTOKEN]</xsl:if>);
IList&lt;<xsl:value-of select="concat( $entityns, '.', @name)"/>&gt; instances =
hibernator.CreateCriteria(typeof(<xsl:value-of select="concat($entityns, '.', @name)"/>))<xsl:for-each select="adl:property[@distinct='user']">
<xsl:value-of select="concat( '.AddOrder( new Order( &#34;', @name, '&#34;, true))')"/>
</xsl:for-each>.List&lt;<xsl:value-of select="concat($entityns, '.', @name)"/>&gt;();
ICriteria search =
hibernator.CreateCriteria(typeof(<xsl:value-of select="concat( $entityns, '.', @name)"/>));
<xsl:for-each select="adl:property">
<xsl:variable name="base-type">
<xsl:call-template name="base-type">
<xsl:with-param name="property" select="."/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="@type='message'">
<!-- search.Add( Expression.Like( "<xsl:value-of select="@name"/>.LocalText", "%"+Params["<xsl:value-of select="concat( 'search_', @name)"/>"]+"%")); -->
</xsl:when>
<xsl:when test="$base-type = 'integer'">
if ( ! String.IsNullOrEmpty( Params[ "<xsl:value-of select="concat( 'search_', @name)"/>"])) {
search.Add( Expression.Eq( "<xsl:value-of select="@name"/>", Int32.Parse( Params["<xsl:value-of select="concat( 'search_', @name)"/>"])));
}
</xsl:when>
<xsl:when test="$base-type = 'real'">
if ( ! String.IsNullOrEmpty( Params[ "<xsl:value-of select="concat( 'search_', @name)"/>"])) {
search.Add( Expression.Eq( "<xsl:value-of select="@name"/>", Int32.Parse( Params["<xsl:value-of select="concat( 'search_', @name)"/>"])));
}
</xsl:when>
<xsl:when test="$base-type = 'money'">
if ( ! String.IsNullOrEmpty( Params[ "<xsl:value-of select="concat( 'search_', @name)"/>"])) {
search.Add( Expression.Eq( "<xsl:value-of select="@name"/>", Int32.Parse( Params["<xsl:value-of select="concat( 'search_', @name)"/>"])));
}
</xsl:when>
<!-- xsl:when test="$base-type = 'entity'">
search.Add( Expression.Like( "<xsl:value-of select="@name"/>.UserIdentifier", "%"+Params["<xsl:value-of select="concat( 'search_', @name)"/>"]+"%"));
</xsl:when doesn't work -->
<xsl:otherwise>
if ( ! String.IsNullOrEmpty( Params[ "<xsl:value-of select="concat( 'search_', @name)"/>"])) {
search.Add( Expression.Like( "<xsl:value-of select="@name"/>", "%"+Params["<xsl:value-of select="concat( 'search_', @name)"/>"]+"%"));
}
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:for-each select="adl:property[@distinct='user' or @distinct='all']">
search.AddOrder(<xsl:value-of select="concat( ' new Order( &#34;', @name, '&#34;, true)')"/>);
</xsl:for-each>
IList&lt;<xsl:value-of select="concat( $entityns, '.', @name)"/>&gt; instances = search.List&lt;<xsl:value-of select="concat( $entityns, '.', @name)"/>&gt;();
<xsl:if test="$authentication-layer = 'Database'">
PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN];
@ -1036,6 +1077,28 @@ namespace <xsl:value-of select="$controllerns"/> {
</xsl:choose>
</xsl:template>
<!-- argument: a property
returns 'true' if that property is of a type which makes it searchable,
else 'false'. See also how search fields are generated in adl2views.xsl -->
<xsl:template name="is-searchable">
<xsl:param name="property"/>
<xsl:variable name="base-type">
<xsl:call-template name="base-type">
<xsl:with-param name="property" select="$property"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$base-type='string'">true</xsl:when>
<xsl:when test="$base-type='integer'">true</xsl:when>
<xsl:when test="$base-type='real'">true</xsl:when>
<xsl:when test="$base-type='money'">true</xsl:when>
<xsl:when test="$base-type='text'">true</xsl:when>
<xsl:when test="$base-type='entity'">true</xsl:when>
<xsl:otherwise>false</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="fetch-property-instance">
<!-- the property for which the instance is sought; it is assumed that
the property passed has type 'entity' -->