MERGED REFLIST_EXT TO REFLIST - AS REQUESTED BY TEO SARCA.

IT WAS HELL OF A MERGE! THANKS FOR TRAINING.
YOU RE ALL WELCOME.
This commit is contained in:
Redhuan D. Oon 2008-11-20 12:28:02 +00:00
parent bb146c5008
commit 36d10d08fb
8 changed files with 119 additions and 173 deletions

View File

@ -586,7 +586,7 @@ public class MAsset extends X_A_Asset
change.setA_Asset_ID(p_A_Asset_ID);
change.setA_Parent_Asset_ID(asset.getA_Parent_Asset_ID());
change.setChangeType("CRT");
MRefList_Ext RefList = new MRefList_Ext (getCtx(), 0, get_TrxName());
MRefList RefList = new MRefList (getCtx(), 0, get_TrxName());
change.setTextDetails(RefList.getListDescription (getCtx(),"A_Update_Type" , "CRT"));
change.setIsInPosession(isOwned());
change.setIsDisposed(isDisposed());
@ -704,7 +704,7 @@ public class MAsset extends X_A_Asset
MAssetChange change = new MAssetChange (getCtx(), 0, get_TrxName());
change.setA_Asset_ID(p_A_Asset_ID);
change.setChangeType("UPD");
MRefList_Ext RefList = new MRefList_Ext (getCtx(), 0, get_TrxName());
MRefList RefList = new MRefList (getCtx(), 0, get_TrxName());
change.setTextDetails(RefList.getListDescription (getCtx(),"A_Update_Type" , "UPD"));
change.setLot(getLot());
change.setSerno(getSerNo());

View File

