IDEMPIERE-994 Model afterSave and afterDelete must check success flag when doing DB work / based on patch from Carlos Sanchez

This commit is contained in:
Carlos Ruiz 2013-06-14 13:09:51 -05:00
parent ce111cb754
commit 3c9696db4b
38 changed files with 167 additions and 99 deletions

View File

@ -470,6 +470,8 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element
@Override
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
// Default Value
if (isMandatory() && is_ValueChanged(COLUMNNAME_IsMandatory))
{
@ -535,6 +537,8 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element
@Override
protected boolean afterDelete (boolean success)
{
if (!success)
return success;
// Update Account Info
StringBuilder msguvd = new StringBuilder("AD_Client_ID=").append(getAD_Client_ID());
MAccount.updateValueDescription(getCtx(),msguvd.toString(), get_TrxName());

View File

@ -41,7 +41,8 @@ public class MAssetUse extends X_A_Asset_Use
protected boolean afterSave (boolean newRecord,boolean success)
{
log.info ("afterSave");
if (!success)
return success;
int p_A_Asset_ID = 0;
int total_unitsused = 0;
p_A_Asset_ID = getA_Asset_ID();
@ -64,7 +65,7 @@ protected boolean afterSave (boolean newRecord,boolean success)
change.setUseUnits(getUseUnits());
change.saveEx();
return true;
return success;
} // afterSave

View File

@ -241,6 +241,8 @@ public class MAttribute extends X_M_Attribute
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
// Changed to Instance Attribute
if (!newRecord && is_ValueChanged("IsInstanceAttribute") && isInstanceAttribute())
{

View File

@ -397,6 +397,8 @@ public class MAttributeSet extends X_M_AttributeSet
protected boolean afterSave (boolean newRecord, boolean success)
{
// Set Instance Attribute
if (!success)
return success;
if (!isInstanceAttribute())
{
StringBuilder sql = new StringBuilder("UPDATE M_AttributeSet mas")

View File

@ -191,12 +191,14 @@ public class MClientShare extends X_AD_ClientShare
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
if (isActive())
{
setDataToLevel();
listChildRecords();
}
return true;
return success;
} // afterSave
/**

View File

@ -345,6 +345,8 @@ public class MColumn extends X_AD_Column
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
// Update Fields
if (!newRecord)
{

View File

@ -139,6 +139,8 @@ public class MCommissionAmt extends X_C_CommissionAmt
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
if (!newRecord)
updateRunHeader();
return success;

View File

@ -115,6 +115,8 @@ public class MCommissionDetail extends X_C_CommissionDetail
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
if (!newRecord)
updateAmtHeader();
return success;

View File

@ -49,7 +49,7 @@ public class MCostDetail extends X_M_CostDetail
/**
*
*/
private static final long serialVersionUID = -7882724307127281675L;
private static final long serialVersionUID = -448632684360931078L;
/**
* Create New Order Cost Detail for Purchase Orders.
@ -686,19 +686,7 @@ public class MCostDetail extends X_M_CostDetail
return !(getDeltaAmt().signum() == 0
&& getDeltaQty().signum() == 0);
} // isDelta
/**
* After Save
* @param newRecord new
* @param success success
* @return true
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
return true;
} // afterSave
/**
* Before Delete
* @return false if processed

View File

@ -152,6 +152,8 @@ import org.compiere.util.Env;
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
updateHeader();
return success;
} // afterSave
@ -163,6 +165,8 @@ import org.compiere.util.Env;
*/
protected boolean afterDelete (boolean success)
{
if (!success)
return success;
updateHeader();
if (getC_Payment_ID() != 0 )
{

View File

@ -270,6 +270,8 @@ public class MDistributionLine extends X_GL_DistributionLine
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
getParent();
m_parent.validate();
m_parent.saveEx();

View File

@ -317,7 +317,9 @@ public class MDunningRunLine extends X_C_DunningRunLine
* @return success
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
{
if (!success)
return success;
updateEntry();
return success;
} // afterSave
@ -328,7 +330,9 @@ public class MDunningRunLine extends X_C_DunningRunLine
* @return success
*/
protected boolean afterDelete (boolean success)
{
{
if (!success)
return success;
updateEntry();
return success;
} // afterDelete

View File

@ -244,6 +244,8 @@ public class MElementValue extends X_C_ElementValue
@Override
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
if (newRecord)
{
// afalcone [Bugs #1837219]

View File

@ -66,6 +66,8 @@ public class MForm extends X_AD_Form
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
if (newRecord)
{
int AD_Role_ID = Env.getAD_Role_ID(getCtx());

View File

@ -130,6 +130,8 @@ public class MInfoWindow extends X_AD_InfoWindow
@Override
protected boolean afterSave(boolean newRecord, boolean success) {
if (!success)
return success;
if (newRecord) // Add to all automatic roles
{
MRole[] roles = MRole.getOf(getCtx(), "IsManual='N'");

View File

@ -39,7 +39,7 @@ public class MInventoryLine extends X_M_InventoryLine
/**
*
*/
private static final long serialVersionUID = -3513145563716006099L;
private static final long serialVersionUID = -3864175464877913555L;
/**
* Get Inventory Line with parameters
@ -365,17 +365,17 @@ public class MInventoryLine extends X_M_InventoryLine
* @param success success
* @return true
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return false;
// Create MA
//if (newRecord && success
// && m_isManualEntry && getM_AttributeSetInstance_ID() == 0)
// createMA();
return true;
} // afterSave
//protected boolean afterSave (boolean newRecord, boolean success)
//{
// if (!success)
// return false;
//
// // Create MA
// //if (newRecord && success
// // && m_isManualEntry && getM_AttributeSetInstance_ID() == 0)
// // createMA();
// return true;
//} // afterSave
/**
* Create Material Allocations for new Instances

View File

@ -227,6 +227,8 @@ public class MInvoicePaySchedule extends X_C_InvoicePaySchedule
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
if (is_ValueChanged("DueAmt"))
{
log.fine("afterSave");

View File

@ -318,6 +318,8 @@ public class MLanguage extends X_AD_Language
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
int no = TranslationTable.getActiveLanguages(true);
if (log.isLoggable(Level.FINE)) log.fine("Active Languages=" + no);
return true;

View File

@ -675,6 +675,8 @@ public class MLocation extends X_C_Location implements Comparator<Object>
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
// Value/Name change in Account
if (!newRecord
&& ("Y".equals(Env.getContext(getCtx(), "$Element_LF"))

View File

@ -143,6 +143,8 @@ public class MMenu extends X_AD_Menu
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
if (newRecord)
insert_Tree(MTree_Base.TREETYPE_Menu);
return success;

View File

@ -227,6 +227,8 @@ public class MOrderPaySchedule extends X_C_OrderPaySchedule
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
if (is_ValueChanged("DueAmt"))
{
log.fine("afterSave");

View File

@ -289,6 +289,8 @@ public class MPInstance extends X_AD_PInstance
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
// Update Statistics
if (!newRecord
&& !isProcessing()

View File

@ -110,6 +110,8 @@ public class MPaySchedule extends X_C_PaySchedule
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
if (newRecord || is_ValueChanged("Percentage") || is_ValueChanged("IsActive"))
{
log.fine("afterSave");

View File

@ -137,7 +137,9 @@ public class MPaySelectionLine extends X_C_PaySelectionLine
* @return success
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
{
if (!success)
return success;
setHeader();
return success;
} // afterSave
@ -148,7 +150,9 @@ public class MPaySelectionLine extends X_C_PaySelectionLine
* @return sucess
*/
protected boolean afterDelete (boolean success)
{
{
if (!success)
return success;
setHeader();
return success;
} // afterDelete

View File

@ -613,6 +613,8 @@ public class MPeriod extends X_C_Period
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
if (newRecord)
{
// SELECT Value FROM AD_Ref_List WHERE AD_Reference_ID=183

View File

@ -358,6 +358,8 @@ public class MProcess extends X_AD_Process
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
if (newRecord) // Add to all automatic roles
{
MRole[] roles = MRole.getOf(getCtx(), "IsManual='N'");

View File

@ -157,6 +157,8 @@ public class MProductBOM extends X_M_Product_BOM
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
// Product Line was changed
if (newRecord || is_ValueChanged("M_ProductBOM_ID"))
{

View File

@ -105,6 +105,8 @@ public class MProductCategoryAcct extends X_M_Product_Category_Acct
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
checkCosting();
return success;
} // afterSave

View File

@ -240,6 +240,8 @@ public class MProjectLine extends X_C_ProjectLine
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
updateHeader();
return success;
} // afterSave
@ -252,6 +254,8 @@ public class MProjectLine extends X_C_ProjectLine
*/
protected boolean afterDelete (boolean success)
{
if (!success)
return success;
updateHeader();
return success;
} // afterDelete

View File

@ -34,7 +34,7 @@ public class MResourceAssignment extends X_S_ResourceAssignment
/**
*
*/
private static final long serialVersionUID = 3024759545660161137L;
private static final long serialVersionUID = 4230793339153210998L;
/**
* Stnadard Constructor
@ -72,37 +72,39 @@ public class MResourceAssignment extends X_S_ResourceAssignment
* @param success success
* @return true
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
/*
v_Description := :new.Name;
IF (:new.Description IS NOT NULL AND LENGTH(:new.Description) > 0) THEN
v_Description := v_Description || ' (' || :new.Description || ')';
END IF;
-- Update Expense Line
UPDATE S_TimeExpenseLine
SET Description = v_Description,
Qty = :new.Qty
WHERE S_ResourceAssignment_ID = :new.S_ResourceAssignment_ID
AND (Description <> v_Description OR Qty <> :new.Qty);
-- Update Order Line
UPDATE C_OrderLine
SET Description = v_Description,
QtyOrdered = :new.Qty
WHERE S_ResourceAssignment_ID = :new.S_ResourceAssignment_ID
AND (Description <> v_Description OR QtyOrdered <> :new.Qty);
-- Update Invoice Line
UPDATE C_InvoiceLine
SET Description = v_Description,
QtyInvoiced = :new.Qty
WHERE S_ResourceAssignment_ID = :new.S_ResourceAssignment_ID
AND (Description <> v_Description OR QtyInvoiced <> :new.Qty);
*/
return success;
} // afterSave
// protected boolean afterSave (boolean newRecord, boolean success)
// {
// /*
// if (!success)
// return success;
// v_Description := :new.Name;
// IF (:new.Description IS NOT NULL AND LENGTH(:new.Description) > 0) THEN
// v_Description := v_Description || ' (' || :new.Description || ')';
// END IF;
//
// -- Update Expense Line
// UPDATE S_TimeExpenseLine
// SET Description = v_Description,
// Qty = :new.Qty
// WHERE S_ResourceAssignment_ID = :new.S_ResourceAssignment_ID
// AND (Description <> v_Description OR Qty <> :new.Qty);
//
// -- Update Order Line
// UPDATE C_OrderLine
// SET Description = v_Description,
// QtyOrdered = :new.Qty
// WHERE S_ResourceAssignment_ID = :new.S_ResourceAssignment_ID
// AND (Description <> v_Description OR QtyOrdered <> :new.Qty);
//
// -- Update Invoice Line
// UPDATE C_InvoiceLine
// SET Description = v_Description,
// QtyInvoiced = :new.Qty
// WHERE S_ResourceAssignment_ID = :new.S_ResourceAssignment_ID
// AND (Description <> v_Description OR QtyInvoiced <> :new.Qty);
// */
// return success;
// } // afterSave
/**
* String Representation

View File

@ -32,8 +32,7 @@ public class MRevenueRecognitionPlan extends X_C_RevenueRecognition_Plan
/**
*
*/
private static final long serialVersionUID = -6748195415080148091L;
private static final long serialVersionUID = -8437258098744762898L;
/**
* Standard Constructor
@ -74,33 +73,35 @@ public class MRevenueRecognitionPlan extends X_C_RevenueRecognition_Plan
* @param success success
* @return success
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (newRecord)
{
MRevenueRecognition rr = new MRevenueRecognition(getCtx(), getC_RevenueRecognition_ID(), get_TrxName());
if (rr.isTimeBased())
{
/** Get InvoiveQty
SELECT QtyInvoiced, M_Product_ID
INTO v_Qty, v_M_Product_ID
FROM C_InvoiceLine
WHERE C_InvoiceLine_ID=:new.C_InvoiceLine_ID;
-- Insert
AD_Sequence_Next ('C_ServiceLevel', :new.AD_Client_ID, v_NextNo);
INSERT INTO C_ServiceLevel
(C_ServiceLevel_ID, C_RevenueRecognition_Plan_ID,
AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,
M_Product_ID, Description, ServiceLevelInvoiced, ServiceLevelProvided,
Processing,Processed)
VALUES
(v_NextNo, :new.C_RevenueRecognition_Plan_ID,
:new.AD_Client_ID,:new.AD_Org_ID,'Y',SysDate,:new.CreatedBy,SysDate,:new.UpdatedBy,
v_M_Product_ID, NULL, v_Qty, 0,
'N', 'N');
**/
}
}
return success;
} // afterSave
// protected boolean afterSave (boolean newRecord, boolean success)
// {
// if (!success)
// return success;
// if (newRecord)
// {
// MRevenueRecognition rr = new MRevenueRecognition(getCtx(), getC_RevenueRecognition_ID(), get_TrxName());
// if (rr.isTimeBased())
// {
// /** Get InvoiveQty
// SELECT QtyInvoiced, M_Product_ID
// INTO v_Qty, v_M_Product_ID
// FROM C_InvoiceLine
// WHERE C_InvoiceLine_ID=:new.C_InvoiceLine_ID;
// -- Insert
// AD_Sequence_Next ('C_ServiceLevel', :new.AD_Client_ID, v_NextNo);
// INSERT INTO C_ServiceLevel
// (C_ServiceLevel_ID, C_RevenueRecognition_Plan_ID,
// AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,
// M_Product_ID, Description, ServiceLevelInvoiced, ServiceLevelProvided,
// Processing,Processed)
// VALUES
// (v_NextNo, :new.C_RevenueRecognition_Plan_ID,
// :new.AD_Client_ID,:new.AD_Org_ID,'Y',SysDate,:new.CreatedBy,SysDate,:new.UpdatedBy,
// v_M_Product_ID, NULL, v_Qty, 0,
// 'N', 'N');
// **/
// }
// }
// return success;
// } // afterSave
} // MRevenueRecognitionPlan

View File

@ -204,7 +204,9 @@ public class MRfQResponseLine extends X_C_RfQResponseLine
* @return success
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
{
if (!success)
return success;
if (!isActive())
{
getQtys (false);

View File

@ -362,7 +362,9 @@ public final class MRole extends X_AD_Role
* @return success
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
{
if (!success)
return success;
if (newRecord && success)
{
// Add Role to SuperUser

View File

@ -510,6 +510,8 @@ public class MTable extends X_AD_Table
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
// Sync Table ID
MSequence seq = MSequence.get(getCtx(), getTableName(), get_TrxName());
if (seq == null || seq.get_ID() == 0)

View File

@ -153,6 +153,8 @@ public class MTask extends X_AD_Task
protected boolean afterSave (boolean newRecord, boolean success)
{
if (log.isLoggable(Level.FINE)) log.fine("Success=" + success);
if (!success)
return success;
if (! newRecord)
{
// Menu/Workflow

View File

@ -353,6 +353,8 @@ public class MTree_Base extends X_AD_Tree
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
if (newRecord) // Base Node
{
if (TREETYPE_BPartner.equals(getTreeType()))

View File

@ -118,6 +118,8 @@ public class MWindow extends X_AD_Window
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
if (newRecord) // Add to all automatic roles
{
MRole[] roles = MRole.getOf(getCtx(), "IsManual='N'");

View File

@ -207,7 +207,9 @@ public class M_Element extends X_AD_Element
* @return success
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
{
if (!success)
return success;
// Update Columns, Fields, Parameters, Print Info
if (!newRecord)
{