* 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
|
* @author Jorg Janke
|
||||||
* @version $Id: MAcctSchemaElement.java,v 1.4 2006/08/10 01:00:44 jjanke Exp $
|
* @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
|
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
|
* Get Column Name of ELEMENTTYPE
|
||||||
* @param elementType ELEMENTTYPE
|
* @param elementType ELEMENTTYPE
|
||||||
* @return column name
|
* @return column name or "" if not found
|
||||||
*/
|
*/
|
||||||
public static String getColumnName(String elementType)
|
public static String getColumnName(String elementType)
|
||||||
{
|
{
|
||||||
if (elementType.equals(ELEMENTTYPE_Organization))
|
if (elementType.equals(ELEMENTTYPE_Organization))
|
||||||
return "AD_Org_ID";
|
return "AD_Org_ID";
|
||||||
else if (elementType.equals(ELEMENTTYPE_Account))
|
else if (elementType.equals(ELEMENTTYPE_Account))
|
||||||
return "Account_ID";
|
return I_C_ValidCombination.COLUMNNAME_Account_ID;
|
||||||
else if (elementType.equals(ELEMENTTYPE_BPartner))
|
else if (elementType.equals(ELEMENTTYPE_BPartner))
|
||||||
return "C_BPartner_ID";
|
return I_C_ValidCombination.COLUMNNAME_C_BPartner_ID;
|
||||||
else if (elementType.equals(ELEMENTTYPE_Product))
|
else if (elementType.equals(ELEMENTTYPE_Product))
|
||||||
return "M_Product_ID";
|
return I_C_ValidCombination.COLUMNNAME_M_Product_ID;
|
||||||
else if (elementType.equals(ELEMENTTYPE_Activity))
|
else if (elementType.equals(ELEMENTTYPE_Activity))
|
||||||
return "C_Activity_ID";
|
return I_C_ValidCombination.COLUMNNAME_C_Activity_ID;
|
||||||
else if (elementType.equals(ELEMENTTYPE_LocationFrom))
|
else if (elementType.equals(ELEMENTTYPE_LocationFrom))
|
||||||
return "C_LocFrom_ID";
|
return I_C_ValidCombination.COLUMNNAME_C_LocFrom_ID;
|
||||||
else if (elementType.equals(ELEMENTTYPE_LocationTo))
|
else if (elementType.equals(ELEMENTTYPE_LocationTo))
|
||||||
return "C_LocTo_ID";
|
return I_C_ValidCombination.COLUMNNAME_C_LocTo_ID;
|
||||||
else if (elementType.equals(ELEMENTTYPE_Campaign))
|
else if (elementType.equals(ELEMENTTYPE_Campaign))
|
||||||
return "C_Campaign_ID";
|
return I_C_ValidCombination.COLUMNNAME_C_Campaign_ID;
|
||||||
else if (elementType.equals(ELEMENTTYPE_OrgTrx))
|
else if (elementType.equals(ELEMENTTYPE_OrgTrx))
|
||||||
return "AD_OrgTrx_ID";
|
return I_C_ValidCombination.COLUMNNAME_AD_OrgTrx_ID;
|
||||||
else if (elementType.equals(ELEMENTTYPE_Project))
|
else if (elementType.equals(ELEMENTTYPE_Project))
|
||||||
return "C_Project_ID";
|
return I_C_ValidCombination.COLUMNNAME_C_Project_ID;
|
||||||
else if (elementType.equals(ELEMENTTYPE_SalesRegion))
|
else if (elementType.equals(ELEMENTTYPE_SalesRegion))
|
||||||
return "C_SalesRegion_ID";
|
return I_C_ValidCombination.COLUMNNAME_C_SalesRegion_ID;
|
||||||
else if (elementType.equals(ELEMENTTYPE_UserList1))
|
else if (elementType.equals(ELEMENTTYPE_UserList1))
|
||||||
return "User1_ID";
|
return I_C_ValidCombination.COLUMNNAME_User1_ID;
|
||||||
else if (elementType.equals(ELEMENTTYPE_UserList2))
|
else if (elementType.equals(ELEMENTTYPE_UserList2))
|
||||||
return "User2_ID";
|
return I_C_ValidCombination.COLUMNNAME_User2_ID;
|
||||||
else if (elementType.equals(ELEMENTTYPE_UserElement1))
|
else if (elementType.equals(ELEMENTTYPE_UserElement1))
|
||||||
return "UserElement1_ID";
|
return I_C_ValidCombination.COLUMNNAME_UserElement1_ID;
|
||||||
else if (elementType.equals(ELEMENTTYPE_UserElement2))
|
else if (elementType.equals(ELEMENTTYPE_UserElement2))
|
||||||
return "UserElement2_ID";
|
return I_C_ValidCombination.COLUMNNAME_UserElement2_ID;
|
||||||
//
|
//
|
||||||
return "";
|
return "";
|
||||||
} // getColumnName
|
} // getColumnName
|
||||||
|
@ -119,7 +122,7 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element
|
||||||
/**
|
/**
|
||||||
* Get Value Query for ELEMENTTYPE Type
|
* Get Value Query for ELEMENTTYPE Type
|
||||||
* @param elementType 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)
|
public static String getValueQuery (String elementType)
|
||||||
{
|
{
|
||||||
|
@ -393,6 +396,7 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element
|
||||||
* @param newRecord new
|
* @param newRecord new
|
||||||
* @return true if it can be saved
|
* @return true if it can be saved
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected boolean beforeSave (boolean newRecord)
|
protected boolean beforeSave (boolean newRecord)
|
||||||
{
|
{
|
||||||
if (getAD_Org_ID() != 0)
|
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_UserList1.equals(et) || ELEMENTTYPE_UserList2.equals(et)
|
||||||
|| ELEMENTTYPE_UserElement1.equals(et) || ELEMENTTYPE_UserElement2.equals(et)))
|
|| ELEMENTTYPE_UserElement1.equals(et) || ELEMENTTYPE_UserElement2.equals(et)))
|
||||||
setIsMandatory(false);
|
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())
|
else if (isMandatory())
|
||||||
{
|
{
|
||||||
String errorField = null;
|
String errorField = null;
|
||||||
if (ELEMENTTYPE_Account.equals(et) && getC_ElementValue_ID() == 0)
|
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)
|
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)
|
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)
|
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)
|
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)
|
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)
|
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)
|
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)
|
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)
|
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)
|
else if (ELEMENTTYPE_SalesRegion.equals(et) && getC_SalesRegion_ID() == 0)
|
||||||
errorField = "C_SalesRegion_ID";
|
errorField = COLUMNNAME_C_SalesRegion_ID;
|
||||||
if (errorField != null)
|
if (errorField != null)
|
||||||
{
|
{
|
||||||
log.saveError("Error", Msg.parseTranslation(getCtx(), "@IsMandatory@: @" + errorField + "@"));
|
log.saveError("Error", Msg.parseTranslation(getCtx(), "@IsMandatory@: @" + errorField + "@"));
|
||||||
|
@ -449,22 +461,23 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element
|
||||||
* @param success success
|
* @param success success
|
||||||
* @return success
|
* @return success
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected boolean afterSave (boolean newRecord, boolean success)
|
protected boolean afterSave (boolean newRecord, boolean success)
|
||||||
{
|
{
|
||||||
// Default Value
|
// Default Value
|
||||||
if (isMandatory() && is_ValueChanged("IsMandatory"))
|
if (isMandatory() && is_ValueChanged(COLUMNNAME_IsMandatory))
|
||||||
{
|
{
|
||||||
if (ELEMENTTYPE_Activity.equals(getElementType()))
|
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()))
|
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()))
|
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()))
|
else if (ELEMENTTYPE_Project.equals(getElementType()))
|
||||||
updateData ("C_Project_ID", getC_Project_ID());
|
updateData (COLUMNNAME_C_Project_ID, getC_Project_ID());
|
||||||
}
|
}
|
||||||
// Resequence
|
// Resequence
|
||||||
if (newRecord || is_ValueChanged("SeqNo"))
|
if (newRecord || is_ValueChanged(COLUMNNAME_SeqNo))
|
||||||
MAccount.updateValueDescription(getCtx(),
|
MAccount.updateValueDescription(getCtx(),
|
||||||
"AD_Client_ID=" + getAD_Client_ID(), get_TrxName());
|
"AD_Client_ID=" + getAD_Client_ID(), get_TrxName());
|
||||||
// Clear Cache
|
// Clear Cache
|
||||||
|
@ -493,13 +506,24 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element
|
||||||
log.fine("ValidCombination=" + noC + ", Fact=" + noF);
|
log.fine("ValidCombination=" + noC + ", Fact=" + noF);
|
||||||
} // updateData
|
} // 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
|
* After Delete
|
||||||
* @param success success
|
* @param success success
|
||||||
* @return success
|
* @return success
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected boolean afterDelete (boolean success)
|
protected boolean afterDelete (boolean success)
|
||||||
{
|
{
|
||||||
// Update Account Info
|
// Update Account Info
|
||||||
|
|
Loading…
Reference in New Issue