Project:
View Issue Details[ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
ID | ||||||||
0035127 | ||||||||
Type | Category | Severity | Reproducibility | Date Submitted | Last Update | |||
defect | [Modules] Remittance | major | always | 2017-02-01 12:38 | 2017-02-16 09:32 | |||
Reporter | egoitz | View Status | public | |||||
Assigned To | vmromanos | |||||||
Priority | normal | Resolution | duplicate | Fixed in Version | ||||
Status | closed | Fix in branch | Fixed in SCM revision | |||||
Projection | none | ETA | none | Target Version | ||||
OS | Any | Database | Any | Java version | ||||
OS Version | Database version | Ant version | ||||||
Product Version | SCM revision | |||||||
Regression date | ||||||||
Regression introduced by commit | 45320 | |||||||
Regression level | ||||||||
Review Assigned To | vmromanos | |||||||
Regression introduced in release | ||||||||
Summary | 0035127: Performance problems adding order or invoices to a remmitance | |||||||
Description | when there are a thousands of payment ins the grid of the add order or invoices popup takes long to be loaded if you click on the show alternative check box. | |||||||
Steps To Reproduce | Open the popup on an environment with a lot of payment in pending (pending sales invoices) | |||||||
Tags | No tags attached. | |||||||
Attached Files | 35127_core.diff [^] (669 bytes) 2017-02-16 09:31 [Show Content] [Hide Content]diff --git a/src-db/database/model/tables/FIN_PAYMENT_PROP_DETAIL.xml b/src-db/database/model/tables/FIN_PAYMENT_PROP_DETAIL.xml --- a/src-db/database/model/tables/FIN_PAYMENT_PROP_DETAIL.xml +++ b/src-db/database/model/tables/FIN_PAYMENT_PROP_DETAIL.xml @@ -68,5 +68,8 @@ <foreign-key foreignTable="FIN_PAYMENT_SCHEDULEDETAIL" name="FIN_PAYMENTSCHDET_PROP_DETAIL"> <reference local="FIN_PAYMENT_SCHEDULEDETAIL_ID" foreign="FIN_PAYMENT_SCHEDULEDETAIL_ID"/> </foreign-key> + <index name="FIN_PAYMENT_PROP_DETAIL_SCDET" unique="false"> + <index-column name="FIN_PAYMENT_SCHEDULEDETAIL_ID"/> + </index> </table> </database> 35127_safe.diff [^] (1,916 bytes) 2017-02-16 09:32 [Show Content] [Hide Content] diff --git a/src/org/openbravo/module/remittance/process/REM_AddRemittance.java b/src/org/openbravo/module/remittance/process/REM_AddRemittance.java --- a/src/org/openbravo/module/remittance/process/REM_AddRemittance.java +++ b/src/org/openbravo/module/remittance/process/REM_AddRemittance.java @@ -52,7 +52,6 @@ import org.openbravo.model.financialmgmt.gl.GLItem; import org.openbravo.model.financialmgmt.payment.FIN_Payment; import org.openbravo.model.financialmgmt.payment.FIN_PaymentMethod; -import org.openbravo.model.financialmgmt.payment.FIN_PaymentPropDetail; import org.openbravo.model.financialmgmt.payment.FIN_PaymentSchedule; import org.openbravo.model.financialmgmt.payment.FIN_PaymentScheduleDetail; import org.openbravo.model.financialmgmt.payment.PaymentPriority; @@ -538,16 +537,8 @@ } // block schedule payments in other payment proposal - final OBCriteria<FIN_PaymentPropDetail> obc = OBDal.getInstance().createCriteria( - FIN_PaymentPropDetail.class); - obc.add(Restrictions.isNotNull(FIN_PaymentPropDetail.PROPERTY_FINPAYMENTSCHEDULEDETAIL)); - if (obc.list() != null && obc.list().size() > 0) { - List<FIN_PaymentScheduleDetail> aux = new ArrayList<FIN_PaymentScheduleDetail>(); - for (FIN_PaymentPropDetail ppd : obc.list()) { - aux.add(ppd.getFINPaymentScheduledetail()); - } - whereClause.append(" and psd.id not in (" + Utility.getInStrList(aux) + ")"); - } + whereClause + .append(" and not exists (select 1 from FIN_Payment_Prop_Detail propDet where propDet.fINPaymentScheduledetail.id = psd.id)"); // Transaction type filter whereClause.append(" and ("); @@ -689,6 +680,7 @@ FIN_PaymentScheduleDetail.class, whereClause.toString()); obqPSD.setParameters(parameters); + obqPSD.setMaxResult(1000); return obqPSD.list(); } finally { 35127_risky.diff [^] (46,218 bytes) 2017-02-16 09:32 [Show Content] [Hide Content] diff --git a/src/org/openbravo/module/remittance/ad_actionbutton/SelectOrdersOrInvoices.java b/src/org/openbravo/module/remittance/ad_actionbutton/SelectOrdersOrInvoices.java --- a/src/org/openbravo/module/remittance/ad_actionbutton/SelectOrdersOrInvoices.java +++ b/src/org/openbravo/module/remittance/ad_actionbutton/SelectOrdersOrInvoices.java @@ -35,7 +35,6 @@ import org.apache.commons.lang.time.DateUtils; import org.hibernate.criterion.Restrictions; import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao; -import org.openbravo.advpaymentmngt.process.FIN_AddPayment; import org.openbravo.advpaymentmngt.utility.FIN_Utility; import org.openbravo.base.exception.OBException; import org.openbravo.base.filter.RequestFilter; @@ -54,6 +53,7 @@ import org.openbravo.model.financialmgmt.payment.FinAccPaymentMethod; import org.openbravo.module.remittance.Remittance; import org.openbravo.module.remittance.RemittanceLine; +import org.openbravo.module.remittance.process.InfoPSD; import org.openbravo.module.remittance.process.REM_AddRemittance; import org.openbravo.xmlEngine.XmlDocument; @@ -177,20 +177,9 @@ "org/openbravo/module/remittance/ad_actionbutton/SelectOrdersOrInvoicesGrid") .createXmlDocument(); + OBDal.getInstance().getSession().clear(); + Remittance remittance = dao.getObject(Remittance.class, strRemittanceId); - List<FIN_PaymentScheduleDetail> selectedScheduledPaymentDetails = new ArrayList<FIN_PaymentScheduleDetail>(); - boolean firstLoad = false; - if (strSelectedPaymentDetails == null || "".equals(strSelectedPaymentDetails)) - firstLoad = true; - if (firstLoad) { - selectedScheduledPaymentDetails = REM_AddRemittance - .getSelectedPendingPaymentsFromRemittance(remittance); - strSelectedPaymentDetails = Utility.getInStrList(selectedScheduledPaymentDetails); - } else { - selectedScheduledPaymentDetails = FIN_AddPayment.getSelectedPaymentDetails(null, - strSelectedPaymentDetails); - } - Date expectedDate = remittance.getDueDate(); if (expectedDate != null) { Calendar cal = Calendar.getInstance(); @@ -198,20 +187,42 @@ cal.add(Calendar.DATE, 1); expectedDate = cal.getTime(); } + + boolean firstLoad = false; + if (_strSelectedPaymentDetails == null || "".equals(_strSelectedPaymentDetails)) + firstLoad = true; + + List<InfoPSD> selectedPaymentDetailsList; + if (firstLoad) { + selectedPaymentDetailsList = REM_AddRemittance + .getSelectedPendingPaymentsFromRemittance(remittance); + strSelectedPaymentDetails = REM_AddRemittance.getInStrList(selectedPaymentDetailsList, false); + } else { + selectedPaymentDetailsList = REM_AddRemittance + .getSelectedPaymentDetails(_strSelectedPaymentDetails); + } + + OBDal.getInstance().getSession().clear(); + + // Necessary to reload here + remittance = dao.getObject(Remittance.class, strRemittanceId); // IsReceipt: // Y: it just allows IN // N: It just allows OUT String isReceipt = strTransactionType; // filtered scheduled payments list - final List<FIN_PaymentScheduleDetail> filteredScheduledPaymentDetails = REM_AddRemittance + final List<InfoPSD> filteredScheduledPaymentDetailList = REM_AddRemittance .getFilteredScheduledPaymentDetails(remittance.getOrganization(), remittance, showAlternativeCurrency, null, expectedDate, strDocumentType, showAlternativePM ? null : remittance.getRemittanceType().getPaymentMethod(), isReceipt, strBPartnerId, - selectedScheduledPaymentDetails); + selectedPaymentDetailsList); + OBDal.getInstance().getSession().clear(); + // Necessary to reload here + remittance = dao.getObject(Remittance.class, strRemittanceId); FieldProvider[] data = REM_AddRemittance.getShownScheduledPaymentDetails(vars, - strSelectedPaymentDetails, selectedScheduledPaymentDetails, - filteredScheduledPaymentDetails, firstLoad, remittance, strDocumentType); + strSelectedPaymentDetails, selectedPaymentDetailsList, filteredScheduledPaymentDetailList, + firstLoad, remittance, strDocumentType); if (!"B".equals(strDocumentType)) { data = groupPerDocumentType(data, strDocumentType); } diff --git a/src/org/openbravo/module/remittance/process/InfoPSD.java b/src/org/openbravo/module/remittance/process/InfoPSD.java new file mode 100644 --- /dev/null +++ b/src/org/openbravo/module/remittance/process/InfoPSD.java @@ -0,0 +1,314 @@ +package org.openbravo.module.remittance.process; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.openbravo.base.session.OBPropertiesProvider; +import org.openbravo.dal.core.OBContext; +import org.openbravo.dal.service.OBDal; +import org.openbravo.model.common.invoice.Invoice; +import org.openbravo.model.common.order.Order; +import org.openbravo.model.financialmgmt.payment.FIN_PaymentSchedule; +import org.openbravo.model.financialmgmt.payment.FIN_PaymentScheduleDetail; + +public class InfoPSD { + + private String finScheduledPaymentDetailId; + private String orderPaymentScheduleId; + private String orderNr; + private String invoiceNr; + private String orderNrTrunc; + private String invoiceNrTrunc; + private String invoicePaymentScheduleId; + private String expectedDate; + private String dueDate; + private BigDecimal invoicedAmount; + private BigDecimal expectedAmount; + private String businessPartnerName; + private String businessPartnerNameTrunc; + private String currencyName; + private String currencyNameTrunc; + private String paymentMethodName; + private String paymentMethodNameTrunc; + private String gridLineColor; + private BigDecimal outstandingAmount; + private SimpleDateFormat dateFormater; + + public InfoPSD(String finScheduledPaymentDetailId, String orderPaymentScheduleId, String orderNr, + String invoiceNr, String invoicePaymentScheduleId, Date expectedDate, Date dueDate, + BigDecimal invoicedAmount, BigDecimal expectedAmount, String businessPartnerName, + String currencyName, String paymentMethodName, String gridLineColor, + BigDecimal outstandingAmount) { + String dateFormat = OBPropertiesProvider.getInstance().getOpenbravoProperties() + .getProperty("dateFormat.java"); + dateFormater = new SimpleDateFormat(dateFormat); + + this.finScheduledPaymentDetailId = finScheduledPaymentDetailId; + this.orderPaymentScheduleId = orderPaymentScheduleId; + this.orderNr = orderNr; + this.invoiceNr = invoiceNr; + this.orderNrTrunc = orderNr; + this.invoiceNrTrunc = invoiceNr; + this.invoicePaymentScheduleId = invoicePaymentScheduleId; + this.expectedDate = expectedDate == null ? "" : dateFormater.format(expectedDate); + this.dueDate = dueDate == null ? "" : dateFormater.format(dueDate); + this.invoicedAmount = invoicedAmount; + this.expectedAmount = expectedAmount; + this.businessPartnerName = businessPartnerName; + this.businessPartnerNameTrunc = (businessPartnerName.length() > 18) ? businessPartnerName + .substring(0, 15).concat("...").toString() : businessPartnerName; + this.currencyName = currencyName; + this.currencyNameTrunc = (currencyName.length() > 18) ? currencyName.substring(0, 15) + .concat("...").toString() : currencyName; + this.paymentMethodName = paymentMethodName; + this.paymentMethodNameTrunc = (paymentMethodName.length() > 18) ? paymentMethodName + .substring(0, 15).concat("...").toString() : paymentMethodName; + this.gridLineColor = gridLineColor; + this.outstandingAmount = outstandingAmount; + } + + public InfoPSD(String finScheduledPaymentDetailId, boolean isDummy) { + this.finScheduledPaymentDetailId = finScheduledPaymentDetailId; + + if (!isDummy) { + try { + OBContext.setAdminMode(true); + + final FIN_PaymentScheduleDetail psd = OBDal.getInstance().get( + FIN_PaymentScheduleDetail.class, finScheduledPaymentDetailId); + + final FIN_PaymentSchedule invPS = psd.getInvoicePaymentSchedule(); + try { + this.invoicePaymentScheduleId = invPS.getId(); + } catch (Exception e) { + this.invoicePaymentScheduleId = null; + } + Invoice invoice = null; + try { + invoice = invPS.getInvoice(); + this.invoiceNr = invoice.getDocumentNo(); + } catch (Exception e) { + this.invoiceNr = null; + } + this.invoiceNrTrunc = invoiceNr; + + try { + this.expectedDate = invPS.getExpectedDate() == null ? "" : dateFormater.format(invPS + .getExpectedDate()); + this.dueDate = invPS.getDueDate() == null ? "" : dateFormater.format(invPS.getDueDate()); + this.invoicedAmount = invoice.getGrandTotalAmount(); + this.expectedAmount = invPS.getAmount(); + this.businessPartnerName = invoice.getBusinessPartner().getName(); + this.currencyName = invoice.getCurrency().getIdentifier(); + this.paymentMethodName = invoice.getPaymentMethod().getName(); + this.gridLineColor = invPS.getFINPaymentPriority().getColor(); + } catch (Exception e) { + this.expectedDate = null; + this.dueDate = null; + this.invoicedAmount = null; + this.expectedAmount = null; + this.businessPartnerName = null; + this.currencyName = null; + this.paymentMethodName = null; + this.gridLineColor = null; + } + + final FIN_PaymentSchedule ordPS = psd.getOrderPaymentSchedule(); + try { + this.orderPaymentScheduleId = ordPS.getId(); + } catch (Exception e) { + this.orderPaymentScheduleId = null; + } + Order order = null; + try { + order = ordPS.getOrder(); + this.orderNr = order.getDocumentNo(); + } catch (Exception e) { + this.orderNr = null; + } + this.orderNrTrunc = orderNr; + + if (this.expectedDate == null) { + try { + this.expectedDate = dateFormater.format(ordPS.getExpectedDate()); + } catch (Exception e) { + this.expectedDate = null; + } + } + + if (this.dueDate == null) { + try { + this.dueDate = dateFormater.format(ordPS.getDueDate()); + } catch (Exception e) { + this.dueDate = null; + } + } + + if (this.invoicedAmount == null) { + try { + this.invoicedAmount = order.getGrandTotalAmount(); + } catch (Exception e) { + this.invoicedAmount = null; + } + } + + if (this.expectedAmount == null) { + try { + this.expectedAmount = psd.getAmount(); + } catch (Exception e) { + this.expectedAmount = null; + } + } + + if (this.businessPartnerName == null) { + try { + this.businessPartnerName = order.getBusinessPartner().getName(); + } catch (Exception e) { + this.businessPartnerName = null; + } + } + this.businessPartnerNameTrunc = (businessPartnerName != null && businessPartnerName + .length() > 18) ? businessPartnerName.substring(0, 15).concat("...").toString() + : businessPartnerName; + + if (this.currencyName == null) { + try { + this.currencyName = order.getCurrency().getIdentifier(); + } catch (Exception e) { + this.currencyName = null; + } + } + this.currencyNameTrunc = (currencyName != null && currencyName.length() > 18) ? currencyName + .substring(0, 15).concat("...").toString() + : currencyName; + + if (this.paymentMethodName == null) { + try { + this.paymentMethodName = order.getPaymentMethod().getName(); + } catch (Exception e) { + this.paymentMethodName = null; + } + } + this.paymentMethodNameTrunc = (paymentMethodName != null && paymentMethodName.length() > 18) ? paymentMethodName + .substring(0, 15).concat("...").toString() + : paymentMethodName; + + if (this.gridLineColor == null) { + try { + this.gridLineColor = ordPS.getFINPaymentPriority().getColor(); + } catch (Exception e) { + this.gridLineColor = null; + } + } + + this.outstandingAmount = psd.getAmount(); + } finally { + OBContext.restorePreviousMode(); + } + } + } + + public String getFinScheduledPaymentDetailId() { + return finScheduledPaymentDetailId; + } + + public String getOrderPaymentScheduleId() { + return orderPaymentScheduleId; + } + + public String getOrderNr() { + return orderNr; + } + + public String getInvoiceNr() { + return invoiceNr; + } + + public String getOrderNrTrunc() { + return orderNrTrunc; + } + + public String getInvoiceNrTrunc() { + return invoiceNrTrunc; + } + + public String getInvoicePaymentScheduleId() { + return invoicePaymentScheduleId; + } + + public String getExpectedDate() { + return expectedDate; + } + + public String getDueDate() { + return dueDate; + } + + public BigDecimal getInvoicedAmount() { + return invoicedAmount; + } + + public BigDecimal getExpectedAmount() { + return expectedAmount; + } + + public String getBusinessPartnerName() { + return businessPartnerName; + } + + public String getCurrencyName() { + return currencyName; + } + + public String getPaymentMethodName() { + return paymentMethodName; + } + + public String getGridLineColor() { + return gridLineColor; + } + + public BigDecimal getOutstandingAmount() { + return outstandingAmount; + } + + public String getBusinessPartnerNameTrunc() { + return businessPartnerNameTrunc; + } + + public String getCurrencyNameTrunc() { + return currencyNameTrunc; + } + + public String getPaymentMethodNameTrunc() { + return paymentMethodNameTrunc; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((finScheduledPaymentDetailId == null) ? 0 : finScheduledPaymentDetailId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + InfoPSD other = (InfoPSD) obj; + if (finScheduledPaymentDetailId == null) { + if (other.finScheduledPaymentDetailId != null) + return false; + } else if (!finScheduledPaymentDetailId.equals(other.finScheduledPaymentDetailId)) + return false; + return true; + } + +} diff --git a/src/org/openbravo/module/remittance/process/REM_AddRemittance.java b/src/org/openbravo/module/remittance/process/REM_AddRemittance.java --- a/src/org/openbravo/module/remittance/process/REM_AddRemittance.java +++ b/src/org/openbravo/module/remittance/process/REM_AddRemittance.java @@ -19,40 +19,38 @@ package org.openbravo.module.remittance.process; import java.math.BigDecimal; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.StringTokenizer; import javax.servlet.ServletException; +import org.hibernate.Query; +import org.hibernate.Session; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.openbravo.advpaymentmngt.utility.FIN_Utility; import org.openbravo.base.exception.OBException; import org.openbravo.base.provider.OBProvider; import org.openbravo.base.secureApp.VariablesSecureApp; -import org.openbravo.base.session.OBPropertiesProvider; import org.openbravo.dal.core.OBContext; import org.openbravo.dal.service.OBCriteria; import org.openbravo.dal.service.OBDal; -import org.openbravo.dal.service.OBQuery; import org.openbravo.data.FieldProvider; import org.openbravo.erpCommon.utility.FieldProviderFactory; import org.openbravo.erpCommon.utility.Utility; import org.openbravo.model.common.businesspartner.BusinessPartner; -import org.openbravo.model.common.currency.Currency; import org.openbravo.model.common.enterprise.DocumentType; import org.openbravo.model.common.enterprise.Organization; import org.openbravo.model.common.invoice.Invoice; import org.openbravo.model.financialmgmt.gl.GLItem; import org.openbravo.model.financialmgmt.payment.FIN_Payment; import org.openbravo.model.financialmgmt.payment.FIN_PaymentMethod; -import org.openbravo.model.financialmgmt.payment.FIN_PaymentPropDetail; import org.openbravo.model.financialmgmt.payment.FIN_PaymentSchedule; import org.openbravo.model.financialmgmt.payment.FIN_PaymentScheduleDetail; import org.openbravo.model.financialmgmt.payment.PaymentPriority; @@ -162,12 +160,12 @@ * * @param remittance */ - public static List<FIN_PaymentScheduleDetail> getSelectedPendingPaymentsFromRemittance( - Remittance remittance) { - List<FIN_PaymentScheduleDetail> existingPaymentScheduleDetail = new ArrayList<FIN_PaymentScheduleDetail>(); + public static List<InfoPSD> getSelectedPendingPaymentsFromRemittance(Remittance remittance) { + List<InfoPSD> existingPaymentScheduleDetail = new ArrayList<InfoPSD>(); for (RemittanceLine line : remittance.getREMRemittanceLineList()) { if (line.getPaymentScheduleDetail() != null) { - existingPaymentScheduleDetail.add(line.getPaymentScheduleDetail()); + existingPaymentScheduleDetail.add(new InfoPSD(line.getPaymentScheduleDetail().getId(), + false)); } } @@ -175,6 +173,38 @@ } /** + * It adds to the scheduledPaymentDetails List the FIN_PaymentScheduleDetails given in the + * strSelectedPaymentDetailsIds comma separated String of Id's that are not yet included on it. + * + * @param scheduledPaymentDetails + * List of FIN_PaymentScheduleDetail. + * @param strSelectedPaymentDetailsIds + * String of comma separated id's that needs to be included in the List if they are not + * present. + * @return returns a List of FIN_PaymentScheduleDetail including all the Payment Schedule Details. + */ + public static List<InfoPSD> getSelectedPaymentDetails(String strSelectedPaymentDetailsIds) { + final List<InfoPSD> selectedScheduledPaymentDetails = new ArrayList<InfoPSD>(); + // FIXME: added to access the FIN_PaymentSchedule and FIN_PaymentScheduleDetail tables to be + // removed when new security implementation is done + OBContext.setAdminMode(); + try { + // selected scheduled payments list + final List<FIN_PaymentScheduleDetail> tempSelectedScheduledPaymentDetails = FIN_Utility + .getOBObjectList(FIN_PaymentScheduleDetail.class, strSelectedPaymentDetailsIds); + for (FIN_PaymentScheduleDetail tempPaymentScheduleDetail : tempSelectedScheduledPaymentDetails) { + if (!selectedScheduledPaymentDetails.contains(tempPaymentScheduleDetail)) + selectedScheduledPaymentDetails + .add(new InfoPSD(tempPaymentScheduleDetail.getId(), false)); + + } + } finally { + OBContext.restorePreviousMode(); + } + return selectedScheduledPaymentDetails; + } + + /** * Builds a FieldProvider with a set of Payment Schedule Details based on the * selectedScheduledPaymentDetails and filteredScheduledPaymentDetails Lists. When the firstLoad * parameter is true the "paymentAmount" field is loaded from the corresponding Remittance Line if @@ -194,237 +224,148 @@ * @return a FieldProvider object with all the given FIN_PaymentScheduleDetails. */ public static FieldProvider[] getShownScheduledPaymentDetails(VariablesSecureApp vars, - String _strSelectedRecords, List<FIN_PaymentScheduleDetail> selectedScheduledPaymentDetails, - List<FIN_PaymentScheduleDetail> filteredScheduledPaymentDetails, boolean firstLoad, - Remittance remittance, String strDocumentType) throws ServletException { + String _strSelectedRecords, List<InfoPSD> strSelectedPaymentDetails, + List<InfoPSD> filteredScheduledPaymentDetailsList, boolean firstLoad, Remittance _remittance, + String strDocumentType) throws ServletException { + + final String remittanceId = _remittance.getId(); + Remittance remittance = _remittance; + // Remove "(" ")" String strSelectedRecords = _strSelectedRecords; strSelectedRecords = strSelectedRecords.replace("(", ""); strSelectedRecords = strSelectedRecords.replace(")", ""); - final List<FIN_PaymentScheduleDetail> shownScheduledPaymentDetails = new ArrayList<FIN_PaymentScheduleDetail>(); - shownScheduledPaymentDetails.addAll(selectedScheduledPaymentDetails); - shownScheduledPaymentDetails.addAll(filteredScheduledPaymentDetails); - FIN_PaymentScheduleDetail[] FIN_PaymentScheduleDetails = new FIN_PaymentScheduleDetail[0]; - FIN_PaymentScheduleDetails = shownScheduledPaymentDetails.toArray(FIN_PaymentScheduleDetails); - // FieldProvider[] data = FieldProviderFactory.getFieldProviderArray(FIN_PaymentSchedules); - // FieldProvider[] data = new FieldProviderFactory[selectedScheduledPayments.size()]; - FieldProvider[] data = FieldProviderFactory.getFieldProviderArray(shownScheduledPaymentDetails); - String dateFormat = OBPropertiesProvider.getInstance().getOpenbravoProperties() - .getProperty("dateFormat.java"); - SimpleDateFormat dateFormater = new SimpleDateFormat(dateFormat); - // FIXME: added to access the FIN_PaymentSchedule and FIN_PaymentScheduleDetail tables to be - // removed when new security implementation is done + final List<InfoPSD> shownScheduledPaymentDetails = new ArrayList<InfoPSD>(); + shownScheduledPaymentDetails.addAll(strSelectedPaymentDetails); + shownScheduledPaymentDetails.addAll(filteredScheduledPaymentDetailsList); + + StringTokenizer records = new StringTokenizer(strSelectedRecords, "'"); + Set<String> recordSet = new LinkedHashSet<String>(); + while (records.hasMoreTokens()) { + recordSet.add(records.nextToken()); + } + + List<FieldProvider> dataList = new ArrayList<FieldProvider>(); OBContext.setAdminMode(); try { - for (int i = 0; i < data.length; i++) { - String selectedId = (selectedScheduledPaymentDetails - .contains(FIN_PaymentScheduleDetails[i])) ? FIN_PaymentScheduleDetails[i].getId() : ""; + int i = 0; + for (final InfoPSD infoPSD : shownScheduledPaymentDetails) { + String fin_PaymentScheduleDetail = infoPSD.getFinScheduledPaymentDetailId(); + + FieldProvider data = new FieldProviderFactory(fin_PaymentScheduleDetail); + + String selectedId = (strSelectedPaymentDetails.contains(new InfoPSD( + fin_PaymentScheduleDetail, true))) ? fin_PaymentScheduleDetail : ""; // If selectedId belongs to a grouping selection calculate whether it should be selected or // not if (!"".equals(selectedId)) { - StringTokenizer records = new StringTokenizer(strSelectedRecords, "'"); - Set<String> recordSet = new LinkedHashSet<String>(); - while (records.hasMoreTokens()) { - recordSet.add(records.nextToken()); - } if (recordSet.contains(selectedId)) { - FieldProviderFactory.setField(data[i], "finSelectedPaymentDetailId", selectedId); + FieldProviderFactory.setField(data, "finSelectedPaymentDetailId", selectedId); } else { - String selectedRecord = FIN_PaymentScheduleDetails[i].getId(); + String selectedRecord = fin_PaymentScheduleDetail; // Find record which contains psdId Set<String> psdIdSet = new LinkedHashSet<String>(); for (String record : recordSet) { if (record.contains(selectedId)) { selectedRecord = record; - StringTokenizer st = new StringTokenizer(record, ","); - while (st.hasMoreTokens()) { - psdIdSet.add(st.nextToken()); + StringTokenizer st2 = new StringTokenizer(record, ","); + while (st2.hasMoreTokens()) { + psdIdSet.add(st2.nextToken()); } } } String psdAmount = vars.getNumericParameter("inpPaymentAmount" + selectedRecord, ""); if ("".equals(psdAmount)) { - psdAmount = getRemittanceLineAmount(FIN_PaymentScheduleDetails[i], remittance); + psdAmount = getRemittanceLineAmount(infoPSD.getFinScheduledPaymentDetailId(), + remittance); } if (!"".equals(psdAmount)) { HashMap<String, BigDecimal> idsAmounts = calculateAmounts(new BigDecimal(psdAmount), psdIdSet); if (idsAmounts.get(selectedId).compareTo(BigDecimal.ZERO) != 0) { - FieldProviderFactory.setField(data[i], "finSelectedPaymentDetailId", selectedId); - FieldProviderFactory.setField(data[i], "paymentAmount", idsAmounts.get(selectedId) + FieldProviderFactory.setField(data, "finSelectedPaymentDetailId", selectedId); + FieldProviderFactory.setField(data, "paymentAmount", idsAmounts.get(selectedId) .toString()); } } } } - FieldProviderFactory.setField(data[i], "finScheduledPaymentDetailId", - FIN_PaymentScheduleDetails[i].getId()); - if (FIN_PaymentScheduleDetails[i].getOrderPaymentSchedule() != null) - FieldProviderFactory.setField(data[i], "orderPaymentScheduleId", - FIN_PaymentScheduleDetails[i].getOrderPaymentSchedule().getId()); - else - FieldProviderFactory.setField(data[i], "orderPaymentScheduleId", ""); - if (FIN_PaymentScheduleDetails[i].getOrderPaymentSchedule() != null) - FieldProviderFactory.setField(data[i], "orderNr", FIN_PaymentScheduleDetails[i] - .getOrderPaymentSchedule().getOrder().getDocumentNo()); - else - FieldProviderFactory.setField(data[i], "orderNr", ""); - if (FIN_PaymentScheduleDetails[i].getInvoicePaymentSchedule() != null) - FieldProviderFactory.setField(data[i], "invoiceNr", FIN_PaymentScheduleDetails[i] - .getInvoicePaymentSchedule().getInvoice().getDocumentNo()); - else - FieldProviderFactory.setField(data[i], "invoiceNr", ""); - if (FIN_PaymentScheduleDetails[i].getOrderPaymentSchedule() != null) - FieldProviderFactory.setField(data[i], "orderNrTrunc", FIN_PaymentScheduleDetails[i] - .getOrderPaymentSchedule().getOrder().getDocumentNo()); - else - FieldProviderFactory.setField(data[i], "orderNrTrunc", ""); - if (FIN_PaymentScheduleDetails[i].getInvoicePaymentSchedule() != null) - FieldProviderFactory.setField(data[i], "invoiceNrTrunc", FIN_PaymentScheduleDetails[i] - .getInvoicePaymentSchedule().getInvoice().getDocumentNo()); - else - FieldProviderFactory.setField(data[i], "invoiceNrTrunc", ""); - if (FIN_PaymentScheduleDetails[i].getInvoicePaymentSchedule() != null) - FieldProviderFactory.setField(data[i], "invoicePaymentScheduleId", - FIN_PaymentScheduleDetails[i].getInvoicePaymentSchedule().getId()); - else - FieldProviderFactory.setField(data[i], "invoicePaymentScheduleId", ""); - if (FIN_PaymentScheduleDetails[i].getInvoicePaymentSchedule() != null) { - FieldProviderFactory.setField( - data[i], - "expectedDate", - dateFormater.format( - FIN_PaymentScheduleDetails[i].getInvoicePaymentSchedule().getExpectedDate()) - .toString()); - FieldProviderFactory.setField( - data[i], - "dueDate", - dateFormater.format( - FIN_PaymentScheduleDetails[i].getInvoicePaymentSchedule().getDueDate()) - .toString()); - FieldProviderFactory.setField(data[i], "invoicedAmount", FIN_PaymentScheduleDetails[i] - .getInvoicePaymentSchedule().getInvoice().getGrandTotalAmount().toString()); - FieldProviderFactory.setField(data[i], "expectedAmount", FIN_PaymentScheduleDetails[i] - .getInvoicePaymentSchedule().getAmount().toString()); + FieldProviderFactory.setField(data, "finScheduledPaymentDetailId", + fin_PaymentScheduleDetail); + FieldProviderFactory.setField(data, "orderPaymentScheduleId", + infoPSD.getOrderPaymentScheduleId()); + FieldProviderFactory.setField(data, "orderNr", infoPSD.getOrderNr()); + FieldProviderFactory.setField(data, "invoiceNr", infoPSD.getInvoiceNr()); + FieldProviderFactory.setField(data, "orderNrTrunc", infoPSD.getOrderNr()); + FieldProviderFactory.setField(data, "invoiceNrTrunc", infoPSD.getInvoiceNrTrunc()); + FieldProviderFactory.setField(data, "invoicePaymentScheduleId", infoPSD.getInvoiceNr()); - // Truncate Business Partner - String businessPartner = FIN_PaymentScheduleDetails[i].getInvoicePaymentSchedule() - .getInvoice().getBusinessPartner().getIdentifier(); - String truncateBusinessPartner = (businessPartner.length() > 18) ? businessPartner - .substring(0, 15).concat("...").toString() : businessPartner; - FieldProviderFactory.setField(data[i], "businessPartnerName", - (businessPartner.length() > 18) ? businessPartner : ""); - FieldProviderFactory.setField(data[i], "businessPartnerNameTrunc", - truncateBusinessPartner); + FieldProviderFactory.setField(data, "expectedDate", infoPSD.getExpectedDate()); + FieldProviderFactory.setField(data, "dueDate", infoPSD.getDueDate()); + FieldProviderFactory.setField(data, "invoicedAmount", + infoPSD.getInvoicedAmount() == null ? "" : infoPSD.getInvoicedAmount().toString()); + FieldProviderFactory.setField(data, "expectedAmount", infoPSD.getExpectedAmount() + .toString()); + FieldProviderFactory + .setField(data, "businessPartnerName", infoPSD.getBusinessPartnerName()); + FieldProviderFactory.setField(data, "businessPartnerNameTrunc", + infoPSD.getBusinessPartnerNameTrunc()); - // Truncate Currency - String currency = FIN_PaymentScheduleDetails[i].getInvoicePaymentSchedule().getInvoice() - .getCurrency().getIdentifier(); - String truncateCurrency = (currency.length() > 18) ? currency.substring(0, 15) - .concat("...").toString() : currency; - FieldProviderFactory.setField(data[i], "currencyName", - (currency.length() > 18) ? currency : ""); - FieldProviderFactory.setField(data[i], "currencyNameTrunc", truncateCurrency); + FieldProviderFactory.setField(data, "currencyName", infoPSD.getCurrencyName()); + FieldProviderFactory.setField(data, "currencyNameTrunc", infoPSD.getCurrencyNameTrunc()); - // Truncate Payment Method - String paymentMethodName = FIN_PaymentScheduleDetails[i].getInvoicePaymentSchedule() - .getFinPaymentmethod().getName(); - String truncatePaymentMethodName = (paymentMethodName.length() > 18) ? paymentMethodName - .substring(0, 15).concat("...").toString() : paymentMethodName; - FieldProviderFactory.setField(data[i], "paymentMethodName", - (paymentMethodName.length() > 18) ? paymentMethodName : ""); - FieldProviderFactory.setField(data[i], "paymentMethodNameTrunc", - truncatePaymentMethodName); + FieldProviderFactory.setField(data, "paymentMethodName", infoPSD.getPaymentMethodName()); + FieldProviderFactory.setField(data, "paymentMethodNameTrunc", + infoPSD.getPaymentMethodNameTrunc()); - if (FIN_PaymentScheduleDetails[i].getInvoicePaymentSchedule().getFINPaymentPriority() != null) { - FieldProviderFactory.setField(data[i], "gridLineColor", FIN_PaymentScheduleDetails[i] - .getInvoicePaymentSchedule().getFINPaymentPriority().getColor()); - } - } else { - FieldProviderFactory.setField( - data[i], - "expectedDate", - dateFormater.format( - FIN_PaymentScheduleDetails[i].getOrderPaymentSchedule().getExpectedDate()) - .toString()); - FieldProviderFactory.setField( - data[i], - "dueDate", - dateFormater.format( - FIN_PaymentScheduleDetails[i].getOrderPaymentSchedule().getDueDate()).toString()); - FieldProviderFactory.setField(data[i], "invoicedAmount", ""); - FieldProviderFactory.setField(data[i], "expectedAmount", FIN_PaymentScheduleDetails[i] - .getOrderPaymentSchedule().getAmount().toString()); + FieldProviderFactory.setField(data, "gridLineColor", infoPSD.getGridLineColor()); - // Truncate Business Partner - String businessPartner = FIN_PaymentScheduleDetails[i].getOrderPaymentSchedule() - .getOrder().getBusinessPartner().getIdentifier(); - String truncateBusinessPartner = (businessPartner.length() > 18) ? businessPartner - .substring(0, 15).concat("...").toString() : businessPartner; - FieldProviderFactory.setField(data[i], "businessPartnerName", - (businessPartner.length() > 18) ? businessPartner : ""); - FieldProviderFactory.setField(data[i], "businessPartnerNameTrunc", - truncateBusinessPartner); - - // Truncate Currency - String currency = FIN_PaymentScheduleDetails[i].getOrderPaymentSchedule().getOrder() - .getCurrency().getIdentifier(); - String truncateCurrency = (currency.length() > 18) ? currency.substring(0, 15) - .concat("...").toString() : currency; - FieldProviderFactory.setField(data[i], "currencyName", - (currency.length() > 18) ? currency : ""); - FieldProviderFactory.setField(data[i], "currencyNameTrunc", truncateCurrency); - - // Truncate Payment Method - String paymentMethodName = FIN_PaymentScheduleDetails[i].getOrderPaymentSchedule() - .getFinPaymentmethod().getName(); - String truncatePaymentMethodName = (paymentMethodName.length() > 18) ? paymentMethodName - .substring(0, 15).concat("...").toString() : paymentMethodName; - FieldProviderFactory.setField(data[i], "paymentMethodName", - (paymentMethodName.length() > 18) ? paymentMethodName : ""); - FieldProviderFactory.setField(data[i], "paymentMethodNameTrunc", - truncatePaymentMethodName); - - if (FIN_PaymentScheduleDetails[i].getOrderPaymentSchedule().getFINPaymentPriority() != null) { - FieldProviderFactory.setField(data[i], "gridLineColor", FIN_PaymentScheduleDetails[i] - .getOrderPaymentSchedule().getFINPaymentPriority().getColor()); - } - } - FieldProviderFactory.setField(data[i], "outstandingAmount", FIN_PaymentScheduleDetails[i] - .getAmount().toString()); + FieldProviderFactory.setField(data, "outstandingAmount", infoPSD.getOutstandingAmount() + .toString()); String strPaymentAmt = ""; String strDifference = ""; - if (firstLoad && (selectedScheduledPaymentDetails.contains(FIN_PaymentScheduleDetails[i])) + if (firstLoad + && (strSelectedPaymentDetails.contains(new InfoPSD(fin_PaymentScheduleDetail, true))) && remittance != null) - strPaymentAmt = getRemittanceLineAmount(FIN_PaymentScheduleDetails[i], remittance); + strPaymentAmt = getRemittanceLineAmount(infoPSD.getFinScheduledPaymentDetailId(), + remittance); else - strPaymentAmt = vars.getNumericParameter("inpPaymentAmount" - + FIN_PaymentScheduleDetails[i].getId(), ""); + strPaymentAmt = vars.getNumericParameter( + "inpPaymentAmount" + infoPSD.getFinScheduledPaymentDetailId(), ""); if (!"".equals(strPaymentAmt)) - strDifference = FIN_PaymentScheduleDetails[i].getAmount() - .subtract(new BigDecimal(strPaymentAmt)).toString(); - if (data[i].getField("paymentAmount") == null - || "".equals(data[i].getField("paymentAmount"))) { - FieldProviderFactory.setField(data[i], "paymentAmount", strPaymentAmt); + strDifference = infoPSD.getOutstandingAmount().subtract(new BigDecimal(strPaymentAmt)) + .toString(); + if (data.getField("paymentAmount") == null || "".equals(data.getField("paymentAmount"))) { + FieldProviderFactory.setField(data, "paymentAmount", strPaymentAmt); } - FieldProviderFactory.setField(data[i], "difference", strDifference); - FieldProviderFactory.setField(data[i], "rownum", String.valueOf(i)); + FieldProviderFactory.setField(data, "difference", strDifference); + FieldProviderFactory.setField(data, "rownum", String.valueOf(i)); + + dataList.add(data); + + if (++i % 100 == 0) { + OBDal.getInstance().getSession().clear(); + remittance = OBDal.getInstance().get(Remittance.class, remittanceId); + } } } finally { OBContext.restorePreviousMode(); } - return data; + + FieldProvider[] a = new FieldProvider[0]; + return dataList.toArray(a); + // return dataFP; } - private static String getRemittanceLineAmount(FIN_PaymentScheduleDetail finPaymentScheduleDetail, + private static String getRemittanceLineAmount(String finPaymentScheduleDetailId, Remittance remittance) { String amount = ""; for (RemittanceLine line : remittance.getREMRemittanceLineList()) - if (line.getPaymentScheduleDetail() == finPaymentScheduleDetail) + if (line.getPaymentScheduleDetail().getId().equals(finPaymentScheduleDetailId)) amount = line.getAmount().toString(); return amount; @@ -486,37 +427,42 @@ return newRemittanceLine; } - public static List<FIN_PaymentScheduleDetail> getFilteredScheduledPaymentDetails( - Organization organization, Currency currency, Date dueDateFrom, Date dueDateTo, + // Problema performance + @SuppressWarnings("unchecked") + public static List<InfoPSD> getFilteredScheduledPaymentDetails(Organization organization, + Remittance remittance, boolean showAlternativeCurrency, Date dueDateFrom, Date dueDateTo, String strTransactionType, FIN_PaymentMethod paymentMethod, String isReceipt, - String strBPartner, List<FIN_PaymentScheduleDetail> selectedScheduledPaymentDetails) { - return getFilteredScheduledPaymentDetails(organization, null, false, dueDateFrom, dueDateTo, - strTransactionType, paymentMethod, isReceipt, strBPartner, selectedScheduledPaymentDetails); - } - - public static List<FIN_PaymentScheduleDetail> getFilteredScheduledPaymentDetails( - Organization organization, Remittance remittance, boolean showAlternativeCurrency, - Date dueDateFrom, Date dueDateTo, String strTransactionType, FIN_PaymentMethod paymentMethod, - String isReceipt, String strBPartner, - List<FIN_PaymentScheduleDetail> selectedScheduledPaymentDetails) { + String strBPartner, List<InfoPSD> selectedScheduledPaymentDetails) { // If it does not allow IN/OUT just return empty list if ("".equals(isReceipt)) { - return new ArrayList<FIN_PaymentScheduleDetail>(); + return new ArrayList<InfoPSD>(0); } final StringBuilder whereClause = new StringBuilder(); - final List<Object> parameters = new ArrayList<Object>(); + final Map<String, Object> parameters = new HashMap<String, Object>(); // FIXME: added to access the FIN_PaymentSchedule and FIN_PaymentScheduleDetail tables to be // removed when new security implementation is done OBContext.setAdminMode(); try { - whereClause.append(" as psd "); // pending scheduled payments // + whereClause.append(" select new org.openbravo.module.remittance.process.InfoPSD(psd.id, "); + whereClause + .append(" ops.id, ord.documentNo, inv.documentNo, ips.id, coalesce(ips.expectedDate, ops.expectedDate), "); + whereClause + .append(" coalesce(ips.dueDate, ops.dueDate), inv.grandTotalAmount, coalesce(ips.amount, ops.amount), "); + whereClause.append(" coalesce(ibp.name, obp.name), coalesce(icur.iSOCode, ocur.iSOCode), "); + whereClause + .append(" coalesce(ipm.name, opm.name), coalesce(ipriority.color, opriority.color), psd.amount) "); + whereClause.append(" from FIN_Payment_ScheduleDetail psd ");// pending scheduled payments // whereClause.append(" left outer join psd.orderPaymentSchedule as ops"); whereClause.append(" left outer join ops.order as ord "); + whereClause.append(" left outer join ord.currency as ocur "); + whereClause.append(" left outer join ord.paymentMethod opm "); whereClause.append(" left outer join ord.businessPartner as obp "); whereClause.append(" left outer join ops.fINPaymentPriority as opriority "); whereClause.append(" left outer join psd.invoicePaymentSchedule ips "); whereClause.append(" left outer join ips.invoice as inv "); + whereClause.append(" left outer join inv.currency as icur "); + whereClause.append(" left outer join inv.paymentMethod ipm "); whereClause.append(" left outer join inv.businessPartner as ibp "); whereClause.append(" left outer join ips.fINPaymentPriority as ipriority "); whereClause.append(" where psd."); @@ -530,24 +476,15 @@ whereClause.append(")"); // remove selected payments - if (selectedScheduledPaymentDetails != null && selectedScheduledPaymentDetails.size() > 0) { - String strSelectedPaymentDetails = Utility.getInStrList(selectedScheduledPaymentDetails); + if (!selectedScheduledPaymentDetails.isEmpty()) { whereClause.append(" and psd not in ("); - whereClause.append(strSelectedPaymentDetails); + whereClause.append(getInStrList(selectedScheduledPaymentDetails, false)); whereClause.append(")"); } // block schedule payments in other payment proposal - final OBCriteria<FIN_PaymentPropDetail> obc = OBDal.getInstance().createCriteria( - FIN_PaymentPropDetail.class); - obc.add(Restrictions.isNotNull(FIN_PaymentPropDetail.PROPERTY_FINPAYMENTSCHEDULEDETAIL)); - if (obc.list() != null && obc.list().size() > 0) { - List<FIN_PaymentScheduleDetail> aux = new ArrayList<FIN_PaymentScheduleDetail>(); - for (FIN_PaymentPropDetail ppd : obc.list()) { - aux.add(ppd.getFINPaymentScheduledetail()); - } - whereClause.append(" and psd.id not in (" + Utility.getInStrList(aux) + ")"); - } + whereClause + .append(" and not exists (select 1 from FIN_Payment_Prop_Detail propDet where propDet.fINPaymentScheduledetail.id = psd.id)"); // Transaction type filter whereClause.append(" and ("); @@ -642,8 +579,8 @@ whereClause.append(FIN_PaymentSchedule.PROPERTY_EXPECTEDDATE); whereClause.append(", ops."); whereClause.append(FIN_PaymentSchedule.PROPERTY_EXPECTEDDATE); - whereClause.append(") >= ?"); - parameters.add(dueDateFrom); + whereClause.append(") >= :dueDateFrom "); + parameters.put("dueDateFrom", dueDateFrom); } // dateTo if (dueDateTo != null) { @@ -651,8 +588,8 @@ whereClause.append(FIN_PaymentSchedule.PROPERTY_EXPECTEDDATE); whereClause.append(", ops."); whereClause.append(FIN_PaymentSchedule.PROPERTY_EXPECTEDDATE); - whereClause.append(") < ?"); - parameters.add(dueDateTo); + whereClause.append(") < :dueDateTo"); + parameters.put("dueDateTo", dueDateTo); } // TODO: Add order to show first scheduled payments from invoices and later scheduled payments // from not invoiced orders. @@ -685,17 +622,34 @@ whereClause.append(")"); whereClause.append(", psd."); whereClause.append(FIN_PaymentScheduleDetail.PROPERTY_AMOUNT); - final OBQuery<FIN_PaymentScheduleDetail> obqPSD = OBDal.getInstance().createQuery( - FIN_PaymentScheduleDetail.class, whereClause.toString()); + final Session session = OBDal.getInstance().getSession(); + final Query query = session.createQuery(whereClause.toString()); - obqPSD.setParameters(parameters); - return obqPSD.list(); + query.setProperties(parameters); + // Uncomment this if you have many records + // query.setMaxResults(1000); + return query.list(); } finally { OBContext.restorePreviousMode(); } } + public static String getInStrList(List<InfoPSD> obObjectList, boolean addParentheses) { + StringBuilder strInList = new StringBuilder(); + for (InfoPSD obObject : obObjectList) { + if (strInList.length() == 0) + strInList.append("'" + obObject.getFinScheduledPaymentDetailId() + "'"); + else + strInList.append(", '" + obObject.getFinScheduledPaymentDetailId() + "'"); + } + if (addParentheses) { + return "(" + strInList.toString() + ")"; + } else { + return strInList.toString(); + } + } + /** * Creates a HashMap with the FIN_PaymentScheduleDetail id's and the amount gotten from the * Session. | |||||||
Relationships [ Relation Graph ] [ Dependency Graph ] | |||||||||||||||
|
Notes | |
(0093984) egoitz (manager) 2017-02-01 12:40 |
You can get also a out of memory error depending on the volume of payments |
(0094275) vmromanos (manager) 2017-02-13 17:12 |
Please note there is a feature request 0022207 that is the right way to fix this issue. Besides there is a design defect 0022330 related to this topic. That means that we will try to fix this issue only if it's easy & fast. Spending too much time in this piece of code doesn't make sense and it would be better to work on the redesign instead. |
(0094379) vmromanos (manager) 2017-02-16 09:31 |
Rejected as duplicated of 0022207 There are two issues that both must be fixed at the same time to make this window working with very high volumens: 1. The Java code doesn't properly manage memory, loading too many records in Hibernate memory, killing the server with high volumens. Besides the process launches too many queries to the database to get the info to be printed in the grid. This makes the process very slow and also contributes to out of memory problems. 2. The grid where the lines are displayed is not ready for working with high volumens, because it doesn't implement pagination. Thus, if the instance has many lines to shown, it kills the browser trying to render all of them. In the customer environment that reports this issue there are a total of more than 83K records to display. My browser is unable to render more than 2K records at the same time. The proper way to fix this is by implementing 0022207. As a workaround for this problem meanwhile 0022207 is not fixed, I have attached 2 solutions for this problem: the safe one (35127_core.diff + 35127_safe.diff) and the risky one (35127_core.diff + 35127_risky.diff): * Safe solution: adds an index to core, refactors a query that had important performance problems and, the most important part, adds a limit of 1K records to be shown. This way we workaround problems explained in #1 and #2 and the user can start creating remittance batches of 1K records. * Risky solution: adds an index to core, heavily refactor Java code to improve memory management (with this patch we fix Out of Memory exceptions) and to improve SQL performance (now the process is finished in less than 15 seconds in my test for the 83K records). However it has two important problems: it might introduce regressions because the changes are really major and it won't fix the browser rendering problems, so depending on the number of records your browser will probably crash. As a conclusion, I would recommend to apply the safe patch and work in batches of 1K records. This window is clearly obsolete and should be refactor instead of investing more time |
Issue History | |||
Date Modified | Username | Field | Change |
2017-02-01 12:38 | egoitz | New Issue | |
2017-02-01 12:38 | egoitz | Assigned To | => platform |
2017-02-01 12:38 | egoitz | Regression introduced by commit | => 45320 |
2017-02-01 12:38 | egoitz | Resolution time | => 1488322800 |
2017-02-01 12:39 | egoitz | Assigned To | platform => Triage Finance |
2017-02-01 12:39 | egoitz | Category | New selectors => Remittance |
2017-02-01 12:40 | egoitz | Note Added: 0093984 | |
2017-02-13 17:12 | vmromanos | Note Added: 0094275 | |
2017-02-13 17:12 | vmromanos | Relationship added | related to 0022207 |
2017-02-13 17:13 | vmromanos | Relationship added | related to 0022330 |
2017-02-13 21:56 | markmm82 | Assigned To | Triage Finance => Sanjota |
2017-02-14 09:17 | jmonfort | Issue Monitored: jmonfort | |
2017-02-14 09:53 | vmromanos | Assigned To | Sanjota => vmromanos |
2017-02-15 11:27 | vmromanos | Status | new => acknowledged |
2017-02-16 09:08 | vmromanos | Status | acknowledged => scheduled |
2017-02-16 09:30 | vmromanos | Review Assigned To | => vmromanos |
2017-02-16 09:31 | vmromanos | Relationship replaced | duplicate of 0022207 |
2017-02-16 09:31 | vmromanos | Note Added: 0094379 | |
2017-02-16 09:31 | vmromanos | Status | scheduled => closed |
2017-02-16 09:31 | vmromanos | Resolution | open => duplicate |
2017-02-16 09:31 | vmromanos | File Added: 35127_core.diff | |
2017-02-16 09:32 | vmromanos | File Added: 35127_safe.diff | |
2017-02-16 09:32 | vmromanos | File Added: 35127_risky.diff |
Copyright © 2000 - 2009 MantisBT Group |