@ -1,16 +1,19 @@
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Smart Business Solution
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
* Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* 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 *
* 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., *
* 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 *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.compiere.model;
import java.sql.PreparedStatement;
@ -60,7 +63,7 @@ public class MAssetAcct extends X_A_Asset_Acct {
if (isProcessing() == true) {
MAssetChange change = new MAssetChange(getCtx(), 0, null);
change.setChangeType("SET");
MRefList_Ext RefList = new MRefList_Ext(getCtx(), 0, null);
MRefList RefList = new MRefList(getCtx(), 0, null);
change.setTextDetails(RefList.getListDescription(getCtx(),
"A_Update_Type", "SET"));
change.setPostingType(getPostingType());

View File

@ -1,15 +1,18 @@
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Smart Business Solution
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
* Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): ______________________________________.
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* 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 *
* 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., *
* 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 *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.compiere.model;
@ -79,7 +82,7 @@ public class MAssetAddition extends X_A_Asset_Addition
change.setA_Asset_ID(p_A_Asset_ID);
change.setA_QTY_Current(getA_QTY_Current());
change.setChangeType("ADD");
MRefList_Ext RefList = new MRefList_Ext (getCtx(), 0, null);
MRefList RefList = new MRefList (getCtx(), 0, null);
change.setTextDetails(RefList.getListDescription (getCtx(),"A_Update_Type" , "ADD"));
change.setPostingType("A");
change.setAssetValueAmt(getAssetValueAmt());
@ -109,7 +112,7 @@ public class MAssetAddition extends X_A_Asset_Addition
change.setA_Asset_ID(p_A_Asset_ID);
change.setA_QTY_Current(getA_QTY_Current());
change.setChangeType("ADD");
MRefList_Ext RefList = new MRefList_Ext (getCtx(), 0, null);
MRefList RefList = new MRefList (getCtx(), 0, null);
change.setTextDetails(RefList.getListDescription (getCtx(),"A_Update_Type" , "ADD"));
change.setPostingType(rs.getString("PostingType"));
change.setAssetValueAmt(getAssetValueAmt());

View File

@ -44,7 +44,7 @@ public class MAssetGroup extends X_A_Asset_Group
} // get
/** Categopry Cache */
private static CCache s_cache = new CCache ("A_Asset_Group", 10);
private static CCache<MAssetGroup, Object> s_cache = new CCache<MAssetGroup, Object> ("A_Asset_Group", 10);
/**
* Standard Constructor

View File

@ -1,3 +1,21 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* 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 *
* 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., *
* 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 *
* or via info@compiere.org or http://www.compiere.org/license.html *
* Copyright (C) 2005 Robert KLEIN. robeklein@gmail.com *
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.model;
import java.sql.ResultSet;
@ -54,7 +72,7 @@ protected boolean afterSave (boolean newRecord,boolean success)
change.setA_Asset_ID(p_A_Asset_ID);
change.setChangeType("USE");
MRefList_Ext RefList = new MRefList_Ext (getCtx(), 0, null);
MRefList RefList = new MRefList (getCtx(), 0, null);
change.setTextDetails(RefList.getListDescription (getCtx(),"A_Update_Type" , "USE"));
change.setUseUnits(getUseUnits());
change.save();

View File

@ -102,7 +102,7 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile
{
change.setA_Asset_ID(p_A_Asset_ID);
change.setChangeType("BAL");
MRefList_Ext RefList = new MRefList_Ext (getCtx(), 0, null);
MRefList RefList = new MRefList (getCtx(), 0, null);
change.setTextDetails(RefList.getListDescription (getCtx(),"A_Update_Type" , "BAL"));
change.setPostingType(getPostingType());
change.setAssetValueAmt(getA_Asset_Cost());

View File

@ -109,6 +109,70 @@ public class MRefList extends X_AD_Ref_List
return retValue;
} // getListName
/**
* Get Reference List Value Description (cached)
* @param ctx context
* @param ListName reference
* @param Value value
* @return List or null
*/
public String getListDescription (Properties ctx, String ListName, String Value)
{
String AD_Language = Env.getAD_Language(ctx);
String key = AD_Language + "_" + ListName + "_" + Value;
String retValue = s_cache.get(key);
if (retValue != null)
return retValue;
boolean isBaseLanguage = Env.isBaseLanguage(AD_Language, "AD_Ref_List");
String sql = isBaseLanguage ?
"SELECT a.Description FROM AD_Ref_List a, AD_Reference b"
+ " WHERE b.Name=? AND a.Value=?"
+ " AND a.AD_Reference_ID = b.AD_Reference_ID" :
"SELECT t.Description FROM AD_Ref_List_Trl t , AD_Reference b"
+ " INNER JOIN AD_Ref_List r ON (r.AD_Ref_List_ID=t.AD_Ref_List_ID) "
+ " WHERE b.Name=? AND a.Value=?"
+ " AND a.AD_Reference_ID = b.AD_Reference_ID AND t.AD_Language=?";
log.info (sql);
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement (sql,null);
pstmt.setString (1, ListName);
pstmt.setString(2, Value);
ResultSet rs = pstmt.executeQuery ();
if (rs.next ())
retValue = rs.getString(1);
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (SQLException ex)
{
log.info("getListDescription - " + sql + " - " + key+ ex);
}
try
{
if (pstmt != null)
pstmt.close ();
}
catch (SQLException ex1)
{
}
pstmt = null;
// Save into Cache
if (retValue == null)
{
retValue = "";
log.info("getListDescription - Not found " + key);
}
s_cache.put(key, retValue);
//
return retValue;
} // getListDescription
/**
* Get Reference List (translated)

View File

@ -1,142 +0,0 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* 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 *
* 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., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
* Author - Jorg Janke, Compiere *
*****************************************************************************/
package org.compiere.model;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import org.compiere.util.CCache;
import org.compiere.util.DB;
import org.compiere.util.Env;
/**
* Reference List Value Extension
*
*
*/
public class MRefList_Ext extends MRefList
{
/**
* Get Reference List Value Description (cached)
* @param ctx context
* @param ListName reference
* @param Value value
* @return List or null
*/
public String getListDescription (Properties ctx, String ListName, String Value)
{
String AD_Language = Env.getAD_Language(ctx);
String key = AD_Language + "_" + ListName + "_" + Value;
String retValue = s_cache.get(key);
if (retValue != null)
return retValue;
boolean isBaseLanguage = Env.isBaseLanguage(AD_Language, "AD_Ref_List");
String sql = isBaseLanguage ?
"SELECT a.Description FROM AD_Ref_List a, AD_Reference b"
+ " WHERE b.Name=? AND a.Value=?"
+ " AND a.AD_Reference_ID = b.AD_Reference_ID" :
"SELECT t.Description FROM AD_Ref_List_Trl t , AD_Reference b"
+ " INNER JOIN AD_Ref_List r ON (r.AD_Ref_List_ID=t.AD_Ref_List_ID) "
+ " WHERE b.Name=? AND a.Value=?"
+ " AND a.AD_Reference_ID = b.AD_Reference_ID AND t.AD_Language=?";
log.info (sql);
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement (sql,null);
pstmt.setString (1, ListName);
pstmt.setString(2, Value);
ResultSet rs = pstmt.executeQuery ();
if (rs.next ())
retValue = rs.getString(1);
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (SQLException ex)
{
log.info("getListDescription - " + sql + " - " + key+ ex);
}
try
{
if (pstmt != null)
pstmt.close ();
}
catch (SQLException ex1)
{
}
pstmt = null;
// Save into Cache
if (retValue == null)
{
retValue = "";
log.info("getListDescription - Not found " + key);
}
s_cache.put(key, retValue);
//
return retValue;
} // getListName
/** Value Cache */
private static CCache<String, String> s_cache = new CCache<String, String>("AD_Ref_List", 20);
/**************************************************************************
* Persistency Constructor
* @param ctx context
* @param AD_Ref_List_ID id
*/
public MRefList_Ext (Properties ctx, int AD_Ref_List_ID, String trxName)
{
super (ctx, AD_Ref_List_ID, trxName);
if (AD_Ref_List_ID == 0)
{
// setAD_Reference_ID (0);
// setAD_Ref_List_ID (0);
setEntityType (ENTITYTYPE_UserMaintained); // U
// setName (null);
// setValue (null);
}
} // MRef_List
/**
* Load Contructor
* @param ctx context
* @param rs result
*/
public MRefList_Ext (Properties ctx, ResultSet rs, String trxName)
{
super (ctx, rs, trxName);
} // MRef_List
/**
* String Representation
* @return Name
*/
public String toString()
{
return getName();
} // toString
} // MRef_List