[ 1955264 ] Changing columns is updating fields needlessly

This commit is contained in:
Carlos Ruiz 2008-07-16 02:50:25 +00:00
parent aa7dfe359b
commit a6345d0702
1 changed files with 74 additions and 53 deletions

View File

@ -273,26 +273,23 @@ public class M_Element extends X_AD_Element
// Update Columns, Fields, Parameters, Print Info
if (!newRecord)
{
StringBuffer sql = new StringBuffer();
int no = 0;
if ( is_ValueChanged(M_Element.COLUMNNAME_Name)
|| is_ValueChanged(M_Element.COLUMNNAME_Description)
|| is_ValueChanged(M_Element.COLUMNNAME_Help)
|| is_ValueChanged(M_Element.COLUMNNAME_ColumnName)
) {
// Column
StringBuffer sql = new StringBuffer("UPDATE AD_Column SET ColumnName=")
sql = new StringBuffer("UPDATE AD_Column SET ColumnName=")
.append(DB.TO_STRING(getColumnName()))
.append(", Name=").append(DB.TO_STRING(getName()))
.append(", Description=").append(DB.TO_STRING(getDescription()))
.append(", Help=").append(DB.TO_STRING(getHelp()))
.append(" WHERE AD_Element_ID=").append(get_ID());
int no = DB.executeUpdate(sql.toString(), get_TrxName());
log.fine("afterSave - Columns updated #" + no);
// Field
sql = new StringBuffer("UPDATE AD_Field SET Name=")
.append(DB.TO_STRING(getName()))
.append(", Description=").append(DB.TO_STRING(getDescription()))
.append(", Help=").append(DB.TO_STRING(getHelp()))
.append(" WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=")
.append(get_ID())
.append(") AND IsCentrallyMaintained='Y'");
no = DB.executeUpdate(sql.toString(), get_TrxName());
log.fine("Fields updated #" + no);
log.fine("afterSave - Columns updated #" + no);
// Parameter
sql = new StringBuffer("UPDATE AD_Process_Para SET ColumnName=")
@ -305,6 +302,7 @@ public class M_Element extends X_AD_Element
.append(DB.TO_STRING(getColumnName().toUpperCase()))
.append(" AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL");
no = DB.executeUpdate(sql.toString(), get_TrxName());
sql = new StringBuffer("UPDATE AD_Process_Para SET ColumnName=")
.append(DB.TO_STRING(getColumnName()))
.append(", Name=").append(DB.TO_STRING(getName()))
@ -314,7 +312,31 @@ public class M_Element extends X_AD_Element
.append(" AND IsCentrallyMaintained='Y'");
no += DB.executeUpdate(sql.toString(), get_TrxName());
log.fine("Parameters updated #" + no);
}
if ( is_ValueChanged(M_Element.COLUMNNAME_Name)
|| is_ValueChanged(M_Element.COLUMNNAME_Description)
|| is_ValueChanged(M_Element.COLUMNNAME_Help)
) {
// Field
sql = new StringBuffer("UPDATE AD_Field SET Name=")
.append(DB.TO_STRING(getName()))
.append(", Description=").append(DB.TO_STRING(getDescription()))
.append(", Help=").append(DB.TO_STRING(getHelp()))
.append(" WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=")
.append(get_ID())
.append(") AND IsCentrallyMaintained='Y'");
no = DB.executeUpdate(sql.toString(), get_TrxName());
log.fine("Fields updated #" + no);
// Info Column - update Name, Description, Help - doesn't have IsCentrallyMaintained currently
// no = DB.executeUpdate(sql.toString(), get_TrxName());
// log.fine("InfoColumn updated #" + no);
}
if ( is_ValueChanged(M_Element.COLUMNNAME_PrintName)
|| is_ValueChanged(M_Element.COLUMNNAME_Name)
) {
// Print Info
sql = new StringBuffer("UPDATE AD_PrintFormatItem pi SET PrintName=")
.append(DB.TO_STRING(getPrintName()))
@ -325,9 +347,8 @@ public class M_Element extends X_AD_Element
.append(get_ID()).append(")");
no = DB.executeUpdate(sql.toString(), get_TrxName());
log.fine("PrintFormatItem updated #" + no);
}
no = DB.executeUpdate(sql.toString(), get_TrxName());
log.fine("InfoWindow updated #" + no);
}
return success;
} // afterSave