details: https://code.openbravo.com/erp/devel/pi/rev/97588079b0b3 changeset: 32669:97588079b0b3 user: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com> date: Mon Sep 11 18:52:12 2017 +0200 summary: Related to issue 36736: Apply again changes in Journal Entries Report
details: https://code.openbravo.com/erp/devel/pi/rev/89a723abed26 changeset: 32670:89a723abed26 user: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com> date: Tue Sep 12 10:18:16 2017 +0200 summary: Related to issue 36736: Use normal db in direct Journal Entries Report Use normal db in Journal Entries Report only when it is launched just after posting a document. diffstat: src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java | 395 +++++---- src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournalDetail.java | 59 +- 2 files changed, 254 insertions(+), 200 deletions(-) diffs (truncated from 949 to 300 lines): diff -r efcc5da08f96 -r 89a723abed26 src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java --- a/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java Tue Sep 12 09:33:36 2017 +0200 +++ b/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java Tue Sep 12 10:18:16 2017 +0200 @@ -47,6 +47,7 @@ import org.openbravo.dal.core.OBContext; import org.openbravo.dal.service.OBDal; import org.openbravo.dal.service.OBQuery; +import org.openbravo.database.ConnectionProvider; import org.openbravo.erpCommon.businessUtility.AccountingSchemaMiscData; import org.openbravo.erpCommon.businessUtility.Tree; import org.openbravo.erpCommon.businessUtility.TreeData; @@ -63,6 +64,7 @@ import org.openbravo.model.common.enterprise.DocumentType; import org.openbravo.model.financialmgmt.accounting.coa.AcctSchema; import org.openbravo.model.financialmgmt.accounting.coa.AcctSchemaTable; +import org.openbravo.service.db.DalConnectionProvider; import org.openbravo.xmlEngine.XmlDocument; public class ReportGeneralLedgerJournal extends HttpSecureAppServlet { @@ -87,8 +89,9 @@ ServletException { VariablesSecureApp vars = new VariablesSecureApp(request); - if (log4j.isDebugEnabled()) + if (log4j.isDebugEnabled()) { log4j.debug("Command: " + vars.getStringParameter("Command")); + } if (vars.commandIn("DEFAULT")) { String strOrg = vars.getGlobalVariable("inpOrg", "ReportGeneralLedgerJournal|Org", @@ -123,11 +126,12 @@ log4j.debug("********DEFAULT*************** strShowOpening: " + strShowOpening); String initRecordNumberOld = vars.getSessionValue( "ReportGeneralLedgerJournal.initRecordNumberOld", "0"); - if (vars.getSessionValue("ReportGeneralLedgerJournal.initRecordNumber", "0").equals("0")) { + if (StringUtils.equals( + vars.getSessionValue("ReportGeneralLedgerJournal.initRecordNumber", "0"), "0")) { vars.setSessionValue("ReportGeneralLedgerJournal.initRecordNumber", "0"); vars.setSessionValue(PREVIOUS_ACCTENTRIES, "0"); vars.setSessionValue(PREVIOUS_RANGE, ""); - } else if (!"-1".equals(initRecordNumberOld)) { + } else if (!StringUtils.equals(initRecordNumberOld, "-1")) { vars.setSessionValue("ReportGeneralLedgerJournal.initRecordNumber", initRecordNumberOld); vars.setSessionValue(PREVIOUS_ACCTENTRIES, vars.getSessionValue(PREVIOUS_ACCTENTRIES_OLD)); vars.setSessionValue(PREVIOUS_RANGE, vars.getSessionValue(PREVIOUS_RANGE_OLD)); @@ -143,15 +147,19 @@ String strcelementvalueto = vars.getGlobalVariable("inpcElementValueIdTo", "ReportGeneralLedgerJournal|C_ElementValue_IDTO", ""); String strcelementvaluefromdes = "", strcelementvaluetodes = ""; - if (!strcelementvaluefrom.equals("")) - strcelementvaluefromdes = ReportGeneralLedgerData.selectSubaccountDescription(this, + ConnectionProvider readOnlyCP = DalConnectionProvider.getReadOnlyConnectionProvider(); + if (StringUtils.isNotEmpty(strcelementvaluefrom)) { + strcelementvaluefromdes = ReportGeneralLedgerData.selectSubaccountDescription(readOnlyCP, strcelementvaluefrom); - if (!strcelementvalueto.equals("")) - strcelementvaluetodes = ReportGeneralLedgerData.selectSubaccountDescription(this, + } + if (StringUtils.isNotEmpty(strcelementvalueto)) { + strcelementvaluetodes = ReportGeneralLedgerData.selectSubaccountDescription(readOnlyCP, strcelementvalueto); - strcelementvaluefromdes = (strcelementvaluefromdes.equals("null")) ? "" + } + strcelementvaluefromdes = (StringUtils.equals(strcelementvaluefromdes, "null")) ? "" : strcelementvaluefromdes; - strcelementvaluetodes = (strcelementvaluetodes.equals("null")) ? "" : strcelementvaluetodes; + strcelementvaluetodes = (StringUtils.equals(strcelementvaluetodes, "null")) ? "" + : strcelementvaluetodes; vars.setSessionValue("inpElementValueIdFrom_DES", strcelementvaluefromdes); vars.setSessionValue("inpElementValueIdTo_DES", strcelementvaluetodes); printPageDataSheet(response, vars, strDateFrom, strDateTo, strDocument, strDocumentNo, @@ -208,27 +216,33 @@ String strOrg = vars.getGlobalVariable("inpOrg", "ReportGeneralLedgerJournal|Org", "0"); String strShowClosing = vars.getRequestGlobalVariable("inpShowClosing", "ReportGeneralLedgerJournal|ShowClosing"); - if (strShowClosing == null || "".equals(strShowClosing)) + if (StringUtils.isEmpty(strShowClosing)) { vars.setSessionValue("ReportGeneralLedgerJournal|ShowClosing", "N"); + } String strShowDivideUp = vars.getRequestGlobalVariable("inpShowDivideUp", "ReportGeneralLedgerJournal|ShowDivideUp"); - if (strShowDivideUp == null || "".equals(strShowDivideUp)) + if (StringUtils.isEmpty(strShowDivideUp)) { vars.setSessionValue("ReportGeneralLedgerJournal|ShowDivideUp", "N"); + } String strShowRegular = vars.getRequestGlobalVariable("inpShowRegular", "ReportGeneralLedgerJournal|ShowRegular"); - if (strShowRegular == null || "".equals(strShowRegular)) + if (StringUtils.isEmpty(strShowRegular)) { vars.setSessionValue("ReportGeneralLedgerJournal|ShowRegular", "N"); + } String strShowReg = vars.getRequestGlobalVariable("inpShowReg", "ReportGeneralLedgerJournal|ShowReg"); - if (strShowReg == null || "".equals(strShowReg)) + if (StringUtils.isEmpty(strShowReg)) { vars.setSessionValue("ReportGeneralLedgerJournal|ShowReg", "N"); + } String strShowOpening = vars.getRequestGlobalVariable("inpShowOpening", "ReportGeneralLedgerJournal|ShowOpening"); - if (strShowOpening == null || "".equals(strShowOpening)) + if (StringUtils.isEmpty(strShowOpening)) { vars.setSessionValue("ReportGeneralLedgerJournal|ShowOpening", "N"); - if (!("Y".equals(strShowOpening)) && !("Y".equals(strShowReg)) - && !("Y".equals(strShowRegular)) && !("Y".equals(strShowClosing)) - && !("Y".equals(strShowDivideUp))) { + } + if (!(StringUtils.equals(strShowOpening, "Y")) && !(StringUtils.equals(strShowReg, "Y")) + && !(StringUtils.equals(strShowRegular, "Y")) + && !(StringUtils.equals(strShowClosing, "Y")) + && !(StringUtils.equals(strShowDivideUp, "Y"))) { strShowRegular = "Y"; vars.setSessionValue("ReportGeneralLedgerJournal|ShowRegular", "Y"); } @@ -254,19 +268,23 @@ "ReportGeneralLedgerJournal|EntryNo"); String strShowDescription = vars.getRequestGlobalVariable("inpShowDescription", "ReportGeneralLedgerJournal|ShowDescription"); - if (strShowDescription == null || "".equals(strShowDescription)) + if (StringUtils.isEmpty(strShowDescription)) { vars.setSessionValue("ReportGeneralLedgerJournal|ShowDescription", "N"); + } String strcelementvaluefrom = vars.getRequestGlobalVariable("inpcElementValueIdFrom", "ReportGeneralLedgerJournal|C_ElementValue_IDFROM"); String strcelementvalueto = vars.getRequestGlobalVariable("inpcElementValueIdTo", "ReportGeneralLedgerJournal|C_ElementValue_IDTO"); String strcelementvaluefromdes = "", strcelementvaluetodes = ""; - if (!strcelementvaluefrom.equals("")) - strcelementvaluefromdes = ReportGeneralLedgerData.selectSubaccountDescription(this, + ConnectionProvider readOnlyCP = DalConnectionProvider.getReadOnlyConnectionProvider(); + if (StringUtils.isNotEmpty(strcelementvaluefrom)) { + strcelementvaluefromdes = ReportGeneralLedgerData.selectSubaccountDescription(readOnlyCP, strcelementvaluefrom); - if (!strcelementvalueto.equals("")) - strcelementvaluetodes = ReportGeneralLedgerData.selectSubaccountDescription(this, + } + if (StringUtils.isNotEmpty(strcelementvalueto)) { + strcelementvaluetodes = ReportGeneralLedgerData.selectSubaccountDescription(readOnlyCP, strcelementvalueto); + } vars.setSessionValue("inpElementValueIdFrom_DES", strcelementvaluefromdes); vars.setSessionValue("inpElementValueIdTo_DES", strcelementvaluetodes); printPageDataSheet(response, vars, strDateFrom, strDateTo, strDocument, strDocumentNo, @@ -290,36 +308,38 @@ String strOrg = vars.getGlobalVariable("inpOrg", "ReportGeneralLedgerJournal|Org", "0"); String strShowClosing = vars.getRequestGlobalVariable("inpShowClosing", "ReportGeneralLedgerJournal|ShowClosing"); - if (strShowClosing == null || "".equals(strShowClosing)) + if (StringUtils.isEmpty(strShowClosing)) { vars.setSessionValue("ReportGeneralLedgerJournal|ShowClosing", "N"); + } String strShowRegular = vars.getRequestGlobalVariable("inpShowRegular", "ReportGeneralLedgerJournal|ShowRegular"); - if (strShowRegular == null || "".equals(strShowRegular)) + if (StringUtils.isEmpty(strShowRegular)) { vars.setSessionValue("ReportGeneralLedgerJournal|ShowRegular", "N"); + } String strShowReg = vars.getRequestGlobalVariable("inpShowReg", "ReportGeneralLedgerJournal|ShowReg"); - if (strShowReg == null || "".equals(strShowReg)) + if (StringUtils.isEmpty(strShowReg)) { vars.setSessionValue("ReportGeneralLedgerJournal|ShowReg", "N"); + } String strShowOpening = vars.getRequestGlobalVariable("inpShowOpening", "ReportGeneralLedgerJournal|ShowOpening"); - if (strShowOpening == null || "".equals(strShowOpening)) + if (StringUtils.isEmpty(strShowOpening)) { vars.setSessionValue("ReportGeneralLedgerJournal|ShowOpening", "N"); + } String strShowDivideUp = vars.getRequestGlobalVariable("inpShowDivideUp", "ReportGeneralLedgerJournal|ShowDivideUp"); - if (strShowDivideUp == null || "".equals(strShowDivideUp)) + if (StringUtils.isEmpty(strShowDivideUp)) { vars.setSessionValue("ReportGeneralLedgerJournal|ShowDivideUp", "N"); + } // In case all flags "Type" are deactivated, the "Regular" one is activated by default - if (!("Y".equals(strShowOpening)) && !("Y".equals(strShowReg)) - && !("Y".equals(strShowRegular)) && !("Y".equals(strShowClosing)) - && !("Y".equals(strShowDivideUp))) { + if (!(StringUtils.equals(strShowOpening, "Y")) && !(StringUtils.equals(strShowReg, "Y")) + && !(StringUtils.equals(strShowRegular, "Y")) + && !(StringUtils.equals(strShowClosing, "Y")) + && !(StringUtils.equals(strShowDivideUp, "Y"))) { strShowRegular = "Y"; vars.setSessionValue("ReportGeneralLedgerJournal|ShowRegular", "Y"); } - // String strRecord = vars.getGlobalVariable("inpRecord", - // "ReportGeneralLedgerJournal|Record"); - // String strTable = vars.getGlobalVariable("inpTable", - // "ReportGeneralLedgerJournal|Table"); String strTable = vars.getStringParameter("inpTable"); String strRecord = vars.getStringParameter("inpRecord"); String strPageNo = vars.getGlobalVariable("inpPageNo", "ReportGeneralLedgerJournal|PageNo", @@ -328,8 +348,9 @@ "ReportGeneralLedgerJournal|EntryNo", "1"); String strShowDescription = vars.getRequestGlobalVariable("inpShowDescription", "ReportGeneralLedgerJournal|ShowDescription"); - if (strShowDescription == null || "".equals(strShowDescription)) + if (StringUtils.isEmpty(strShowDescription)) { vars.setSessionValue("ReportGeneralLedgerJournal|ShowDescription", "N"); + } /* * Scenario 1: We will have FactAcctGroupId while the request redirect from * ReportGeneralLedger Report. Otherwise we don't need to use FactAcctGroupId for PDF or Excel @@ -341,19 +362,20 @@ * strFactAcctGroupId(will take care of criteria from current screen) */ String strFactAcctGroupId = ""; - if (strcAcctSchemaId.equals("") && strDateFrom.equals("") && strDocument.equals("") - && strOrg.equals("0") && strShowClosing.equals("") && strShowReg.equals("") - && strShowOpening.equals("") && strRecord.equals("")) { + if (StringUtils.isEmpty(strcAcctSchemaId) && StringUtils.isEmpty(strDateFrom) + && StringUtils.isEmpty(strDocument) && StringUtils.equals(strOrg, "0") + && StringUtils.isEmpty(strShowClosing) && StringUtils.isEmpty(strShowReg) + && StringUtils.isEmpty(strShowOpening) && StringUtils.isEmpty(strRecord)) { int currentHistoryIndex = new Integer( new VariablesHistory(request).getCurrentHistoryIndex()).intValue(); String currentCommand = vars.getSessionValue("reqHistory.command" + currentHistoryIndex); - if (currentCommand.equals("DIRECT2")) { + if (StringUtils.equals(currentCommand, "DIRECT2")) { strFactAcctGroupId = vars.getGlobalVariable("inpFactAcctGroupId", "ReportGeneralLedgerJournal|FactAcctGroupId"); } } - // vars.setSessionValue("ReportGeneralLedgerJournal.initRecordNumber", "0"); + setHistoryCommand(request, "DEFAULT"); String strcelementvaluefrom = vars.getRequestGlobalVariable("inpcElementValueIdFrom", "ReportGeneralLedgerJournal|C_ElementValue_IDFROM"); @@ -361,18 +383,19 @@ "ReportGeneralLedgerJournal|C_ElementValue_IDTO"); printPagePDF(request, response, vars, strDateFrom, strDateTo, strDocument, strDocumentNo, strOrg, strTable, strRecord, strFactAcctGroupId, strcAcctSchemaId, strShowClosing, - strShowReg, strShowOpening, strPageNo, strEntryNo, "Y".equals(strShowDescription) ? "Y" - : "", strShowRegular, strShowDivideUp, strcelementvaluefrom, strcelementvalueto); + strShowReg, strShowOpening, strPageNo, strEntryNo, + StringUtils.equals(strShowDescription, "Y") ? "Y" : "", strShowRegular, strShowDivideUp, + strcelementvaluefrom, strcelementvalueto); } else if (vars.commandIn("PREVIOUS_RELATION")) { String strInitRecord = vars.getSessionValue("ReportGeneralLedgerJournal.initRecordNumber"); String strPreviousRecordRange = vars.getSessionValue(PREVIOUS_RANGE); String[] previousRecord = strPreviousRecordRange.split(","); strPreviousRecordRange = previousRecord[0]; - int intRecordRange = strPreviousRecordRange.equals("") ? 0 : Integer + int intRecordRange = StringUtils.isEmpty(strPreviousRecordRange) ? 0 : Integer .parseInt(strPreviousRecordRange); strPreviousRecordRange = previousRecord[1]; - intRecordRange += strPreviousRecordRange.equals("") ? 0 : Integer + intRecordRange += StringUtils.isEmpty(strPreviousRecordRange) ? 0 : Integer .parseInt(strPreviousRecordRange); // Remove parts of the previous range @@ -389,10 +412,10 @@ sb_previousAcctEntries.append(previousAcctEntries[i] + ","); } - if (strInitRecord.equals("") || strInitRecord.equals("0")) + if (StringUtils.isEmpty(strInitRecord) || StringUtils.equals(strInitRecord, "0")) { vars.setSessionValue("ReportGeneralLedgerJournal.initRecordNumber", "0"); - else { - int initRecord = (strInitRecord.equals("") ? 0 : Integer.parseInt(strInitRecord)); + } else { + int initRecord = (StringUtils.isEmpty(strInitRecord) ? 0 : Integer.parseInt(strInitRecord)); initRecord -= intRecordRange; strInitRecord = ((initRecord < 0) ? "0" : Integer.toString(initRecord)); vars.setSessionValue("ReportGeneralLedgerJournal.initRecordNumber", strInitRecord); @@ -437,16 +460,20 @@ String strcelementvalueto, String strcelementvaluefromdes, String strcelementvaluetodes) throws IOException, ServletException { String strAllaccounts = "Y"; - if (strcelementvaluefrom != null && !strcelementvaluefrom.equals("")) + if (StringUtils.isNotEmpty(strcelementvaluefrom)) { strAllaccounts = "N"; - String strRecordRange = Utility.getContext(this, vars, "#RecordRange", + } + ConnectionProvider readOnlyCP = DalConnectionProvider.getReadOnlyConnectionProvider(); + String strRecordRange = Utility.getContext(readOnlyCP, vars, "#RecordRange", "ReportGeneralLedgerJournal"); - int intRecordRangePredefined = (strRecordRange.equals("") ? 0 : Integer + int intRecordRangePredefined = (StringUtils.isEmpty(strRecordRange) ? 0 : Integer .parseInt(strRecordRange)); String strInitRecord = vars.getSessionValue("ReportGeneralLedgerJournal.initRecordNumber"); - int initRecordNumber = (strInitRecord.equals("") ? 0 : Integer.parseInt(strInitRecord)); - if (log4j.isDebugEnabled()) + int initRecordNumber = (StringUtils.isEmpty(strInitRecord) ? 0 : Integer + .parseInt(strInitRecord)); + if (log4j.isDebugEnabled()) { log4j.debug("Output: dataSheet"); + } response.setContentType("text/html; charset=UTF-8"); PrintWriter out = response.getWriter(); XmlDocument xmlDocument = null; @@ -455,8 +482,8 @@ ReportGeneralLedgerJournalData[] dataCountLines = null; ReportGeneralLedgerJournalData scrollCountLines = null; String strPosition = "0"; - ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportGeneralLedgerJournal", false, - "", "", "imprimir();return false;", false, "ad_reports", strReplaceWith, false, true); ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits