* removed deprecated classes
* use getSQLValue*Ex
This commit is contained in:
teo_sarca 2009-01-26 08:07:39 +00:00
parent 523a1f1b2d
commit ad44888075
5 changed files with 11 additions and 1979 deletions

View File

@ -1,316 +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. *
* For the text or an alternative of this public license, you may reach us *
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
* Contributor(s): Victor Perez www.e-evolution.com *
*****************************************************************************/
//package org.compiere.mfg.model;
package org.eevolution.model;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.Properties;
import org.compiere.model.CalloutEngine;
import org.compiere.model.GridField;
import org.compiere.model.GridTab;
import org.compiere.util.DB;
import org.compiere.util.Env;
/**
* Order CalloutMRP
*
* @author Victor Perez
* @version $Id: CalloutMRP.java,v 1.11 2004/03/22 07:15:03 vpj-cd Exp $
*/
public class CalloutMRP extends CalloutEngine
{
/** Debug Steps */
private boolean steps = false;
public String OrderLine(Properties ctx, int WindowNo,GridTab mTab, GridField mField, Object value)
{
setCalloutActive(true);
String sql = new String("SELECT mrp.PP_MRP_ID FROM PP_MRP mrp WHERE mrp.C_OrderLine_ID = ? ");
//MOrderLine ol = new MOrderLine(Env.getCtx(), C_OrderLine_ID);
Integer C_OrderLine_ID = (Integer)mTab.getValue("C_OrderLine_ID");
Integer M_Product_ID = (Integer)mTab.getValue("M_Product_ID");
if (C_OrderLine_ID != null)
{
String Desc = (String)mTab.getValue("Description");
Timestamp Today = new Timestamp(System.currentTimeMillis());
String Name = Today.toString();
BigDecimal QtyOrdered = (BigDecimal)mTab.getValue("QtyOrdered");
BigDecimal QtyDelivered = (BigDecimal)mTab.getValue("QtyDelivered");
Timestamp DatePromised = (Timestamp)mTab.getValue("DatePromised");
Timestamp DateOrdered = (Timestamp)mTab.getValue("DateOrdered");
//int M_Product_ID = ((Integer)mTab.getValue("M_Product_ID")).intValue();
int M_Warehouse_ID = ((Integer)mTab.getValue("M_Warehouse_ID")).intValue();
int C_Order_ID = ((Integer)mTab.getValue("C_Order_ID")).intValue();
int C_BPartner_ID = ((Integer)mTab.getValue("C_BPartner_ID")).intValue();
boolean IsSOTrx = "Y".equals(Env.getContext(ctx, WindowNo, "IsSOTrx"));
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement (sql);
pstmt.setInt(1, C_OrderLine_ID.intValue());
ResultSet rs = pstmt.executeQuery ();
while (rs.next())
{
MPPMRP mrp = new MPPMRP(Env.getCtx(), rs.getInt(1),"PP_MRP");
if(QtyOrdered.subtract(QtyDelivered).compareTo(Env.ZERO) > 0)
{
mrp.setDescription(Desc);
mrp.setC_BPartner_ID(C_BPartner_ID);
mrp.setQty(QtyOrdered.subtract(QtyDelivered));
mrp.setDatePromised(DatePromised);
mrp.setDateOrdered(DateOrdered);
mrp.setM_Product_ID(M_Product_ID.intValue());
mrp.setM_Warehouse_ID(M_Warehouse_ID);
mrp.save();
}
else
mrp.delete(true);
}
if (rs.getRow() == 0 && QtyOrdered.subtract(QtyDelivered).compareTo(Env.ZERO) > 0)
{
MPPMRP mrp = new MPPMRP(Env.getCtx(), 0,"PP_MRP");
mrp.setC_OrderLine_ID(C_OrderLine_ID.intValue());
mrp.setC_BPartner_ID(C_BPartner_ID);
mrp.setName(Name);
mrp.setDescription(Desc);
mrp.setC_Order_ID(C_Order_ID);
mrp.setQty(QtyOrdered.subtract(QtyDelivered));
mrp.setDatePromised(DatePromised);
mrp.setDateOrdered(DateOrdered);
mrp.setM_Product_ID(M_Product_ID.intValue());
mrp.setM_Warehouse_ID(M_Warehouse_ID);
//mrp.setS_Resource_ID();
if (IsSOTrx)
{
mrp.setOrderType(MPPMRP.ORDERTYPE_SalesOrder);
mrp.setTypeMRP(MPPMRP.TYPEMRP_Demand);
}
else
{
mrp.setOrderType(MPPMRP.ORDERTYPE_MaterialRequisition);
mrp.setTypeMRP("POO");
mrp.setTypeMRP(MPPMRP.TYPEMRP_Supply);
}
mrp.save();
}
rs.close();
pstmt.close();
}
catch (Exception e)
{
//log.error ("doIt - " + sql, e);
System.out.println("doIt - " + sql + e);
}
} // C_OrderLine_ID != null
return "";
}
public String PPOrder(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
setCalloutActive(true);
String sql = new String("SELECT mrp.PP_MRP_ID FROM PP_MRP mrp WHERE mrp.PP_Order_ID = ? ");
//MOrderLine ol = new MOrderLine(Env.getCtx(), C_OrderLine_ID);
Integer PP_Order_ID = ((Integer)mTab.getValue("PP_Order_ID"));
if (PP_Order_ID != null)
{
String Desc = (String)mTab.getValue("Description");
Timestamp Today = new Timestamp(System.currentTimeMillis());
String Name = Today.toString();
BigDecimal QtyOrdered = (BigDecimal)mTab.getValue("QtyOrdered");
BigDecimal QtyDelivered = (BigDecimal)mTab.getValue("QtyDelivered");
Timestamp DatePromised = (Timestamp)mTab.getValue("DatePromised");
Timestamp DateOrdered = (Timestamp)mTab.getValue("DateOrdered");
int M_Product_ID = ((Integer)mTab.getValue("M_Product_ID")).intValue();
int M_Warehouse_ID = ((Integer)mTab.getValue("M_Warehouse_ID")).intValue();
//int C_Order_ID = ((Integer)mTab.getValue("C_Order_ID")).intValue();
MPPOrder o = new MPPOrder(Env.getCtx(), PP_Order_ID.intValue(),"PP_Order");
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement (sql);
pstmt.setInt(1, PP_Order_ID.intValue());
ResultSet rs = pstmt.executeQuery ();
while (rs.next())
{
MPPMRP mrp = new MPPMRP(Env.getCtx(), rs.getInt(1),"PP_MRP");
if(QtyOrdered.subtract(QtyDelivered).compareTo(Env.ZERO) > 0)
{
mrp.setDescription(Desc);
mrp.setQty(QtyOrdered.subtract(QtyDelivered));
mrp.setDatePromised(DatePromised);
mrp.setDateOrdered(DateOrdered);
mrp.setM_Product_ID(M_Product_ID);
mrp.setM_Warehouse_ID(M_Warehouse_ID);
mrp.save();
}
else
mrp.delete(true);
}
if (rs.getRow() == 0 || QtyOrdered.subtract(QtyDelivered).compareTo(Env.ZERO) > 0)
{
MPPMRP mrp = new MPPMRP(Env.getCtx(), 0,"PP_MRP");
mrp.setPP_Order_ID(PP_Order_ID.intValue());
mrp.setDescription(Desc);
mrp.setName(Name);
//mrp.setC_Order_ID(o.getC_Order_ID());
mrp.setQty(QtyOrdered.subtract(QtyDelivered));
mrp.setDatePromised(DatePromised);
mrp.setDateOrdered(DateOrdered);
mrp.setM_Product_ID(M_Product_ID);
mrp.setM_Warehouse_ID(M_Warehouse_ID);
//mrp.setS_Resource_ID();
mrp.setTypeMRP(MPPMRP.TYPEMRP_Supply);
mrp.setOrderType(MPPMRP.ORDERTYPE_ManufacturingOrder);
mrp.save();
}
rs.close();
pstmt.close();
}
catch (Exception e)
{
//log.error ("doIt - " + sql, e);
System.out.println("doIt - " + sql + e);
}
}
return "";
}
public String PPOrderLine(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
setCalloutActive(true);
String sql = new String("SELECT mrp.PP_MRP_ID FROM PP_MRP mrp WHERE mrp.PP_Order_BOMLine_ID = ? ");
//MOrderLine ol = new MOrderLine(Env.getCtx(), C_OrderLine_ID);
Integer PP_Order_BOMLine_ID = ((Integer)mTab.getValue("PP_Order_ID"));
if (PP_Order_BOMLine_ID != null)
{
String Desc = (String)mTab.getValue("Description");
Timestamp Today = new Timestamp(System.currentTimeMillis());
String Name = Today.toString();
BigDecimal QtyRequiered = (BigDecimal)mTab.getValue("QtyRequiered");
BigDecimal QtyDelivered = (BigDecimal)mTab.getValue("QtyDelivered");
Timestamp DatePromised = (Timestamp)mTab.getValue("DatePromised");
Timestamp DateOrdered = (Timestamp)mTab.getValue("DateOrdered");
int M_Product_ID = ((Integer)mTab.getValue("M_Product_ID")).intValue();
int M_Warehouse_ID = ((Integer)mTab.getValue("M_Warehouse_ID")).intValue();
MPPOrderBOMLine ol = new MPPOrderBOMLine(Env.getCtx(), PP_Order_BOMLine_ID.intValue(),"PP_Order_BOM_Line");
MPPOrder o = new MPPOrder(Env.getCtx(), ol.getPP_Order_ID(),"PP_Order");
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement (sql);
pstmt.setInt(1, PP_Order_BOMLine_ID.intValue());
ResultSet rs = pstmt.executeQuery ();
while (rs.next())
{
MPPMRP mrp = new MPPMRP(Env.getCtx(), rs.getInt(1),"PP_MRP");
if(QtyRequiered.subtract(QtyDelivered).compareTo(Env.ZERO) > 0)
{
mrp.setDescription(o.getDescription());
mrp.setQty(ol.getQtyRequiered().subtract(ol.getQtyDelivered()));
mrp.setDatePromised(o.getDatePromised());
mrp.setDateOrdered(o.getDateOrdered());
mrp.setM_Product_ID(ol.getM_Product_ID());
mrp.setM_Warehouse_ID(ol.getM_Warehouse_ID());
mrp.save();
}
else
mrp.delete(true);
}
if (rs.getRow() == 0 || QtyRequiered.subtract(QtyDelivered).compareTo(Env.ZERO) > 0)
{
MPPMRP mrp = new MPPMRP(Env.getCtx(), 0,"PP_MRP");
//MOrder o = new MOrder(Env.getCtx(), ol.getC_Order_ID());
mrp.setPP_Order_BOMLine_ID(PP_Order_BOMLine_ID.intValue());
mrp.setDescription(Desc);
mrp.setName(Name);
mrp.setPP_Order_ID(o.getPP_Order_ID());
mrp.setQty(QtyRequiered.subtract(QtyDelivered));
mrp.setDatePromised(DatePromised);
mrp.setDateOrdered(DateOrdered);
mrp.setM_Product_ID(M_Product_ID);
mrp.setM_Warehouse_ID(M_Warehouse_ID);
//mrp.setS_Resource_ID();
mrp.setOrderType(MPPMRP.TYPEMRP_Demand);
mrp.setOrderType(MPPMRP.ORDERTYPE_ManufacturingOrder);
mrp.save();
}
rs.close();
pstmt.close();
}
catch (Exception e)
{
//log.error ("doIt - " + sql, e);
System.out.println("doIt - " + sql + e);
}
}
return "";
}
}

View File

@ -13,11 +13,7 @@
*****************************************************************************/
package org.eevolution.model;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.model.CalloutEngine;
import org.compiere.model.GridField;
@ -33,75 +29,18 @@ import org.compiere.util.DB;
*/
public class CalloutPayroll extends CalloutEngine
{
/**
* Payroll
*/
public String ColumnType (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
if (value == null )
if (value == null)
return "";
Integer HR_Concept_ID = (Integer) value;
if ( HR_Concept_ID == null || HR_Concept_ID.intValue() == 0)
final int HR_Concept_ID = (Integer) value;
if (HR_Concept_ID == 0)
return "";
mTab.setValue("ColumnType",DB.getSQLValueString("HR_Concept",
"SELECT ColumnType FROM HR_Concept WHERE HR_Concept_ID=?",HR_Concept_ID.intValue()) );
//
final String columnType = DB.getSQLValueStringEx(null,
"SELECT ColumnType FROM HR_Concept WHERE HR_Concept_ID=?",
HR_Concept_ID);
mTab.setValue(MHRAttribute.COLUMNNAME_ColumnType, columnType);
return "";
}
/**
* HRProcess Change - DocType.
* @param ctx Context
* @param WindowNo current Window No
* @param mTab Model Tab
* @param mField Model Field
* @param value The new value
* @return Error message or ""
*/
public String docType (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
Integer C_DocType_ID = (Integer)value; // Actually C_DocTypeTarget_ID
if (C_DocType_ID == null || C_DocType_ID.intValue() == 0)
return "";
// Re-Create new DocNo, if there is a doc number already
// and the existing source used a different Sequence number
String oldDocNo = (String)mTab.getValue("DocumentNo");
boolean newDocNo = (oldDocNo == null);
if (!newDocNo && oldDocNo.startsWith("<") && oldDocNo.endsWith(">"))
newDocNo = true;
Integer oldC_DocType_ID = (Integer)mTab.getValue("C_DocType_ID");
String sql = "SELECT d.DocSubTypeSO,d.HasCharges,'N'," // 1..3
+ "d.IsDocNoControlled,s.CurrentNext,s.CurrentNextSys," // 4..6
+ "s.AD_Sequence_ID,d.IsSOTrx " // 7..8
+ "FROM C_DocType d, AD_Sequence s "
+ "WHERE C_DocType_ID=?" // #1
+ " AND d.DocNoSequence_ID=s.AD_Sequence_ID(+)";
try
{
int AD_Sequence_ID = 0;
// Get old AD_SeqNo for comparison
if (!newDocNo && oldC_DocType_ID.intValue() != 0)
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, oldC_DocType_ID.intValue());
ResultSet rs = pstmt.executeQuery();
if (rs.next())
AD_Sequence_ID = rs.getInt(6);
rs.close();
pstmt.close();
}
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_DocType_ID.intValue());
ResultSet rs = pstmt.executeQuery();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
return e.getLocalizedMessage();
}
return "";
} // docType
} // CalloutPayroll

File diff suppressed because it is too large Load Diff

View File

@ -1,121 +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. *
* For the text or an alternative of this public license, you may reach us *
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
* Contributor(s): Victor Perez www.e-evolution.com *
*****************************************************************************/
package org.eevolution.model;
// import for GenericPO
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.util.Properties;
import org.compiere.model.DocWorkflowMgr;
import org.compiere.model.PO;
import org.compiere.model.POInfo;
import org.compiere.util.CLogger;
public class GenericPO extends PO {
//private Logger log = Logger.getCLogger(getClass());
/** Standard Constructor */
public GenericPO (Properties ctx, int ID , String trxName)
{
super (ctx, ID, trxName);
}
/** Load Constructor */
public GenericPO (Properties ctx, ResultSet rs,String trxName)
{
super (ctx, rs,trxName);
}
/** Document Value Workflow Manager */
private static DocWorkflowMgr s_docWFMgr = null;
/**
* Set Document Value Workflow Manager
* @param docWFMgr mgr
*/
public static void setDocWorkflowMgr (DocWorkflowMgr docWFMgr)
{
s_docWFMgr = docWFMgr;
s_log.config (s_docWFMgr.toString());
} // setDocWorkflowMgr
private int Table_ID = 0;
protected BigDecimal accessLevel = new BigDecimal(3);
/** Logger */
protected transient CLogger log = CLogger.getCLogger (getClass());
/** Static Logger */
private static CLogger s_log = CLogger.getCLogger (PO.class);
/** AccessLevel 3 - Client - Org */
protected int get_AccessLevel()
{
return accessLevel.intValue();
}
/** Load Meta Data */
protected POInfo initPO (Properties ctx)
{
Table_ID = Integer.valueOf(ctx.getProperty("compieredataTable_ID")).intValue();
//log.info("Table_ID: "+Table_ID);
POInfo poi = POInfo.getPOInfo (ctx, Table_ID);
return poi;
}
public String toString()
{
StringBuffer sb = new StringBuffer ("GenericPO[Table=").append(""+Table_ID+",ID=").append(get_ID()).append("]");
return sb.toString();
}
public static final int AD_ORGTRX_ID_AD_Reference_ID=130;
/** Set Trx Organization.
Performing or initiating organization */
public void setAD_OrgTrx_ID (int AD_OrgTrx_ID)
{
if (AD_OrgTrx_ID == 0) set_Value ("AD_OrgTrx_ID", null);
else
set_Value ("AD_OrgTrx_ID", new Integer(AD_OrgTrx_ID));
}
/** Get Trx Organization.
Performing or initiating organization */
public int getAD_OrgTrx_ID()
{
Integer ii = (Integer)get_Value("AD_OrgTrx_ID");
if (ii == null) return 0;
return ii.intValue();
}
// setValue
public void setValue(String columnName, Object value) {
set_Value(columnName, value);
}
// setValueNoCheck
public void setValueNoCheck(String columnName, Object value) {
set_ValueNoCheck(columnName, value);
}
// setValue
public void setValue(int index, Object value) {
set_Value(index, value);
}
public void setDocWorkflowMgr()
{
}
} // GenericPO

View File

@ -87,7 +87,7 @@ public class MHRYear extends X_HR_Year
public boolean createPeriods()
{
int sumDays = 0;
int C_Calendar_ID = DB.getSQLValue(get_TrxName(), "SELECT C_Calendar_ID FROM C_Year WHERE C_Year_ID = ?", getC_Year_ID());
int C_Calendar_ID = DB.getSQLValueEx(get_TrxName(), "SELECT C_Calendar_ID FROM C_Year WHERE C_Year_ID = ?", getC_Year_ID());
if (C_Calendar_ID <= 0)
return false;
@ -97,7 +97,7 @@ public class MHRYear extends X_HR_Year
sumDays = period != 1 ? (period-1) * (getNetDays()) : 0;
Timestamp StartDate = TimeUtil.addDays(getStartDate(),sumDays);
Timestamp EndDate = TimeUtil.addDays(StartDate,getNetDays()-1);
int C_Period_ID = DB.getSQLValue(get_TrxName(),
int C_Period_ID = DB.getSQLValueEx(get_TrxName(),
"SELECT C_Period_ID FROM C_Period p "
+ " INNER JOIN C_Year y ON (p.C_Year_ID=y.C_Year_ID) "
+ " WHERE "
@ -108,7 +108,7 @@ public class MHRYear extends X_HR_Year
return false;
MPeriod m_period = MPeriod.get(getCtx(), C_Period_ID, payroll.getAD_Org_ID());
X_HR_Period HR_Period = new X_HR_Period(getCtx(), 0, get_TrxName());
MHRPeriod HR_Period = new MHRPeriod(getCtx(), 0, get_TrxName());
HR_Period.setAD_Org_ID(getAD_Org_ID());
HR_Period.setHR_Year_ID(getHR_Year_ID());
HR_Period.setHR_Payroll_ID(getHR_Payroll_ID());