details: http://code.openbravo.com/erp/devel/pi/rev/1c4a76d20d9a changeset: 3640:1c4a76d20d9a user: mtaal date: Wed Feb 25 21:34:44 2009 +0100 description: Fixes issue 7804, Update Issue validation in export.database for package a module fails with NOT_NULL_IN_DB_NOT_MANDATORY_IN_AD
diffs (171 lines): diff -r 9c25af4090cd -r 1c4a76d20d9a src-db/database/model/tables/AD_EXCEPTIONS.xml --- a/src-db/database/model/tables/AD_EXCEPTIONS.xml Wed Feb 25 18:24:31 2009 +0100 +++ b/src-db/database/model/tables/AD_EXCEPTIONS.xml Wed Feb 25 21:34:44 2009 +0100 @@ -41,7 +41,7 @@ <default/> <onCreateDefault/> </column> - <column name="TYPE" primaryKey="false" required="false" type="NVARCHAR" size="60" autoIncrement="false"> + <column name="TYPE" primaryKey="false" required="false" type="VARCHAR" size="60" autoIncrement="false"> <default/> <onCreateDefault/> </column> diff -r 9c25af4090cd -r 1c4a76d20d9a src/org/openbravo/base/model/Property.java --- a/src/org/openbravo/base/model/Property.java Wed Feb 25 18:24:31 2009 +0100 +++ b/src/org/openbravo/base/model/Property.java Wed Feb 25 21:34:44 2009 +0100 @@ -27,11 +27,6 @@ import org.apache.log4j.Logger; import org.openbravo.base.expression.Evaluator; -import org.openbravo.base.model.BaseOBObjectDef; -import org.openbravo.base.model.Column; -import org.openbravo.base.model.Entity; -import org.openbravo.base.model.Module; -import org.openbravo.base.model.NamingUtil; import org.openbravo.base.util.Check; import org.openbravo.base.validation.PropertyValidator; import org.openbravo.base.validation.ValidationException; @@ -110,12 +105,11 @@ setDefaultValue(fromColumn.getDefaultValue()); - // setMandatory to false on purpose because there are many cases whereby it is set to + // use of the mandatory is restricted because there are many cases whereby it is set to // true while the underlying db column allows null, this because the mandatory value // is used in the ui // setMandatory(overrideMandatoryCustom(fromColumn)); - // setMandatory(false); - setMandatory(false); + setMandatory(fromColumn.isMandatory()); setMinValue(fromColumn.getValueMin()); setMaxValue(fromColumn.getValueMax()); @@ -144,30 +138,30 @@ // This because it is not possible to define in a field if a field should // be mandatory. So these columns are hidden on windows/tabs where they // should not be entered. - private boolean overrideMandatoryCustom(Column c) { - final boolean columnMandatory = c.isMandatory(); - if (c.getTable().getTableName().equalsIgnoreCase("AD_User") - && c.getColumnName().equalsIgnoreCase("username")) { - return false; - } - if (!c.getTable().getTableName().equalsIgnoreCase("M_ProductionPlan") - && !c.getTable().getTableName().equalsIgnoreCase("M_Production")) { - return columnMandatory; - } - if (c.getColumnName().equalsIgnoreCase("endtime")) { - return false; - } else if (c.getColumnName().equalsIgnoreCase("ma_costcenteruse")) { - return false; - } else if (c.getColumnName().equalsIgnoreCase("MA_Wrphase_ID")) { - return false; - } else if (c.getColumnName().equalsIgnoreCase("neededquantity")) { - return false; - } else if (c.getColumnName().equalsIgnoreCase("rejectedquantity")) { - return false; - } else { - return columnMandatory; - } - } + // private boolean overrideMandatoryCustom(Column c) { + // final boolean columnMandatory = c.isMandatory(); + // if (c.getTable().getTableName().equalsIgnoreCase("AD_User") + // && c.getColumnName().equalsIgnoreCase("username")) { + // return false; + // } + // if (!c.getTable().getTableName().equalsIgnoreCase("M_ProductionPlan") + // && !c.getTable().getTableName().equalsIgnoreCase("M_Production")) { + // return columnMandatory; + // } + // if (c.getColumnName().equalsIgnoreCase("endtime")) { + // return false; + // } else if (c.getColumnName().equalsIgnoreCase("ma_costcenteruse")) { + // return false; + // } else if (c.getColumnName().equalsIgnoreCase("MA_Wrphase_ID")) { + // return false; + // } else if (c.getColumnName().equalsIgnoreCase("neededquantity")) { + // return false; + // } else if (c.getColumnName().equalsIgnoreCase("rejectedquantity")) { + // return false; + // } else { + // return columnMandatory; + // } + // } /** * Initializes the name of the property. This is done separately from the @@ -623,11 +617,13 @@ // this assumes ofcourse that all ids are generated // also client and organization may be nullified as they are set // automatically - if (value == null && isMandatory() && !isId() && !isClientOrOrganization()) { - final ValidationException ve = new ValidationException(); - ve.addMessage(this, "Property " + this + " is mandatory, null values are not allowed."); - throw ve; - } + + // disabled because isMandatory should not be used right now + // if (value == null && isMandatory() && !isId() && !isClientOrOrganization()) { + // final ValidationException ve = new ValidationException(); + // ve.addMessage(this, "Property " + this + " is mandatory, null values are not allowed."); + // throw ve; + // } if (value == null) { return; diff -r 9c25af4090cd -r 1c4a76d20d9a src/org/openbravo/service/system/DatabaseValidator.java --- a/src/org/openbravo/service/system/DatabaseValidator.java Wed Feb 25 18:24:31 2009 +0100 +++ b/src/org/openbravo/service/system/DatabaseValidator.java Wed Feb 25 21:34:44 2009 +0100 @@ -286,30 +286,29 @@ final Property property = getProperty(dbTable.getName(), dbColumn.getName()); - if (property != null && !property.isMandatory() && dbColumn.isRequired()) { - result.addError( - SystemValidationResult.SystemValidationType.NOT_NULL_IN_DB_NOT_MANDATORY_IN_AD, "Column " - + dbTable.getName() + "." + dbColumn.getName() - + " is required (not-null) but in the Application Dictonary" - + " it is set as non-mandatory"); - - final Property p = getProperty(dbTable.getName(), dbColumn.getName()); - updateSql - .append("update ad_column set ismandatory='Y' where ad_column_id in (select c.ad_column_id from ad_column c, ad_table t " - + "where c.ad_table_id=t.ad_table_id and t.tablename='" - + p.getEntity().getTableName() + "' and c.columnname='" + p.getColumnName() + "');\n"); - - } + // disabled because mandatory is always false + // if (property != null && !property.isMandatory() && dbColumn.isRequired()) { + // result.addError( + // SystemValidationResult.SystemValidationType.NOT_NULL_IN_DB_NOT_MANDATORY_IN_AD, "Column " + // + dbTable.getName() + "." + dbColumn.getName() + // + " is required (not-null) but in the Application Dictonary" + // + " it is set as non-mandatory"); + // + // final Property p = getProperty(dbTable.getName(), dbColumn.getName()); + // updateSql + // .append("update ad_column set ismandatory='Y' where ad_column_id in (select c.ad_column_id from ad_column c, ad_table t " + // + "where c.ad_table_id=t.ad_table_id and t.tablename='" + // + p.getEntity().getTableName() + "' and c.columnname='" + p.getColumnName() + "');\n"); + // + // } // disabled this check, will be done in 2.60 - if (false) { - if (property != null && property.isMandatory() && !dbColumn.isRequired()) { - result.addError(SystemValidationType.MANDATORY_IN_AD_NULLABLE_IN_DB, "Column " - + dbTable.getName() + "." + dbColumn.getName() - + " is not-required (null-allowed) but in the Application Dictonary" - + " it is set as mandatory"); - } - } + // if (property != null && property.isMandatory() && !dbColumn.isRequired()) { + // result.addError(SystemValidationType.MANDATORY_IN_AD_NULLABLE_IN_DB, "Column " + // + dbTable.getName() + "." + dbColumn.getName() + // + " is not-required (null-allowed) but in the Application Dictonary" + // + " it is set as mandatory"); + // } // check the default value if (property != null && property.getActualDefaultValue() != null) { ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits