* BF [ 1795817 ] Acct Schema Elements "Account" and "Org" should be mandatory
* fix javadoc * use COLUMNNAME_* instead of strings
This commit is contained in:
parent
fd8bd2431d
commit
be8de7826f
|
@ -26,6 +26,9 @@ import org.compiere.util.*;
|
|||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: MAcctSchemaElement.java,v 1.4 2006/08/10 01:00:44 jjanke Exp $
|
||||
*
|
||||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||
* <li>BF [ 1795817 ] Acct Schema Elements "Account" and "Org" should be mandatory
|
||||
*/
|
||||
public final class MAcctSchemaElement extends X_C_AcctSchema_Element
|
||||
{
|
||||
|
@ -78,40 +81,40 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element
|
|||
/**
|
||||
* Get Column Name of ELEMENTTYPE
|
||||
* @param elementType ELEMENTTYPE
|
||||
* @return column name
|
||||
* @return column name or "" if not found
|
||||
*/
|
||||
public static String getColumnName(String elementType)
|
||||
{
|
||||
if (elementType.equals(ELEMENTTYPE_Organization))
|
||||
return "AD_Org_ID";
|
||||
else if (elementType.equals(ELEMENTTYPE_Account))
|
||||
return "Account_ID";
|
||||
return I_C_ValidCombination.COLUMNNAME_Account_ID;
|
||||
else if (elementType.equals(ELEMENTTYPE_BPartner))
|
||||
return "C_BPartner_ID";
|
||||
return I_C_ValidCombination.COLUMNNAME_C_BPartner_ID;
|
||||
else if (elementType.equals(ELEMENTTYPE_Product))
|
||||
return "M_Product_ID";
|
||||
return I_C_ValidCombination.COLUMNNAME_M_Product_ID;
|
||||
else if (elementType.equals(ELEMENTTYPE_Activity))
|
||||
return "C_Activity_ID";
|
||||
return I_C_ValidCombination.COLUMNNAME_C_Activity_ID;
|
||||
else if (elementType.equals(ELEMENTTYPE_LocationFrom))
|
||||
return "C_LocFrom_ID";
|
||||
return I_C_ValidCombination.COLUMNNAME_C_LocFrom_ID;
|
||||
else if (elementType.equals(ELEMENTTYPE_LocationTo))
|
||||
return "C_LocTo_ID";
|
||||
return I_C_ValidCombination.COLUMNNAME_C_LocTo_ID;
|
||||
else if (elementType.equals(ELEMENTTYPE_Campaign))
|
||||
return "C_Campaign_ID";
|
||||
return I_C_ValidCombination.COLUMNNAME_C_Campaign_ID;
|
||||
else if (elementType.equals(ELEMENTTYPE_OrgTrx))
|
||||
return "AD_OrgTrx_ID";
|
||||
return I_C_ValidCombination.COLUMNNAME_AD_OrgTrx_ID;
|
||||
else if (elementType.equals(ELEMENTTYPE_Project))
|
||||
return "C_Project_ID";
|
||||
return I_C_ValidCombination.COLUMNNAME_C_Project_ID;
|
||||
else if (elementType.equals(ELEMENTTYPE_SalesRegion))
|
||||
return "C_SalesRegion_ID";
|
||||
return I_C_ValidCombination.COLUMNNAME_C_SalesRegion_ID;
|
||||
else if (elementType.equals(ELEMENTTYPE_UserList1))
|
||||
return "User1_ID";
|
||||
return I_C_ValidCombination.COLUMNNAME_User1_ID;
|
||||
else if (elementType.equals(ELEMENTTYPE_UserList2))
|
||||
return "User2_ID";
|
||||
return I_C_ValidCombination.COLUMNNAME_User2_ID;
|
||||
else if (elementType.equals(ELEMENTTYPE_UserElement1))
|
||||
return "UserElement1_ID";
|
||||
return I_C_ValidCombination.COLUMNNAME_UserElement1_ID;
|
||||
else if (elementType.equals(ELEMENTTYPE_UserElement2))
|
||||
return "UserElement2_ID";
|
||||
return I_C_ValidCombination.COLUMNNAME_UserElement2_ID;
|
||||
//
|
||||
return "";
|
||||
} // getColumnName
|
||||
|
@ -119,7 +122,7 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element
|
|||
/**
|
||||
* Get Value Query for ELEMENTTYPE Type
|
||||
* @param elementType ELEMENTTYPE type
|
||||
* @return query "SELECT Value,Name FROM Table WHERE ID="
|
||||
* @return query "SELECT Value,Name FROM Table WHERE ID=" or "" if not found
|
||||
*/
|
||||
public static String getValueQuery (String elementType)
|
||||
{
|
||||
|
@ -393,6 +396,7 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element
|
|||
* @param newRecord new
|
||||
* @return true if it can be saved
|
||||
*/
|
||||
@Override
|
||||
protected boolean beforeSave (boolean newRecord)
|
||||
{
|
||||
if (getAD_Org_ID() != 0)
|
||||
|
@ -402,31 +406,39 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element
|
|||
(ELEMENTTYPE_UserList1.equals(et) || ELEMENTTYPE_UserList2.equals(et)
|
||||
|| ELEMENTTYPE_UserElement1.equals(et) || ELEMENTTYPE_UserElement2.equals(et)))
|
||||
setIsMandatory(false);
|
||||
// Acct Schema Elements "Account" and "Org" should be mandatory - teo_sarca BF [ 1795817 ]
|
||||
if (ELEMENTTYPE_Account.equals(et) || ELEMENTTYPE_Organization.equals(et)) {
|
||||
if (!isMandatory())
|
||||
setIsMandatory(true);
|
||||
if (!isActive())
|
||||
setIsActive(true);
|
||||
}
|
||||
//
|
||||
else if (isMandatory())
|
||||
{
|
||||
String errorField = null;
|
||||
if (ELEMENTTYPE_Account.equals(et) && getC_ElementValue_ID() == 0)
|
||||
errorField = "C_ElementValue_ID";
|
||||
errorField = COLUMNNAME_C_ElementValue_ID;
|
||||
else if (ELEMENTTYPE_Activity.equals(et) && getC_Activity_ID() == 0)
|
||||
errorField = "C_Activity_ID";
|
||||
errorField = COLUMNNAME_C_Activity_ID;
|
||||
else if (ELEMENTTYPE_BPartner.equals(et) && getC_BPartner_ID() == 0)
|
||||
errorField = "C_BPartner_ID";
|
||||
errorField = COLUMNNAME_C_BPartner_ID;
|
||||
else if (ELEMENTTYPE_Campaign.equals(et) && getC_Campaign_ID() == 0)
|
||||
errorField = "C_Campaign_ID";
|
||||
errorField = COLUMNNAME_C_Campaign_ID;
|
||||
else if (ELEMENTTYPE_LocationFrom.equals(et) && getC_Location_ID() == 0)
|
||||
errorField = "C_Location_ID";
|
||||
errorField = COLUMNNAME_C_Location_ID;
|
||||
else if (ELEMENTTYPE_LocationTo.equals(et) && getC_Location_ID() == 0)
|
||||
errorField = "C_Location_ID";
|
||||
errorField = COLUMNNAME_C_Location_ID;
|
||||
else if (ELEMENTTYPE_Organization.equals(et) && getOrg_ID() == 0)
|
||||
errorField = "Org_ID";
|
||||
errorField = COLUMNNAME_Org_ID;
|
||||
else if (ELEMENTTYPE_OrgTrx.equals(et) && getOrg_ID() == 0)
|
||||
errorField = "Org_ID";
|
||||
errorField = COLUMNNAME_Org_ID;
|
||||
else if (ELEMENTTYPE_Product.equals(et) && getM_Product_ID() == 0)
|
||||
errorField = "M_Product_ID";
|
||||
errorField = COLUMNNAME_M_Product_ID;
|
||||
else if (ELEMENTTYPE_Project.equals(et) && getC_Project_ID() == 0)
|
||||
errorField = "C_Project_ID";
|
||||
errorField = COLUMNNAME_C_Project_ID;
|
||||
else if (ELEMENTTYPE_SalesRegion.equals(et) && getC_SalesRegion_ID() == 0)
|
||||
errorField = "C_SalesRegion_ID";
|
||||
errorField = COLUMNNAME_C_SalesRegion_ID;
|
||||
if (errorField != null)
|
||||
{
|
||||
log.saveError("Error", Msg.parseTranslation(getCtx(), "@IsMandatory@: @" + errorField + "@"));
|
||||
|
@ -449,22 +461,23 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element
|
|||
* @param success success
|
||||
* @return success
|
||||
*/
|
||||
@Override
|
||||
protected boolean afterSave (boolean newRecord, boolean success)
|
||||
{
|
||||
// Default Value
|
||||
if (isMandatory() && is_ValueChanged("IsMandatory"))
|
||||
if (isMandatory() && is_ValueChanged(COLUMNNAME_IsMandatory))
|
||||
{
|
||||
if (ELEMENTTYPE_Activity.equals(getElementType()))
|
||||
updateData ("C_Activity_ID", getC_Activity_ID());
|
||||
updateData (COLUMNNAME_C_Activity_ID, getC_Activity_ID());
|
||||
else if (ELEMENTTYPE_BPartner.equals(getElementType()))
|
||||
updateData ("C_BPartner_ID", getC_BPartner_ID());
|
||||
updateData (COLUMNNAME_C_BPartner_ID, getC_BPartner_ID());
|
||||
else if (ELEMENTTYPE_Product.equals(getElementType()))
|
||||
updateData ("M_Product_ID", getM_Product_ID());
|
||||
updateData (COLUMNNAME_M_Product_ID, getM_Product_ID());
|
||||
else if (ELEMENTTYPE_Project.equals(getElementType()))
|
||||
updateData ("C_Project_ID", getC_Project_ID());
|
||||
updateData (COLUMNNAME_C_Project_ID, getC_Project_ID());
|
||||
}
|
||||
// Resequence
|
||||
if (newRecord || is_ValueChanged("SeqNo"))
|
||||
if (newRecord || is_ValueChanged(COLUMNNAME_SeqNo))
|
||||
MAccount.updateValueDescription(getCtx(),
|
||||
"AD_Client_ID=" + getAD_Client_ID(), get_TrxName());
|
||||
// Clear Cache
|
||||
|
@ -493,13 +506,24 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element
|
|||
log.fine("ValidCombination=" + noC + ", Fact=" + noF);
|
||||
} // updateData
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean beforeDelete ()
|
||||
{
|
||||
String et = getElementType();
|
||||
// Acct Schema Elements "Account" and "Org" should be mandatory - teo_sarca BF [ 1795817 ]
|
||||
if (ELEMENTTYPE_Account.equals(et) || ELEMENTTYPE_Organization.equals(et)) {
|
||||
log.saveError("Error", Msg.parseTranslation(getCtx(), "@DeleteError@ @IsMandatory@"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* After Delete
|
||||
* @param success success
|
||||
* @return success
|
||||
*/
|
||||
@Override
|
||||
protected boolean afterDelete (boolean success)
|
||||
{
|
||||
// Update Account Info
|
||||
|
|
Loading…
Reference in New Issue