[ 2051056 ] MResource[Type] should be cached

* use MUOM.get() (cached) instead of new MUOM
This commit is contained in:
teo_sarca 2008-08-14 09:44:06 +00:00
parent ce561b9bdc
commit 1a5f51e1c7
14 changed files with 108 additions and 62 deletions

View File

@ -16,8 +16,10 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.sql.*; import java.sql.ResultSet;
import java.util.*; import java.util.Properties;
import org.compiere.util.CCache;
/** /**
@ -25,9 +27,34 @@ import java.util.*;
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: MResource.java,v 1.2 2006/07/30 00:51:05 jjanke Exp $ * @version $Id: MResource.java,v 1.2 2006/07/30 00:51:05 jjanke Exp $
*
* @author Teo Sarca, www.arhipac.ro
* <li>FR [ 2051056 ] MResource[Type] should be cached
*/ */
public class MResource extends X_S_Resource public class MResource extends X_S_Resource
{ {
/** Cache */
private static CCache<Integer, MResource> s_cache = new CCache<Integer, MResource>(Table_Name, 20);
/**
* Get from Cache
* @param ctx
* @param S_Resource_ID
* @return MResource
*/
public static MResource get(Properties ctx, int S_Resource_ID)
{
if (S_Resource_ID <= 0)
return null;
MResource r = s_cache.get(S_Resource_ID);
if (r == null) {
r = new MResource(ctx, S_Resource_ID, null);
if (r.get_ID() == S_Resource_ID) {
s_cache.put(S_Resource_ID, r);
}
}
return r;
}
/** /**
* Standard Constructor * Standard Constructor
@ -62,8 +89,13 @@ public class MResource extends X_S_Resource
*/ */
public MResourceType getResourceType() public MResourceType getResourceType()
{ {
if (m_resourceType == null && getS_ResourceType_ID() != 0) // Use cache if we are outside transaction:
if (get_TrxName() == null && getS_ResourceType_ID() > 0)
return MResourceType.get(getCtx(), getS_ResourceType_ID());
//
if (m_resourceType == null && getS_ResourceType_ID() != 0) {
m_resourceType = new MResourceType (getCtx(), getS_ResourceType_ID(), get_TrxName()); m_resourceType = new MResourceType (getCtx(), getS_ResourceType_ID(), get_TrxName());
}
return m_resourceType; return m_resourceType;
} // getResourceType } // getResourceType
@ -94,7 +126,7 @@ public class MResource extends X_S_Resource
if (getValue() == null || getValue().length() == 0) if (getValue() == null || getValue().length() == 0)
setValue(getName()); setValue(getName());
m_product = new MProduct(this, getResourceType()); m_product = new MProduct(this, getResourceType());
return m_product.save(get_TrxName()); m_product.saveEx(get_TrxName());
} }
return true; return true;
} // beforeSave } // beforeSave
@ -112,7 +144,7 @@ public class MResource extends X_S_Resource
MProduct prod = getProduct(); MProduct prod = getProduct();
if (prod.setResource(this)) if (prod.setResource(this))
prod.save(get_TrxName()); prod.saveEx(get_TrxName());
return success; return success;
} // afterSave } // afterSave

View File

@ -16,8 +16,10 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.sql.*; import java.sql.ResultSet;
import java.util.*; import java.util.Properties;
import org.compiere.util.CCache;
/** /**
@ -25,9 +27,36 @@ import java.util.*;
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: MResourceType.java,v 1.2 2006/07/30 00:51:03 jjanke Exp $ * @version $Id: MResourceType.java,v 1.2 2006/07/30 00:51:03 jjanke Exp $
*
* @author Teo Sarca, www.arhipac.ro
* <li>FR [ 2051056 ] MResource[Type] should be cached
*/ */
public class MResourceType extends X_S_ResourceType public class MResourceType extends X_S_ResourceType
{ {
/** Cache */
private static CCache<Integer, MResourceType> s_cache = new CCache<Integer, MResourceType>(Table_Name, 20);
/**
* Get from Cache
* @param ctx
* @param S_ResourceType_ID
* @return MResourceType
*/
public static MResourceType get(Properties ctx, int S_ResourceType_ID)
{
if (S_ResourceType_ID <= 0)
return null;
MResourceType type = s_cache.get(S_ResourceType_ID);
if (type == null) {
type = new MResourceType(ctx, S_ResourceType_ID, null);
if (type.get_ID() == S_ResourceType_ID) {
s_cache.put(S_ResourceType_ID, type);
}
}
return type;
}
/** /**
* Standard Constructor * Standard Constructor
* @param ctx context * @param ctx context
@ -70,7 +99,7 @@ public class MResourceType extends X_S_ResourceType
{ {
MProduct product = products[i]; MProduct product = products[i];
if (product.setResource(this)) if (product.setResource(this))
product.save(get_TrxName()); product.saveEx(get_TrxName());
} }
} }

View File

@ -840,8 +840,8 @@ public class MPPMRP extends X_PP_MRP
if (S_Resource_ID == 0) if (S_Resource_ID == 0)
return Env.ZERO; return Env.ZERO;
MResource S_Resource = new MResource(Env.getCtx(),S_Resource_ID,null); MResource S_Resource = MResource.get(Env.getCtx(),S_Resource_ID);
MResourceType S_ResourceType = new MResourceType(Env.getCtx(),S_Resource.getS_ResourceType_ID(),null); MResourceType S_ResourceType = MResourceType.get(Env.getCtx(),S_Resource.getS_ResourceType_ID());
BigDecimal AvailableDayTime = Env.ZERO; BigDecimal AvailableDayTime = Env.ZERO;
int AvailableDays = 0; int AvailableDays = 0;

View File

@ -103,8 +103,7 @@ public class CRPReasoner {
public Timestamp getBorderDayMin(Timestamp dateTime, MResource r) { public Timestamp getBorderDayMin(Timestamp dateTime, MResource r) {
MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null); MResourceType t = MResourceType.get(Env.getCtx(), r.getS_ResourceType_ID());
Timestamp dMin = null;
return (t.isTimeSlot()) ? return (t.isTimeSlot()) ?
DateTimeUtil.getDayBorder(dateTime, t.getTimeSlotStart(), false) : DateTimeUtil.getDayBorder(dateTime, t.getTimeSlotStart(), false) :
DateTimeUtil.getDayBorder(dateTime, null, false); DateTimeUtil.getDayBorder(dateTime, null, false);
@ -112,8 +111,7 @@ public class CRPReasoner {
public Timestamp getBorderDayMax(Timestamp dateTime, MResource r) { public Timestamp getBorderDayMax(Timestamp dateTime, MResource r) {
MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null); MResourceType t = MResourceType.get(Env.getCtx(), r.getS_ResourceType_ID());
Timestamp dMin = null;
return (t.isTimeSlot()) ? return (t.isTimeSlot()) ?
DateTimeUtil.getDayBorder(dateTime, t.getTimeSlotEnd(), true) : DateTimeUtil.getDayBorder(dateTime, t.getTimeSlotEnd(), true) :
DateTimeUtil.getDayBorder(dateTime, null, true); DateTimeUtil.getDayBorder(dateTime, null, true);
@ -121,8 +119,7 @@ public class CRPReasoner {
public boolean isResourceAvailable(Timestamp dateTime, MResource r) { public boolean isResourceAvailable(Timestamp dateTime, MResource r) {
MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null); MResourceType t = MResourceType.get(Env.getCtx(), r.getS_ResourceType_ID());
return ( checkResourceAvailability(dateTime, r) && checkResourceTypeAvailability(dateTime, t) ); return ( checkResourceAvailability(dateTime, r) && checkResourceTypeAvailability(dateTime, t) );
} }

View File

@ -109,7 +109,7 @@ public class CRP extends SvrProcess {
long nodeMillis = 0; long nodeMillis = 0;
int nodeId = -1; int nodeId = -1;
resource = new MResource(Env.getCtx(), p_S_Resource_ID, null); resource = MResource.get(getCtx(), p_S_Resource_ID);
MPPOrder[] orders = reasoner.getPPOrdersNotCompleted(resource); MPPOrder[] orders = reasoner.getPPOrdersNotCompleted(resource);
log.log(Level.INFO,"MPP_Order[] : " + orders.length); log.log(Level.INFO,"MPP_Order[] : " + orders.length);
for(int i = 0; i < orders.length; i++) { for(int i = 0; i < orders.length; i++) {
@ -127,17 +127,17 @@ public class CRP extends SvrProcess {
log.log(Level.FINE,"MPP_Order Workflow:" + owf.getName()); log.log(Level.FINE,"MPP_Order Workflow:" + owf.getName());
date = orders[i].getDateStartSchedule(); date = orders[i].getDateStartSchedule();
nodeId = owf.getPP_Order_Node_ID(); nodeId = owf.getPP_Order_Node_ID();
while(nodeId != 0) { while(nodeId != 0) {
node = new MPPOrderNode(getCtx(),nodeId , get_TrxName()); node = new MPPOrderNode(getCtx(),nodeId , get_TrxName());
log.log(Level.FINE,"MPP_Order Node:" + node.getName() + " Description:" + node.getDescription()); log.log(Level.FINE,"MPP_Order Node:" + node.getName() + " Description:" + node.getDescription());
resource = new MResource(Env.getCtx(), node.getS_Resource_ID(), null); resource = MResource.get(getCtx(), node.getS_Resource_ID());
resourceType = new MResourceType(Env.getCtx(), resource.getS_ResourceType_ID(), null); resourceType = MResourceType.get(getCtx(), resource.getS_ResourceType_ID());
// Checks, whether the resource type is principal available on one day a week. // Checks, whether the resource type is principal available on one day a week.
// If not, process breaks with a Info message about. // If not, process breaks with a Info message about.
if(!reasoner.checkResourceTypeAvailability(resourceType)) { if(!reasoner.checkResourceTypeAvailability(resourceType)) {
return Msg.getMsg(Env.getCtx(), "ResourceNotInSlotDay"); return Msg.getMsg(Env.getCtx(), "ResourceNotInSlotDay");
} }
@ -164,16 +164,14 @@ public class CRP extends SvrProcess {
nodeId = owf.getLast(0, getAD_Client_ID()); nodeId = owf.getLast(0, getAD_Client_ID());
while(nodeId != 0) { while(nodeId != 0) {
node = new MPPOrderNode(getCtx(),nodeId , get_TrxName()); node = new MPPOrderNode(getCtx(),nodeId , get_TrxName());
log.log(Level.FINE,"MPP_Order Node:" + node.getName() + " Description:" + node.getDescription()); log.log(Level.FINE,"MPP_Order Node:" + node.getName() + " Description:" + node.getDescription());
resource = new MResource(Env.getCtx(), node.getS_Resource_ID(), null); resource = MResource.get(getCtx(), node.getS_Resource_ID());
resourceType = new MResourceType(Env.getCtx(), resource.getS_ResourceType_ID(), null); resourceType = MResourceType.get(getCtx(), resource.getS_ResourceType_ID());
// Checks, whether the resource type is principal available on one day a week. // Checks, whether the resource type is principal available on one day a week.
// If not, process breaks with a Info message about. // If not, process breaks with a Info message about.
if(!reasoner.checkResourceTypeAvailability(resourceType)) { if(!reasoner.checkResourceTypeAvailability(resourceType)) {
return Msg.getMsg(Env.getCtx(), "ResourceNotInSlotDay"); return Msg.getMsg(Env.getCtx(), "ResourceNotInSlotDay");
} }

View File

@ -148,11 +148,11 @@ public class CRPSummary extends SvrProcess
// Calculate Total seconds for Node // Calculate Total seconds for Node
seconds = (n.getQueuingTime() + n.getSetupTime() + QtyOpen.multiply(new BigDecimal(n.getDuration())).longValue() + n.getMovingTime() + n.getWaitingTime()) * owf.getDurationBaseSec(); seconds = (n.getQueuingTime() + n.getSetupTime() + QtyOpen.multiply(new BigDecimal(n.getDuration())).longValue() + n.getMovingTime() + n.getWaitingTime()) * owf.getDurationBaseSec();
// Calculate Factor Day // Calculate Factor Day
MResource r = new MResource(getCtx(),n.getS_Resource_ID(),null); MResource r = MResource.get(getCtx(),n.getS_Resource_ID());
if (r == null) if (r == null)
continue; continue;
MResourceType type = new MResourceType(Env.getCtx(),r.getS_ResourceType_ID(),null); MResourceType type = MResourceType.get(Env.getCtx(),r.getS_ResourceType_ID());
long hours = 0 ; long hours = 0 ;
if (type.isTimeSlot()) if (type.isTimeSlot())
@ -186,11 +186,11 @@ public class CRPSummary extends SvrProcess
// Calculate Total seconds for Node // Calculate Total seconds for Node
seconds = (n.getQueuingTime() + n.getSetupTime() + QtyOpen.multiply(new BigDecimal(n.getDuration())).longValue() + n.getMovingTime() + n.getWaitingTime()) * owf.getDurationBaseSec(); seconds = (n.getQueuingTime() + n.getSetupTime() + QtyOpen.multiply(new BigDecimal(n.getDuration())).longValue() + n.getMovingTime() + n.getWaitingTime()) * owf.getDurationBaseSec();
// Calculate Factor Day // Calculate Factor Day
MResource r = new MResource(getCtx(),n.getS_Resource_ID(),null); MResource r = MResource.get(getCtx(),n.getS_Resource_ID());
if (r == null) if (r == null)
continue; continue;
MResourceType type = new MResourceType(Env.getCtx(),r.getS_ResourceType_ID(),null); MResourceType type = MResourceType.get(Env.getCtx(),r.getS_ResourceType_ID());
long hours = 0 ; long hours = 0 ;
if (type.isTimeSlot()) if (type.isTimeSlot())
@ -360,7 +360,7 @@ public class CRPSummary extends SvrProcess
gc2.clear(Calendar.MINUTE); gc2.clear(Calendar.MINUTE);
gc2.clear(Calendar.HOUR_OF_DAY); gc2.clear(Calendar.HOUR_OF_DAY);
MResourceType t = new MResourceType(Env.getCtx(),r.getS_ResourceType_ID(),null); MResourceType t = MResourceType.get(Env.getCtx(),r.getS_ResourceType_ID());
long hours = 0; long hours = 0;
if (t.isTimeSlot()) if (t.isTimeSlot())
@ -434,7 +434,7 @@ public class CRPSummary extends SvrProcess
Long Hours = new Long(hours); Long Hours = new Long(hours);
cols.setCapacity(Hours.intValue()); cols.setCapacity(Hours.intValue());
int C_UOM_ID = DB.getSQLValue(null,"SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? " , r.getS_Resource_ID()); int C_UOM_ID = DB.getSQLValue(null,"SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? " , r.getS_Resource_ID());
MUOM oum = new MUOM(getCtx(),C_UOM_ID,null); MUOM oum = MUOM.get(getCtx(),C_UOM_ID);
if (oum.isHour()) if (oum.isHour())
{ {
Timestamp date = new Timestamp(gc1.getTimeInMillis()); Timestamp date = new Timestamp(gc1.getTimeInMillis());

View File

@ -111,7 +111,7 @@ public class MRP extends SvrProcess
else if (name.equals("S_Resource_ID")) else if (name.equals("S_Resource_ID"))
{ {
p_S_Resource_ID = ((BigDecimal)para[i].getParameter()).intValue(); p_S_Resource_ID = ((BigDecimal)para[i].getParameter()).intValue();
MResource r = new MResource(getCtx(),p_S_Resource_ID, get_TrxName()); MResource r = MResource.get(getCtx(),p_S_Resource_ID);
Date_Planning_Horizon = TimeUtil.addDays(Today, r.getPlanningHorizon()); Date_Planning_Horizon = TimeUtil.addDays(Today, r.getPlanningHorizon());
} }
else if (name.equals("M_Warehouse_ID")) else if (name.equals("M_Warehouse_ID"))

View File

@ -176,8 +176,8 @@ public class RollupWorkflow extends SvrProcess
String sql = "SELECT CASE WHEN ow.DurationUnit = 's' THEN 1 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration ) WHEN ow.DurationUnit = 'm' THEN 60 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration) WHEN ow.DurationUnit = 'h' THEN 3600 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration) WHEN ow.DurationUnit = 'Y' THEN 31536000 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration) WHEN ow.DurationUnit = 'M' THEN 2592000 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration ) WHEN ow.DurationUnit = 'D' THEN 86400 * ((onode.SetupTime/ow.QtyBatchSize) + onode.Duration) END AS load FROM AD_WF_Node onode INNER JOIN AD_Workflow ow ON (ow.AD_Workflow_ID = onode.AD_Workflow_ID) WHERE onode.AD_WF_Node_ID = ? AND onode.AD_Client_ID = ?" ; String sql = "SELECT CASE WHEN ow.DurationUnit = 's' THEN 1 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration ) WHEN ow.DurationUnit = 'm' THEN 60 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration) WHEN ow.DurationUnit = 'h' THEN 3600 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration) WHEN ow.DurationUnit = 'Y' THEN 31536000 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration) WHEN ow.DurationUnit = 'M' THEN 2592000 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration ) WHEN ow.DurationUnit = 'D' THEN 86400 * ((onode.SetupTime/ow.QtyBatchSize) + onode.Duration) END AS load FROM AD_WF_Node onode INNER JOIN AD_Workflow ow ON (ow.AD_Workflow_ID = onode.AD_Workflow_ID) WHERE onode.AD_WF_Node_ID = ? AND onode.AD_Client_ID = ?" ;
int seconds = DB.getSQLValue(get_TrxName(),sql,node.getAD_WF_Node_ID(),node.getAD_Client_ID()); int seconds = DB.getSQLValue(get_TrxName(),sql,node.getAD_WF_Node_ID(),node.getAD_Client_ID());
int C_UOM_ID = DB.getSQLValue(get_TrxName(),"SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? " , node.getS_Resource_ID()); int C_UOM_ID = DB.getSQLValue(get_TrxName(),"SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? " , node.getS_Resource_ID());
MUOM oum = new MUOM(getCtx(),C_UOM_ID,get_TrxName()); MUOM uom = MUOM.get(getCtx(), C_UOM_ID);
if (oum.isHour()) if (uom.isHour())
{ {
BigDecimal time = new BigDecimal(seconds); BigDecimal time = new BigDecimal(seconds);

View File

@ -338,34 +338,24 @@ public class CCRP extends CAbstractForm {
} }
public MUOM getSourceUOM() { public MUOM getSourceUOM() {
MResource r = getResource(); MResource r = getResource();
int uom_id = r.getResourceType().getC_UOM_ID(); int uom_id = r.getResourceType().getC_UOM_ID();
return (uom_id > 0) ? MUOM.get(Env.getCtx(),uom_id) : null;
return (uom_id > 0) ? new MUOM(Env.getCtx(),uom_id, null) : null;
} }
public MResource getResource() { public MResource getResource() {
MResource r = null; MResource r = null;
if(resource.getValue() != null) { if(resource.getValue() != null) {
r = MResource.get(Env.getCtx(), ((Integer)resource.getValue()).intValue());
r = new MResource(Env.getCtx(), ((Integer)resource.getValue()).intValue(), null);
} }
return r; return r;
} }
public MUOM getTargetUOM() { public MUOM getTargetUOM() {
MUOM u = null; MUOM u = null;
if(resource.getValue() != null) { if(resource.getValue() != null) {
u = MUOM.get(Env.getCtx(), ((Integer)resource.getValue()).intValue());
u = new MUOM(Env.getCtx(), ((Integer)resource.getValue()).intValue(), null);
} }
return u; return u;
} }

View File

@ -205,10 +205,10 @@ implements FormPanel, ActionListener
if (date != null && S_Resource_ID != 0) if (date != null && S_Resource_ID != 0)
{ {
System.out.println("Call createDataset(date,S_Resource_ID)"); System.out.println("Call createDataset(date,S_Resource_ID)");
MResource r = new MResource (Env.getCtx(), S_Resource_ID, null); MResource r = MResource.get(Env.getCtx(), S_Resource_ID);
// Ge<EFBFBD>ndert Anfang 04.08.2005 // Ge<EFBFBD>ndert Anfang 04.08.2005
int uom_id = r.getResourceType().getC_UOM_ID(); int uom_id = r.getResourceType().getC_UOM_ID();
MUOM uom = new MUOM(Env.getCtx(),uom_id,null); MUOM uom = MUOM.get(Env.getCtx(),uom_id);
CategoryDataset dataset = null; CategoryDataset dataset = null;
if(uom.isHour()) { if(uom.isHour()) {
@ -361,7 +361,7 @@ implements FormPanel, ActionListener
String namesummary = Msg.translate(Env.getCtx(), "Summary"); String namesummary = Msg.translate(Env.getCtx(), "Summary");
String namepossiblecapacity = "Possible Capacity"; String namepossiblecapacity = "Possible Capacity";
MResourceType t = new MResourceType(Env.getCtx(),r.getS_ResourceType_ID(),null); MResourceType t = MResourceType.get(Env.getCtx(),r.getS_ResourceType_ID());
DefaultCategoryDataset dataset = new DefaultCategoryDataset(); DefaultCategoryDataset dataset = new DefaultCategoryDataset();
@ -533,7 +533,7 @@ implements FormPanel, ActionListener
System.out.println("\n Nameload :"+nameload); System.out.println("\n Nameload :"+nameload);
String namesummary = Msg.translate(Env.getCtx(), "Summary"); String namesummary = Msg.translate(Env.getCtx(), "Summary");
System.out.println("\n Namesummary :"+namesummary); System.out.println("\n Namesummary :"+namesummary);
MResourceType t = new MResourceType(Env.getCtx(),r.getS_ResourceType_ID(),null); MResourceType t = MResourceType.get(Env.getCtx(),r.getS_ResourceType_ID());
System.out.println("\n Resourcetype "+t); System.out.println("\n Resourcetype "+t);
int days = 1; int days = 1;
long hours = 0; long hours = 0;
@ -547,7 +547,7 @@ implements FormPanel, ActionListener
// Long Hours = new Long(hours); // Long Hours = new Long(hours);
int C_UOM_ID = DB.getSQLValue(null,"SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? " , r.getS_Resource_ID()); int C_UOM_ID = DB.getSQLValue(null,"SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? " , r.getS_Resource_ID());
MUOM uom = new MUOM(Env.getCtx(),C_UOM_ID,null); MUOM uom = MUOM.get(Env.getCtx(),C_UOM_ID);
System.out.println("\n uom1 "+uom+"\n"); System.out.println("\n uom1 "+uom+"\n");
//System.out.println("um.isHour()"+ uom.isHour() ); //System.out.println("um.isHour()"+ uom.isHour() );
if (!uom.isHour()) if (!uom.isHour())

View File

@ -983,7 +983,7 @@ public class VMRPDetailed extends CPanel implements FormPanel, ActionListener, V
if (rs.next()) if (rs.next())
{ {
UOM = rs.getInt(1); UOM = rs.getInt(1);
MUOM um = new MUOM(Env.getCtx(),UOM, null); MUOM um = MUOM.get(Env.getCtx(),UOM);
KeyNamePair kum = new KeyNamePair(um.getC_UOM_ID(),um.getName()); KeyNamePair kum = new KeyNamePair(um.getC_UOM_ID(),um.getName());
fUOM.setText(kum.toString()); fUOM.setText(kum.toString());

View File

@ -174,7 +174,7 @@ public abstract class BOMTreeFactory implements BOMTreeModel {
if(node.getUserObject() instanceof MPPOrder) { if(node.getUserObject() instanceof MPPOrder) {
MPPOrder o = (MPPOrder)node.getUserObject(); MPPOrder o = (MPPOrder)node.getUserObject();
MResource r = new MResource(Env.getCtx(), o.getS_Resource_ID(), null); MResource r = MResource.get(Env.getCtx(), o.getS_Resource_ID());
name = o.getDocumentNo()+" ("+r.getName()+")"; name = o.getDocumentNo()+" ("+r.getName()+")";
} }

View File

@ -105,7 +105,7 @@ public class CreateRfQAction extends ProcessPopupAction {
BOMWrapper bom = (BOMWrapper)node.getUserObject(); BOMWrapper bom = (BOMWrapper)node.getUserObject();
MPPOrder mo = new MPPOrder(Env.getCtx(), bom.getPP_Order_ID(), null); MPPOrder mo = new MPPOrder(Env.getCtx(), bom.getPP_Order_ID(), null);
MResource r = new MResource(Env.getCtx(), mo.getS_Resource_ID(), null); MResource r = MResource.get(Env.getCtx(), mo.getS_Resource_ID());
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();

View File

@ -55,11 +55,11 @@ public abstract class CRPDatasetFactory extends CRPReasoner implements CRPModel
public static CRPModel get(Timestamp start, Timestamp end, MResource r) { public static CRPModel get(Timestamp start, Timestamp end, MResource r) {
MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null); MResourceType t = MResourceType.get(Env.getCtx(), r.getS_ResourceType_ID());
// Hardcoded UOM ID - 'Minutes' is base unit // UOM ID - 'Minutes' is base unit
final MUOM uom1 = new MUOM(Env.getCtx(), 103, null); final MUOM uom1 = MUOM.get(Env.getCtx(), MUOM.getMinute_UOM_ID(Env.getCtx()));
// Target UOM is the resource type's UOM // Target UOM is the resource type's UOM
final MUOM uom2 = new MUOM(Env.getCtx(), t.getC_UOM_ID(), null); final MUOM uom2 = MUOM.get(Env.getCtx(), t.getC_UOM_ID());
CRPDatasetFactory factory = new CRPDatasetFactory() { CRPDatasetFactory factory = new CRPDatasetFactory() {
@ -83,7 +83,7 @@ public abstract class CRPDatasetFactory extends CRPReasoner implements CRPModel
String labelActCap = Msg.translate(Env.getCtx(), "DailyCapacity"); String labelActCap = Msg.translate(Env.getCtx(), "DailyCapacity");
String labelLoadAct = Msg.translate(Env.getCtx(), "ActualLoad"); String labelLoadAct = Msg.translate(Env.getCtx(), "ActualLoad");
MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null); MResourceType t = MResourceType.get(Env.getCtx(), r.getS_ResourceType_ID());
BigDecimal utilization = r.getPercentUtilization(); BigDecimal utilization = r.getPercentUtilization();
BigDecimal dailyCapacity = null; BigDecimal dailyCapacity = null;
@ -127,9 +127,9 @@ public abstract class CRPDatasetFactory extends CRPReasoner implements CRPModel
public BigDecimal calculateLoad(Timestamp dateTime, MResource r, String docStatus) { public BigDecimal calculateLoad(Timestamp dateTime, MResource r, String docStatus) {
MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null); MResourceType t = MResourceType.get(Env.getCtx(), r.getS_ResourceType_ID());
MPPOrderNode[] nodes = getPPOrderNodes(dateTime, r); MPPOrderNode[] nodes = getPPOrderNodes(dateTime, r);
MUOM uom = new MUOM(Env.getCtx(), t.getC_UOM_ID(), null); MUOM uom = MUOM.get(Env.getCtx(), t.getC_UOM_ID());
MPPOrder o = null; MPPOrder o = null;
BigDecimal qtyOpen; BigDecimal qtyOpen;
@ -258,7 +258,7 @@ public abstract class CRPDatasetFactory extends CRPReasoner implements CRPModel
MPPOrderNode on = (MPPOrderNode)node.getUserObject(); MPPOrderNode on = (MPPOrderNode)node.getUserObject();
MPPOrderWorkflow owf = new MPPOrderWorkflow(Env.getCtx(), on.getPP_Order_Workflow_ID(), null); MPPOrderWorkflow owf = new MPPOrderWorkflow(Env.getCtx(), on.getPP_Order_Workflow_ID(), null);
MResourceType rt = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null); MResourceType rt = MResourceType.get(Env.getCtx(), r.getS_ResourceType_ID());
// no function // no function
//Env.getLanguage(Env.getCtx()).getTimeFormat(); //Env.getLanguage(Env.getCtx()).getTimeFormat();