Added before- and after- update hooks when saving auxiliary records

This commit is contained in:
sb 2009-04-17 13:11:04 +00:00
parent 5b49d6a280
commit 6e995bfc5c
2 changed files with 36 additions and 22 deletions

View file

@ -9,8 +9,8 @@
Transform ADL into (partial) controller classes
$Author: sb $
$Revision: 1.32 $
$Date: 2009-04-17 09:43:27 $
$Revision: 1.33 $
$Date: 2009-04-17 13:11:04 $
-->
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
@ -70,7 +70,7 @@
//
// Automatically generated abstract super class for controllers for the
// <xsl:value-of select="/adl:application/@name"/> application; generated using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.32 $', 10)"/>
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.33 $', 10)"/>
//
// <xsl:value-of select="/adl:application/@revision"/>
//
@ -180,7 +180,7 @@
//
// Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s
// Automatically generated from application description using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.32 $', 10)"/>
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.33 $', 10)"/>
//
// This file is automatically generated; DO NOT EDIT IT.
//
@ -277,12 +277,18 @@
foreach ( <xsl:value-of select="concat($entityns, '.', @name)"/> instance in instances) {
<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 ){
<xsl:value-of select="concat( 'instance.', @name)"/> = new Message();
hibernator.SaveOrUpdate( <xsl:value-of select="concat( 'instance.', @name)"/>);
}
</xsl:for-each>
<xsl:variable name="slot" select="concat( 'instance.', @name)"/>
if ( <xsl:value-of select="$slot"/> == null || <xsl:value-of select="concat( $slot, '.MessageId')"/> == 0 ){
<xsl:value-of select="$slot"/> = new Message();
<xsl:value-of select="$slot"/>.BeforeUpdateHook( hibernator);
hibernator.SaveOrUpdate( <xsl:value-of select="$slot"/>);
<xsl:value-of select="$slot"/>.AfterUpdateHook( hibernator);
}
</xsl:for-each>
instance.BeforeUpdateHook( hibernator);
hibernator.SaveOrUpdate( instance);
instance.AfterUpdateHook( hibernator);
}
hibernator.Flush();
<xsl:if test="adl:list[@name='list']">
@ -412,7 +418,9 @@
if ( mess == null) {
mess = new Message();
}
mess.BeforeUpdateHook( hibernator);
hibernator.SaveOrUpdate( mess);
mess.AfterUpdateHook( hibernator);
Translation trans = mess.GetTranslationObject( locale, hibernator);
if ( trans == null) {
@ -420,9 +428,11 @@
}
trans.MessageText = Form["<xsl:value-of select="concat( 'instance.', @name)"/>"];
record.<xsl:value-of select="@name"/> = mess;
hibernator.SaveOrUpdate( trans);
}
</xsl:for-each>
trans.BeforeUpdateHook( hibernator);
hibernator.SaveOrUpdate( trans);
trans.AfterUpdateHook( hibernator);
}
</xsl:for-each>
</xsl:if>
<xsl:for-each select="descendant::adl:property[@type='entity']">
/* for properties of type 'entity', it should not be necessary to do anything
@ -586,13 +596,17 @@
<xsl:value-of select="concat( 'item.', $foreignkey)"/>;
if ( oldparent != null) {
oldparent.<xsl:value-of select="@name"/>.Remove( item);
oldparent.BeforeUpdateHook( hibernator);
hibernator.SaveOrUpdate( oldparent);
oldparent.AfterUpdateHook( hibernator);
}
/* then add it to my <xsl:value-of select="@name"/> */
record.<xsl:value-of select="@name"/>.Add( item);
<xsl:value-of select="concat( 'item.', $foreignkey)"/> = record;
item.BeforeUpdateHook( hibernator);
hibernator.SaveOrUpdate( item);
item.AfterUpdateHook( hibernator);
}
} /* foreach ( string index... */
} /* if ( Form.GetValues( "<xsl:value-of select="concat( 'instance.', @name)"/>") != null) */