bug 2821 : Changes to ADL to implement the 'PrototypeFor classes carry default values for forms' solution.
status 2821: resolved FIXED
This commit is contained in:
parent
d2b026f8b9
commit
148624c084
3 changed files with 170 additions and 37 deletions
|
|
@ -8,8 +8,8 @@
|
|||
Transform ADL into C# entity classes
|
||||
|
||||
$Author: sb $
|
||||
$Revision: 1.18 $
|
||||
$Date: 2009-03-02 10:31:44 $
|
||||
$Revision: 1.19 $
|
||||
$Date: 2009-04-28 13:34:14 $
|
||||
-->
|
||||
|
||||
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
|
||||
|
|
@ -70,7 +70,7 @@
|
|||
// (c)2007 Cygnet Solutions Ltd
|
||||
//
|
||||
// Automatically generated from application description using
|
||||
// adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.18 $', 10)"/>
|
||||
// adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.19 $', 10)"/>
|
||||
//
|
||||
// <xsl:value-of select="/adl:application/@revision"/>
|
||||
//
|
||||
|
|
@ -97,7 +97,7 @@
|
|||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Automatically generated from description of group <xsl:value-of select="@name"/>
|
||||
/// using adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.18 $', 10)"/>.
|
||||
/// using adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.19 $', 10)"/>.
|
||||
///
|
||||
/// DO NOT EDIT THIS FILE!
|
||||
/// </remarks>
|
||||
|
|
@ -123,7 +123,7 @@
|
|||
// (c)2007 Cygnet Solutions Ltd
|
||||
//
|
||||
// Automatically generated from application description using
|
||||
// adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.18 $', 10)"/>
|
||||
// adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.19 $', 10)"/>
|
||||
//
|
||||
// <xsl:value-of select="/adl:application/@revision"/>
|
||||
//
|
||||
|
|
@ -149,7 +149,7 @@
|
|||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Automatically generated from description of entity <xsl:value-of select="@name"/>
|
||||
/// using adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.18 $', 10)"/>.
|
||||
/// using adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.19 $', 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.
|
||||
///
|
||||
|
|
@ -386,10 +386,29 @@
|
|||
<!-- 'descendant' to catch properties inside keys as well as properties which are direct children -->
|
||||
<xsl:apply-templates select="descendant::adl:property"/>
|
||||
}
|
||||
}
|
||||
/* ---- [ cut here: next file 'junk'] ------------------------- */
|
||||
|
||||
/// A prototype for <xsl:value-of select="@name"/> used when initialising forms for which
|
||||
/// there is as yet no real record. This has only those properties of <xsl:value-of select="@name"/>
|
||||
/// which have default values. Objects of this class are not known to NHibernate and are
|
||||
/// never persisted to the database.
|
||||
public class <xsl:value-of select="concat( 'PrototypeFor', @name)"/> {
|
||||
|
||||
</xsl:template>
|
||||
/// Dummy IsNew property always returns true
|
||||
public Boolean IsNew { get { return true; }}
|
||||
|
||||
/// Dummy user identifier which always returns just '[new]'
|
||||
public string UserIdentifier { get { return "[new]";}}
|
||||
|
||||
<xsl:for-each select="adl:property">
|
||||
<xsl:call-template name="prototype-property">
|
||||
<xsl:with-param name="property" select="."/>
|
||||
</xsl:call-template>
|
||||
</xsl:for-each>
|
||||
}
|
||||
}
|
||||
/* ---- [ cut here: next file 'junk'] ------------------------- */
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="adl:property[@concrete='false']">
|
||||
<!-- generate nothing for non-concrete properties -->
|
||||
|
|
@ -440,7 +459,7 @@
|
|||
</xsl:when>
|
||||
<xsl:when test="normalize-space( $nullable-decoration) = '?'"> = null</xsl:when>
|
||||
<xsl:when test="$base-type = 'Boolean'"> = false</xsl:when>
|
||||
<xsl:when test="$base-type = 'int'"> = 0</xsl:when>
|
||||
<xsl:when test="$base-type = 'integer'"> = 0</xsl:when>
|
||||
<xsl:when test="$csharp-type = 'Decimal'"> = 0.0M</xsl:when>
|
||||
<xsl:when test="$base-type = 'real'"> = 0.0</xsl:when>
|
||||
<xsl:when test="$csharp-type = 'String'">
|
||||
|
|
@ -748,4 +767,93 @@
|
|||
<xsl:value-of select="translate($unnormalisedname,
|
||||
$notpermittedinconstantname, $permittedinconstantname)"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="prototype-property">
|
||||
<xsl:param name="property"/>
|
||||
<xsl:apply-templates select="help"/>
|
||||
|
||||
<xsl:variable name="base-type">
|
||||
<xsl:call-template name="base-type">
|
||||
<xsl:with-param name="property" select="$property"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="csharp-type">
|
||||
<xsl:call-template name="csharp-type">
|
||||
<xsl:with-param name="property" select="$property"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="nullable-decoration">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@required='true'"/>
|
||||
<!-- when required is 'true' null is not permitted anyway; otherwise... -->
|
||||
<xsl:when test="@type='message'"/>
|
||||
<xsl:when test="$base-type='entity'"/>
|
||||
<xsl:when test="$base-type='string'"/>
|
||||
<xsl:when test="$base-type='text'"/>
|
||||
<!-- entities and strings are always nullable, don't need decoration -->
|
||||
<xsl:when test="$base-type='list'"/>
|
||||
<xsl:when test="$base-type='link'"/>
|
||||
<!-- things which are collections are not nullable -->
|
||||
<xsl:otherwise>?</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="initialiser">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@default">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$csharp-type = 'String'">
|
||||
"<xsl:value-of select="@default"/>"
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="@default"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="$nullable-decoration = '?'">
|
||||
null
|
||||
</xsl:when>
|
||||
<xsl:when test="$base-type = 'Boolean'">false</xsl:when>
|
||||
<xsl:when test="$base-type = 'integer'">0</xsl:when>
|
||||
<xsl:when test="$csharp-type = 'Decimal'">0.0M</xsl:when>
|
||||
<xsl:when test="$base-type = 'real'">0.0</xsl:when>
|
||||
<xsl:when test="$base-type = 'date'">new DateTime()</xsl:when>
|
||||
<xsl:when test="$csharp-type = 'String'">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@required='true'">
|
||||
""
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
null
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
null
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
/// <summary>
|
||||
/// Auto generated prototype property for field <xsl:value-of select="$property/@name"/>
|
||||
/// </summary>
|
||||
<xsl:apply-templates select="adl:prompt"/>
|
||||
<!-- TODO: this should get the size right if type = 'defined', but hasn't been tested -->
|
||||
<xsl:if test="$base-type = 'string'">
|
||||
<xsl:variable name="base-size">
|
||||
<xsl:call-template name="base-size">
|
||||
<xsl:with-param name="property" select="$property"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
[FieldWidth(<xsl:value-of select="$base-size"/>)]
|
||||
</xsl:if>
|
||||
<xsl:if test="$property/@distinct = 'user' or $property/@distinct = 'all'">[IsUserDistinct()]</xsl:if>
|
||||
<xsl:if test="$property/@type = 'money'">
|
||||
[Dimension( "money",Unit="<xsl:value-of select="$property/ancestor::adl:application/@currency"/>")]
|
||||
</xsl:if>
|
||||
public virtual <xsl:value-of select="normalize-space( $csharp-type)"/><xsl:value-of select="$nullable-decoration"/><xsl:text> </xsl:text> <xsl:value-of select="@name"/>
|
||||
{
|
||||
get { return <xsl:value-of select="normalize-space( $initialiser)"/>;}
|
||||
}
|
||||
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
Loading…
Add table
Add a link
Reference in a new issue