Refinements of the ADL transforms to have them better work with more than just the
SRU codebase. Note that synthetic primary key is now assumed to be 'Id'.... though actually most of the references to an entity's primary key should be looking it up rather than assuming its name.
This commit is contained in:
parent
e672bbd40f
commit
9b6fd82110
|
@ -9,8 +9,8 @@
|
||||||
Transform ADL into (partial) controller classes
|
Transform ADL into (partial) controller classes
|
||||||
|
|
||||||
$Author: af $
|
$Author: af $
|
||||||
$Revision: 1.1 $
|
$Revision: 1.2 $
|
||||||
$Date: 2008-01-09 15:01:45 $
|
$Date: 2008-01-14 16:53:31 $
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
|
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
|
||||||
|
@ -35,13 +35,17 @@
|
||||||
<xsl:apply-templates select="entity"/>
|
<xsl:apply-templates select="entity"/>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="entity[count(property/@distinct)!=1]">
|
||||||
|
<!-- Ignore entities withot a simple (non-composite) key. -->
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="entity">
|
<xsl:template match="entity">
|
||||||
<!-- what's all this about? the objective is to get the revision number of the
|
<!-- 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
|
transform into the output, /without/ getting that revision number overwritten
|
||||||
with the revision number of the generated file if the generated file is
|
with the revision number of the generated file if the generated file is
|
||||||
stored to CVS -->
|
stored to CVS -->
|
||||||
<xsl:variable name="transform-rev1"
|
<xsl:variable name="transform-rev1"
|
||||||
select="substring( '$Revision: 1.1 $', 11)"/>
|
select="substring( '$Revision: 1.2 $', 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)"/>
|
||||||
|
|
||||||
|
@ -69,25 +73,18 @@
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Data;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Configuration;
|
|
||||||
using System.Web;
|
|
||||||
using System.Web.Security;
|
|
||||||
using System.Web.UI;
|
|
||||||
using System.Web.UI.WebControls;
|
|
||||||
using System.Web.UI.WebControls.WebParts;
|
|
||||||
using System.Web.UI.HtmlControls;
|
|
||||||
using Castle.MonoRail.Framework.Helpers;
|
using Castle.MonoRail.Framework.Helpers;
|
||||||
using Cygnet.Web.Helpers;
|
using Cygnet.Web.Helpers;
|
||||||
using Cygnet.Web.Controllers;
|
using Cygnet.Web.Controllers;
|
||||||
|
using System.Web.Security;
|
||||||
using NHibernate;
|
using NHibernate;
|
||||||
using NHibernate.Expression;
|
using NHibernate.Expression;
|
||||||
using Castle.MonoRail.Framework;
|
using Castle.MonoRail.Framework;
|
||||||
using SRU.Hospitality.Entities;
|
using ADL.Entities;
|
||||||
using SRU.Hospitality.Helpers;
|
|
||||||
using ADL.Exceptions;
|
using ADL.Exceptions;
|
||||||
using Iesi.Collections.Generic;
|
using Iesi.Collections.Generic;
|
||||||
|
using <xsl:value-of select="$entityns" />;
|
||||||
|
|
||||||
namespace <xsl:value-of select="$controllerns"/> {
|
namespace <xsl:value-of select="$controllerns"/> {
|
||||||
|
|
||||||
|
@ -112,12 +109,10 @@ namespace <xsl:value-of select="$controllerns"/> {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void Store()
|
private void Store()
|
||||||
{
|
{
|
||||||
ISession hibernator =
|
ISession hibernator = NHibernateHelper.GetCurrentSession();
|
||||||
NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN],
|
|
||||||
Session[NHibernateHelper.PASSTOKEN]);
|
|
||||||
List<string> messages = new List<string>();
|
List<string> messages = new List<string>();
|
||||||
|
|
||||||
<xsl:value-of select="$entityns"/>.<xsl:value-of select="@name"/> record;
|
<xsl:value-of select="@name"/> record;
|
||||||
|
|
||||||
<xsl:apply-templates select="property"/>
|
<xsl:apply-templates select="property"/>
|
||||||
|
|
||||||
|
@ -126,11 +121,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
||||||
if ( String.IsNullOrEmpty( id))
|
if ( String.IsNullOrEmpty( id))
|
||||||
{
|
{
|
||||||
/* it's new, create persistent object */
|
/* it's new, create persistent object */
|
||||||
record = new <xsl:value-of select="$entityns"/>.<xsl:value-of select="@name"/>(<xsl:for-each select="property[@distinct='system']">Form[<xsl:value-of select="concat( 'instance.', @name)"/>]<xsl:choose>
|
record = new <xsl:value-of select="@name"/>();
|
||||||
<xsl:when test="position() = last()"/>
|
|
||||||
<xsl:otherwise>, </xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:for-each>);
|
|
||||||
|
|
||||||
/* perform any domain knowledge behaviour on the new record
|
/* perform any domain knowledge behaviour on the new record
|
||||||
* after instantiation */
|
* after instantiation */
|
||||||
|
@ -143,7 +134,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
||||||
record =
|
record =
|
||||||
hibernator.CreateCriteria(typeof(<xsl:value-of select="@name"/>))
|
hibernator.CreateCriteria(typeof(<xsl:value-of select="@name"/>))
|
||||||
.Add(Expression.Eq("<xsl:value-of select="$key"/>", Int32.Parse(id)))
|
.Add(Expression.Eq("<xsl:value-of select="$key"/>", Int32.Parse(id)))
|
||||||
.UniqueResult<<xsl:value-of select="$entityns"/>.<xsl:value-of select="@name"/>>();
|
.UniqueResult<<xsl:value-of select="@name"/>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( record != null)
|
if ( record != null)
|
||||||
|
@ -162,7 +153,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
||||||
.Add(Expression.Eq("<xsl:call-template name="primary-key">
|
.Add(Expression.Eq("<xsl:call-template name="primary-key">
|
||||||
<xsl:with-param name="entityname" select="@entity"/>
|
<xsl:with-param name="entityname" select="@entity"/>
|
||||||
</xsl:call-template>", Int32.Parse(Form["<xsl:value-of select="concat( 'instance.', @name)"/>"])))
|
</xsl:call-template>", Int32.Parse(Form["<xsl:value-of select="concat( 'instance.', @name)"/>"])))
|
||||||
.UniqueResult<<xsl:value-of select="$entityns"/>.<xsl:value-of select="@entity"/>>();
|
.UniqueResult<<xsl:value-of select="@entity"/>>();
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
|
|
||||||
<xsl:for-each select="property[@type='link']">
|
<xsl:for-each select="property[@type='link']">
|
||||||
|
@ -189,8 +180,8 @@ namespace <xsl:value-of select="$controllerns"/> {
|
||||||
<!-- todo: won't work for entities having natural keys -->
|
<!-- todo: won't work for entities having natural keys -->
|
||||||
<xsl:value-of select="concat( 'record.', @name)"/>.Add(
|
<xsl:value-of select="concat( 'record.', @name)"/>.Add(
|
||||||
hibernator.CreateCriteria(typeof(<xsl:value-of select="@entity"/>))
|
hibernator.CreateCriteria(typeof(<xsl:value-of select="@entity"/>))
|
||||||
.Add(Expression.Eq("<xsl:value-of select="@entity"/>Id", Int32.Parse(index)))
|
.Add(Expression.Eq("Id", Int32.Parse(index)))
|
||||||
.UniqueResult<<xsl:value-of select="$entityns"/>.<xsl:value-of select="@entity"/>>());
|
.UniqueResult<<xsl:value-of select="@entity"/>>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
|
@ -205,7 +196,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
||||||
/* updating <xsl:value-of select="@name"/> child records; first remove any not on the submitted list */
|
/* updating <xsl:value-of select="@name"/> child records; first remove any not on the submitted list */
|
||||||
foreach ( <xsl:value-of select="@entity"/> item in record.<xsl:value-of select="@name"/>)
|
foreach ( <xsl:value-of select="@entity"/> item in record.<xsl:value-of select="@name"/>)
|
||||||
{
|
{
|
||||||
String itemId = item.Key.ToString();
|
String itemId = item.KeyString;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
foreach ( string index in <xsl:value-of select="concat(@name, 'Values')"/>)
|
foreach ( string index in <xsl:value-of select="concat(@name, 'Values')"/>)
|
||||||
|
@ -228,8 +219,8 @@ namespace <xsl:value-of select="$controllerns"/> {
|
||||||
{
|
{
|
||||||
<xsl:value-of select="@entity"/> item =
|
<xsl:value-of select="@entity"/> item =
|
||||||
hibernator.CreateCriteria(typeof(<xsl:value-of select="@entity"/>))
|
hibernator.CreateCriteria(typeof(<xsl:value-of select="@entity"/>))
|
||||||
.Add(Expression.Eq("<xsl:value-of select="@entity"/>Id", Int32.Parse(index)))
|
.Add(Expression.Eq("Id", Int32.Parse(index)))
|
||||||
.UniqueResult<<xsl:value-of select="$entityns"/>.<xsl:value-of select="@entity"/>>();
|
.UniqueResult<<xsl:value-of select="@entity"/>>();
|
||||||
|
|
||||||
if ( ! record.<xsl:value-of select="@name"/>.Contains( item))
|
if ( ! record.<xsl:value-of select="@name"/>.Contains( item))
|
||||||
{
|
{
|
||||||
|
@ -261,13 +252,12 @@ namespace <xsl:value-of select="$controllerns"/> {
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyBag["messages"] = messages;
|
PropertyBag["messages"] = messages;
|
||||||
PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN];
|
|
||||||
PropertyBag["instance"] = record;
|
PropertyBag["instance"] = record;
|
||||||
|
|
||||||
<xsl:call-template name="menus">
|
<xsl:call-template name="menus">
|
||||||
<xsl:with-param name="entity" select="."/>
|
<xsl:with-param name="entity" select="."/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
RenderViewWithFailover("<xsl:value-of select="concat( form[position()=1]/@name, '.vm')"/>", "<xsl:value-of select="concat( form[position()=1]/@name, '.auto.vm')"/>");
|
RenderViewWithFailover("<xsl:value-of select="form[position()=1]/@name"/>");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -281,9 +271,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
||||||
[AccessibleThrough(Verb.Get)]
|
[AccessibleThrough(Verb.Get)]
|
||||||
public void Delete()
|
public void Delete()
|
||||||
{
|
{
|
||||||
ISession hibernator =
|
ISession hibernator = NHibernateHelper.GetCurrentSession();
|
||||||
NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN],
|
|
||||||
Session[NHibernateHelper.PASSTOKEN]);
|
|
||||||
string id = Params["<xsl:value-of select="concat( 'instance.', $key)"/>"];
|
string id = Params["<xsl:value-of select="concat( 'instance.', $key)"/>"];
|
||||||
string reallydelete = Params["reallydelete"];
|
string reallydelete = Params["reallydelete"];
|
||||||
|
|
||||||
|
@ -292,7 +280,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
||||||
<xsl:value-of select="@name"/> record =
|
<xsl:value-of select="@name"/> record =
|
||||||
hibernator.CreateCriteria(typeof(<xsl:value-of select="@name"/>))
|
hibernator.CreateCriteria(typeof(<xsl:value-of select="@name"/>))
|
||||||
.Add(Expression.Eq("<xsl:value-of select="$key"/>", Int32.Parse(id)))
|
.Add(Expression.Eq("<xsl:value-of select="$key"/>", Int32.Parse(id)))
|
||||||
.UniqueResult<<xsl:value-of select="$entityns"/>.<xsl:value-of select="@name"/>>();
|
.UniqueResult<<xsl:value-of select="@name"/>>();
|
||||||
|
|
||||||
if ( record != null)
|
if ( record != null)
|
||||||
{
|
{
|
||||||
|
@ -301,7 +289,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
||||||
hibernator.Delete(
|
hibernator.Delete(
|
||||||
hibernator.CreateCriteria(typeof(<xsl:value-of select="@name"/>))
|
hibernator.CreateCriteria(typeof(<xsl:value-of select="@name"/>))
|
||||||
.Add(Expression.Eq("<xsl:value-of select="$key"/>", Int32.Parse(id)))
|
.Add(Expression.Eq("<xsl:value-of select="$key"/>", Int32.Parse(id)))
|
||||||
.UniqueResult<<xsl:value-of select="$entityns"/>.<xsl:value-of select="@name"/>>());
|
.UniqueResult<<xsl:value-of select="@name"/>>());
|
||||||
|
|
||||||
hibernator.Flush();
|
hibernator.Flush();
|
||||||
}
|
}
|
||||||
|
@ -341,19 +329,16 @@ namespace <xsl:value-of select="$controllerns"/> {
|
||||||
/// <param name="view">The name of the list view to show</param>
|
/// <param name="view">The name of the list view to show</param>
|
||||||
public void InternalShowList( String view)
|
public void InternalShowList( String view)
|
||||||
{
|
{
|
||||||
ISession hibernator =
|
ISession hibernator = NHibernateHelper.GetCurrentSession();
|
||||||
NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN],
|
|
||||||
Session[NHibernateHelper.PASSTOKEN]);
|
|
||||||
IList<<xsl:value-of select="@name"/>> instances =
|
IList<<xsl:value-of select="@name"/>> instances =
|
||||||
hibernator.CreateCriteria(typeof(<xsl:value-of select="@name"/>))<xsl:for-each select="property[@distinct='user']">
|
hibernator.CreateCriteria(typeof(<xsl:value-of select="@name"/>))<xsl:for-each select="property[@distinct='user']">
|
||||||
<xsl:value-of select="concat( '.AddOrder( new Order( "', @name, '", true))')"/>
|
<xsl:value-of select="concat( '.AddOrder( new Order( "', @name, '", true))')"/>
|
||||||
</xsl:for-each>.List<<xsl:value-of select="@name"/>>();
|
</xsl:for-each>.List<<xsl:value-of select="@name"/>>();
|
||||||
|
|
||||||
PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN];
|
|
||||||
PropertyBag["instances"] =
|
PropertyBag["instances"] =
|
||||||
PaginationHelper.CreatePagination( this, instances, 25);
|
PaginationHelper.CreatePagination( this, instances, 25);
|
||||||
|
|
||||||
RenderViewWithFailover(view + ".vm", view + ".auto.vm");
|
RenderViewWithFailover(view);
|
||||||
}
|
}
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
}
|
}
|
||||||
|
@ -387,7 +372,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
||||||
<xsl:value-of select="../@natural-key"/>
|
<xsl:value-of select="../@natural-key"/>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:value-of select="concat( ../@name, 'Id')"/>
|
<xsl:value-of select="concat( '', 'Id')"/>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
|
@ -415,18 +400,15 @@ namespace <xsl:value-of select="$controllerns"/> {
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
if ( command.Equals( "delete"))
|
if ( command.Equals( "delete"))
|
||||||
{
|
{
|
||||||
ISession hibernator =
|
ISession hibernator = NHibernateHelper.GetCurrentSession();
|
||||||
NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN],
|
|
||||||
Session[NHibernateHelper.PASSTOKEN]);
|
|
||||||
string id = Form["<xsl:value-of select="concat( 'instance.', $key)"/>"];
|
string id = Form["<xsl:value-of select="concat( 'instance.', $key)"/>"];
|
||||||
|
|
||||||
PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN];
|
|
||||||
PropertyBag["instance"] =
|
PropertyBag["instance"] =
|
||||||
hibernator.CreateCriteria(typeof(<xsl:value-of select="../@name"/>))
|
hibernator.CreateCriteria(typeof(<xsl:value-of select="../@name"/>))
|
||||||
.Add(Expression.Eq("<xsl:value-of select="$key"/>", Int32.Parse(id)))
|
.Add(Expression.Eq("<xsl:value-of select="$key"/>", Int32.Parse(id)))
|
||||||
.UniqueResult<<xsl:value-of select="$entityns"/>.<xsl:value-of select="../@name"/>>();
|
.UniqueResult<<xsl:value-of select="../@name"/>>();
|
||||||
|
|
||||||
RenderViewWithFailover( "maybedelete.vm", "maybedelete.auto.vm");
|
RenderViewWithFailover( "maybedelete.vm");
|
||||||
}
|
}
|
||||||
else if ( command.Equals( "store"))
|
else if ( command.Equals( "store"))
|
||||||
{
|
{
|
||||||
|
@ -444,39 +426,32 @@ namespace <xsl:value-of select="$controllerns"/> {
|
||||||
[AccessibleThrough(Verb.Get)]
|
[AccessibleThrough(Verb.Get)]
|
||||||
public void <xsl:value-of select="@name"/>( )
|
public void <xsl:value-of select="@name"/>( )
|
||||||
{
|
{
|
||||||
ISession hibernator =
|
ISession hibernator = NHibernateHelper.GetCurrentSession();
|
||||||
NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN],
|
|
||||||
Session[NHibernateHelper.PASSTOKEN]);
|
|
||||||
<xsl:call-template name="menus">
|
<xsl:call-template name="menus">
|
||||||
<xsl:with-param name="entity" select=".."/>
|
<xsl:with-param name="entity" select=".."/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
|
RenderViewWithFailover("<xsl:value-of select="@name"/>");
|
||||||
PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN];
|
|
||||||
RenderViewWithFailover("<xsl:value-of select="concat( @name, '.vm')"/>", "<xsl:value-of select="concat( @name, '.auto.vm')"/>");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Show the form named <xsl:value-of select="@name"/>, containing the indicated record
|
/// Show the form named <xsl:value-of select="@name"/>, containing the indicated record
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="<xsl:value-of select="concat( ../@name, 'Id')"/>">the key value of the record to show</param>
|
/// <param name="Id">the key value of the record to show</param>
|
||||||
[AccessibleThrough(Verb.Get)]
|
[AccessibleThrough(Verb.Get)]
|
||||||
public void <xsl:value-of select="@name"/>( Int32 <xsl:value-of select="concat( ../@name, 'Id')"/>)
|
public void <xsl:value-of select="@name"/>( Int32 Id)
|
||||||
{
|
{
|
||||||
ISession hibernator =
|
ISession hibernator = NHibernateHelper.GetCurrentSession();
|
||||||
NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN],
|
<xsl:value-of select="../@name"/> record =
|
||||||
Session[NHibernateHelper.PASSTOKEN]);
|
|
||||||
<xsl:value-of select="$entityns"/>.<xsl:value-of select="../@name"/> record =
|
|
||||||
hibernator.CreateCriteria(typeof(<xsl:value-of select="../@name"/>))
|
hibernator.CreateCriteria(typeof(<xsl:value-of select="../@name"/>))
|
||||||
.Add(Expression.Eq("<xsl:value-of select="concat( ../@name, 'Id')"/>", <xsl:value-of select="../@name"/>Id))
|
.Add(Expression.Eq("Id", Id))
|
||||||
.UniqueResult<<xsl:value-of select="$entityns"/>.<xsl:value-of select="../@name"/>>();
|
.UniqueResult<<xsl:value-of select="../@name"/>>();
|
||||||
|
|
||||||
PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN];
|
|
||||||
PropertyBag["instance"] = record;
|
PropertyBag["instance"] = record;
|
||||||
|
|
||||||
<xsl:call-template name="menus">
|
<xsl:call-template name="menus">
|
||||||
<xsl:with-param name="entity" select=".."/>
|
<xsl:with-param name="entity" select=".."/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
RenderViewWithFailover("<xsl:value-of select="concat( @name, '.vm')"/>", "<xsl:value-of select="concat( @name, '.auto.vm')"/>");
|
RenderViewWithFailover("<xsl:value-of select="@name"/>");
|
||||||
}
|
}
|
||||||
|
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
@ -535,7 +510,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
||||||
<xsl:value-of select="//entity[@name=$entityname]/@natural-key"/>
|
<xsl:value-of select="//entity[@name=$entityname]/@natural-key"/>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:value-of select="concat( $entityname, 'Id')" />
|
<xsl:value-of select="'Id'" />
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
|
@ -8,15 +8,17 @@
|
||||||
Transform ADL into entity classes
|
Transform ADL into entity classes
|
||||||
|
|
||||||
$Author: af $
|
$Author: af $
|
||||||
$Revision: 1.1 $
|
$Revision: 1.2 $
|
||||||
$Date: 2008-01-09 15:01:45 $
|
$Date: 2008-01-14 16:53:31 $
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<!-- 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! -->
|
||||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
|
||||||
|
|
||||||
<xsl:output encoding="UTF-8" method="text"/>
|
<xsl:output encoding="UTF-8" method="text"/>
|
||||||
|
|
||||||
|
|
||||||
<!-- The locale for which these entities are generated
|
<!-- The locale for which these entities are generated
|
||||||
TODO: Entities should NOT be locale specific. Instead, the
|
TODO: Entities should NOT be locale specific. Instead, the
|
||||||
entity should generate messages based on the
|
entity should generate messages based on the
|
||||||
|
@ -45,11 +47,13 @@
|
||||||
stored to CVS -->
|
stored to CVS -->
|
||||||
|
|
||||||
<xsl:variable name="transform-rev1"
|
<xsl:variable name="transform-rev1"
|
||||||
select="substring( '$Revision: 1.1 $', 11)"/>
|
select="substring( '$Revision: 1.2 $', 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)"/>
|
||||||
|
|
||||||
/* ---- [ cut here: next file '<xsl:value-of select="@name"/>.auto.cs'] ---------------- */
|
<xsl:variable name="keynames" select="property[@distinct='system']" />
|
||||||
|
|
||||||
|
/* ---- [ cut here: next file '<xsl:value-of select="@name"/>.auto.cs'] ---------------- */
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
@ -67,11 +71,10 @@
|
||||||
namespace <xsl:value-of select="$entityns"/>
|
namespace <xsl:value-of select="$entityns"/>
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.Configuration;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using ADL.Entities;
|
||||||
using ADL.Exceptions;
|
using ADL.Exceptions;
|
||||||
using Iesi.Collections.Generic;
|
using Iesi.Collections.Generic;
|
||||||
|
|
||||||
|
@ -92,6 +95,7 @@
|
||||||
<xsl:call-template name="initialise-lists"/>
|
<xsl:call-template name="initialise-lists"/>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Auto-generated one-arg constructor; initialises Id slot and also all
|
/// Auto-generated one-arg constructor; initialises Id slot and also all
|
||||||
/// one-to-many slots
|
/// one-to-many slots
|
||||||
|
@ -100,17 +104,18 @@
|
||||||
{
|
{
|
||||||
<xsl:call-template name="initialise-lists"/>
|
<xsl:call-template name="initialise-lists"/>
|
||||||
|
|
||||||
<xsl:choose>
|
<!--xsl:choose>
|
||||||
<xsl:when test="@natural-key">
|
<xsl:when test="@natural-key">
|
||||||
/* natural primary key exists - not initialising abstract key */
|
/* natural primary key exists - not initialising abstract key */
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
_<xsl:value-of select="@name"/>Id = key;
|
_Id = key;
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose-->
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
<xsl:choose>
|
<!--xsl:choose>
|
||||||
<xsl:when test="@natural-key">
|
<xsl:when test="@natural-key">
|
||||||
/* natural primary key exists - not generating abstract key */
|
/* natural primary key exists - not generating abstract key */
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
|
@ -118,24 +123,47 @@
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Auto-generated iv/property for Id slot
|
/// Auto-generated iv/property for Id slot
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int _<xsl:value-of select="@name"/>Id = -1;
|
private int _Id = -1;
|
||||||
|
|
||||||
public virtual int <xsl:value-of select="@name"/>Id
|
public virtual int Id
|
||||||
{
|
{
|
||||||
get { return _<xsl:value-of select="@name"/>Id; }
|
get { return _Id; }
|
||||||
set { _<xsl:value-of select="@name"/>Id = value; }
|
set { _Id = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Auto-generated overridden property for the Key slot, maps onto
|
/// Auto-generated overridden property for the Key slot, maps onto
|
||||||
/// _<xsl:value-of select="@name"/>Id
|
/// _Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override int Key
|
public override int Key
|
||||||
{
|
{
|
||||||
get { return _<xsl:value-of select="@name"/>Id; }
|
get { return _Id; }
|
||||||
}
|
}
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
|
</xsl:choose-->
|
||||||
|
/// <summary>
|
||||||
|
/// Auto-generated overridden property for the Key slot, maps onto
|
||||||
|
/// </summary>
|
||||||
|
public override string KeyString {
|
||||||
|
get {
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="count($keynames)=0">
|
||||||
|
return null; // No primary key; return null.
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:when test="count($keynames)=1">
|
||||||
|
return <xsl:value-of select="$keynames[1]/@name"/>.ToString(); // Single key.
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
StringBuilder result = new StringBuilder(<xsl:value-of select="$keynames[1]/@name"/>);
|
||||||
|
<xsl:for-each select="$keynames[position() != 1]">
|
||||||
|
result.Append('|');
|
||||||
|
result.Append(<xsl:value-of select="@name"/>);
|
||||||
|
</xsl:for-each>
|
||||||
|
return result.ToString();
|
||||||
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A user readable distinct identifying string
|
/// A user readable distinct identifying string
|
||||||
|
@ -166,7 +194,7 @@
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
result.AppendFormat( "<xsl:value-of select="@name"/>#{0}[", _<xsl:value-of select="@name"/>Id);
|
result.AppendFormat( "<xsl:value-of select="@name"/>#{0}", <xsl:call-template name="list-properties"/>);
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
|
|
||||||
|
@ -181,6 +209,17 @@
|
||||||
|
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template name="list-properties">
|
||||||
|
<xsl:param name="props" select="property[@distinct='system']"/>
|
||||||
|
<xsl:if test="count($props)!=0">
|
||||||
|
<xsl:value-of select="$props[1]/@name"/>
|
||||||
|
<xsl:if test="count($props)!=1">, </xsl:if>
|
||||||
|
<xsl:call-template name="list-properties">
|
||||||
|
<xsl:with-param name="props" select="$props[position()!=1]"/>
|
||||||
|
</xsl:call-template>
|
||||||
|
</xsl:if>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="property[@concrete='false']">
|
<xsl:template match="property[@concrete='false']">
|
||||||
<!-- generate nothing for non-concrete properties -->
|
<!-- generate nothing for non-concrete properties -->
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
@ -200,69 +239,59 @@
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
|
|
||||||
|
<xsl:variable name="type-nullable">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="@type='defined'">
|
||||||
|
<xsl:call-template name="type-nullable">
|
||||||
|
<xsl:with-param name="typename" select="$defined-type"/>
|
||||||
|
</xsl:call-template>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:when test="@type!='link' and @type!='list' and @type!='entity'">
|
||||||
|
<xsl:call-template name="type-nullable">
|
||||||
|
<xsl:with-param name="typename" select="@type"/>
|
||||||
|
</xsl:call-template>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>true</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:variable>
|
||||||
|
|
||||||
<xsl:variable name="type">
|
<xsl:variable name="type">
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
|
<xsl:when test="@type='defined'">
|
||||||
|
<!-- Find the right definition, then map its type onto a C# type -->
|
||||||
|
<xsl:call-template name="type-declarator">
|
||||||
|
<xsl:with-param name="typename" select="$defined-type"/>
|
||||||
|
</xsl:call-template>
|
||||||
|
</xsl:when>
|
||||||
<xsl:when test="@type = 'link'">
|
<xsl:when test="@type = 'link'">
|
||||||
ICollection<<xsl:value-of select="@entity"/>>
|
ICollection<<xsl:value-of select="@entity"/>>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="@type = 'list'">
|
<xsl:when test="@type = 'list'">
|
||||||
ICollection<<xsl:value-of select="@entity"/>>
|
ICollection<<xsl:value-of select="@entity"/>>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="@type = 'date'">DateTime</xsl:when>
|
|
||||||
<xsl:when test="@type = 'time'">DateTime</xsl:when>
|
|
||||||
<xsl:when test="@type = 'string'">String</xsl:when>
|
|
||||||
<xsl:when test="@type = 'text'">String</xsl:when>
|
|
||||||
<xsl:when test="@type = 'boolean'">bool</xsl:when>
|
|
||||||
<xsl:when test="@type = 'timestamp'">TimeStamp</xsl:when>
|
|
||||||
<xsl:when test="@type = 'integer'">int</xsl:when>
|
|
||||||
<xsl:when test="@type = 'real'">double</xsl:when>
|
|
||||||
<xsl:when test="@type = 'money'">Decimal</xsl:when>
|
|
||||||
<xsl:when test="@type = 'entity'">
|
<xsl:when test="@type = 'entity'">
|
||||||
<xsl:value-of select="@entity"/>
|
<xsl:value-of select="@entity"/>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="@type='defined'">
|
<xsl:otherwise>
|
||||||
<!-- MUCH more complicated... find the right definition, then map its type onto a C# type -->
|
<xsl:call-template name="type-declarator">
|
||||||
<xsl:choose>
|
<xsl:with-param name="typename" select="@type"/>
|
||||||
<!-- DefinableDataTypes are string|integer|real|money|date|time|timestamp -->
|
<xsl:with-param name="nullable" select="@required!='true'"/>
|
||||||
<xsl:when test="$defined-type = 'string'">String</xsl:when>
|
</xsl:call-template>
|
||||||
<xsl:when test="$defined-type = 'integer'">int</xsl:when>
|
</xsl:otherwise>
|
||||||
<xsl:when test="$defined-type = 'real'">double</xsl:when>
|
|
||||||
<xsl:when test="$defined-type = 'money'">Decimal</xsl:when>
|
|
||||||
<xsl:when test="$defined-type = 'date'">DateTime</xsl:when>
|
|
||||||
<xsl:when test="$defined-type = 'time'">DateTime</xsl:when>
|
|
||||||
<xsl:when test="$defined-type = 'timestamp'">TimeStamp</xsl:when>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:otherwise>[unknown?]</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</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 = 'int'">?</xsl:when>
|
|
||||||
<xsl:when test="@type = 'boolean'">?</xsl:when>
|
|
||||||
<xsl:when test="$type = 'double'">?</xsl:when>
|
|
||||||
<xsl:when test="$type = 'Double'">?</xsl:when>
|
|
||||||
<xsl:when test="$type = 'DateTime'">?</xsl:when>
|
|
||||||
<xsl:when test="$type = 'TimeStamp'">?</xsl:when>
|
|
||||||
<xsl:otherwise/>
|
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
<xsl:variable name="initialiser">
|
<xsl:variable name="initialiser">
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="@default">
|
<xsl:when test="@default">
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="$type = 'String'"> = "<xsl:value-of select="@default"/>"</xsl:when>
|
<xsl:when test="$type = 'String'">
|
||||||
<xsl:otherwise> = <xsl:value-of select="@default"/></xsl:otherwise>
|
= "<xsl:value-of select="@default"/>"
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
= <xsl:value-of select="@default"/>
|
||||||
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="$nullable-decoration = '?'"> = null</xsl:when>
|
|
||||||
<xsl:when test="@type = 'boolean'"> = false</xsl:when>
|
|
||||||
<xsl:when test="$type = 'int'"> = 0</xsl:when>
|
|
||||||
<xsl:when test="$type = 'double'"> = 0.0</xsl:when>
|
|
||||||
<xsl:when test="$type = 'Decimal'"> = 0.0M</xsl:when>
|
|
||||||
<xsl:when test="$type='String'"> = null</xsl:when>
|
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
|
|
||||||
|
@ -280,13 +309,13 @@
|
||||||
private Regex <xsl:value-of select="@name"/>Validator = new Regex( "<xsl:value-of select="$validationpattern"/>");
|
private Regex <xsl:value-of select="@name"/>Validator = new Regex( "<xsl:value-of select="$validationpattern"/>");
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
|
|
||||||
private <xsl:value-of select="$type"/><xsl:value-of select="$nullable-decoration"/> _<xsl:value-of select="@name"/> <xsl:value-of select="$initialiser"/>;
|
private <xsl:value-of select="$type"/> _<xsl:value-of select="@name"/> <xsl:value-of select="$initialiser"/>;
|
||||||
|
|
||||||
public virtual <xsl:value-of select="$type"/><xsl:value-of select="$nullable-decoration"/><xsl:text> </xsl:text> <xsl:value-of select="@name"/>
|
public virtual <xsl:value-of select="$type"/><xsl:text> </xsl:text> <xsl:value-of select="@name"/>
|
||||||
{
|
{
|
||||||
get { return _<xsl:value-of select="@name"/>; }
|
get { return _<xsl:value-of select="@name"/>; }
|
||||||
set {
|
set {
|
||||||
<xsl:if test="@required='true'">
|
<xsl:if test="@required='true' and $type-nullable='true'">
|
||||||
if ( value == null)
|
if ( value == null)
|
||||||
{
|
{
|
||||||
throw new DataRequiredException( <xsl:choose>
|
throw new DataRequiredException( <xsl:choose>
|
||||||
|
@ -341,6 +370,61 @@
|
||||||
|
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template name="type-declarator">
|
||||||
|
<xsl:param name="typename"/>
|
||||||
|
<xsl:param name="nullable" select="false()"/>
|
||||||
|
<xsl:variable name="override-type" select="document('types.xml',/application)/types/type[@name=$typename]"/>
|
||||||
|
<xsl:variable name="type0">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$override-type">
|
||||||
|
<xsl:copy-of select="$override-type"/>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:copy-of select="document('types.xml')/types/type[@name=$typename]"/>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:variable>
|
||||||
|
<xsl:variable name="type" select="msxsl:node-set($type0)/type"/>
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$type">
|
||||||
|
<xsl:value-of select="$type/@dotnet" />
|
||||||
|
<xsl:if test="$nullable and $type/@dotnet-kind='value'">?</xsl:if>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:message terminate="yes">
|
||||||
|
Error! <xsl:value-of select="$typename"/> not found.
|
||||||
|
</xsl:message>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template name="type-nullable">
|
||||||
|
<xsl:param name="typename"/>
|
||||||
|
<xsl:variable name="override-type" select="document('types.xml',/application)/types/type[@name=$typename]"/>
|
||||||
|
<xsl:variable name="type0">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$override-type">
|
||||||
|
<xsl:copy-of select="$override-type"/>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:copy-of select="document('types.xml')/types/type[@name=$typename]"/>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:variable>
|
||||||
|
<xsl:variable name="type" select="msxsl:node-set($type0)/type"/>
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$type">
|
||||||
|
<xsl:if test="$type/@dotnet-kind!='value'">true</xsl:if>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:message terminate="yes">
|
||||||
|
Error! <xsl:value-of select="$typename"/> not found.
|
||||||
|
</xsl:message>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
|
||||||
<xsl:template match="help">
|
<xsl:template match="help">
|
||||||
<xsl:if test="@locale=$locale">
|
<xsl:if test="@locale=$locale">
|
||||||
<!-- might conceivably be more than one line -->
|
<!-- might conceivably be more than one line -->
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
Transform ADL into velocity view templates
|
Transform ADL into velocity view templates
|
||||||
|
|
||||||
$Author: af $
|
$Author: af $
|
||||||
$Revision: 1.1 $
|
$Revision: 1.2 $
|
||||||
$Date: 2008-01-09 15:01:45 $
|
$Date: 2008-01-14 16:53:31 $
|
||||||
-->
|
-->
|
||||||
<!-- 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! -->
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
stored to CVS -->
|
stored to CVS -->
|
||||||
|
|
||||||
<xsl:variable name="transform-rev1"
|
<xsl:variable name="transform-rev1"
|
||||||
select="substring( '$Revision: 1.1 $', 11)"/>
|
select="substring( '$Revision: 1.2 $', 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)"/>
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<!-- there isn't a natural primary key; create a hidden widget
|
<!-- there isn't a natural primary key; create a hidden widget
|
||||||
for the abstract primary key -->
|
for the abstract primary key -->
|
||||||
${FormHelper.HiddenField( "instance.<xsl:value-of select="@name"/>Id")}
|
${FormHelper.HiddenField( "instance.Id")}
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
<table>
|
<table>
|
||||||
|
@ -146,7 +146,6 @@
|
||||||
${FormHelper.InstallScripts()}
|
${FormHelper.InstallScripts()}
|
||||||
${Validation.InstallScripts()}
|
${Validation.InstallScripts()}
|
||||||
${Scriptaculous.InstallScripts()}
|
${Scriptaculous.InstallScripts()}
|
||||||
${DateTime.InstallScripts()}
|
|
||||||
${ShuffleWidgetHelper.InstallScripts()}
|
${ShuffleWidgetHelper.InstallScripts()}
|
||||||
<script type="text/javascript" language='JavaScript1.2' src="../script/panes.js"></script>
|
<script type="text/javascript" language='JavaScript1.2' src="../script/panes.js"></script>
|
||||||
|
|
||||||
|
@ -239,7 +238,7 @@
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<!-- there isn't a natural primary key; create a hidden widget
|
<!-- there isn't a natural primary key; create a hidden widget
|
||||||
for the abstract primary key -->
|
for the abstract primary key -->
|
||||||
${FormHelper.HiddenField( "instance.<xsl:value-of select="ancestor::entity/@name"/>Id")}
|
${FormHelper.HiddenField( "instance.Id")}
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
<xsl:if test="fieldgroup">
|
<xsl:if test="fieldgroup">
|
||||||
|
@ -336,7 +335,7 @@
|
||||||
<xsl:value-of select="//entity[@name=$farent]/@natural-key"/>
|
<xsl:value-of select="//entity[@name=$farent]/@natural-key"/>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:value-of select="concat( $farent, 'Id')"/>
|
<xsl:value-of select="concat( '', 'Id')"/>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
|
@ -349,7 +348,7 @@
|
||||||
<xsl:value-of select="ancestor::entity[@natural-key]"/>
|
<xsl:value-of select="ancestor::entity[@natural-key]"/>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:value-of select="concat( $nearent, 'Id')"/>
|
<xsl:value-of select="concat( '', 'Id')"/>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
|
@ -464,7 +463,7 @@
|
||||||
<td>
|
<td>
|
||||||
<a>
|
<a>
|
||||||
<xsl:attribute name="href">
|
<xsl:attribute name="href">
|
||||||
<xsl:value-of select="concat( $action, '.rails?', ../@name, 'Id=$instance.', ../@name, 'Id')"/>
|
<xsl:value-of select="concat( $action, '.rails?', ../@name, 'Id=$instance.Id')"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
Edit!
|
Edit!
|
||||||
</a>
|
</a>
|
||||||
|
@ -524,7 +523,7 @@
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<!-- it's presumably intended to be a computed field -->
|
<!-- it's presumably intended to be a computed field -->
|
||||||
Computed field? TODO: Not yet implememented
|
Computed field '<xsl:value-of select="$propname"/>'? TODO: Not yet implememented
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
@ -675,7 +674,7 @@
|
||||||
<xsl:when test="../permission">
|
<xsl:when test="../permission">
|
||||||
<xsl:value-of select="../permission[position()=1]/@permission"/>
|
<xsl:value-of select="../permission[position()=1]/@permission"/>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>none</xsl:otherwise>
|
<xsl:otherwise>edit</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -712,14 +711,14 @@
|
||||||
<xsl:when test="@type='entity'">
|
<xsl:when test="@type='entity'">
|
||||||
<!-- a menu of the appropriate entity -->
|
<!-- a menu of the appropriate entity -->
|
||||||
#if ( $instance)
|
#if ( $instance)
|
||||||
${FormHelper.Select( "instance.<xsl:value-of select="@name"/>", $instance.<xsl:value-of select="@name"/>, <xsl:value-of select="concat( '$all_', @name)"/>, "%{firstoption='[unset]' firstoptionvalue='-1' text='UserIdentifier' value='<xsl:value-of select="concat( @entity, 'Id')"/>' title='<xsl:value-of select="normalize-space( $if-missing)"/>'}" )}
|
${FormHelper.Select( "instance.<xsl:value-of select="@name"/>", $instance.<xsl:value-of select="@name"/>, <xsl:value-of select="concat( '$all_', @name)"/>, "%{firstoption='[unset]' firstoptionvalue='-1' text='UserIdentifier' value='<xsl:value-of select="concat( '', 'Id')"/>' title='<xsl:value-of select="normalize-space( $if-missing)"/>'}" )}
|
||||||
#else
|
#else
|
||||||
${FormHelper.Select( "instance.<xsl:value-of select="@name"/>", $<xsl:value-of select="@name"/>, <xsl:value-of select="concat( '$all_', @name)"/>, "%{firstoption='[unset]' firstoptionvalue='-1' text='UserIdentifier' value='<xsl:value-of select="concat( @entity, 'Id')"/>' title='<xsl:value-of select="normalize-space( $if-missing)"/>'}" )}
|
${FormHelper.Select( "instance.<xsl:value-of select="@name"/>", $<xsl:value-of select="@name"/>, <xsl:value-of select="concat( '$all_', @name)"/>, "%{firstoption='[unset]' firstoptionvalue='-1' text='UserIdentifier' value='<xsl:value-of select="concat( '', 'Id')"/>' title='<xsl:value-of select="normalize-space( $if-missing)"/>'}" )}
|
||||||
#end
|
#end
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="@type='list'">
|
<xsl:when test="@type='list'">
|
||||||
<!-- a multi-select menu of the appropriate entity -->
|
<!-- a multi-select menu of the appropriate entity -->
|
||||||
${FormHelper.Select( "instance.<xsl:value-of select="@name"/>", $instance.<xsl:value-of select="@name"/>, <xsl:value-of select="concat( '$all_', @name)"/>, "%{multiple='multiple' size='8' text='UserIdentifier' value='<xsl:value-of select="concat( @entity, 'Id')"/>' title='<xsl:value-of select="normalize-space( $if-missing)"/>'}" )}
|
${FormHelper.Select( "instance.<xsl:value-of select="@name"/>", $instance.<xsl:value-of select="@name"/>, <xsl:value-of select="concat( '$all_', @name)"/>, "%{multiple='multiple' size='8' text='UserIdentifier' value='<xsl:value-of select="concat( '', 'Id')"/>' title='<xsl:value-of select="normalize-space( $if-missing)"/>'}" )}
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="@type='defined'">
|
<xsl:when test="@type='defined'">
|
||||||
<!-- likely to be hardest of all... -->
|
<!-- likely to be hardest of all... -->
|
||||||
|
@ -930,7 +929,6 @@
|
||||||
${FormHelper.InstallScripts()}
|
${FormHelper.InstallScripts()}
|
||||||
${Validation.InstallScripts()}
|
${Validation.InstallScripts()}
|
||||||
${Scriptaculous.InstallScripts()}
|
${Scriptaculous.InstallScripts()}
|
||||||
${DateTime.InstallScripts()}
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
@ -1016,7 +1014,7 @@
|
||||||
<td>
|
<td>
|
||||||
<a>
|
<a>
|
||||||
<xsl:attribute name="href">
|
<xsl:attribute name="href">
|
||||||
<xsl:value-of select="concat( $action, '.rails?', ../@name, 'Id=$instance.', ../@name, 'Id')"/>
|
<xsl:value-of select="concat( $action, '.rails?Id=$instance.Id')"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
Edit!
|
Edit!
|
||||||
</a>
|
</a>
|
||||||
|
@ -1055,7 +1053,7 @@
|
||||||
<td>
|
<td>
|
||||||
<a>
|
<a>
|
||||||
<xsl:attribute name="href">
|
<xsl:attribute name="href">
|
||||||
<xsl:value-of select="concat( $action, '.rails?', ../@name, 'Id=$instance.', ../@name, 'Id')"/>
|
<xsl:value-of select="concat( $action, '.rails?Id=$instance.Id')"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
Edit!
|
Edit!
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="urn:nhibernate-mapping-2.2">
|
<xsl:stylesheet version="1.0"
|
||||||
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||||
|
xmlns:h="urn:nhibernate-mapping-2.2">
|
||||||
<!--
|
<!--
|
||||||
Application Description Framework
|
Application Description Framework
|
||||||
hibernate2adl.xsl
|
hibernate2adl.xsl
|
||||||
|
@ -11,90 +13,179 @@
|
||||||
is not sufficiently rich.
|
is not sufficiently rich.
|
||||||
|
|
||||||
$Author: af $
|
$Author: af $
|
||||||
$Revision: 1.1 $
|
$Revision: 1.2 $
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<xsl:output indent="yes" method="xml" encoding="utf-8" doctype-system="file:../j2adl.dtd"/>
|
<xsl:output indent="yes" method="xml" encoding="utf-8"
|
||||||
|
/>
|
||||||
|
|
||||||
<xsl:template match="hibernate-mapping">
|
<xsl:variable name="entityns" select="/h:hibernate-mapping/@namespace"/>
|
||||||
|
|
||||||
|
<xsl:template match="h:hibernate-mapping">
|
||||||
<application name="unset" version="unset">
|
<application name="unset" version="unset">
|
||||||
<xsl:apply-templates select="class"/>
|
<xsl:apply-templates select="h:class"/>
|
||||||
</application>
|
</application>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="class">
|
<xsl:template match="h:class">
|
||||||
<entity>
|
<entity>
|
||||||
<xsl:attribute name="name">
|
<xsl:attribute name="name">
|
||||||
<xsl:value-of select="@name"/>
|
<xsl:call-template name="last-part">
|
||||||
|
<xsl:with-param name="full" select="@name"/>
|
||||||
|
</xsl:call-template>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
<xsl:apply-templates/>
|
<xsl:apply-templates/>
|
||||||
|
<form name="edit" properties="listed">
|
||||||
|
<xsl:for-each select="h:property|h:composite-id/*">
|
||||||
|
<field>
|
||||||
|
<xsl:attribute name="property">
|
||||||
|
<xsl:value-of select="@name"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
</field>
|
||||||
|
</xsl:for-each>
|
||||||
|
</form>
|
||||||
|
<list name="list" onselect="edit" properties="listed">
|
||||||
|
<pragma name="with-pagination-control" value="true"/>
|
||||||
|
<pragma name="with-can-add" value="true"/>
|
||||||
|
<xsl:for-each select="h:property[@type!='list' and @type!='link']|h:composite-id/*">
|
||||||
|
<field>
|
||||||
|
<xsl:attribute name="property">
|
||||||
|
<xsl:value-of select="@name"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
</field>
|
||||||
|
</xsl:for-each>
|
||||||
|
</list>
|
||||||
</entity>
|
</entity>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="property">
|
<xsl:template match="h:property|h:key-property">
|
||||||
<property>
|
<property>
|
||||||
<xsl:attribute name="name">
|
<xsl:attribute name="name">
|
||||||
<xsl:value-of select="@name"/>
|
<xsl:value-of select="@name"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
<xsl:attribute name="type">
|
<xsl:attribute name="type">
|
||||||
<xsl:choose>
|
<xsl:call-template name="type-attr">
|
||||||
<xsl:when test="@type = 'DateTime'">date</xsl:when>
|
<xsl:with-param name="t" select="@type" />
|
||||||
<xsl:when test="@type = 'String'">string</xsl:when>
|
</xsl:call-template>
|
||||||
<xsl:when test="@type = 'bool'">boolean</xsl:when>
|
|
||||||
<xsl:when test="@type = 'TimeStamp'">timestamp</xsl:when>
|
|
||||||
<xsl:when test="@type = 'int'">integer</xsl:when>
|
|
||||||
<xsl:otherwise>[unknown?]</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="contains(name(..),'composite-id')">
|
||||||
|
<xsl:attribute name="distinct">system</xsl:attribute>
|
||||||
|
<xsl:attribute name="required">true</xsl:attribute>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
<xsl:attribute name="required">
|
<xsl:attribute name="required">
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="@not-null = 'true'">true</xsl:when>
|
<xsl:when test="@not-null = 'true'">true</xsl:when>
|
||||||
<xsl:otherwise>false</xsl:otherwise>
|
<xsl:otherwise>false</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
<xsl:attribute name="size">
|
</xsl:otherwise>
|
||||||
<xsl:value-of select="@length"/>
|
</xsl:choose>
|
||||||
</xsl:attribute>
|
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="id">
|
<xsl:template match="h:id">
|
||||||
<property distinct="system" required="true">
|
<property distinct="system" required="true">
|
||||||
<xsl:attribute name="name">
|
<xsl:attribute name="name">
|
||||||
<xsl:value-of select="@name"/>
|
<xsl:value-of select="@name"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
<xsl:attribute name="type">
|
<xsl:attribute name="type">
|
||||||
<xsl:choose>
|
<xsl:call-template name="type-attr">
|
||||||
<xsl:when test="@type = 'DateTime'">date</xsl:when>
|
<xsl:with-param name="t" select="@type" />
|
||||||
<xsl:when test="@type = 'String'">string</xsl:when>
|
</xsl:call-template>
|
||||||
<xsl:when test="@type = 'bool'">boolean</xsl:when>
|
|
||||||
<xsl:when test="@type = 'TimeStamp'">timestamp</xsl:when>
|
|
||||||
<xsl:when test="@type = 'int'">integer</xsl:when>
|
|
||||||
<xsl:otherwise>[unknown?]</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:attribute>
|
|
||||||
<xsl:attribute name="size">
|
|
||||||
<xsl:value-of select="@length"/>
|
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
</property>
|
</property>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="many-to-one">
|
<xsl:template name="type-attr">
|
||||||
<property type="entity">
|
<xsl:param name="t"/>
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$t = 'DateTime'">date</xsl:when>
|
||||||
|
<xsl:when test="$t = 'Decimal'">real</xsl:when>
|
||||||
|
<xsl:when test="$t = 'String' or $t='string'">string</xsl:when>
|
||||||
|
<xsl:when test="starts-with($t,'String(')">string</xsl:when>
|
||||||
|
<xsl:when test="$t = 'bool' or $t='Boolean'">boolean</xsl:when>
|
||||||
|
<xsl:when test="$t = 'TimeStamp'">timestamp</xsl:when>
|
||||||
|
<xsl:when test="$t = 'int' or $t='Int32'">integer</xsl:when>
|
||||||
|
<xsl:when test="substring($t, string-length($t) - 3)='Type'">
|
||||||
|
<xsl:value-of select="substring($t, 1, string-length($t)-4)"/>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>[unknown!<xsl:value-of select="$t"/>]</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template name="last-part">
|
||||||
|
<xsl:param name="full"/>
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="starts-with($full, concat($entityns, '.'))">
|
||||||
|
<xsl:value-of select="substring($full, string-length($entityns)+2)"/>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise><xsl:value-of select="$full"/></xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="h:many-to-one|h:key-many-to-one">
|
||||||
|
<property>
|
||||||
<xsl:attribute name="name">
|
<xsl:attribute name="name">
|
||||||
<xsl:value-of select="@name"/>
|
<xsl:value-of select="@name"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
|
<xsl:attribute name="type">entity</xsl:attribute>
|
||||||
<xsl:attribute name="entity">
|
<xsl:attribute name="entity">
|
||||||
<xsl:value-of select="@class"/>
|
<xsl:call-template name="last-part">
|
||||||
|
<xsl:with-param name="full" select="@class"/>
|
||||||
|
</xsl:call-template>
|
||||||
|
</xsl:attribute>
|
||||||
|
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="contains(name(..),'composite-id')">
|
||||||
|
<xsl:attribute name="distinct">system</xsl:attribute>
|
||||||
|
<xsl:attribute name="required">true</xsl:attribute>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:attribute name="required">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="@not-null = 'true'">true</xsl:when>
|
||||||
|
<xsl:otherwise>false</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:attribute>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</property>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="h:set/h:many-to-many">
|
||||||
|
<property>
|
||||||
|
<xsl:attribute name="name">
|
||||||
|
<xsl:value-of select="../@name"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
<xsl:attribute name="type">link</xsl:attribute>
|
||||||
|
<xsl:attribute name="entity">
|
||||||
|
<xsl:call-template name="last-part">
|
||||||
|
<xsl:with-param name="full" select="@class"/>
|
||||||
|
</xsl:call-template>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
</property>
|
</property>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="@* | node()">
|
<xsl:template match="h:set/h:one-to-many">
|
||||||
|
<property>
|
||||||
|
<xsl:attribute name="name">
|
||||||
|
<xsl:value-of select="../@name"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
<xsl:attribute name="type">list</xsl:attribute>
|
||||||
|
<xsl:attribute name="entity">
|
||||||
|
<xsl:call-template name="last-part">
|
||||||
|
<xsl:with-param name="full" select="@class"/>
|
||||||
|
</xsl:call-template>
|
||||||
|
</xsl:attribute>
|
||||||
|
</property>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<!-- xsl:template match="@* | node()">
|
||||||
<xsl:copy>
|
<xsl:copy>
|
||||||
<xsl:apply-templates select="@* | node()"/>
|
<xsl:apply-templates select="@* | node()"/>
|
||||||
</xsl:copy>
|
</xsl:copy>
|
||||||
|
|
||||||
</xsl:template>
|
</xsl:template -->
|
||||||
</xsl:stylesheet>
|
</xsl:stylesheet>
|
10
ADL.NET/Trans/types.xml
Executable file
10
ADL.NET/Trans/types.xml
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
<types>
|
||||||
|
<type name="integer" dotnet="Int32" sql="INTEGER" dotnet-kind="value" default="0" />
|
||||||
|
<type name="real" dotnet="Double" sql="REAL" dotnet-kind="value" default="0.0"/>
|
||||||
|
<type name="boolean" dotnet="Boolean" sql="BIT" dotnet-kind="value" default="false"/>
|
||||||
|
<type name="date" dotnet="DateTime" sql="DATETIME" dotnet-kind="value" />
|
||||||
|
<type name="time" dotnet="TimeSpan" sql="DECIMAL" dotnet-kind="value" />
|
||||||
|
<type name="money" dotnet="Decimal" sql="MONEY" dotnet-kind="value" />
|
||||||
|
|
||||||
|
<type name="string" dotnet="String" sql="NVARCHAR" dotnet-kind="reference" />
|
||||||
|
</types>
|
Loading…
Reference in a new issue