* FR [ 1675490 ] ModelValidator on modelChange after events
This commit is contained in:
parent
4f1d27f4b4
commit
cbe2450316
|
@ -28,14 +28,20 @@ package org.compiere.model;
|
||||||
public interface ModelValidator
|
public interface ModelValidator
|
||||||
{
|
{
|
||||||
/** Model Change Type New */
|
/** Model Change Type New */
|
||||||
|
public static final int TYPE_BEFORE_NEW = 1; // teo_sarca [ 1675490 ]
|
||||||
public static final int TYPE_NEW = 1;
|
public static final int TYPE_NEW = 1;
|
||||||
public static final int CHANGETYPE_NEW = 1;
|
public static final int CHANGETYPE_NEW = 1; // Compatibility with Compiere 260c
|
||||||
|
public static final int TYPE_AFTER_NEW = 4; // teo_sarca [ 1675490 ]
|
||||||
/** Model Change Type Change */
|
/** Model Change Type Change */
|
||||||
|
public static final int TYPE_BEFORE_CHANGE = 2; // teo_sarca [ 1675490 ]
|
||||||
public static final int TYPE_CHANGE = 2;
|
public static final int TYPE_CHANGE = 2;
|
||||||
public static final int CHANGETYPE_CHANGE = 2;
|
public static final int CHANGETYPE_CHANGE = 2; // Compatibility with Compiere 260c
|
||||||
|
public static final int TYPE_AFTER_CHANGE = 5; // teo_sarca [ 1675490 ]
|
||||||
/** Model Change Type Delete */
|
/** Model Change Type Delete */
|
||||||
|
public static final int TYPE_BEFORE_DELETE = 3; // teo_sarca [ 1675490 ]
|
||||||
public static final int TYPE_DELETE = 3;
|
public static final int TYPE_DELETE = 3;
|
||||||
public static final int CHANGETYPE_DELETE = 3;
|
public static final int CHANGETYPE_DELETE = 3; // Compatibility with Compiere 260c
|
||||||
|
public static final int TYPE_AFTER_DELETE = 6; // teo_sarca [ 1675490 ]
|
||||||
|
|
||||||
/** Called before document is prepared */
|
/** Called before document is prepared */
|
||||||
public static final int TIMING_BEFORE_PREPARE = 1;
|
public static final int TIMING_BEFORE_PREPARE = 1;
|
||||||
|
|
|
@ -1790,6 +1790,7 @@ public abstract class PO
|
||||||
// throw new DBException(e);
|
// throw new DBException(e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Call ModelValidators TYPE_NEW/TYPE_CHANGE
|
||||||
String errorMsg = ModelValidationEngine.get().fireModelChange
|
String errorMsg = ModelValidationEngine.get().fireModelChange
|
||||||
(this, newRecord ? ModelValidator.TYPE_NEW : ModelValidator.TYPE_CHANGE);
|
(this, newRecord ? ModelValidator.TYPE_NEW : ModelValidator.TYPE_CHANGE);
|
||||||
if (errorMsg != null)
|
if (errorMsg != null)
|
||||||
|
@ -1834,6 +1835,15 @@ public abstract class PO
|
||||||
success = false;
|
success = false;
|
||||||
// throw new DBException(e);
|
// throw new DBException(e);
|
||||||
}
|
}
|
||||||
|
// Call ModelValidators TYPE_AFTER_NEW/TYPE_AFTER_CHANGE - teo_sarca [ 1675490 ]
|
||||||
|
if (success) {
|
||||||
|
String errorMsg = ModelValidationEngine.get().fireModelChange
|
||||||
|
(this, newRecord ? ModelValidator.TYPE_AFTER_NEW : ModelValidator.TYPE_AFTER_CHANGE);
|
||||||
|
if (errorMsg != null) {
|
||||||
|
log.saveError("Error", errorMsg);
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
// OK
|
// OK
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
|
@ -2443,7 +2453,7 @@ public abstract class PO
|
||||||
log.saveError("CannotDelete", errorMsg);
|
log.saveError("CannotDelete", errorMsg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//
|
// Call ModelValidators TYPE_DELETE
|
||||||
errorMsg = ModelValidationEngine.get().fireModelChange
|
errorMsg = ModelValidationEngine.get().fireModelChange
|
||||||
(this, ModelValidator.TYPE_DELETE);
|
(this, ModelValidator.TYPE_DELETE);
|
||||||
if (errorMsg != null)
|
if (errorMsg != null)
|
||||||
|
@ -2543,6 +2553,14 @@ public abstract class PO
|
||||||
// throw new DBException(e);
|
// throw new DBException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Call ModelValidators TYPE_AFTER_DELETE - teo_sarca [ 1675490 ]
|
||||||
|
if (success) {
|
||||||
|
errorMsg = ModelValidationEngine.get().fireModelChange(this, ModelValidator.TYPE_AFTER_DELETE);
|
||||||
|
if (errorMsg != null) {
|
||||||
|
log.saveError("Error", errorMsg);
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Reset
|
// Reset
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue