IDEMPIERE-4199 Clean up org.adempiere.extend
This commit is contained in:
parent
895f766307
commit
9ed3e2e0df
|
@ -6,8 +6,7 @@ Bundle-Version: 7.1.0.qualifier
|
|||
Eclipse-RegisterBuddy: org.adempiere.tools
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version>=11))"
|
||||
Export-Package: compiere.model,
|
||||
test
|
||||
Export-Package: test
|
||||
Fragment-Host: org.adempiere.base;bundle-version="0.0.0"
|
||||
Eclipse-PatchFragment: true
|
||||
Import-Package: junit.framework;version="3.8.2",
|
||||
|
|
|
@ -1,244 +0,0 @@
|
|||
/******************************************************************************
|
||||
* 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 compiere.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;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
* User Callout Example.
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: CalloutUser.java,v 1.2 2006/07/30 00:51:57 jjanke Exp $
|
||||
*/
|
||||
public class CalloutUser extends CalloutEngine
|
||||
{
|
||||
/**
|
||||
* JustAnExample.
|
||||
* The string in the Callout field is:
|
||||
* <code>com.adempiere.custom.CalloutEngine.justAnExample</code>
|
||||
*
|
||||
* @param ctx Context
|
||||
* @param WindowNo current Window No
|
||||
* @param mTab Model Tab
|
||||
* @param mField Model Field
|
||||
* @param value The new value
|
||||
* @param oldValue The old value
|
||||
* @return error message or "" if OK
|
||||
*/
|
||||
public String justAnExample (Properties ctx, int WindowNo,
|
||||
GridTab mTab, GridField mField, Object value, Object oldValue)
|
||||
{
|
||||
log.info("JustAnExample");
|
||||
return "";
|
||||
} // justAnExample
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Invoice Header- BPartner.
|
||||
* - C_BPartner_Location_ID
|
||||
* - AD_User_ID
|
||||
* @param ctx Context
|
||||
* @param WindowNo current Window No
|
||||
* @param mTab Model Tab
|
||||
* @param mField Model Field
|
||||
* @param value The new value
|
||||
* @param oldValue The old value
|
||||
* @return error message
|
||||
*/
|
||||
public String bPartner (Properties ctx, int WindowNo,
|
||||
GridTab mTab, GridField mField, Object value, Object oldValue)
|
||||
{
|
||||
Integer C_BPartner_ID = (Integer)value;
|
||||
if (C_BPartner_ID == null || C_BPartner_ID.intValue() == 0)
|
||||
return "";
|
||||
|
||||
String sql = "SELECT p.AD_Language,p.C_PaymentTerm_ID,"
|
||||
+ " COALESCE(p.M_PriceList_ID,g.M_PriceList_ID) AS M_PriceList_ID, p.PaymentRule,p.POReference,"
|
||||
+ " p.SO_Description,p.IsDiscountPrinted,"
|
||||
+ " p.SO_CreditLimit, p.SO_CreditLimit-p.SO_CreditUsed AS CreditAvailable,"
|
||||
+ " l.C_BPartner_Location_ID,c.AD_User_ID,"
|
||||
+ " COALESCE(p.PO_PriceList_ID,g.PO_PriceList_ID) AS PO_PriceList_ID, p.PaymentRulePO,p.PO_PaymentTerm_ID "
|
||||
+ "FROM C_BPartner p"
|
||||
+ " INNER JOIN C_BP_Group g ON (p.C_BP_Group_ID=g.C_BP_Group_ID)"
|
||||
+ " LEFT OUTER JOIN C_BPartner_Location l ON (p.C_BPartner_ID=l.C_BPartner_ID AND l.IsBillTo='Y' AND l.IsActive='Y')"
|
||||
+ " LEFT OUTER JOIN AD_User c ON (p.C_BPartner_ID=c.C_BPartner_ID) "
|
||||
+ "WHERE p.C_BPartner_ID=? AND p.IsActive='Y'"; // #1
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, C_BPartner_ID.intValue());
|
||||
rs = pstmt.executeQuery();
|
||||
//
|
||||
if (rs.next())
|
||||
{
|
||||
// Location
|
||||
int locID = rs.getInt("C_BPartner_Location_ID");
|
||||
// overwritten by InfoBP selection - works only if InfoWindow
|
||||
// was used otherwise creates error (uses last value, may belong to differnt BP)
|
||||
if (C_BPartner_ID.toString().equals(Env.getContext(ctx, WindowNo, Env.TAB_INFO, "C_BPartner_ID")))
|
||||
{
|
||||
String loc = Env.getContext(ctx, WindowNo, Env.TAB_INFO, "C_BPartner_Location_ID");
|
||||
if (loc.length() > 0)
|
||||
locID = Integer.parseInt(loc);
|
||||
}
|
||||
if (locID == 0)
|
||||
mTab.setValue("C_BPartner_Location_ID", null);
|
||||
else
|
||||
mTab.setValue("C_BPartner_Location_ID", Integer.valueOf(locID));
|
||||
|
||||
// Contact - overwritten by InfoBP selection
|
||||
int contID = rs.getInt("AD_User_ID");
|
||||
if (C_BPartner_ID.toString().equals(Env.getContext(ctx, WindowNo, Env.TAB_INFO, "C_BPartner_ID")))
|
||||
{
|
||||
String cont = Env.getContext(ctx, WindowNo, Env.TAB_INFO, "AD_User_ID");
|
||||
if (cont.length() > 0)
|
||||
contID = Integer.parseInt(cont);
|
||||
}
|
||||
if (contID == 0)
|
||||
mTab.setValue("AD_User_ID", null);
|
||||
else
|
||||
mTab.setValue("AD_User_ID", Integer.valueOf(contID));
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
return e.getLocalizedMessage();
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
|
||||
return "";
|
||||
} // bPartner
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Frie Value - convert to standardized Name
|
||||
*
|
||||
* @param value Name
|
||||
* @return Name
|
||||
*/
|
||||
public String Frie_Name (String value)
|
||||
{
|
||||
if (value == null || value.length() == 0)
|
||||
return "";
|
||||
//
|
||||
String retValue = value;
|
||||
String SQL = "SELECT FRIE_Name(?) FROM DUAL";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(SQL, null);
|
||||
pstmt.setString(1, value);
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
retValue = rs.getString(1);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, SQL, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
return retValue;
|
||||
} // Frie_Name
|
||||
|
||||
|
||||
/**
|
||||
* Frie Value - convert Name to Value
|
||||
*
|
||||
* @param value Name
|
||||
* @return Value of Name
|
||||
*/
|
||||
public String Frie_Value (String value)
|
||||
{
|
||||
if (value == null || value.length() == 0)
|
||||
return "";
|
||||
//
|
||||
String retValue = value;
|
||||
String SQL = "SELECT FRIE_Value(FRIE_Name(?)) FROM DUAL";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(SQL, null);
|
||||
pstmt.setString(1, value);
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
retValue = rs.getString(1);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, SQL, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs,pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
return retValue;
|
||||
} // Frie_Value
|
||||
|
||||
|
||||
/**
|
||||
* Frie Status - convert to Status.
|
||||
*
|
||||
* @param value value
|
||||
* @return Status
|
||||
*/
|
||||
public String Frie_Status (String value)
|
||||
{
|
||||
String retValue = "N"; // default
|
||||
if (value != null && value.equals("A")) // Auslaufartikel
|
||||
retValue = "Y"; //
|
||||
return retValue;
|
||||
} // Frie_Status
|
||||
|
||||
} // CalloutUser
|
|
@ -1,63 +0,0 @@
|
|||
/******************************************************************************
|
||||
* The contents of this file are subject to the Adempiere 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.adempiere.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 Adempiere ERP & CRM Smart Business Solution. The Initial
|
||||
* Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
|
||||
* are Copyright (C) 1999-2006 Jorg Janke.
|
||||
* All parts are Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.
|
||||
* Contributor(s): ______________________________________.
|
||||
*****************************************************************************/
|
||||
package adempiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Visit Business Model
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: MVisit.java.txt,v 1.1 2006/04/21 17:55:19 jjanke Exp $
|
||||
*/
|
||||
public class MVisit extends X_XX_Visit
|
||||
{
|
||||
/**
|
||||
* Standard Constructor
|
||||
* @param ctx context
|
||||
* @param XX_Visit_ID id
|
||||
* @param trxName transaction
|
||||
*/
|
||||
public MVisit(Properties ctx, int XX_Visit_ID, String trxName)
|
||||
{
|
||||
super(ctx, XX_Visit_ID, trxName);
|
||||
} // MVisit
|
||||
|
||||
/**
|
||||
* Load Constructor
|
||||
* @param ctx context
|
||||
* @param rs result set
|
||||
* @param trxName transaction
|
||||
*/
|
||||
public MVisit(Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super(ctx, rs, trxName);
|
||||
} // MVisit
|
||||
|
||||
/**
|
||||
* Before Save "Trigger"
|
||||
* @param newRecord new
|
||||
* @return true if can be saved
|
||||
*/
|
||||
protected boolean beforeSave(boolean newRecord)
|
||||
{
|
||||
// Invoice at least 5 minutes
|
||||
if (newRecord && getMinutes() < 5)
|
||||
setMinutes(5);
|
||||
|
||||
return true;
|
||||
} // beforeSave
|
||||
|
||||
} // MVisit
|
|
@ -1,90 +0,0 @@
|
|||
/******************************************************************************
|
||||
* 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 compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.model.POInfo;
|
||||
|
||||
|
||||
/**
|
||||
* This is a non-working example of a Persistent Business Object.
|
||||
* You would extend the class generated by GenerateModel.java
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: MyModelExample.java,v 1.2 2006/07/30 00:51:57 jjanke Exp $
|
||||
*/
|
||||
public class MyModelExample extends PO
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7122834919952485992L;
|
||||
|
||||
/**
|
||||
* Standard constructor.
|
||||
* You must implement this constructor for Adempiere Persistency
|
||||
* @param ctx context
|
||||
* @param ID the primary key ID
|
||||
* @param trxName transaction
|
||||
*/
|
||||
public MyModelExample (Properties ctx, int ID, String trxName)
|
||||
{
|
||||
super (ctx, ID, trxName);
|
||||
} // MyModelExample
|
||||
|
||||
/**
|
||||
* Optional Load Constructor.
|
||||
* You would use this constructor to load several business objects.
|
||||
* <code>
|
||||
* SELECT * FROM MyModelExample WHERE ...
|
||||
* </code>
|
||||
* @param ctx context
|
||||
* @param rs result set
|
||||
* @param trxName transaction
|
||||
*/
|
||||
public MyModelExample (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super (ctx, rs, trxName);
|
||||
} // MyModelExample
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Init Persistent Object.
|
||||
* You would NOT create this method as it is created by the persistency
|
||||
* class generated by GenerateModel.java
|
||||
* @param ctx context
|
||||
* @return PO information
|
||||
*/
|
||||
protected POInfo initPO (Properties ctx)
|
||||
{
|
||||
return null;
|
||||
} // initPO
|
||||
|
||||
/**
|
||||
* Get Access Level
|
||||
* @return access level
|
||||
*/
|
||||
protected int get_AccessLevel()
|
||||
{
|
||||
return 0;
|
||||
} // get_AccessLevel
|
||||
|
||||
} // MyModelExample
|
|
@ -1,263 +0,0 @@
|
|||
/******************************************************************************
|
||||
* 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 compiere.model;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MClient;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.ModelValidationEngine;
|
||||
import org.compiere.model.ModelValidator;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
|
||||
/**
|
||||
* Validator Example Implementation
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: MyValidator.java,v 1.2 2006/07/30 00:51:57 jjanke Exp $
|
||||
*/
|
||||
public class MyValidator implements ModelValidator
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public MyValidator ()
|
||||
{
|
||||
super ();
|
||||
} // MyValidator
|
||||
|
||||
/** Logger */
|
||||
private static final CLogger log = CLogger.getCLogger(MyValidator.class);
|
||||
/** Client */
|
||||
private int m_AD_Client_ID = -1;
|
||||
/** User */
|
||||
private int m_AD_User_ID = -1;
|
||||
/** Role */
|
||||
private int m_AD_Role_ID = -1;
|
||||
|
||||
/**
|
||||
* Initialize Validation
|
||||
* @param engine validation engine
|
||||
* @param client client
|
||||
*/
|
||||
public void initialize (ModelValidationEngine engine, MClient client)
|
||||
{
|
||||
//client = null for global validator
|
||||
if (client != null) {
|
||||
m_AD_Client_ID = client.getAD_Client_ID();
|
||||
if (log.isLoggable(Level.INFO)) log.info(client.toString());
|
||||
}
|
||||
else {
|
||||
if (log.isLoggable(Level.INFO)) log.info("Initializing global validator: "+this.toString());
|
||||
}
|
||||
|
||||
// We want to be informed when C_Order is created/changed
|
||||
engine.addModelChange(MOrder.Table_Name, this);
|
||||
// We want to validate Order before preparing
|
||||
engine.addDocValidate(MOrder.Table_Name, this);
|
||||
} // initialize
|
||||
|
||||
/**
|
||||
* Model Change of a monitored Table.
|
||||
* Called after PO.beforeSave/PO.beforeDelete
|
||||
* when you called addModelChange for the table
|
||||
* @param po persistent object
|
||||
* @param type TYPE_
|
||||
* @return error message or null
|
||||
* @exception Exception if the recipient wishes the change to be not accept.
|
||||
*/
|
||||
public String modelChange (PO po, int type) throws Exception
|
||||
{
|
||||
if (po.get_TableName().equals("C_Order") && type == TYPE_CHANGE)
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
MOrder order = (MOrder)po;
|
||||
if (log.isLoggable(Level.INFO)) log.info(po.toString());
|
||||
}
|
||||
return null;
|
||||
} // modelChange
|
||||
|
||||
/**
|
||||
* Validate Document.
|
||||
* Called as first step of DocAction.prepareIt
|
||||
* when you called addDocValidate for the table.
|
||||
* Note that totals, etc. may not be correct.
|
||||
* @param po persistent object
|
||||
* @param timing see TIMING_ constants
|
||||
* @return error message or null
|
||||
*/
|
||||
public String docValidate (PO po, int timing)
|
||||
{
|
||||
if (log.isLoggable(Level.INFO)) log.info(po.get_TableName() + " Timing: "+timing);
|
||||
|
||||
// Ignore all after Complete events
|
||||
if (timing == TIMING_AFTER_COMPLETE)
|
||||
return null;
|
||||
|
||||
if (timing == TIMING_BEFORE_PREPARE) {
|
||||
if (po.get_TableName().equals(MOrder.Table_Name))
|
||||
{
|
||||
/** Order Discount Example *
|
||||
MOrder order = (MOrder)po;
|
||||
String error = orderDiscount(order);
|
||||
if (error != null)
|
||||
return error;
|
||||
/** Order Discount Example */
|
||||
if (log.isLoggable(Level.INFO)) log.info(po.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
} // docValidate
|
||||
|
||||
/**
|
||||
* Order Discount.
|
||||
* Make sure that last line is discount and check correctness
|
||||
* @param order order
|
||||
* @return error message or null
|
||||
*/
|
||||
/*private String orderDiscount (MOrder order)
|
||||
{
|
||||
String DISCOUNT = "Discount";
|
||||
int C_Tax_ID = 0;
|
||||
BigDecimal totalLines = Env.ZERO;
|
||||
MOrderLine discountLine = null;
|
||||
//
|
||||
MOrderLine[] lines = order.getLines();
|
||||
for (int i = 0; i < lines.length; i++)
|
||||
{
|
||||
MOrderLine oLine = lines[i];
|
||||
String description = oLine.getDescription();
|
||||
if (description != null && description.equals(DISCOUNT))
|
||||
discountLine = oLine;
|
||||
else
|
||||
{
|
||||
totalLines = totalLines.add(oLine.getLineNetAmt());
|
||||
if (C_Tax_ID == 0)
|
||||
C_Tax_ID = oLine.getC_Tax_ID();
|
||||
else if (C_Tax_ID != oLine.getC_Tax_ID())
|
||||
return "Order has more then one Tax, cannot add discount";
|
||||
}
|
||||
}
|
||||
if (discountLine == null)
|
||||
{
|
||||
discountLine = new MOrderLine(order);
|
||||
discountLine.setDescription(DISCOUNT);
|
||||
discountLine.setQty(Env.ONE);
|
||||
discountLine.setC_Tax_ID(C_Tax_ID);
|
||||
discountLine.setLine(9999);
|
||||
}
|
||||
// Calculate Discount
|
||||
BigDecimal discountPercent = new BigDecimal(3); // 3% example
|
||||
BigDecimal discountAmt = totalLines.multiply(discountPercent);
|
||||
discountAmt = discountAmt.divide(Env.ONEHUNDRED, order.getPrecision(), RoundingMode.HALF_UP);
|
||||
discountLine.setPrice(discountAmt.negate());
|
||||
if (!discountLine.save())
|
||||
return "Could not save discount line";
|
||||
|
||||
if (log.isLoggable(Level.INFO)) log.info(discountLine.toString());
|
||||
order.getLines(true, null);
|
||||
return null;
|
||||
} // orderDiscount*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* User Login.
|
||||
* Called when preferences are set
|
||||
* @param AD_Org_ID org
|
||||
* @param AD_Role_ID role
|
||||
* @param AD_User_ID user
|
||||
* @return error message or null
|
||||
*/
|
||||
public String login (int AD_Org_ID, int AD_Role_ID, int AD_User_ID)
|
||||
{
|
||||
if (log.isLoggable(Level.INFO)) log.info("AD_User_ID=" + AD_User_ID);
|
||||
m_AD_User_ID = AD_User_ID;
|
||||
m_AD_Role_ID = AD_Role_ID;
|
||||
return null;
|
||||
} // login
|
||||
|
||||
/**
|
||||
* Get Client to be monitored
|
||||
* @return AD_Client_ID client
|
||||
*/
|
||||
public int getAD_Client_ID()
|
||||
{
|
||||
return m_AD_Client_ID;
|
||||
} // getAD_Client_ID
|
||||
|
||||
|
||||
/**
|
||||
* String Representation
|
||||
* @return info
|
||||
*/
|
||||
public String toString ()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ("MyValidator[Order@Gardenworld");
|
||||
sb.append ("]");
|
||||
return sb.toString ();
|
||||
} // toString
|
||||
|
||||
/**
|
||||
* Sample Validator BefoMRolere Save Properties - to set mandatory properties on users
|
||||
* avoid users changing properties
|
||||
*/
|
||||
public void beforeSaveProperties() {
|
||||
// not for SuperUser or role SysAdmin
|
||||
if ( m_AD_User_ID == 0 // System
|
||||
|| m_AD_User_ID == 100 // SuperUser
|
||||
|| m_AD_Role_ID == 0) // System Administrator
|
||||
|
||||
return;
|
||||
|
||||
log.info("Setting default Properties");
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
MRole role = MRole.get(Env.getCtx(), m_AD_Role_ID);
|
||||
|
||||
// Example - if you don't want user to select auto commit property
|
||||
// Ini.setProperty(Ini.P_A_COMMIT, false);
|
||||
|
||||
// Example - if you don't want user to select auto login
|
||||
// Ini.setProperty(Ini.P_A_LOGIN, false);
|
||||
|
||||
// Example - if you don't want user to select store password
|
||||
// Ini.setProperty(Ini.P_STORE_PWD, false);
|
||||
|
||||
// Example - if you want your user inherit ALWAYS the show accounting from role
|
||||
// Ini.setProperty(Ini.P_SHOW_ACCT, role.isShowAcct());
|
||||
|
||||
// Example - if you want to avoid your user from changing the working date
|
||||
/*
|
||||
Timestamp DEFAULT_TODAY = new Timestamp(System.currentTimeMillis());
|
||||
// Date (remove seconds)
|
||||
DEFAULT_TODAY.setHours(0);
|
||||
DEFAULT_TODAY.setMinutes(0);
|
||||
DEFAULT_TODAY.setSeconds(0);
|
||||
DEFAULT_TODAY.setNanos(0);
|
||||
Ini.setProperty(Ini.P_TODAY, DEFAULT_TODAY.toString());
|
||||
Env.setContext(Env.getCtx(), "#Date", DEFAULT_TODAY);
|
||||
*/
|
||||
|
||||
} // beforeSaveProperties
|
||||
|
||||
} // MyValidator
|
|
@ -1,96 +0,0 @@
|
|||
/******************************************************************************
|
||||
* The contents of this file are subject to the Adempiere 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.adempiere.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 Adempiere ERP & CRM Smart Business Solution. The Initial
|
||||
* Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
|
||||
* are Copyright (C) 1999-2006 Jorg Janke.
|
||||
* All parts are Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.
|
||||
* Contributor(s): ______________________________________.
|
||||
*****************************************************************************/
|
||||
package adempiere.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.process.SvrProcess;
|
||||
import org.compiere.util.AdempiereSystemError;
|
||||
import org.compiere.util.AdempiereUserError;
|
||||
|
||||
/**
|
||||
* Generate Invoice for Visit Process
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: XXVisitInvoice.java.txt,v 1.1 2006/04/21 17:55:19 jjanke Exp $
|
||||
*/
|
||||
public class XXVisitInvoice extends SvrProcess
|
||||
{
|
||||
/** Parameter */
|
||||
private int p_XX_Visit_ID = 0;
|
||||
|
||||
/**
|
||||
* Prepare
|
||||
* @see org.compiere.process.SvrProcess#prepare()
|
||||
*/
|
||||
protected void prepare()
|
||||
{
|
||||
p_XX_Visit_ID = getRecord_ID();
|
||||
} // prepare
|
||||
|
||||
/**
|
||||
* Process
|
||||
* @see org.compiere.process.SvrProcess#doIt()
|
||||
* @return summary
|
||||
* @throws Exception
|
||||
*/
|
||||
protected String doIt() throws Exception
|
||||
{
|
||||
log.info("XX_Visit_ID=" + p_XX_Visit_ID);
|
||||
MVisit visit = new MVisit (getCtx(), p_XX_Visit_ID, get_TrxName());
|
||||
if (visit.get_ID() == 0 || visit.get_ID() != p_XX_Visit_ID)
|
||||
throw new AdempiereSystemError("@NotFound@ @XX_Visit_ID@ " + p_XX_Visit_ID);
|
||||
// Nothing to do
|
||||
if (visit.isProcessed())
|
||||
throw new AdempiereUserError("@XX_Visit_ID@ @Processed@");
|
||||
// Create Invoice Header
|
||||
MInvoice invoice = new MInvoice (getCtx(), 0, get_TrxName());
|
||||
invoice.setIsSOTrx(true);
|
||||
invoice.setC_DocTypeTarget_ID();
|
||||
// Set Business Partner
|
||||
MBPartner bp = new MBPartner (getCtx(), visit.getC_BPartner_ID(), null);
|
||||
invoice.setBPartner(bp);
|
||||
invoice.setC_BPartner_Location_ID(visit.getC_BPartner_Location_ID());
|
||||
invoice.setAD_User_ID(visit.getAD_User_ID());
|
||||
// Other Invoice Details
|
||||
invoice.setSalesRep_ID(visit.getSalesRep_ID());
|
||||
invoice.setDescription(visit.getName());
|
||||
if (!invoice.save())
|
||||
throw new AdempiereSystemError("Could not save Invoice");
|
||||
|
||||
// Create Invoice Line
|
||||
MInvoiceLine line = new MInvoiceLine(invoice);
|
||||
line.setQty(visit.getMinutes());
|
||||
line.setPrice(new BigDecimal(5));
|
||||
line.setDescription(visit.getDescription());
|
||||
if (line.getDescription() == null)
|
||||
line.setDescription(visit.getName());
|
||||
line.setTax();
|
||||
if (!line.save())
|
||||
throw new AdempiereSystemError("Could not save invoice line");
|
||||
|
||||
// Update Visit
|
||||
visit.setProcessed(true);
|
||||
visit.save();
|
||||
|
||||
// Process Invoice
|
||||
invoice.setDocAction(MInvoice.DOCACTION_Complete);
|
||||
invoice.processIt(MInvoice.DOCACTION_Complete);
|
||||
invoice.save();
|
||||
|
||||
return "@C_Invoice_ID@ " + invoice.getDocumentNo();
|
||||
} // doIt
|
||||
|
||||
} // XXVisitInvoice
|
|
@ -1,285 +0,0 @@
|
|||
/** Generated Model - DO NOT CHANGE - Copyright (C) 1999-2005 Jorg Janke */
|
||||
package adempiere.model;
|
||||
|
||||
import org.compiere.model.*;
|
||||
import java.util.*;
|
||||
import java.sql.*;
|
||||
import java.math.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Generated Model for XX_Visit
|
||||
*
|
||||
* @author Jorg Janke (generated)
|
||||
* @version Release 2.5.3c - 2006-03-08 11:13:42.216
|
||||
*/
|
||||
public class X_XX_Visit extends PO {
|
||||
/** Standard Constructor */
|
||||
public X_XX_Visit(Properties ctx, int XX_Visit_ID, String trxName) {
|
||||
super(ctx, XX_Visit_ID, trxName);
|
||||
/**
|
||||
* if (XX_Visit_ID == 0) { setAD_User_ID (0); setC_BPartner_ID (0);
|
||||
* setC_BPartner_Location_ID (0); setMinutes (0); setName (null);
|
||||
* setR_InterestArea_ID (0); setSalesRep_ID (0); setVISITTIME (new
|
||||
* Timestamp(System.currentTimeMillis())); setXX_Visit_ID (0); }
|
||||
*/
|
||||
}
|
||||
|
||||
/** Load Constructor */
|
||||
public X_XX_Visit(Properties ctx, ResultSet rs, String trxName) {
|
||||
super(ctx, rs, trxName);
|
||||
}
|
||||
|
||||
/** AD_Table_ID=1000001 */
|
||||
public static final int Table_ID = 1000001;
|
||||
|
||||
/** TableName=XX_Visit */
|
||||
public static final String Table_Name = "XX_Visit";
|
||||
|
||||
protected static KeyNamePair Model = new KeyNamePair(1000001, "XX_Visit");
|
||||
|
||||
protected BigDecimal accessLevel = new BigDecimal(1);
|
||||
|
||||
/** AccessLevel 1 - Org */
|
||||
protected int get_AccessLevel() {
|
||||
return accessLevel.intValue();
|
||||
}
|
||||
|
||||
/** Load Meta Data */
|
||||
protected POInfo initPO(Properties ctx) {
|
||||
POInfo poi = POInfo.getPOInfo(ctx, Table_ID);
|
||||
return poi;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer("X_XX_Visit[").append(get_ID())
|
||||
.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set User/Contact. User within the system - Internal or Business Partner
|
||||
* Contact
|
||||
*/
|
||||
public void setAD_User_ID(int AD_User_ID) {
|
||||
if (AD_User_ID < 1)
|
||||
throw new IllegalArgumentException("AD_User_ID is mandatory.");
|
||||
set_Value("AD_User_ID", new Integer(AD_User_ID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get User/Contact. User within the system - Internal or Business Partner
|
||||
* Contact
|
||||
*/
|
||||
public int getAD_User_ID() {
|
||||
Integer ii = (Integer) get_Value("AD_User_ID");
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Business Partner . Identifies a Business Partner
|
||||
*/
|
||||
public void setC_BPartner_ID(int C_BPartner_ID) {
|
||||
if (C_BPartner_ID < 1)
|
||||
throw new IllegalArgumentException("C_BPartner_ID is mandatory.");
|
||||
set_Value("C_BPartner_ID", new Integer(C_BPartner_ID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Business Partner . Identifies a Business Partner
|
||||
*/
|
||||
public int getC_BPartner_ID() {
|
||||
Integer ii = (Integer) get_Value("C_BPartner_ID");
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Partner Location. Identifies the (ship to) address for this Business
|
||||
* Partner
|
||||
*/
|
||||
public void setC_BPartner_Location_ID(int C_BPartner_Location_ID) {
|
||||
if (C_BPartner_Location_ID < 1)
|
||||
throw new IllegalArgumentException(
|
||||
"C_BPartner_Location_ID is mandatory.");
|
||||
set_Value("C_BPartner_Location_ID", new Integer(C_BPartner_Location_ID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Partner Location. Identifies the (ship to) address for this Business
|
||||
* Partner
|
||||
*/
|
||||
public int getC_BPartner_Location_ID() {
|
||||
Integer ii = (Integer) get_Value("C_BPartner_Location_ID");
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Description. Optional short description of the record
|
||||
*/
|
||||
public void setDescription(String Description) {
|
||||
if (Description != null && Description.length() > 255) {
|
||||
log.warning("Length > 255 - truncated");
|
||||
Description = Description.substring(0, 254);
|
||||
}
|
||||
set_Value("Description", Description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Description. Optional short description of the record
|
||||
*/
|
||||
public String getDescription() {
|
||||
return (String) get_Value("Description");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Minutes. Minutes spent with the BPatyner
|
||||
*/
|
||||
public void setMinutes(int Minutes) {
|
||||
set_Value("Minutes", new Integer(Minutes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Minutes. Minutes spent with the BPatyner
|
||||
*/
|
||||
public int getMinutes() {
|
||||
Integer ii = (Integer) get_Value("Minutes");
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Name. Alphanumeric identifier of the entity
|
||||
*/
|
||||
public void setName(String Name) {
|
||||
if (Name == null)
|
||||
throw new IllegalArgumentException("Name is mandatory.");
|
||||
if (Name.length() > 120) {
|
||||
log.warning("Length > 120 - truncated");
|
||||
Name = Name.substring(0, 119);
|
||||
}
|
||||
set_Value("Name", Name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name. Alphanumeric identifier of the entity
|
||||
*/
|
||||
public String getName() {
|
||||
return (String) get_Value("Name");
|
||||
}
|
||||
|
||||
public KeyNamePair getKeyNamePair() {
|
||||
return new KeyNamePair(get_ID(), getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Processed. The document has been processed
|
||||
*/
|
||||
public void setProcessed(boolean Processed) {
|
||||
set_Value("Processed", new Boolean(Processed));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Processed. The document has been processed
|
||||
*/
|
||||
public boolean isProcessed() {
|
||||
Object oo = get_Value("Processed");
|
||||
if (oo != null) {
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean) oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Process Now */
|
||||
public void setProcessing(boolean Processing) {
|
||||
set_Value("Processing", new Boolean(Processing));
|
||||
}
|
||||
|
||||
/** Get Process Now */
|
||||
public boolean isProcessing() {
|
||||
Object oo = get_Value("Processing");
|
||||
if (oo != null) {
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean) oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Interest Area. Interest Area or Topic
|
||||
*/
|
||||
public void setR_InterestArea_ID(int R_InterestArea_ID) {
|
||||
if (R_InterestArea_ID < 1)
|
||||
throw new IllegalArgumentException(
|
||||
"R_InterestArea_ID is mandatory.");
|
||||
set_Value("R_InterestArea_ID", new Integer(R_InterestArea_ID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Interest Area. Interest Area or Topic
|
||||
*/
|
||||
public int getR_InterestArea_ID() {
|
||||
Integer ii = (Integer) get_Value("R_InterestArea_ID");
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** SalesRep_ID AD_Reference_ID=190 */
|
||||
public static final int SALESREP_ID_AD_Reference_ID = 190;
|
||||
|
||||
/**
|
||||
* Set Sales Representative. Sales Representative or Company Agent
|
||||
*/
|
||||
public void setSalesRep_ID(int SalesRep_ID) {
|
||||
if (SalesRep_ID < 1)
|
||||
throw new IllegalArgumentException("SalesRep_ID is mandatory.");
|
||||
set_Value("SalesRep_ID", new Integer(SalesRep_ID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Sales Representative. Sales Representative or Company Agent
|
||||
*/
|
||||
public int getSalesRep_ID() {
|
||||
Integer ii = (Integer) get_Value("SalesRep_ID");
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** Set VISITTIME */
|
||||
public void setVISITTIME(Timestamp VISITTIME) {
|
||||
if (VISITTIME == null)
|
||||
throw new IllegalArgumentException("VISITTIME is mandatory.");
|
||||
set_Value("VISITTIME", VISITTIME);
|
||||
}
|
||||
|
||||
/** Get VISITTIME */
|
||||
public Timestamp getVISITTIME() {
|
||||
return (Timestamp) get_Value("VISITTIME");
|
||||
}
|
||||
|
||||
/** Set Visit */
|
||||
public void setXX_Visit_ID(int XX_Visit_ID) {
|
||||
if (XX_Visit_ID < 1)
|
||||
throw new IllegalArgumentException("XX_Visit_ID is mandatory.");
|
||||
set_ValueNoCheck("XX_Visit_ID", new Integer(XX_Visit_ID));
|
||||
}
|
||||
|
||||
/** Get Visit */
|
||||
public int getXX_Visit_ID() {
|
||||
Integer ii = (Integer) get_Value("XX_Visit_ID");
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
}
|
|
@ -1,189 +0,0 @@
|
|||
/******************************************************************************
|
||||
* 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.test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.Adempiere;
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.MOrderLine;
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.util.CLogMgt;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Ini;
|
||||
import org.compiere.util.Login;
|
||||
import org.compiere.util.Trx;
|
||||
|
||||
|
||||
/**
|
||||
* Order Test Example
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: OrderTest.java,v 1.2 2006/07/30 00:51:57 jjanke Exp $
|
||||
*/
|
||||
public class OrderTest implements Runnable
|
||||
{
|
||||
/**
|
||||
* OrderTest
|
||||
* @param no thread number
|
||||
* @param numberOrders number of orders to create
|
||||
*/
|
||||
public OrderTest (int no, int numberOrders, int avgLines)
|
||||
{
|
||||
super ();
|
||||
m_no = no;
|
||||
m_numberOrders = numberOrders;
|
||||
m_maxLines = avgLines * 2;
|
||||
} // OrderTest
|
||||
|
||||
int m_no = 0;
|
||||
int m_numberOrders = 0;
|
||||
int m_maxLines = 20;
|
||||
|
||||
int m_errors = 0;
|
||||
/** Logger */
|
||||
private static final CLogger log = CLogger.getCLogger (OrderTest.class);
|
||||
|
||||
/**
|
||||
* Run
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
long time = System.currentTimeMillis();
|
||||
int count = 0;
|
||||
MBPartner bp = new MBPartner(Env.getCtx(), 117, null);
|
||||
bp.setSOCreditStatus(MBPartner.SOCREDITSTATUS_NoCreditCheck);
|
||||
bp.saveEx();
|
||||
|
||||
//
|
||||
for (int i = 0; i < m_numberOrders; i++)
|
||||
{
|
||||
Trx trx = Trx.get(Trx.createTrxName("Test" + m_no + "_" + i),true);
|
||||
trx.setDisplayName(getClass().getName()+"_run");
|
||||
trx.start();
|
||||
//
|
||||
MOrder order = new MOrder(Env.getCtx(),0,trx.getTrxName());
|
||||
order.setDescription("#" + m_no + "_" + i);
|
||||
order.setC_DocTypeTarget_ID(135); // POS
|
||||
order.setC_BPartner_ID(117); // C&W
|
||||
order.setSalesRep_ID(101); // GardenAdmin
|
||||
order.setDeliveryRule(MOrder.DELIVERYRULE_Force);
|
||||
if (!order.save())
|
||||
{
|
||||
log.warning("#" + m_no + "_" + i + ": Not saved(1)");
|
||||
m_errors++;
|
||||
continue;
|
||||
}
|
||||
Random r = new Random();
|
||||
int linesNumber = r.nextInt(m_maxLines) + 1;
|
||||
for (int j = 0; j < linesNumber; j++)
|
||||
{
|
||||
MOrderLine line = new MOrderLine(order);
|
||||
line.setM_Product_ID(123); // Oak Tree
|
||||
line.setQty(new BigDecimal(5));
|
||||
if (!line.save())
|
||||
{
|
||||
log.warning("#" + m_no + "_" + i + ": Line not saved");
|
||||
m_errors++;
|
||||
}
|
||||
}
|
||||
// Process
|
||||
order.setDocAction(DocAction.ACTION_Complete);
|
||||
if (!order.processIt(DocAction.ACTION_Complete))
|
||||
{
|
||||
log.warning("#" + m_no + "_" + i + ": Not processed");
|
||||
m_errors++;
|
||||
trx.rollback();
|
||||
trx.close();
|
||||
continue;
|
||||
}
|
||||
if (!order.save())
|
||||
{
|
||||
log.warning("#" + m_no + "_" + i + ": Not saved(2)");
|
||||
m_errors++;
|
||||
}
|
||||
else
|
||||
count++;
|
||||
trx.commit();
|
||||
trx.close();
|
||||
//
|
||||
if (log.isLoggable(Level.INFO)) log.info(order.toString());
|
||||
}
|
||||
time = System.currentTimeMillis() - time;
|
||||
log.warning("#" + m_no + ", Errors=" + m_errors
|
||||
+ ", Count=" + count
|
||||
+ " " + ((float)count*100/m_numberOrders)
|
||||
+ "% - " + time + "ms - ea " + ((float)time/count) + "ms");
|
||||
} // run
|
||||
|
||||
/**
|
||||
* Test
|
||||
* @param args ignored
|
||||
*/
|
||||
public static void main (String[] args)
|
||||
{
|
||||
Adempiere.startup(true);
|
||||
CLogMgt.setLoggerLevel(Level.INFO, null);
|
||||
CLogMgt.setLevel(Level.INFO);
|
||||
//
|
||||
Ini.setProperty(Ini.P_UID,"SuperUser");
|
||||
Ini.setProperty(Ini.P_PWD,"System");
|
||||
Ini.setProperty(Ini.P_ROLE,"GardenWorld Admin");
|
||||
Ini.setProperty(Ini.P_CLIENT, "GardenWorld");
|
||||
Ini.setProperty(Ini.P_ORG,"HQ");
|
||||
Ini.setProperty(Ini.P_WAREHOUSE,"HQ Warehouse");
|
||||
Ini.setProperty(Ini.P_LANGUAGE,"English");
|
||||
Login login = new Login(Env.getCtx());
|
||||
if (!login.batchLogin(null))
|
||||
System.exit(1);
|
||||
//
|
||||
CLogMgt.setLoggerLevel(Level.WARNING, null);
|
||||
CLogMgt.setLevel(Level.WARNING);
|
||||
|
||||
int NO_TESTS = 2;
|
||||
int NO_ORDERS = 200;
|
||||
int NO_LINES = 20;
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
Thread[] tests = new Thread[NO_TESTS];
|
||||
for (int i = 0; i < tests.length; i++)
|
||||
{
|
||||
tests[i] = new Thread(new OrderTest(i, NO_ORDERS, NO_LINES));
|
||||
tests[i].start();
|
||||
}
|
||||
// Wait
|
||||
for (int i = 0; i < tests.length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
tests[i].join();
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
time = System.currentTimeMillis() - time;
|
||||
|
||||
System.out.println("Time (ms)=" + time);
|
||||
|
||||
} // main
|
||||
|
||||
} // OrderTest
|
Loading…
Reference in New Issue