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:
parent
bb146c5008
commit
36d10d08fb
|
@ -586,7 +586,7 @@ public class MAsset extends X_A_Asset
|
||||||
change.setA_Asset_ID(p_A_Asset_ID);
|
change.setA_Asset_ID(p_A_Asset_ID);
|
||||||
change.setA_Parent_Asset_ID(asset.getA_Parent_Asset_ID());
|
change.setA_Parent_Asset_ID(asset.getA_Parent_Asset_ID());
|
||||||
change.setChangeType("CRT");
|
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.setTextDetails(RefList.getListDescription (getCtx(),"A_Update_Type" , "CRT"));
|
||||||
change.setIsInPosession(isOwned());
|
change.setIsInPosession(isOwned());
|
||||||
change.setIsDisposed(isDisposed());
|
change.setIsDisposed(isDisposed());
|
||||||
|
@ -704,7 +704,7 @@ public class MAsset extends X_A_Asset
|
||||||
MAssetChange change = new MAssetChange (getCtx(), 0, get_TrxName());
|
MAssetChange change = new MAssetChange (getCtx(), 0, get_TrxName());
|
||||||
change.setA_Asset_ID(p_A_Asset_ID);
|
change.setA_Asset_ID(p_A_Asset_ID);
|
||||||
change.setChangeType("UPD");
|
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.setTextDetails(RefList.getListDescription (getCtx(),"A_Update_Type" , "UPD"));
|
||||||
change.setLot(getLot());
|
change.setLot(getLot());
|
||||||
change.setSerno(getSerNo());
|
change.setSerno(getSerNo());
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* The contents of this file are subject to the Compiere License Version 1.1
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
* ("License"); You may not use this file except in compliance with the License
|
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||||
* You may obtain a copy of the License at http://www.compiere.org/license.html
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
* the specific language governing rights and limitations under the License.
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
* The Original Code is Compiere ERP & CRM Smart Business Solution
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
|
* See the GNU General Public License for more details. *
|
||||||
* Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
|
* You should have received a copy of the GNU General Public License along *
|
||||||
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
* Contributor(s): ______________________________________.
|
* 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;
|
package org.compiere.model;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
@ -60,7 +63,7 @@ public class MAssetAcct extends X_A_Asset_Acct {
|
||||||
if (isProcessing() == true) {
|
if (isProcessing() == true) {
|
||||||
MAssetChange change = new MAssetChange(getCtx(), 0, null);
|
MAssetChange change = new MAssetChange(getCtx(), 0, null);
|
||||||
change.setChangeType("SET");
|
change.setChangeType("SET");
|
||||||
MRefList_Ext RefList = new MRefList_Ext(getCtx(), 0, null);
|
MRefList RefList = new MRefList(getCtx(), 0, null);
|
||||||
change.setTextDetails(RefList.getListDescription(getCtx(),
|
change.setTextDetails(RefList.getListDescription(getCtx(),
|
||||||
"A_Update_Type", "SET"));
|
"A_Update_Type", "SET"));
|
||||||
change.setPostingType(getPostingType());
|
change.setPostingType(getPostingType());
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* The contents of this file are subject to the Compiere License Version 1.1
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
* ("License"); You may not use this file except in compliance with the License
|
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||||
* You may obtain a copy of the License at http://www.compiere.org/license.html
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
* the specific language governing rights and limitations under the License.
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
* The Original Code is Compiere ERP & CRM Smart Business Solution
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
|
* See the GNU General Public License for more details. *
|
||||||
* Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
|
* You should have received a copy of the GNU General Public License along *
|
||||||
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
* Contributor(s): ______________________________________.
|
* 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;
|
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_Asset_ID(p_A_Asset_ID);
|
||||||
change.setA_QTY_Current(getA_QTY_Current());
|
change.setA_QTY_Current(getA_QTY_Current());
|
||||||
change.setChangeType("ADD");
|
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.setTextDetails(RefList.getListDescription (getCtx(),"A_Update_Type" , "ADD"));
|
||||||
change.setPostingType("A");
|
change.setPostingType("A");
|
||||||
change.setAssetValueAmt(getAssetValueAmt());
|
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_Asset_ID(p_A_Asset_ID);
|
||||||
change.setA_QTY_Current(getA_QTY_Current());
|
change.setA_QTY_Current(getA_QTY_Current());
|
||||||
change.setChangeType("ADD");
|
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.setTextDetails(RefList.getListDescription (getCtx(),"A_Update_Type" , "ADD"));
|
||||||
change.setPostingType(rs.getString("PostingType"));
|
change.setPostingType(rs.getString("PostingType"));
|
||||||
change.setAssetValueAmt(getAssetValueAmt());
|
change.setAssetValueAmt(getAssetValueAmt());
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class MAssetGroup extends X_A_Asset_Group
|
||||||
} // get
|
} // get
|
||||||
|
|
||||||
/** Categopry Cache */
|
/** 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
|
* Standard Constructor
|
||||||
|
|
|
@ -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;
|
package org.compiere.model;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
@ -54,7 +72,7 @@ protected boolean afterSave (boolean newRecord,boolean success)
|
||||||
|
|
||||||
change.setA_Asset_ID(p_A_Asset_ID);
|
change.setA_Asset_ID(p_A_Asset_ID);
|
||||||
change.setChangeType("USE");
|
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.setTextDetails(RefList.getListDescription (getCtx(),"A_Update_Type" , "USE"));
|
||||||
change.setUseUnits(getUseUnits());
|
change.setUseUnits(getUseUnits());
|
||||||
change.save();
|
change.save();
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile
|
||||||
{
|
{
|
||||||
change.setA_Asset_ID(p_A_Asset_ID);
|
change.setA_Asset_ID(p_A_Asset_ID);
|
||||||
change.setChangeType("BAL");
|
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.setTextDetails(RefList.getListDescription (getCtx(),"A_Update_Type" , "BAL"));
|
||||||
change.setPostingType(getPostingType());
|
change.setPostingType(getPostingType());
|
||||||
change.setAssetValueAmt(getA_Asset_Cost());
|
change.setAssetValueAmt(getA_Asset_Cost());
|
||||||
|
|
|
@ -109,6 +109,70 @@ public class MRefList extends X_AD_Ref_List
|
||||||
return retValue;
|
return retValue;
|
||||||
} // getListName
|
} // 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)
|
* Get Reference List (translated)
|
||||||
|
|
|
@ -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
|
|
Loading…
Reference in New Issue