bug 2792 : Reinstated the calls to the deprecated Before- and AfterUpdateHooks, and also to the deprecated BeforeDeletionHook. I am not entirely happy with this solution, which looks ugly.
Note that currently the Before- and AfterUpdateHooks are only called (in the auto-generated controller) for the principal record of a form, and not for any auxiliary records. It's possible that the hooks should also be called for these. This isn't really satisfactory - it makes for ugly and prolix code - and a better solution is desirable. More thought needed.
This commit is contained in:
parent
124a10b8cc
commit
1376b2db36
|
@ -9,8 +9,8 @@
|
||||||
Transform ADL into (partial) controller classes
|
Transform ADL into (partial) controller classes
|
||||||
|
|
||||||
$Author: sb $
|
$Author: sb $
|
||||||
$Revision: 1.30 $
|
$Revision: 1.31 $
|
||||||
$Date: 2009-03-25 11:52:51 $
|
$Date: 2009-04-17 09:38:46 $
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
|
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
<xsl:param name="entityns" select="Unset"/>
|
<xsl:param name="entityns" select="Unset"/>
|
||||||
<!-- Whether to authenticate at application or at database layer.
|
<!-- Whether to authenticate at application or at database layer.
|
||||||
If not 'Application', then 'Database'. -->
|
If not 'Application', then 'Database'. -->
|
||||||
<xsl:param name="authentication-layer" select="'Application'"/>
|
<xsl:param name="authentication-layer" select="Application"/>
|
||||||
|
|
||||||
<!-- the name and version of the product being built -->
|
<!-- the name and version of the product being built -->
|
||||||
<xsl:param name="product-version" select="'Application Description Language Framework'"/>
|
<xsl:param name="product-version" select="'Application Description Language Framework'"/>
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
//
|
//
|
||||||
// Automatically generated abstract super class for controllers for the
|
// Automatically generated abstract super class for controllers for the
|
||||||
// <xsl:value-of select="/adl:application/@name"/> application; generated using
|
// <xsl:value-of select="/adl:application/@name"/> application; generated using
|
||||||
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.30 $', 10)"/>
|
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.31 $', 10)"/>
|
||||||
//
|
//
|
||||||
// <xsl:value-of select="/adl:application/@revision"/>
|
// <xsl:value-of select="/adl:application/@revision"/>
|
||||||
//
|
//
|
||||||
|
@ -180,7 +180,7 @@
|
||||||
//
|
//
|
||||||
// Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s
|
// Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s
|
||||||
// Automatically generated from application description using
|
// Automatically generated from application description using
|
||||||
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.30 $', 10)"/>
|
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.31 $', 10)"/>
|
||||||
//
|
//
|
||||||
// This file is automatically generated; DO NOT EDIT IT.
|
// This file is automatically generated; DO NOT EDIT IT.
|
||||||
//
|
//
|
||||||
|
@ -279,10 +279,10 @@
|
||||||
<xsl:for-each select="adl:property[@type='message']">
|
<xsl:for-each select="adl:property[@type='message']">
|
||||||
if ( <xsl:value-of select="concat( 'instance.', @name)"/> == null || <xsl:value-of select="concat( 'instance.', @name, '.MessageId')"/> == 0 ){
|
if ( <xsl:value-of select="concat( 'instance.', @name)"/> == null || <xsl:value-of select="concat( 'instance.', @name, '.MessageId')"/> == 0 ){
|
||||||
<xsl:value-of select="concat( 'instance.', @name)"/> = new Message();
|
<xsl:value-of select="concat( 'instance.', @name)"/> = new Message();
|
||||||
hibernator.Save( <xsl:value-of select="concat( 'instance.', @name)"/>);
|
hibernator.SaveOrUpdate( <xsl:value-of select="concat( 'instance.', @name)"/>);
|
||||||
}
|
}
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
hibernator.Save( instance);
|
hibernator.SaveOrUpdate( instance);
|
||||||
}
|
}
|
||||||
hibernator.Flush();
|
hibernator.Flush();
|
||||||
<xsl:if test="adl:list[@name='list']">
|
<xsl:if test="adl:list[@name='list']">
|
||||||
|
@ -412,7 +412,7 @@
|
||||||
if ( mess == null) {
|
if ( mess == null) {
|
||||||
mess = new Message();
|
mess = new Message();
|
||||||
}
|
}
|
||||||
hibernator.Save( mess);
|
hibernator.SaveOrUpdate( mess);
|
||||||
|
|
||||||
Translation trans = mess.GetTranslationObject( locale, hibernator);
|
Translation trans = mess.GetTranslationObject( locale, hibernator);
|
||||||
if ( trans == null) {
|
if ( trans == null) {
|
||||||
|
@ -420,7 +420,7 @@
|
||||||
}
|
}
|
||||||
trans.MessageText = Form["<xsl:value-of select="concat( 'instance.', @name)"/>"];
|
trans.MessageText = Form["<xsl:value-of select="concat( 'instance.', @name)"/>"];
|
||||||
record.<xsl:value-of select="@name"/> = mess;
|
record.<xsl:value-of select="@name"/> = mess;
|
||||||
hibernator.Save( trans);
|
hibernator.SaveOrUpdate( trans);
|
||||||
}
|
}
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
|
@ -586,13 +586,13 @@
|
||||||
<xsl:value-of select="concat( 'item.', $foreignkey)"/>;
|
<xsl:value-of select="concat( 'item.', $foreignkey)"/>;
|
||||||
if ( oldparent != null) {
|
if ( oldparent != null) {
|
||||||
oldparent.<xsl:value-of select="@name"/>.Remove( item);
|
oldparent.<xsl:value-of select="@name"/>.Remove( item);
|
||||||
hibernator.Save( oldparent);
|
hibernator.SaveOrUpdate( oldparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* then add it to my <xsl:value-of select="@name"/> */
|
/* then add it to my <xsl:value-of select="@name"/> */
|
||||||
record.<xsl:value-of select="@name"/>.Add( item);
|
record.<xsl:value-of select="@name"/>.Add( item);
|
||||||
<xsl:value-of select="concat( 'item.', $foreignkey)"/> = record;
|
<xsl:value-of select="concat( 'item.', $foreignkey)"/> = record;
|
||||||
hibernator.Save( item);
|
hibernator.SaveOrUpdate( item);
|
||||||
}
|
}
|
||||||
} /* foreach ( string index... */
|
} /* foreach ( string index... */
|
||||||
} /* if ( Form.GetValues( "<xsl:value-of select="concat( 'instance.', @name)"/>") != null) */
|
} /* if ( Form.GetValues( "<xsl:value-of select="concat( 'instance.', @name)"/>") != null) */
|
||||||
|
@ -602,12 +602,17 @@
|
||||||
|
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
|
|
||||||
/* write the record to the database, in order to guarantee we have a valid key */
|
/* write the record to the database, in order to guarantee we have a valid key */
|
||||||
hibernator.Save(record);
|
/* 20090416 we have a significant problem in that the ILifecycle interface is not
|
||||||
hibernator.Flush();
|
doing what we expect - or, at least, not consistently!
|
||||||
tx.Commit();
|
Reinstating the before- and after- update hooks */
|
||||||
|
record.BeforeUpdateHook( hibernator);
|
||||||
|
hibernator.SaveOrUpdate(record);
|
||||||
|
record.AfterUpdateHook( hibernator);
|
||||||
|
|
||||||
messages.Add( "<xsl:call-template name="i18n-record-saved"/>");
|
tx.Commit();
|
||||||
|
|
||||||
|
messages.Add( "<xsl:call-template name="i18n-record-saved"/>");
|
||||||
} /* try actually commit */
|
} /* try actually commit */
|
||||||
catch ( Exception any) {
|
catch ( Exception any) {
|
||||||
messages.Add( "<xsl:call-template name="i18n-record-not-saved"/>");
|
messages.Add( "<xsl:call-template name="i18n-record-not-saved"/>");
|
||||||
|
@ -662,17 +667,18 @@
|
||||||
{
|
{
|
||||||
<xsl:value-of select="concat($entityns, '.', @name)"/> record = FetchRecord( hibernator);
|
<xsl:value-of select="concat($entityns, '.', @name)"/> record = FetchRecord( hibernator);
|
||||||
|
|
||||||
if ( record != null)
|
if ( record != null)
|
||||||
{
|
{
|
||||||
hibernator.Delete( record);
|
record.BeforeDeleteHook( hibernator);
|
||||||
hibernator.Flush();
|
hibernator.Delete( record);
|
||||||
}
|
hibernator.Flush();
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
throw new ApplicationException( "No such record?");
|
{
|
||||||
}
|
throw new ApplicationException( "No such record?");
|
||||||
}
|
}
|
||||||
<xsl:choose>
|
}
|
||||||
|
<xsl:choose>
|
||||||
<xsl:when test="adl:list">
|
<xsl:when test="adl:list">
|
||||||
Redirect( "<xsl:value-of select="concat(adl:list[position()=1]/@name, '.rails')"/>");
|
Redirect( "<xsl:value-of select="concat(adl:list[position()=1]/@name, '.rails')"/>");
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
|
|
Loading…
Reference in a new issue