From d5c557f93e23da32a16d48c1c1bd0fd72c8e37b1 Mon Sep 17 00:00:00 2001 From: sb Date: Thu, 2 Oct 2008 10:43:42 +0000 Subject: [PATCH] Bringing into line with current b_development --- schemas/adl-0.dtd | 165 ++---- transforms/adl2activerecord.xslt | 715 ++++++++++++++++++++++++++ transforms/adl2canonical.xslt | 9 +- transforms/adl2controllerclasses.xslt | 8 +- transforms/adl2documentation.xslt | 68 ++- transforms/adl2entityclasses.xslt | 210 +++++++- transforms/adl2hibernate.xslt | 133 +++-- transforms/adl2mssql.xslt | 47 +- 8 files changed, 1156 insertions(+), 199 deletions(-) create mode 100755 transforms/adl2activerecord.xslt diff --git a/schemas/adl-0.dtd b/schemas/adl-0.dtd index 87115cf..f65f331 100755 --- a/schemas/adl-0.dtd +++ b/schemas/adl-0.dtd @@ -13,12 +13,13 @@ - + + name: the name of this application version: the version number of this application revision: the revision of the ADL document + currency: the base monetary currency, in the form of an ISO 4217 three-letter code xmlns: XML namespace, in case required --> - + for it, although code which links to it will be generated --> should HTML markup within a documentation element be allowed? If so, are there restrictions? --> - + @@ -327,117 +330,6 @@ that we can allow HTML block level entities within content elements --> concrete %Boolean; #IMPLIED cascade (%CascadeActions;) #IMPLIED> - - - - - - - - - - - - - + + + + + diff --git a/transforms/adl2activerecord.xslt b/transforms/adl2activerecord.xslt new file mode 100755 index 0000000..1ce1cf0 --- /dev/null +++ b/transforms/adl2activerecord.xslt @@ -0,0 +1,715 @@ + + + + + + + + + + + + + + + + + + + + + + + + + abcdefghijklmnopqrstuvwxyz .,;:?/() + ABCDEFGHIJKLMNOPQRSTUVWXYZ_________ + + + /* ---- [ cut here: next file '.auto.cs'] ---------------- */ + //------------------------------------------------------------- + // + // + // .auto.cs + // + // (c)2007 Cygnet Solutions Ltd + // + // Main application entry point for + // Automatically generated from application description using + // adl2activerecord.xsl revision + // + // + // + // This file is automatically generated; DO NOT EDIT IT. + // + //------------------------------------------------------------- + + using System; + using System.Windows.Forms; + using Castle.ActiveRecord; + using Castle.ActiveRecord.Framework.Config; + using Cygnet.Entities; + + namespace + { + /// <summary> + /// + /// </summary> + /// <remarks> + /// Automatically generated from description of application + /// using adl2activerecord.xsl revision . + /// Note that manually maintained parts of this class may be defined in + /// a separate file called .manual.cs, q.v. + /// + /// DO NOT EDIT THIS FILE! + /// </remarks> + public class + { + public static void Main() + { + XmlConfigurationSource source = new XmlConfigurationSource("appconfig.xml"); + + ActiveRecordStarter.Initialize( source + + , typeof( ) + ); + } + } + } + /* ---- [ cut here: next file 'junk'] ------------------------- */ + + + + + + + + + /* ---- [ cut here: next file '.auto.cs'] ---------------- */ + + //------------------------------------------------------------- + // + // + // .auto.cs + // + // (c)2007 Cygnet Solutions Ltd + // + // Automatically generated from application description using + // adl2activerecord.xsl revision + // + // + // + // This file is automatically generated; DO NOT EDIT IT. + // + //------------------------------------------------------------- + + using System; + using System.Text; + using System.Collections.Generic; + using Castle.ActiveRecord; + using Cygnet.Entities; + using Cygnet.Exceptions; + using Cygnet.Entities.Exceptions; + + namespace + { + /// <summary> + /// + /// </summary> + /// <remarks> + /// Automatically generated from description of entity + /// using adl2activerecord.xsl revision . + /// Note that manually maintained parts of this class may be defined in + /// a separate file called .manual.cs, q.v. + /// + /// DO NOT EDIT THIS FILE! + /// </remarks> + [ActiveRecord] + public partial class : AdlActiveRecord<> + { + /// <summary> + /// Auto-generated no-args constructor; does nothing (but probably should + /// ensure ID slot is initialised correctly) + /// </summary> + public () : base(){ + + } + + + + + /* natural primary key exists - not generating abstract key */ + + + /* primary key exists - not generating abstract key */ + + /// <summary> + /// Auto-generated constructor; initialises each of the slots within + /// the primary key and also all one-to-many and many-to-many slots + /// </summary> + public ( + + + + + + + , + ){ + + + + + this. = ; + + } + + + + + ADL: ERROR: Entity '' has no key. Was the + canonicalise stage missed in the build process? + + + + /// <summary> + /// Auto-generated overridden property for the Key slot, maps onto + /// + /// .KeyString + /// </summary> + public override string KeyString { + get { + StringBuilder result = new StringBuilder(); + + result.Append(.KeyString); + + result.Append('|'); + + + return result.ToString(); + } + } + + /// <summary> + /// A user readable distinct identifying string + /// </summary> + public override string UserIdentifier + { + get { + StringBuilder result = new StringBuilder(); + + + + + + if ( != null){ + result.Append( ); + } + + + + if ( != null){ + result.Append( ); + } + + + + if ( != null){ + result.Append(.ToString( "d")); + } + + + + if ( != null){ + result.Append(.ToString( "t")); + } + + + + result.Append(.ToString()); + + + if ( != null){ + result.Append(); + } + + + + + + result.Append( ","); + + + + + + result.AppendFormat( "#{0}", KeyString); + + + + return result.ToString(); + } + } + + /// <summary> + /// If I should not be deleted, return a message explaining why I should not be deleted; else null. + /// </summary> + /// <returns>a message explaining why I should not be deleted; else null</returns> + public override string NoDeleteReason { + get { + string result = null; + + StringBuilder bob = new StringBuilder(); + + + + + + + + + + + if ( != null && .Count > 0) { + bob.AppendFormat("Cannot delete this as it has {0} dependent ; ", .Count); + } + + + + + if (bob.Length > 0) { + result = bob.ToString(); + } + + return result; + } + } + + + } + } + /* ---- [ cut here: next file 'junk'] ------------------------- */ + + + + + + /* NOTE: property '' is marked as being abstract; it must + * be supported by manually maintained code */ + + + + // auto generating iv/property pair for slot with name + + + + + + + + + + + + + + + + + + + + + + + + ? + + + + + + + + = "" + + + = + + + + = null + = false + = 0 + = 0.0M + = 0.0 + = null + + + + + + + + + + + + + + + private Regex Validator = new Regex( ""); + + + + + + + + + + + public const int = + + + + + + + + + + + + + ADL: ERROR: Cannot infer a value for option + + + ; + + + + private ; + + /// <summary> + + /// + /// Auto generated property for field + + /// + /// </summary> + + [PrimaryKey] + [Property(ColumnType="StringClob")] + + + + [HasMany(Inverse=true, Cascade=ManyRelationCascadeEnum.All)] + + + [HasMany(Inverse=true, Cascade=ManyRelationCascadeEnum.AllDeleteOrphan)] + + [HasMany(Inverse=true, Cascade=ManyRelationCascadeEnum.Delete)] + [HasMany(Inverse=true, Cascade=ManyRelationCascadeEnum.SaveUpdate)] + [HasMany] + + + [BelongsTo()] + [Property] + + [IsUserDistinct()] + public virtual + { + get { + + if ( == null) { + = new List<>(); + } + + + return ; + } + set { + + + + + + + + + + + if ( value == null) + { + throw new DataRequiredException( + + + + + "The value for may not be set to null" + + + ); + } + + + + + + + + + + + + + + + if ( value > ) + { + throw new DataRangeException( "The maximum permitted value for is "); + } + + + if ( value < ) + { + throw new DataRangeException( "The minimum permitted value for is "); + } + + + if ( value != null && ! Validator.IsMatch( value)) + { + throw new DataFormatException( string.Format( "The value supplied ({0}) does not match the format required by ", value)); + } + + + + + + switch ( value ) { + + case + + + : + + break; + default: + throw new DataRangeException( string.Format( "The value supplied ({0}) is not an acceptable value for ", value)); + } + + + + + if ( value != null && value.Length > ) + { + value = value.Substring( 0, ); + } + + = value; + } + } + + + /// <summary> + /// auto generated primitive value for key property of type entity (experimental) + /// </summary> + + + + + + private + = false + = 0 + = 0.0M + = 0.0 + = null + + [unknown? ] + + ; + + /// <summary> + /// auto generated primitive value getter/setter for key property of type entity (experimental) + /// </summary> + public virtual { + get { return ; } + set { = value; } + } + + + + + + + + + /* */ + + + + + + "" + + + + + /// + + + + + + + + + = new Message(); + + + + + + + + + + + + = new List<>(); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ADL: ERROR: could not find C# base type of property + + + + + + + + + + + + + + + + + + + + + + + + Message + + IList<> + + + IList<> + + DateTime + DateTime + String + String + Boolean + DateTime + int + double + Decimal + + + + + + + + + + + [unknown?] + + + + \ No newline at end of file diff --git a/transforms/adl2canonical.xslt b/transforms/adl2canonical.xslt index 7a4b22e..a1414d2 100755 --- a/transforms/adl2canonical.xslt +++ b/transforms/adl2canonical.xslt @@ -20,8 +20,8 @@ explicitly state the permission, even if it is 'none'. $Author: sb $ - $Revision: 1.3 $ - $Date: 2008-07-15 15:20:53 $ + $Revision: 1.4 $ + $Date: 2008-10-02 10:43:46 $ --> + *************************************************************************** @@ -73,11 +74,11 @@ * THIS FILE IS AUTOMATICALLY GENERATED AND SHOULD NOT * BE MANUALLY EDITED. * - * Generated using adl2canonical.xslt + * Generated using adl2canonical.xslt * *************************************************************************** - + diff --git a/transforms/adl2controllerclasses.xslt b/transforms/adl2controllerclasses.xslt index f995e6a..874600a 100755 --- a/transforms/adl2controllerclasses.xslt +++ b/transforms/adl2controllerclasses.xslt @@ -9,8 +9,8 @@ Transform ADL into (partial) controller classes $Author: sb $ - $Revision: 1.16 $ - $Date: 2008-08-22 17:14:41 $ + $Revision: 1.17 $ + $Date: 2008-10-02 10:43:42 $ --> - + @@ -40,7 +40,12 @@ - + + + abcdefghijklmnopqrstuvwxyz .,;:?/() + ABCDEFGHIJKLMNOPQRSTUVWXYZ_________ @@ -61,7 +66,7 @@ // (c)2007 Cygnet Solutions Ltd // // Automatically generated from application description using - // adl2entityclass.xsl revision + // adl2entityclass.xsl revision // // // @@ -77,6 +82,8 @@ using Cygnet.Exceptions; using Cygnet.Entities; using Iesi.Collections.Generic; + using NHibernate; + using NHibernate.Classic; namespace { @@ -85,7 +92,7 @@ /// </summary> /// <remarks> /// Automatically generated from description of entity - /// using adl2entityclass.xsl revision . + /// using adl2entityclass.xsl revision . /// Note that manually maintained parts of this class may be defined in /// a separate file called .manual.cs, q.v. /// @@ -153,7 +160,7 @@ return result.ToString(); } } - + /// <summary> /// True if I have not yet been persisted to the database, else false. /// NOTE: This code is experimental and may change! @@ -162,24 +169,24 @@ get { Boolean result = false; - - - if ( == 0) { - result = true; - } - - - if ( String.IsNullOrEmpty( )) { - result = true; - } - - - /* TODO: ADL does not yet correctly generate IsNew for - * properties of type */ - - - - return result; + + + if ( == 0) { + result = true; + } + + + if ( String.IsNullOrEmpty( )) { + result = true; + } + + + /* TODO: ADL does not yet correctly generate IsNew for + * properties of type */ + + + + return result; } } @@ -278,6 +285,28 @@ return result; } } + + /// <summary> + /// Should I permit myself to be deleted? If I have a valid NoDeleteReason then no. Otherwise + /// I should remove my backlinks to entities which list me in lists which have 'inverse="true"' + /// </summary> + /// <returns>a veto if I should not be deleted; else no veto</returns> + public override LifecycleVeto OnDelete(ISession hibernator) { + string ndr = NoDeleteReason; + LifecycleVeto result = LifecycleVeto.NoVeto; + if ( ndr != null) { + result = LifecycleVeto.Veto; + } else { + _indeletion = true; + + + = null; + + } + return result; + } + } @@ -338,7 +367,16 @@ = 0 = 0.0M = 0.0 - = null + + + + = "" + + + = null + + + @@ -356,6 +394,34 @@ private Regex Validator = new Regex( ""); + + + + + + + + + public const int = + + + + + + + + + + + + + ADL: ERROR: Cannot infer a value for option + + + ; + + + private ; /// <summary> @@ -371,7 +437,18 @@ /// /// </summary> + + + + + + + + + [FieldWidth()] + [IsUserDistinct()] + [Dimension( "money",Unit="")] public virtual { get { @@ -395,7 +472,7 @@ - if ( value == null) + if ( ! _indeletion && value == null) { throw new DataRequiredException( @@ -439,6 +516,52 @@ } + + + + + + + if ( value != null){ + + + switch ( value ) { + + case + + + : + + break; + default: + throw new DataRangeException( string.Format( "The value supplied ({0}) is not an acceptable value for ", value)); + } + + + + } + + + + + bool acceptable = false; + + + + + if ( value == null) { acceptable = true; } else + + + + if ( "".Equals( value)) { acceptable = true; } + else + + if ( ! acceptable) { + throw new DataRangeException( string.Format( "The value supplied ('{0}') is not an acceptable value for ", value)); + } + + + if ( value != null && value.Length > ) { @@ -488,6 +611,10 @@ + + [LocalisedDisplayName( "", Locale="")] + + "" @@ -518,4 +645,31 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/transforms/adl2hibernate.xslt b/transforms/adl2hibernate.xslt index 8e312a7..81d89f2 100755 --- a/transforms/adl2hibernate.xslt +++ b/transforms/adl2hibernate.xslt @@ -12,15 +12,28 @@ Transform ADL to Hibernate $Author: sb $ - $Revision: 1.5 $ + $Revision: 1.6 $ --> + + + + + @@ -422,20 +438,14 @@ false - - - - - - - - - - - - - + + + + + + all + + @@ -444,6 +454,22 @@ + + + + + + + + + + + + + + + @@ -475,23 +501,53 @@ + + + + + + + + + all + + + + + + + + + + + + + + + + + + + - + + + - + - + @@ -527,25 +583,38 @@ - - - + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/transforms/adl2mssql.xslt b/transforms/adl2mssql.xslt index 6405e09..d59acee 100755 --- a/transforms/adl2mssql.xslt +++ b/transforms/adl2mssql.xslt @@ -12,7 +12,7 @@ Convert ADL to MS-SQL $Author: sb $ - $Revision: 1.12 $ + $Revision: 1.13 $ --> @@ -26,6 +26,15 @@ Name_Id - the name of the auto generated primary key is the name of the entity followed by '_Id' --> + + + + @@ -103,7 +112,7 @@ -- -- -- Database for application version - -- Generated for MS-SQL 2000+ using adl2mssql.xslt + -- Generated for MS-SQL 2000+ using adl2mssql.xslt -- THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT IT. -- -- @@ -414,9 +423,25 @@ - + + + + + + + + + + + + + + + + + - + @@ -464,10 +489,10 @@ ------------------------------------------------------------------------------------------------- CREATE TABLE "" ( - "" + "" NOT NULL, - "" + "" NOT NULL ) @@ -526,13 +551,13 @@ - + - + @@ -540,13 +565,13 @@ - + - + @@ -742,7 +767,7 @@ DATETIME INT DOUBLE PRECISION - DECIMAL( 16,2) + DECIMAL( 16, 2) [sql:unknown? []]