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
|
||||
|
||||
$Author: af $
|
||||
$Revision: 1.1 $
|
||||
$Date: 2008-01-09 15:01:45 $
|
||||
$Revision: 1.2 $
|
||||
$Date: 2008-01-14 16:53:31 $
|
||||
-->
|
||||
|
||||
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
|
||||
|
@ -35,13 +35,17 @@
|
|||
<xsl:apply-templates select="entity"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="entity[count(property/@distinct)!=1]">
|
||||
<!-- Ignore entities withot a simple (non-composite) key. -->
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="entity">
|
||||
<!-- 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.1 $', 11)"/>
|
||||
select="substring( '$Revision: 1.2 $', 11)"/>
|
||||
<xsl:variable name="transform-revision"
|
||||
select="substring( $transform-rev1, 0, string-length( $transform-rev1) - 1)"/>
|
||||
|
||||
|
@ -69,25 +73,18 @@
|
|||
//------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
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 Cygnet.Web.Helpers;
|
||||
using Cygnet.Web.Controllers;
|
||||
using System.Web.Security;
|
||||
using NHibernate;
|
||||
using NHibernate.Expression;
|
||||
using Castle.MonoRail.Framework;
|
||||
using SRU.Hospitality.Entities;
|
||||
using SRU.Hospitality.Helpers;
|
||||
using ADL.Entities;
|
||||
using ADL.Exceptions;
|
||||
using Iesi.Collections.Generic;
|
||||
using <xsl:value-of select="$entityns" />;
|
||||
|
||||
namespace <xsl:value-of select="$controllerns"/> {
|
||||
|
||||
|
@ -112,12 +109,10 @@ namespace <xsl:value-of select="$controllerns"/> {
|
|||
/// </summary>
|
||||
private void Store()
|
||||
{
|
||||
ISession hibernator =
|
||||
NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN],
|
||||
Session[NHibernateHelper.PASSTOKEN]);
|
||||
ISession hibernator = NHibernateHelper.GetCurrentSession();
|
||||
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"/>
|
||||
|
||||
|
@ -126,11 +121,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
|||
if ( String.IsNullOrEmpty( id))
|
||||
{
|
||||
/* 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>
|
||||
<xsl:when test="position() = last()"/>
|
||||
<xsl:otherwise>, </xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>);
|
||||
record = new <xsl:value-of select="@name"/>();
|
||||
|
||||
/* perform any domain knowledge behaviour on the new record
|
||||
* after instantiation */
|
||||
|
@ -143,7 +134,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
|||
record =
|
||||
hibernator.CreateCriteria(typeof(<xsl:value-of select="@name"/>))
|
||||
.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)
|
||||
|
@ -162,7 +153,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
|||
.Add(Expression.Eq("<xsl:call-template name="primary-key">
|
||||
<xsl:with-param name="entityname" select="@entity"/>
|
||||
</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 select="property[@type='link']">
|
||||
|
@ -189,8 +180,8 @@ namespace <xsl:value-of select="$controllerns"/> {
|
|||
<!-- todo: won't work for entities having natural keys -->
|
||||
<xsl:value-of select="concat( 'record.', @name)"/>.Add(
|
||||
hibernator.CreateCriteria(typeof(<xsl:value-of select="@entity"/>))
|
||||
.Add(Expression.Eq("<xsl:value-of select="@entity"/>Id", Int32.Parse(index)))
|
||||
.UniqueResult<<xsl:value-of select="$entityns"/>.<xsl:value-of select="@entity"/>>());
|
||||
.Add(Expression.Eq("Id", Int32.Parse(index)))
|
||||
.UniqueResult<<xsl:value-of select="@entity"/>>());
|
||||
}
|
||||
}
|
||||
</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 */
|
||||
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;
|
||||
|
||||
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 =
|
||||
hibernator.CreateCriteria(typeof(<xsl:value-of select="@entity"/>))
|
||||
.Add(Expression.Eq("<xsl:value-of select="@entity"/>Id", Int32.Parse(index)))
|
||||
.UniqueResult<<xsl:value-of select="$entityns"/>.<xsl:value-of select="@entity"/>>();
|
||||
.Add(Expression.Eq("Id", Int32.Parse(index)))
|
||||
.UniqueResult<<xsl:value-of select="@entity"/>>();
|
||||
|
||||
if ( ! record.<xsl:value-of select="@name"/>.Contains( item))
|
||||
{
|
||||
|
@ -261,13 +252,12 @@ namespace <xsl:value-of select="$controllerns"/> {
|
|||
}
|
||||
|
||||
PropertyBag["messages"] = messages;
|
||||
PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN];
|
||||
PropertyBag["instance"] = record;
|
||||
|
||||
<xsl:call-template name="menus">
|
||||
<xsl:with-param name="entity" select="."/>
|
||||
</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
|
||||
{
|
||||
|
@ -281,9 +271,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
|||
[AccessibleThrough(Verb.Get)]
|
||||
public void Delete()
|
||||
{
|
||||
ISession hibernator =
|
||||
NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN],
|
||||
Session[NHibernateHelper.PASSTOKEN]);
|
||||
ISession hibernator = NHibernateHelper.GetCurrentSession();
|
||||
string id = Params["<xsl:value-of select="concat( 'instance.', $key)"/>"];
|
||||
string reallydelete = Params["reallydelete"];
|
||||
|
||||
|
@ -292,7 +280,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
|||
<xsl:value-of select="@name"/> record =
|
||||
hibernator.CreateCriteria(typeof(<xsl:value-of select="@name"/>))
|
||||
.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)
|
||||
{
|
||||
|
@ -301,7 +289,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
|||
hibernator.Delete(
|
||||
hibernator.CreateCriteria(typeof(<xsl:value-of select="@name"/>))
|
||||
.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();
|
||||
}
|
||||
|
@ -341,19 +329,16 @@ namespace <xsl:value-of select="$controllerns"/> {
|
|||
/// <param name="view">The name of the list view to show</param>
|
||||
public void InternalShowList( String view)
|
||||
{
|
||||
ISession hibernator =
|
||||
NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN],
|
||||
Session[NHibernateHelper.PASSTOKEN]);
|
||||
ISession hibernator = NHibernateHelper.GetCurrentSession();
|
||||
IList<<xsl:value-of select="@name"/>> instances =
|
||||
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:for-each>.List<<xsl:value-of select="@name"/>>();
|
||||
|
||||
PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN];
|
||||
PropertyBag["instances"] =
|
||||
PaginationHelper.CreatePagination( this, instances, 25);
|
||||
|
||||
RenderViewWithFailover(view + ".vm", view + ".auto.vm");
|
||||
RenderViewWithFailover(view);
|
||||
}
|
||||
</xsl:if>
|
||||
}
|
||||
|
@ -387,7 +372,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
|||
<xsl:value-of select="../@natural-key"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat( ../@name, 'Id')"/>
|
||||
<xsl:value-of select="concat( '', 'Id')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
@ -415,18 +400,15 @@ namespace <xsl:value-of select="$controllerns"/> {
|
|||
</xsl:for-each>
|
||||
if ( command.Equals( "delete"))
|
||||
{
|
||||
ISession hibernator =
|
||||
NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN],
|
||||
Session[NHibernateHelper.PASSTOKEN]);
|
||||
ISession hibernator = NHibernateHelper.GetCurrentSession();
|
||||
string id = Form["<xsl:value-of select="concat( 'instance.', $key)"/>"];
|
||||
|
||||
PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN];
|
||||
PropertyBag["instance"] =
|
||||
hibernator.CreateCriteria(typeof(<xsl:value-of select="../@name"/>))
|
||||
.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"))
|
||||
{
|
||||
|
@ -444,39 +426,32 @@ namespace <xsl:value-of select="$controllerns"/> {
|
|||
[AccessibleThrough(Verb.Get)]
|
||||
public void <xsl:value-of select="@name"/>( )
|
||||
{
|
||||
ISession hibernator =
|
||||
NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN],
|
||||
Session[NHibernateHelper.PASSTOKEN]);
|
||||
<xsl:call-template name="menus">
|
||||
<xsl:with-param name="entity" select=".."/>
|
||||
</xsl:call-template>
|
||||
|
||||
PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN];
|
||||
RenderViewWithFailover("<xsl:value-of select="concat( @name, '.vm')"/>", "<xsl:value-of select="concat( @name, '.auto.vm')"/>");
|
||||
ISession hibernator = NHibernateHelper.GetCurrentSession();
|
||||
<xsl:call-template name="menus">
|
||||
<xsl:with-param name="entity" select=".."/>
|
||||
</xsl:call-template>
|
||||
RenderViewWithFailover("<xsl:value-of select="@name"/>");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show the form named <xsl:value-of select="@name"/>, containing the indicated record
|
||||
/// </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)]
|
||||
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 =
|
||||
NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN],
|
||||
Session[NHibernateHelper.PASSTOKEN]);
|
||||
<xsl:value-of select="$entityns"/>.<xsl:value-of select="../@name"/> record =
|
||||
ISession hibernator = NHibernateHelper.GetCurrentSession();
|
||||
<xsl:value-of select="../@name"/> record =
|
||||
hibernator.CreateCriteria(typeof(<xsl:value-of select="../@name"/>))
|
||||
.Add(Expression.Eq("<xsl:value-of select="concat( ../@name, 'Id')"/>", <xsl:value-of select="../@name"/>Id))
|
||||
.UniqueResult<<xsl:value-of select="$entityns"/>.<xsl:value-of select="../@name"/>>();
|
||||
.Add(Expression.Eq("Id", Id))
|
||||
.UniqueResult<<xsl:value-of select="../@name"/>>();
|
||||
|
||||
PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN];
|
||||
PropertyBag["instance"] = record;
|
||||
|
||||
<xsl:call-template name="menus">
|
||||
<xsl:with-param name="entity" select=".."/>
|
||||
</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>
|
||||
|
@ -535,7 +510,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
|||
<xsl:value-of select="//entity[@name=$entityname]/@natural-key"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat( $entityname, 'Id')" />
|
||||
<xsl:value-of select="'Id'" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
|
|
@ -8,14 +8,16 @@
|
|||
Transform ADL into entity classes
|
||||
|
||||
$Author: af $
|
||||
$Revision: 1.1 $
|
||||
$Date: 2008-01-09 15:01:45 $
|
||||
$Revision: 1.2 $
|
||||
$Date: 2008-01-14 16:53:31 $
|
||||
-->
|
||||
|
||||
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
|
||||
Whitespace (or lack of it) is significant! -->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:output encoding="UTF-8" method="text"/>
|
||||
<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"/>
|
||||
|
||||
|
||||
<!-- The locale for which these entities are generated
|
||||
TODO: Entities should NOT be locale specific. Instead, the
|
||||
|
@ -45,11 +47,13 @@
|
|||
stored to CVS -->
|
||||
|
||||
<xsl:variable name="transform-rev1"
|
||||
select="substring( '$Revision: 1.1 $', 11)"/>
|
||||
select="substring( '$Revision: 1.2 $', 11)"/>
|
||||
<xsl:variable name="transform-revision"
|
||||
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'] ---------------- */
|
||||
|
||||
//-------------------------------------------------------------
|
||||
//
|
||||
|
@ -66,127 +70,162 @@
|
|||
//-------------------------------------------------------------
|
||||
namespace <xsl:value-of select="$entityns"/>
|
||||
{
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using ADL.Exceptions;
|
||||
using Iesi.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using ADL.Entities;
|
||||
using ADL.Exceptions;
|
||||
using Iesi.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Automatically generated from description of entity <xsl:value-of select="@name"/>
|
||||
/// using adl2entityclass.xsl. Note that manually maintained parts of this
|
||||
/// class may be defined in a separate file called <xsl:value-of select="@name"/>.cs, q.v.
|
||||
///
|
||||
/// DO NOT EDIT THIS FILE!
|
||||
/// </summary>
|
||||
public partial class <xsl:value-of select="@name"/> : Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// Auto-generated no-args constructor; does nothing (but probably should
|
||||
/// ensure ID slot is initialised correctly)
|
||||
/// </summary>
|
||||
public <xsl:value-of select="@name"/>() : base(){
|
||||
<xsl:call-template name="initialise-lists"/>
|
||||
}
|
||||
/// <summary>
|
||||
/// Automatically generated from description of entity <xsl:value-of select="@name"/>
|
||||
/// using adl2entityclass.xsl. Note that manually maintained parts of this
|
||||
/// class may be defined in a separate file called <xsl:value-of select="@name"/>.cs, q.v.
|
||||
///
|
||||
/// DO NOT EDIT THIS FILE!
|
||||
/// </summary>
|
||||
public partial class <xsl:value-of select="@name"/> : Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// Auto-generated no-args constructor; does nothing (but probably should
|
||||
/// ensure ID slot is initialised correctly)
|
||||
/// </summary>
|
||||
public <xsl:value-of select="@name"/>() : base(){
|
||||
<xsl:call-template name="initialise-lists"/>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Auto-generated one-arg constructor; initialises Id slot and also all
|
||||
/// one-to-many slots
|
||||
/// </summary>
|
||||
public <xsl:value-of select="@name"/>( int key)
|
||||
{
|
||||
<xsl:call-template name="initialise-lists"/>
|
||||
/*
|
||||
/// <summary>
|
||||
/// Auto-generated one-arg constructor; initialises Id slot and also all
|
||||
/// one-to-many slots
|
||||
/// </summary>
|
||||
public <xsl:value-of select="@name"/>( int key)
|
||||
{
|
||||
<xsl:call-template name="initialise-lists"/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="@natural-key">
|
||||
/* natural primary key exists - not initialising abstract key */
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
_<xsl:value-of select="@name"/>Id = key;
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
}
|
||||
<!--xsl:choose>
|
||||
<xsl:when test="@natural-key">
|
||||
/* natural primary key exists - not initialising abstract key */
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
_Id = key;
|
||||
</xsl:otherwise>
|
||||
</xsl:choose-->
|
||||
}
|
||||
*/
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="@natural-key">
|
||||
<!--xsl:choose>
|
||||
<xsl:when test="@natural-key">
|
||||
/* natural primary key exists - not generating abstract key */
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
/// <summary>
|
||||
/// Auto-generated iv/property for Id slot
|
||||
/// </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; }
|
||||
set { _<xsl:value-of select="@name"/>Id = value; }
|
||||
get { return _Id; }
|
||||
set { _Id = value; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Auto-generated overridden property for the Key slot, maps onto
|
||||
/// _<xsl:value-of select="@name"/>Id
|
||||
/// _Id
|
||||
/// </summary>
|
||||
public override int Key
|
||||
{
|
||||
get { return _<xsl:value-of select="@name"/>Id; }
|
||||
get { return _Id; }
|
||||
}
|
||||
</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>
|
||||
|
||||
/// <summary>
|
||||
/// A user readable distinct identifying string
|
||||
/// </summary>
|
||||
public override string UserIdentifier
|
||||
{
|
||||
get {
|
||||
StringBuilder result = new StringBuilder();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A user readable distinct identifying string
|
||||
/// </summary>
|
||||
public override string UserIdentifier
|
||||
{
|
||||
get {
|
||||
StringBuilder result = new StringBuilder();
|
||||
<xsl:choose>
|
||||
<xsl:when test="property[@distinct='user']">
|
||||
<xsl:for-each select="property[@distinct='user']">
|
||||
<xsl:choose>
|
||||
<xsl:when test="property[@distinct='user']">
|
||||
<xsl:for-each select="property[@distinct='user']">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@type='entity'">
|
||||
<!-- TODO: this is dangerous and could potentially give rise to
|
||||
<xsl:when test="@type='entity'">
|
||||
<!-- TODO: this is dangerous and could potentially give rise to
|
||||
infinite loops; find a way of stopping it running away! -->
|
||||
result.Append( <xsl:value-of select="concat( @name, '.UserIdentifier')"/>);
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
result.Append(<xsl:value-of select="concat( '_', @name)"/>);
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:choose>
|
||||
<xsl:when test="position() = last()"/>
|
||||
<xsl:otherwise>
|
||||
result.Append( ", ");
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
result.Append( <xsl:value-of select="concat( @name, '.UserIdentifier')"/>);
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
result.AppendFormat( "<xsl:value-of select="@name"/>#{0}[", _<xsl:value-of select="@name"/>Id);
|
||||
result.Append(<xsl:value-of select="concat( '_', @name)"/>);
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="position() = last()"/>
|
||||
<xsl:otherwise>
|
||||
result.Append( ", ");
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
result.AppendFormat( "<xsl:value-of select="@name"/>#{0}", <xsl:call-template name="list-properties"/>);
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
<xsl:apply-templates select="property"/>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</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']">
|
||||
<!-- generate nothing for non-concrete properties -->
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="property">
|
||||
// auto generating iv/property pair for slot with name <xsl:value-of select="@name"/>
|
||||
// auto generating iv/property pair for slot with name <xsl:value-of select="@name"/>
|
||||
<xsl:apply-templates select="help"/>
|
||||
|
||||
<xsl:variable name="defined-type">
|
||||
|
@ -200,69 +239,59 @@
|
|||
</xsl:choose>
|
||||
</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: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'">
|
||||
ICollection<<xsl:value-of select="@entity"/>>
|
||||
</xsl:when>
|
||||
<xsl:when test="@type = 'list'">
|
||||
ICollection<<xsl:value-of select="@entity"/>>
|
||||
</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:value-of select="@entity"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="@type='defined'">
|
||||
<!-- MUCH more complicated... find the right definition, then map its type onto a C# type -->
|
||||
<xsl:choose>
|
||||
<!-- DefinableDataTypes are string|integer|real|money|date|time|timestamp -->
|
||||
<xsl:when test="$defined-type = 'string'">String</xsl:when>
|
||||
<xsl:when test="$defined-type = 'integer'">int</xsl:when>
|
||||
<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:otherwise>
|
||||
<xsl:call-template name="type-declarator">
|
||||
<xsl:with-param name="typename" select="@type"/>
|
||||
<xsl:with-param name="nullable" select="@required!='true'"/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="initialiser">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@default">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$type = 'String'"> = "<xsl:value-of select="@default"/>"</xsl:when>
|
||||
<xsl:otherwise> = <xsl:value-of select="@default"/></xsl:otherwise>
|
||||
<xsl:when test="$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="@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:variable>
|
||||
|
||||
|
@ -277,78 +306,133 @@
|
|||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:if test="string-length( $validationpattern) > 0">
|
||||
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>
|
||||
|
||||
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"/>; }
|
||||
set {
|
||||
<xsl:if test="@required='true' and $type-nullable='true'">
|
||||
if ( value == null)
|
||||
{
|
||||
throw new DataRequiredException( <xsl:choose>
|
||||
<xsl:when test="ifmissing[@locale=$locale]">
|
||||
<xsl:apply-templates select="ifmissing"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
"The value for <xsl:value-of select="@name"/> may not be set to null"
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
);
|
||||
}
|
||||
</xsl:if>
|
||||
<xsl:if test="@type='defined'">
|
||||
<xsl:variable name="definition">
|
||||
<xsl:value-of select="@definition"/>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="maximum">
|
||||
<xsl:value-of select="/application/definition[@name=$definition]/@maximum"/>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="minimum">
|
||||
<xsl:value-of select="/application/definition[@name=$definition]/@minimum"/>
|
||||
</xsl:variable>
|
||||
<xsl:if test="string-length( $maximum) > 0">
|
||||
if ( value > <xsl:value-of select="$maximum"/>)
|
||||
{
|
||||
get { return _<xsl:value-of select="@name"/>; }
|
||||
set {
|
||||
<xsl:if test="@required='true'">
|
||||
if ( value == null)
|
||||
{
|
||||
throw new DataRequiredException( <xsl:choose>
|
||||
<xsl:when test="ifmissing[@locale=$locale]">
|
||||
<xsl:apply-templates select="ifmissing"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
"The value for <xsl:value-of select="@name"/> may not be set to null"
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
);
|
||||
}
|
||||
</xsl:if>
|
||||
<xsl:if test="@type='defined'">
|
||||
<xsl:variable name="definition">
|
||||
<xsl:value-of select="@definition"/>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="maximum">
|
||||
<xsl:value-of select="/application/definition[@name=$definition]/@maximum"/>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="minimum">
|
||||
<xsl:value-of select="/application/definition[@name=$definition]/@minimum"/>
|
||||
</xsl:variable>
|
||||
<xsl:if test="string-length( $maximum) > 0">
|
||||
if ( value > <xsl:value-of select="$maximum"/>)
|
||||
{
|
||||
throw new DataRangeException( "The maximum permitted value for <xsl:value-of select="@name"/> is <xsl:value-of select="$maximum"/>");
|
||||
}
|
||||
</xsl:if>
|
||||
<xsl:if test="string-length( $minimum) > 0">
|
||||
if ( value < <xsl:value-of select="$minimum"/>)
|
||||
{
|
||||
throw new DataRangeException( "The minimum permitted value for <xsl:value-of select="@name"/> is <xsl:value-of select="$minimum"/>");
|
||||
}
|
||||
</xsl:if>
|
||||
<xsl:if test="string-length( $validationpattern) > 0">
|
||||
if ( value != null && ! <xsl:value-of select="@name"/>Validator.IsMatch( value))
|
||||
{
|
||||
throw new DataFormatException( string.Format( "The value supplied ({0}) does not match the format required by <xsl:value-of select="@name"/>", value));
|
||||
}
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
<xsl:if test="@size and $type='String'">
|
||||
if ( value != null && value.Length > <xsl:value-of select="@size"/>)
|
||||
{
|
||||
value = value.Substring( 0, <xsl:value-of select="@size"/>);
|
||||
}
|
||||
</xsl:if>
|
||||
_<xsl:value-of select="@name"/> = value;
|
||||
}
|
||||
throw new DataRangeException( "The maximum permitted value for <xsl:value-of select="@name"/> is <xsl:value-of select="$maximum"/>");
|
||||
}
|
||||
</xsl:if>
|
||||
<xsl:if test="string-length( $minimum) > 0">
|
||||
if ( value < <xsl:value-of select="$minimum"/>)
|
||||
{
|
||||
throw new DataRangeException( "The minimum permitted value for <xsl:value-of select="@name"/> is <xsl:value-of select="$minimum"/>");
|
||||
}
|
||||
</xsl:if>
|
||||
<xsl:if test="string-length( $validationpattern) > 0">
|
||||
if ( value != null && ! <xsl:value-of select="@name"/>Validator.IsMatch( value))
|
||||
{
|
||||
throw new DataFormatException( string.Format( "The value supplied ({0}) does not match the format required by <xsl:value-of select="@name"/>", value));
|
||||
}
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
<xsl:if test="@size and $type='String'">
|
||||
if ( value != null && value.Length > <xsl:value-of select="@size"/>)
|
||||
{
|
||||
value = value.Substring( 0, <xsl:value-of select="@size"/>);
|
||||
}
|
||||
</xsl:if>
|
||||
_<xsl:value-of select="@name"/> = value;
|
||||
}
|
||||
}
|
||||
|
||||
</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:if test="@locale=$locale">
|
||||
<!-- might conceivably be more than one line -->
|
||||
<!-- might conceivably be more than one line -->
|
||||
<xsl:text>
|
||||
/* </xsl:text><xsl:apply-templates/> */
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="ifmissing">
|
||||
<xsl:if test="@locale=$locale">
|
||||
"<xsl:value-of select="normalize-space(.)"/>"
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
Transform ADL into velocity view templates
|
||||
|
||||
$Author: af $
|
||||
$Revision: 1.1 $
|
||||
$Date: 2008-01-09 15:01:45 $
|
||||
$Revision: 1.2 $
|
||||
$Date: 2008-01-14 16:53:31 $
|
||||
-->
|
||||
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
|
||||
Whitespace (or lack of it) is significant! -->
|
||||
|
@ -31,7 +31,7 @@
|
|||
stored to CVS -->
|
||||
|
||||
<xsl:variable name="transform-rev1"
|
||||
select="substring( '$Revision: 1.1 $', 11)"/>
|
||||
select="substring( '$Revision: 1.2 $', 11)"/>
|
||||
<xsl:variable name="transform-revision"
|
||||
select="substring( $transform-rev1, 0, string-length( $transform-rev1) - 1)"/>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
|||
<xsl:otherwise>
|
||||
<!-- there isn't a natural primary key; create a hidden widget
|
||||
for the abstract primary key -->
|
||||
${FormHelper.HiddenField( "instance.<xsl:value-of select="@name"/>Id")}
|
||||
${FormHelper.HiddenField( "instance.Id")}
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<table>
|
||||
|
@ -146,7 +146,6 @@
|
|||
${FormHelper.InstallScripts()}
|
||||
${Validation.InstallScripts()}
|
||||
${Scriptaculous.InstallScripts()}
|
||||
${DateTime.InstallScripts()}
|
||||
${ShuffleWidgetHelper.InstallScripts()}
|
||||
<script type="text/javascript" language='JavaScript1.2' src="../script/panes.js"></script>
|
||||
|
||||
|
@ -239,7 +238,7 @@
|
|||
<xsl:otherwise>
|
||||
<!-- there isn't a natural primary key; create a hidden widget
|
||||
for the abstract primary key -->
|
||||
${FormHelper.HiddenField( "instance.<xsl:value-of select="ancestor::entity/@name"/>Id")}
|
||||
${FormHelper.HiddenField( "instance.Id")}
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:if test="fieldgroup">
|
||||
|
@ -336,7 +335,7 @@
|
|||
<xsl:value-of select="//entity[@name=$farent]/@natural-key"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat( $farent, 'Id')"/>
|
||||
<xsl:value-of select="concat( '', 'Id')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
@ -349,7 +348,7 @@
|
|||
<xsl:value-of select="ancestor::entity[@natural-key]"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat( $nearent, 'Id')"/>
|
||||
<xsl:value-of select="concat( '', 'Id')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
@ -464,7 +463,7 @@
|
|||
<td>
|
||||
<a>
|
||||
<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>
|
||||
Edit!
|
||||
</a>
|
||||
|
@ -524,7 +523,7 @@
|
|||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- 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:choose>
|
||||
</xsl:template>
|
||||
|
@ -675,7 +674,7 @@
|
|||
<xsl:when test="../permission">
|
||||
<xsl:value-of select="../permission[position()=1]/@permission"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>none</xsl:otherwise>
|
||||
<xsl:otherwise>edit</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<tr>
|
||||
|
@ -712,14 +711,14 @@
|
|||
<xsl:when test="@type='entity'">
|
||||
<!-- a menu of the appropriate entity -->
|
||||
#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
|
||||
${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
|
||||
</xsl:when>
|
||||
<xsl:when test="@type='list'">
|
||||
<!-- 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 test="@type='defined'">
|
||||
<!-- likely to be hardest of all... -->
|
||||
|
@ -930,7 +929,6 @@
|
|||
${FormHelper.InstallScripts()}
|
||||
${Validation.InstallScripts()}
|
||||
${Scriptaculous.InstallScripts()}
|
||||
${DateTime.InstallScripts()}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
@ -1016,7 +1014,7 @@
|
|||
<td>
|
||||
<a>
|
||||
<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>
|
||||
Edit!
|
||||
</a>
|
||||
|
@ -1055,7 +1053,7 @@
|
|||
<td>
|
||||
<a>
|
||||
<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>
|
||||
Edit!
|
||||
</a>
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?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">
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:h="urn:nhibernate-mapping-2.2">
|
||||
<!--
|
||||
Application Description Framework
|
||||
hibernate2adl.xsl
|
||||
|
@ -11,90 +13,179 @@
|
|||
is not sufficiently rich.
|
||||
|
||||
$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:variable name="entityns" select="/h:hibernate-mapping/@namespace"/>
|
||||
|
||||
<xsl:template match="hibernate-mapping">
|
||||
<xsl:template match="h:hibernate-mapping">
|
||||
<application name="unset" version="unset">
|
||||
<xsl:apply-templates select="class"/>
|
||||
</application>
|
||||
<xsl:apply-templates select="h:class"/>
|
||||
</application>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="class">
|
||||
<xsl:template match="h:class">
|
||||
<entity>
|
||||
<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: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>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="property">
|
||||
<xsl:template match="h:property|h:key-property">
|
||||
<property>
|
||||
<xsl:attribute name="name">
|
||||
<xsl:value-of select="@name"/>
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="type">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@type = 'DateTime'">date</xsl:when>
|
||||
<xsl:when test="@type = 'String'">string</xsl:when>
|
||||
<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:call-template name="type-attr">
|
||||
<xsl:with-param name="t" select="@type" />
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
<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:attribute name="size">
|
||||
<xsl:value-of select="@length"/>
|
||||
</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="id">
|
||||
<xsl:template match="h:id">
|
||||
<property distinct="system" required="true">
|
||||
<xsl:attribute name="name">
|
||||
<xsl:value-of select="@name"/>
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="type">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@type = 'DateTime'">date</xsl:when>
|
||||
<xsl:when test="@type = 'String'">string</xsl:when>
|
||||
<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:call-template name="type-attr">
|
||||
<xsl:with-param name="t" select="@type" />
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
</property>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="many-to-one">
|
||||
<property type="entity">
|
||||
<xsl:template name="type-attr">
|
||||
<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:value-of select="@name"/>
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="type">entity</xsl:attribute>
|
||||
<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>
|
||||
</property>
|
||||
</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:apply-templates select="@* | node()"/>
|
||||
</xsl:copy>
|
||||
|
||||
</xsl:template>
|
||||
</xsl:template -->
|
||||
</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