Implement [1762461] - Remove hardcoded list items checking in generated models

https://sourceforge.net/tracker2/index.php?func=detail&aid=1762461&group_id=176962&atid=879335
This commit is contained in:
Carlos Ruiz 2009-03-12 08:06:38 +00:00
parent 031ca7ee0e
commit 0fe7309780
5 changed files with 81 additions and 17 deletions

View File

@ -753,9 +753,10 @@ public class ModelClassGenerator
+ "throw new IllegalArgumentException (\"").append(columnName)
.append(" Invalid value - \" + ").append(columnName)
.append(" + \" - ").append(values).append("\");");
//
if (found && !columnName.equals("EntityType"))
sb.append (statement);
// [1762461] - Remove hardcoded list items checking in generated models
// if (found && !columnName.equals("EntityType"))
// sb.append (statement);
sb.append("\n");
return retValue.toString();
} // addListValidation

View File

@ -80,14 +80,14 @@ public class ModelInterfaceGenerator
"/******************************************************************************\n"
+" * Product: Adempiere ERP & CRM Smart Business Solution *\n"
+" * Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *\n"
+" * This program is free software; you can redistribute it and/or modify it *\n"
+" * This program is free software, you can redistribute it and/or modify it *\n"
+" * under the terms version 2 of the GNU General Public License as published *\n"
+" * by the Free Software Foundation. This program is distributed in the hope *\n"
+" * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *\n"
+" * that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *\n"
+" * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *\n"
+" * See the GNU General Public License for more details. *\n"
+" * You should have received a copy of the GNU General Public License along *\n"
+" * with this program; if not, write to the Free Software Foundation, Inc., *\n"
+" * with this program, if not, write to the Free Software Foundation, Inc., *\n"
+" * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *\n"
+" * For the text or an alternative of this public license, you may reach us *\n"
+" * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *\n"

View File

@ -1,17 +1,14 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software;
you can redistribute it and/or modify it *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program;
if not, write to the Free Software Foundation, Inc., *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
@ -20,6 +17,7 @@
package org.compiere.model;
import java.math.BigDecimal;
import java.sql.Timestamp;
import org.compiere.util.KeyNamePair;
/** Generated Interface for AD_Reference
@ -43,6 +41,14 @@ public interface I_AD_Reference
/** Load Meta Data */
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
*/
public int getAD_Client_ID();
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
@ -69,6 +75,22 @@ public interface I_AD_Reference
*/
public int getAD_Reference_ID();
/** Column name Created */
public static final String COLUMNNAME_Created = "Created";
/** Get Created.
* Date this record was created
*/
public Timestamp getCreated();
/** Column name CreatedBy */
public static final String COLUMNNAME_CreatedBy = "CreatedBy";
/** Get Created By.
* User who created this records
*/
public int getCreatedBy();
/** Column name Description */
public static final String COLUMNNAME_Description = "Description";
@ -110,6 +132,19 @@ public interface I_AD_Reference
*/
public String getHelp();
/** Column name IsActive */
public static final String COLUMNNAME_IsActive = "IsActive";
/** Set Active.
* The record is active in the system
*/
public void setIsActive (boolean IsActive);
/** Get Active.
* The record is active in the system
*/
public boolean isActive();
/** Column name IsOrderByValue */
public static final String COLUMNNAME_IsOrderByValue = "IsOrderByValue";
@ -136,6 +171,22 @@ public interface I_AD_Reference
*/
public String getName();
/** Column name Updated */
public static final String COLUMNNAME_Updated = "Updated";
/** Get Updated.
* Date this record was updated
*/
public Timestamp getUpdated();
/** Column name UpdatedBy */
public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";
/** Get Updated By.
* User who updated this records
*/
public int getUpdatedBy();
/** Column name ValidationType */
public static final String COLUMNNAME_ValidationType = "ValidationType";

View File

@ -778,6 +778,17 @@ public abstract class PO
m_newValues[index] = stringValue.substring(0,length);
}
}
// Validate reference list [1762461]
if (p_info.getColumn(index).DisplayType == DisplayType.List &&
p_info.getColumn(index).AD_Reference_Value_ID > 0 &&
value instanceof String) {
if (MRefList.get(getCtx(), p_info.getColumn(index).AD_Reference_Value_ID,
(String) value, get_TrxName()) != null)
;
else
throw new IllegalArgumentException(ColumnName + " Invalid value - "
+ value + " - Reference_ID=" + p_info.getColumn(index).AD_Reference_Value_ID);
}
if (CLogMgt.isLevelFinest())
log.finest(ColumnName + " = " + m_newValues[index] + " (OldValue="+m_oldValues[index]+")");
}

View File

@ -1,14 +1,14 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
@ -30,7 +30,7 @@ public class X_AD_Reference extends PO implements I_AD_Reference, I_Persistent
/**
*
*/
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 20081221L;
/** Standard Constructor */
public X_AD_Reference (Properties ctx, int AD_Reference_ID, String trxName)
@ -121,6 +121,7 @@ public class X_AD_Reference extends PO implements I_AD_Reference, I_Persistent
*/
public void setEntityType (String EntityType)
{
set_Value (COLUMNNAME_EntityType, EntityType);
}
@ -215,7 +216,7 @@ public class X_AD_Reference extends PO implements I_AD_Reference, I_Persistent
public void setValidationType (String ValidationType)
{
if (ValidationType == null) throw new IllegalArgumentException ("ValidationType is mandatory");
if (ValidationType.equals("L") || ValidationType.equals("D") || ValidationType.equals("T")); else throw new IllegalArgumentException ("ValidationType Invalid value - " + ValidationType + " - Reference_ID=2 - L - D - T"); set_Value (COLUMNNAME_ValidationType, ValidationType);
set_Value (COLUMNNAME_ValidationType, ValidationType);
}
/** Get Validation type.