Work on improving the NHibernate performance (not good enough yet).
This commit is contained in:
		
							parent
							
								
									9a6b02cd6b
								
							
						
					
					
						commit
						aec6114d9f
					
				|  | @ -9,8 +9,8 @@ | |||
|     Transform ADL into (partial) controller classes | ||||
|      | ||||
|     $Author: sb $ | ||||
|     $Revision: 1.15 $ | ||||
|     $Date: 2008-03-12 13:46:10 $ | ||||
|     $Revision: 1.16 $ | ||||
|     $Date: 2008-03-12 17:40:02 $ | ||||
|   --> | ||||
| 
 | ||||
|   <!-- WARNING WARNING WARNING: Do NOT reformat this file!  | ||||
|  | @ -49,38 +49,66 @@ | |||
|     <xsl:param name="abstract-key-name-convention" select="Id"/> | ||||
| 
 | ||||
|     <xsl:template match="adl:application"> | ||||
|       <xsl:call-template name="collection-factory"/> | ||||
|       <xsl:apply-templates select="adl:entity"/> | ||||
|     </xsl:template> | ||||
| 
 | ||||
|   <xsl:template name="collection-factory"> | ||||
|     /* ---- [ cut here: next file '<xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller')"/>.auto.cs'] ---------------- */ | ||||
| //------------------------------------------------------------------ | ||||
| // | ||||
| //  Application Description Language framework | ||||
| //  <xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller')"/>.auto.cs | ||||
| // | ||||
| // (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.16 $', 10)"/> | ||||
| // | ||||
| //  This file is automatically generated; DO NOT EDIT IT. | ||||
| // | ||||
| //------------------------------------------------------------------ | ||||
| 
 | ||||
| using System; | ||||
| using System.Data; | ||||
| using System.Collections.Generic; | ||||
| using NHibernate; | ||||
| using NHibernate.Expression; | ||||
| using <xsl:value-of select="$entityns"/>; | ||||
| 
 | ||||
| namespace <xsl:value-of select="$controllerns"/> { | ||||
| 
 | ||||
|   /// <summary> | ||||
|   /// Automatically generated abstract super class for controllers for the | ||||
|   /// <xsl:value-of select="/adl:application/@name"/> application | ||||
|   ///  | ||||
|   /// DO NOT EDIT THIS FILE! | ||||
|   /// </summary> | ||||
|   public abstract class <xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller')"/> : BaseController { | ||||
|     <xsl:for-each select="//adl:entity"> | ||||
|       /// <summary> | ||||
|       /// Return a list of all instances of <xsl:value-of select="@name"/> for use in menus, etc; | ||||
|       /// </summary> | ||||
|       protected IList<<xsl:value-of select="concat( $entityns, '.', @name)"/>> <xsl:value-of select="concat( 'FetchAll', @name)"/>( ISession hibernator) { | ||||
|         return hibernator.CreateCriteria(typeof(<xsl:value-of select="concat( $entityns, '.', @name)"/>)) | ||||
|       <xsl:for-each select="descendant::adl:property[@distinct='user']"> | ||||
|           .AddOrder( <xsl:value-of select="concat('new Order( "', @name, '", true)')"/>) | ||||
|       </xsl:for-each> | ||||
|           .SetCacheable( true) | ||||
|           .SetCacheRegion( "<xsl:value-of select="/adl:application/@name"/>") | ||||
|           .List<<xsl:value-of select="concat( $entityns, '.', @name)"/>>(); | ||||
|       } | ||||
|        | ||||
|     </xsl:for-each> | ||||
|     } | ||||
|   } | ||||
|   </xsl:template> | ||||
| 
 | ||||
|     <!-- Don't bother generating anything for foreign entities --> | ||||
|     <xsl:template match="adl:entity[@foreign='true']"/> | ||||
|    | ||||
|     <xsl:template match="adl:entity[adl:form|adl:page|adl:list]"> | ||||
|       <!-- 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.15 $', 11)"/> | ||||
|       <xsl:variable name="transform-revision" | ||||
|                     select="substring( $transform-rev1, 0, string-length( $transform-rev1) - 1)"/> | ||||
| 
 | ||||
