diff --git a/transforms/adl2controllerclasses.xslt b/transforms/adl2controllerclasses.xslt index dc2c2f0..71842ac 100755 --- a/transforms/adl2controllerclasses.xslt +++ b/transforms/adl2controllerclasses.xslt @@ -1,6 +1,6 @@ - - - + - + - - + - - - - + + - + - - - - - - + + + + + + - - - - + + /* ---- [ cut here: next file '.auto.cs'] ---------------- */ + //------------------------------------------------------------------ + // + // + // + // + // (c) 2007 Cygnet Solutions Ltd + // + // Automatically generated abstract super class for controllers for the + // application; generated using + // adl2controllerclasses.xslt version + // + // This file is automatically generated; DO NOT EDIT IT. + // + //------------------------------------------------------------------ - - /* ---- [ cut here: next file '.auto.cs'] ---------------- */ -//------------------------------------------------------------------ -// -// -// -// -// (c) 2007 Cygnet Solutions Ltd -// -// Automatically generated abstract super class for controllers for the -// application; generated using -// adl2controllerclasses.xslt version -// -// This file is automatically generated; DO NOT EDIT IT. -// -//------------------------------------------------------------------ + using System; + using System.Data; + using System.Collections.Generic; + using NHibernate; + using NHibernate.Expression; + using Cygnet.Web.Controllers; + using ; -using System; -using System.Data; -using System.Collections.Generic; -using NHibernate; -using NHibernate.Expression; -using Cygnet.Web.Controllers; -using ; + namespace { -namespace { - - /// <summary> - /// Automatically generated abstract super class for controllers for the - /// application - /// - /// DO NOT EDIT THIS FILE! - /// </summary> - public abstract partial class : BaseController { - /// <summary> - /// Return a list of all instances of for use in menus, etc; + /// Automatically generated abstract super class for controllers for the + /// application + /// + /// DO NOT EDIT THIS FILE! /// </summary> - protected IList<> ( ISession hibernator) { + public abstract partial class : BaseController { + + /// <summary> + /// Return a list of all instances of for use in menus, etc; + /// </summary> + protected IList<> ( ISession hibernator) { return hibernator.CreateCriteria(typeof()) .AddOrder( ) - .SetCacheable( true) - .SetCacheRegion( "") - .List<>(); - } - + .SetCacheable( true) + .SetCacheRegion( "") + .List<>(); + } + - } -} + } + } + - - + + + - Not generating controller for entity , - as it has no forms, pages or lists. - + /* + * Not generating controller for entity , + * as it has no forms, pages or lists. + */ - + - /* ---- [ cut here: next file 'Controller.auto.cs'] ---------------- */ + /* ---- [ cut here: next file 'Controller.auto.cs'] ---------------- */ -//------------------------------------------------------------------ -// -// -// Controller.auto.cs -// -// (c) 2007 Cygnet Solutions Ltd -// -// Controller for auto-generated forms for editing s -// Automatically generated from application description using -// adl2controllerclasses.xslt version -// -// This file is automatically generated; DO NOT EDIT IT. -// -//------------------------------------------------------------------ + //------------------------------------------------------------------ + // + // + // Controller.auto.cs + // + // (c) 2007 Cygnet Solutions Ltd + // + // Controller for auto-generated forms for editing s + // Automatically generated from application description using + // adl2controllerclasses.xslt version + // + // This file is automatically generated; DO NOT EDIT IT. + // + //------------------------------------------------------------------ -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.Exceptions; -using Cygnet.Web.Helpers; -using Cygnet.Web.Controllers; -using Cygnet.Web.SmartControls; -using NHibernate; -using NHibernate.Expression; -using Castle.MonoRail.Framework; -using Iesi.Collections.Generic; -using ; + 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.Exceptions; + using Cygnet.Web.Helpers; + using Cygnet.Web.Controllers; + using Cygnet.Web.SmartControls; + using NHibernate; + using NHibernate.Expression; + using Castle.MonoRail.Framework; + using Iesi.Collections.Generic; + using ; -namespace { + namespace { - /// <summary> - /// Automatically generated partial controller class following 'thin controller' - /// strategy, for entity . Note that part of this - /// class may be defined in a separate file called - /// Controller.manual.cs, q.v. - /// - /// DO NOT EDIT THIS FILE! - /// </summary> - [ + /// <summary> + /// Automatically generated partial controller class following 'thin controller' + /// strategy, for entity . Note that part of this + /// class may be defined in a separate file called + /// Controller.manual.cs, q.v. + /// + /// DO NOT EDIT THIS FILE! + /// </summary> + [ - Layout(""), + Layout(""), - Rescue(""), + Rescue(""), - ControllerDetails("", Area = ""), - Helper(typeof(), "") - ] - public partial class : { + ControllerDetails("", Area = ""), + Helper(typeof(), "") + ] + public partial class : { /* The SmartFormHelper stuff in generated controller classes does not yet work. There is some - * hope that in future it will offer definite benefits and in the mean time it is doing no harm. - * However if you are looking for bugs look elsewhere - this is not currently used */ + * hope that in future it will offer definite benefits and in the mean time it is doing no harm. + * However if you are looking for bugs look elsewhere - this is not currently used */ protected class : SmartFormHelper { - public () { - - - - - - /* Entity is foreign..? */ - - Register<>( "", + public () { + + + + + + /* Entity is foreign..? */ + + Register<>( "", new TypeMenuControl<>( "","")); - - - Register<>( "", EntityMenuControl<>.Instance); - - - + + + Register<>( "", EntityMenuControl<>.Instance); + + + - Register<>( "", EntityShuffleControl<>.Instance); + Register<>( "", EntityShuffleControl<>.Instance); - } + } } - /// <summary> - /// Temporary hack to sort a problem with uninitialised messages - /// </summary> - public void fixupMessages() { - ISession hibernator = - NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN], - Session[NHibernateHelper.PASSTOKEN]); + /// <summary> + /// Temporary hack to sort a problem with uninitialised messages + /// </summary> + public void fixupMessages() { + ISession hibernator = + NHibernateHelper.GetCurrentSession( + Session[ NHibernateHelper.USERTOKEN], + Session[NHibernateHelper.PASSTOKEN] + ); ICollection<> instances = - hibernator.CreateCriteria( typeof( )) - .List<>(); - + hibernator.CreateCriteria( typeof( )) + .List<>(); + foreach ( instance in instances) { if ( == null || == 0 ){ - = new Message(); - hibernator.Save( ); + = new Message(); + hibernator.Save( ); } - hibernator.Save( instance); + hibernator.Save( instance); } hibernator.Flush(); - list(); + list(); - } + } - + - - /// <summary> - /// Store the record represented by the parameters passed in an HTTP service - /// Without Id -> it's new, I create a new persistent object; - /// With Id -> it's existing, I update the existing persistent object. - /// NOTE: Should only be called from a handler for method 'POST', never 'GET'. - /// </summary> - private void Store() - { - ISession hibernator = - NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN], - Session[NHibernateHelper.PASSTOKEN]); + + /// <summary> + /// Store the record represented by the parameters passed in an HTTP service + /// Without Id -> it's new, I create a new persistent object; + /// With Id -> it's existing, I update the existing persistent object. + /// NOTE: Should only be called from a handler for method 'POST', never 'GET'. + /// </summary> + private void Store() + { + ISession hibernator = + NHibernateHelper.GetCurrentSession( + Session[ NHibernateHelper.USERTOKEN], + Session[NHibernateHelper.PASSTOKEN] + ); List<string> messages = new List<string>(); /* A 'newborn' instance can be updated even if the current user doesn't have - * update permissions, seeing that we use an update operation to set the - * field values and save the entity. */ + * update permissions, seeing that we use an update operation to set the + * field values and save the entity. */ Boolean isnewborn = false; - + /* the instance (record) of type we're dealing with */ - record = null; + record = null; try { - + /* a criteria object to use in distinctness checks */ ICriteria matchCriteria = null; - + - record = FetchRecord( hibernator); + record = FetchRecord( hibernator); - + - if ( HasNoErrors()) { - if ( record == null) { - /* it seems to be new, create persistent object - if the user is permitted to */ - AssertUserCanCreate(); - - try { - record = new ( - - - - - - - Int32.Parse( Form[""]) - - - - - - - - - hibernator.CreateCriteria( typeof( )) - - - - Form[ ""] - - - .UniqueResult<>() - Form[""] - - - - , - - ); - } - catch ( FormatException) { - /* failed to parse a number - not wholly unexpected, since it's most likely - * that an empty string was passed in */ - record = new (); - } - catch ( NullReferenceException) { - /* again, probably more normal than otherwise */ - record = new (); - } - messages.Add( "New record created"); - isnewborn = true; - } + if ( HasNoErrors()) { + if ( record == null) { + /* it seems to be new, create persistent object - if the user is permitted to */ + AssertUserCanCreate(); - if ( record != null) { - /* a transaction to ensure our database operations are atomic */ - ITransaction tx = null; - - if ( ! isnewborn) { - /* isnewborn cannot be true unless we've already checked user can create - * so no need to do it again here */ - AssertUserCanUpdate(); - } - - try { - /* begin our atomic transaction */ - tx = hibernator.BeginTransaction(); - - /* actually update the record */ - BindObjectInstance( record, ParamStore.Form, "instance"); - - - /* there is at least one slot whose value is an internationalised message; - * if these have yet to be initialised they must be handled specially */ - Locale locale = GetBestLocaleForUser(); - - if ( ! String.IsNullOrEmpty( Form[""])){ - /* there's an uninitialised message for this slot */ - Message mess = record.; - if ( mess == null) { - mess = new Message(); - } - hibernator.Save( mess); - - Translation trans = mess.GetTranslationObject( locale, hibernator); - if ( trans == null) { - trans = new Translation( mess, locale); - } - trans.MessageText = Form[""]; - record. = mess; - hibernator.Save( trans); - } - - - - /* for properties of type 'entity', it should not be necessary to do anything - * special - BindObjectInstance /should/ do it all. Unfortunately it sometimes - * doesn't, and I haven't yet characterised why not. */ - - - - if ( ! String.IsNullOrEmpty( Form[""])) - { - record. = + try { + record = new ( + + - - ; - } - - - - ADL: ERROR: Could not fix up value of , because no - entity was found called - - - - + + + + + Int32.Parse( Form[""]) + + + + + + + + + + hibernator.CreateCriteria( typeof( )) + + + + Form[ ""] + + + .UniqueResult<>() + + + Form[""] + + + + + , + + ); + } + catch ( FormatException) { + /* failed to parse a number - not wholly unexpected, since it's most likely + * that an empty string was passed in */ + record = new (); + } + catch ( NullReferenceException) { + /* again, probably more normal than otherwise */ + record = new (); + } + messages.Add( "New record created"); + isnewborn = true; + } - + if ( record != null) { + /* a transaction to ensure our database operations are atomic */ + ITransaction tx = null; + + if ( ! isnewborn) { + /* isnewborn cannot be true unless we've already checked user can create + * so no need to do it again here */ + AssertUserCanUpdate(); + } + + try { + /* begin our atomic transaction */ + tx = hibernator.BeginTransaction(); + + /* actually update the record */ + BindObjectInstance( record, ParamStore.Form, "instance"); + + + /* there is at least one slot whose value is an internationalised message; + * if these have yet to be initialised they must be handled specially */ + Locale locale = GetBestLocaleForUser(); + + if ( ! String.IsNullOrEmpty( Form[""])){ + /* there's an uninitialised message for this slot */ + Message mess = record.; + if ( mess == null) { + mess = new Message(); + } + hibernator.Save( mess); + + Translation trans = mess.GetTranslationObject( locale, hibernator); + if ( trans == null) { + trans = new Translation( mess, locale); + } + trans.MessageText = Form[""]; + record. = mess; + hibernator.Save( trans); + } + + + + /* for properties of type 'entity', it should not be necessary to do anything + * special - BindObjectInstance /should/ do it all. Unfortunately it sometimes + * doesn't, and I haven't yet characterised why not. */ + + + + if ( ! String.IsNullOrEmpty( Form[""])) + { + record. = + + Form[ ""] + ; + } + + + + ADL: ERROR: Could not fix up value of , because no + entity was found called + + + + + + @@ -396,38 +403,38 @@ namespace { - /* to update a link table which has no other data than the near and far keys, it is - * sufficient to smash the existing values and create new ones. It's also a lot easier! */ - - string[] = Form.GetValues( ""); - - if ( != null) - { - /* update the linking table for my ; first smash the old values */ - if ( != null) - { - .Clear(); - } - else - { - = new HashedSet<>(); - } - - /* then reinstate the values from the indexes passed */ - foreach ( string index in ) - { - .Add( - hibernator.CreateCriteria(typeof()) - - - - - .UniqueResult<>()); - } - } - + /* to update a link table which has no other data than the near and far keys, it is + * sufficient to smash the existing values and create new ones. It's also a lot easier! */ - + string[] = Form.GetValues( ""); + + if ( != null) + { + /* update the linking table for my ; first smash the old values */ + if ( != null) + { + .Clear(); + } + else + { + = new HashedSet<>(); + } + + /* then reinstate the values from the indexes passed */ + foreach ( string index in ) + { + .Add( + hibernator.CreateCriteria(typeof()) + + + + + .UniqueResult<>()); + } + } + + + @@ -447,277 +454,269 @@ namespace { - /* with a list we cannot just smash the old values! Instead we need to check - * each one and exclude it if no longer required */ - if ( Form.GetValues( "") != null) - { - string[] = Form.GetValues( ""); + /* with a list we cannot just smash the old values! Instead we need to check + * each one and exclude it if no longer required */ + if ( Form.GetValues( "") != null) + { + string[] = Form.GetValues( ""); - /* updating child records; first remove any not on the submitted list */ - foreach ( item in record.) - { - String itemId = item.KeyString; - bool found = false; + /* updating child records; first remove any not on the submitted list */ + foreach ( item in record.) + { + String itemId = item.KeyString; + bool found = false; - foreach ( string index in ) - { - if ( index.Equals( itemId)) - { - found = true; - break; - } - } /* foreach ( string index... */ - - if ( ! found) - { - record..Remove( item); - break; - } - } /* foreach ( item ... */ + foreach ( string index in ) + { + if ( index.Equals( itemId)) + { + found = true; + break; + } + } /* foreach ( string index... */ - /* then add any on the included list which are not already members */ - foreach ( string index in ) - { - item = - hibernator.CreateCriteria(typeof()) - - - - - .UniqueResult<>(); - - if ( ! record..Contains( item)) - { - /* check whether it's already a child of another - * and, if it is, remove it */ - oldparent = - ; - if ( oldparent != null) { - oldparent..Remove( item); - hibernator.Save( oldparent); - } - - /* then add it to my */ - record..Add( item); - = record; - hibernator.Save( item); - } - } /* foreach ( string index... */ - } /* if ( Form.GetValues( "") != null) */ - + if ( ! found) + { + record..Remove( item); + break; + } + } /* foreach ( item ... */ - /* write the record to the database, in order to guarantee we have a valid key */ - hibernator.Save(record); - hibernator.Flush(); - tx.Commit(); - - messages.Add( ""); - } /* try actually commit */ - catch ( Exception any) { - tx.Rollback(); - messages.Add( ""); - throw any; - } - } /* if ( record != null) */ - else { - throw new ApplicationException( String.Format( " - - ")); - } - } /* if ( HasNoErrors()) */ + /* then add any on the included list which are not already members */ + foreach ( string index in ) + { + item = + hibernator.CreateCriteria(typeof()) + + + + + .UniqueResult<>(); + + if ( ! record..Contains( item)) + { + /* check whether it's already a child of another + * and, if it is, remove it */ + oldparent = + ; + if ( oldparent != null) { + oldparent..Remove( item); + hibernator.Save( oldparent); + } + + /* then add it to my */ + record..Add( item); + = record; + hibernator.Save( item); + } + } /* foreach ( string index... */ + } /* if ( Form.GetValues( "") != null) */ + + + /* write the record to the database, in order to guarantee we have a valid key */ + hibernator.Save(record); + hibernator.Flush(); + tx.Commit(); + + messages.Add( ""); + } /* try actually commit */ + catch ( Exception any) { + tx.Rollback(); + messages.Add( ""); + throw any; + } + } /* if ( record != null) */ + else { + throw new ApplicationException( String.Format( " + + ")); + } + } /* if ( HasNoErrors()) */ } /* try */ catch ( DataSuitabilityException dse) { - AddError( dse); + AddError( dse); } catch ( ApplicationException axe) { - AddError( axe.Message); + AddError( axe.Message); } if ( ! HasNoErrors()) { - /* the session may be polluted; create a new session */ - NHibernateHelper.CloseSession(); - hibernator = NHibernateHelper.GetCurrentSession( - Session[ NHibernateHelper.USERTOKEN], - Session[NHibernateHelper.PASSTOKEN]); + /* the session may be polluted; create a new session */ + NHibernateHelper.CloseSession(); + hibernator = NHibernateHelper.GetCurrentSession( + Session[ NHibernateHelper.USERTOKEN], + Session[NHibernateHelper.PASSTOKEN] + ); - record = FetchRecord( hibernator); + record = FetchRecord( hibernator); } /* if ( ! HasNoErrors()) */ + ( record); + } + - TypedPropertyBag = new { - - - - - username = Session[ NHibernateHelper.USERTOKEN], - - messages = messages, - instance = record }; - - RenderViewWithFailover("", - ""); - } - - - - - /// <summary> - /// Actually delete the selected record - /// </summary> - [AccessibleThrough(Verb.Post)] - public void Delete() - { + + + /// <summary> + /// Actually delete the selected record + /// </summary> + [AccessibleThrough(Verb.Post)] + public void Delete() + { AssertUserCanDelete(); - ISession hibernator = - NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN], - Session[NHibernateHelper.PASSTOKEN]); + ISession hibernator = + NHibernateHelper.GetCurrentSession( + Session[ NHibernateHelper.USERTOKEN], + Session[NHibernateHelper.PASSTOKEN] + ); if ( "true".Equals( Params["reallydelete"])) { - record = FetchRecord( hibernator); + record = FetchRecord( hibernator); - if ( record != null) - { - hibernator.Delete( record); - hibernator.Flush(); - } - else - { - throw new ApplicationException( "No such record?"); - } + if ( record != null) + { + hibernator.Delete( record); + hibernator.Flush(); } - - - Redirect( ""); - - - Redirect( FormsAuthentication.DefaultUrl); - - - } - - + else + { + throw new ApplicationException( "No such record?"); + } + } + + + Redirect( ""); + + + Redirect( FormsAuthentication.DefaultUrl); + + + } + + - - - - /// <summary> - /// list all instances of this entity to allow the user to select one for editing - /// this method invokes the default list view - which is probably what you want unless - /// you've a special reason for doing something different - /// </summary> - public void InternalShowList() - { + + + + /// <summary> + /// list all instances of this entity to allow the user to select one for editing + /// this method invokes the default list view - which is probably what you want unless + /// you've a special reason for doing something different + /// </summary> + public void InternalShowList() + { InternalShowList( ""); - } + } - /// <summary> - /// list all instances of this entity to allow the user to select one for editing - /// </summary> - /// <param name="view">The name of the list view to show</param> - public void InternalShowList( String view) - { + /// <summary> + /// list all instances of this entity to allow the user to select one for editing + /// </summary> + /// <param name="view">The name of the list view to show</param> + public void InternalShowList( String view) + { AssertUserCanRead(); - ISession hibernator = - NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN], - Session[NHibernateHelper.PASSTOKEN]); + ISession hibernator = + NHibernateHelper.GetCurrentSession( + Session[ NHibernateHelper.USERTOKEN], + Session[NHibernateHelper.PASSTOKEN] + ); ICriteria search = - hibernator.CreateCriteria(typeof()); + hibernator.CreateCriteria(typeof()); - - - - - - - - - - - - if ( ! String.IsNullOrEmpty( Params[ ""])) { - search - - - ; - } - - - - - search.AddOrder(); - + + + + + + + + + + + + if ( ! String.IsNullOrEmpty( Params[ ""])) { + search + + Params[""] + ; + } + + + + + search.AddOrder(); + - IList<> instances = search.List<>(); + IList<> instances = search.List<>(); - - PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN]; - + + PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN]; + PropertyBag["instances"] = PaginationHelper.CreatePagination( this, instances, 25); RenderViewWithFailover(view + ".vm", view + ".auto.vm"); - } - + } + /// <summary> /// Fetch the record represented by the values in the current Form /// </summary> protected FetchRecord(ISession hibernator) { - /* the instance (record) of type we're dealing with */ - record = null; - /* whether we have valid values for all the key fields */ - bool allkeys = true; + /* the instance (record) of type we're dealing with */ + record = null; + /* whether we have valid values for all the key fields */ + bool allkeys = true; - /* check whether values for all key slots have been passed in; if so, we're probably dealing with an - * existing record */ - + /* check whether values for all key slots have been passed in; if so, we're probably dealing with an + * existing record */ + if ( String.IsNullOrEmpty( Form[""])) { - allkeys = false; + allkeys = false; } else if ( "".Equals( Form[""])) { - /* nasty artefact of NVelocity forms - default 'null value' is dollar followed by fieldname */ - allkeys = false; + /* nasty artefact of NVelocity forms - default 'null value' is dollar followed by fieldname */ + allkeys = false; } - + - if ( allkeys){ - /* it's (probably) existing, retrieve it */ - record = hibernator.CreateCriteria(typeof()) - - - - - - - - .UniqueResult<>(); - } - - return record; + if ( allkeys){ + /* it's (probably) existing, retrieve it */ + record = hibernator.CreateCriteria(typeof()) + + + + Form[""] + + + .UniqueResult<>(); + } + + return record; + } + } } - } -} /* ---- [ cut here: next file 'junk'] ------------------------- */ - if ( String.IsNullOrEmpty( Form[ "" ])) - { - AddError( - - - - - " - - " - - ); - } + if ( String.IsNullOrEmpty( Form[ "" ])) + { + AddError( + + + + + " + + " + + ); + } @@ -736,196 +735,139 @@ namespace { /// </summary> [AccessibleThrough(Verb.Post)] public void ( ) { - string command = Form[ "command"]; + string command = Form[ "command"]; - if ( command == null) { - throw new Exception( ""); - } - else + if ( command == null) { + throw new Exception( ""); + } + else if ( command.Equals( "")) { - /* NOTE: You must write an implementation of this verb in a - * manually maintained partial class file for this class */ - (); + /* NOTE: You must write an implementation of this verb in a + * manually maintained partial class file for this class */ + (); } else - if ( command.Equals( "delete")) - { - ISession hibernator = - NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN], - Session[NHibernateHelper.PASSTOKEN]); + if ( command.Equals( "delete")) + { + ISession hibernator = + NHibernateHelper.GetCurrentSession( + Session[ NHibernateHelper.USERTOKEN], + Session[NHibernateHelper.PASSTOKEN] + ); - record = FetchRecord( hibernator); + record = FetchRecord( hibernator); - TypedPropertyBag = new { - - username = Session[ NHibernateHelper.USERTOKEN], + TypedPropertyBag = new { + + username = Session[ NHibernateHelper.USERTOKEN], - instance = record }; - - RenderViewWithFailover( "maybedelete.vm", "maybedelete.auto.vm"); - } - else if ( command.Equals( "store")) - { - Store(); - } - else - { - throw new Exception( String.Format(" - - ", command)); - } + instance = record }; + + RenderViewWithFailover( "maybedelete.vm", "maybedelete.auto.vm"); } - + else if ( command.Equals( "store")) + { + Store(); + } + else + { + throw new Exception( String.Format(" + + ", command)); + } + } + /// <summary> /// Show the form named , with no content /// </summary> [AccessibleThrough(Verb.Get)] public void ( ) { - AssertUserCanRead(); - - /* we don't actually instantiate this local variable; it exists to that - * TypedPropertyBag can do introspection to infer property types */ - record = null; - - ISession hibernator = - NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN], - Session[NHibernateHelper.PASSTOKEN]); + AssertUserCanRead(); - TypedPropertyBag = new { - - username = Session[ NHibernateHelper.USERTOKEN], - - - - - instance = record - }; - - RenderViewWithFailover("", - ""); + ( ()null); } - - - + /// <summary> /// Show the form named , containing the indicated record. As /// the primary key of the record is itself an entity, we need to first fetch that entity /// </summary> - - - - /// <param name="">the key value of the key value of the record to show</param> - - - /// <param name="">the key value of the record to show</param> - - - - [AccessibleThrough(Verb.Get)] - public void ( - - string - - - - - - - - - - , - ) { - ISession hibernator = - NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN], - Session[NHibernateHelper.PASSTOKEN]); - this.( + - - hibernator.CreateCriteria(typeof()) - - - - - .UniqueResult<>() + /// <param name="">the key value of the key value of the record to show</param> - + /// <param name="">the key value of the record to show</param> - , - ); - } - - - /// <summary> - /// Show the form named , containing the indicated record - /// </summary> - - /// <param name="">the key value of the record to show</param> - + [AccessibleThrough(Verb.Get)] public void ( - + string , - ) - { - ISession hibernator = - NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN], - Session[NHibernateHelper.PASSTOKEN]); - record = - hibernator.CreateCriteria(typeof()) + ) { + ISession hibernator = + NHibernateHelper.GetCurrentSession( + Session[ NHibernateHelper.USERTOKEN], + Session[NHibernateHelper.PASSTOKEN] + ); + ( + hibernator.CreateCriteria( typeof()) - .UniqueResult<>(); - - TypedPropertyBag = new { - - username = Session[ NHibernateHelper.USERTOKEN], + .UniqueResult<>()); + } + + /// <summary> + /// Show the form named , containing the indicated record + /// </summary> + /// <param name="record">the record to show</param> + protected void ( record) + { + ISession hibernator = + NHibernateHelper.GetCurrentSession( + Session[ NHibernateHelper.USERTOKEN], + Session[NHibernateHelper.PASSTOKEN] + ); + + TypedPropertyBag = new { + + username = Session[ NHibernateHelper.USERTOKEN], - - instance = record }; + + instance = record }; - RenderViewWithFailover("", ""); + RenderViewWithFailover("", ""); } + - - - + /// <summary> /// list all instances of this entity to allow the user to select one /// this method invokes the named view. /// </summary> public void () { - InternalShowList( ""); + InternalShowList( ""); } - + - + /* */ - + @@ -951,15 +893,17 @@ namespace { /* should be distinct: check that it is */ matchCriteria = - hibernator.CreateCriteria(typeof()); + hibernator.CreateCriteria(typeof()); matchCriteria - + + Form[""] + ; - + if ( record != null) { - /* i.e. we do have values for each of our key fields... */ + /* i.e. we do have values for each of our key fields... */ @@ -969,16 +913,17 @@ namespace { matchCriteria.Add(Expression.Not( - Form[""] + Form[""] + )); } if ( matchCriteria.List<>().Count > 0) { - AddError( - String.Format("There is already a {0} with the {1} '{2}'", - "", "", Form[""])); + AddError( + String.Format("There is already a {0} with the {1} '{2}'", + "", "", Form[""])); } @@ -1002,19 +947,19 @@ namespace { - /* produce a list of to populate the select for */ + /* produce a list of to populate the select for */ - /* produce a list of to populate the LHS of the shuffle for */ + /* produce a list of to populate the LHS of the shuffle for */ - /* produce a list of to populate the multi-select for */ + /* produce a list of to populate the multi-select for */ @@ -1027,15 +972,15 @@ namespace { - + - /* there's no way I can find of producing a set of just those entities - * we'll need menus for. So we set up variables for all the menus we might - * need, and then only instantiate those we do need. */ + /* there's no way I can find of producing a set of just those entities + * we'll need menus for. So we set up variables for all the menus we might + * need, and then only instantiate those we do need. */ - + @@ -1055,14 +1000,14 @@ namespace { - + - + - = - ( NHibernateHelper.GetCurrentSession()), - + = + ( NHibernateHelper.GetCurrentSession()), + @@ -1153,7 +1098,7 @@ namespace { - Expression.Eq("", + Expression.Eq("", @@ -1164,11 +1109,10 @@ namespace { Decimal.Parse( ) - Date.Parse( ) + DateTime.Parse( ) - @@ -1194,7 +1138,7 @@ namespace { - Expression.Like( "", "%"+Params[""]+"%") + Expression.Like( "", "%"++"%") @@ -1233,7 +1177,7 @@ namespace { - + @@ -1244,14 +1188,14 @@ namespace { ADL: ERROR: property passed to fetch-property-instance whose type is not 'entity' - hibernator.CreateCriteria(typeof()) + hibernator.CreateCriteria(typeof()) - Form[""] + - .UniqueResult<>() + .UniqueResult<>() \ No newline at end of file diff --git a/transforms/adl2entityclasses.xslt b/transforms/adl2entityclasses.xslt index 4372f26..be0ad61 100755 --- a/transforms/adl2entityclasses.xslt +++ b/transforms/adl2entityclasses.xslt @@ -1,5 +1,5 @@ - - - /* ---- [ cut here: next file '.auto.cs'] ---------------- */ - - //------------------------------------------------------------- - // - // - // .auto.cs - // - // (c)2007 Cygnet Solutions Ltd - // - // Automatically generated from application description using - // adl2entityclass.xsl revision - // - // This file is automatically generated; DO NOT EDIT IT. - // - //------------------------------------------------------------- - namespace - { - using System; - using System.Configuration; - using System.Collections; - using System.Collections.Generic; - using System.Text; - using System.Text.RegularExpressions; - using Cygnet.Exceptions; - using Cygnet.Entities; - using Iesi.Collections.Generic; - /// <summary> - /// - /// </summary> - /// <remarks> - /// Automatically generated from description of entity - /// using adl2entityclass.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 partial class : Entity - { - /// <summary> - /// Auto-generated no-args constructor; does nothing (but probably should - /// ensure ID slot is initialised correctly) - /// </summary> - public () : base(){ - - } + //------------------------------------------------------------- + // + // + // .auto.cs + // + // (c)2007 Cygnet Solutions Ltd + // + // Automatically generated from application description using + // adl2entityclass.xsl revision + // + // This file is automatically generated; DO NOT EDIT IT. + // + //------------------------------------------------------------- + using System; + using System.Configuration; + using System.Collections; + using System.Collections.Generic; + using System.Text; + using System.Text.RegularExpressions; + using Cygnet.Exceptions; + using Cygnet.Entities; + using Iesi.Collections.Generic; + + namespace + { + /// <summary> + /// + /// </summary> + /// <remarks> + /// Automatically generated from description of entity + /// using adl2entityclass.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 partial class : Entity + { + /// <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 - /// </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")); - - - 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); - } + result.Append( ); + + + + result.Append(.ToString( "d")); + + + + result.Append(.ToString( "t")); + + + result.Append(); + + + + + + result.Append( ","); + + + } + + + + result.AppendFormat( "#{0}", KeyString); + + - - - - if (bob.Length > 0) { - result = bob.ToString(); - } - - return result; - } - } - - - } - } - /* ---- [ cut here: next file 'junk'] ------------------------- */ + 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(); + - - - /* NOTE: property '' is marked as being abstract; it must - * be supported by manually maintained code */ - - - - // auto generating iv/property pair for slot with name - + + + + + + + + + if ( != null && .Count > 0) { + bob.AppendFormat("Cannot delete this as it has {0} dependent ; ", .Count); + } - - - - - - - - - - - - - - - - - - - - - - - ? - - - - - - - - = "" - - - = - - - - = null - = false - = 0 - = 0.0M - = 0.0 - = null - - + + + + if (bob.Length > 0) { + result = bob.ToString(); + } + + return result; + } + } + + + } + } + /* ---- [ cut here: next file 'junk'] ------------------------- */ - - - - - - - - - - - - private Regex Validator = new Regex( ""); - + - private ; + + + /* NOTE: property '' is marked as being abstract; it must + * be supported by manually maintained code */ + - /// <summary> - /// - - - - Auto generated property for field - : - /// - /// </summary> - public virtual - { - get { - - if ( == null) { - = new HashedSet<>(); - } - - - 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)); - } - - - - if ( value != null && value.Length > ) - { - value = value.Substring( 0, ); - } - - = value; - } - } + + // auto generating iv/property pair for slot with name + - - /* generate primitive value getter/setter for key property of type entity (experimental) */ - - - - - - private - = false - = 0 - = 0.0M - = 0.0 - = null - [unknown? ] - - ; + + + + + + + + + + + + + + + + + + + + + + + ? + + + + + + + + = "" + + + = + + + + = null + = false + = 0 + = 0.0M + = 0.0 + = null + + - public virtual { - get { return ; } - set { = value; } - } - + + + + + + + + + + + + private Regex Validator = new Regex( ""); + - + private ; - - - - + /// <summary> + + + /// + + + /// Auto generated property for field + + + + /// + + /// </summary> + public virtual + { + get { + + if ( == null) { + = new HashedSet<>(); + } + + + 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)); + } + + + + 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; } + } + + + + + + + + /* */ - - - - - - "" - - + + + + + + "" + + @@ -437,7 +444,7 @@ - = new Message(); + = new Message(); @@ -449,7 +456,7 @@ - = new HashedSet<>(); + = new HashedSet<>(); diff --git a/transforms/adl2views.xslt b/transforms/adl2views.xslt index ec8bd6d..da436f5 100755 --- a/transforms/adl2views.xslt +++ b/transforms/adl2views.xslt @@ -13,8 +13,8 @@ Transform ADL into velocity view templates $Author: sb $ - $Revision: 1.7 $ - $Date: 2008-06-06 08:46:27 $ + $Revision: 1.8 $ + $Date: 2008-06-06 15:52:48 $ --> @@ -124,7 +124,7 @@ Auto generated Velocity maybe-delete form for , generated from ADL. - Generated using adl2views.xslt + Generated using adl2views.xslt @@ -162,7 +162,7 @@ Auto generated Velocity maybe-delete form for , generated from ADL. - Generated using adl2views.xslt + Generated using adl2views.xslt @@ -243,7 +243,7 @@ Auto generated Velocity form for , generated from ADL. - Generated using adl2views.xslt + Generated using adl2views.xslt #capturefor( title) #if ( $instance) @@ -364,7 +364,7 @@ Auto generated Velocity form for , generated from ADL. - Generated using adl2views.xsl + Generated using adl2views.xsl