diff --git a/transforms01/adl2canonical.xslt b/transforms01/adl2canonical.xslt index 5ebaf25..0272f75 100755 --- a/transforms01/adl2canonical.xslt +++ b/transforms01/adl2canonical.xslt @@ -20,8 +20,8 @@ explicitly state the permission, even if it is 'none'. $Author: sb $ - $Revision: 1.8 $ - $Date: 2008-02-28 14:52:08 $ + $Revision: 1.9 $ + $Date: 2008-05-09 16:12:12 $ --> + * Generated using adl2canonical.xslt * *************************************************************************** @@ -407,14 +407,15 @@ NOTE that n-to-n properties cannot currently be user-distinct and are therefore not inspected --> - + + + - \ No newline at end of file diff --git a/transforms01/adl2controllerclasses.xslt b/transforms01/adl2controllerclasses.xslt index beac2ae..e055989 100755 --- a/transforms01/adl2controllerclasses.xslt +++ b/transforms01/adl2controllerclasses.xslt @@ -9,8 +9,8 @@ Transform ADL into (partial) controller classes $Author: sb $ - $Revision: 1.23 $ - $Date: 2008-05-08 17:26:44 $ + $Revision: 1.24 $ + $Date: 2008-05-09 16:12:12 $ --> - /// <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], + /// <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. - Boolean isnewborn = false; + 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. */ + Boolean isnewborn = false; - - - - + /* the instance (record) of type we're dealing with */ + record = null; - try { + try { - /* declare a list of to use in - * distinctness checks */ - IList<> matches = null; - + /* a criteria object to use in distinctness checks */ + ICriteria matchCriteria = null; + - + record = FetchRecord( hibernator); - if ( record == null) { - /* it seems to be new, create persistent object */ - AssertUserCanCreate(); + + + if ( HasNoErrors()) { + if ( record == null) { + /* it seems to be new, create persistent object - if the user is permitted to */ + AssertUserCanCreate(); - try { - record = new ( + try { + record = new ( - + Int32.Parse( Form[""]) - if ( index.Equals( itemId)) - { - found = true; - break; - } - } + foreach ( string index in ) + { + if ( index.Equals( itemId)) + { + found = true; + break; + } + } /* foreach ( string index... */ - if ( ! found) - { - record..Remove( item); - } - } /* foreach ( string index... */ + if ( ! found) + { + record..Remove( item); + } + } /* foreach ( item ... */ - /* then add any on the included list which are not already members */ - foreach ( string index in ) - { - - item = - hibernator.CreateCriteria(typeof()) - .Add(Expression.Eq("Id", index)) - .UniqueResult<.>(); + /* then add any on the included list which are not already members */ + foreach ( string index in ) + { + + item = + hibernator.CreateCriteria(typeof()) + .Add(Expression.Eq("Id", index)) + .UniqueResult<.>(); - if ( ! record..Contains( item)) - { - record..Add( item); - } - } /* foreach ( string index... */ - } /* if ( Form.GetValues( "") != null) */ + if ( ! record..Contains( item)) + { + record..Add( 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(); + /* write the record to the database, in order to guarantee we have a valid key */ + hibernator.Save(record); + hibernator.Flush(); + tx.Commit(); - messages.Add( "Record saved successfully"); - } /* try actually commit */ - catch ( Exception any) { - tx.Rollback(); - messages.Add( "Record not saved"); - throw any; - } - } /* if ( record != null) */ - else { - throw new ApplicationException( String.Format( "No record of type with the key values supplied was found")); - } - } /* try */ - catch ( DataSuitabilityException dse) - { - AddError( dse); - } - catch ( ApplicationException axe) - { - AddError( axe.Message); - } + messages.Add( "Record saved successfully"); + } /* try actually commit */ + catch ( Exception any) { + tx.Rollback(); + messages.Add( "Record not saved"); + throw any; + } + } /* if ( record != null) */ + else { + throw new ApplicationException( String.Format( "No record of type with the key values supplied was found")); + } + } /* if ( HasNoErrors()) */ + } /* try */ + catch ( DataSuitabilityException dse) + { + AddError( dse); + } + catch ( ApplicationException axe) + { + AddError( axe.Message); + } - PropertyBag["messages"] = messages; - PropertyBag["instance"] = record; + PropertyBag["messages"] = messages; + PropertyBag["instance"] = record; - PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN]; + PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN]; - if ( HasNoErrors()) - { - /* the session may be polluted; create a new session */ - NHibernateHelper.CloseSession(); - hibernator = NHibernateHelper.GetCurrentSession( - Session[ NHibernateHelper.USERTOKEN], - Session[NHibernateHelper.PASSTOKEN] - ); + if ( ! HasNoErrors()) + { + /* the session may be polluted; create a new session */ + NHibernateHelper.CloseSession(); + hibernator = NHibernateHelper.GetCurrentSession( + Session[ NHibernateHelper.USERTOKEN], + Session[NHibernateHelper.PASSTOKEN]); - - - - - - } + record = FetchRecord( hibernator); + } /* if ( ! HasNoErrors()) */ - RenderViewWithFailover("", - ""); - } + RenderViewWithFailover("", + ""); + } - /// <summary> - /// Actually delete the selected record - /// </summary> - [AccessibleThrough(Verb.Post)] - public void Delete() - { - AssertUserCanDelete(); - ISession hibernator = - NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN], + /// <summary> + /// Actually delete the selected record + /// </summary> + [AccessibleThrough(Verb.Post)] + public void Delete() + { + AssertUserCanDelete(); + ISession hibernator = + NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN], Session[NHibernateHelper.PASSTOKEN]); - string reallydelete = Params["reallydelete"]; + if ( "true".Equals( Params["reallydelete"])) + { + record = FetchRecord( hibernator); - if ( "true".Equals( reallydelete)) - { - - - - - - if ( record != null) - { - hibernator.Delete( record); - - hibernator.Flush(); - } - else - { - throw new ApplicationException( "No such record?"); - } - } - + if ( record != null) + { + hibernator.Delete( record); + hibernator.Flush(); + } + else + { + throw new ApplicationException( "No such record?"); + } + } + - Redirect( ""); + Redirect( ""); - Redirect( FormsAuthentication.DefaultUrl); + 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() - { - 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) - { - AssertUserCanRead(); - ISession hibernator = - NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN], + /// <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]); - IList<> instances = - hibernator.CreateCriteria(typeof()) + IList<> instances = + hibernator.CreateCriteria(typeof()) .List<>(); - PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN]; + PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN]; - PropertyBag["instances"] = - PaginationHelper.CreatePagination( this, instances, 25); + PropertyBag["instances"] = + PaginationHelper.CreatePagination( this, instances, 25); - RenderViewWithFailover(view + ".vm", view + ".auto.vm"); - } + 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; + + /* 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; + } else if ( "".Equals( Form[""])) { + /* 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()) + + + + + + + .Add( Expression.Eq( "", + + Int32.Parse( Form[ ""]) + + + + + + + + + + hibernator.CreateCriteria( typeof( )) + .Add(Expression.Eq( "", + + Int32.Parse( Form[ ""]) + + + Form[ ""] + + )) + .UniqueResult<>() + + + Form[ ""] + + )) + + .UniqueResult<>(); + } + + return record; + } + } } - /* ---- [ cut here: next file 'junk'] ------------------------- */ - - - - if ( Form[ "" ] == null) - { - AddError( - - - - "You must supply a value for " - ); - } - - - - - - - - - - - - - - - - - - - + /* ---- [ cut here: next file 'junk'] ------------------------- */ - - - - + + + if ( String.IsNullOrEmpty( Form[ "" ])) + { + AddError( + + + + + "You must supply a value for " + + ); + } + + + + + + - - - - "" @@ -585,184 +622,181 @@ namespace { - /// <summary> - /// Handle the submission of the form named - /// </summary> - [AccessibleThrough(Verb.Post)] - public void ( ) { - string command = Form[ "command"]; + /// <summary> + /// Handle the submission of the form named + /// </summary> + [AccessibleThrough(Verb.Post)] + public void ( ) { + string command = Form[ "command"]; - if ( command == null) { - throw new Exception( "No command?"); - } - else - - if ( command.Equals( "")) - { - /* 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], + if ( command == null) { + throw new Exception( "No command?"); + } + else + + if ( command.Equals( "")) + { + /* 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]); - - - - + record = FetchRecord( hibernator); - - PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN]; - - PropertyBag["instance"] = record; + + PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN]; + + PropertyBag["instance"] = record; - RenderViewWithFailover( "maybedelete.vm", "maybedelete.auto.vm"); - } - else if ( command.Equals( "store")) - { - Store(); - } - else - { - throw new Exception( String.Format("Unrecognised command '{0}'", command)); - } - } + RenderViewWithFailover( "maybedelete.vm", "maybedelete.auto.vm"); + } + else if ( command.Equals( "store")) + { + Store(); + } + else + { + throw new Exception( String.Format("Unrecognised command '{0}'", command)); + } + } - /// <summary> - /// Show the form named , with no content - /// </summary> - [AccessibleThrough(Verb.Get)] - public void ( ) - { - AssertUserCanRead(); + /// <summary> + /// Show the form named , with no content + /// </summary> + [AccessibleThrough(Verb.Get)] + public void ( ) + { + AssertUserCanRead(); - ISession hibernator = - NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN], + ISession hibernator = + NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN], Session[NHibernateHelper.PASSTOKEN]); - PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN]; + PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN]; - RenderViewWithFailover("", - ""); - } + RenderViewWithFailover("", + ""); + } - + - /// <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 ( - - - - - - - - - - - - - - - , - ) { - ISession hibernator = - NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN], + /// <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 ( + + + + + + + + + + + + + + + , + ) { + ISession hibernator = + NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN], Session[NHibernateHelper.PASSTOKEN]); - this.( - - - - hibernator.CreateCriteria(typeof()) - .Add( Expression.Eq( "", )) - .UniqueResult<>() - - - - - - , - ); - } + this.( + + + + hibernator.CreateCriteria(typeof()) + .Add( Expression.Eq( "", )) + .UniqueResult<>() + + + + + + , + ); + } - /// <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 ( - - - - - , - ) - { - ISession hibernator = - NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN], + /// <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 ( + + + + + , + ) + { + ISession hibernator = + NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN], Session[NHibernateHelper.PASSTOKEN]); - record = - hibernator.CreateCriteria(typeof()) - - .Add(Expression.Eq("", )) - - .UniqueResult<>(); + record = + hibernator.CreateCriteria(typeof()) + + .Add(Expression.Eq("", )) + + .UniqueResult<>(); - - PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN]; - - PropertyBag["instance"] = record; + + PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN]; + + PropertyBag["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( ""); - } + /// <summary> + /// list all instances of this entity to allow the user to select one + /// this method invokes the named view. + /// </summary> + public void () + { + InternalShowList( ""); + } - /* */ + /* */ - + - - Int32.Parse( Form[""]) - - - Form[""] - - ))) + Int32.Parse( Form[""]) + Form[""] + ))); - .List<>(); + } - if ( matches.Count > 0) + if ( matchCriteria.List<>().Count > 0) { - throw new - DataNotDistinctException( - 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[""])); } @@ -838,212 +871,159 @@ namespace { - - - - - - - - - - - - - - /* 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 multi-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 multi-select for */ + + + + + + + + + + + + - + /* 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. */ - - - - - - - - - - /* 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 LHS of the shuffle for */ + + + + + + /* produce a list of to populate the multi-select for */ + + + + - - - + + + - - - PropertyBag[""] = - ( NHibernateHelper.GetCurrentSession()); + + + PropertyBag[""] = + ( NHibernateHelper.GetCurrentSession()); - - - - - ADL: ERROR: No entity passed to template primary-key-csharp-type - - - - - ADL: WARNING: entity '' has no primary key. - You will have to manually edit - - - - - - - - - - - - - - ADL: ERROR: No key for entity: - - - - - - ADL: WARNING: Entity has a composite primary key. - You will need to manually edit - - - - - - - - - ADL: WARNING: Entity has no primary key. - You will need to manually edit - - - - - - - - - - - - - ADL: ERROR: property passed to fetch-property-instance whose type is not 'entity' - - - hibernator.CreateCriteria(typeof()) - - .Add(Expression.Eq("", - - - - - - Int32.Parse( Form[""]) - Form[""] - )) - - .UniqueResult<>() - - - - - - - /* check whether values for all key slots have been passed in; if so, we're probably dealing with an - * existing record */ - - /* the instance (record) of type we're dealing with */ - record = null; - /* whether we have valid values for all the key fields */ - bool allkeys = true; + + + + + ADL: ERROR: No entity passed to template primary-key-csharp-type + - - if ( String.IsNullOrEmpty( Form[""])) { - allkeys = false; - } - else if ( "".Equals( Form[""])) { - /* nasty artefact of NVelocity forms - default 'null value' is dollar followed by fieldname */ - allkeys = false; - } - + + + ADL: WARNING: entity '' has no primary key. + You will have to manually edit + + + + + + + - if ( allkeys){ - /* it's (probably) existing, retrieve it */ - record = hibernator.CreateCriteria(typeof()) - - - - - - - .Add( Expression.Eq( "", - Int32.Parse( Form[ ""]) - - - - - - - - - hibernator.CreateCriteria( typeof( )) - .Add(Expression.Eq( "", - Int32.Parse( Form[ ""]) - Form[ ""])) - .UniqueResult<>() - Form[ ""])) - - .UniqueResult<>(); - } - - \ No newline at end of file + + + + + + ADL: ERROR: No key for entity: + + + + + + ADL: WARNING: Entity has a composite primary key. + You will need to manually edit + + + + + + + + + ADL: WARNING: Entity has no primary key. + You will need to manually edit + + + + + + + + + + + + + ADL: ERROR: property passed to fetch-property-instance whose type is not 'entity' + + + hibernator.CreateCriteria(typeof()) + + .Add(Expression.Eq("", + + + + + + + + Int32.Parse( Form[""]) + Form[""] + )) + + .UniqueResult<>() + + + \ No newline at end of file diff --git a/transforms01/adl2entityclass.xslt b/transforms01/adl2entityclass.xslt index b7fc83a..c3fe25a 100755 --- a/transforms01/adl2entityclass.xslt +++ b/transforms01/adl2entityclass.xslt @@ -8,8 +8,8 @@ Transform ADL into entity classes $Author: sb $ - $Revision: 1.12 $ - $Date: 2008-03-12 13:46:10 $ + $Revision: 1.13 $ + $Date: 2008-05-09 16:12:12 $ --> + select="substring( '$Revision: 1.13 $', 11)"/> @@ -220,8 +220,8 @@ get { StringBuilder result = new StringBuilder(); - - + + if ( != null) diff --git a/transforms01/adl2views.xslt b/transforms01/adl2views.xslt index 77c5d68..02de96c 100755 --- a/transforms01/adl2views.xslt +++ b/transforms01/adl2views.xslt @@ -12,26 +12,32 @@ Transform ADL into velocity view templates $Author: sb $ - $Revision: 1.15 $ - $Date: 2008-04-18 10:06:47 $ + $Revision: 1.16 $ + $Date: 2008-05-09 16:12:12 $ --> - + - - + + - - + - - + + + + + + + - + + - + + @@ -71,7 +82,7 @@ + I'm not responsible for the html, the head, or for the body tag --> @@ -93,55 +104,58 @@ Auto generated Velocity maybe-delete form for , generated from ADL. - Generated using adl2views.xslt + Generated using adl2views.xslt - - - - - - - - [none] - - + + + + + + + + [none] + + - - - - - [ cut here: next file '' ] - - - - #set( $title = " $instance.UserIdentifier") - - $!title - - - Auto generated Velocity maybe-delete form for , - generated from ADL. + + + + + + [ cut here: next file '' ] + + + + + #set( $title = " $instance.UserIdentifier") + + $!title + + + Auto generated Velocity maybe-delete form for , + generated from ADL. - Generated using adl2views.xslt - - - - - - - - - - - - + Generated using adl2views.xslt + + + + + + + + + + + + - +
@@ -213,7 +227,7 @@ Auto generated Velocity form for , generated from ADL. - Generated using adl2views.xslt + Generated using adl2views.xslt #capturefor( title) #if ( $instance) @@ -223,6 +237,7 @@ #end #end #capturefor( headextras) +