|       <!-- xsl:variable name="key"> | ||||
|         <xsl:call-template name="primary-key-name"> | ||||
|           <xsl:with-param name="entity" select="."/> | ||||
|         </xsl:call-template> | ||||
|       </xsl:variable> | ||||
|       <xsl:variable name="keytype"> | ||||
|         <xsl:choose> | ||||
|           <xsl:when test="adl:key/adl:property"> | ||||
|             <xsl:call-template name="primary-key-csharp-type"> | ||||
|               <xsl:with-param name="entity" select="."/> | ||||
|             </xsl:call-template> | ||||
|           </xsl:when> | ||||
|           <xsl:otherwise>[no primary key]</xsl:otherwise> | ||||
|         </xsl:choose> | ||||
|       </xsl:variable --> | ||||
| 
 | ||||
| 
 | ||||
|       /* ---- [ cut here: next file '<xsl:value-of select="@name"/>Controller.auto.cs'] ---------------- */ | ||||
| 
 | ||||
|  | @ -93,7 +121,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="$transform-revision"/> | ||||
| //  adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.16 $', 10)"/> | ||||
| // | ||||
| //  This file is automatically generated; DO NOT EDIT IT. | ||||
| // | ||||
|  | @ -131,7 +159,7 @@ namespace <xsl:value-of select="$controllerns"/> { | |||
|   /// </summary> | ||||
|   [ Layout("empty"), Rescue("generalerror"),  | ||||
|     ControllerDetails("<xsl:value-of select="@name"/>", Area = "auto")] | ||||
|   public partial class <xsl:value-of select="@name"/>Controller : BaseController { | ||||
|   public partial class <xsl:value-of select="@name"/>Controller : <xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller')"/> { | ||||
| 
 | ||||
|       <xsl:if test="adl:form"> | ||||
|         <!-- unless there's at least one form, we won't generate a 'store' method --> | ||||
|  | @ -678,13 +706,17 @@ namespace <xsl:value-of select="$controllerns"/> { | |||
| 
 | ||||
|     <xsl:template name="menus"> | ||||
|       <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  | ||||
|            * need, and then only instantiate those we do need. */ | ||||
|       <!-- xsl:for-each select="//adl:entity"> | ||||
|           IList<<xsl:value-of select="concat( $entityns, '.', @name)"/>> <xsl:value-of select="concat( 'all', @name)"/> = null; | ||||
|       </xsl:for-each --> | ||||
|       <xsl:for-each select="$entity//adl:property[@type='entity']">  | ||||
|         <!-- $entity//adl:property because it is possible to have type='entity' in the key --> | ||||
|           /* produce a list of <xsl:value-of select="@entity"/> to populate the menu for <xsl:value-of select="@name"/> */ | ||||
|         <xsl:call-template name="menu"> | ||||
|           <xsl:with-param name="property" select="."/> | ||||
|         </xsl:call-template> | ||||
| 
 | ||||
|       </xsl:for-each> | ||||
|       <xsl:for-each select="$entity/adl:property[@type='link']"> | ||||
|         <!-- $entity/adl:property because it is not possible to have type='link' in the key --> | ||||
|  | @ -710,9 +742,7 @@ namespace <xsl:value-of select="$controllerns"/> { | |||
|       <xsl:param name="property"/> | ||||
|       <xsl:variable name="entity" select="//adl:entity[@name=$property/@entity]"/> | ||||
|           PropertyBag["<xsl:value-of select="concat('all_', $property/@name)"/>"] =  | ||||
|             hibernator.CreateCriteria(typeof(<xsl:value-of select="concat( $entityns, '.', $entity/@name)"/>))<xsl:for-each select="$entity//adl:property[@distinct='user']"> | ||||
|               <xsl:value-of select="concat('.AddOrder( new Order( "', @name, '", true))')"/> | ||||
|             </xsl:for-each>.List<<xsl:value-of select="concat( $entityns, '.', $property/@entity)"/>>(); | ||||
|             <xsl:value-of select="concat( 'FetchAll', $entity/@name)"/>( NHibernateHelper.GetCurrentSession()); | ||||
|     </xsl:template> | ||||
| 
 | ||||
|   <xsl:template name="primary-key-csharp-type"> | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue