Merged trunk 11345 to 11658 into branches/osgi/approach2

This commit is contained in:
joergviola 2010-03-14 14:38:00 +00:00
parent c33f850d6d
commit 0798948086
313 changed files with 18320 additions and 4606 deletions

View File

@ -137,5 +137,7 @@
<classpathentry exported="true" kind="lib" path="packages/liberoMFG.jar"/> <classpathentry exported="true" kind="lib" path="packages/liberoMFG.jar"/>
<classpathentry exported="true" kind="lib" path="tools/lib/iText-2.1.7.jar"/> <classpathentry exported="true" kind="lib" path="tools/lib/iText-2.1.7.jar"/>
<classpathentry exported="true" kind="lib" path="tools/lib/miglayout-3.7.1-swing.jar"/> <classpathentry exported="true" kind="lib" path="tools/lib/miglayout-3.7.1-swing.jar"/>
<classpathentry exported="true" kind="lib" path="tools/lib/payflow.jar"/>
<classpathentry kind="lib" path="tools/lib/cron4j-2.2.1.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -37,6 +37,7 @@ import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.PropertyResourceBundle; import java.util.PropertyResourceBundle;
@ -60,6 +61,7 @@ import org.compiere.db.CConnection;
import org.compiere.interfaces.MD5; import org.compiere.interfaces.MD5;
import org.compiere.model.MAttachment; import org.compiere.model.MAttachment;
import org.compiere.model.MAttachmentEntry; import org.compiere.model.MAttachmentEntry;
import org.compiere.model.MBPartner;
import org.compiere.model.MProcess; import org.compiere.model.MProcess;
import org.compiere.model.X_AD_PInstance_Para; import org.compiere.model.X_AD_PInstance_Para;
import org.compiere.process.ClientProcess; import org.compiere.process.ClientProcess;
@ -368,6 +370,7 @@ public class ReportStarter implements ProcessCall, ClientProcess
String Name=pi.getTitle(); String Name=pi.getTitle();
int AD_PInstance_ID=pi.getAD_PInstance_ID(); int AD_PInstance_ID=pi.getAD_PInstance_ID();
int Record_ID=pi.getRecord_ID(); int Record_ID=pi.getRecord_ID();
log.info( "Name="+Name+" AD_PInstance_ID="+AD_PInstance_ID+" Record_ID="+Record_ID); log.info( "Name="+Name+" AD_PInstance_ID="+AD_PInstance_ID+" Record_ID="+Record_ID);
String trxName = null; String trxName = null;
if (trx != null) { if (trx != null) {
@ -424,6 +427,15 @@ public class ReportStarter implements ProcessCall, ClientProcess
String name = jasperReport.getName(); String name = jasperReport.getName();
File reportDir = data.getReportDir(); File reportDir = data.getReportDir();
// Add reportDir to class path
ClassLoader scl = ClassLoader.getSystemClassLoader();
try {
java.net.URLClassLoader ucl = new java.net.URLClassLoader(new java.net.URL[]{reportDir.toURI().toURL()}, scl);
net.sf.jasperreports.engine.util.JRResourcesUtil.setThreadClassLoader(ucl);
} catch (MalformedURLException me) {
log.warning("Could not add report directory to classpath: "+ me.getMessage());
}
if (jasperReport != null) { if (jasperReport != null) {
File[] subreports; File[] subreports;
@ -462,9 +474,20 @@ public class ReportStarter implements ProcessCall, ClientProcess
// in iReports you can 'SELECT' AD_Client_ID, AD_Org_ID and AD_User_ID using only AD_PINSTANCE_ID // in iReports you can 'SELECT' AD_Client_ID, AD_Org_ID and AD_User_ID using only AD_PINSTANCE_ID
params.put("AD_PINSTANCE_ID", new Integer( AD_PInstance_ID)); params.put("AD_PINSTANCE_ID", new Integer( AD_PInstance_ID));
Language currLang = Env.getLanguage(Env.getCtx()); Language currLang = Env.getLanguage(Env.getCtx());
params.put("CURRENT_LANG", currLang.getAD_Language()); ProcessInfoParameter[] pip = pi.getParameter();
params.put(JRParameter.REPORT_LOCALE, currLang.getLocale()); // Check for language parameter
if (pip!=null) {
for (int i=0; i<pip.length; i++) {
if ("CURRENT_LANG".equalsIgnoreCase(pip[i].getParameterName())) {
currLang = (Language)pip[i].getParameter();
}
}
}
params.put("CURRENT_LANG", currLang.getAD_Language());
params.put(JRParameter.REPORT_LOCALE, currLang.getLocale());
// Resources // Resources
File resFile = null; File resFile = null;
if (reportPath.startsWith("attachment:") && attachment != null) { if (reportPath.startsWith("attachment:") && attachment != null) {

View File

@ -23,6 +23,7 @@
<classpathentry kind="lib" path="/tools/lib/looks-2.0.4.jar"/> <classpathentry kind="lib" path="/tools/lib/looks-2.0.4.jar"/>
<classpathentry kind="lib" path="/tools/lib/commons-collections-3.1.jar"/> <classpathentry kind="lib" path="/tools/lib/commons-collections-3.1.jar"/>
<classpathentry kind="lib" path="/tools/lib/activemq-core-5.0.0.jar"/> <classpathentry kind="lib" path="/tools/lib/activemq-core-5.0.0.jar"/>
<classpathentry kind="lib" path="/tools/lib/cron4j-2.2.1.jar"/>
<classpathentry kind="src" path="/JasperReportsTools"/> <classpathentry kind="src" path="/JasperReportsTools"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="build"/> <classpathentry kind="output" path="build"/>

View File

@ -31,6 +31,7 @@
<pathelement path="../tools/lib/j2ee.jar"/> <pathelement path="../tools/lib/j2ee.jar"/>
<pathelement path="../tools/lib/jnlp.jar"/> <pathelement path="../tools/lib/jnlp.jar"/>
<pathelement path="../tools/lib/servlet-api.jar" /> <pathelement path="../tools/lib/servlet-api.jar" />
<pathelement path="../tools/lib/cron4j-2.2.1.jar" />
</path> </path>

View File

@ -24,7 +24,7 @@
* - Trifon Trifonov (trifonnt@users.sourceforge.net) * * - Trifon Trifonov (trifonnt@users.sourceforge.net) *
* * * *
* Sponsors: * * Sponsors: *
* - E-evolution (http://www.e-evolution.com) * * - e-Evolution (http://www.e-evolution.com) *
***********************************************************************/ ***********************************************************************/
package org.adempiere.model; package org.adempiere.model;
@ -39,6 +39,7 @@ import org.compiere.model.PO;
import org.compiere.model.X_AD_ReplicationDocument; import org.compiere.model.X_AD_ReplicationDocument;
import org.compiere.model.X_AD_ReplicationTable; import org.compiere.model.X_AD_ReplicationTable;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.Env;
/** /**
@ -50,11 +51,15 @@ import org.compiere.util.CLogger;
* <li> https://sourceforge.net/tracker/?func=detail&aid=2875989&group_id=176962&atid=879332 * <li> https://sourceforge.net/tracker/?func=detail&aid=2875989&group_id=176962&atid=879332
* <li>[ 2195090 ] Stabilization of replication * <li>[ 2195090 ] Stabilization of replication
* <li>https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2936561&group_id=176962 * <li>https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2936561&group_id=176962
* <li> BF2947615 The document recplicacion not working
* <li> https://sourceforge.net/tracker/?func=detail&aid=2947615&group_id=176962&atid=879332
* *
* @version $Id$ * @version $Id$
*/ */
public class ExportModelValidator implements ModelValidator public class ExportModelValidator implements ModelValidator
{ {
/** Context variable which says if replication is enabled */
public static final String CTX_IsReplicationEnabled = "#IsReplicationEnabled";
/** Logger */ /** Logger */
private static CLogger log = CLogger.getCLogger(ExportModelValidator.class); private static CLogger log = CLogger.getCLogger(ExportModelValidator.class);
@ -129,8 +134,8 @@ public class ExportModelValidator implements ModelValidator
if (X_AD_ReplicationTable.REPLICATIONTYPE_Merge.equals(rplTable.getReplicationType()) if (X_AD_ReplicationTable.REPLICATIONTYPE_Merge.equals(rplTable.getReplicationType())
|| X_AD_ReplicationTable.REPLICATIONTYPE_Reference.equals(rplTable.getReplicationType())) || X_AD_ReplicationTable.REPLICATIONTYPE_Reference.equals(rplTable.getReplicationType()))
{ {
MTable table = MTable.get (client.getCtx(), rplTable.getAD_Table_ID()); String tableName = MTable.getTableName(client.getCtx(), rplTable.getAD_Table_ID());
engine.addModelChange(table.getTableName(), this); engine.addModelChange(tableName, this);
} }
} }
} }
@ -141,9 +146,8 @@ public class ExportModelValidator implements ModelValidator
if (X_AD_ReplicationDocument.REPLICATIONTYPE_Merge.equals(rplDocument.getReplicationType()) if (X_AD_ReplicationDocument.REPLICATIONTYPE_Merge.equals(rplDocument.getReplicationType())
|| X_AD_ReplicationDocument.REPLICATIONTYPE_Reference.equals(rplDocument.getReplicationType())) || X_AD_ReplicationDocument.REPLICATIONTYPE_Reference.equals(rplDocument.getReplicationType()))
{ {
//MDocType docType = MDocType.get(client.getCtx(), rplDocuments[i].getC_DocType_ID()); String tableName = MTable.getTableName(client.getCtx(), rplDocument.getAD_Table_ID());
MTable table = MTable.get (client.getCtx(), rplDocument.getAD_Table_ID()); engine.addDocValidate(tableName, this);
engine.addDocValidate(table.getTableName(), this);
} }
} }
} }
@ -167,10 +171,16 @@ public class ExportModelValidator implements ModelValidator
|| type == TYPE_AFTER_NEW || type == TYPE_AFTER_NEW
|| type == TYPE_BEFORE_DELETE) // After Change or After New || type == TYPE_BEFORE_DELETE) // After Change or After New
{ {
expHelper.exportRecord( po, X_AD_ReplicationTable replicationTable = MReplicationStrategy.getReplicationTable(
MReplicationStrategy.REPLICATION_TABLE, po.getCtx(), m_AD_ReplicationStrategy_ID, po.get_Table_ID());
MReplicationStrategy.getReplicationTable(po.getCtx(), m_AD_ReplicationStrategy_ID, po.get_Table_ID()).getReplicationType(), if (replicationTable != null)
type); {
expHelper.exportRecord(
po,
MReplicationStrategy.REPLICATION_TABLE,
replicationTable.getReplicationType(),
type);
}
} }
} }
@ -188,7 +198,7 @@ public class ExportModelValidator implements ModelValidator
*/ */
public String docValidate (PO po, int type) public String docValidate (PO po, int type)
{ {
log.info("po.get_TableName() = " + po.get_TableName()); log.info("Replicate the Document = " + po.get_TableName() + " with Type = " + type);
String result = null; String result = null;
if (expHelper != null) { if (expHelper != null) {
try { try {
@ -196,13 +206,30 @@ public class ExportModelValidator implements ModelValidator
|| type == TIMING_AFTER_CLOSE || type == TIMING_AFTER_CLOSE
|| type == TIMING_AFTER_REVERSECORRECT || type == TIMING_AFTER_REVERSECORRECT
|| type == TIMING_AFTER_VOID || type == TIMING_AFTER_VOID
|| type == TIMING_AFTER_PREPARE //|| type == TIMING_AFTER_PREPARE
) )
{ {
expHelper.exportRecord( po, X_AD_ReplicationDocument replicationDocument = null;
MReplicationStrategy.REPLICATION_DOCUMENT , int C_DocType_ID = po.get_ValueAsInt("C_DocType_ID");
MReplicationStrategy.getReplicationDocument(po.getCtx(), m_AD_ReplicationStrategy_ID, po.get_Table_ID()).getReplicationType(), if (C_DocType_ID > 0)
type); {
replicationDocument = MReplicationStrategy.getReplicationDocument(
po.getCtx(), m_AD_ReplicationStrategy_ID, po.get_Table_ID(), C_DocType_ID);
}
else
{
replicationDocument = MReplicationStrategy.getReplicationDocument(
po.getCtx(), m_AD_ReplicationStrategy_ID, po.get_Table_ID());
}
if (replicationDocument != null) {
expHelper.exportRecord(
po,
MReplicationStrategy.REPLICATION_DOCUMENT,
replicationDocument.getReplicationType(),
type);
}
} }
} catch (Exception e) { } catch (Exception e) {
@ -223,6 +250,7 @@ public class ExportModelValidator implements ModelValidator
*/ */
public String login (int AD_Org_ID, int AD_Role_ID, int AD_User_ID) public String login (int AD_Org_ID, int AD_Role_ID, int AD_User_ID)
{ {
Env.setContext(Env.getCtx(), CTX_IsReplicationEnabled, true);
m_AD_Org_ID = AD_Org_ID; m_AD_Org_ID = AD_Org_ID;
m_AD_Role_ID = AD_Role_ID; m_AD_Role_ID = AD_Role_ID;
m_AD_User_ID = AD_User_ID; m_AD_User_ID = AD_User_ID;

View File

@ -102,13 +102,15 @@ public class GridTabWrapper implements InvocationHandler
GridField field = m_gridTab.getField(propertyName); GridField field = m_gridTab.getField(propertyName);
if (field != null) if (field != null)
{ {
return field.getValue(); final Object value = field.getValue();
return value instanceof Boolean ? value : "Y".equals(value);
} }
// //
field = m_gridTab.getField("Is"+propertyName); field = m_gridTab.getField("Is"+propertyName);
if (field != null) if (field != null)
{ {
return field.getValue(); final Object value = field.getValue();
return value instanceof Boolean ? value : "Y".equals(value);
} }
// //
throw new IllegalArgumentException("Method not supported - "+methodName); throw new IllegalArgumentException("Method not supported - "+methodName);

View File

@ -37,9 +37,6 @@ import org.compiere.model.MOrder;
import org.compiere.model.MOrderLine; import org.compiere.model.MOrderLine;
import org.compiere.model.MTable; import org.compiere.model.MTable;
import org.compiere.model.Query; import org.compiere.model.Query;
import org.compiere.model.X_M_PromotionDistribution;
import org.compiere.model.X_M_PromotionLine;
import org.compiere.model.X_M_PromotionReward;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
@ -97,17 +94,17 @@ public class PromotionRule {
"M_PromotionDistribution.M_Promotion_ID = ? AND M_PromotionDistribution.IsActive = 'Y'", order.get_TrxName()); "M_PromotionDistribution.M_Promotion_ID = ? AND M_PromotionDistribution.IsActive = 'Y'", order.get_TrxName());
query.setParameters(new Object[]{entry.getKey()}); query.setParameters(new Object[]{entry.getKey()});
query.setOrderBy("SeqNo"); query.setOrderBy("SeqNo");
List<X_M_PromotionDistribution> list = query.<X_M_PromotionDistribution>list(); List<MPromotionDistribution> list = query.<MPromotionDistribution>list();
Query rewardQuery = new Query(Env.getCtx(), MTable.get(order.getCtx(), I_M_PromotionReward.Table_ID), Query rewardQuery = new Query(Env.getCtx(), MTable.get(order.getCtx(), I_M_PromotionReward.Table_ID),
"M_PromotionReward.M_Promotion_ID = ? AND M_PromotionReward.IsActive = 'Y'", order.get_TrxName()); "M_PromotionReward.M_Promotion_ID = ? AND M_PromotionReward.IsActive = 'Y'", order.get_TrxName());
rewardQuery.setParameters(new Object[]{entry.getKey()}); rewardQuery.setParameters(new Object[]{entry.getKey()});
rewardQuery.setOrderBy("SeqNo"); rewardQuery.setOrderBy("SeqNo");
List<X_M_PromotionReward> rewardList = rewardQuery.<X_M_PromotionReward>list(); List<MPromotionReward> rewardList = rewardQuery.<MPromotionReward>list();
List<X_M_PromotionLine> promotionLines = new ArrayList<X_M_PromotionLine>(); List<MPromotionLine> promotionLines = new ArrayList<MPromotionLine>();
for (Integer M_PromotionLine_ID : entry.getValue()) { for (Integer M_PromotionLine_ID : entry.getValue()) {
X_M_PromotionLine promotionLine = new X_M_PromotionLine(order.getCtx(), M_PromotionLine_ID, order.get_TrxName()); MPromotionLine promotionLine = new MPromotionLine(order.getCtx(), M_PromotionLine_ID, order.get_TrxName());
promotionLines.add(promotionLine); promotionLines.add(promotionLine);
} }
while (true) { while (true) {
@ -116,8 +113,8 @@ public class PromotionRule {
Set<Integer>mandatoryLineSet = new HashSet<Integer>(); Set<Integer>mandatoryLineSet = new HashSet<Integer>();
boolean mandatoryLineNotFound = false; boolean mandatoryLineNotFound = false;
List<Integer> validPromotionLineIDs = new ArrayList<Integer>(); List<Integer> validPromotionLineIDs = new ArrayList<Integer>();
for (X_M_PromotionLine promotionLine : promotionLines) { for (MPromotionLine promotionLine : promotionLines) {
if (promotionLine.getM_PromotionGroup_ID() == 0 && promotionLine.getMinimumAmt() != null && promotionLine.getMinimumAmt().signum() > 0) { if (promotionLine.getM_PromotionGroup_ID() == 0 && promotionLine.getMinimumAmt() != null && promotionLine.getMinimumAmt().signum() >= 0) {
if (orderAmount.compareTo(promotionLine.getMinimumAmt()) >= 0) { if (orderAmount.compareTo(promotionLine.getMinimumAmt()) >= 0) {
orderAmount = orderAmount.subtract(promotionLine.getMinimumAmt()); orderAmount = orderAmount.subtract(promotionLine.getMinimumAmt());
validPromotionLineIDs.add(promotionLine.getM_PromotionLine_ID()); validPromotionLineIDs.add(promotionLine.getM_PromotionLine_ID());
@ -130,14 +127,14 @@ public class PromotionRule {
if (mandatoryLineNotFound) { if (mandatoryLineNotFound) {
break; break;
} }
for (X_M_PromotionDistribution pd : list) { for (MPromotionDistribution pd : list) {
if (entry.getValue().contains(pd.getM_PromotionLine_ID())) { if (entry.getValue().contains(pd.getM_PromotionLine_ID())) {
//sort available orderline base on distribution sorting type //sort available orderline base on distribution sorting type
List<Integer> orderLineIdList = new ArrayList<Integer>(); List<Integer> orderLineIdList = new ArrayList<Integer>();
orderLineIdList.addAll(orderLineQty.keySet()); orderLineIdList.addAll(orderLineQty.keySet());
if (pd.getDistributionSorting() != null) { if (pd.getDistributionSorting() != null) {
Comparator<Integer> cmp = olComparator; Comparator<Integer> cmp = olComparator;
if (pd.getDistributionSorting().equals(X_M_PromotionDistribution.DISTRIBUTIONSORTING_Descending)) if (pd.getDistributionSorting().equals(MPromotionDistribution.DISTRIBUTIONSORTING_Descending))
cmp = Collections.reverseOrder(cmp); cmp = Collections.reverseOrder(cmp);
Collections.sort(orderLineIdList, cmp); Collections.sort(orderLineIdList, cmp);
} }
@ -171,7 +168,7 @@ public class PromotionRule {
} }
} }
for (X_M_PromotionReward pr : rewardList) { for (MPromotionReward pr : rewardList) {
if (pr.isForAllDistribution()) { if (pr.isForAllDistribution()) {
Collection<DistributionSet> all = distributions.values(); Collection<DistributionSet> all = distributions.values();
BigDecimal totalPrice = BigDecimal.ZERO; BigDecimal totalPrice = BigDecimal.ZERO;
@ -189,13 +186,13 @@ public class PromotionRule {
} }
} }
BigDecimal discount = BigDecimal.ZERO; BigDecimal discount = BigDecimal.ZERO;
if (pr.getRewardType().equals(X_M_PromotionReward.REWARDTYPE_AbsoluteAmount)) { if (pr.getRewardType().equals(MPromotionReward.REWARDTYPE_AbsoluteAmount)) {
if (pr.getAmount().compareTo(totalPrice) < 0) { if (pr.getAmount().compareTo(totalPrice) < 0) {
discount = totalPrice.subtract(pr.getAmount()); discount = totalPrice.subtract(pr.getAmount());
} }
} else if (pr.getRewardType().equals(X_M_PromotionReward.REWARDTYPE_FlatDiscount)) { } else if (pr.getRewardType().equals(MPromotionReward.REWARDTYPE_FlatDiscount)) {
discount = pr.getAmount(); discount = pr.getAmount();
} else if (pr.getRewardType().equals(X_M_PromotionReward.REWARDTYPE_Percentage)) { } else if (pr.getRewardType().equals(MPromotionReward.REWARDTYPE_Percentage)) {
discount = pr.getAmount().divide(BigDecimal.valueOf(100.00)).multiply(totalPrice); discount = pr.getAmount().divide(BigDecimal.valueOf(100.00)).multiply(totalPrice);
} }
if (discount.signum() > 0) { if (discount.signum() > 0) {
@ -216,7 +213,7 @@ public class PromotionRule {
//sort by reward distribution sorting //sort by reward distribution sorting
if (pr.getDistributionSorting() != null ) { if (pr.getDistributionSorting() != null ) {
Comparator<Integer> cmp = new OrderLineComparator(orderLineIndex); Comparator<Integer> cmp = new OrderLineComparator(orderLineIndex);
if (pr.getDistributionSorting().equals(X_M_PromotionReward.DISTRIBUTIONSORTING_Descending)) if (pr.getDistributionSorting().equals(MPromotionReward.DISTRIBUTIONSORTING_Descending))
cmp = Collections.reverseOrder(cmp); cmp = Collections.reverseOrder(cmp);
Set<Integer> keySet = distributionSet.orderLines.keySet(); Set<Integer> keySet = distributionSet.orderLines.keySet();
List<Integer> keyList = new ArrayList<Integer>(); List<Integer> keyList = new ArrayList<Integer>();
@ -261,13 +258,13 @@ public class PromotionRule {
} }
for (MOrderLine ol : lines) { for (MOrderLine ol : lines) {
if (ol.getC_OrderLine_ID() == C_OrderLine_ID) { if (ol.getC_OrderLine_ID() == C_OrderLine_ID) {
if (pr.getRewardType().equals(X_M_PromotionReward.REWARDTYPE_Percentage)) { if (pr.getRewardType().equals(MPromotionReward.REWARDTYPE_Percentage)) {
BigDecimal priceActual = ol.getPriceActual(); BigDecimal priceActual = ol.getPriceActual();
BigDecimal discount = priceActual.multiply(pr.getAmount().divide(BigDecimal.valueOf(100.00))); BigDecimal discount = priceActual.multiply(pr.getAmount().divide(BigDecimal.valueOf(100.00)));
addDiscountLine(order, ol, discount, qty, pr.getC_Charge_ID(), pr.getM_Promotion()); addDiscountLine(order, ol, discount, qty, pr.getC_Charge_ID(), pr.getM_Promotion());
} else if (pr.getRewardType().equals(X_M_PromotionReward.REWARDTYPE_FlatDiscount)) { } else if (pr.getRewardType().equals(MPromotionReward.REWARDTYPE_FlatDiscount)) {
addDiscountLine(order, ol, pr.getAmount(), BigDecimal.valueOf(1.00), pr.getC_Charge_ID(), pr.getM_Promotion()); addDiscountLine(order, ol, pr.getAmount(), BigDecimal.valueOf(1.00), pr.getC_Charge_ID(), pr.getM_Promotion());
} else if (pr.getRewardType().equals(X_M_PromotionReward.REWARDTYPE_AbsoluteAmount)) { } else if (pr.getRewardType().equals(MPromotionReward.REWARDTYPE_AbsoluteAmount)) {
BigDecimal priceActual = ol.getPriceActual(); BigDecimal priceActual = ol.getPriceActual();
totalPrice = totalPrice.add(priceActual.multiply(qty)); totalPrice = totalPrice.add(priceActual.multiply(qty));
} }
@ -279,7 +276,7 @@ public class PromotionRule {
if (setBalance.signum() == 0) if (setBalance.signum() == 0)
break; break;
} }
if (pr.getRewardType().equals(X_M_PromotionReward.REWARDTYPE_AbsoluteAmount)) { if (pr.getRewardType().equals(MPromotionReward.REWARDTYPE_AbsoluteAmount)) {
if (pr.getAmount().compareTo(totalPrice) < 0) { if (pr.getAmount().compareTo(totalPrice) < 0) {
addDiscountLine(order, null, totalPrice.subtract(pr.getAmount()), BigDecimal.valueOf(1.00), pr.getC_Charge_ID(), pr.getM_Promotion()); addDiscountLine(order, null, totalPrice.subtract(pr.getAmount()), BigDecimal.valueOf(1.00), pr.getC_Charge_ID(), pr.getM_Promotion());
} }
@ -414,7 +411,7 @@ public class PromotionRule {
* @return Distribution Qty * @return Distribution Qty
* @throws Exception * @throws Exception
*/ */
private static DistributionSet calculateDistributionQty(X_M_PromotionDistribution distribution, private static DistributionSet calculateDistributionQty(MPromotionDistribution distribution,
DistributionSet prevSet, List<Integer> validPromotionLineIDs, Map<Integer, BigDecimal> orderLineQty, List<Integer> orderLineIdList, String trxName) throws Exception { DistributionSet prevSet, List<Integer> validPromotionLineIDs, Map<Integer, BigDecimal> orderLineQty, List<Integer> orderLineIdList, String trxName) throws Exception {
String sql = "SELECT C_OrderLine.C_OrderLine_ID FROM M_PromotionLine" String sql = "SELECT C_OrderLine.C_OrderLine_ID FROM M_PromotionLine"
@ -474,9 +471,9 @@ public class PromotionRule {
match = true; match = true;
} }
if (match) { if (match) {
if (X_M_PromotionDistribution.DISTRIBUTIONTYPE_Max.equals(distribution.getDistributionType())) { if (MPromotionDistribution.DISTRIBUTIONTYPE_Max.equals(distribution.getDistributionType())) {
setQty = compare > 0 ? totalOrderLineQty : distribution.getQty(); setQty = compare > 0 ? totalOrderLineQty : distribution.getQty();
} else if (X_M_PromotionDistribution.DISTRIBUTIONTYPE_Min.equals(distribution.getDistributionType())) { } else if (MPromotionDistribution.DISTRIBUTIONTYPE_Min.equals(distribution.getDistributionType())) {
setQty = compare < 0 ? totalOrderLineQty : distribution.getQty(); setQty = compare < 0 ? totalOrderLineQty : distribution.getQty();
} else { } else {
setQty = compare > 0 ? totalOrderLineQty.subtract(distribution.getQty()) setQty = compare > 0 ? totalOrderLineQty.subtract(distribution.getQty())
@ -543,11 +540,11 @@ public class PromotionRule {
private static List<Integer> findPromotionLine(int promotion_ID, MOrder order) throws SQLException { private static List<Integer> findPromotionLine(int promotion_ID, MOrder order) throws SQLException {
Query query = new Query(Env.getCtx(), MTable.get(order.getCtx(), I_M_PromotionLine.Table_ID), " M_PromotionLine.M_Promotion_ID = ? AND M_PromotionLine.IsActive = 'Y'", order.get_TrxName()); Query query = new Query(Env.getCtx(), MTable.get(order.getCtx(), I_M_PromotionLine.Table_ID), " M_PromotionLine.M_Promotion_ID = ? AND M_PromotionLine.IsActive = 'Y'", order.get_TrxName());
query.setParameters(new Object[]{promotion_ID}); query.setParameters(new Object[]{promotion_ID});
List<X_M_PromotionLine>plist = query.<X_M_PromotionLine>list(); List<MPromotionLine>plist = query.<MPromotionLine>list();
//List<M_PromotionLine_ID> //List<M_PromotionLine_ID>
List<Integer>applicable = new ArrayList<Integer>(); List<Integer>applicable = new ArrayList<Integer>();
MOrderLine[] lines = order.getLines(); MOrderLine[] lines = order.getLines();
for (X_M_PromotionLine pl : plist) { for (MPromotionLine pl : plist) {
boolean match = false; boolean match = false;
if (pl.getM_PromotionGroup_ID() > 0) { if (pl.getM_PromotionGroup_ID() > 0) {
String sql = "SELECT DISTINCT C_OrderLine.C_OrderLine_ID FROM M_PromotionGroup INNER JOIN M_PromotionGroupLine" String sql = "SELECT DISTINCT C_OrderLine.C_OrderLine_ID FROM M_PromotionGroup INNER JOIN M_PromotionGroupLine"

View File

@ -14,14 +14,14 @@
package org.adempiere.model; package org.adempiere.model;
import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.AdempiereException;
import org.compiere.model.I_C_Order;
import org.compiere.model.I_C_OrderLine;
import org.compiere.model.MClient; import org.compiere.model.MClient;
import org.compiere.model.MOrder; import org.compiere.model.MOrder;
import org.compiere.model.MOrderLine; import org.compiere.model.MOrderLine;
import org.compiere.model.ModelValidationEngine; import org.compiere.model.ModelValidationEngine;
import org.compiere.model.ModelValidator; import org.compiere.model.ModelValidator;
import org.compiere.model.PO; import org.compiere.model.PO;
import org.compiere.model.X_C_Order;
import org.compiere.model.X_C_OrderLine;
import org.compiere.util.DB; import org.compiere.util.DB;
/** /**
@ -140,10 +140,11 @@ public class PromotionValidator implements ModelValidator {
} }
public void initialize(ModelValidationEngine engine, MClient client) { public void initialize(ModelValidationEngine engine, MClient client) {
engine.addDocValidate(X_C_Order.Table_Name, this);
engine.addModelChange(X_C_OrderLine.Table_Name, this);
if (client != null) if (client != null)
m_AD_Client_ID = client.getAD_Client_ID(); m_AD_Client_ID = client.getAD_Client_ID();
engine.addDocValidate(I_C_Order.Table_Name, this);
engine.addModelChange(I_C_OrderLine.Table_Name, this);
} }
public String login(int AD_Org_ID, int AD_Role_ID, int AD_User_ID) { public String login(int AD_Org_ID, int AD_Role_ID, int AD_User_ID) {

View File

@ -29,8 +29,13 @@
package org.adempiere.process; package org.adempiere.process;
import java.math.BigDecimal;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.acct.Doc; import org.compiere.acct.Doc;
@ -41,6 +46,7 @@ import org.compiere.process.ProcessInfoParameter;
import org.compiere.process.SvrProcess; import org.compiere.process.SvrProcess;
import org.compiere.util.AdempiereUserError; import org.compiere.util.AdempiereUserError;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.Trx; import org.compiere.util.Trx;
@ -115,32 +121,101 @@ public class ClientAcctProcessor extends SvrProcess
*/ */
private void postSession() private void postSession()
{ {
for (int i = 0; i < Doc.getDocumentsTableID().length; i++) List<BigDecimal> listProcessedOn = new ArrayList<BigDecimal>();
listProcessedOn.add(Env.ZERO); // to include potential null values
//get current time from db
Timestamp ts = DB.getSQLValueTS(get_TrxName(), "SELECT CURRENT_TIMESTAMP FROM DUAL");
//go back 2 second to be safe (to avoid posting documents being completed at this precise moment)
long ms = ts.getTime()- (2 * 1000);
ts = new Timestamp(ms);
long mili = ts.getTime();
BigDecimal value = new BigDecimal(Long.toString(mili));
//first pass, collect all ts (FR 2962094 - required for weighted average costing)
int[] documentsTableID = Doc.getDocumentsTableID();
String[] documentsTableName = Doc.getDocumentsTableName();
for (int i = 0; i < documentsTableID.length; i++)
{ {
int AD_Table_ID = Doc.getDocumentsTableID()[i]; int AD_Table_ID = documentsTableID[i];
String TableName = Doc.getDocumentsTableName()[i]; String TableName = documentsTableName[i];
// Post only special documents // Post only special documents
if (p_AD_Table_ID != 0 if (p_AD_Table_ID != 0
&& p_AD_Table_ID != AD_Table_ID) && p_AD_Table_ID != AD_Table_ID)
continue; continue;
// SELECT * FROM table
StringBuffer sql = new StringBuffer ("SELECT * FROM ").append(TableName) StringBuffer sql = new StringBuffer ("SELECT DISTINCT ProcessedOn FROM ").append(TableName)
.append(" WHERE AD_Client_ID=?") .append(" WHERE AD_Client_ID=? AND ProcessedOn<?")
.append(" AND Processed='Y' AND Posted='N' AND IsActive='Y'") .append(" AND Processed='Y' AND Posted='N' AND IsActive='Y'");
.append(" ORDER BY Created");
//
int count = 0;
int countError = 0;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
pstmt.setInt(1, getAD_Client_ID()); pstmt.setInt(1, getAD_Client_ID());
pstmt.setBigDecimal(2, value);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
count++; BigDecimal processedOn = rs.getBigDecimal(1);
if (!listProcessedOn.contains(processedOn))
listProcessedOn.add(processedOn);
}
}
catch (Exception e)
{
log.log(Level.SEVERE, sql.toString(), e);
}
finally
{
DB.close(rs, pstmt);
}
}
// initialize counters per table
int[] count = new int[documentsTableID.length];
int[] countError = new int[documentsTableID.length];
for (int i = 0; i < count.length; i++) {
count[i] = 0;
countError[i] = 0;
}
//sort and post in the processed date order
Collections.sort(listProcessedOn);
for (BigDecimal processedOn : listProcessedOn)
{
for (int i = 0; i < documentsTableID.length; i++)
{
int AD_Table_ID = documentsTableID[i];
String TableName = documentsTableName[i];
// Post only special documents
if (p_AD_Table_ID != 0
&& p_AD_Table_ID != AD_Table_ID)
continue;
// SELECT * FROM table
StringBuffer sql = new StringBuffer ("SELECT * FROM ").append(TableName)
.append(" WHERE AD_Client_ID=? AND (ProcessedOn");
if (processedOn.compareTo(Env.ZERO) != 0)
sql.append("=?");
else
sql.append(" IS NULL OR ProcessedOn=0");
sql.append(") AND Processed='Y' AND Posted='N' AND IsActive='Y'")
.append(" ORDER BY Created");
//
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
pstmt.setInt(1, getAD_Client_ID());
if (processedOn.compareTo(Env.ZERO) != 0)
pstmt.setBigDecimal(2, processedOn);
rs = pstmt.executeQuery();
while (rs.next())
{
count[i]++;
boolean ok = true; boolean ok = true;
// Run every posting document in own transaction // Run every posting document in own transaction
String innerTrxName = Trx.createTrxName("CAP"); String innerTrxName = Trx.createTrxName("CAP");
@ -174,7 +249,7 @@ public class ClientAcctProcessor extends SvrProcess
innerTrx = null; innerTrx = null;
} }
if (!ok) if (!ok)
countError++; countError[i]++;
} }
} }
catch (Exception e) catch (Exception e)
@ -186,18 +261,25 @@ public class ClientAcctProcessor extends SvrProcess
DB.close(rs, pstmt); DB.close(rs, pstmt);
} }
// } // for tableID
if (count > 0)
} // for processedOn
for (int i = 0; i < documentsTableID.length; i++)
{
String TableName = documentsTableName[i];
if (count[i] > 0)
{ {
m_summary.append(TableName).append("=").append(count); m_summary.append(TableName).append("=").append(count[i]);
if (countError > 0) if (countError[i] > 0)
m_summary.append("(Errors=").append(countError).append(")"); m_summary.append("(Errors=").append(countError[i]).append(")");
m_summary.append(" - "); m_summary.append(" - ");
log.finer(getName() + ": " + m_summary.toString()); log.finer(getName() + ": " + m_summary.toString());
} }
else else
log.finer(getName() + ": " + TableName + " - no work"); log.finer(getName() + ": " + TableName + " - no work");
} }
} // postSession } // postSession
} // ClientAcctProcessor } // ClientAcctProcessor

View File

@ -1,4 +1,4 @@
/********************************************************************** /***********************************************************************
* This file is part of Adempiere ERP Bazaar * * This file is part of Adempiere ERP Bazaar *
* http://www.adempiere.org * * http://www.adempiere.org *
* * * *
@ -23,16 +23,32 @@
* Sponsors: * * Sponsors: *
* - Company (http://www.notima.se) * * - Company (http://www.notima.se) *
* - Company (http://www.cyberphoto.se) * * - Company (http://www.cyberphoto.se) *
***********************************************************************/ **********************************************************************/
package org.adempiere.process; package org.adempiere.process;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.Iterator;
import java.util.logging.*; import java.util.List;
import org.compiere.model.*; import java.util.Map;
import org.compiere.process.*; import java.util.TreeMap;
import org.compiere.util.*; import java.util.logging.Level;
import org.compiere.model.I_C_ElementValue;
import org.compiere.model.I_C_ValidCombination;
import org.compiere.model.I_M_Product;
import org.compiere.model.I_M_Product_Acct;
import org.compiere.model.MAccount;
import org.compiere.model.MElementValue;
import org.compiere.model.MPriceList;
import org.compiere.model.MPriceListVersion;
import org.compiere.model.MProduct;
import org.compiere.model.MProductPrice;
import org.compiere.model.Query;
import org.compiere.model.X_M_Product_Acct;
import org.compiere.process.ProcessInfoParameter;
import org.compiere.process.SvrProcess;
import org.compiere.util.Env;
/** /**
* Creates expense type products from a given range of expense account * Creates expense type products from a given range of expense account
@ -107,8 +123,8 @@ public class ExpenseTypesFromAccounts extends SvrProcess {
MProduct product; MProduct product;
// Read all existing applicable products into memory for quick comparison. // Read all existing applicable products into memory for quick comparison.
List<MProduct> products = new Query(getCtx(), MProduct.Table_Name, "ProductType=?", get_TrxName()) List<MProduct> products = new Query(getCtx(), I_M_Product.Table_Name, "ProductType=?", get_TrxName())
.setParameters(new Object[]{MProduct.PRODUCTTYPE_ExpenseType}) .setParameters(MProduct.PRODUCTTYPE_ExpenseType)
.list(); .list();
Map<String,MProduct> productMap = new TreeMap<String, MProduct>(); Map<String,MProduct> productMap = new TreeMap<String, MProduct>();
@ -121,10 +137,10 @@ public class ExpenseTypesFromAccounts extends SvrProcess {
MAccount validComb; MAccount validComb;
List<MAccount> validCombs = new Query( List<MAccount> validCombs = new Query(
getCtx(), getCtx(),
MAccount.Table_Name, I_C_ValidCombination.Table_Name,
"C_AcctSchema_ID=? and AD_Client_ID=? and AD_Org_ID=0", "C_AcctSchema_ID=? and AD_Client_ID=? and AD_Org_ID=0",
get_TrxName()) get_TrxName())
.setParameters(new Object[]{m_acctSchemaId, m_clientId}) .setParameters(m_acctSchemaId, m_clientId)
.list(); .list();
Map<Integer, MAccount> validCombMap = new TreeMap<Integer, MAccount>(); Map<Integer, MAccount> validCombMap = new TreeMap<Integer, MAccount>();
@ -136,10 +152,10 @@ public class ExpenseTypesFromAccounts extends SvrProcess {
// Read all accounttypes that fit the given criteria. // Read all accounttypes that fit the given criteria.
List<MElementValue> result = new Query( List<MElementValue> result = new Query(
getCtx(), getCtx(),
MElementValue.Table_Name, I_C_ElementValue.Table_Name,
"AccountType=? and isSummary='N' and Value>=? and Value<=? and AD_Client_ID=?", "AccountType=? and isSummary='N' and Value>=? and Value<=? and AD_Client_ID=?",
get_TrxName()) get_TrxName())
.setParameters(new Object[]{MElementValue.ACCOUNTTYPE_Expense, m_startElement, m_endElement, m_clientId}) .setParameters(MElementValue.ACCOUNTTYPE_Expense, m_startElement, m_endElement, m_clientId)
.list(); .list();
MElementValue elem; MElementValue elem;
@ -195,8 +211,8 @@ public class ExpenseTypesFromAccounts extends SvrProcess {
// TODO: It might be needed to make the accounting more specific, but the purpose // TODO: It might be needed to make the accounting more specific, but the purpose
// of the process now is to create general accounts so this is intentional. // of the process now is to create general accounts so this is intentional.
productAcct = new Query(getCtx(), X_M_Product_Acct.Table_Name, "M_Product_ID=? and C_AcctSchema_ID=?", get_TrxName()) productAcct = new Query(getCtx(), I_M_Product_Acct.Table_Name, "M_Product_ID=? and C_AcctSchema_ID=?", get_TrxName())
.setParameters(new Object[]{product.get_ID(), m_acctSchemaId}) .setParameters(product.get_ID(), m_acctSchemaId)
.first(); .first();
productAcct.setP_Expense_Acct(validComb.get_ID()); productAcct.setP_Expense_Acct(validComb.get_ID());
productAcct.setP_Revenue_Acct(validComb.get_ID()); productAcct.setP_Revenue_Acct(validComb.get_ID());

View File

@ -23,6 +23,7 @@ import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.model.I_C_InvoiceLine;
import org.compiere.model.MInOut; import org.compiere.model.MInOut;
import org.compiere.model.MInOutLine; import org.compiere.model.MInOutLine;
import org.compiere.model.MInvoiceLine; import org.compiere.model.MInvoiceLine;
@ -204,10 +205,10 @@ public class InOutGenerateRMA extends SvrProcess
// //
// Link to corresponding Invoice Line (if any) - teo_sarca [ 2818523 ] // Link to corresponding Invoice Line (if any) - teo_sarca [ 2818523 ]
// The MMatchInv records will be automatically generated on MInOut.completeIt() // The MMatchInv records will be automatically generated on MInOut.completeIt()
final MInvoiceLine invoiceLine = new Query(shipment.getCtx(), MInvoiceLine.Table_Name, MInvoiceLine invoiceLine = new Query(shipment.getCtx(), I_C_InvoiceLine.Table_Name,
MInvoiceLine.COLUMNNAME_M_RMALine_ID+"=?", I_C_InvoiceLine.COLUMNNAME_M_RMALine_ID+"=?",
shipment.get_TrxName()) shipment.get_TrxName())
.setParameters(new Object[]{rmaLine.getM_RMALine_ID()}) .setParameters(rmaLine.getM_RMALine_ID())
.firstOnly(); .firstOnly();
if (invoiceLine != null) if (invoiceLine != null)
{ {

View File

@ -26,11 +26,9 @@
* * * *
* Sponsors: * * Sponsors: *
* - E-evolution (http://www.e-evolution.com/) * * - E-evolution (http://www.e-evolution.com/) *
**********************************************************************/ *********************************************************************/
package org.adempiere.process.rpl.exp; package org.adempiere.process.rpl.exp;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -45,22 +43,19 @@ import javax.xml.parsers.ParserConfigurationException;
import org.adempiere.process.rpl.IExportProcessor; import org.adempiere.process.rpl.IExportProcessor;
import org.compiere.model.MClient; import org.compiere.model.MClient;
import org.compiere.model.MColumn; import org.compiere.model.MColumn;
import org.compiere.model.MEXPFormat;
import org.compiere.model.MEXPFormatLine;
import org.compiere.model.MEXPProcessor;
import org.compiere.model.MEXPProcessorType;
import org.compiere.model.MReplicationStrategy; import org.compiere.model.MReplicationStrategy;
import org.compiere.model.MTable; import org.compiere.model.MTable;
import org.compiere.model.PO; import org.compiere.model.PO;
import org.compiere.model.Query; import org.compiere.model.Query;
import org.compiere.model.X_EXP_FormatLine; import org.compiere.model.X_EXP_FormatLine;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Language;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.Trx; import org.compiere.util.Trx;
import org.compiere.model.MEXPFormat;
import org.compiere.model.MEXPFormatLine;
import org.compiere.model.MEXPProcessor;
import org.compiere.model.MEXPProcessorType;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.Text; import org.w3c.dom.Text;
@ -74,6 +69,8 @@ import org.w3c.dom.Text;
* @author victor.perez@e-evolution.com, e-Evolution * @author victor.perez@e-evolution.com, e-Evolution
* <li>[ 2195090 ] Stabilization of replication * <li>[ 2195090 ] Stabilization of replication
* <li>https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2936561&group_id=176962 * <li>https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2936561&group_id=176962
* <li>BF [2947622] The replication ID (Primary Key) is not working
* <li>https://sourceforge.net/tracker/?func=detail&aid=2947622&group_id=176962&atid=879332
* *
*/ */
public class ExportHelper { public class ExportHelper {
@ -84,12 +81,6 @@ public class ExportHelper {
/** XML Document */ /** XML Document */
private Document outDocument = null; private Document outDocument = null;
/** Date Time Format */
private SimpleDateFormat m_dateTimeFormat = null;
/** Date Format */
private SimpleDateFormat m_dateFormat = null;
/** Custom Date Format */ /** Custom Date Format */
private SimpleDateFormat m_customDateFormat = null; private SimpleDateFormat m_customDateFormat = null;
@ -103,15 +94,10 @@ public class ExportHelper {
public ExportHelper(MClient client, MReplicationStrategy rplStrategy) { public ExportHelper(MClient client, MReplicationStrategy rplStrategy) {
m_AD_Client_ID = client.getAD_Client_ID(); m_AD_Client_ID = client.getAD_Client_ID();
m_rplStrategy = rplStrategy; m_rplStrategy = rplStrategy;
m_dateTimeFormat = DisplayType.getDateFormat(DisplayType.DateTime, Language.getLanguage(Env.getAD_Language(client.getCtx())));
m_dateFormat = DisplayType.getDateFormat(DisplayType.Date, Language.getLanguage(Env.getAD_Language(client.getCtx())));
} }
public ExportHelper(Properties ctx , int AD_Client_ID) { public ExportHelper(Properties ctx , int AD_Client_ID) {
m_AD_Client_ID = AD_Client_ID; m_AD_Client_ID = AD_Client_ID;
m_dateTimeFormat = DisplayType.getDateFormat(DisplayType.DateTime, Language.getLanguage(Env.getAD_Language(ctx)));
m_dateFormat = DisplayType.getDateFormat(DisplayType.Date, Language.getLanguage(Env.getAD_Language(ctx)));
} }
/** /**
@ -157,48 +143,20 @@ public class ExportHelper {
outDocument = createNewDocument(); outDocument = createNewDocument();
StringBuffer sql = new StringBuffer("SELECT * ") HashMap<String, Integer> variableMap = new HashMap<String, Integer>();
.append("FROM ").append(po.get_TableName()).append(" ")
.append("WHERE ").append(po.get_KeyColumns()[0]).append("=?")
;
if (exportFormat.getWhereClause() != null & !"".equals(exportFormat.getWhereClause())) { Element rootElement = outDocument.createElement(exportFormat.getValue());
sql.append(" AND ").append(exportFormat.getWhereClause()); if (exportFormat.getDescription() != null && !"".equals(exportFormat.getDescription()))
}
ResultSet rs = null;
PreparedStatement pstmt = null;
try
{ {
pstmt = DB.prepareStatement(sql.toString(), po.get_TrxName()); rootElement.appendChild(outDocument.createComment(exportFormat.getDescription()));
pstmt.setInt(1, po.get_ID());
rs = pstmt.executeQuery();
if (rs.next())
{
HashMap<String, Integer> variableMap = new HashMap<String, Integer>();
//variableMap.put(TOTAL_SEGMENTS, new Integer(1));
Element rootElement = outDocument.createElement(exportFormat.getValue());
if (exportFormat.getDescription() != null && !"".equals(exportFormat.getDescription())) {
rootElement.appendChild(outDocument.createComment(exportFormat.getDescription()));
}
rootElement.setAttribute("AD_Client_Value", client.getValue());
rootElement.setAttribute("Version", exportFormat.getVersion());
rootElement.setAttribute("ReplicationMode", ReplicationMode.toString());
rootElement.setAttribute("ReplicationType", ReplicationType);
rootElement.setAttribute("ReplicationEvent", ReplicationEvent.toString());
outDocument.appendChild(rootElement);
generateExportFormat(rootElement, exportFormat, rs, po, po.get_ID(), variableMap);
}
} finally {
try {
if (rs != null) rs.close();
if (pstmt != null) pstmt.close();
} catch (SQLException ex) {/*ignored*/}
rs = null;
pstmt = null;
} }
rootElement.setAttribute("AD_Client_Value", client.getValue());
rootElement.setAttribute("Version", exportFormat.getVersion());
rootElement.setAttribute("ReplicationMode", ReplicationMode.toString());
rootElement.setAttribute("ReplicationType", ReplicationType);
rootElement.setAttribute("ReplicationEvent", ReplicationEvent.toString());
outDocument.appendChild(rootElement);
generateExportFormat(rootElement, exportFormat, po, po.get_ID(), variableMap);
MEXPProcessor mExportProcessor = null; MEXPProcessor mExportProcessor = null;
mExportProcessor = new MEXPProcessor (po.getCtx(), m_rplStrategy.getEXP_Processor_ID(), po.get_TrxName() ); mExportProcessor = new MEXPProcessor (po.getCtx(), m_rplStrategy.getEXP_Processor_ID(), po.get_TrxName() );
@ -236,11 +194,11 @@ public class ExportHelper {
MTable table = MTable.get(exportFormat.getCtx(), exportFormat.getAD_Table_ID()); MTable table = MTable.get(exportFormat.getCtx(), exportFormat.getAD_Table_ID());
log.info("Table = " + table); log.info("Table = " + table);
Collection<PO> datas = new Query(exportFormat.getCtx(),table.getTableName(), exportFormat.getWhereClause(), exportFormat.get_TrxName()) Collection<PO> records = new Query(exportFormat.getCtx(),table.getTableName(), exportFormat.getWhereClause(), exportFormat.get_TrxName())
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.list(); .list();
for (PO po : datas) for (PO po : records)
{ {
log.info("Client = " + client.toString()); log.info("Client = " + client.toString());
log.finest("po.getAD_Org_ID() = " + po.getAD_Org_ID()); log.finest("po.getAD_Org_ID() = " + po.getAD_Org_ID());
@ -253,52 +211,22 @@ public class ExportHelper {
throw new Exception(Msg.getMsg (po.getCtx(), "ExportNoneColumnKeyNotSupported"));//TODO: Create Mesagge. throw new Exception(Msg.getMsg (po.getCtx(), "ExportNoneColumnKeyNotSupported"));//TODO: Create Mesagge.
} }
// TODO - get proper Export Format!
String version = "3.2.0";
outDocument = createNewDocument(); outDocument = createNewDocument();
StringBuffer sql = new StringBuffer("SELECT * ")
.append("FROM ").append(table.getTableName()).append(" ")
.append("WHERE ").append(po.get_KeyColumns()[0]).append("=?")
;
if (exportFormat.getWhereClause() != null & !"".equals(exportFormat.getWhereClause())) { HashMap<String, Integer> variableMap = new HashMap<String, Integer>();
sql.append(" AND ").append(exportFormat.getWhereClause()); Element rootElement = outDocument.createElement(exportFormat.getValue());
} if (exportFormat.getDescription() != null && !"".equals(exportFormat.getDescription()))
ResultSet rs = null;
PreparedStatement pstmt = null;
try
{ {
pstmt = DB.prepareStatement(sql.toString(), po.get_TrxName()); rootElement.appendChild(outDocument.createComment(exportFormat.getDescription()));
pstmt.setInt(1, po.get_ID());
rs = pstmt.executeQuery();
if (rs.next())
{
HashMap<String, Integer> variableMap = new HashMap<String, Integer>();
//variableMap.put(TOTAL_SEGMENTS, new Integer(1));
Element rootElement = outDocument.createElement(exportFormat.getValue());
if (exportFormat.getDescription() != null && !"".equals(exportFormat.getDescription())) {
rootElement.appendChild(outDocument.createComment(exportFormat.getDescription()));
}
rootElement.setAttribute("AD_Client_Value", client.getValue());
rootElement.setAttribute("Version", exportFormat.getVersion());
rootElement.setAttribute("ReplicationMode", ReplicationMode.toString());
rootElement.setAttribute("ReplicationType", ReplicationType);
rootElement.setAttribute("ReplicationEvent", ReplicationEvent.toString());
outDocument.appendChild(rootElement);
generateExportFormat(rootElement, exportFormat, rs, po, po.get_ID(), variableMap);
}
} finally {
try {
if (rs != null) rs.close();
if (pstmt != null) pstmt.close();
} catch (SQLException ex) {/*ignored*/}
rs = null;
pstmt = null;
} }
rootElement.setAttribute("AD_Client_Value", client.getValue());
rootElement.setAttribute("Version", exportFormat.getVersion());
rootElement.setAttribute("ReplicationMode", ReplicationMode.toString());
rootElement.setAttribute("ReplicationType", ReplicationType);
rootElement.setAttribute("ReplicationEvent", ReplicationEvent.toString());
outDocument.appendChild(rootElement);
generateExportFormat(rootElement, exportFormat, po, po.get_ID(), variableMap);
}// finish record read }// finish record read
return outDocument; return outDocument;
} }
@ -310,7 +238,7 @@ public class ExportHelper {
* <DocumentNo>101</DocumentNo> * <DocumentNo>101</DocumentNo>
* </C_Invoice> * </C_Invoice>
*/ */
private void generateExportFormat(Element rootElement, MEXPFormat exportFormat, ResultSet rs, PO masterPO, int masterID, HashMap<String, Integer> variableMap) throws SQLException, Exception private void generateExportFormat(Element rootElement, MEXPFormat exportFormat, PO masterPO, int masterID, HashMap<String, Integer> variableMap) throws SQLException, Exception
{ {
Collection<MEXPFormatLine> formatLines = exportFormat.getFormatLines(); Collection<MEXPFormatLine> formatLines = exportFormat.getFormatLines();
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ -323,7 +251,7 @@ public class ExportHelper {
// process single XML Attribute // process single XML Attribute
// Create new element // Create new element
Element newElement = outDocument.createElement(formatLine.getValue()); Element newElement = outDocument.createElement(formatLine.getValue());
log.info("Format Line Seach key"+ formatLine.getValue());
if (formatLine.getAD_Column_ID() == 0) { if (formatLine.getAD_Column_ID() == 0) {
throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPColumnMandatory")); throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPColumnMandatory"));
} }
@ -336,7 +264,7 @@ public class ExportHelper {
} else { } } else { }
//log.info("["+column.getColumnName()+"]"); //log.info("["+column.getColumnName()+"]");
Object value = rs.getObject(column.getColumnName()); Object value = masterPO.get_Value(column.getColumnName());
String valueString = null; String valueString = null;
if (value != null) { if (value != null) {
valueString = value.toString(); valueString = value.toString();
@ -350,14 +278,12 @@ public class ExportHelper {
if (valueString != null) { if (valueString != null) {
if (formatLine.getDateFormat() != null && !"".equals(formatLine.getDateFormat())) { if (formatLine.getDateFormat() != null && !"".equals(formatLine.getDateFormat())) {
m_customDateFormat = new SimpleDateFormat( formatLine.getDateFormat() ); // "MM/dd/yyyy" m_customDateFormat = new SimpleDateFormat( formatLine.getDateFormat() ); // "MM/dd/yyyy"
//Date date = m_customDateFormat.parse ( valueString );
valueString = m_customDateFormat.format(Timestamp.valueOf (valueString)); valueString = m_customDateFormat.format(Timestamp.valueOf (valueString));
newElement.setAttribute("DateFormat", m_customDateFormat.toPattern()); // Add "DateForamt attribute" newElement.setAttribute("DateFormat", m_customDateFormat.toPattern()); // Add "DateForamt attribute"
} else { } else
//valueString = m_dateFormat.format (Timestamp.valueOf (valueString)); {
//newElement.setAttribute("DateFormat", m_dateTimeFormat.toPattern()); // Add "DateForamt attribute newElement.setAttribute("DateFormat", valueString);
//Standard Japanese Format (default) works better (yyyy-mm-dd)
newElement.setAttribute("DateFormat", valueString);
} }
} }
@ -365,13 +291,9 @@ public class ExportHelper {
if (valueString != null) { if (valueString != null) {
if (formatLine.getDateFormat() != null && !"".equals(formatLine.getDateFormat())) { if (formatLine.getDateFormat() != null && !"".equals(formatLine.getDateFormat())) {
m_customDateFormat = new SimpleDateFormat( formatLine.getDateFormat() ); // "MM/dd/yyyy" m_customDateFormat = new SimpleDateFormat( formatLine.getDateFormat() ); // "MM/dd/yyyy"
//Date date = m_customDateFormat.parse ( valueString );
valueString = m_customDateFormat.format(Timestamp.valueOf (valueString)); valueString = m_customDateFormat.format(Timestamp.valueOf (valueString));
newElement.setAttribute("DateFormat", m_customDateFormat.toPattern()); // Add "DateForamt attribute" newElement.setAttribute("DateFormat", m_customDateFormat.toPattern()); // Add "DateForamt attribute"
} else { } else {
//valueString = m_dateTimeFormat.format (Timestamp.valueOf (valueString));
//newElement.setAttribute("DateFormat", m_dateTimeFormat.toPattern()); // Add "DateForamt attribute
//Standard Japanese Format (default) works better (yyyy-mm-dd hh:mm:ss m.mm)
newElement.setAttribute("DateFormat", valueString); newElement.setAttribute("DateFormat", valueString);
} }
} }
@ -382,8 +304,6 @@ public class ExportHelper {
newElement.appendChild(newText); newElement.appendChild(newText);
rootElement.appendChild(newElement); rootElement.appendChild(newElement);
elementHasValue = true; elementHasValue = true;
//increaseVariable(variableMap, formatLines[i].getVariableName()); // Increase value of Variable if any Variable
//increaseVariable(variableMap, TOTAL_SEGMENTS);
} else { } else {
// Empty field. // Empty field.
if (formatLine.isMandatory()) { if (formatLine.isMandatory()) {
@ -407,7 +327,7 @@ public class ExportHelper {
} else { } } else { }
//log.info("["+column.getColumnName()+"]"); //log.info("["+column.getColumnName()+"]");
Object value = rs.getObject(column.getColumnName()); Object value = masterPO.get_Value(column.getColumnName());
String valueString = null; String valueString = null;
if (value != null) { if (value != null) {
valueString = value.toString(); valueString = value.toString();
@ -442,8 +362,7 @@ public class ExportHelper {
if (valueString != null && !"".equals(valueString) && !"null".equals(valueString)) { if (valueString != null && !"".equals(valueString) && !"null".equals(valueString)) {
rootElement.setAttribute(formatLine.getValue(), valueString); rootElement.setAttribute(formatLine.getValue(), valueString);
elementHasValue = true; elementHasValue = true;
//increaseVariable(variableMap, formatLines[i].getVariableName()); // Increase value of Variable if any Variable
//increaseVariable(variableMap, TOTAL_SEGMENTS);
} else { } else {
// Empty field. // Empty field.
} }
@ -458,44 +377,30 @@ public class ExportHelper {
MTable tableEmbedded = MTable.get(masterPO.getCtx(), embeddedFormat.getAD_Table_ID()); MTable tableEmbedded = MTable.get(masterPO.getCtx(), embeddedFormat.getAD_Table_ID());
log.info("Table Embedded = " + tableEmbedded); log.info("Table Embedded = " + tableEmbedded);
StringBuffer sql = new StringBuffer("SELECT * ")
.append("FROM ").append(tableEmbedded.getTableName()).append(" ") final StringBuffer whereClause = new StringBuffer(masterPO.get_KeyColumns()[0] +"=?");
.append("WHERE ").append(masterPO.get_KeyColumns()[0]).append("=?")
//+ "WHERE " + po.get_WhereClause(false) if (embeddedFormat.getWhereClause() != null & !"".equals(embeddedFormat.getWhereClause()))
;
if (embeddedFormat.getWhereClause() != null & !"".equals(embeddedFormat.getWhereClause())) {
sql.append(" AND ").append(embeddedFormat.getWhereClause());
}
log.info(sql.toString());
ResultSet rsEmbedded = null;
PreparedStatement pstmt = null;
try
{ {
pstmt = DB.prepareStatement(sql.toString(), masterPO.get_TrxName()); whereClause.append(" AND ").append(embeddedFormat.getWhereClause());
pstmt.setInt(1, masterID);
rsEmbedded = pstmt.executeQuery();
while (rsEmbedded.next())
{
//System.out.println("Trifon - tableEmbedded.getTableName()_ID = "+ tableEmbedded.getTableName() + "_ID");
int embeddedID = rsEmbedded.getInt(tableEmbedded.getTableName() + "_ID");
PO poEmbedded = tableEmbedded.getPO (embeddedID, masterPO.get_TrxName());
Element embeddedElement = outDocument.createElement(formatLine.getValue());
if (formatLine.getDescription() != null && !"".equals(formatLine.getDescription())) {
embeddedElement.appendChild(outDocument.createComment(formatLine.getDescription()));
}
generateExportFormat(embeddedElement, embeddedFormat, rsEmbedded, poEmbedded, embeddedID, variableMap);
rootElement.appendChild(embeddedElement);
}
} finally {
try {
if (rsEmbedded != null) rsEmbedded.close();
if (pstmt != null) pstmt.close();
} catch (SQLException ex) { }
rsEmbedded = null;
pstmt = null;
} }
Collection<PO> instances = new Query(masterPO.getCtx(),
tableEmbedded.getTableName(), whereClause.toString(),
masterPO.get_TrxName()).setClient_ID().setParameters(
new Object[] { masterID }).list();
for (PO instance : instances)
{
Element embeddedElement = outDocument.createElement(formatLine.getValue());
if (formatLine.getDescription() != null && !"".equals(formatLine.getDescription()))
{
embeddedElement.appendChild(outDocument.createComment(formatLine.getDescription()));
}
generateExportFormat(embeddedElement, embeddedFormat, instance, instance.get_ID(), variableMap);
rootElement.appendChild(embeddedElement);
}
} }
else if ( formatLine.getType().equals(X_EXP_FormatLine.TYPE_ReferencedEXPFormat) ) else if ( formatLine.getType().equals(X_EXP_FormatLine.TYPE_ReferencedEXPFormat) )
@ -508,63 +413,34 @@ public class ExportHelper {
MTable tableEmbedded = MTable.get(masterPO.getCtx(), embeddedFormat.getAD_Table_ID()); MTable tableEmbedded = MTable.get(masterPO.getCtx(), embeddedFormat.getAD_Table_ID());
log.info("Table Embedded = " + tableEmbedded); log.info("Table Embedded = " + tableEmbedded);
StringBuffer sql = new StringBuffer("SELECT * ")
.append("FROM ").append(tableEmbedded.getTableName()).append(" ") final StringBuffer whereClause = new StringBuffer(tableEmbedded.getTableName() + "_ID =?");
.append("WHERE ").append(tableEmbedded.getTableName() + "_ID").append("=?") if (embeddedFormat.getWhereClause() != null & !"".equals(embeddedFormat.getWhereClause()))
//+ "WHERE " + po.get_WhereClause(false)
;
if (embeddedFormat.getWhereClause() != null & !"".equals(embeddedFormat.getWhereClause())) {
sql.append(" AND ").append(embeddedFormat.getWhereClause());
}
log.info(sql.toString());
if (formatLine.getAD_Column_ID() == 0) {
throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPColumnMandatory"));
}
MColumn column = MColumn.get(masterPO.getCtx(), formatLine.getAD_Column_ID());
if (column == null) {
throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPColumnMandatory"));
}
if ( column.isVirtualColumn() ) {
log.info("This is Virtual Column!");
} else { }
//log.info("["+column.getColumnName()+"]");
Object value = rs.getObject(column.getColumnName());
/* String valueString = null;
if (value != null) {
valueString = value.toString();
} else {
throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPFieldMandatory"));
}
*/
log.info(sql.toString());
ResultSet rsEmbedded = null;
PreparedStatement pstmt = null;
try
{ {
pstmt = DB.prepareStatement(sql.toString(), masterPO.get_TrxName()); whereClause.append(" AND ").append(embeddedFormat.getWhereClause());
pstmt.setObject(1, value); }
rsEmbedded = pstmt.executeQuery();
while (rsEmbedded.next())
{
//System.out.println("Trifon - tableEmbedded.getTableName()_ID = "+ tableEmbedded.getTableName() + "_ID");
int embeddedID = rsEmbedded.getInt(tableEmbedded.getTableName() + "_ID");
PO poEmbedded = tableEmbedded.getPO (embeddedID, masterPO.get_TrxName());
Element embeddedElement = outDocument.createElement(formatLine.getValue()); Object value = masterPO.get_Value(tableEmbedded.getTableName() + "_ID");
if (formatLine.getDescription() != null && !"".equals(formatLine.getDescription())) { if (value == null)
embeddedElement.appendChild(outDocument.createComment(formatLine.getDescription())); {
} continue;
generateExportFormat(embeddedElement, embeddedFormat, rsEmbedded, poEmbedded, embeddedID, variableMap); }
rootElement.appendChild(embeddedElement);
}
} finally { Collection<PO> instances = new Query(masterPO.getCtx(),tableEmbedded.getTableName(), whereClause.toString(),masterPO.get_TrxName())
try { .setClient_ID()
if (rsEmbedded != null) rsEmbedded.close(); .setParameters(value)
if (pstmt != null) pstmt.close(); .list();
} catch (SQLException ex) { }
rsEmbedded = null; for (PO instance : instances)
pstmt = null; {
Element embeddedElement = outDocument.createElement(formatLine.getValue());
if (formatLine.getDescription() != null && !"".equals(formatLine.getDescription()))
{
embeddedElement.appendChild(outDocument.createComment(formatLine.getDescription()));
}
generateExportFormat(embeddedElement, embeddedFormat, instance, instance.get_ID(), variableMap);
rootElement.appendChild(embeddedElement);
} }
} }

View File

@ -25,7 +25,7 @@
* * * *
* Sponsors: * * Sponsors: *
* - E-evolution (http://www.e-evolution.com/) * * - E-evolution (http://www.e-evolution.com/) *
**********************************************************************/ *********************************************************************/
package org.adempiere.process.rpl.imp; package org.adempiere.process.rpl.imp;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -40,8 +40,8 @@ import java.util.Properties;
import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathExpressionException;
import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.AdempiereException;
import org.adempiere.process.rpl.exp.ExportHelper;
import org.adempiere.process.rpl.XMLHelper; import org.adempiere.process.rpl.XMLHelper;
import org.adempiere.process.rpl.exp.ExportHelper;
import org.compiere.model.I_AD_Client; import org.compiere.model.I_AD_Client;
import org.compiere.model.MClient; import org.compiere.model.MClient;
import org.compiere.model.MColumn; import org.compiere.model.MColumn;
@ -52,7 +52,9 @@ import org.compiere.model.MTable;
import org.compiere.model.ModelValidator; import org.compiere.model.ModelValidator;
import org.compiere.model.PO; import org.compiere.model.PO;
import org.compiere.model.Query; import org.compiere.model.Query;
import org.compiere.model.X_AD_ReplicationDocument;
import org.compiere.model.X_AD_ReplicationTable; import org.compiere.model.X_AD_ReplicationTable;
import org.compiere.process.DocAction;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
import org.compiere.util.Env; import org.compiere.util.Env;
@ -69,6 +71,8 @@ import org.w3c.dom.NodeList;
* @author victor.perez@e-evolution.com, e-Evolution * @author victor.perez@e-evolution.com, e-Evolution
* <li>[ 2195090 ] Stabilization of replication * <li>[ 2195090 ] Stabilization of replication
* <li>https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2936561&group_id=176962 * <li>https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2936561&group_id=176962
* <li>BF [2947622] The replication ID (Primary Key) is not working
* <li>https://sourceforge.net/tracker/?func=detail&aid=2947622&group_id=176962&atid=879332
* *
*/ */
public class ImportHelper { public class ImportHelper {
@ -79,12 +83,6 @@ public class ImportHelper {
/** Static Logger */ /** Static Logger */
private static CLogger s_log = CLogger.getCLogger(ImportHelper.class); private static CLogger s_log = CLogger.getCLogger(ImportHelper.class);
/** Date Time Format */
private SimpleDateFormat m_dateTimeFormat = null;
/** Date Format */
private SimpleDateFormat m_dateFormat = null;
/** Custom Date Format */ /** Custom Date Format */
private SimpleDateFormat m_customDateFormat = null; private SimpleDateFormat m_customDateFormat = null;
@ -94,9 +92,6 @@ public class ImportHelper {
public ImportHelper(Properties ctx) public ImportHelper(Properties ctx)
{ {
this.ctx = ctx; this.ctx = ctx;
// Construct DateFromat and DateTimeFormat
m_dateTimeFormat = DisplayType.getDateFormat(DisplayType.DateTime, Env.getLanguage(ctx));
m_dateFormat = DisplayType.getDateFormat(DisplayType.Date, Env.getLanguage(ctx));
} }
/** /**
@ -171,65 +166,62 @@ public class ImportHelper {
if(po != null) if(po != null)
{ {
// Here must invoke other method else we get cycle... if(MReplicationStrategy.REPLICATION_TABLE==ReplicationMode)
if (ModelValidator.TYPE_BEFORE_DELETE == ReplicationEvent {
|| ModelValidator.TYPE_BEFORE_DELETE_REPLICATION == ReplicationEvent // Here must invoke other method else we get cycle...
|| ModelValidator.TYPE_DELETE == ReplicationEvent) if ( ModelValidator.TYPE_BEFORE_DELETE == ReplicationEvent
{ || ModelValidator.TYPE_BEFORE_DELETE_REPLICATION == ReplicationEvent
po.deleteEx(true); || ModelValidator.TYPE_DELETE == ReplicationEvent)
} {
else po.deleteEx(true);
{ }
if(X_AD_ReplicationTable.REPLICATIONTYPE_Broadcast.equals(ReplicationType)) else
{ {
po.saveReplica(true); if(X_AD_ReplicationTable.REPLICATIONTYPE_Broadcast.equals(ReplicationType))
MReplicationStrategy rplStrategy = new MReplicationStrategy(client.getCtx(), client.getAD_ReplicationStrategy_ID(), null); {
ExportHelper expHelper = new ExportHelper(client, rplStrategy); po.saveReplica(true);
expHelper.exportRecord( po, MReplicationStrategy rplStrategy = new MReplicationStrategy(client.getCtx(), client.getAD_ReplicationStrategy_ID(), null);
MReplicationStrategy.REPLICATION_TABLE, ExportHelper expHelper = new ExportHelper(client, rplStrategy);
X_AD_ReplicationTable.REPLICATIONTYPE_Merge, expHelper.exportRecord( po,
ModelValidator.TYPE_AFTER_CHANGE); MReplicationStrategy.REPLICATION_TABLE,
} X_AD_ReplicationTable.REPLICATIONTYPE_Merge,
else if(X_AD_ReplicationTable.REPLICATIONTYPE_Merge.equals(ReplicationType) ModelValidator.TYPE_AFTER_CHANGE);
|| X_AD_ReplicationTable.REPLICATIONTYPE_Reference.equals(ReplicationType))
{
po.saveReplica(true);
}
/*else if (X_AD_ReplicationTable.REPLICATIONTYPE_Reference.equals(ReplicationType))
{
//Do nothing??
}*/
else if(X_AD_ReplicationTable.REPLICATIONTYPE_Local.equals(ReplicationType))
{
//Do nothing??
}
else
{
// Replication Type is not one of the possible values...ERROR
throw new Exception(Msg.getMsg(ctx, "EXPReplicationTypeNonValidType"));
}
}
} else if(X_AD_ReplicationTable.REPLICATIONTYPE_Merge.equals(ReplicationType)
|| X_AD_ReplicationTable.REPLICATIONTYPE_Reference.equals(ReplicationType))
{
if(po.is_Changed())
{
po.saveReplica(true);
}
}
/*else if (X_AD_ReplicationTable.REPLICATIONTYPE_Reference.equals(ReplicationType))
{
//Do nothing??
}*/
else if(X_AD_ReplicationTable.REPLICATIONTYPE_Local.equals(ReplicationType))
{
//Do nothing??
}
else
{
// Replication Type is not one of the possible values...ERROR
throw new Exception(Msg.getMsg(ctx, "EXPReplicationTypeNonValidType"));
}
}
}
else if(MReplicationStrategy.REPLICATION_DOCUMENT == ReplicationMode
&& X_AD_ReplicationDocument.REPLICATIONTYPE_Merge.equals(ReplicationType)
&& po instanceof DocAction)
{
Env.setContext(po.getCtx(), "#AD_Client_ID", po.getAD_Client_ID());
DocAction document = (DocAction)po;
document.processIt(document.getDocAction());
po.saveEx();
}
} }
result.append("Save Successful ;"); result.append("Save Successful ;");
/*if (resultSave)
{
if(ReplicationMode == MReplicationStrategy.REPLICATION_DOCUMENT &&
ReplicationType == X_AD_ReplicationDocument.REPLICATIONTYPE_Merge)
{
String status = po.get_ValueAsString("DocStatus");
String action = po.get_ValueAsString("DocAction");
DocAction m_document;
m_document=(DocAction) po;
DocumentEngine engine = new DocumentEngine (m_document, status);
engine.processIt (action);
}
// Success in save
} else {
// Failed in save
throw new Exception(Msg.getMsg(ctx, "EXPFormatFailedSave"));
}*/
} }
/** /**
@ -239,7 +231,6 @@ public class ImportHelper {
* @throws Exception * @throws Exception
* @throws XPathExpressionException * @throws XPathExpressionException
*/ */
@SuppressWarnings("unchecked")
private PO importElement(Properties ctx, StringBuffer result, Element rootElement, private PO importElement(Properties ctx, StringBuffer result, Element rootElement,
MEXPFormat expFormat, String ReplicationType, String trxName) throws Exception, XPathExpressionException MEXPFormat expFormat, String ReplicationType, String trxName) throws Exception, XPathExpressionException
{ {
@ -279,7 +270,7 @@ public class ImportHelper {
log.info("=================== Beginnig of Format Line ==============================="); log.info("=================== Beginnig of Format Line ===============================");
log.info("formatLine: [" + formatLine.toString() + "]"); log.info("formatLine: [" + formatLine.toString() + "]");
//Get the value //Get the value
Object value = getValueFromFormat(formatLine,po,rootElement,result,ReplicationType,trxName); Object value = getValueFromFormat(formatLine,po,rootElement,result,ReplicationType);
if (value == null || value.toString().equals("")) if (value == null || value.toString().equals(""))
continue; continue;
//Set the value //Set the value
@ -300,7 +291,7 @@ public class ImportHelper {
* @throws Exception * @throws Exception
*/ */
private Object getValueFromFormat(MEXPFormatLine line,PO po,Element rootElement, private Object getValueFromFormat(MEXPFormatLine line,PO po,Element rootElement,
StringBuffer result, String ReplicationType, String trxName) throws Exception StringBuffer result, String ReplicationType) throws Exception
{ {
Object value = null; Object value = null;
@ -315,7 +306,7 @@ public class ImportHelper {
{ {
// Referenced Export Format // Referenced Export Format
//get from cache //get from cache
MEXPFormat referencedExpFormat = MEXPFormat.get(ctx, line.getEXP_EmbeddedFormat_ID(), trxName); MEXPFormat referencedExpFormat = MEXPFormat.get(ctx, line.getEXP_EmbeddedFormat_ID(), po.get_TrxName());
log.info("referencedExpFormat = " + referencedExpFormat); log.info("referencedExpFormat = " + referencedExpFormat);
int refRecord_ID = 0; int refRecord_ID = 0;
@ -329,7 +320,7 @@ public class ImportHelper {
log.info("referencedNode = " + referencedNode); log.info("referencedNode = " + referencedNode);
if(referencedNode!=null) if(referencedNode!=null)
{ {
refRecord_ID = getID(ctx, referencedExpFormat, referencedNode, line.getValue(), trxName); refRecord_ID = getID(ctx, referencedExpFormat, referencedNode, line.getValue(), po.get_TrxName());
log.info("refRecord_ID = " + refRecord_ID); log.info("refRecord_ID = " + refRecord_ID);
value = new Integer(refRecord_ID); value = new Integer(refRecord_ID);
} }
@ -349,7 +340,7 @@ public class ImportHelper {
// Embedded Export Format It is used for Parent-Son records like Order&OrderLine // Embedded Export Format It is used for Parent-Son records like Order&OrderLine
//get from cache //get from cache
MEXPFormat referencedExpFormat = MEXPFormat.get(ctx, line.getEXP_EmbeddedFormat_ID(), trxName); MEXPFormat referencedExpFormat = MEXPFormat.get(ctx, line.getEXP_EmbeddedFormat_ID(), po.get_TrxName());
log.info("embeddedExpFormat = " + referencedExpFormat); log.info("embeddedExpFormat = " + referencedExpFormat);
NodeList nodeList = XMLHelper.getNodeList("/"+rootElement.getNodeName() + "/" + line.getValue(), rootElement); NodeList nodeList = XMLHelper.getNodeList("/"+rootElement.getNodeName() + "/" + line.getValue(), rootElement);
@ -361,7 +352,7 @@ public class ImportHelper {
PO embeddedPo = null; PO embeddedPo = null;
// Import embedded PO // Import embedded PO
log.info("=== BEGIN RECURSION CALL ==="); log.info("=== BEGIN RECURSION CALL ===");
embeddedPo = importElement(ctx, result, referencedElement, referencedExpFormat,ReplicationType, trxName); embeddedPo = importElement(ctx, result, referencedElement, referencedExpFormat,ReplicationType, po.get_TrxName());
log.info("embeddedPo = " + embeddedPo); log.info("embeddedPo = " + embeddedPo);
embeddedPo.saveReplica(true); embeddedPo.saveReplica(true);
result.append(" Embedded Save Successful ; "); result.append(" Embedded Save Successful ; ");
@ -394,15 +385,16 @@ public class ImportHelper {
*/ */
private void setReplicaValues(Object value,MEXPFormatLine line,PO po,StringBuffer result)throws Exception private void setReplicaValues(Object value,MEXPFormatLine line,PO po,StringBuffer result)throws Exception
{ {
MColumn column = MColumn.get(ctx, line.getAD_Column_ID());
log.info("column=[" + column + "]");
if (value !=null) if (value !=null)
{ {
if (!MEXPFormatLine.TYPE_EmbeddedEXPFormat.equals(line.getType()) ) if (!MEXPFormatLine.TYPE_EmbeddedEXPFormat.equals(line.getType()) )
{ {
MColumn column = MColumn.get(ctx, line.getAD_Column_ID());
log.info("column=[" + column + "]");
// Clazz // Clazz
Class clazz = DisplayType.getClass(column.getAD_Reference_ID(), true); Class<?> clazz = DisplayType.getClass(column.getAD_Reference_ID(), true);
// Handle Posted // Handle Posted
if (column.getColumnName().equalsIgnoreCase("Posted") if (column.getColumnName().equalsIgnoreCase("Posted")
@ -481,7 +473,11 @@ public class ImportHelper {
} }
else if(DisplayType.YesNo == column.getAD_Reference_ID()) else if(DisplayType.YesNo == column.getAD_Reference_ID())
{ {
po.set_ValueOfColumn(line.getAD_Column_ID(), value); if(clazz == Boolean.class)
{
String v = value.toString().equals("true") ? "Y" : "N";
po.set_ValueOfColumn(line.getAD_Column_ID(), v);
}
} }
else else
{ {
@ -491,7 +487,8 @@ public class ImportHelper {
if(clazz == Boolean.class) if(clazz == Boolean.class)
{ {
po.set_ValueOfColumn(line.getAD_Column_ID(), value); String v = value.toString().equals("true") ? "Y" : "N";
po.set_ValueOfColumn(line.getAD_Column_ID(), v);
} }
else else
{ {
@ -519,7 +516,7 @@ public class ImportHelper {
{ {
final String whereClause = I_AD_Client.COLUMNNAME_Value + "= ? "; final String whereClause = I_AD_Client.COLUMNNAME_Value + "= ? ";
MClient result = new Query(ctx,I_AD_Client.Table_Name,whereClause,trxName) MClient result = new Query(ctx,I_AD_Client.Table_Name,whereClause,trxName)
.setParameters(new Object[]{value}) .setParameters(value)
.firstOnly(); .firstOnly();
s_log.info("Client_Value =[" + value + "]"); s_log.info("Client_Value =[" + value + "]");
@ -565,6 +562,7 @@ public class ImportHelper {
throw new AdempiereException(Msg.getMsg(ctx, "EXPFormatLineNoUniqueColumns")); throw new AdempiereException(Msg.getMsg(ctx, "EXPFormatLineNoUniqueColumns"));
} }
int replication_id = 0;
Object[] cols = new Object[uniqueFormatLines.size()]; Object[] cols = new Object[uniqueFormatLines.size()];
Object[] params = new Object[uniqueFormatLines.size()]; Object[] params = new Object[uniqueFormatLines.size()];
StringBuffer whereClause= new StringBuffer(""); StringBuffer whereClause= new StringBuffer("");
@ -634,6 +632,10 @@ public class ImportHelper {
{ {
//double doubleValue = Double.parseDouble(value.toString()); //double doubleValue = Double.parseDouble(value.toString());
value = new Integer(value.toString()); value = new Integer(value.toString());
if (DisplayType.ID == column.getAD_Reference_ID())
{
replication_id = (Integer) value;
}
} }
else else
{ {
@ -671,7 +673,14 @@ public class ImportHelper {
if(values.size()<=0)//Means that is a new record if(values.size()<=0)//Means that is a new record
{ {
return MTable.get(ctx, expFormat.getAD_Table_ID()).getPO(0,trxName); PO po = po = MTable.get(ctx, expFormat.getAD_Table_ID()).getPO(0,trxName);
if (replication_id > 0 )
{
po.set_CustomColumn(po.get_KeyColumns()[0], replication_id);
}
return po;
} }
return values.get(0);//Return the first (unique) record. return values.get(0);//Return the first (unique) record.

View File

@ -31,7 +31,6 @@ import java.util.logging.Level;
import org.adempiere.exceptions.DBException; import org.adempiere.exceptions.DBException;
import org.compiere.model.MAccount; import org.compiere.model.MAccount;
import org.compiere.model.MAcctSchema; import org.compiere.model.MAcctSchema;
import org.compiere.model.MClient;
import org.compiere.model.MConversionRate; import org.compiere.model.MConversionRate;
import org.compiere.model.MDocType; import org.compiere.model.MDocType;
import org.compiere.model.MNote; import org.compiere.model.MNote;
@ -358,6 +357,9 @@ public abstract class Doc
/** Log per Document */ /** Log per Document */
protected CLogger log = CLogger.getCLogger(getClass()); protected CLogger log = CLogger.getCLogger(getClass());
/* If the transaction must be managed locally (false if it's managed externally by the caller) */
private boolean m_manageLocalTrx;
/************************************************************************** /**************************************************************************
* Constructor * Constructor
@ -396,8 +398,11 @@ public abstract class Doc
// Document Type // Document Type
setDocumentType (defaultDocumentType); setDocumentType (defaultDocumentType);
m_trxName = trxName; m_trxName = trxName;
if (m_trxName == null) m_manageLocalTrx = false;
if (m_trxName == null) {
m_trxName = "Post" + m_DocumentType + p_po.get_ID(); m_trxName = "Post" + m_DocumentType + p_po.get_ID();
m_manageLocalTrx = true;
}
p_po.set_TrxName(m_trxName); p_po.set_TrxName(m_trxName);
// Amounts // Amounts
@ -551,7 +556,7 @@ public abstract class Doc
// Lock Record ---- // Lock Record ----
String trxName = null; // outside trx if on server String trxName = null; // outside trx if on server
if (MClient.isClientAccounting()) if (! m_manageLocalTrx)
trxName = getTrxName(); // on trx if it's in client trxName = getTrxName(); // on trx if it's in client
StringBuffer sql = new StringBuffer ("UPDATE "); StringBuffer sql = new StringBuffer ("UPDATE ");
sql.append(get_TableName()).append( " SET Processing='Y' WHERE ") sql.append(get_TableName()).append( " SET Processing='Y' WHERE ")
@ -830,8 +835,10 @@ public abstract class Doc
else else
{ {
log.log(Level.SEVERE, "(fact not saved) ... rolling back"); log.log(Level.SEVERE, "(fact not saved) ... rolling back");
trx.rollback(); if (m_manageLocalTrx) {
trx.close(); trx.rollback();
trx.close();
}
unlock(); unlock();
return STATUS_Error; return STATUS_Error;
} }
@ -841,30 +848,36 @@ public abstract class Doc
if (!save(getTrxName())) // contains unlock & document status update if (!save(getTrxName())) // contains unlock & document status update
{ {
log.log(Level.SEVERE, "(doc not saved) ... rolling back"); log.log(Level.SEVERE, "(doc not saved) ... rolling back");
trx.rollback(); if (m_manageLocalTrx) {
trx.close(); trx.rollback();
trx.close();
}
unlock(); unlock();
return STATUS_Error; return STATUS_Error;
} }
// Success // Success
trx.commit(true); if (m_manageLocalTrx) {
trx.close(); trx.commit(true);
trx = null; trx.close();
trx = null;
}
// *** Transaction End *** // *** Transaction End ***
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, "... rolling back", e); log.log(Level.SEVERE, "... rolling back", e);
status = STATUS_Error; status = STATUS_Error;
try { if (m_manageLocalTrx) {
if (trx != null) try {
trx.rollback(); if (trx != null)
} catch (Exception e2) {} trx.rollback();
try { } catch (Exception e2) {}
if (trx != null) try {
trx.close(); if (trx != null)
trx = null; trx.close();
} catch (Exception e3) {} trx = null;
} catch (Exception e3) {}
}
unlock(); unlock();
} }
p_Status = status; p_Status = status;
@ -886,7 +899,7 @@ public abstract class Doc
private void unlock() private void unlock()
{ {
String trxName = null; // outside trx if on server String trxName = null; // outside trx if on server
if (MClient.isClientAccounting()) if (! m_manageLocalTrx)
trxName = getTrxName(); // on trx if it's in client trxName = getTrxName(); // on trx if it's in client
StringBuffer sql = new StringBuffer ("UPDATE "); StringBuffer sql = new StringBuffer ("UPDATE ");
sql.append(get_TableName()).append( " SET Processing='N' WHERE ") sql.append(get_TableName()).append( " SET Processing='N' WHERE ")
@ -2013,6 +2026,38 @@ public abstract class Doc
return 0; return 0;
} // getC_Project_ID } // getC_Project_ID
/**
* Get C_ProjectPhase_ID
* @return Project Phase
*/
public int getC_ProjectPhase_ID()
{
int index = p_po.get_ColumnIndex("C_ProjectPhase_ID");
if (index != -1)
{
Integer ii = (Integer)p_po.get_Value(index);
if (ii != null)
return ii.intValue();
}
return 0;
} // getC_ProjectPhase_ID
/**
* Get C_ProjectTask_ID
* @return Project Task
*/
public int getC_ProjectTask_ID()
{
int index = p_po.get_ColumnIndex("C_ProjectTask_ID");
if (index != -1)
{
Integer ii = (Integer)p_po.get_Value(index);
if (ii != null)
return ii.intValue();
}
return 0;
} // getC_ProjectTask_ID
/** /**
* Get C_SalesRegion_ID * Get C_SalesRegion_ID
* @return Sales Region * @return Sales Region

View File

@ -983,6 +983,38 @@ public class DocLine
return 0; return 0;
} // getC_Project_ID } // getC_Project_ID
/**
* Get Project Phase
* @return C_ProjectPhase_ID
*/
public int getC_ProjectPhase_ID()
{
int index = p_po.get_ColumnIndex("C_ProjectPhase_ID");
if (index != -1)
{
Integer ii = (Integer)p_po.get_Value(index);
if (ii != null)
return ii.intValue();
}
return 0;
} // getC_ProjectPhase_ID
/**
* Get Project Task
* @return C_ProjectTask_ID
*/
public int getC_ProjectTask_ID()
{
int index = p_po.get_ColumnIndex("C_ProjectTask_ID");
if (index != -1)
{
Integer ii = (Integer)p_po.get_Value(index);
if (ii != null)
return ii.intValue();
}
return 0;
} // getC_ProjectTask_ID
/** /**
* Get Campaign * Get Campaign
* @return C_Campaign_ID * @return C_Campaign_ID

View File

@ -216,6 +216,8 @@ public class Doc_MatchInv extends Doc
pv.setC_Activity_ID(m_invoiceLine.getC_Activity_ID()); pv.setC_Activity_ID(m_invoiceLine.getC_Activity_ID());
pv.setC_Campaign_ID(m_invoiceLine.getC_Campaign_ID()); pv.setC_Campaign_ID(m_invoiceLine.getC_Campaign_ID());
pv.setC_Project_ID(m_invoiceLine.getC_Project_ID()); pv.setC_Project_ID(m_invoiceLine.getC_Project_ID());
pv.setC_ProjectPhase_ID(m_invoiceLine.getC_ProjectPhase_ID());
pv.setC_ProjectTask_ID(m_invoiceLine.getC_ProjectTask_ID());
pv.setC_UOM_ID(m_invoiceLine.getC_UOM_ID()); pv.setC_UOM_ID(m_invoiceLine.getC_UOM_ID());
pv.setUser1_ID(m_invoiceLine.getUser1_ID()); pv.setUser1_ID(m_invoiceLine.getUser1_ID());
pv.setUser2_ID(m_invoiceLine.getUser2_ID()); pv.setUser2_ID(m_invoiceLine.getUser2_ID());
@ -251,6 +253,8 @@ public class Doc_MatchInv extends Doc
cr.setC_Activity_ID(m_invoiceLine.getC_Activity_ID()); cr.setC_Activity_ID(m_invoiceLine.getC_Activity_ID());
cr.setC_Campaign_ID(m_invoiceLine.getC_Campaign_ID()); cr.setC_Campaign_ID(m_invoiceLine.getC_Campaign_ID());
cr.setC_Project_ID(m_invoiceLine.getC_Project_ID()); cr.setC_Project_ID(m_invoiceLine.getC_Project_ID());
cr.setC_ProjectPhase_ID(m_invoiceLine.getC_ProjectPhase_ID());
cr.setC_ProjectTask_ID(m_invoiceLine.getC_ProjectTask_ID());
cr.setC_UOM_ID(m_invoiceLine.getC_UOM_ID()); cr.setC_UOM_ID(m_invoiceLine.getC_UOM_ID());
cr.setUser1_ID(m_invoiceLine.getUser1_ID()); cr.setUser1_ID(m_invoiceLine.getUser1_ID());
cr.setUser2_ID(m_invoiceLine.getUser2_ID()); cr.setUser2_ID(m_invoiceLine.getUser2_ID());
@ -293,6 +297,8 @@ public class Doc_MatchInv extends Doc
pv.setC_Activity_ID(m_invoiceLine.getC_Activity_ID()); pv.setC_Activity_ID(m_invoiceLine.getC_Activity_ID());
pv.setC_Campaign_ID(m_invoiceLine.getC_Campaign_ID()); pv.setC_Campaign_ID(m_invoiceLine.getC_Campaign_ID());
pv.setC_Project_ID(m_invoiceLine.getC_Project_ID()); pv.setC_Project_ID(m_invoiceLine.getC_Project_ID());
pv.setC_ProjectPhase_ID(m_invoiceLine.getC_ProjectPhase_ID());
pv.setC_ProjectTask_ID(m_invoiceLine.getC_ProjectTask_ID());
pv.setC_UOM_ID(m_invoiceLine.getC_UOM_ID()); pv.setC_UOM_ID(m_invoiceLine.getC_UOM_ID());
pv.setUser1_ID(m_invoiceLine.getUser1_ID()); pv.setUser1_ID(m_invoiceLine.getUser1_ID());
pv.setUser2_ID(m_invoiceLine.getUser2_ID()); pv.setUser2_ID(m_invoiceLine.getUser2_ID());

View File

@ -204,6 +204,8 @@ public class Doc_MatchPO extends Doc
cr.setC_Activity_ID(m_oLine.getC_Activity_ID()); cr.setC_Activity_ID(m_oLine.getC_Activity_ID());
cr.setC_Campaign_ID(m_oLine.getC_Campaign_ID()); cr.setC_Campaign_ID(m_oLine.getC_Campaign_ID());
cr.setC_Project_ID(m_oLine.getC_Project_ID()); cr.setC_Project_ID(m_oLine.getC_Project_ID());
cr.setC_ProjectPhase_ID(m_oLine.getC_ProjectPhase_ID());
cr.setC_ProjectTask_ID(m_oLine.getC_ProjectTask_ID());
cr.setC_UOM_ID(m_oLine.getC_UOM_ID()); cr.setC_UOM_ID(m_oLine.getC_UOM_ID());
cr.setUser1_ID(m_oLine.getUser1_ID()); cr.setUser1_ID(m_oLine.getUser1_ID());
cr.setUser2_ID(m_oLine.getUser2_ID()); cr.setUser2_ID(m_oLine.getUser2_ID());
@ -220,6 +222,8 @@ public class Doc_MatchPO extends Doc
dr.setC_Activity_ID(m_oLine.getC_Activity_ID()); dr.setC_Activity_ID(m_oLine.getC_Activity_ID());
dr.setC_Campaign_ID(m_oLine.getC_Campaign_ID()); dr.setC_Campaign_ID(m_oLine.getC_Campaign_ID());
dr.setC_Project_ID(m_oLine.getC_Project_ID()); dr.setC_Project_ID(m_oLine.getC_Project_ID());
dr.setC_ProjectPhase_ID(m_oLine.getC_ProjectPhase_ID());
dr.setC_ProjectTask_ID(m_oLine.getC_ProjectTask_ID());
dr.setC_UOM_ID(m_oLine.getC_UOM_ID()); dr.setC_UOM_ID(m_oLine.getC_UOM_ID());
dr.setUser1_ID(m_oLine.getUser1_ID()); dr.setUser1_ID(m_oLine.getUser1_ID());
dr.setUser2_ID(m_oLine.getUser2_ID()); dr.setUser2_ID(m_oLine.getUser2_ID());

View File

@ -394,6 +394,14 @@ public final class FactLine extends X_Fact_Acct
setC_Project_ID (m_docLine.getC_Project_ID()); setC_Project_ID (m_docLine.getC_Project_ID());
if (getC_Project_ID() == 0) if (getC_Project_ID() == 0)
setC_Project_ID (m_doc.getC_Project_ID()); setC_Project_ID (m_doc.getC_Project_ID());
if (m_docLine != null)
setC_ProjectPhase_ID(m_docLine.getC_ProjectPhase_ID());
if (getC_ProjectPhase_ID() == 0)
setC_ProjectPhase_ID (m_doc.getC_ProjectPhase_ID());
if (m_docLine != null)
setC_ProjectTask_ID(m_docLine.getC_ProjectTask_ID());
if (getC_ProjectTask_ID() == 0)
setC_ProjectTask_ID (m_doc.getC_ProjectTask_ID());
// Campaign // Campaign
if (m_docLine != null) if (m_docLine != null)
setC_Campaign_ID (m_docLine.getC_Campaign_ID()); setC_Campaign_ID (m_docLine.getC_Campaign_ID());
@ -1092,6 +1100,8 @@ public final class FactLine extends X_Fact_Acct
// Dimensions // Dimensions
setAD_OrgTrx_ID(fact.getAD_OrgTrx_ID()); setAD_OrgTrx_ID(fact.getAD_OrgTrx_ID());
setC_Project_ID (fact.getC_Project_ID()); setC_Project_ID (fact.getC_Project_ID());
setC_ProjectPhase_ID(fact.getC_ProjectPhase_ID());
setC_ProjectTask_ID(fact.getC_ProjectTask_ID());
setC_Activity_ID(fact.getC_Activity_ID()); setC_Activity_ID(fact.getC_Activity_ID());
setC_Campaign_ID(fact.getC_Campaign_ID()); setC_Campaign_ID(fact.getC_Campaign_ID());
setC_SalesRegion_ID(fact.getC_SalesRegion_ID()); setC_SalesRegion_ID(fact.getC_SalesRegion_ID());

View File

@ -0,0 +1,28 @@
/******************************************************************************
* Copyright (C) 2010 Low Heng Sin *
* Copyright (C) 2010 Idalica Corporation *
* 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. *
*****************************************************************************/
package org.compiere.model;
/**
*
* @author hengsin
*
*/
public interface AdempiereProcessor2 {
/**
* @return true if previous DateNextRun should be use as base to calculate the new
* DateNextRun value. False to follow the legacy behaviour where current
* server time is use as the base to the new DateNextRun value.
*/
public boolean isIgnoreProcessingTime();
}

View File

@ -633,12 +633,16 @@ public class CalloutOrder extends CalloutEngine
+ "WHERE pl.C_Currency_ID=c.C_Currency_ID" + "WHERE pl.C_Currency_ID=c.C_Currency_ID"
+ " AND pl.M_PriceList_ID=plv.M_PriceList_ID" + " AND pl.M_PriceList_ID=plv.M_PriceList_ID"
+ " AND pl.M_PriceList_ID=? " // 1 + " AND pl.M_PriceList_ID=? " // 1
+ " AND plv.ValidFrom <= ? "
+ "ORDER BY plv.ValidFrom DESC"; + "ORDER BY plv.ValidFrom DESC";
// Use newest price list - may not be future // Use newest price list - may not be future
try try
{ {
pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, M_PriceList_ID.intValue()); pstmt.setInt(1, M_PriceList_ID.intValue());
Timestamp date = Env.getContextAsDate(ctx, WindowNo, "DateOrdered");
pstmt.setTimestamp(2, date);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
@ -706,10 +710,25 @@ public class CalloutOrder extends CalloutEngine
// //
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID"); int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
pp.setM_PriceList_ID(M_PriceList_ID); pp.setM_PriceList_ID(M_PriceList_ID);
Timestamp orderDate = (Timestamp)mTab.getValue("DateOrdered");
/** PLV is only accurate if PL selected in header */ /** PLV is only accurate if PL selected in header */
int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_Version_ID"); int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_Version_ID");
if ( M_PriceList_Version_ID == 0 && M_PriceList_ID > 0)
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "SELECT plv.M_PriceList_Version_ID "
+ "FROM M_PriceList_Version plv "
+ "WHERE plv.M_PriceList_ID=? " // 1
+ " AND plv.ValidFrom <= ? "
+ "ORDER BY plv.ValidFrom DESC";
// Use newest price list - may not be future
M_PriceList_Version_ID = DB.getSQLValueEx(null, sql, M_PriceList_ID, orderDate);
if ( M_PriceList_Version_ID > 0 )
Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", M_PriceList_Version_ID );
}
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID); pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
Timestamp orderDate = (Timestamp)mTab.getValue("DateOrdered");
pp.setPriceDate(orderDate); pp.setPriceDate(orderDate);
// //
mTab.setValue("PriceList", pp.getPriceList()); mTab.setValue("PriceList", pp.getPriceList());

View File

@ -323,21 +323,16 @@ public class GridField
return false; return false;
// Numeric Keys and Created/Updated as well as // Numeric Keys and Created/Updated as well as
// DocumentNo/Value/ASI are not mandatory (persistence layer manages them) // DocumentNo/Value/ASI ars not mandatory (persistency layer manages them)
if (m_vo.ColumnName.equals("DocumentNo") && m_vo.AD_Column_ID == 53251){ if (m_gridTab != null && // if gridtab doesn't exist then it's not a window field (probably a process parameter field)
// TODO - Find why Report Parameter marked as Mandatory is not displayed as Mandatory? ( (m_vo.IsKey && m_vo.ColumnName.endsWith("_ID"))
// Find better solution?
// https://sourceforge.net/tracker/?func=detail&aid=2902292&group_id=176962&atid=879334
// https://sourceforge.net/tracker/?func=detail&aid=2897730&group_id=176962&atid=879332
return true;
} else if ((m_vo.IsKey && m_vo.ColumnName.endsWith("_ID"))
|| m_vo.ColumnName.startsWith("Created") || m_vo.ColumnName.startsWith("Updated") || m_vo.ColumnName.startsWith("Created") || m_vo.ColumnName.startsWith("Updated")
|| m_vo.ColumnName.equals("Value") || m_vo.ColumnName.equals("Value")
|| m_vo.ColumnName.equals("DocumentNo") || m_vo.ColumnName.equals("DocumentNo")
|| m_vo.ColumnName.equals("M_AttributeSetInstance_ID")) // 0 is valid || m_vo.ColumnName.equals("M_AttributeSetInstance_ID") // 0 is valid
{ )
)
return false; return false;
}
// Mandatory if displayed // Mandatory if displayed
return isDisplayed (checkContext); return isDisplayed (checkContext);
@ -1286,6 +1281,19 @@ public class GridField
m_inserting = inserting; m_inserting = inserting;
m_error = false; // reset error m_error = false; // reset error
updateContext();
// Does not fire, if same value
Object oldValue = m_oldValue;
if (inserting)
oldValue = INSERTING;
m_propertyChangeListeners.firePropertyChange(PROPERTY, oldValue, m_value);
} // setValue
/**
* Update env. context with current value
*/
public void updateContext() {
// Set Context // Set Context
if (m_vo.displayType == DisplayType.Text if (m_vo.displayType == DisplayType.Text
|| m_vo.displayType == DisplayType.Memo || m_vo.displayType == DisplayType.Memo
@ -1294,15 +1302,15 @@ public class GridField
|| m_vo.displayType == DisplayType.RowID || m_vo.displayType == DisplayType.RowID
|| isEncrypted()) || isEncrypted())
; // ignore ; // ignore
else if (newValue instanceof Boolean) else if (m_value instanceof Boolean)
{ {
backupValue(); // teo_sarca [ 1699826 ] backupValue(); // teo_sarca [ 1699826 ]
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName, Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName,
((Boolean)newValue).booleanValue()); ((Boolean)m_value).booleanValue());
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName, Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName,
m_value==null ? null : (((Boolean)m_value) ? "Y" : "N")); m_value==null ? null : (((Boolean)m_value) ? "Y" : "N"));
} }
else if (newValue instanceof Timestamp) else if (m_value instanceof Timestamp)
{ {
backupValue(); // teo_sarca [ 1699826 ] backupValue(); // teo_sarca [ 1699826 ]
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName, (Timestamp)m_value); Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName, (Timestamp)m_value);
@ -1317,13 +1325,7 @@ public class GridField
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName, Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName,
m_value==null ? null : m_value.toString()); m_value==null ? null : m_value.toString());
} }
}
// Does not fire, if same value
Object oldValue = m_oldValue;
if (inserting)
oldValue = INSERTING;
m_propertyChangeListeners.firePropertyChange(PROPERTY, oldValue, m_value);
} // setValue
/** /**
* Set Value and Validate * Set Value and Validate

View File

@ -48,6 +48,7 @@ import org.compiere.util.Env;
import org.compiere.util.Ini; import org.compiere.util.Ini;
import org.compiere.util.MSort; import org.compiere.util.MSort;
import org.compiere.util.SecureEngine; import org.compiere.util.SecureEngine;
import org.compiere.util.Trx;
import org.compiere.util.ValueNamePair; import org.compiere.util.ValueNamePair;
/** /**
@ -3201,6 +3202,7 @@ private Object[] getDataAtRow(int row)
private PreparedStatement m_pstmt = null; private PreparedStatement m_pstmt = null;
private ResultSet m_rs = null; private ResultSet m_rs = null;
private Trx trx = null;
/** /**
* Open ResultSet * Open ResultSet
@ -3240,17 +3242,22 @@ private Object[] getDataAtRow(int row)
if (rows == 0) if (rows == 0)
info.append(" - ").append(m_SQL_Count); info.append(" - ").append(m_SQL_Count);
//postgresql need trx to use cursor based resultset
String trxName = m_virtual ? Trx.createTrxName("Loader") : null;
trx = trxName != null ? Trx.get(trxName, true) : null;
// open Statement (closed by Loader.close) // open Statement (closed by Loader.close)
try try
{ {
m_pstmt = DB.prepareStatement(m_SQL, null); m_pstmt = DB.prepareStatement(m_SQL, trxName);
if (maxRows > 0 && rows > maxRows) if (maxRows > 0 && rows > maxRows)
{ {
m_pstmt.setMaxRows(maxRows); m_pstmt.setMaxRows(maxRows);
info.append(" - MaxRows=").append(maxRows); info.append(" - MaxRows=").append(maxRows);
rows = maxRows; rows = maxRows;
} }
// m_pstmt.setFetchSize(20); //ensure not all row is fectch into memory for virtual table
if (m_virtual)
m_pstmt.setFetchSize(100);
setParameter (m_pstmt, false); setParameter (m_pstmt, false);
m_rs = m_pstmt.executeQuery(); m_rs = m_pstmt.executeQuery();
} }
@ -3272,6 +3279,8 @@ private Object[] getDataAtRow(int row)
DB.close(m_rs, m_pstmt); DB.close(m_rs, m_pstmt);
m_rs = null; m_rs = null;
m_pstmt = null; m_pstmt = null;
if (trx != null)
trx.close();
} // close } // close
/** /**
@ -3335,7 +3344,10 @@ private Object[] getDataAtRow(int row)
{ {
log.log(Level.SEVERE, "run", e); log.log(Level.SEVERE, "run", e);
} }
close(); finally
{
close();
}
fireDataStatusIEvent("", ""); fireDataStatusIEvent("", "");
} // run } // run

View File

@ -106,6 +106,19 @@ public interface I_AD_Scheduler
*/ */
public int getCreatedBy(); public int getCreatedBy();
/** Column name CronPattern */
public static final String COLUMNNAME_CronPattern = "CronPattern";
/** Set Cron Scheduling Pattern.
* Cron pattern to define when the process should be invoked.
*/
public void setCronPattern (String CronPattern);
/** Get Cron Scheduling Pattern.
* Cron pattern to define when the process should be invoked.
*/
public String getCronPattern();
/** Column name DateLastRun */ /** Column name DateLastRun */
public static final String COLUMNNAME_DateLastRun = "DateLastRun"; public static final String COLUMNNAME_DateLastRun = "DateLastRun";
@ -184,6 +197,19 @@ public interface I_AD_Scheduler
*/ */
public boolean isActive(); public boolean isActive();
/** Column name IsIgnoreProcessingTime */
public static final String COLUMNNAME_IsIgnoreProcessingTime = "IsIgnoreProcessingTime";
/** Set Ignore Processing Time.
* Do not include processing time for the DateNextRun calculation
*/
public void setIsIgnoreProcessingTime (boolean IsIgnoreProcessingTime);
/** Get Ignore Processing Time.
* Do not include processing time for the DateNextRun calculation
*/
public boolean isIgnoreProcessingTime();
/** Column name KeepLogDays */ /** Column name KeepLogDays */
public static final String COLUMNNAME_KeepLogDays = "KeepLogDays"; public static final String COLUMNNAME_KeepLogDays = "KeepLogDays";

View File

@ -526,6 +526,21 @@ public interface I_C_AcctSchema_Default
public I_C_ValidCombination getP_Asset_A() throws RuntimeException; public I_C_ValidCombination getP_Asset_A() throws RuntimeException;
/** Column name P_AverageCostVariance_Acct */
public static final String COLUMNNAME_P_AverageCostVariance_Acct = "P_AverageCostVariance_Acct";
/** Set Average Cost Variance.
* Average Cost Variance
*/
public void setP_AverageCostVariance_Acct (int P_AverageCostVariance_Acct);
/** Get Average Cost Variance.
* Average Cost Variance
*/
public int getP_AverageCostVariance_Acct();
public I_C_ValidCombination getP_AverageCostVariance_A() throws RuntimeException;
/** Column name PayDiscount_Exp_Acct */ /** Column name PayDiscount_Exp_Acct */
public static final String COLUMNNAME_PayDiscount_Exp_Acct = "PayDiscount_Exp_Acct"; public static final String COLUMNNAME_PayDiscount_Exp_Acct = "PayDiscount_Exp_Acct";
@ -1095,12 +1110,12 @@ public interface I_C_AcctSchema_Default
public static final String COLUMNNAME_V_Liability_Services_Acct = "V_Liability_Services_Acct"; public static final String COLUMNNAME_V_Liability_Services_Acct = "V_Liability_Services_Acct";
/** Set Vendor Service Liability. /** Set Vendor Service Liability.
* Account for Vender Service Liability * Account for Vendor Service Liability
*/ */
public void setV_Liability_Services_Acct (int V_Liability_Services_Acct); public void setV_Liability_Services_Acct (int V_Liability_Services_Acct);
/** Get Vendor Service Liability. /** Get Vendor Service Liability.
* Account for Vender Service Liability * Account for Vendor Service Liability
*/ */
public int getV_Liability_Services_Acct(); public int getV_Liability_Services_Acct();

View File

@ -262,6 +262,19 @@ public interface I_C_AllocationHdr
*/ */
public boolean isProcessed(); public boolean isProcessed();
/** Column name ProcessedOn */
public static final String COLUMNNAME_ProcessedOn = "ProcessedOn";
/** Set Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public void setProcessedOn (BigDecimal ProcessedOn);
/** Get Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public BigDecimal getProcessedOn();
/** Column name Processing */ /** Column name Processing */
public static final String COLUMNNAME_Processing = "Processing"; public static final String COLUMNNAME_Processing = "Processing";

View File

@ -297,6 +297,19 @@ public interface I_C_BankStatement
*/ */
public boolean isProcessed(); public boolean isProcessed();
/** Column name ProcessedOn */
public static final String COLUMNNAME_ProcessedOn = "ProcessedOn";
/** Set Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public void setProcessedOn (BigDecimal ProcessedOn);
/** Get Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public BigDecimal getProcessedOn();
/** Column name Processing */ /** Column name Processing */
public static final String COLUMNNAME_Processing = "Processing"; public static final String COLUMNNAME_Processing = "Processing";

View File

@ -307,6 +307,19 @@ public interface I_C_Cash
*/ */
public boolean isProcessed(); public boolean isProcessed();
/** Column name ProcessedOn */
public static final String COLUMNNAME_ProcessedOn = "ProcessedOn";
/** Set Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public void setProcessedOn (BigDecimal ProcessedOn);
/** Get Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public BigDecimal getProcessedOn();
/** Column name Processing */ /** Column name Processing */
public static final String COLUMNNAME_Processing = "Processing"; public static final String COLUMNNAME_Processing = "Processing";

View File

@ -486,10 +486,10 @@ public interface I_C_Invoice
/** Column name DunningGrace */ /** Column name DunningGrace */
public static final String COLUMNNAME_DunningGrace = "DunningGrace"; public static final String COLUMNNAME_DunningGrace = "DunningGrace";
/** Set Dunning Grace */ /** Set Dunning Grace Date */
public void setDunningGrace (Timestamp DunningGrace); public void setDunningGrace (Timestamp DunningGrace);
/** Get Dunning Grace */ /** Get Dunning Grace Date */
public Timestamp getDunningGrace(); public Timestamp getDunningGrace();
/** Column name GenerateTo */ /** Column name GenerateTo */
@ -756,6 +756,19 @@ public interface I_C_Invoice
*/ */
public boolean isProcessed(); public boolean isProcessed();
/** Column name ProcessedOn */
public static final String COLUMNNAME_ProcessedOn = "ProcessedOn";
/** Set Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public void setProcessedOn (BigDecimal ProcessedOn);
/** Get Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public BigDecimal getProcessedOn();
/** Column name Processing */ /** Column name Processing */
public static final String COLUMNNAME_Processing = "Processing"; public static final String COLUMNNAME_Processing = "Processing";

View File

@ -895,10 +895,14 @@ public interface I_C_Order
/** Column name OrderType */ /** Column name OrderType */
public static final String COLUMNNAME_OrderType = "OrderType"; public static final String COLUMNNAME_OrderType = "OrderType";
/** Set OrderType */ /** Set Order Type.
* Type of Order: MRP records grouped by source (Sales Order, Purchase Order, Distribution Order, Requisition)
*/
public void setOrderType (String OrderType); public void setOrderType (String OrderType);
/** Get OrderType */ /** Get Order Type.
* Type of Order: MRP records grouped by source (Sales Order, Purchase Order, Distribution Order, Requisition)
*/
public String getOrderType(); public String getOrderType();
/** Column name Pay_BPartner_ID */ /** Column name Pay_BPartner_ID */
@ -992,6 +996,19 @@ public interface I_C_Order
*/ */
public boolean isProcessed(); public boolean isProcessed();
/** Column name ProcessedOn */
public static final String COLUMNNAME_ProcessedOn = "ProcessedOn";
/** Set Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public void setProcessedOn (BigDecimal ProcessedOn);
/** Get Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public BigDecimal getProcessedOn();
/** Column name Processing */ /** Column name Processing */
public static final String COLUMNNAME_Processing = "Processing"; public static final String COLUMNNAME_Processing = "Processing";

View File

@ -860,6 +860,19 @@ public interface I_C_Payment
*/ */
public boolean isProcessed(); public boolean isProcessed();
/** Column name ProcessedOn */
public static final String COLUMNNAME_ProcessedOn = "ProcessedOn";
/** Set Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public void setProcessedOn (BigDecimal ProcessedOn);
/** Get Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public BigDecimal getProcessedOn();
/** Column name Processing */ /** Column name Processing */
public static final String COLUMNNAME_Processing = "Processing"; public static final String COLUMNNAME_Processing = "Processing";

View File

@ -257,6 +257,19 @@ public interface I_C_ProjectIssue
*/ */
public boolean isProcessed(); public boolean isProcessed();
/** Column name ProcessedOn */
public static final String COLUMNNAME_ProcessedOn = "ProcessedOn";
/** Set Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public void setProcessedOn (BigDecimal ProcessedOn);
/** Get Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public BigDecimal getProcessedOn();
/** Column name Processing */ /** Column name Processing */
public static final String COLUMNNAME_Processing = "Processing"; public static final String COLUMNNAME_Processing = "Processing";

View File

@ -393,6 +393,19 @@ public interface I_GL_Journal
*/ */
public boolean isProcessed(); public boolean isProcessed();
/** Column name ProcessedOn */
public static final String COLUMNNAME_ProcessedOn = "ProcessedOn";
/** Set Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public void setProcessedOn (BigDecimal ProcessedOn);
/** Get Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public BigDecimal getProcessedOn();
/** Column name Processing */ /** Column name Processing */
public static final String COLUMNNAME_Processing = "Processing"; public static final String COLUMNNAME_Processing = "Processing";

View File

@ -62,19 +62,6 @@ public interface I_I_ReportLine
*/ */
public int getAD_Org_ID(); public int getAD_Org_ID();
/** Column name AmountType */
public static final String COLUMNNAME_AmountType = "AmountType";
/** Set Amount Type.
* Type of amount to report
*/
public void setAmountType (String AmountType);
/** Get Amount Type.
* Type of amount to report
*/
public String getAmountType();
/** Column name CalculationType */ /** Column name CalculationType */
public static final String COLUMNNAME_CalculationType = "CalculationType"; public static final String COLUMNNAME_CalculationType = "CalculationType";
@ -241,6 +228,32 @@ public interface I_I_ReportLine
*/ */
public String getName(); public String getName();
/** Column name PAAmountType */
public static final String COLUMNNAME_PAAmountType = "PAAmountType";
/** Set Amount Type.
* PA Amount Type for reporting
*/
public void setPAAmountType (String PAAmountType);
/** Get Amount Type.
* PA Amount Type for reporting
*/
public String getPAAmountType();
/** Column name PAPeriodType */
public static final String COLUMNNAME_PAPeriodType = "PAPeriodType";
/** Set Period Type.
* PA Period Type
*/
public void setPAPeriodType (String PAPeriodType);
/** Get Period Type.
* PA Period Type
*/
public String getPAPeriodType();
/** Column name PA_ReportLine_ID */ /** Column name PA_ReportLine_ID */
public static final String COLUMNNAME_PA_ReportLine_ID = "PA_ReportLine_ID"; public static final String COLUMNNAME_PA_ReportLine_ID = "PA_ReportLine_ID";

View File

@ -752,6 +752,19 @@ public interface I_M_InOut
*/ */
public boolean isProcessed(); public boolean isProcessed();
/** Column name ProcessedOn */
public static final String COLUMNNAME_ProcessedOn = "ProcessedOn";
/** Set Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public void setProcessedOn (BigDecimal ProcessedOn);
/** Get Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public BigDecimal getProcessedOn();
/** Column name Processing */ /** Column name Processing */
public static final String COLUMNNAME_Processing = "Processing"; public static final String COLUMNNAME_Processing = "Processing";

View File

@ -337,6 +337,19 @@ public interface I_M_Inventory
*/ */
public boolean isProcessed(); public boolean isProcessed();
/** Column name ProcessedOn */
public static final String COLUMNNAME_ProcessedOn = "ProcessedOn";
/** Set Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public void setProcessedOn (BigDecimal ProcessedOn);
/** Get Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public BigDecimal getProcessedOn();
/** Column name Processing */ /** Column name Processing */
public static final String COLUMNNAME_Processing = "Processing"; public static final String COLUMNNAME_Processing = "Processing";

View File

@ -242,6 +242,19 @@ public interface I_M_MatchInv
*/ */
public boolean isProcessed(); public boolean isProcessed();
/** Column name ProcessedOn */
public static final String COLUMNNAME_ProcessedOn = "ProcessedOn";
/** Set Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public void setProcessedOn (BigDecimal ProcessedOn);
/** Get Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public BigDecimal getProcessedOn();
/** Column name Processing */ /** Column name Processing */
public static final String COLUMNNAME_Processing = "Processing"; public static final String COLUMNNAME_Processing = "Processing";

View File

@ -283,6 +283,19 @@ public interface I_M_MatchPO
*/ */
public boolean isProcessed(); public boolean isProcessed();
/** Column name ProcessedOn */
public static final String COLUMNNAME_ProcessedOn = "ProcessedOn";
/** Set Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public void setProcessedOn (BigDecimal ProcessedOn);
/** Get Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public BigDecimal getProcessedOn();
/** Column name Processing */ /** Column name Processing */
public static final String COLUMNNAME_Processing = "Processing"; public static final String COLUMNNAME_Processing = "Processing";

View File

@ -510,6 +510,19 @@ public interface I_M_Movement
*/ */
public boolean isProcessed(); public boolean isProcessed();
/** Column name ProcessedOn */
public static final String COLUMNNAME_ProcessedOn = "ProcessedOn";
/** Set Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public void setProcessedOn (BigDecimal ProcessedOn);
/** Get Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public BigDecimal getProcessedOn();
/** Column name Processing */ /** Column name Processing */
public static final String COLUMNNAME_Processing = "Processing"; public static final String COLUMNNAME_Processing = "Processing";

View File

@ -136,6 +136,21 @@ public interface I_M_Product_Acct
public I_C_ValidCombination getP_Asset_A() throws RuntimeException; public I_C_ValidCombination getP_Asset_A() throws RuntimeException;
/** Column name P_AverageCostVariance_Acct */
public static final String COLUMNNAME_P_AverageCostVariance_Acct = "P_AverageCostVariance_Acct";
/** Set Average Cost Variance.
* Average Cost Variance
*/
public void setP_AverageCostVariance_Acct (int P_AverageCostVariance_Acct);
/** Get Average Cost Variance.
* Average Cost Variance
*/
public int getP_AverageCostVariance_Acct();
public I_C_ValidCombination getP_AverageCostVariance_A() throws RuntimeException;
/** Column name P_Burden_Acct */ /** Column name P_Burden_Acct */
public static final String COLUMNNAME_P_Burden_Acct = "P_Burden_Acct"; public static final String COLUMNNAME_P_Burden_Acct = "P_Burden_Acct";

View File

@ -162,6 +162,21 @@ public interface I_M_Product_Category_Acct
public I_C_ValidCombination getP_Asset_A() throws RuntimeException; public I_C_ValidCombination getP_Asset_A() throws RuntimeException;
/** Column name P_AverageCostVariance_Acct */
public static final String COLUMNNAME_P_AverageCostVariance_Acct = "P_AverageCostVariance_Acct";
/** Set Average Cost Variance.
* Average Cost Variance
*/
public void setP_AverageCostVariance_Acct (int P_AverageCostVariance_Acct);
/** Get Average Cost Variance.
* Average Cost Variance
*/
public int getP_AverageCostVariance_Acct();
public I_C_ValidCombination getP_AverageCostVariance_A() throws RuntimeException;
/** Column name P_Burden_Acct */ /** Column name P_Burden_Acct */
public static final String COLUMNNAME_P_Burden_Acct = "P_Burden_Acct"; public static final String COLUMNNAME_P_Burden_Acct = "P_Burden_Acct";

View File

@ -236,6 +236,19 @@ public interface I_M_Production
*/ */
public boolean isProcessed(); public boolean isProcessed();
/** Column name ProcessedOn */
public static final String COLUMNNAME_ProcessedOn = "ProcessedOn";
/** Set Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public void setProcessedOn (BigDecimal ProcessedOn);
/** Get Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public BigDecimal getProcessedOn();
/** Column name Processing */ /** Column name Processing */
public static final String COLUMNNAME_Processing = "Processing"; public static final String COLUMNNAME_Processing = "Processing";

View File

@ -307,6 +307,19 @@ public interface I_M_Requisition
*/ */
public boolean isProcessed(); public boolean isProcessed();
/** Column name ProcessedOn */
public static final String COLUMNNAME_ProcessedOn = "ProcessedOn";
/** Set Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public void setProcessedOn (BigDecimal ProcessedOn);
/** Get Processed On.
* The date+time (expressed in decimal format) when the document has been processed
*/
public BigDecimal getProcessedOn();
/** Column name Processing */ /** Column name Processing */
public static final String COLUMNNAME_Processing = "Processing"; public static final String COLUMNNAME_Processing = "Processing";

View File

@ -75,19 +75,6 @@ public interface I_PA_ReportColumn
*/ */
public int getAD_OrgTrx_ID(); public int getAD_OrgTrx_ID();
/** Column name AmountType */
public static final String COLUMNNAME_AmountType = "AmountType";
/** Set Amount Type.
* Type of amount to report
*/
public void setAmountType (String AmountType);
/** Get Amount Type.
* Type of amount to report
*/
public String getAmountType();
/** Column name C_Activity_ID */ /** Column name C_Activity_ID */
public static final String COLUMNNAME_C_Activity_ID = "C_Activity_ID"; public static final String COLUMNNAME_C_Activity_ID = "C_Activity_ID";
@ -584,6 +571,32 @@ public interface I_PA_ReportColumn
*/ */
public int getOrg_ID(); public int getOrg_ID();
/** Column name PAAmountType */
public static final String COLUMNNAME_PAAmountType = "PAAmountType";
/** Set Amount Type.
* PA Amount Type for reporting
*/
public void setPAAmountType (String PAAmountType);
/** Get Amount Type.
* PA Amount Type for reporting
*/
public String getPAAmountType();
/** Column name PAPeriodType */
public static final String COLUMNNAME_PAPeriodType = "PAPeriodType";
/** Set Period Type.
* PA Period Type
*/
public void setPAPeriodType (String PAPeriodType);
/** Get Period Type.
* PA Period Type
*/
public String getPAPeriodType();
/** Column name PA_ReportColumn_ID */ /** Column name PA_ReportColumn_ID */
public static final String COLUMNNAME_PA_ReportColumn_ID = "PA_ReportColumn_ID"; public static final String COLUMNNAME_PA_ReportColumn_ID = "PA_ReportColumn_ID";

View File

@ -62,19 +62,6 @@ public interface I_PA_ReportLine
*/ */
public int getAD_Org_ID(); public int getAD_Org_ID();
/** Column name AmountType */
public static final String COLUMNNAME_AmountType = "AmountType";
/** Set Amount Type.
* Type of amount to report
*/
public void setAmountType (String AmountType);
/** Get Amount Type.
* Type of amount to report
*/
public String getAmountType();
/** Column name CalculationType */ /** Column name CalculationType */
public static final String COLUMNNAME_CalculationType = "CalculationType"; public static final String COLUMNNAME_CalculationType = "CalculationType";
@ -206,6 +193,32 @@ public interface I_PA_ReportLine
public I_PA_ReportLine getOper_2() throws RuntimeException; public I_PA_ReportLine getOper_2() throws RuntimeException;
/** Column name PAAmountType */
public static final String COLUMNNAME_PAAmountType = "PAAmountType";
/** Set Amount Type.
* PA Amount Type for reporting
*/
public void setPAAmountType (String PAAmountType);
/** Get Amount Type.
* PA Amount Type for reporting
*/
public String getPAAmountType();
/** Column name PAPeriodType */
public static final String COLUMNNAME_PAPeriodType = "PAPeriodType";
/** Set Period Type.
* PA Period Type
*/
public void setPAPeriodType (String PAPeriodType);
/** Get Period Type.
* PA Period Type
*/
public String getPAPeriodType();
/** Column name PA_ReportLine_ID */ /** Column name PA_ReportLine_ID */
public static final String COLUMNNAME_PA_ReportLine_ID = "PA_ReportLine_ID"; public static final String COLUMNNAME_PA_ReportLine_ID = "PA_ReportLine_ID";

View File

@ -41,9 +41,7 @@ public class MAccount extends X_C_ValidCombination
/** /**
* *
*/ */
private static final long serialVersionUID = -8887316767838767993L; private static final long serialVersionUID = -1936396369349550834L;
/** /**
* Get existing Account or create it * Get existing Account or create it
@ -242,9 +240,9 @@ public class MAccount extends X_C_ValidCombination
*/ */
public static MAccount get (Properties ctx, int C_AcctSchema_ID, String alias) public static MAccount get (Properties ctx, int C_AcctSchema_ID, String alias)
{ {
String whereClause = "C_AcctSchema_ID=? AND Alias=?"; final String whereClause = "C_AcctSchema_ID=? AND Alias=?";
MAccount retValue = new Query(ctx,MAccount.Table_Name,whereClause.toString(),null) MAccount retValue = new Query(ctx,I_C_ValidCombination.Table_Name,whereClause,null)
.setParameters(new Object[]{C_AcctSchema_ID,alias}) .setParameters(C_AcctSchema_ID,alias)
.firstOnly(); .firstOnly();
return retValue; return retValue;
} // get } // get
@ -358,7 +356,7 @@ public class MAccount extends X_C_ValidCombination
* @param where where clause * @param where where clause
* @param trxName transaction * @param trxName transaction
*/ */
public static void updateValueDescription (Properties ctx, String where, String trxName) public static void updateValueDescription (Properties ctx, final String where, String trxName)
{ {
List<MAccount> accounts= new Query(ctx,MAccount.Table_Name,where,trxName) List<MAccount> accounts= new Query(ctx,MAccount.Table_Name,where,trxName)
.setOrderBy(MAccount.COLUMNNAME_C_ValidCombination_ID).list(); .setOrderBy(MAccount.COLUMNNAME_C_ValidCombination_ID).list();

View File

@ -138,9 +138,9 @@ public final class MAccountLookup extends Lookup implements Serializable
if (ID == C_ValidCombination_ID) // already loaded if (ID == C_ValidCombination_ID) // already loaded
return true; return true;
String whereClause = "C_ValidCombination_ID=?"; final String whereClause = "C_ValidCombination_ID=?";
MAccount account = new Query(Env.getCtx(),MAccount.Table_Name,whereClause,null) MAccount account = new Query(Env.getCtx(),I_C_ValidCombination.Table_Name,whereClause,null)
.setParameters(new Object[]{ID}) .setParameters(ID)
.firstOnly(); .firstOnly();
if(account == null) if(account == null)
@ -178,12 +178,12 @@ public final class MAccountLookup extends Lookup implements Serializable
list.add(new KeyNamePair (-1, "")); list.add(new KeyNamePair (-1, ""));
// //
ArrayList<Object> params = new ArrayList<Object>(); ArrayList<Object> params = new ArrayList<Object>();
String whereClause = "AD_Client_ID=?"; final String whereClause = "AD_Client_ID=?";
params.add(Env.getAD_Client_ID(m_ctx)); params.add(Env.getAD_Client_ID(m_ctx));
List<MAccount> accounts = new Query(Env.getCtx(),MAccount.Table_Name,whereClause,null) List<MAccount> accounts = new Query(Env.getCtx(),I_C_ValidCombination.Table_Name,whereClause,null)
.setParameters(params) .setParameters(params)
.setOrderBy(MAccount.COLUMNNAME_Combination) .setOrderBy(I_C_ValidCombination.COLUMNNAME_Combination)
.setOnlyActiveRecords(onlyActive) .setOnlyActiveRecords(onlyActive)
.list(); .list();

View File

@ -49,7 +49,7 @@ public class MAcctProcessor extends X_C_AcctProcessor
*/ */
public static MAcctProcessor[] getActive (Properties ctx) public static MAcctProcessor[] getActive (Properties ctx)
{ {
List<MAcctProcessor> list = new Query(ctx, MAcctProcessor.Table_Name, null, null) List<MAcctProcessor> list = new Query(ctx, I_C_AcctProcessor.Table_Name, null, null)
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.list(); .list();
return list.toArray(new MAcctProcessor[list.size()]); return list.toArray(new MAcctProcessor[list.size()]);
@ -129,8 +129,8 @@ public class MAcctProcessor extends X_C_AcctProcessor
public AdempiereProcessorLog[] getLogs () public AdempiereProcessorLog[] getLogs ()
{ {
String whereClause = "C_AcctProcessor_ID=? "; String whereClause = "C_AcctProcessor_ID=? ";
List<MAcctProcessor> list = new Query(getCtx(), MAcctProcessorLog.Table_Name,whereClause,get_TrxName()) List<MAcctProcessor> list = new Query(getCtx(), I_C_AcctProcessorLog.Table_Name,whereClause,get_TrxName())
.setParameters(new Object[]{getC_AcctProcessor_ID()}) .setParameters(getC_AcctProcessor_ID())
.setOrderBy("Created DESC") .setOrderBy("Created DESC")
.list(); .list();
return list.toArray(new MAcctProcessorLog[list.size()]); return list.toArray(new MAcctProcessorLog[list.size()]);

View File

@ -115,7 +115,7 @@ public class MAcctSchema extends X_C_AcctSchema
params.add(AD_Client_ID); params.add(AD_Client_ID);
} }
List <MAcctSchema> ass = new Query(ctx, MAcctSchema.Table_Name,whereClause,trxName) List <MAcctSchema> ass = new Query(ctx, I_C_AcctSchema.Table_Name,whereClause,trxName)
.setParameters(params) .setParameters(params)
.setOrderBy(MAcctSchema.COLUMNNAME_C_AcctSchema_ID) .setOrderBy(MAcctSchema.COLUMNNAME_C_AcctSchema_ID)
.list(); .list();

View File

@ -33,10 +33,12 @@ import org.compiere.util.KeyNamePair;
*/ */
public class MAcctSchemaDefault extends X_C_AcctSchema_Default public class MAcctSchemaDefault extends X_C_AcctSchema_Default
{ {
/**
*
*/ /**
private static final long serialVersionUID = 199959007595802866L; *
*/
private static final long serialVersionUID = 199959007595802866L;
/** /**
* Get Accounting Schema Default Info * Get Accounting Schema Default Info
@ -46,9 +48,9 @@ public class MAcctSchemaDefault extends X_C_AcctSchema_Default
*/ */
public static MAcctSchemaDefault get (Properties ctx, int C_AcctSchema_ID) public static MAcctSchemaDefault get (Properties ctx, int C_AcctSchema_ID)
{ {
String whereClause = "C_AcctSchema_ID=?"; final String whereClause = "C_AcctSchema_ID=?";
return new Query(ctx,MAcctSchemaDefault.Table_Name,whereClause,null) return new Query(ctx,I_C_AcctSchema_Default.Table_Name,whereClause,null)
.setParameters(new Object[]{C_AcctSchema_ID}) .setParameters(C_AcctSchema_ID)
.firstOnly(); .firstOnly();
} // get } // get

View File

@ -40,10 +40,12 @@ import org.compiere.util.Msg;
*/ */
public final class MAcctSchemaElement extends X_C_AcctSchema_Element public final class MAcctSchemaElement extends X_C_AcctSchema_Element
{ {
/**
*
*/ /**
private static final long serialVersionUID = 4215184252533527719L; *
*/
private static final long serialVersionUID = 4215184252533527719L;
/** /**
@ -61,9 +63,10 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element
s_log.fine("C_AcctSchema_ID=" + as.getC_AcctSchema_ID()); s_log.fine("C_AcctSchema_ID=" + as.getC_AcctSchema_ID());
ArrayList<MAcctSchemaElement> list = new ArrayList<MAcctSchemaElement>(); ArrayList<MAcctSchemaElement> list = new ArrayList<MAcctSchemaElement>();
String whereClause = "C_AcctSchema_ID=? AND IsActive=?"; final String whereClause = "C_AcctSchema_ID=? AND IsActive=?";
List<MAcctSchemaElement> elements= new Query(as.getCtx(), MAcctSchemaElement.Table_Name,whereClause,as.get_TrxName()) List<MAcctSchemaElement> elements= new Query(as.getCtx(), I_C_AcctSchema_Element.Table_Name,whereClause,as.get_TrxName())
.setParameters(new Object[]{as.getC_AcctSchema_ID(),"Y"}).setOrderBy("SeqNo") .setParameters(as.getC_AcctSchema_ID(),"Y")
.setOrderBy("SeqNo")
.list(); .list();
for(MAcctSchemaElement ase : elements) for(MAcctSchemaElement ase : elements)

View File

@ -35,10 +35,12 @@ import org.compiere.util.KeyNamePair;
*/ */
public class MAcctSchemaGL extends X_C_AcctSchema_GL public class MAcctSchemaGL extends X_C_AcctSchema_GL
{ {
/**
*
*/ /**
private static final long serialVersionUID = 5303102649110271896L; *
*/
private static final long serialVersionUID = 5303102649110271896L;
/** /**
@ -49,9 +51,9 @@ public class MAcctSchemaGL extends X_C_AcctSchema_GL
*/ */
public static MAcctSchemaGL get (Properties ctx, int C_AcctSchema_ID) public static MAcctSchemaGL get (Properties ctx, int C_AcctSchema_ID)
{ {
String whereClause = "C_AcctSchema_ID=?"; final String whereClause = "C_AcctSchema_ID=?";
return new Query(ctx,MAcctSchemaGL.Table_Name,whereClause,null) return new Query(ctx,I_C_AcctSchema_GL.Table_Name,whereClause,null)
.setParameters(new Object[]{C_AcctSchema_ID}) .setParameters(C_AcctSchema_ID)
.firstOnly(); .firstOnly();
} // get } // get

View File

@ -33,9 +33,7 @@ import org.compiere.util.Env;
*/ */
public class MAchievement extends X_PA_Achievement public class MAchievement extends X_PA_Achievement
{ {
/**
*
*/
private static final long serialVersionUID = -1438593600498523664L; private static final long serialVersionUID = -1438593600498523664L;
/** /**
@ -56,9 +54,11 @@ public class MAchievement extends X_PA_Achievement
*/ */
public static MAchievement[] getOfMeasure (Properties ctx, int PA_Measure_ID) public static MAchievement[] getOfMeasure (Properties ctx, int PA_Measure_ID)
{ {
String whereClause ="PA_Measure_ID=? AND IsAchieved='Y'"; final String whereClause ="PA_Measure_ID=? AND IsAchieved='Y'";
List <MAchievement> list = new Query(ctx,MAchievement.Table_Name, whereClause, null) List <MAchievement> list = new Query(ctx,I_PA_Achievement.Table_Name, whereClause, null)
.setParameters(new Object[]{PA_Measure_ID}).setOrderBy("SeqNo, DateDoc").list(); .setParameters(PA_Measure_ID)
.setOrderBy("SeqNo, DateDoc")
.list();
MAchievement[] retValue = new MAchievement[list.size ()]; MAchievement[] retValue = new MAchievement[list.size ()];
retValue = list.toArray (retValue); retValue = list.toArray (retValue);

View File

@ -88,9 +88,9 @@ public class MAlert extends X_AD_Alert
if (m_rules != null && !reload) if (m_rules != null && !reload)
return m_rules; return m_rules;
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String whereClause = "AD_Alert_ID=?"; final String whereClause = "AD_Alert_ID=?";
List <MAlertRule> list = new Query(getCtx(), MAlertRule.Table_Name, whereClause, null) List <MAlertRule> list = new Query(getCtx(), I_AD_AlertRule.Table_Name, whereClause, null)
.setParameters(new Object[]{getAD_Alert_ID()}) .setParameters(getAD_Alert_ID())
.setOrderBy("Name, AD_AlertRule_ID") .setOrderBy("Name, AD_AlertRule_ID")
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.list() .list()
@ -115,9 +115,9 @@ public class MAlert extends X_AD_Alert
if (m_recipients != null && !reload) if (m_recipients != null && !reload)
return m_recipients; return m_recipients;
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String whereClause = "AD_Alert_ID=?"; final String whereClause = "AD_Alert_ID=?";
List <MAlertRecipient> list = new Query(getCtx(), MAlertRecipient.Table_Name, whereClause, null) List <MAlertRecipient> list = new Query(getCtx(), I_AD_AlertRecipient.Table_Name, whereClause, null)
.setParameters(new Object[]{getAD_Alert_ID()}) .setParameters(getAD_Alert_ID())
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.list() .list()
; ;

View File

@ -16,12 +16,10 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.CCache; import org.compiere.util.CCache;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
@ -50,26 +48,9 @@ public class MAlertProcessor extends X_AD_AlertProcessor
*/ */
public static MAlertProcessor[] getActive (Properties ctx) public static MAlertProcessor[] getActive (Properties ctx)
{ {
ArrayList<MAlertProcessor> list = new ArrayList<MAlertProcessor>(); List <MAlertProcessor> list = new Query(ctx,I_AD_AlertProcessor.Table_Name, null, null)
String sql = "SELECT * FROM AD_AlertProcessor WHERE IsActive='Y'"; .setOnlyActiveRecords(true)
PreparedStatement pstmt = null; .list();
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MAlertProcessor (ctx, rs, null));
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
MAlertProcessor[] retValue = new MAlertProcessor[list.size ()]; MAlertProcessor[] retValue = new MAlertProcessor[list.size ()];
list.toArray (retValue); list.toArray (retValue);
return retValue; return retValue;
@ -131,30 +112,11 @@ public class MAlertProcessor extends X_AD_AlertProcessor
*/ */
public AdempiereProcessorLog[] getLogs () public AdempiereProcessorLog[] getLogs ()
{ {
ArrayList<MAlertProcessorLog> list = new ArrayList<MAlertProcessorLog>(); final String whereClause ="AD_AlertProcessor_ID=?";
String sql = "SELECT * " List <MAlertProcessorLog> list = new Query(getCtx(), I_AD_AlertProcessorLog.Table_Name, whereClause, null)
+ "FROM AD_AlertProcessorLog " .setParameters(getAD_AlertProcessor_ID())
+ "WHERE AD_AlertProcessor_ID=? " .setOrderBy("Created DESC")
+ "ORDER BY Created DESC"; .list();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, getAD_AlertProcessor_ID());
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MAlertProcessorLog (getCtx(), rs, null));
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
MAlertProcessorLog[] retValue = new MAlertProcessorLog[list.size ()]; MAlertProcessorLog[] retValue = new MAlertProcessorLog[list.size ()];
list.toArray (retValue); list.toArray (retValue);
return retValue; return retValue;
@ -186,28 +148,13 @@ public class MAlertProcessor extends X_AD_AlertProcessor
MAlert[] alerts = s_cacheAlerts.get(get_ID()); MAlert[] alerts = s_cacheAlerts.get(get_ID());
if (alerts != null && !reload) if (alerts != null && !reload)
return alerts; return alerts;
String sql = "SELECT * FROM AD_Alert "
+ "WHERE AD_AlertProcessor_ID=? AND IsActive='Y' "; final String whereClause ="AD_AlertProcessor_ID=?";
ArrayList<MAlert> list = new ArrayList<MAlert>(); List <MAlert> list = new Query(getCtx(), I_AD_Alert.Table_Name, whereClause, null)
PreparedStatement pstmt = null; .setParameters(getAD_AlertProcessor_ID())
ResultSet rs = null; .setOnlyActiveRecords(true)
try .list();
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, getAD_AlertProcessor_ID());
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MAlert (getCtx(), rs, null));
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
// //
alerts = new MAlert[list.size ()]; alerts = new MAlert[list.size ()];
list.toArray (alerts); list.toArray (alerts);

View File

@ -144,13 +144,13 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction
*/ */
public static MAllocationHdr[] getOfCash (Properties ctx, int C_Cash_ID, String trxName) public static MAllocationHdr[] getOfCash (Properties ctx, int C_Cash_ID, String trxName)
{ {
String whereClause = "IsActive='Y'" final String whereClause = "IsActive='Y'"
+ " AND EXISTS (SELECT 1 FROM C_CashLine cl, C_AllocationLine al " + " AND EXISTS (SELECT 1 FROM C_CashLine cl, C_AllocationLine al "
+ "where cl.C_Cash_ID=? and al.C_CashLine_ID=cl.C_CashLine_ID " + "where cl.C_Cash_ID=? and al.C_CashLine_ID=cl.C_CashLine_ID "
+ "and C_AllocationHdr.C_AllocationHdr_ID=al.C_AllocationHdr_ID)"; + "and C_AllocationHdr.C_AllocationHdr_ID=al.C_AllocationHdr_ID)";
Query query = MTable.get(ctx, MAllocationHdr.Table_ID) Query query = MTable.get(ctx, I_C_AllocationHdr.Table_ID)
.createQuery(whereClause, trxName); .createQuery(whereClause, trxName);
query.setParameters(new Object[]{C_Cash_ID}); query.setParameters(C_Cash_ID);
List<MAllocationHdr> list = query.list(); List<MAllocationHdr> list = query.list();
MAllocationHdr[] retValue = new MAllocationHdr[list.size()]; MAllocationHdr[] retValue = new MAllocationHdr[list.size()];
list.toArray(retValue); list.toArray(retValue);
@ -416,7 +416,7 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction
+ I_C_Invoice.COLUMNNAME_DocStatus + " NOT IN (?,?)"; + I_C_Invoice.COLUMNNAME_DocStatus + " NOT IN (?,?)";
boolean InvoiceIsPaid = new Query(getCtx(), I_C_Invoice.Table_Name, whereClause, get_TrxName()) boolean InvoiceIsPaid = new Query(getCtx(), I_C_Invoice.Table_Name, whereClause, get_TrxName())
.setClient_ID() .setClient_ID()
.setParameters(new Object[]{line.getC_Invoice_ID(), "Y", MInvoice.DOCSTATUS_Voided, MInvoice.DOCSTATUS_Reversed}) .setParameters(line.getC_Invoice_ID(), "Y", X_C_Invoice.DOCSTATUS_Voided, X_C_Invoice.DOCSTATUS_Reversed)
.match(); .match();
if(InvoiceIsPaid) if(InvoiceIsPaid)
throw new AdempiereException("@ValidationError@ @C_Invoice_ID@ @IsPaid@"); throw new AdempiereException("@ValidationError@ @C_Invoice_ID@ @IsPaid@");

View File

@ -24,7 +24,6 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Properties; import java.util.Properties;
@ -45,7 +44,6 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.MimeType; import org.compiere.util.MimeType;
import org.w3c.dom.Document; import org.w3c.dom.Document;
@ -72,7 +70,7 @@ public class MAttachment extends X_AD_Attachment
/** /**
* Get Attachment * Get Attachment (if there are more than one attachment it gets the first in no specific order)
* @param ctx context * @param ctx context
* @param AD_Table_ID table * @param AD_Table_ID table
* @param Record_ID record * @param Record_ID record
@ -80,35 +78,10 @@ public class MAttachment extends X_AD_Attachment
*/ */
public static MAttachment get (Properties ctx, int AD_Table_ID, int Record_ID) public static MAttachment get (Properties ctx, int AD_Table_ID, int Record_ID)
{ {
MAttachment retValue = null; final String whereClause = I_AD_Attachment.COLUMNNAME_AD_Table_ID+"=? AND "+I_AD_Attachment.COLUMNNAME_Record_ID+"=?";
PreparedStatement pstmt = null; MAttachment retValue = new Query(ctx,I_AD_Attachment.Table_Name,whereClause, null)
String sql = "SELECT * FROM AD_Attachment WHERE AD_Table_ID=? AND Record_ID=?"; .setParameters(AD_Table_ID, Record_ID)
try .first();
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, AD_Table_ID);
pstmt.setInt (2, Record_ID);
ResultSet rs = pstmt.executeQuery ();
if (rs.next ())
retValue = new MAttachment (ctx, rs, null);
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
return retValue; return retValue;
} // get } // get

View File

@ -221,7 +221,7 @@ public class MAttributeSet extends X_M_AttributeSet
{ {
final String whereClause = X_M_AttributeSetExclude.COLUMNNAME_M_AttributeSet_ID+"=?"; final String whereClause = X_M_AttributeSetExclude.COLUMNNAME_M_AttributeSet_ID+"=?";
List<X_M_AttributeSetExclude> list = new Query(getCtx(), X_M_AttributeSetExclude.Table_Name, whereClause, null) List<X_M_AttributeSetExclude> list = new Query(getCtx(), X_M_AttributeSetExclude.Table_Name, whereClause, null)
.setParameters(new Object[]{get_ID()}) .setParameters(get_ID())
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.list(); .list();
m_excludes = new X_M_AttributeSetExclude[list.size ()]; m_excludes = new X_M_AttributeSetExclude[list.size ()];
@ -253,9 +253,9 @@ public class MAttributeSet extends X_M_AttributeSet
return true; return true;
if (m_excludeLots == null) if (m_excludeLots == null)
{ {
String whereClause = X_M_LotCtlExclude.COLUMNNAME_M_LotCtl_ID+"=?"; final String whereClause = X_M_LotCtlExclude.COLUMNNAME_M_LotCtl_ID+"=?";
List<X_M_LotCtlExclude> list = new Query(getCtx(), X_M_LotCtlExclude.Table_Name, whereClause, null) List<X_M_LotCtlExclude> list = new Query(getCtx(), X_M_LotCtlExclude.Table_Name, whereClause, null)
.setParameters(new Object[]{getM_LotCtl_ID()}) .setParameters(getM_LotCtl_ID())
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.list(); .list();
m_excludeLots = new X_M_LotCtlExclude[list.size ()]; m_excludeLots = new X_M_LotCtlExclude[list.size ()];
@ -287,9 +287,9 @@ public class MAttributeSet extends X_M_AttributeSet
return true; return true;
if (m_excludeSerNos == null) if (m_excludeSerNos == null)
{ {
String whereClause = X_M_SerNoCtlExclude.COLUMNNAME_M_SerNoCtl_ID+"=?"; final String whereClause = X_M_SerNoCtlExclude.COLUMNNAME_M_SerNoCtl_ID+"=?";
List<X_M_SerNoCtlExclude> list = new Query(getCtx(), X_M_SerNoCtlExclude.Table_Name, whereClause, null) List<X_M_SerNoCtlExclude> list = new Query(getCtx(), X_M_SerNoCtlExclude.Table_Name, whereClause, null)
.setParameters(new Object[]{getM_SerNoCtl_ID()}) .setParameters(getM_SerNoCtl_ID())
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.list(); .list();
m_excludeSerNos = new X_M_SerNoCtlExclude[list.size ()]; m_excludeSerNos = new X_M_SerNoCtlExclude[list.size ()];

View File

@ -16,15 +16,12 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.CCache; import org.compiere.util.CCache;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Msg; import org.compiere.util.Msg;
/** /**
@ -69,36 +66,13 @@ public class MBOM extends X_M_BOM
public static MBOM[] getOfProduct (Properties ctx, int M_Product_ID, public static MBOM[] getOfProduct (Properties ctx, int M_Product_ID,
String trxName, String whereClause) String trxName, String whereClause)
{ {
ArrayList<MBOM> list = new ArrayList<MBOM>(); //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String sql = "SELECT * FROM M_BOM WHERE M_Product_ID=?"; String where = "M_Product_ID=?";
if (whereClause != null && whereClause.length() > 0) if (whereClause != null && whereClause.length() > 0)
sql += " AND " + whereClause; where += " AND " + whereClause;
PreparedStatement pstmt = null; List <MBOM> list = new Query(ctx, I_M_BOM.Table_Name, where, trxName)
try .setParameters(M_Product_ID)
{ .list();
pstmt = DB.prepareStatement (sql, trxName);
pstmt.setInt (1, M_Product_ID);
ResultSet rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MBOM (ctx, rs, trxName));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
MBOM[] retValue = new MBOM[list.size ()]; MBOM[] retValue = new MBOM[list.size ()];
list.toArray (retValue); list.toArray (retValue);

View File

@ -16,11 +16,9 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
@ -47,34 +45,12 @@ public class MBOMProduct extends X_M_BOMProduct
*/ */
public static MBOMProduct[] getOfBOM (MBOM bom) public static MBOMProduct[] getOfBOM (MBOM bom)
{ {
ArrayList<MBOMProduct> list = new ArrayList<MBOMProduct>(); //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String sql = "SELECT * FROM M_BOMProduct WHERE M_BOM_ID=? ORDER BY SeqNo"; String whereClause = "M_BOM_ID=?";
PreparedStatement pstmt = null; List <MBOMProduct> list = new Query(bom.getCtx(), I_M_BOMProduct.Table_Name, whereClause, bom.get_TrxName())
try .setParameters(bom.getM_BOM_ID())
{ .setOrderBy("SeqNo")
pstmt = DB.prepareStatement (sql, bom.get_TrxName()); .list();
pstmt.setInt (1, bom.getM_BOM_ID());
ResultSet rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MBOMProduct (bom.getCtx(), rs, bom.get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
MBOMProduct[] retValue = new MBOMProduct[list.size ()]; MBOMProduct[] retValue = new MBOMProduct[list.size ()];
list.toArray (retValue); list.toArray (retValue);

View File

@ -16,14 +16,11 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB;
/** /**
* BP Bank Account Model * BP Bank Account Model
@ -33,48 +30,24 @@ import org.compiere.util.DB;
*/ */
public class MBPBankAccount extends X_C_BP_BankAccount public class MBPBankAccount extends X_C_BP_BankAccount
{ {
/** /**
* *
*/ */
private static final long serialVersionUID = 2580706419593695062L; private static final long serialVersionUID = 2580706419593695062L;
/** /**
* Get Accounst Of BPartner * Get Accounts Of BPartner
* @param ctx context * @param ctx context
* @param C_BPartner_ID bpartner * @param C_BPartner_ID bpartner
* @return * @return
*/ */
public static MBPBankAccount[] getOfBPartner (Properties ctx, int C_BPartner_ID) public static MBPBankAccount[] getOfBPartner (Properties ctx, int C_BPartner_ID)
{ {
String sql = "SELECT * FROM C_BP_BankAccount WHERE C_BPartner_ID=? AND IsActive='Y'"; final String whereClause = MBPBankAccount.COLUMNNAME_C_BPartner_ID+"=?";
ArrayList<MBPBankAccount> list = new ArrayList<MBPBankAccount>(); List<MBPBankAccount>list = new Query(ctx,I_C_BP_BankAccount.Table_Name,whereClause,null)
PreparedStatement pstmt = null; .setParameters(C_BPartner_ID)
try .setOnlyActiveRecords(true)
{ .list();
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_BPartner_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
list.add(new MBPBankAccount(ctx, rs, null));
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try {
if (pstmt != null)
pstmt.close();
pstmt = null;
} catch (Exception e) {
pstmt = null;
}
MBPBankAccount[] retValue = new MBPBankAccount[list.size()]; MBPBankAccount[] retValue = new MBPBankAccount[list.size()];
list.toArray(retValue); list.toArray(retValue);

View File

@ -49,7 +49,6 @@ public class MBPartner extends X_C_BPartner
*/ */
private static final long serialVersionUID = -3669895599574182217L; private static final long serialVersionUID = -3669895599574182217L;
/** /**
* Get Empty Template Business Partner * Get Empty Template Business Partner
* @param ctx context * @param ctx context
@ -97,38 +96,10 @@ public class MBPartner extends X_C_BPartner
*/ */
public static MBPartner getBPartnerCashTrx (Properties ctx, int AD_Client_ID) public static MBPartner getBPartnerCashTrx (Properties ctx, int AD_Client_ID)
{ {
MBPartner retValue = null; MBPartner retValue = (MBPartner) MClientInfo.get(ctx, AD_Client_ID).getC_BPartnerCashTrx();
String sql = "SELECT * FROM C_BPartner " if (retValue == null)
+ "WHERE C_BPartner_ID IN (SELECT C_BPartnerCashTrx_ID FROM AD_ClientInfo WHERE AD_Client_ID=?)"; s_log.log(Level.SEVERE, "Not found for AD_Client_ID=" + AD_Client_ID);
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
retValue = new MBPartner (ctx, rs, null);
else
s_log.log(Level.SEVERE, "Not found for AD_Client_ID=" + AD_Client_ID);
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
finally
{
try
{
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null;
}
return retValue; return retValue;
} // getBPartnerCashTrx } // getBPartnerCashTrx
@ -142,9 +113,9 @@ public class MBPartner extends X_C_BPartner
{ {
if (Value == null || Value.length() == 0) if (Value == null || Value.length() == 0)
return null; return null;
String whereClause = "Value=? AND AD_Client_ID=?"; final String whereClause = "Value=? AND AD_Client_ID=?";
MBPartner retValue = new Query(ctx,MBPartner.Table_Name,whereClause.toString(),null) MBPartner retValue = new Query(ctx, I_C_BPartner.Table_Name, whereClause, null)
.setParameters(new Object[]{Value,Env.getAD_Client_ID(ctx)}) .setParameters(Value,Env.getAD_Client_ID(ctx))
.firstOnly(); .firstOnly();
return retValue; return retValue;
} // get } // get
@ -157,9 +128,9 @@ public class MBPartner extends X_C_BPartner
*/ */
public static MBPartner get (Properties ctx, int C_BPartner_ID) public static MBPartner get (Properties ctx, int C_BPartner_ID)
{ {
String whereClause = "C_BPartner_ID=? AND AD_Client_ID=?"; final String whereClause = "C_BPartner_ID=? AND AD_Client_ID=?";
MBPartner retValue = new Query(ctx,MBPartner.Table_Name,whereClause.toString(),null) MBPartner retValue = new Query(ctx,I_C_BPartner.Table_Name,whereClause,null)
.setParameters(new Object[]{C_BPartner_ID,Env.getAD_Client_ID(ctx)}) .setParameters(C_BPartner_ID,Env.getAD_Client_ID(ctx))
.firstOnly(); .firstOnly();
return retValue; return retValue;
} // get } // get

View File

@ -59,7 +59,7 @@ public class MBPartnerLocation extends X_C_BPartner_Location
public static MBPartnerLocation[] getForBPartner (Properties ctx, int C_BPartner_ID, String trxName) public static MBPartnerLocation[] getForBPartner (Properties ctx, int C_BPartner_ID, String trxName)
{ {
List<MBPartnerLocation> list = new Query(ctx, Table_Name, "C_BPartner_ID=?", trxName) List<MBPartnerLocation> list = new Query(ctx, Table_Name, "C_BPartner_ID=?", trxName)
.setParameters(new Object[]{C_BPartner_ID}) .setParameters(C_BPartner_ID)
.list(); .list();
MBPartnerLocation[] retValue = new MBPartnerLocation[list.size ()]; MBPartnerLocation[] retValue = new MBPartnerLocation[list.size ()];
list.toArray (retValue); list.toArray (retValue);

View File

@ -18,12 +18,10 @@ package org.compiere.model;
import java.io.File; import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import org.compiere.process.DocAction; import org.compiere.process.DocAction;
import org.compiere.process.DocumentEngine; import org.compiere.process.DocumentEngine;
@ -131,37 +129,11 @@ public class MBankStatement extends X_C_BankStatement implements DocAction
return m_lines; return m_lines;
} }
// //
ArrayList<MBankStatementLine> list = new ArrayList<MBankStatementLine>(); final String whereClause = I_C_BankStatementLine.COLUMNNAME_C_BankStatement_ID+"=?";
String sql = "SELECT * FROM C_BankStatementLine " List<MBankStatementLine> list = new Query(getCtx(),I_C_BankStatementLine.Table_Name,whereClause,get_TrxName())
+ "WHERE C_BankStatement_ID=?" .setParameters(getC_BankStatement_ID())
+ "ORDER BY Line"; .setOrderBy("Line")
PreparedStatement pstmt = null; .list();
try
{
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getC_BankStatement_ID());
ResultSet rs = pstmt.executeQuery();
while (rs.next())
list.add (new MBankStatementLine(getCtx(), rs, get_TrxName()));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, "getLines", e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
MBankStatementLine[] retValue = new MBankStatementLine[list.size()]; MBankStatementLine[] retValue = new MBankStatementLine[list.size()];
list.toArray(retValue); list.toArray(retValue);
return retValue; return retValue;

View File

@ -69,14 +69,14 @@ public class MCash extends X_C_Cash implements DocAction
Timestamp dateAcct, int C_Currency_ID, String trxName) Timestamp dateAcct, int C_Currency_ID, String trxName)
{ {
// Existing Journal // Existing Journal
String whereClause = "C_Cash.AD_Org_ID=?" // #1 final String whereClause = "C_Cash.AD_Org_ID=?" // #1
+ " AND TRUNC(C_Cash.StatementDate)=?" // #2 + " AND TRUNC(C_Cash.StatementDate)=?" // #2
+ " AND C_Cash.Processed='N'" + " AND C_Cash.Processed='N'"
+ " AND EXISTS (SELECT * FROM C_CashBook cb " + " AND EXISTS (SELECT * FROM C_CashBook cb "
+ "WHERE C_Cash.C_CashBook_ID=cb.C_CashBook_ID AND cb.AD_Org_ID=C_Cash.AD_Org_ID" + "WHERE C_Cash.C_CashBook_ID=cb.C_CashBook_ID AND cb.AD_Org_ID=C_Cash.AD_Org_ID"
+ " AND cb.C_Currency_ID=?)"; // #3 + " AND cb.C_Currency_ID=?)"; // #3
MCash retValue = new Query(ctx, MCash.Table_Name, whereClause, trxName) MCash retValue = new Query(ctx, I_C_Cash.Table_Name, whereClause, trxName)
.setParameters(new Object[]{AD_Org_ID,TimeUtil.getDay(dateAcct),C_Currency_ID}) .setParameters(AD_Org_ID,TimeUtil.getDay(dateAcct),C_Currency_ID)
.first() .first()
; ;
@ -108,12 +108,12 @@ public class MCash extends X_C_Cash implements DocAction
public static MCash get (Properties ctx, int C_CashBook_ID, public static MCash get (Properties ctx, int C_CashBook_ID,
Timestamp dateAcct, String trxName) Timestamp dateAcct, String trxName)
{ {
String whereClause ="C_CashBook_ID=?" // #1 final String whereClause ="C_CashBook_ID=?" // #1
+ " AND TRUNC(StatementDate)=?" // #2 + " AND TRUNC(StatementDate)=?" // #2
+ " AND Processed='N'"; + " AND Processed='N'";
MCash retValue = new Query(ctx, MCash.Table_Name, whereClause, trxName) MCash retValue = new Query(ctx, MCash.Table_Name, whereClause, trxName)
.setParameters(new Object[]{C_CashBook_ID, TimeUtil.getDay(dateAcct)}) .setParameters(C_CashBook_ID, TimeUtil.getDay(dateAcct))
.first() .first()
; ;
@ -217,10 +217,10 @@ public class MCash extends X_C_Cash implements DocAction
return m_lines; return m_lines;
} }
String whereClause =MCashLine.COLUMNNAME_C_Cash_ID+"=?"; final String whereClause =MCashLine.COLUMNNAME_C_Cash_ID+"=?";
List<MCashLine> list = new Query(getCtx(),MCashLine.Table_Name, whereClause, get_TrxName()) List<MCashLine> list = new Query(getCtx(),I_C_CashLine.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{getC_Cash_ID()}) .setParameters(getC_Cash_ID())
.setOrderBy(MCashLine.COLUMNNAME_Line) .setOrderBy(I_C_CashLine.COLUMNNAME_Line)
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.list(); .list();

View File

@ -80,9 +80,9 @@ public class MCommission extends X_C_Commission
{ {
//[ 1867477 ] //[ 1867477 ]
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String whereClause = "IsActive='Y' AND C_Commission_ID=?"; final String whereClause = "IsActive='Y' AND C_Commission_ID=?";
List<MCommissionLine> list = new Query(getCtx(), MCommissionLine.Table_Name, whereClause, get_TrxName()) List<MCommissionLine> list = new Query(getCtx(), I_C_CommissionLine.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{getC_Commission_ID()}) .setParameters(getC_Commission_ID())
.setOrderBy("Line") .setOrderBy("Line")
.list(); .list();
// Convert // Convert

View File

@ -17,13 +17,10 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
/** /**
@ -88,35 +85,10 @@ public class MCommissionAmt extends X_C_CommissionAmt
*/ */
public MCommissionDetail[] getDetails() public MCommissionDetail[] getDetails()
{ {
String sql = "SELECT * FROM C_CommissionDetail WHERE C_CommissionAmt_ID=?"; final String whereClause = I_C_CommissionDetail.COLUMNNAME_C_CommissionAmt_ID+"=?";
ArrayList<MCommissionDetail> list = new ArrayList<MCommissionDetail>(); List<MCommissionDetail> list = new Query(getCtx(),I_C_CommissionDetail.Table_Name, whereClause, get_TrxName())
PreparedStatement pstmt = null; .setParameters(getC_CommissionAmt_ID())
try .list();
{
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getC_CommissionAmt_ID());
ResultSet rs = pstmt.executeQuery();
while (rs.next())
list.add(new MCommissionDetail(getCtx(), rs, get_TrxName()));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
// Convert // Convert
MCommissionDetail[] retValue = new MCommissionDetail[list.size()]; MCommissionDetail[] retValue = new MCommissionDetail[list.size()];
list.toArray(retValue); list.toArray(retValue);

View File

@ -17,13 +17,10 @@
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
/** /**
@ -34,10 +31,12 @@ import org.compiere.util.Env;
*/ */
public class MCommissionRun extends X_C_CommissionRun public class MCommissionRun extends X_C_CommissionRun
{ {
/**
*
*/ /**
private static final long serialVersionUID = -3103035295526318283L; *
*/
private static final long serialVersionUID = -3103035295526318283L;
/** /**
* Standard Constructor * Standard Constructor
@ -86,35 +85,10 @@ public class MCommissionRun extends X_C_CommissionRun
*/ */
public MCommissionAmt[] getAmts() public MCommissionAmt[] getAmts()
{ {
String sql = "SELECT * FROM C_CommissionAmt WHERE C_CommissionRun_ID=?"; final String whereClause = I_C_CommissionAmt.COLUMNNAME_C_CommissionRun_ID+"=?";
ArrayList<MCommissionAmt> list = new ArrayList<MCommissionAmt>(); List<MCommissionAmt> list = new Query(getCtx(),I_C_CommissionAmt.Table_Name,whereClause,get_TrxName())
PreparedStatement pstmt = null; .setParameters(getC_CommissionRun_ID())
try .list();
{
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getC_CommissionRun_ID());
ResultSet rs = pstmt.executeQuery();
while (rs.next())
list.add(new MCommissionAmt(getCtx(), rs, get_TrxName()));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
// Convert // Convert
MCommissionAmt[] retValue = new MCommissionAmt[list.size()]; MCommissionAmt[] retValue = new MCommissionAmt[list.size()];
list.toArray(retValue); list.toArray(retValue);

View File

@ -32,8 +32,10 @@ import org.compiere.util.DB;
*/ */
public class MContainer extends X_CM_Container public class MContainer extends X_CM_Container
{ {
/** serialVersionUID */ /**
private static final long serialVersionUID = 395679572291279730L; *
*/
private static final long serialVersionUID = 3999588662066631303L;
/** /**
* get Container by Relative URL * get Container by Relative URL
@ -46,9 +48,9 @@ public class MContainer extends X_CM_Container
public static MContainer get(Properties ctx, String relURL, int CM_WebProject_Id, String trxName) { public static MContainer get(Properties ctx, String relURL, int CM_WebProject_Id, String trxName) {
MContainer thisContainer = null; MContainer thisContainer = null;
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
String whereClause = "(RelativeURL LIKE ? OR RelativeURL LIKE ?) AND CM_WebProject_ID=?"; final String whereClause = "(RelativeURL LIKE ? OR RelativeURL LIKE ?) AND CM_WebProject_ID=?";
thisContainer = new Query(ctx, MContainer.Table_Name, whereClause, trxName) thisContainer = new Query(ctx, I_CM_Container.Table_Name, whereClause, trxName)
.setParameters(new Object[]{relURL, relURL+"/",CM_WebProject_Id}) .setParameters(relURL, relURL+"/",CM_WebProject_Id)
.first(); .first();
return thisContainer; return thisContainer;
@ -66,9 +68,9 @@ public class MContainer extends X_CM_Container
public static MContainer get(Properties ctx, int CM_Container_ID, int CM_WebProject_Id, String trxName) { public static MContainer get(Properties ctx, int CM_Container_ID, int CM_WebProject_Id, String trxName) {
MContainer thisContainer = null; MContainer thisContainer = null;
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
String whereClause = "CM_Container_ID=? AND CM_WebProject_ID=?"; final String whereClause = "CM_Container_ID=? AND CM_WebProject_ID=?";
thisContainer = new Query(ctx, MContainer.Table_Name, whereClause, trxName) thisContainer = new Query(ctx, I_CM_Container.Table_Name, whereClause, trxName)
.setParameters(new Object[]{CM_Container_ID, CM_WebProject_Id}) .setParameters(CM_Container_ID, CM_WebProject_Id)
.first(); .first();
// //
return thisContainer; return thisContainer;
@ -112,9 +114,9 @@ public class MContainer extends X_CM_Container
{ {
MContainer cc = null; MContainer cc = null;
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
String whereClause = "CM_Container_ID=?"; final String whereClause = "CM_Container_ID=?";
cc = new Query(ctx, MContainer.Table_Name, whereClause, trxName) cc = new Query(ctx, I_CM_Container.Table_Name, whereClause, trxName)
.setParameters(new Object[]{CM_Container_ID}) .setParameters(CM_Container_ID)
.first(); .first();
// //
return cc; return cc;
@ -130,9 +132,9 @@ public class MContainer extends X_CM_Container
public static MContainer[] getContainers (MWebProject project) public static MContainer[] getContainers (MWebProject project)
{ {
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
String whereClause = "CM_WebProject_ID=?"; final String whereClause = "CM_WebProject_ID=?";
List<MContainer> list = new Query(project.getCtx(), MContainer.Table_Name, whereClause, project.get_TrxName()) List<MContainer> list = new Query(project.getCtx(), I_CM_Container.Table_Name, whereClause, project.get_TrxName())
.setParameters(new Object[]{project.getCM_WebProject_ID ()}) .setParameters(project.getCM_WebProject_ID ())
.setOrderBy("CM_Container_ID") .setOrderBy("CM_Container_ID")
.list(); .list();
// //

View File

@ -16,13 +16,10 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB;
/** /**
* CStage Element * CStage Element
@ -32,11 +29,13 @@ import org.compiere.util.DB;
*/ */
public class MContainerElement extends X_CM_Container_Element public class MContainerElement extends X_CM_Container_Element
{ {
/** serialVersionUID */ /**
private static final long serialVersionUID = 7230036377422361941L; *
*/
private static final long serialVersionUID = 8487403111353473486L;
/** Logger */ /** Logger */
private static CLogger s_log = CLogger.getCLogger (MContainer.class); private static CLogger s_log = CLogger.getCLogger (MContainerElement.class);
/** /**
* get Container Element by ID * get Container Element by ID
@ -46,35 +45,7 @@ public class MContainerElement extends X_CM_Container_Element
* @return ContainerElement * @return ContainerElement
*/ */
public static MContainerElement get(Properties ctx, int CM_ContainerElement_ID, String trxName) { public static MContainerElement get(Properties ctx, int CM_ContainerElement_ID, String trxName) {
MContainerElement thisContainerElement = null; return new MContainerElement(ctx, CM_ContainerElement_ID, trxName);
String sql = "SELECT * FROM CM_Container_Element WHERE CM_Container_Element_ID=?";
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement(sql, trxName);
pstmt.setInt(1, CM_ContainerElement_ID);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
thisContainerElement = (new MContainerElement(ctx, rs, trxName));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
return thisContainerElement;
} }
/*************************************************************************** /***************************************************************************

View File

@ -23,6 +23,7 @@ import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
@ -45,7 +46,8 @@ public class MConversionRate extends X_C_Conversion_Rate
/** /**
* *
*/ */
private static final long serialVersionUID = -2753651400799848008L; private static final long serialVersionUID = -8171829790483133141L;
/** Logger */ /** Logger */
private static CLogger s_log = CLogger.getCLogger (MConversionRate.class); private static CLogger s_log = CLogger.getCLogger (MConversionRate.class);
@ -156,12 +158,10 @@ public class MConversionRate extends X_C_Conversion_Rate
spotCal.set(Calendar.SECOND, 0); spotCal.set(Calendar.SECOND, 0);
spotCal.set(Calendar.MILLISECOND, 0); spotCal.set(Calendar.MILLISECOND, 0);
startTs = new java.sql.Timestamp(spotCal.getTimeInMillis()); startTs = new java.sql.Timestamp(spotCal.getTimeInMillis());
final String whereClause = "C_Currency_ID=? and C_Currency_ID_To=? and ValidFrom>=? and ValidTo<=? and C_ConversionType_ID=?";
MConversionRate rate, updateRate = null; MConversionRate rate, updateRate = null;
java.util.List<MConversionRate> rates = new Query(ctx, MConversionRate.Table_Name, List<MConversionRate> rates = new Query(ctx, I_C_Conversion_Rate.Table_Name, whereClause,trxName)
"C_Currency_ID=? and C_Currency_ID_To=? and ValidFrom>=? and ValidTo<=? and C_ConversionType_ID=?", .setParameters(curFrom.get_ID(), curTo.get_ID(), startTs, startTs, MConversionType.TYPE_SPOT)
trxName)
.setParameters(new Object[]{curFrom.get_ID(), curTo.get_ID(), startTs, startTs, MConversionType.TYPE_SPOT})
.list(); .list();
if (rates.size()>0) { if (rates.size()>0) {

View File

@ -1289,20 +1289,19 @@ public class MCost extends X_M_Cost
{ {
MCost cost = null; MCost cost = null;
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String whereClause = "AD_Client_ID=? AND AD_Org_ID=?" final String whereClause = "AD_Client_ID=? AND AD_Org_ID=?"
+ " AND M_Product_ID=?" + " AND M_Product_ID=?"
+ " AND M_AttributeSetInstance_ID=?" + " AND M_AttributeSetInstance_ID=?"
+ " AND M_CostType_ID=? AND C_AcctSchema_ID=?" + " AND M_CostType_ID=? AND C_AcctSchema_ID=?"
+ " AND M_CostElement_ID=?"; + " AND M_CostElement_ID=?";
cost = new Query(product.getCtx(), MCost.Table_Name, whereClause, trxName) cost = new Query(product.getCtx(), I_M_Cost.Table_Name, whereClause, trxName)
.setParameters(new Object[]{ .setParameters( product.getAD_Client_ID(),
product.getAD_Client_ID(),
AD_Org_ID, AD_Org_ID,
product.getM_Product_ID(), product.getM_Product_ID(),
M_AttributeSetInstance_ID, M_AttributeSetInstance_ID,
as.getM_CostType_ID(), as.getM_CostType_ID(),
as.getC_AcctSchema_ID(), as.getC_AcctSchema_ID(),
M_CostElement_ID}) M_CostElement_ID)
.firstOnly(); .firstOnly();
//FR: [ 2214883 ] - end - //FR: [ 2214883 ] - end -
// New // New

View File

@ -16,13 +16,10 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.CCache; import org.compiere.util.CCache;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
@ -38,6 +35,8 @@ import org.compiere.util.Msg;
* @author Teo Sarca, www.arhipac.ro * @author Teo Sarca, www.arhipac.ro
* <li>BF [ 2664529 ] More then one Labor/Burden//Overhead is not allowed * <li>BF [ 2664529 ] More then one Labor/Burden//Overhead is not allowed
* <li>BF [ 2667470 ] MCostElement.getMaterialCostElement should check only material * <li>BF [ 2667470 ] MCostElement.getMaterialCostElement should check only material
* @author red1
* <li>FR: [ 2214883 ] Remove SQL code and Replace for Query -- JUnit tested
*/ */
public class MCostElement extends X_M_CostElement public class MCostElement extends X_M_CostElement
{ {
@ -61,9 +60,10 @@ public class MCostElement extends X_M_CostElement
return null; return null;
} }
// //
final String whereClause = "AD_Client_ID=? AND CostingMethod=? AND CostElementType=?"; final String whereClause = "CostingMethod=? AND CostElementType=?";
MCostElement retValue = new Query(po.getCtx(), Table_Name, whereClause, po.get_TrxName()) MCostElement retValue = new Query(po.getCtx(), Table_Name, whereClause, po.get_TrxName())
.setParameters(new Object[]{po.getAD_Client_ID(), CostingMethod, COSTELEMENTTYPE_Material}) .setParameters(CostingMethod, COSTELEMENTTYPE_Material)
.setClient_ID()
.setOrderBy("AD_Org_ID") .setOrderBy("AD_Org_ID")
.firstOnly(); .firstOnly();
if (retValue != null) if (retValue != null)
@ -92,37 +92,17 @@ public class MCostElement extends X_M_CostElement
*/ */
public static MCostElement getMaterialCostElement(Properties ctx, String CostingMethod) public static MCostElement getMaterialCostElement(Properties ctx, String CostingMethod)
{ {
final String whereClause = "CostingMethod=?";
List<MCostElement> list = new Query(ctx, I_M_CostElement.Table_Name, whereClause, null)
.setParameters(CostingMethod)
.setClient_ID()
.setOrderBy(I_M_CostElement.COLUMNNAME_AD_Org_ID)
.list();
MCostElement retValue = null; MCostElement retValue = null;
String sql = "SELECT * FROM M_CostElement WHERE AD_Client_ID=? AND CostingMethod=? ORDER BY AD_Org_ID"; if (list.size() > 0)
PreparedStatement pstmt = null; retValue = list.get(0);
try if (list.size() > 1)
{ s_log.info("More then one Material Cost Element for CostingMethod=" + CostingMethod);
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, Env.getAD_Client_ID(ctx));
pstmt.setString(2, CostingMethod);
ResultSet rs = pstmt.executeQuery ();
if (rs.next ())
retValue = new MCostElement (ctx, rs, null);
if (rs.next())
s_log.info("More then one Material Cost Element for CostingMethod=" + CostingMethod);
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
return retValue; return retValue;
} // getMaterialCostElement } // getMaterialCostElement
@ -147,36 +127,12 @@ public class MCostElement extends X_M_CostElement
*/ */
public static MCostElement[] getCostingMethods (PO po) public static MCostElement[] getCostingMethods (PO po)
{ {
ArrayList<MCostElement> list = new ArrayList<MCostElement>(); final String whereClause ="CostElementType=? AND CostingMethod IS NOT NULL";
String sql = "SELECT * FROM M_CostElement " List<MCostElement> list = new Query(po.getCtx(), I_M_CostElement.Table_Name, whereClause, po.get_TrxName())
+ "WHERE AD_Client_ID=?" .setParameters(COSTELEMENTTYPE_Material)
+ " AND IsActive='Y' AND CostElementType='M' AND CostingMethod IS NOT NULL"; .setClient_ID()
PreparedStatement pstmt = null; .setOnlyActiveRecords(true)
try .list();
{
pstmt = DB.prepareStatement (sql, po.get_TrxName());
pstmt.setInt (1, po.getAD_Client_ID());
ResultSet rs = pstmt.executeQuery ();
while (rs.next ())
list.add(new MCostElement (po.getCtx(), rs, po.get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
// //
MCostElement[] retValue = new MCostElement[list.size ()]; MCostElement[] retValue = new MCostElement[list.size ()];
list.toArray (retValue); list.toArray (retValue);
@ -191,36 +147,11 @@ public class MCostElement extends X_M_CostElement
*/ */
public static MCostElement[] getNonCostingMethods (PO po) public static MCostElement[] getNonCostingMethods (PO po)
{ {
ArrayList<MCostElement> list = new ArrayList<MCostElement>(); final String whereClause = "CostingMethod IS NULL";
String sql = "SELECT * FROM M_CostElement " List<MCostElement>list = new Query(po.getCtx(),I_M_CostElement.Table_Name, whereClause, po.get_TrxName())
+ "WHERE AD_Client_ID=?" .setClient_ID()
+ " AND IsActive='Y' AND CostingMethod IS NULL"; .setOnlyActiveRecords(true)
PreparedStatement pstmt = null; .list();
try
{
pstmt = DB.prepareStatement (sql, po.get_TrxName());
pstmt.setInt (1, po.getAD_Client_ID());
ResultSet rs = pstmt.executeQuery ();
while (rs.next ())
list.add(new MCostElement (po.getCtx(), rs, po.get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
// //
MCostElement[] retValue = new MCostElement[list.size ()]; MCostElement[] retValue = new MCostElement[list.size ()];
list.toArray (retValue); list.toArray (retValue);
@ -255,12 +186,12 @@ public class MCostElement extends X_M_CostElement
*/ */
public static MCostElement[] getElements (Properties ctx, String trxName) public static MCostElement[] getElements (Properties ctx, String trxName)
{ {
int AD_Client_ID = Env.getAD_Client_ID(ctx);
int AD_Org_ID = 0; // Org is always ZERO - see beforeSave int AD_Org_ID = 0; // Org is always ZERO - see beforeSave
String whereClause = "AD_Client_ID = ? AND AD_Org_ID = ?"; final String whereClause = "AD_Org_ID=?";
List<MCostElement> list = new Query(ctx, Table_Name, whereClause, trxName) List<MCostElement> list = new Query(ctx, Table_Name, whereClause, trxName)
.setParameters(new Object[]{AD_Client_ID, AD_Org_ID}) .setParameters(AD_Org_ID)
.setClient_ID()
.list(); .list();
MCostElement[] retValue = new MCostElement[list.size()]; MCostElement[] retValue = new MCostElement[list.size()];
list.toArray(retValue); list.toArray(retValue);
@ -279,7 +210,7 @@ public class MCostElement extends X_M_CostElement
return new Query(ctx, Table_Name, whereClause, null) return new Query(ctx, Table_Name, whereClause, null)
.setClient_ID() .setClient_ID()
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.setParameters(new Object[]{CostingMethod}) .setParameters(CostingMethod)
.list(); .list();
} }
@ -345,7 +276,7 @@ public class MCostElement extends X_M_CostElement
} }
} }
// Maintain Calclated // Maintain Calculated
/* /*
if (COSTELEMENTTYPE_Material.equals(getCostElementType())) if (COSTELEMENTTYPE_Material.equals(getCostElementType()))
{ {
@ -393,37 +324,14 @@ public class MCostElement extends X_M_CostElement
} }
// Costing Methods on PC level // Costing Methods on PC level
String sql = "SELECT M_Product_Category_ID FROM M_Product_Category_Acct WHERE AD_Client_ID=? AND CostingMethod=?";
int M_Product_Category_ID = 0; int M_Product_Category_ID = 0;
PreparedStatement pstmt = null; final String whereClause ="CostingMethod=?";
try MProductCategoryAcct retValue = new Query(getCtx(), I_M_Product_Category_Acct.Table_Name, whereClause, null)
{ .setParameters(getCostingMethod())
pstmt = DB.prepareStatement (sql, null); .setClient_ID()
pstmt.setInt (1, getAD_Client_ID()); .first();
pstmt.setString (2, getCostingMethod()); if (retValue != null)
ResultSet rs = pstmt.executeQuery (); M_Product_Category_ID = retValue.getM_Product_Category_ID();
if (rs.next ())
{
M_Product_Category_ID = rs.getInt(1);
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
if (M_Product_Category_ID != 0) if (M_Product_Category_ID != 0)
{ {
log.saveError("CannotDeleteUsed", Msg.getElement(getCtx(), "M_Product_Category_ID") log.saveError("CannotDeleteUsed", Msg.getElement(getCtx(), "M_Product_Category_ID")

View File

@ -105,8 +105,8 @@ public class MCurrency extends X_C_Currency
return retValue; return retValue;
// Try database // Try database
Query query = new Query(ctx, MCurrency.Table_Name, "iso_code=?", null); Query query = new Query(ctx, I_C_Currency.Table_Name, "ISO_Code=?", null);
query.setParameters(new Object[]{ISOcode}); query.setParameters(ISOcode);
retValue = (MCurrency)query.firstOnly(); retValue = (MCurrency)query.firstOnly();
// Save // Save

View File

@ -61,9 +61,9 @@ public class MDocType extends X_C_DocType
*/ */
static public MDocType[] getOfDocBaseType (Properties ctx, String DocBaseType) static public MDocType[] getOfDocBaseType (Properties ctx, String DocBaseType)
{ {
String whereClause = "AD_Client_ID=? AND DocBaseType=?"; final String whereClause = "AD_Client_ID=? AND DocBaseType=?";
List<MDocType> list = new Query(ctx, Table_Name, whereClause, null) List<MDocType> list = new Query(ctx, Table_Name, whereClause, null)
.setParameters(new Object[]{Env.getAD_Client_ID(ctx), DocBaseType}) .setParameters(Env.getAD_Client_ID(ctx), DocBaseType)
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.setOrderBy("IsDefault DESC, C_DocType_ID") .setOrderBy("IsDefault DESC, C_DocType_ID")
.list(); .list();
@ -77,9 +77,8 @@ public class MDocType extends X_C_DocType
*/ */
static public MDocType[] getOfClient (Properties ctx) static public MDocType[] getOfClient (Properties ctx)
{ {
String whereClause = "AD_Client_ID=?"; List<MDocType> list = new Query(ctx, Table_Name, null, null)
List<MDocType> list = new Query(ctx, Table_Name, whereClause, null) .setClient_ID()
.setParameters(new Object[]{Env.getAD_Client_ID(ctx)})
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.list(); .list();
return list.toArray(new MDocType[list.size()]); return list.toArray(new MDocType[list.size()]);

View File

@ -85,11 +85,11 @@ public class MDunningRun extends X_C_DunningRun
// just one level // just one level
levels = new Query( levels = new Query(
getCtx(), getCtx(),
MDunningLevel.Table_Name, I_C_DunningLevel.Table_Name,
"C_Dunning_ID=? AND C_DunningLevel_ID=?", "C_Dunning_ID=? AND C_DunningLevel_ID=?",
get_TrxName()) get_TrxName())
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.setParameters(new Object[]{getC_Dunning_ID(), getC_DunningLevel_ID()}) .setParameters(getC_Dunning_ID(), getC_DunningLevel_ID())
.setOrderBy("DaysAfterDue DESC, C_DunningLevel_ID") .setOrderBy("DaysAfterDue DESC, C_DunningLevel_ID")
.list(); .list();
} else { } else {
@ -100,7 +100,7 @@ public class MDunningRun extends X_C_DunningRun
"C_Dunning_ID=?", "C_Dunning_ID=?",
get_TrxName()) get_TrxName())
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.setParameters(new Object[]{getC_Dunning_ID()}) .setParameters(getC_Dunning_ID())
.setOrderBy("DaysAfterDue DESC, C_DunningLevel_ID") .setOrderBy("DaysAfterDue DESC, C_DunningLevel_ID")
.list(); .list();
} }

View File

@ -87,7 +87,7 @@ public class MEXPFormat extends X_EXP_Format {
final String clauseWhere = X_EXP_FormatLine.COLUMNNAME_EXP_Format_ID + "=?"; final String clauseWhere = X_EXP_FormatLine.COLUMNNAME_EXP_Format_ID + "=?";
m_lines = new Query(getCtx() , I_EXP_FormatLine.Table_Name, clauseWhere , get_TrxName()) m_lines = new Query(getCtx() , I_EXP_FormatLine.Table_Name, clauseWhere , get_TrxName())
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.setParameters(new Object[]{getEXP_Format_ID()}) .setParameters(getEXP_Format_ID())
.setOrderBy(orderBy) .setOrderBy(orderBy)
.list(); .list();
return m_lines; return m_lines;
@ -102,7 +102,7 @@ public class MEXPFormat extends X_EXP_Format {
+ " AND " + X_EXP_FormatLine.COLUMNNAME_IsPartUniqueIndex +"= ?"; + " AND " + X_EXP_FormatLine.COLUMNNAME_IsPartUniqueIndex +"= ?";
m_lines_unique = new Query(getCtx(), I_EXP_FormatLine.Table_Name, clauseWhere, get_TrxName()) m_lines_unique = new Query(getCtx(), I_EXP_FormatLine.Table_Name, clauseWhere, get_TrxName())
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.setParameters(new Object[]{getEXP_Format_ID(), "Y"}) .setParameters(getEXP_Format_ID(), "Y")
.setOrderBy(X_EXP_FormatLine.COLUMNNAME_Position) .setOrderBy(X_EXP_FormatLine.COLUMNNAME_Position)
.list(); .list();
return m_lines_unique; return m_lines_unique;
@ -130,18 +130,18 @@ public class MEXPFormat extends X_EXP_Format {
if(retValue!=null) if(retValue!=null)
return retValue; return retValue;
StringBuffer whereCluse = new StringBuffer(X_EXP_Format.COLUMNNAME_Value).append("=?") StringBuffer whereClause = new StringBuffer(X_EXP_Format.COLUMNNAME_Value).append("=?")
.append(" AND AD_Client_ID = ?") .append(" AND AD_Client_ID = ?")
.append(" AND ").append(X_EXP_Format.COLUMNNAME_Version).append(" = ?"); .append(" AND ").append(X_EXP_Format.COLUMNNAME_Version).append(" = ?");
retValue = (MEXPFormat) new Query(ctx,X_EXP_Format.Table_Name,whereCluse.toString(),trxName) retValue = (MEXPFormat) new Query(ctx,X_EXP_Format.Table_Name,whereClause.toString(),trxName)
.setParameters(new Object[] {value,AD_Client_ID,version}).first(); .setParameters(value,AD_Client_ID,version).first();
if(retValue != null) if(retValue != null)
{ {
retValue.getFormatLines(); retValue.getFormatLines();
s_cache.put (key, retValue); s_cache.put (key, retValue);
exp_format_by_id_cache.put(retValue.getEXP_Format_ID(), retValue); exp_format_by_id_cache.put(retValue.getEXP_Format_ID(), retValue);
} }
return retValue; return retValue;
@ -161,13 +161,13 @@ public class MEXPFormat extends X_EXP_Format {
.append(" AND ").append(X_EXP_Format.COLUMNNAME_Version).append(" = ?"); .append(" AND ").append(X_EXP_Format.COLUMNNAME_Version).append(" = ?");
retValue = (MEXPFormat) new Query(ctx,X_EXP_Format.Table_Name,whereClause.toString(),trxName) retValue = (MEXPFormat) new Query(ctx,X_EXP_Format.Table_Name,whereClause.toString(),trxName)
.setParameters(new Object[] {AD_Client_ID,AD_Table_ID,version}) .setParameters(AD_Client_ID,AD_Table_ID,version)
.first(); .first();
if(retValue!=null) if(retValue!=null)
{ {
retValue.getFormatLines(); retValue.getFormatLines();
s_cache.put (key, retValue); s_cache.put (key, retValue);
exp_format_by_id_cache.put(retValue.getEXP_Format_ID(), retValue); exp_format_by_id_cache.put(retValue.getEXP_Format_ID(), retValue);
} }
return retValue; return retValue;

View File

@ -213,8 +213,8 @@ public class MElementValue extends X_C_ElementValue
{ {
// //
// Check if we have accounting facts // Check if we have accounting facts
boolean match = new Query(getCtx(), MFactAcct.Table_Name, MFactAcct.COLUMNNAME_Account_ID+"=?", get_TrxName()) boolean match = new Query(getCtx(), I_Fact_Acct.Table_Name, I_Fact_Acct.COLUMNNAME_Account_ID+"=?", get_TrxName())
.setParameters(new Object[]{getC_ElementValue_ID()}) .setParameters(getC_ElementValue_ID())
.match(); .match();
if (match) if (match)
{ {
@ -223,8 +223,8 @@ public class MElementValue extends X_C_ElementValue
// //
// Check Valid Combinations - teo_sarca FR [ 1883533 ] // Check Valid Combinations - teo_sarca FR [ 1883533 ]
String whereClause = MAccount.COLUMNNAME_Account_ID+"=?"; String whereClause = MAccount.COLUMNNAME_Account_ID+"=?";
POResultSet<MAccount> rs = new Query(getCtx(), MAccount.Table_Name, whereClause, get_TrxName()) POResultSet<MAccount> rs = new Query(getCtx(), I_C_ValidCombination.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{get_ID()}) .setParameters(get_ID())
.scroll(); .scroll();
try { try {
while(rs.hasNext()) { while(rs.hasNext()) {

View File

@ -39,7 +39,7 @@ public class MFactAcct extends X_Fact_Acct
/** /**
* *
*/ */
private static final long serialVersionUID = 756203818233903671L; private static final long serialVersionUID = 5251847162314796574L;
/** /**
* Delete Accounting * Delete Accounting
@ -135,19 +135,4 @@ public class MFactAcct extends X_Fact_Acct
return acct; return acct;
} // getMAccount } // getMAccount
/**
* Check if a document is already posted
* @param AD_Table_ID table
* @param Record_ID record
* @param trxName transaction
* @return boolean indicating if the document has already accounting facts
* @throws DBException on database exception
*/
public static boolean alreadyPosted(int AD_Table_ID, int Record_ID, String trxName) throws DBException
{
final String sql = "SELECT 1 FROM Fact_Acct WHERE AD_Table_ID=? AND Record_ID=?";
int one = DB.getSQLValue(trxName, sql, new Object[]{AD_Table_ID, Record_ID});
return (one == 1);
}
} // MFactAcct } // MFactAcct

View File

@ -32,8 +32,6 @@ package org.compiere.model;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Properties; import java.util.Properties;
import org.compiere.util.Env;
/** /**
* *
* @author Daniel Tamm * @author Daniel Tamm
@ -80,8 +78,8 @@ public class MFreightCategory extends X_M_FreightCategory {
*/ */
public static MFreightCategory getByValue(Properties ctx, String value, String trxName) { public static MFreightCategory getByValue(Properties ctx, String value, String trxName) {
Query q = new Query(ctx, MFreightCategory.Table_Name, "Value=? AND AD_Client_ID=?", trxName); Query q = new Query(ctx, I_M_FreightCategory.Table_Name, "Value=?", trxName);
q.setParameters(new Object[]{value, Env.getAD_Client_ID(ctx)}); q.setParameters(value).setClient_ID();
return q.first(); return q.first();
} }

View File

@ -623,8 +623,8 @@ public class MInOut extends X_M_InOut implements DocAction
set_TrxName(m_lines, get_TrxName()); set_TrxName(m_lines, get_TrxName());
return m_lines; return m_lines;
} }
List<MInOutLine> list = new Query(getCtx(), MInOutLine.Table_Name, "M_InOut_ID=?", get_TrxName()) List<MInOutLine> list = new Query(getCtx(), I_M_InOutLine.Table_Name, "M_InOut_ID=?", get_TrxName())
.setParameters(new Object[]{getM_InOut_ID()}) .setParameters(getM_InOut_ID())
.setOrderBy(MInOutLine.COLUMNNAME_Line) .setOrderBy(MInOutLine.COLUMNNAME_Line)
.list(); .list();
// //
@ -655,8 +655,8 @@ public class MInOut extends X_M_InOut implements DocAction
set_TrxName(m_confirms, get_TrxName()); set_TrxName(m_confirms, get_TrxName());
return m_confirms; return m_confirms;
} }
List<MInOutConfirm> list = new Query(getCtx(), MInOutConfirm.Table_Name, "M_InOut_ID=?", get_TrxName()) List<MInOutConfirm> list = new Query(getCtx(), I_M_InOutConfirm.Table_Name, "M_InOut_ID=?", get_TrxName())
.setParameters(new Object[]{getM_InOut_ID()}) .setParameters(getM_InOut_ID())
.list(); .list();
m_confirms = new MInOutConfirm[list.size ()]; m_confirms = new MInOutConfirm[list.size ()];
list.toArray (m_confirms); list.toArray (m_confirms);
@ -1486,6 +1486,9 @@ public class MInOut extends X_M_InOut implements DocAction
m_processMsg = CLogger.retrieveErrorString("Could not create Inv Matching"); m_processMsg = CLogger.retrieveErrorString("Could not create Inv Matching");
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
} }
if (MClient.isClientAccountingImmediate()) {
String ignoreError = DocumentEngine.postImmediate(inv.getCtx(), inv.getAD_Client_ID(), inv.get_Table_ID(), inv.get_ID(), true, inv.get_TrxName());
}
} }
} }
@ -1500,6 +1503,9 @@ public class MInOut extends X_M_InOut implements DocAction
m_processMsg = "Could not create PO Matching"; m_processMsg = "Could not create PO Matching";
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
} }
if (MClient.isClientAccountingImmediate()) {
String ignoreError = DocumentEngine.postImmediate(po.getCtx(), po.getAD_Client_ID(), po.get_Table_ID(), po.get_ID(), true, po.get_TrxName());
}
// Update PO with ASI // Update PO with ASI
if ( oLine != null && oLine.getM_AttributeSetInstance_ID() == 0 if ( oLine != null && oLine.getM_AttributeSetInstance_ID() == 0
&& sLine.getMovementQty().compareTo(oLine.getQtyOrdered()) == 0) // just if full match [ 1876965 ] && sLine.getMovementQty().compareTo(oLine.getQtyOrdered()) == 0) // just if full match [ 1876965 ]
@ -1523,6 +1529,9 @@ public class MInOut extends X_M_InOut implements DocAction
m_processMsg = "Could not create PO(Inv) Matching"; m_processMsg = "Could not create PO(Inv) Matching";
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
} }
if (MClient.isClientAccountingImmediate()) {
String ignoreError = DocumentEngine.postImmediate(po.getCtx(), po.getAD_Client_ID(), po.get_Table_ID(), po.get_ID(), true, po.get_TrxName());
}
// Update PO with ASI // Update PO with ASI
oLine = new MOrderLine (getCtx(), po.getC_OrderLine_ID(), get_TrxName()); oLine = new MOrderLine (getCtx(), po.getC_OrderLine_ID(), get_TrxName());
if ( oLine != null && oLine.getM_AttributeSetInstance_ID() == 0 if ( oLine != null && oLine.getM_AttributeSetInstance_ID() == 0

View File

@ -151,9 +151,9 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction
set_TrxName(m_lines, get_TrxName()); set_TrxName(m_lines, get_TrxName());
return m_lines; return m_lines;
} }
final String whereClause = MInOutLineConfirm.COLUMNNAME_M_InOutConfirm_ID+"=?"; final String whereClause = I_M_InOutLineConfirm.COLUMNNAME_M_InOutConfirm_ID+"=?";
List<MInOutLineConfirm> list = new Query(getCtx(), MInOutLineConfirm.Table_Name, whereClause, get_TrxName()) List<MInOutLineConfirm> list = new Query(getCtx(), I_M_InOutLineConfirm.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{getM_InOutConfirm_ID()}) .setParameters(getM_InOutConfirm_ID())
.list(); .list();
m_lines = new MInOutLineConfirm[list.size ()]; m_lines = new MInOutLineConfirm[list.size ()];
list.toArray (m_lines); list.toArray (m_lines);

View File

@ -60,7 +60,7 @@ public class MInOutLine extends X_M_InOutLine
{ {
String whereClause = "C_OrderLine_ID=?" + (!Util.isEmpty(where, true) ? " AND "+where : ""); String whereClause = "C_OrderLine_ID=?" + (!Util.isEmpty(where, true) ? " AND "+where : "");
List<MInOutLine> list = new Query(ctx, Table_Name, whereClause, trxName) List<MInOutLine> list = new Query(ctx, Table_Name, whereClause, trxName)
.setParameters(new Object[]{C_OrderLine_ID}) .setParameters(C_OrderLine_ID)
.list(); .list();
return list.toArray (new MInOutLine[list.size()]); return list.toArray (new MInOutLine[list.size()]);
} // getOfOrderLine } // getOfOrderLine
@ -78,7 +78,7 @@ public class MInOutLine extends X_M_InOutLine
{ {
String whereClause = "M_RMALine_ID=? " + (!Util.isEmpty(where, true) ? " AND "+where : ""); String whereClause = "M_RMALine_ID=? " + (!Util.isEmpty(where, true) ? " AND "+where : "");
List<MRMALine> list = new Query(ctx, Table_Name, whereClause, trxName) List<MRMALine> list = new Query(ctx, Table_Name, whereClause, trxName)
.setParameters(new Object[]{M_RMALine_ID}) .setParameters(M_RMALine_ID)
.list(); .list();
return list.toArray (new MInOutLine[list.size()]); return list.toArray (new MInOutLine[list.size()]);
} // getOfRMALine } // getOfRMALine

View File

@ -46,8 +46,8 @@ public class MInOutLineMA extends X_M_InOutLineMA
public static MInOutLineMA[] get (Properties ctx, int M_InOutLine_ID, String trxName) public static MInOutLineMA[] get (Properties ctx, int M_InOutLine_ID, String trxName)
{ {
Query query = MTable.get(ctx, MInOutLineMA.Table_Name) Query query = MTable.get(ctx, MInOutLineMA.Table_Name)
.createQuery(MInOutLineMA.COLUMNNAME_M_InOutLine_ID+"=?", trxName); .createQuery(I_M_InOutLineMA.COLUMNNAME_M_InOutLine_ID+"=?", trxName);
query.setParameters(new Object[]{M_InOutLine_ID}); query.setParameters(M_InOutLine_ID);
List<MInOutLineMA> list = query.list(); List<MInOutLineMA> list = query.list();
MInOutLineMA[] retValue = new MInOutLineMA[list.size ()]; MInOutLineMA[] retValue = new MInOutLineMA[list.size ()];
list.toArray (retValue); list.toArray (retValue);

View File

@ -48,8 +48,7 @@ public class MInventory extends X_M_Inventory implements DocAction
/** /**
* *
*/ */
private static final long serialVersionUID = 910998472569265447L; private static final long serialVersionUID = -7137974064086172763L;
/** /**
* Get Inventory from Cache * Get Inventory from Cache
@ -145,8 +144,8 @@ public class MInventory extends X_M_Inventory implements DocAction
return m_lines; return m_lines;
} }
// //
List<MInventoryLine> list = new Query(getCtx(), MInventoryLine.Table_Name, "M_Inventory_ID=?", get_TrxName()) List<MInventoryLine> list = new Query(getCtx(), I_M_InventoryLine.Table_Name, "M_Inventory_ID=?", get_TrxName())
.setParameters(new Object[]{get_ID()}) .setParameters(get_ID())
.setOrderBy(MInventoryLine.COLUMNNAME_Line) .setOrderBy(MInventoryLine.COLUMNNAME_Line)
.list(); .list();
m_lines = list.toArray(new MInventoryLine[list.size()]); m_lines = list.toArray(new MInventoryLine[list.size()]);

View File

@ -39,8 +39,7 @@ public class MInventoryLine extends X_M_InventoryLine
/** /**
* *
*/ */
private static final long serialVersionUID = 1336000922103246463L; private static final long serialVersionUID = 5649152656460089476L;
/** /**
* Get Inventory Line with parameters * Get Inventory Line with parameters
@ -55,8 +54,8 @@ public class MInventoryLine extends X_M_InventoryLine
{ {
final String whereClause = "M_Inventory_ID=? AND M_Locator_ID=?" final String whereClause = "M_Inventory_ID=? AND M_Locator_ID=?"
+" AND M_Product_ID=? AND M_AttributeSetInstance_ID=?"; +" AND M_Product_ID=? AND M_AttributeSetInstance_ID=?";
return new Query(inventory.getCtx(), MInventoryLine.Table_Name, whereClause, inventory.get_TrxName()) return new Query(inventory.getCtx(), I_M_InventoryLine.Table_Name, whereClause, inventory.get_TrxName())
.setParameters(new Object[]{inventory.get_ID(), M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID}) .setParameters(inventory.get_ID(), M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID)
.firstOnly(); .firstOnly();
} // get } // get

View File

@ -74,7 +74,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
public static MInvoice[] getOfBPartner (Properties ctx, int C_BPartner_ID, String trxName) public static MInvoice[] getOfBPartner (Properties ctx, int C_BPartner_ID, String trxName)
{ {
List<MInvoice> list = new Query(ctx, Table_Name, COLUMNNAME_C_BPartner_ID+"=?", trxName) List<MInvoice> list = new Query(ctx, Table_Name, COLUMNNAME_C_BPartner_ID+"=?", trxName)
.setParameters(new Object[]{C_BPartner_ID}) .setParameters(C_BPartner_ID)
.list(); .list();
return list.toArray(new MInvoice[list.size()]); return list.toArray(new MInvoice[list.size()]);
} // getOfBPartner } // getOfBPartner
@ -630,9 +630,9 @@ public class MInvoice extends X_C_Invoice implements DocAction
String whereClauseFinal = "C_Invoice_ID=? "; String whereClauseFinal = "C_Invoice_ID=? ";
if (whereClause != null) if (whereClause != null)
whereClauseFinal += whereClause; whereClauseFinal += whereClause;
List<MInvoiceLine> list = new Query(getCtx(), MInvoiceLine.Table_Name, whereClauseFinal, get_TrxName()) List<MInvoiceLine> list = new Query(getCtx(), I_C_InvoiceLine.Table_Name, whereClauseFinal, get_TrxName())
.setParameters(new Object[]{getC_Invoice_ID()}) .setParameters(getC_Invoice_ID())
.setOrderBy(MInvoiceLine.COLUMNNAME_Line) .setOrderBy(I_C_InvoiceLine.COLUMNNAME_Line)
.list(); .list();
return list.toArray(new MInvoiceLine[list.size()]); return list.toArray(new MInvoiceLine[list.size()]);
} // getLines } // getLines
@ -784,8 +784,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
return m_taxes; return m_taxes;
final String whereClause = MInvoiceTax.COLUMNNAME_C_Invoice_ID+"=?"; final String whereClause = MInvoiceTax.COLUMNNAME_C_Invoice_ID+"=?";
List<MInvoiceTax> list = new Query(getCtx(), MInvoiceTax.Table_Name, whereClause, get_TrxName()) List<MInvoiceTax> list = new Query(getCtx(), I_C_InvoiceTax.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{get_ID()}) .setParameters(get_ID())
.list(); .list();
m_taxes = list.toArray(new MInvoiceTax[list.size()]); m_taxes = list.toArray(new MInvoiceTax[list.size()]);
return m_taxes; return m_taxes;
@ -1681,8 +1681,12 @@ public class MInvoice extends X_C_Invoice implements DocAction
m_processMsg = "Could not create PO Matching"; m_processMsg = "Could not create PO Matching";
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
} }
else else {
matchPO++; matchPO++;
if (MClient.isClientAccountingImmediate()) {
String ignoreError = DocumentEngine.postImmediate(po.getCtx(), po.getAD_Client_ID(), po.get_Table_ID(), po.get_ID(), true, po.get_TrxName());
}
}
} }
} }
@ -1720,8 +1724,12 @@ public class MInvoice extends X_C_Invoice implements DocAction
m_processMsg = CLogger.retrieveErrorString("Could not create Invoice Matching"); m_processMsg = CLogger.retrieveErrorString("Could not create Invoice Matching");
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
} }
else else {
matchInv++; matchInv++;
if (MClient.isClientAccountingImmediate()) {
String ignoreError = DocumentEngine.postImmediate(inv.getCtx(), inv.getAD_Client_ID(), inv.get_Table_ID(), inv.get_ID(), true, inv.get_TrxName());
}
}
} }
} // for all lines } // for all lines
if (matchInv > 0) if (matchInv > 0)

View File

@ -74,7 +74,7 @@ public class MInvoiceTax extends X_C_InvoiceTax
} }
retValue = new Query(line.getCtx(), Table_Name, "C_Invoice_ID=? AND C_Tax_ID=?", trxName) retValue = new Query(line.getCtx(), Table_Name, "C_Invoice_ID=? AND C_Tax_ID=?", trxName)
.setParameters(new Object[]{line.getC_Invoice_ID(), C_Tax_ID}) .setParameters(line.getC_Invoice_ID(), C_Tax_ID)
.firstOnly(); .firstOnly();
if (retValue != null) if (retValue != null)
{ {

View File

@ -215,9 +215,9 @@ public class MJournal extends X_GL_Journal implements DocAction
public MJournalLine[] getLines (boolean requery) public MJournalLine[] getLines (boolean requery)
{ {
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String whereClause = "GL_Journal_ID=?"; final String whereClause = "GL_Journal_ID=?";
List <MJournalLine> list = new Query(getCtx(), MJournalLine.Table_Name, whereClause.toString(), null) List <MJournalLine> list = new Query(getCtx(), I_GL_JournalLine.Table_Name, whereClause, null)
.setParameters(new Object[]{getGL_Journal_ID()}) .setParameters(getGL_Journal_ID())
.setOrderBy("Line") .setOrderBy("Line")
.list(); .list();
// //

View File

@ -474,16 +474,13 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction
; ;
else else
{ {
String status = journal.completeIt(); journal.processIt(DocAction.ACTION_Complete);
if (!DocAction.STATUS_Completed.equals(status)) journal.saveEx();
if (!DocAction.STATUS_Completed.equals(journal.getDocStatus()))
{ {
journal.setDocStatus(status);
journal.save();
m_processMsg = journal.getProcessMsg(); m_processMsg = journal.getProcessMsg();
return status; return journal.getDocStatus();
} }
journal.setDocStatus(DOCSTATUS_Completed);
journal.save();
} }
// //
TotalDr = TotalDr.add(journal.getTotalDr()); TotalDr = TotalDr.add(journal.getTotalDr());

View File

@ -70,7 +70,7 @@ public class MLanguage extends X_AD_Language
public static MLanguage get (Properties ctx, String AD_Language) public static MLanguage get (Properties ctx, String AD_Language)
{ {
return new Query(ctx, Table_Name, COLUMNNAME_AD_Language+"=?", null) return new Query(ctx, Table_Name, COLUMNNAME_AD_Language+"=?", null)
.setParameters(new Object[]{AD_Language}) .setParameters(AD_Language)
.firstOnly(); .firstOnly();
} // get } // get
@ -83,7 +83,7 @@ public class MLanguage extends X_AD_Language
public static MLanguage[] getWithLanguage (Properties ctx, String LanguageISO) public static MLanguage[] getWithLanguage (Properties ctx, String LanguageISO)
{ {
List<MLanguage> list = new Query(ctx, Table_Name, COLUMNNAME_LanguageISO+"=?", null) List<MLanguage> list = new Query(ctx, Table_Name, COLUMNNAME_LanguageISO+"=?", null)
.setParameters(new Object[]{LanguageISO}) .setParameters(LanguageISO)
.list(); .list();
return list.toArray(new MLanguage[list.size()]); return list.toArray(new MLanguage[list.size()]);
} // get } // get
@ -95,7 +95,7 @@ public class MLanguage extends X_AD_Language
public static void maintain (Properties ctx) public static void maintain (Properties ctx)
{ {
List<MLanguage> list = new Query(ctx, Table_Name, "IsSystemLanguage=? AND IsBaseLanguage=?", null) List<MLanguage> list = new Query(ctx, Table_Name, "IsSystemLanguage=? AND IsBaseLanguage=?", null)
.setParameters(new Object[]{true, false}) .setParameters(true, false)
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.list(); .list();
for (MLanguage language : list) { for (MLanguage language : list) {
@ -138,7 +138,6 @@ public class MLanguage extends X_AD_Language
* @param LanguageISO language code * @param LanguageISO language code
* @param trxName transaction * @param trxName transaction
*/ */
@SuppressWarnings("unused")
private MLanguage (Properties ctx, String AD_Language, String Name, private MLanguage (Properties ctx, String AD_Language, String Name,
String CountryCode, String LanguageISO, String trxName) String CountryCode, String LanguageISO, String trxName)
{ {

View File

@ -54,9 +54,9 @@ public class MLot extends X_M_Lot
public static MLot[] getProductLots (Properties ctx, int M_Product_ID, String trxName) public static MLot[] getProductLots (Properties ctx, int M_Product_ID, String trxName)
{ {
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String whereClause = "M_Product_ID=?"; final String whereClause = "M_Product_ID=?";
List <MLot> list = new Query(ctx, MLot.Table_Name, whereClause, trxName) List <MLot> list = new Query(ctx, I_M_Lot.Table_Name, whereClause, trxName)
.setParameters(new Object[]{M_Product_ID}) .setParameters(M_Product_ID)
.list(); .list();
// //
MLot[] retValue = new MLot[list.size()]; MLot[] retValue = new MLot[list.size()];
@ -70,32 +70,15 @@ public class MLot extends X_M_Lot
* @param M_Product_ID product * @param M_Product_ID product
* @param lot * @param lot
* @param trxName transaction * @param trxName transaction
* @return Array of Lots for Product * @return Last Lot for Product
*/ */
public static MLot getProductLot (Properties ctx, int M_Product_ID, String lot, String trxName) public static MLot getProductLot (Properties ctx, int M_Product_ID, String lot, String trxName)
{ {
String sql = "SELECT * FROM M_Lot WHERE M_Product_ID=? AND Name=?"; final String whereClause = "M_Product_ID=? AND Name=?";
MLot retValue = null; MLot retValue = new Query(ctx, I_M_Lot.Table_Name, whereClause, trxName)
PreparedStatement pstmt = null; .setParameters(M_Product_ID, lot)
ResultSet rs = null; .setOrderBy(I_M_Lot.COLUMNNAME_M_Lot_ID + " DESC")
try .first();
{
pstmt = DB.prepareStatement (sql, trxName);
pstmt.setInt (1, M_Product_ID);
pstmt.setString(2, lot);
rs = pstmt.executeQuery ();
while (rs.next ())
retValue = new MLot (ctx, rs, trxName);
}
catch (SQLException ex)
{
s_log.log(Level.SEVERE, sql, ex);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
return retValue; return retValue;
} // getProductLot } // getProductLot

View File

@ -66,8 +66,8 @@ public class MMatchInv extends X_M_MatchInv
return new MMatchInv[]{}; return new MMatchInv[]{};
// //
final String whereClause = "M_InOutLine_ID=? AND C_InvoiceLine_ID=?"; final String whereClause = "M_InOutLine_ID=? AND C_InvoiceLine_ID=?";
List<MMatchInv> list = new Query(ctx, MMatchInv.Table_Name, whereClause, trxName) List<MMatchInv> list = new Query(ctx, I_M_MatchInv.Table_Name, whereClause, trxName)
.setParameters(new Object[]{M_InOutLine_ID, C_InvoiceLine_ID}) .setParameters(M_InOutLine_ID, C_InvoiceLine_ID)
.list(); .list();
return list.toArray (new MMatchInv[list.size()]); return list.toArray (new MMatchInv[list.size()]);
} // get } // get
@ -86,8 +86,8 @@ public class MMatchInv extends X_M_MatchInv
return new MMatchInv[]{}; return new MMatchInv[]{};
// //
String whereClause = "C_InvoiceLine_ID=?"; String whereClause = "C_InvoiceLine_ID=?";
List<MMatchInv> list = new Query(ctx, MMatchInv.Table_Name, whereClause, trxName) List<MMatchInv> list = new Query(ctx, I_M_MatchInv.Table_Name, whereClause, trxName)
.setParameters(new Object[]{C_InvoiceLine_ID}) .setParameters(C_InvoiceLine_ID)
.list(); .list();
return list.toArray (new MMatchInv[list.size()]); return list.toArray (new MMatchInv[list.size()]);
} // getInvoiceLine } // getInvoiceLine
@ -107,8 +107,8 @@ public class MMatchInv extends X_M_MatchInv
// //
final String whereClause = "EXISTS (SELECT 1 FROM M_InOutLine l" final String whereClause = "EXISTS (SELECT 1 FROM M_InOutLine l"
+" WHERE M_MatchInv.M_InOutLine_ID=l.M_InOutLine_ID AND l.M_InOut_ID=?)"; +" WHERE M_MatchInv.M_InOutLine_ID=l.M_InOutLine_ID AND l.M_InOut_ID=?)";
List<MMatchInv> list = new Query(ctx, MMatchInv.Table_Name, whereClause, trxName) List<MMatchInv> list = new Query(ctx, I_M_MatchInv.Table_Name, whereClause, trxName)
.setParameters(new Object[]{M_InOut_ID}) .setParameters(M_InOut_ID)
.list(); .list();
return list.toArray (new MMatchInv[list.size()]); return list.toArray (new MMatchInv[list.size()]);
} // getInOut } // getInOut
@ -128,8 +128,8 @@ public class MMatchInv extends X_M_MatchInv
// //
final String whereClause = " EXISTS (SELECT 1 FROM C_InvoiceLine il" final String whereClause = " EXISTS (SELECT 1 FROM C_InvoiceLine il"
+" WHERE M_MatchInv.C_InvoiceLine_ID=il.C_InvoiceLine_ID AND il.C_Invoice_ID=?)"; +" WHERE M_MatchInv.C_InvoiceLine_ID=il.C_InvoiceLine_ID AND il.C_Invoice_ID=?)";
List<MMatchInv> list = new Query(ctx, MMatchInv.Table_Name, whereClause, trxName) List<MMatchInv> list = new Query(ctx, I_M_MatchInv.Table_Name, whereClause, trxName)
.setParameters(new Object[]{C_Invoice_ID}) .setParameters(C_Invoice_ID)
.list(); .list();
return list.toArray (new MMatchInv[list.size()]); return list.toArray (new MMatchInv[list.size()]);
} // getInvoice } // getInvoice
@ -429,7 +429,11 @@ public class MMatchInv extends X_M_MatchInv
if (receipt.getMovementType().equals(MInOut.MOVEMENTTYPE_VendorReturns)) if (receipt.getMovementType().equals(MInOut.MOVEMENTTYPE_VendorReturns))
qty = getQty().negate(); qty = getQty().negate();
// //
BigDecimal price = cd.getAmt().divide(cd.getQty(),12,BigDecimal.ROUND_HALF_UP); BigDecimal price = null;
if (cd.getQty().compareTo(Env.ZERO) == 0) // avoid division by zero
price = Env.ZERO;
else
price = cd.getAmt().divide(cd.getQty(),12,BigDecimal.ROUND_HALF_UP);
cd.setDeltaAmt(price.multiply(qty.negate())); cd.setDeltaAmt(price.multiply(qty.negate()));
cd.setDeltaQty(qty.negate()); cd.setDeltaQty(qty.negate());
cd.setProcessed(false); cd.setProcessed(false);
@ -470,8 +474,8 @@ public class MMatchInv extends X_M_MatchInv
} }
// //
final String whereClause = MMatchInv.COLUMNNAME_M_InOutLine_ID+"=?"; final String whereClause = MMatchInv.COLUMNNAME_M_InOutLine_ID+"=?";
List<MMatchInv> list = new Query(ctx, MMatchInv.Table_Name, whereClause, trxName) List<MMatchInv> list = new Query(ctx, I_M_MatchInv.Table_Name, whereClause, trxName)
.setParameters(new Object[]{M_InOutLine_ID}) .setParameters(M_InOutLine_ID)
.list(); .list();
return list.toArray (new MMatchInv[list.size()]); return list.toArray (new MMatchInv[list.size()]);
} // getInOutLine } // getInOutLine

View File

@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.report.MReportTree;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;

View File

@ -102,8 +102,8 @@ public class MMovement extends X_M_Movement implements DocAction
} }
// //
final String whereClause = "M_Movement_ID=?"; final String whereClause = "M_Movement_ID=?";
List<MMovement> list = new Query(getCtx(), MMovementLine.Table_Name, whereClause, get_TrxName()) List<MMovementLine> list = new Query(getCtx(), I_M_MovementLine.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{getM_Movement_ID()}) .setParameters(getM_Movement_ID())
.setOrderBy(MMovementLine.COLUMNNAME_Line) .setOrderBy(MMovementLine.COLUMNNAME_Line)
.list(); .list();
m_lines = new MMovementLine[list.size ()]; m_lines = new MMovementLine[list.size ()];
@ -121,8 +121,8 @@ public class MMovement extends X_M_Movement implements DocAction
if (m_confirms != null && !requery) if (m_confirms != null && !requery)
return m_confirms; return m_confirms;
List<MMovementConfirm> list = new Query(getCtx(), MMovementConfirm.Table_Name, "M_Movement_ID=?", get_TrxName()) List<MMovementConfirm> list = new Query(getCtx(), I_M_MovementConfirm.Table_Name, "M_Movement_ID=?", get_TrxName())
.setParameters(new Object[]{get_ID()}) .setParameters(get_ID())
.list(); .list();
m_confirms = list.toArray(new MMovementConfirm[list.size()]); m_confirms = list.toArray(new MMovementConfirm[list.size()]);
return m_confirms; return m_confirms;

View File

@ -335,7 +335,7 @@ public class MMovementLine extends X_M_MovementLine
whereClause += " AND (" + where + ")"; whereClause += " AND (" + where + ")";
// //
List<MMovementLine> list = new Query(ctx, Table_Name, whereClause, trxName) List<MMovementLine> list = new Query(ctx, Table_Name, whereClause, trxName)
.setParameters(new Object[]{DD_OrderLine_ID}) .setParameters(DD_OrderLine_ID)
.list(); .list();
return list.toArray(new MMovementLine[list.size()]); return list.toArray(new MMovementLine[list.size()]);
} // getOfOrderLine } // getOfOrderLine

View File

@ -639,14 +639,14 @@ public class MOrder extends X_C_Order implements DocAction
public MOrderLine[] getLines (String whereClause, String orderClause) public MOrderLine[] getLines (String whereClause, String orderClause)
{ {
//red1 - using new Query class from Teo / Victor's MDDOrder.java implementation //red1 - using new Query class from Teo / Victor's MDDOrder.java implementation
StringBuffer whereClauseFinal = new StringBuffer(MOrderLine.COLUMNNAME_C_Order_ID+"=?"); StringBuffer whereClauseFinal = new StringBuffer(MOrderLine.COLUMNNAME_C_Order_ID+"=? ");
if (!Util.isEmpty(whereClause, true)) if (!Util.isEmpty(whereClause, true))
whereClauseFinal.append(whereClause); whereClauseFinal.append(whereClause);
if (orderClause.length() == 0) if (orderClause.length() == 0)
orderClause = MOrderLine.COLUMNNAME_Line; orderClause = MOrderLine.COLUMNNAME_Line;
// //
List<MOrderLine> list = new Query(getCtx(), MOrderLine.Table_Name, whereClauseFinal.toString(), get_TrxName()) List<MOrderLine> list = new Query(getCtx(), I_C_OrderLine.Table_Name, whereClauseFinal.toString(), get_TrxName())
.setParameters(new Object[]{get_ID()}) .setParameters(get_ID())
.setOrderBy(orderClause) .setOrderBy(orderClause)
.list(); .list();
for (MOrderLine ol : list) { for (MOrderLine ol : list) {
@ -731,8 +731,8 @@ public class MOrder extends X_C_Order implements DocAction
if (m_taxes != null && !requery) if (m_taxes != null && !requery)
return m_taxes; return m_taxes;
// //
List<MOrderTax> list = new Query(getCtx(), MOrderTax.Table_Name, "C_Order_ID=?", get_TrxName()) List<MOrderTax> list = new Query(getCtx(), I_C_OrderTax.Table_Name, "C_Order_ID=?", get_TrxName())
.setParameters(new Object[]{get_ID()}) .setParameters(get_ID())
.list(); .list();
m_taxes = list.toArray(new MOrderTax[list.size()]); m_taxes = list.toArray(new MOrderTax[list.size()]);
return m_taxes; return m_taxes;
@ -749,8 +749,8 @@ public class MOrder extends X_C_Order implements DocAction
+" WHERE il.C_Invoice_ID=C_Invoice.C_Invoice_ID" +" WHERE il.C_Invoice_ID=C_Invoice.C_Invoice_ID"
+" AND il.C_OrderLine_ID=ol.C_OrderLine_ID" +" AND il.C_OrderLine_ID=ol.C_OrderLine_ID"
+" AND ol.C_Order_ID=?)"; +" AND ol.C_Order_ID=?)";
List<MInvoice> list = new Query(getCtx(), MInvoice.Table_Name, whereClause, get_TrxName()) List<MInvoice> list = new Query(getCtx(), I_C_Invoice.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{get_ID()}) .setParameters(get_ID())
.setOrderBy("C_Invoice_ID DESC") .setOrderBy("C_Invoice_ID DESC")
.list(); .list();
return list.toArray(new MInvoice[list.size()]); return list.toArray(new MInvoice[list.size()]);
@ -780,8 +780,8 @@ public class MOrder extends X_C_Order implements DocAction
+" WHERE iol.M_InOut_ID=M_InOut.M_InOut_ID" +" WHERE iol.M_InOut_ID=M_InOut.M_InOut_ID"
+" AND iol.C_OrderLine_ID=ol.C_OrderLine_ID" +" AND iol.C_OrderLine_ID=ol.C_OrderLine_ID"
+" AND ol.C_Order_ID=?)"; +" AND ol.C_Order_ID=?)";
List<MInvoice> list = new Query(getCtx(), MInOut.Table_Name, whereClause, get_TrxName()) List<MInvoice> list = new Query(getCtx(), I_M_InOut.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{get_ID()}) .setParameters(get_ID())
.setOrderBy("M_InOut_ID DESC") .setOrderBy("M_InOut_ID DESC")
.list(); .list();
return list.toArray(new MInOut[list.size()]); return list.toArray(new MInOut[list.size()]);
@ -1790,10 +1790,9 @@ public class MOrder extends X_C_Order implements DocAction
} }
} }
// Manually Process Shipment // Manually Process Shipment
String status = shipment.completeIt(); shipment.processIt(DocAction.ACTION_Complete);
shipment.setDocStatus(status); shipment.saveEx(get_TrxName());
shipment.save(get_TrxName()); if (!DOCSTATUS_Completed.equals(shipment.getDocStatus()))
if (!DOCSTATUS_Completed.equals(status))
{ {
m_processMsg = "@M_InOut_ID@: " + shipment.getProcessMsg(); m_processMsg = "@M_InOut_ID@: " + shipment.getProcessMsg();
return null; return null;
@ -1877,11 +1876,10 @@ public class MOrder extends X_C_Order implements DocAction
} }
} }
// Manually Process Invoice // Manually Process Invoice
String status = invoice.completeIt(); invoice.processIt(DocAction.ACTION_Complete);
invoice.setDocStatus(status); invoice.saveEx(get_TrxName());
invoice.save(get_TrxName());
setC_CashLine_ID(invoice.getC_CashLine_ID()); setC_CashLine_ID(invoice.getC_CashLine_ID());
if (!DOCSTATUS_Completed.equals(status)) if (!DOCSTATUS_Completed.equals(invoice.getDocStatus()))
{ {
m_processMsg = "@C_Invoice_ID@: " + invoice.getProcessMsg(); m_processMsg = "@C_Invoice_ID@: " + invoice.getProcessMsg();
return null; return null;

View File

@ -48,7 +48,7 @@ public class MOrg extends X_AD_Org
List<MOrg> list = new Query(po.getCtx(), Table_Name, "AD_Client_ID=?", null) List<MOrg> list = new Query(po.getCtx(), Table_Name, "AD_Client_ID=?", null)
.setOrderBy(COLUMNNAME_Value) .setOrderBy(COLUMNNAME_Value)
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.setParameters(new Object[]{po.getAD_Client_ID()}) .setParameters(po.getAD_Client_ID())
.list(); .list();
for (MOrg org : list) for (MOrg org : list)
{ {

View File

@ -52,7 +52,7 @@ public class MOrgInfo extends X_AD_OrgInfo
return retValue; return retValue;
} }
retValue = new Query(ctx, Table_Name, "AD_Org_ID=?", null) retValue = new Query(ctx, Table_Name, "AD_Org_ID=?", null)
.setParameters(new Object[]{AD_Org_ID}) .setParameters(AD_Org_ID)
.firstOnly(); .firstOnly();
if (retValue != null) if (retValue != null)
{ {

View File

@ -21,6 +21,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
@ -39,10 +40,11 @@ import org.compiere.util.Env;
*/ */
public class MPInstance extends X_AD_PInstance public class MPInstance extends X_AD_PInstance
{ {
/**
* /**
*/ *
private static final long serialVersionUID = 209806970824523840L; */
private static final long serialVersionUID = -5848424269552679604L;
/** /**
* Standard Constructor * Standard Constructor
@ -124,38 +126,12 @@ public class MPInstance extends X_AD_PInstance
{ {
if (m_parameters != null) if (m_parameters != null)
return m_parameters; return m_parameters;
ArrayList<MPInstancePara> list = new ArrayList<MPInstancePara>(); //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
// final String whereClause = "AD_PInstance_ID=?";
String sql = "SELECT * FROM AD_PInstance_Para WHERE AD_PInstance_ID=?"; List <MPInstancePara> list = new Query(getCtx(), I_AD_PInstance_Para.Table_Name, whereClause, null) // @TODO: Review implications of using transaction
PreparedStatement pstmt = null; .setParameters(getAD_PInstance_ID())
try .list();
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, getAD_PInstance_ID());
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
list.add(new MPInstancePara(getCtx(), rs, null));
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
try
{
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null;
}
// //
m_parameters = new MPInstancePara[list.size()]; m_parameters = new MPInstancePara[list.size()];
list.toArray(m_parameters); list.toArray(m_parameters);

View File

@ -64,7 +64,7 @@ public class MPOS extends X_C_POS
{ {
String whereClause = field+"=?"; String whereClause = field+"=?";
List<MPOS> list = new Query(ctx, Table_Name, whereClause, null) List<MPOS> list = new Query(ctx, Table_Name, whereClause, null)
.setParameters(new Object[]{ID}) .setParameters(ID)
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.setOrderBy(COLUMNNAME_Name) .setOrderBy(COLUMNNAME_Name)
.list(); .list();

Some files were not shown because too many files have changed in this diff Show More