List of usage examples for javax.servlet ServletException getMessage
public String getMessage()
From source file:org.openbravo.erpCommon.ad_reports.ReportShipmentDimensionalAnalyzeJR.java
private void printPageHtml(HttpServletRequest request, HttpServletResponse response, VariablesSecureApp vars, String strComparative, String strDateFrom, String strDateTo, String strPartnerGroup, String strcBpartnerId, String strProductCategory, String strmProductId, String strmWarehouseId, String strNotShown, String strShown, String strDateFromRef, String strDateToRef, String strOrg, String strsalesrepId, String strOrder, String strMayor, String strMenor, String strPartnerSalesrepId, String strCurrencyId, String strOutput) throws IOException, ServletException { if (log4j.isDebugEnabled()) log4j.debug("Output: print html"); String strOrderby = ""; String[] discard = { "", "", "", "", "", "", "", "", "" }; String[] discard1 = { "selEliminarBody1", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard" }; if (strOrg.equals("")) strOrg = vars.getOrg();/*from w w w. j av a 2 s. com*/ if (strComparative.equals("Y")) discard1[0] = "selEliminarBody2"; String strTitle = ""; strTitle = Utility.messageBD(this, "From", vars.getLanguage()) + " " + strDateFrom + " " + Utility.messageBD(this, "To", vars.getLanguage()) + " " + strDateTo; if (!strPartnerGroup.equals("")) strTitle = strTitle + ", " + Utility.messageBD(this, "ForBPartnerGroup", vars.getLanguage()) + " " + ReportShipmentDimensionalAnalyzeJRData.selectBpgroup(this, strPartnerGroup); if (!strProductCategory.equals("")) strTitle = strTitle + ", " + Utility.messageBD(this, "ProductCategory", vars.getLanguage()) + " " + ReportShipmentDimensionalAnalyzeJRData.selectProductCategory(this, strProductCategory); if (!strsalesrepId.equals("")) strTitle = strTitle + ", " + Utility.messageBD(this, "TheSalesRep", vars.getLanguage()) + " " + ReportShipmentDimensionalAnalyzeJRData.selectSalesrep(this, strsalesrepId); if (!strPartnerSalesrepId.equals("")) strTitle = strTitle + ", " + Utility.messageBD(this, "TheClientSalesRep", vars.getLanguage()) + " " + ReportShipmentDimensionalAnalyzeJRData.selectSalesrep(this, strPartnerSalesrepId); if (!strmWarehouseId.equals("")) strTitle = strTitle + " " + Utility.messageBD(this, "And", vars.getLanguage()) + " " + Utility.messageBD(this, "TheWarehouse", vars.getLanguage()) + " " + ReportShipmentDimensionalAnalyzeJRData.selectMwarehouse(this, strmWarehouseId); ReportShipmentDimensionalAnalyzeJRData[] data = null; String[] strShownArray = { "", "", "", "", "", "", "", "", "" }; if (strShown.startsWith("(")) strShown = strShown.substring(1, strShown.length() - 1); if (!strShown.equals("")) { strShown = Replace.replace(strShown, "'", ""); strShown = Replace.replace(strShown, " ", ""); StringTokenizer st = new StringTokenizer(strShown, ",", false); int intContador = 0; while (st.hasMoreTokens()) { strShownArray[intContador] = st.nextToken(); intContador++; } } ReportSalesDimensionalAnalyzeJRData[] dimensionLabel = null; if (vars.getLanguage().equals("en_US")) { dimensionLabel = ReportSalesDimensionalAnalyzeJRData.selectNotShown(this, ""); } else { dimensionLabel = ReportSalesDimensionalAnalyzeJRData.selectNotShownTrl(this, vars.getLanguage(), ""); } // Checking report limit first StringBuffer levelsconcat = new StringBuffer(); levelsconcat.append("''"); String[] strLevelLabel = { "", "", "", "", "", "", "", "", "" }; String[] strTextShow = { "", "", "", "", "", "", "", "", "" }; int intDiscard = 0; int intProductLevel = 10; int intAuxDiscard = -1; for (int i = 0; i < 9; i++) { if (strShownArray[i].equals("1")) { strTextShow[i] = "C_BP_GROUP.NAME"; intDiscard++; strLevelLabel[i] = dimensionLabel[0].name; levelsconcat.append(" || "); levelsconcat.append("C_BP_GROUP.C_BP_GROUP_ID"); } else if (strShownArray[i].equals("2")) { strTextShow[i] = "AD_COLUMN_IDENTIFIER(to_char('C_Bpartner'), to_char( C_BPARTNER.C_BPARTNER_ID), to_char('" + vars.getLanguage() + "'))"; intDiscard++; strLevelLabel[i] = dimensionLabel[1].name; levelsconcat.append(" || "); levelsconcat.append("C_BPARTNER.C_BPARTNER_ID"); } else if (strShownArray[i].equals("3")) { strTextShow[i] = "M_PRODUCT_CATEGORY.NAME"; intDiscard++; strLevelLabel[i] = dimensionLabel[2].name; levelsconcat.append(" || "); levelsconcat.append("M_PRODUCT_CATEGORY.M_PRODUCT_CATEGORY_ID"); } else if (strShownArray[i].equals("4")) { strTextShow[i] = "AD_COLUMN_IDENTIFIER(to_char('M_Product'), to_char( M_PRODUCT.M_PRODUCT_ID), to_char('" + vars.getLanguage() + "'))|| CASE WHEN uomsymbol IS NULL THEN '' ELSE to_char(' ('||uomsymbol||')') END"; intAuxDiscard = i; intDiscard++; intProductLevel = i + 1; strLevelLabel[i] = dimensionLabel[3].name; levelsconcat.append(" || "); levelsconcat.append("M_PRODUCT.M_PRODUCT_ID"); } else if (strShownArray[i].equals("5")) { strTextShow[i] = "M_INOUT.DOCUMENTNO"; intDiscard++; strLevelLabel[i] = dimensionLabel[4].name; levelsconcat.append(" || "); levelsconcat.append("M_INOUT.M_INOUT_ID"); } else if (strShownArray[i].equals("6")) { strTextShow[i] = "AD_USER.FIRSTNAME||' '||' '||AD_USER.LASTNAME"; intDiscard++; strLevelLabel[i] = dimensionLabel[5].name; levelsconcat.append(" || "); levelsconcat.append("AD_USER.AD_USER_ID"); } else if (strShownArray[i].equals("7")) { strTextShow[i] = "M_WAREHOUSE.NAME"; intDiscard++; strLevelLabel[i] = dimensionLabel[6].name; levelsconcat.append(" || "); levelsconcat.append("M_WAREHOUSE.M_WAREHOUSE_ID"); } else if (strShownArray[i].equals("8")) { strTextShow[i] = "AD_ORG.NAME"; intDiscard++; strLevelLabel[i] = dimensionLabel[7].name; levelsconcat.append(" || "); levelsconcat.append("AD_ORG.AD_ORG_ID"); } else if (strShownArray[i].equals("9")) { strTextShow[i] = "AD_USER.NAME"; intDiscard++; strLevelLabel[i] = dimensionLabel[8].name; levelsconcat.append(" || "); levelsconcat.append("AD_USER.AD_USER_ID"); } else { strTextShow[i] = "''"; discard[i] = "display:none;"; } } if (intDiscard != 0 || intAuxDiscard != -1) { int k = 1; if (intDiscard == 1) { strOrderby = " ORDER BY NIVEL" + k + ","; } else { strOrderby = " ORDER BY "; } while (k < intDiscard) { strOrderby = strOrderby + "NIVEL" + k + ","; k++; } if (k == 1) { if (strOrder.equals("Normal")) { strOrderby = " ORDER BY NIVEL" + k; } else if (strOrder.equals("Amountasc")) { strOrderby = " ORDER BY CONVAMOUNT ASC"; } else if (strOrder.equals("Amountdesc")) { strOrderby = " ORDER BY CONVAMOUNT DESC"; } else { strOrderby = "1"; } } else { if (strOrder.equals("Normal")) { strOrderby += "NIVEL" + k; } else if (strOrder.equals("Amountasc")) { strOrderby += "CONVAMOUNT ASC"; } else if (strOrder.equals("Amountdesc")) { strOrderby += "CONVAMOUNT DESC"; } else { strOrderby = "1"; } } } else { strOrderby = " ORDER BY 1"; } String strHaving = ""; if (!strMayor.equals("") && !strMenor.equals("")) { strHaving = " HAVING (SUM(CONVAMOUNT) > " + strMayor + " AND SUM(CONVAMOUNT) < " + strMenor + ")"; } else if (!strMayor.equals("") && strMenor.equals("")) { strHaving = " HAVING (SUM(CONVAMOUNT) > " + strMayor + ")"; } else if (strMayor.equals("") && !strMenor.equals("")) { strHaving = " HAVING (SUM(CONVAMOUNT) < " + strMenor + ")"; } /* * else { strHaving = " HAVING (SUM(CONVAMOUNT) <> 0 OR SUM(CONVAMOUNTREF) <> 0)"; } */ strOrderby = strHaving + strOrderby; int limit = 0; int mycount = 0; try { limit = Integer.parseInt(Utility.getPreference(vars, "ReportsLimit", "")); if (limit > 0) { mycount = Integer.parseInt((strComparative.equals("Y")) ? ReportShipmentDimensionalAnalyzeJRData.selectCount(this, levelsconcat.toString(), Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportShipmentDimensionalAnalyzeJR"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strmWarehouseId, strsalesrepId, strPartnerSalesrepId, strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strDateFromRef, DateTimeData.nDaysAfter(this, strDateToRef, "1")) : ReportShipmentDimensionalAnalyzeJRData.selectNoComparativeCount(this, levelsconcat.toString(), Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportShipmentDimensionalAnalyzeJR"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strmWarehouseId, strsalesrepId, strPartnerSalesrepId, strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"))); } } catch (NumberFormatException e) { } if (limit > 0 && mycount > limit) { String msgbody = Utility.messageBD(this, "ReportsLimitBody", vars.getLanguage()); msgbody = msgbody.replace("@rows@", Integer.toString(mycount)); msgbody = msgbody.replace("@limit@", Integer.toString(limit)); advisePopUp(request, response, "ERROR", Utility.messageBD(this, "ReportsLimitHeader", vars.getLanguage()), msgbody); } else { // Checks if there is a conversion rate for each of the transactions // of // the report String strConvRateErrorMsg = ""; OBError myMessage = null; myMessage = new OBError(); if (strComparative.equals("Y")) { try { data = ReportShipmentDimensionalAnalyzeJRData.select(this, strCurrencyId, strTextShow[0], strTextShow[1], strTextShow[2], strTextShow[3], strTextShow[4], strTextShow[5], strTextShow[6], strTextShow[7], strTextShow[8], Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportShipmentDimensionalAnalyzeJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strmWarehouseId, strsalesrepId, strPartnerSalesrepId, strDateFromRef, DateTimeData.nDaysAfter(this, strDateToRef, "1"), strOrderby); } catch (ServletException ex) { myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage()); } } else { try { data = ReportShipmentDimensionalAnalyzeJRData.selectNoComparative(this, strCurrencyId, strTextShow[0], strTextShow[1], strTextShow[2], strTextShow[3], strTextShow[4], strTextShow[5], strTextShow[6], strTextShow[7], strTextShow[8], Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportShipmentDimensionalAnalyzeJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strmWarehouseId, strsalesrepId, strPartnerSalesrepId, strOrderby); } catch (ServletException ex) { myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage()); } } strConvRateErrorMsg = myMessage.getMessage(); // If a conversion rate is missing for a certain transaction, an error // message window pops-up. if (!strConvRateErrorMsg.equals("") && strConvRateErrorMsg != null) { advisePopUp(request, response, "ERROR", Utility.messageBD(this, "NoConversionRateHeader", vars.getLanguage()), strConvRateErrorMsg); } else { // Otherwise, the report is launched String strReportPath = ""; if (strComparative.equals("Y")) { strReportPath = "@basedesign@/org/openbravo/erpCommon/ad_reports/WeightDimensionalComparative.jrxml"; } else { strReportPath = "@basedesign@/org/openbravo/erpCommon/ad_reports/WeightDimensionalNoComparative.jrxml"; } if (data == null || data.length == 0) { advisePopUp(request, response, "WARNING", Utility.messageBD(this, "ProcessStatus-W", vars.getLanguage()), Utility.messageBD(this, "NoDataFound", vars.getLanguage())); } else { HashMap<String, Object> parameters = new HashMap<String, Object>(); parameters.put("LEVEL1_LABEL", strLevelLabel[0]); parameters.put("LEVEL2_LABEL", strLevelLabel[1]); parameters.put("LEVEL3_LABEL", strLevelLabel[2]); parameters.put("LEVEL4_LABEL", strLevelLabel[3]); parameters.put("LEVEL5_LABEL", strLevelLabel[4]); parameters.put("LEVEL6_LABEL", strLevelLabel[5]); parameters.put("LEVEL7_LABEL", strLevelLabel[6]); parameters.put("LEVEL8_LABEL", strLevelLabel[7]); parameters.put("LEVEL9_LABEL", strLevelLabel[8]); parameters.put("DIMENSIONS", new Integer(intDiscard)); parameters.put("REPORT_SUBTITLE", strTitle); parameters.put("PRODUCT_LEVEL", new Integer(intProductLevel)); renderJR(vars, response, strReportPath, strOutput, parameters, data, null); } } } }
From source file:org.openbravo.erpCommon.ad_reports.ReportSalesDimensionalAnalyzeJR.java
private void printPageHtml(HttpServletRequest request, HttpServletResponse response, VariablesSecureApp vars, String strComparative, String strDateFrom, String strDateTo, String strPartnerGroup, String strcBpartnerId, String strProductCategory, String strmProductId, String strmWarehouseId, String strNotShown, String strShown, String strDateFromRef, String strDateToRef, String strOrg, String strsalesrepId, String strOrder, String strMayor, String strMenor, String strPartnerSalesrepId, String strCurrencyId, String strOutput) throws IOException, ServletException { if (log4j.isDebugEnabled()) log4j.debug("Output: print html"); String strOrderby = ""; String[] discard = { "", "", "", "", "", "", "", "", "", "", "" }; String[] discard1 = { "selEliminarBody1", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard" }; if (strOrg.equals("")) strOrg = vars.getOrg();/* ww w . j a v a 2 s . co m*/ if (strComparative.equals("Y")) discard1[0] = "selEliminarBody2"; String strTitle = ""; strTitle = Utility.messageBD(this, "From", vars.getLanguage()) + " " + strDateFrom + " " + Utility.messageBD(this, "To", vars.getLanguage()) + " " + strDateTo; if (!strPartnerGroup.equals("")) strTitle = strTitle + ", " + Utility.messageBD(this, "ForBPartnerGroup", vars.getLanguage()) + " " + ReportSalesDimensionalAnalyzeJRData.selectBpgroup(this, strPartnerGroup); if (!strProductCategory.equals("")) strTitle = strTitle + ", " + Utility.messageBD(this, "ProductCategory", vars.getLanguage()) + " " + ReportSalesDimensionalAnalyzeJRData.selectProductCategory(this, strProductCategory); if (!strsalesrepId.equals("")) strTitle = strTitle + ", " + Utility.messageBD(this, "TheSalesRep", vars.getLanguage()) + " " + ReportSalesDimensionalAnalyzeJRData.selectSalesrep(this, strsalesrepId); if (!strPartnerSalesrepId.equals("")) strTitle = strTitle + ", " + Utility.messageBD(this, "TheClientSalesRep", vars.getLanguage()) + " " + ReportSalesDimensionalAnalyzeJRData.selectSalesrep(this, strPartnerSalesrepId); if (!strmWarehouseId.equals("")) strTitle = strTitle + " " + Utility.messageBD(this, "And", vars.getLanguage()) + " " + Utility.messageBD(this, "TheWarehouse", vars.getLanguage()) + " " + ReportSalesDimensionalAnalyzeJRData.selectMwarehouse(this, strmWarehouseId); ReportSalesDimensionalAnalyzeJRData[] data = null; String[] strShownArray = { "", "", "", "", "", "", "", "", "", "", "" }; if (strShown.startsWith("(")) strShown = strShown.substring(1, strShown.length() - 1); if (!strShown.equals("")) { strShown = Replace.replace(strShown, "'", ""); strShown = Replace.replace(strShown, " ", ""); StringTokenizer st = new StringTokenizer(strShown, ",", false); int intContador = 0; while (st.hasMoreTokens()) { strShownArray[intContador] = st.nextToken(); intContador++; } } ReportSalesDimensionalAnalyzeJRData[] dimensionLabel = null; if (vars.getLanguage().equals("en_US")) { dimensionLabel = ReportSalesDimensionalAnalyzeJRData.selectNotShown(this, ""); } else { dimensionLabel = ReportSalesDimensionalAnalyzeJRData.selectNotShownTrl(this, vars.getLanguage(), ""); } // Checking report limit first StringBuffer levelsconcat = new StringBuffer(); levelsconcat.append("''"); String[] strLevelLabel = { "", "", "", "", "", "", "", "", "", "", "" }; String[] strTextShow = { "", "", "", "", "", "", "", "", "", "", "" }; int intDiscard = 0; int intProductLevel = 12; int intAuxDiscard = -1; for (int i = 0; i < 11; i++) { if (strShownArray[i].equals("1")) { strTextShow[i] = "C_BP_GROUP.NAME"; intDiscard++; strLevelLabel[i] = dimensionLabel[0].name; levelsconcat.append(" || "); levelsconcat.append("C_BP_GROUP.C_BP_GROUP_ID"); } else if (strShownArray[i].equals("2")) { strTextShow[i] = "AD_COLUMN_IDENTIFIER(to_char('C_Bpartner'), to_char( C_BPARTNER.C_BPARTNER_ID), to_char('" + vars.getLanguage() + "'))"; intDiscard++; strLevelLabel[i] = dimensionLabel[1].name; levelsconcat.append(" || "); levelsconcat.append("C_BPARTNER.C_BPARTNER_ID"); } else if (strShownArray[i].equals("3")) { strTextShow[i] = "M_PRODUCT_CATEGORY.NAME"; intDiscard++; strLevelLabel[i] = dimensionLabel[2].name; levelsconcat.append(" || "); levelsconcat.append("M_PRODUCT_CATEGORY.M_PRODUCT_CATEGORY_ID"); } else if (strShownArray[i].equals("4")) { strTextShow[i] = "AD_COLUMN_IDENTIFIER(to_char('M_Product'), to_char( M_PRODUCT.M_PRODUCT_ID), to_char('" + vars.getLanguage() + "'))|| CASE WHEN uomsymbol IS NULL THEN '' ELSE to_char(' ('||uomsymbol||')') END"; intAuxDiscard = i; intDiscard++; intProductLevel = i + 1; strLevelLabel[i] = dimensionLabel[3].name; levelsconcat.append(" || "); levelsconcat.append("M_PRODUCT.M_PRODUCT_ID"); } else if (strShownArray[i].equals("5")) { strTextShow[i] = "C_ORDER.DOCUMENTNO"; intDiscard++; strLevelLabel[i] = dimensionLabel[4].name; levelsconcat.append(" || "); levelsconcat.append("C_ORDER.C_ORDER_ID"); } else if (strShownArray[i].equals("6")) { strTextShow[i] = "AD_USER.FIRSTNAME||' '||' '||AD_USER.LASTNAME"; intDiscard++; strLevelLabel[i] = dimensionLabel[5].name; levelsconcat.append(" || "); levelsconcat.append("AD_USER.AD_USER_ID"); } else if (strShownArray[i].equals("7")) { strTextShow[i] = "M_WAREHOUSE.NAME"; intDiscard++; strLevelLabel[i] = dimensionLabel[6].name; levelsconcat.append(" || "); levelsconcat.append("M_WAREHOUSE.M_WAREHOUSE_ID"); } else if (strShownArray[i].equals("8")) { strTextShow[i] = "AD_ORG.NAME"; intDiscard++; strLevelLabel[i] = dimensionLabel[7].name; levelsconcat.append(" || "); levelsconcat.append("AD_ORG.AD_ORG_ID"); } else if (strShownArray[i].equals("9")) { strTextShow[i] = "AD_USER.NAME"; intDiscard++; strLevelLabel[i] = dimensionLabel[8].name; levelsconcat.append(" || "); levelsconcat.append("AD_USER.AD_USER_ID"); } else if (strShownArray[i].equals("10")) { strTextShow[i] = "AD_COLUMN_IDENTIFIER(to_char('C_PROJECT'), to_char(C_ORDER.C_PROJECT_ID), to_char( '" + vars.getLanguage() + "'))"; intDiscard++; strLevelLabel[i] = dimensionLabel[9].name; levelsconcat.append(" || "); levelsconcat.append("C_ORDER.C_PROJECT_ID"); } else if (strShownArray[i].equals("11")) { strTextShow[i] = "AD_COLUMN_IDENTIFIER(to_char('C_Bpartner_Location'), to_char( C_ORDER.C_BPARTNER_LOCATION_ID), to_char( '" + vars.getLanguage() + "'))"; intDiscard++; strLevelLabel[i] = dimensionLabel[10].name; levelsconcat.append(" || "); levelsconcat.append("C_ORDER.C_BPARTNER_LOCATION_ID"); } else { strTextShow[i] = "''"; discard[i] = "display:none;"; } } if (intDiscard != 0 || intAuxDiscard != -1) { int k = 1; if (intDiscard == 1) { strOrderby = " ORDER BY NIVEL" + k + ","; } else { strOrderby = " ORDER BY "; } while (k < intDiscard) { strOrderby = strOrderby + "NIVEL" + k + ","; k++; } if (k == 1) { if (strOrder.equals("Normal")) { strOrderby = " ORDER BY NIVEL" + k; } else if (strOrder.equals("Amountasc")) { strOrderby = " ORDER BY CONVAMOUNT ASC"; } else if (strOrder.equals("Amountdesc")) { strOrderby = " ORDER BY CONVAMOUNT DESC"; } else { strOrderby = "1"; } } else { if (strOrder.equals("Normal")) { strOrderby += "NIVEL" + k; } else if (strOrder.equals("Amountasc")) { strOrderby += "CONVAMOUNT ASC"; } else if (strOrder.equals("Amountdesc")) { strOrderby += "CONVAMOUNT DESC"; } else { strOrderby = "1"; } } } else { strOrderby = " ORDER BY 1"; } String strHaving = ""; if (!strMayor.equals("") && !strMenor.equals("")) { strHaving = " HAVING (SUM(CONVAMOUNT) > " + strMayor + " AND SUM(CONVAMOUNT) < " + strMenor + ")"; } else if (!strMayor.equals("") && strMenor.equals("")) { strHaving = " HAVING (SUM(CONVAMOUNT) > " + strMayor + ")"; } else if (strMayor.equals("") && !strMenor.equals("")) { strHaving = " HAVING (SUM(CONVAMOUNT) < " + strMenor + ")"; } else { strHaving = " HAVING (SUM(CONVAMOUNT) <> 0 OR SUM(CONVAMOUNTREF) <> 0)"; } strOrderby = strHaving + strOrderby; int limit = 0; int mycount = 0; try { limit = Integer.parseInt(Utility.getPreference(vars, "ReportsLimit", "")); if (limit > 0) { mycount = Integer .parseInt((strComparative.equals("Y")) ? ReportSalesDimensionalAnalyzeJRData.selectCount(this, levelsconcat.toString(), Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportSalesDimensionalAnalyzeJR"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strmWarehouseId, strsalesrepId, strPartnerSalesrepId, strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strDateFromRef, DateTimeData.nDaysAfter(this, strDateToRef, "1")) : ReportSalesDimensionalAnalyzeJRData.selectNoComparativeCount(this, levelsconcat.toString(), Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportSalesDimensionalAnalyzeJR"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strmWarehouseId, strsalesrepId, strPartnerSalesrepId, strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"))); } } catch (NumberFormatException e) { } if (limit > 0 && mycount > limit) { String msgbody = Utility.messageBD(this, "ReportsLimitBody", vars.getLanguage()); msgbody = msgbody.replace("@rows@", Integer.toString(mycount)); msgbody = msgbody.replace("@limit@", Integer.toString(limit)); advisePopUp(request, response, "ERROR", Utility.messageBD(this, "ReportsLimitHeader", vars.getLanguage()), msgbody); } else { // Checks if there is a conversion rate for each of the transactions // of // the report String strConvRateErrorMsg = ""; OBError myMessage = null; myMessage = new OBError(); if (strComparative.equals("Y")) { try { data = ReportSalesDimensionalAnalyzeJRData.select(this, strCurrencyId, strTextShow[0], strTextShow[1], strTextShow[2], strTextShow[3], strTextShow[4], strTextShow[5], strTextShow[6], strTextShow[7], strTextShow[8], strTextShow[9], strTextShow[10], Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportSalesDimensionalAnalyzeJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strmWarehouseId, strsalesrepId, strPartnerSalesrepId, strDateFromRef, DateTimeData.nDaysAfter(this, strDateToRef, "1"), strOrderby); } catch (ServletException ex) { myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage()); } } else { try { data = ReportSalesDimensionalAnalyzeJRData.selectNoComparative(this, strCurrencyId, strTextShow[0], strTextShow[1], strTextShow[2], strTextShow[3], strTextShow[4], strTextShow[5], strTextShow[6], strTextShow[7], strTextShow[8], strTextShow[9], strTextShow[10], Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportSalesDimensionalAnalyzeJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strmWarehouseId, strsalesrepId, strPartnerSalesrepId, strOrderby); } catch (ServletException ex) { myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage()); } } strConvRateErrorMsg = myMessage.getMessage(); // If a conversion rate is missing for a certain transaction, an error // message window pops-up. if (!strConvRateErrorMsg.equals("") && strConvRateErrorMsg != null) { advisePopUp(request, response, "ERROR", Utility.messageBD(this, "NoConversionRateHeader", vars.getLanguage()), strConvRateErrorMsg); } else { // Otherwise, the report is launched String strReportPath; if (strComparative.equals("Y")) { strReportPath = "@basedesign@/org/openbravo/erpCommon/ad_reports/WeightDimensionalComparative.jrxml"; } else { strReportPath = "@basedesign@/org/openbravo/erpCommon/ad_reports/WeightDimensionalNoComparative.jrxml"; } if (data == null || data.length == 0) { advisePopUp(request, response, "WARNING", Utility.messageBD(this, "ProcessStatus-W", vars.getLanguage()), Utility.messageBD(this, "NoDataFound", vars.getLanguage())); } else { HashMap<String, Object> parameters = new HashMap<String, Object>(); parameters.put("LEVEL1_LABEL", strLevelLabel[0]); parameters.put("LEVEL2_LABEL", strLevelLabel[1]); parameters.put("LEVEL3_LABEL", strLevelLabel[2]); parameters.put("LEVEL4_LABEL", strLevelLabel[3]); parameters.put("LEVEL5_LABEL", strLevelLabel[4]); parameters.put("LEVEL6_LABEL", strLevelLabel[5]); parameters.put("LEVEL7_LABEL", strLevelLabel[6]); parameters.put("LEVEL8_LABEL", strLevelLabel[7]); parameters.put("LEVEL9_LABEL", strLevelLabel[8]); parameters.put("LEVEL10_LABEL", strLevelLabel[9]); parameters.put("LEVEL11_LABEL", strLevelLabel[10]); parameters.put("DIMENSIONS", new Integer(intDiscard)); parameters.put("REPORT_SUBTITLE", strTitle); parameters.put("PRODUCT_LEVEL", new Integer(intProductLevel)); renderJR(vars, response, strReportPath, strOutput, parameters, data, null); } } } }
From source file:org.openbravo.advpaymentmngt.ad_actionbutton.ProcessInvoice.java
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { VariablesSecureApp vars = new VariablesSecureApp(request); if (vars.commandIn("DEFAULT")) { final String strWindowId = vars.getGlobalVariable("inpwindowId", "ProcessInvoice|Window_ID", IsIDFilter.instance);/* w ww . j av a 2 s.c om*/ final String strTabId = vars.getGlobalVariable("inpTabId", "ProcessInvoice|Tab_ID", IsIDFilter.instance); final String strC_Invoice_ID = vars.getGlobalVariable("inpcInvoiceId", strWindowId + "|C_Invoice_ID", "", IsIDFilter.instance); final String strdocaction = vars.getStringParameter("inpdocaction"); final String strProcessing = vars.getStringParameter("inpprocessing", "Y"); final String strOrg = vars.getRequestGlobalVariable("inpadOrgId", "ProcessInvoice|Org_ID", IsIDFilter.instance); final String strClient = vars.getStringParameter("inpadClientId", IsIDFilter.instance); final String strdocstatus = vars.getRequiredStringParameter("inpdocstatus"); final String stradTableId = "318"; final int accesslevel = 1; if ((org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), strTabId)) || !(Utility.isElementInList( Utility.getContext(this, vars, "#User_Client", strWindowId, accesslevel), strClient) && Utility.isElementInList( Utility.getContext(this, vars, "#User_Org", strWindowId, accesslevel), strOrg))) { OBError myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage())); vars.setMessage(strTabId, myError); printPageClosePopUp(response, vars); } else { printPageDocAction(response, vars, strC_Invoice_ID, strdocaction, strProcessing, strdocstatus, stradTableId, strWindowId); } } else if (vars.commandIn("SAVE_BUTTONDocAction111")) { final String strWindowId = vars.getGlobalVariable("inpwindowId", "ProcessInvoice|Window_ID", IsIDFilter.instance); final String strTabId = vars.getGlobalVariable("inpTabId", "ProcessInvoice|Tab_ID", IsIDFilter.instance); final String strC_Invoice_ID = vars.getGlobalVariable("inpKey", strWindowId + "|C_Invoice_ID", ""); final String strdocaction = vars.getStringParameter("inpdocaction"); final String strVoidInvoiceDate = vars.getStringParameter("inpVoidedDocumentDate"); final String strVoidInvoiceAcctDate = vars.getStringParameter("inpVoidedDocumentAcctDate"); final String strOrg = vars.getGlobalVariable("inpadOrgId", "ProcessInvoice|Org_ID", IsIDFilter.instance); OBError myMessage = null; try { Invoice invoice = dao.getObject(Invoice.class, strC_Invoice_ID); invoice.setDocumentAction(strdocaction); OBDal.getInstance().save(invoice); OBDal.getInstance().flush(); OBError msg = null; for (ProcessInvoiceHook hook : hooks) { msg = hook.preProcess(invoice, strdocaction); if (msg != null && "Error".equals(msg.getType())) { vars.setMessage(strTabId, msg); String strWindowPath = Utility.getTabURL(strTabId, "R", true); if (strWindowPath.equals("")) strWindowPath = strDefaultServlet; printPageClosePopUp(response, vars, strWindowPath); return; } } // check BP currency if ("CO".equals(strdocaction)) { // check BP currency if (invoice.getBusinessPartner().getCurrency() == null) { String errorMSG = Utility.messageBD(this, "InitBPCurrencyLnk", vars.getLanguage(), false); msg = new OBError(); msg.setType("Error"); msg.setTitle(Utility.messageBD(this, "Error", vars.getLanguage())); msg.setMessage(String.format(errorMSG, invoice.getBusinessPartner().getId(), invoice.getBusinessPartner().getName())); vars.setMessage(strTabId, msg); printPageClosePopUp(response, vars, Utility.getTabURL(strTabId, "R", true)); return; } } OBContext.setAdminMode(true); Process process = null; try { process = dao.getObject(Process.class, "111"); } finally { OBContext.restorePreviousMode(); } Map<String, String> parameters = null; if (!strVoidInvoiceDate.isEmpty() && !strVoidInvoiceAcctDate.isEmpty()) { Date voidDate = null; Date voidAcctDate = null; try { voidDate = OBDateUtils.getDate(strVoidInvoiceDate); voidAcctDate = OBDateUtils.getDate(strVoidInvoiceAcctDate); } catch (ParseException pe) { voidDate = new Date(); voidAcctDate = new Date(); log4j.error("Not possible to parse the following date: " + strVoidInvoiceDate, pe); log4j.error("Not possible to parse the following date: " + strVoidInvoiceAcctDate, pe); } parameters = new HashMap<String, String>(); parameters.put("voidedDocumentDate", OBDateUtils.formatDate(voidDate, "yyyy-MM-dd")); parameters.put("voidedDocumentAcctDate", OBDateUtils.formatDate(voidAcctDate, "yyyy-MM-dd")); } final ProcessInstance pinstance = CallProcess.getInstance().call(process, strC_Invoice_ID, parameters); OBDal.getInstance().getSession().refresh(invoice); invoice.setAPRMProcessinvoice(invoice.getDocumentAction()); // Remove invoice's used credit description if ("RE".equals(strdocaction) && pinstance.getResult() != 0L) { final String invDesc = invoice.getDescription(); if (invDesc != null) { final String creditMsg = Utility.messageBD(this, "APRM_InvoiceDescUsedCredit", vars.getLanguage()); if (creditMsg != null) { final StringBuffer newDesc = new StringBuffer(); for (final String line : invDesc.split("\n")) { if (!line.startsWith(creditMsg.substring(0, creditMsg.lastIndexOf("%s")))) { newDesc.append(line); if (!"".equals(line)) newDesc.append("\n"); } } invoice.setDescription(newDesc.toString()); } } } OBDal.getInstance().save(invoice); OBDal.getInstance().flush(); OBContext.setAdminMode(); try { // on error close popup if (pinstance.getResult() == 0L) { OBDal.getInstance().commitAndClose(); final PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance.getId()); myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData); log4j.debug(myMessage.getMessage()); vars.setMessage(strTabId, myMessage); String strWindowPath = Utility.getTabURL(strTabId, "R", true); if (strWindowPath.equals("")) strWindowPath = strDefaultServlet; printPageClosePopUp(response, vars, strWindowPath); return; } } finally { OBContext.restorePreviousMode(); } for (ProcessInvoiceHook hook : hooks) { msg = hook.postProcess(invoice, strdocaction); if (msg != null && "Error".equals(msg.getType())) { vars.setMessage(strTabId, msg); String strWindowPath = Utility.getTabURL(strTabId, "R", true); if (strWindowPath.equals("")) strWindowPath = strDefaultServlet; printPageClosePopUp(response, vars, strWindowPath); OBDal.getInstance().rollbackAndClose(); return; } } OBDal.getInstance().commitAndClose(); final PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance.getId()); myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData); log4j.debug(myMessage.getMessage()); vars.setMessage(strTabId, myMessage); OBContext.setAdminMode(); try { if (!"CO".equals(strdocaction)) { String strWindowPath = Utility.getTabURL(strTabId, "R", true); if (strWindowPath.equals("")) strWindowPath = strDefaultServlet; printPageClosePopUp(response, vars, strWindowPath); return; } } finally { OBContext.restorePreviousMode(); } if ("CO".equals(strdocaction)) { // Need to refresh the invoice again from the db invoice = dao.getObject(Invoice.class, strC_Invoice_ID); OBContext.setAdminMode(false); String invoiceDocCategory = ""; try { invoiceDocCategory = invoice.getDocumentType().getDocumentCategory(); /* * Print a grid popup in case of credit payment */ // If the invoice grand total is ZERO or already has payments (due to // payment method automation) or the business partner does not have a default financial // account defined or invoice's payment method is not inside BP's financial // account do not cancel credit if (BigDecimal.ZERO.compareTo(invoice.getGrandTotalAmount()) != 0 && isPaymentMethodConfigured(invoice) && !isInvoiceWithPayments(invoice) && (AcctServer.DOCTYPE_ARInvoice.equals(invoiceDocCategory) || AcctServer.DOCTYPE_APInvoice.equals(invoiceDocCategory))) { creditPayments = dao.getCustomerPaymentsWithCredit(invoice.getOrganization(), invoice.getBusinessPartner(), invoice.isSalesTransaction()); if (creditPayments != null && !creditPayments.isEmpty()) { printPageCreditPaymentGrid(response, vars, strC_Invoice_ID, strdocaction, strTabId, strC_Invoice_ID, strdocaction, strWindowId, strTabId, invoice.getInvoiceDate(), strOrg); } } } finally { OBContext.restorePreviousMode(); } executePayments(response, vars, strWindowId, strTabId, strC_Invoice_ID, strOrg); } } catch (ServletException ex) { myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage()); if (!myMessage.isConnectionAvailable()) { bdErrorConnection(response); return; } else vars.setMessage(strTabId, myMessage); } } else if (vars.commandIn("GRIDLIST")) { final String strWindowId = vars.getGlobalVariable("inpwindowId", "ProcessInvoice|Window_ID", IsIDFilter.instance); final String strC_Invoice_ID = vars.getGlobalVariable("inpKey", strWindowId + "|C_Invoice_ID", "", IsIDFilter.instance); printGrid(response, vars, strC_Invoice_ID); } else if (vars.commandIn("USECREDITPAYMENTS") || vars.commandIn("CANCEL_USECREDITPAYMENTS")) { final String strWindowId = vars.getGlobalVariable("inpwindowId", "ProcessInvoice|Window_ID", IsIDFilter.instance); final String strTabId = vars.getGlobalVariable("inpTabId", "ProcessInvoice|Tab_ID", IsIDFilter.instance); final String strC_Invoice_ID = vars.getGlobalVariable("inpKey", strWindowId + "|C_Invoice_ID", ""); final String strPaymentDate = vars.getRequiredStringParameter("inpPaymentDate"); final String strOrg = vars.getGlobalVariable("inpadOrgId", "ProcessInvoice|Org_ID", IsIDFilter.instance); final String strCreditPaymentIds; if (vars.commandIn("CANCEL_USECREDITPAYMENTS")) { strCreditPaymentIds = null; } else { strCreditPaymentIds = vars.getInParameter("inpCreditPaymentId", IsIDFilter.instance); } /* * Use credit logic */ if (strCreditPaymentIds != null && !strCreditPaymentIds.isEmpty()) { List<FIN_Payment> selectedCreditPayment = FIN_Utility.getOBObjectList(FIN_Payment.class, strCreditPaymentIds); HashMap<String, BigDecimal> selectedCreditPaymentAmounts = FIN_AddPayment .getSelectedBaseOBObjectAmount(vars, selectedCreditPayment, "inpPaymentAmount"); try { OBContext.setAdminMode(true); final Invoice invoice = OBDal.getInstance().get(Invoice.class, strC_Invoice_ID); final StringBuffer creditPaymentsIdentifiers = new StringBuffer(); BigDecimal totalUsedCreditAmt = BigDecimal.ZERO; for (final FIN_Payment creditPayment : selectedCreditPayment) { final BigDecimal usedCreditAmt = selectedCreditPaymentAmounts.get(creditPayment.getId()); // Set Used Credit = Amount + Previous used credit introduced by the user creditPayment.setUsedCredit(usedCreditAmt.add(creditPayment.getUsedCredit())); final StringBuffer description = new StringBuffer(); if (creditPayment.getDescription() != null && !creditPayment.getDescription().equals("")) description.append(creditPayment.getDescription()).append("\n"); description.append(String.format( Utility.messageBD(this, "APRM_CreditUsedinInvoice", vars.getLanguage()), invoice.getDocumentNo())); String truncateDescription = (description.length() > 255) ? description.substring(0, 251).concat("...").toString() : description.toString(); creditPayment.setDescription(truncateDescription); totalUsedCreditAmt = totalUsedCreditAmt.add(usedCreditAmt); creditPaymentsIdentifiers.append(creditPayment.getDocumentNo()); creditPaymentsIdentifiers.append(", "); } creditPaymentsIdentifiers.delete(creditPaymentsIdentifiers.length() - 2, creditPaymentsIdentifiers.length()); creditPaymentsIdentifiers.append("\n"); final List<FIN_PaymentScheduleDetail> paymentScheduleDetails = new ArrayList<FIN_PaymentScheduleDetail>(); final HashMap<String, BigDecimal> paymentScheduleDetailsAmounts = new HashMap<String, BigDecimal>(); BigDecimal allocatedAmt = BigDecimal.ZERO; for (final FIN_PaymentScheduleDetail paymentScheduleDetail : dao .getInvoicePendingScheduledPaymentDetails(invoice)) { if (totalUsedCreditAmt.compareTo(allocatedAmt) > 0) { final BigDecimal pendingToAllocate = totalUsedCreditAmt.subtract(allocatedAmt); paymentScheduleDetails.add(paymentScheduleDetail); final BigDecimal psdAmt = paymentScheduleDetail.getAmount(); if (psdAmt.compareTo(pendingToAllocate) <= 0) { paymentScheduleDetailsAmounts.put(paymentScheduleDetail.getId(), psdAmt); allocatedAmt = allocatedAmt.add(psdAmt); } else { paymentScheduleDetailsAmounts.put(paymentScheduleDetail.getId(), pendingToAllocate); allocatedAmt = allocatedAmt.add(pendingToAllocate); } } } // Create new Payment final boolean isSalesTransaction = invoice.isSalesTransaction(); final DocumentType docType = FIN_Utility.getDocumentType(invoice.getOrganization(), isSalesTransaction ? AcctServer.DOCTYPE_ARReceipt : AcctServer.DOCTYPE_APPayment); final String strPaymentDocumentNo = FIN_Utility.getDocumentNo(docType, docType.getTable() != null ? docType.getTable().getDBTableName() : ""); final FIN_FinancialAccount bpFinAccount = isSalesTransaction ? invoice.getBusinessPartner().getAccount() : invoice.getBusinessPartner().getPOFinancialAccount(); // Calculate Conversion Rate final ConversionRate conversionRate = StringUtils.equals(invoice.getCurrency().getId(), bpFinAccount.getCurrency().getId()) ? null : FinancialUtils.getConversionRate(FIN_Utility.getDate(strPaymentDate), invoice.getCurrency(), bpFinAccount.getCurrency(), invoice.getOrganization(), invoice.getClient()); final FIN_Payment newPayment = FIN_AddPayment.savePayment(null, isSalesTransaction, docType, strPaymentDocumentNo, invoice.getBusinessPartner(), invoice.getPaymentMethod(), bpFinAccount, "0", FIN_Utility.getDate(strPaymentDate), invoice.getOrganization(), invoice.getDocumentNo(), paymentScheduleDetails, paymentScheduleDetailsAmounts, false, false, invoice.getCurrency(), conversionRate != null ? conversionRate.getMultipleRateBy() : null, null); newPayment.setAmount(BigDecimal.ZERO); newPayment.setGeneratedCredit(BigDecimal.ZERO); newPayment.setUsedCredit(totalUsedCreditAmt); // Link new Payment with the credit payments used for (final FIN_Payment creditPayment : selectedCreditPayment) { final BigDecimal usedCreditAmt = selectedCreditPaymentAmounts.get(creditPayment.getId()); FIN_PaymentProcess.linkCreditPayment(newPayment, usedCreditAmt, creditPayment); } // Process the new payment OBError message = FIN_AddPayment.processPayment(vars, this, "P", newPayment); if ("Success".equals(message.getType())) { // Update Invoice's description final StringBuffer invDesc = new StringBuffer(); if (invoice.getDescription() != null) { invDesc.append(invoice.getDescription()); invDesc.append("\n"); } invDesc.append(String.format( Utility.messageBD(this, "APRM_InvoiceDescUsedCredit", vars.getLanguage()), creditPaymentsIdentifiers.toString())); invoice.setDescription(invDesc.toString()); } else { message.setMessage(OBMessageUtils.messageBD("PaymentError") + " " + message.getMessage()); vars.setMessage(strTabId, message); } } catch (final Exception e) { log4j.error("Exception while canceling the credit in the invoice: " + strC_Invoice_ID); e.printStackTrace(); } finally { OBContext.restorePreviousMode(); } } executePayments(response, vars, strWindowId, strTabId, strC_Invoice_ID, strOrg); } }
From source file:jp.terasoluna.fw.web.struts.plugins.ResetterPlugInTest.java
/** * testInitResources01()/*w ww .ja va 2s . c o m*/ * <br><br> * * (?n) * <br> * _?FG * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resourcePath:null<br> * (?) digesterRules:?|<br> * (?) ServletContext#getResource():?|<br> * * <br> * l?F(?) RESETTER_RESOURCES:?|<br> * (?) digesterRules:?|<br> * (?) O:ServletException<br> * ?bZ?[W?F"resources file location is not specified"<br> * (?) ?O:??O?<br> * G?[?O?F"resources file location is not specified"<br> * * <br> * this.resourcesPathnullServletException?mF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResources01() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); // reset.xmlpX? UTUtil.setPrivateField(plugin, "resourcesPath", null); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); // eXg?s try { plugin.initResources(servlet, conf); fail(); } catch (ServletException e) { assertEquals("resources file location is not specified", e.getMessage()); assertTrue(LogUTUtil.checkError("resources file location is not specified")); } }
From source file:jp.terasoluna.fw.web.struts.plugins.ResetterPlugInTest.java
/** * testInitResources02()// w ww . j a v a 2 s . c o m * <br><br> * * (?n) * <br> * _?FG * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resourcePath:""<br> * (?) digesterRules:?|<br> * (?) ServletContext#getResource():?|<br> * * <br> * l?F(?) RESETTER_RESOURCES:?|<br> * (?) digesterRules:?|<br> * (?) O:ServletException<br> * ?bZ?[W?F"resources file location is not specified"<br> * (?) ?O:??O?<br> * G?[?O?F"resources file location is not specified"<br> * * <br> * this.resourcesPathServletException?mF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResources02() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); // reset.xmlpX? UTUtil.setPrivateField(plugin, "resourcesPath", ""); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); // eXg?s try { plugin.initResources(servlet, conf); fail(); } catch (ServletException e) { assertEquals("resources file location is not specified", e.getMessage()); assertTrue(LogUTUtil.checkError("resources file location is not specified")); } }
From source file:org.apache.tomcat.maven.plugin.tomcat7.run.AbstractRunMojo.java
/** * {@inheritDoc}/*from w w w . j a va 2 s . c om*/ */ public void execute() throws MojoExecutionException, MojoFailureException { if (skip) { getLog().info("skip execution"); return; } // ensure project is a web application if (!isWar() && !addContextWarDependencies && getAdditionalWebapps().isEmpty()) { getLog().info(messagesProvider.getMessage("AbstractRunMojo.nonWar")); return; } ClassLoader originalClassLoader = null; if (useSeparateTomcatClassLoader) { originalClassLoader = Thread.currentThread().getContextClassLoader(); } try { getLog().info(messagesProvider.getMessage("AbstractRunMojo.runningWar", getWebappUrl())); initConfiguration(); startContainer(); if (!fork) { waitIndefinitely(); } } catch (LifecycleException exception) { throw new MojoExecutionException(messagesProvider.getMessage("AbstractRunMojo.cannotStart"), exception); } catch (IOException exception) { throw new MojoExecutionException( messagesProvider.getMessage("AbstractRunMojo.cannotCreateConfiguration"), exception); } catch (ServletException e) { throw new MojoExecutionException(e.getMessage(), e); } catch (MavenFilteringException e) { throw new MojoExecutionException("filtering issue: " + e.getMessage(), e); } finally { if (useSeparateTomcatClassLoader) { Thread.currentThread().setContextClassLoader(originalClassLoader); } } }
From source file:org.openbravo.erpCommon.ad_reports.ReportInvoiceCustomerDimensionalAnalysesJR.java
private void printPageHtml(HttpServletRequest request, HttpServletResponse response, VariablesSecureApp vars, String strComparative, String strDateFrom, String strDateTo, String strPartnerGroup, String strcBpartnerId, String strProductCategory, String strmProductId, String strNotShown, String strShown, String strDateFromRef, String strDateToRef, String strDateFromRef2, String strDateToRef2, String strDateFromRef3, String strDateToRef3, String strOrg, String strsalesrepId, String strcProjectId, String strProducttype, String strcDocTypeId, String strOrder, String strMayor, String strMenor, String strPartnerSalesrepId, String strCurrencyId, String strVoid, String strOutput) throws IOException, ServletException { if (log4j.isDebugEnabled()) log4j.debug("Output: print html"); String strOrderby = ""; String[] discard = { "", "", "", "", "", "", "", "", "", "" }; String[] discard1 = { "selEliminarBody1", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard" }; if (strOrg.equals("")) strOrg = vars.getOrg();/*w ww . j a v a 2 s . co m*/ boolean multiComparative2 = false; boolean multiComparative3 = false; if (strComparative.equals("Y")) { discard1[0] = "selEliminarBody2"; if (StringUtils.isNotBlank(strDateFromRef2) && StringUtils.isNotBlank(strDateToRef2)) { multiComparative2 = true; if (StringUtils.isNotBlank(strDateFromRef3) && StringUtils.isNotBlank(strDateToRef3)) { multiComparative3 = true; } else { strDateFromRef3 = ""; strDateToRef3 = ""; } } else { strDateFromRef2 = ""; strDateToRef2 = ""; strDateFromRef3 = ""; strDateToRef3 = ""; } } String strTitle = ""; strTitle = Utility.messageBD(this, "From", vars.getLanguage()) + " " + strDateFrom + " " + Utility.messageBD(this, "to", vars.getLanguage()) + " " + strDateTo; if (!strPartnerGroup.equals("")) strTitle = strTitle + ", " + Utility.messageBD(this, "ForBPartnerGroup", vars.getLanguage()) + " " + ReportInvoiceCustomerDimensionalAnalysesJRData.selectBpgroup(this, strPartnerGroup); if (!strProductCategory.equals("")) strTitle = strTitle + ", " + Utility.messageBD(this, "ProductCategory", vars.getLanguage()) + " " + ReportInvoiceCustomerDimensionalAnalysesJRData.selectProductCategory(this, strProductCategory); if (!strcProjectId.equals("")) strTitle = strTitle + ", " + Utility.messageBD(this, "Project", vars.getLanguage()) + " " + ReportInvoiceCustomerDimensionalAnalysesJRData.selectProject(this, strcProjectId); if (!strProducttype.equals("")) strTitle = strTitle + ", " + Utility.messageBD(this, "PRODUCTTYPE", vars.getLanguage()) + " " + ReportInvoiceCustomerDimensionalAnalysesJRData.selectProducttype(this, "270", vars.getLanguage(), strProducttype); if (!strsalesrepId.equals("")) strTitle = strTitle + ", " + Utility.messageBD(this, "TheClientSalesRep", vars.getLanguage()) + " " + ReportInvoiceCustomerDimensionalAnalysesJRData.selectSalesrep(this, strsalesrepId); if (!strPartnerSalesrepId.equals("")) strTitle = strTitle + " " + Utility.messageBD(this, "And", vars.getLanguage()) + " " + Utility.messageBD(this, "TheClientSalesRep", vars.getLanguage()) + " " + ReportInvoiceCustomerDimensionalAnalysesJRData.selectSalesrep(this, strPartnerSalesrepId); ReportInvoiceCustomerDimensionalAnalysesJRData[] data = null; ReportInvoiceCustomerDimensionalAnalysesJRData dataXLS = null; String[] strShownArray = { "", "", "", "", "", "", "", "", "", "" }; if (strShown.startsWith("(")) strShown = strShown.substring(1, strShown.length() - 1); if (!strShown.equals("")) { strShown = Replace.replace(strShown, "'", ""); strShown = Replace.replace(strShown, " ", ""); StringTokenizer st = new StringTokenizer(strShown, ",", false); int intContador = 0; while (st.hasMoreTokens()) { strShownArray[intContador] = st.nextToken(); intContador++; } } ReportInvoiceCustomerDimensionalAnalysesJRData[] dimensionLabel = null; if (vars.getLanguage().equals("en_US")) { dimensionLabel = ReportInvoiceCustomerDimensionalAnalysesJRData.selectNotShown(this, ""); } else { dimensionLabel = ReportInvoiceCustomerDimensionalAnalysesJRData.selectNotShownTrl(this, vars.getLanguage(), ""); } // Checking report limit first StringBuffer levelsconcat = new StringBuffer(); levelsconcat.append("''"); String[] strLevelLabel = { "", "", "", "", "", "", "", "", "", "" }; String[] strTextShow = { "", "", "", "", "", "", "", "", "", "" }; int intOrder = 0; int intProductLevel = 11; int intAuxDiscard = -1; for (int i = 0; i < 10; i++) { if (strShownArray[i].equals("1")) { strTextShow[i] = "C_BP_GROUP.NAME"; intOrder++; strLevelLabel[i] = dimensionLabel[0].name; levelsconcat.append(" || "); levelsconcat.append("C_BP_GROUP.C_BP_GROUP_ID"); } else if (strShownArray[i].equals("2")) { strTextShow[i] = "AD_COLUMN_IDENTIFIER(to_char('C_Bpartner'), to_char( C_BPARTNER.C_BPARTNER_ID), to_char( '" + vars.getLanguage() + "'))"; intOrder++; strLevelLabel[i] = dimensionLabel[1].name; levelsconcat.append(" || "); levelsconcat.append("C_BPARTNER.C_BPARTNER_ID"); } else if (strShownArray[i].equals("3")) { strTextShow[i] = "M_PRODUCT_CATEGORY.NAME"; intOrder++; strLevelLabel[i] = dimensionLabel[2].name; levelsconcat.append(" || "); levelsconcat.append("M_PRODUCT_CATEGORY.M_PRODUCT_CATEGORY_ID"); } else if (strShownArray[i].equals("4")) { strTextShow[i] = "AD_COLUMN_IDENTIFIER(to_char('M_Product'), to_char( M_PRODUCT.M_PRODUCT_ID), to_char( '" + vars.getLanguage() + "'))|| CASE WHEN uomsymbol IS NULL THEN '' ELSE to_char(' ('||uomsymbol||')') END"; intAuxDiscard = i; intOrder++; intProductLevel = i + 1; strLevelLabel[i] = dimensionLabel[3].name; levelsconcat.append(" || "); levelsconcat.append("M_PRODUCT.M_PRODUCT_ID"); } else if (strShownArray[i].equals("5")) { strTextShow[i] = "C_INVOICE.DOCUMENTNO"; intOrder++; strLevelLabel[i] = dimensionLabel[4].name; levelsconcat.append(" || "); levelsconcat.append("C_INVOICE.C_INVOICE_ID"); } else if (strShownArray[i].equals("6")) { strTextShow[i] = "AD_USER.FIRSTNAME||' '||' '||AD_USER.LASTNAME"; intOrder++; strLevelLabel[i] = dimensionLabel[5].name; levelsconcat.append(" || "); levelsconcat.append("AD_USER.AD_USER_ID"); } else if (strShownArray[i].equals("8")) { strTextShow[i] = "AD_ORG.NAME"; intOrder++; strLevelLabel[i] = dimensionLabel[6].name; levelsconcat.append(" || "); levelsconcat.append("AD_ORG.AD_ORG_ID"); } else if (strShownArray[i].equals("9")) { strTextShow[i] = "CASE WHEN AD_USER.AD_USER_ID IS NOT NULL THEN AD_COLUMN_IDENTIFIER(to_char('Ad_User'), to_char( AD_USER.AD_USER_ID), to_char( '" + vars.getLanguage() + "')) ELSE '' END"; intOrder++; strLevelLabel[i] = dimensionLabel[7].name; levelsconcat.append(" || "); levelsconcat.append("AD_USER.AD_USER_ID"); } else if (strShownArray[i].equals("10")) { strTextShow[i] = "C_PROJECT.NAME"; intOrder++; strLevelLabel[i] = dimensionLabel[8].name; levelsconcat.append(" || "); levelsconcat.append("C_PROJECT.C_PROJECT_ID"); } else if (strShownArray[i].equals("11")) { strTextShow[i] = "AD_COLUMN_IDENTIFIER(to_char('C_Bpartner_Location'), to_char( M_INOUT.C_BPARTNER_LOCATION_ID), to_char( '" + vars.getLanguage() + "'))"; intOrder++; strLevelLabel[i] = dimensionLabel[9].name; levelsconcat.append(" || "); levelsconcat.append("M_INOUT.C_BPARTNER_LOCATION_ID"); } else { strTextShow[i] = "''"; discard[i] = "display:none;"; } } if (intOrder != 0 || intAuxDiscard != -1) { int k = 1; if (intOrder == 1) { strOrderby = " ORDER BY NIVEL" + k + ","; } else { strOrderby = " ORDER BY "; } while (k < intOrder) { strOrderby = strOrderby + "NIVEL" + k + ","; k++; } if (k == 1) { if (strOrder.equals("Normal")) { strOrderby = " ORDER BY NIVEL" + k; } else if (strOrder.equals("Amountasc")) { strOrderby = " ORDER BY CONVAMOUNT ASC"; } else if (strOrder.equals("Amountdesc")) { strOrderby = " ORDER BY CONVAMOUNT DESC"; } else { strOrderby = "1"; } } else { if (strOrder.equals("Normal")) { strOrderby += "NIVEL" + k; } else if (strOrder.equals("Amountasc")) { strOrderby += "CONVAMOUNT ASC"; } else if (strOrder.equals("Amountdesc")) { strOrderby += "CONVAMOUNT DESC"; } else { strOrderby = "1"; } } } else { strOrderby = " ORDER BY 1"; } String strHaving = ""; if (!strMayor.equals("") && !strMenor.equals("")) { strHaving = " HAVING (SUM(CONVAMOUNT) >= " + strMayor + " AND SUM(CONVAMOUNT) <= " + strMenor + ")"; } else if (!strMayor.equals("") && strMenor.equals("")) { strHaving = " HAVING (SUM(CONVAMOUNT) >= " + strMayor + ")"; } else if (strMayor.equals("") && !strMenor.equals("")) { strHaving = " HAVING (SUM(CONVAMOUNT) <= " + strMenor + ")"; } strOrderby = strHaving + strOrderby; int limit = 0; int mycount = 0; try { limit = Integer.parseInt(Utility.getPreference(vars, "ReportsLimit", "")); if (limit > 0) { mycount = Integer.parseInt((strComparative.equals("Y")) ? ReportInvoiceCustomerDimensionalAnalysesJRData.selectCount(this, levelsconcat.toString(), Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerDimensionalAnalysesJR"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strsalesrepId, strPartnerSalesrepId, strcProjectId, strProducttype, strcDocTypeId, strVoid.equals("Y") ? "" : "VO", strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strDateFromRef, DateTimeData.nDaysAfter(this, strDateToRef, "1"), strDateFromRef2, DateTimeData.nDaysAfter(this, strDateToRef2, "1"), strDateFromRef3, DateTimeData.nDaysAfter(this, strDateToRef3, "1")) : ReportInvoiceCustomerDimensionalAnalysesJRData.selectNoComparativeCount(this, levelsconcat.toString(), Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerDimensionalAnalysesJR"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strsalesrepId, strPartnerSalesrepId, strcProjectId, strProducttype, strcDocTypeId, strVoid.equals("Y") ? "" : "VO", strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"))); } } catch (NumberFormatException e) { } if (limit > 0 && mycount > limit) { String msgbody = Utility.messageBD(this, "ReportsLimitBody", vars.getLanguage()); msgbody = msgbody.replace("@rows@", Integer.toString(mycount)); msgbody = msgbody.replace("@limit@", Integer.toString(limit)); advisePopUp(request, response, "ERROR", Utility.messageBD(this, "ReportsLimitHeader", vars.getLanguage()), msgbody); } else { // Checks if there is a conversion rate for each of the transactions of the report String strConvRateErrorMsg = ""; OBError myMessage = null; myMessage = new OBError(); if ("xls".equals(strOutput)) { try { dataXLS = ReportInvoiceCustomerDimensionalAnalysesJRData.selectXLS(this, strCurrencyId, Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerDimensionalAnalysesJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strsalesrepId, strPartnerSalesrepId, strcProjectId, strProducttype, strcDocTypeId, strVoid.equals("Y") ? "" : "VO"); } catch (ServletException ex) { myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage()); } } else { if (strComparative.equals("Y")) { try { if (multiComparative2) { if (multiComparative3) { // Multi-comparative B: 1 base date, 3 reference dates data = ReportInvoiceCustomerDimensionalAnalysesJRData.select3(this, strCurrencyId, strTextShow[0], strTextShow[1], strTextShow[2], strTextShow[3], strTextShow[4], strTextShow[5], strTextShow[6], strTextShow[7], strTextShow[8], strTextShow[9], Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerDimensionalAnalysesJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strsalesrepId, strPartnerSalesrepId, strcProjectId, strProducttype, strcDocTypeId, strVoid.equals("Y") ? "" : "VO", strDateFromRef, DateTimeData.nDaysAfter(this, strDateToRef, "1"), strDateFromRef2, DateTimeData.nDaysAfter(this, strDateToRef2, "1"), strDateFromRef3, DateTimeData.nDaysAfter(this, strDateToRef3, "1"), strOrderby); } else { // Multi-comparative A: 1 base date, 2 reference dates data = ReportInvoiceCustomerDimensionalAnalysesJRData.select2(this, strCurrencyId, strTextShow[0], strTextShow[1], strTextShow[2], strTextShow[3], strTextShow[4], strTextShow[5], strTextShow[6], strTextShow[7], strTextShow[8], strTextShow[9], Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerDimensionalAnalysesJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strsalesrepId, strPartnerSalesrepId, strcProjectId, strProducttype, strcDocTypeId, strVoid.equals("Y") ? "" : "VO", strDateFromRef, DateTimeData.nDaysAfter(this, strDateToRef, "1"), strDateFromRef2, DateTimeData.nDaysAfter(this, strDateToRef2, "1"), strOrderby); } } else { // Regular comparative: 1 base date, 1 reference date data = ReportInvoiceCustomerDimensionalAnalysesJRData.select(this, strCurrencyId, strTextShow[0], strTextShow[1], strTextShow[2], strTextShow[3], strTextShow[4], strTextShow[5], strTextShow[6], strTextShow[7], strTextShow[8], strTextShow[9], Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerDimensionalAnalysesJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strsalesrepId, strPartnerSalesrepId, strcProjectId, strProducttype, strcDocTypeId, strVoid.equals("Y") ? "" : "VO", strDateFromRef, DateTimeData.nDaysAfter(this, strDateToRef, "1"), strOrderby); } } catch (ServletException ex) { myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage()); } } else { try { data = ReportInvoiceCustomerDimensionalAnalysesJRData.selectNoComparative(this, strCurrencyId, strTextShow[0], strTextShow[1], strTextShow[2], strTextShow[3], strTextShow[4], strTextShow[5], strTextShow[6], strTextShow[7], strTextShow[8], strTextShow[9], Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerDimensionalAnalysesJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strsalesrepId, strPartnerSalesrepId, strcProjectId, strProducttype, strcDocTypeId, strVoid.equals("Y") ? "" : "VO", strOrderby); } catch (ServletException ex) { myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage()); } } } strConvRateErrorMsg = myMessage.getMessage(); // If a conversion rate is missing for a certain transaction, an error message window pops-up. if (!strConvRateErrorMsg.equals("") && strConvRateErrorMsg != null) { advisePopUp(request, response, "ERROR", Utility.messageBD(this, "NoConversionRateHeader", vars.getLanguage()), strConvRateErrorMsg); } else { // Otherwise, the report is launched if ("xls".equals(strOutput)) { try { if (!dataXLS.hasData()) { advisePopUp(request, response, "WARNING", Utility.messageBD(this, "ProcessStatus-W", vars.getLanguage()), Utility.messageBD(this, "NoDataFound", vars.getLanguage())); } else { /* * int rowLimit = 65532; ScrollableFieldProvider limitedData = new * LimitRowsScrollableFieldProviderFilter( dataXLS, rowLimit); */ String strReportName = "@basedesign@/org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerDimensionalAnalysesXLS.jrxml"; HashMap<String, Object> parameters = new HashMap<String, Object>(); String strDateFormat; strDateFormat = vars.getJavaDateFormat(); parameters.put("strDateFormat", strDateFormat); renderJR(vars, response, strReportName, null, "xls", parameters, dataXLS, null); } } finally { if (dataXLS != null) { dataXLS.close(); } } } else { String strReportPath; if (strComparative.equals("Y")) { strReportPath = "@basedesign@/org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerDimensionalAnalysesComparativeJR.jrxml"; if (multiComparative2) { strReportPath = "@basedesign@/org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerDimensionalAnalysesMultiComparativeJR.jrxml"; } if (multiComparative3) { strReportPath = "@basedesign@/org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerDimensionalAnalysesMultiComparativeExtendedJR.jrxml"; } } else { strReportPath = "@basedesign@/org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerDimensionalAnalysesNoComparativeJR.jrxml"; } if (data == null || data.length == 0) { advisePopUp(request, response, "WARNING", Utility.messageBD(this, "ProcessStatus-W", vars.getLanguage()), Utility.messageBD(this, "NoDataFound", vars.getLanguage())); } else { HashMap<String, Object> parameters = new HashMap<String, Object>(); parameters.put("LEVEL1_LABEL", strLevelLabel[0]); parameters.put("LEVEL2_LABEL", strLevelLabel[1]); parameters.put("LEVEL3_LABEL", strLevelLabel[2]); parameters.put("LEVEL4_LABEL", strLevelLabel[3]); parameters.put("LEVEL5_LABEL", strLevelLabel[4]); parameters.put("LEVEL6_LABEL", strLevelLabel[5]); parameters.put("LEVEL7_LABEL", strLevelLabel[6]); parameters.put("LEVEL8_LABEL", strLevelLabel[7]); parameters.put("LEVEL9_LABEL", strLevelLabel[8]); parameters.put("LEVEL10_LABEL", strLevelLabel[9]); parameters.put("DIMENSIONS", new Integer(intOrder)); parameters.put("REPORT_SUBTITLE", strTitle); parameters.put("PRODUCT_LEVEL", new Integer(intProductLevel)); renderJR(vars, response, strReportPath, strOutput, parameters, data, null); } } } } }
From source file:org.openbravo.client.application.ADAlertDatasourceService.java
private List<String> getAlertIdsFromAlertRules(List<AlertRule> alertRules) { List<String> alertIds = new ArrayList<String>(); for (AlertRule alertRule : alertRules) { // Adding alert rule if it has not filter clause. In case it has, it will be added only in // case it returns data after applying the filter clause. if (alertRule.getFilterClause() == null) { for (Alert alert : alertRule.getADAlertList()) { alertIds.add((String) DalUtil.getId(alert)); }/*from ww w. jav a 2s. co m*/ } String filterClause = null; if (alertRule.getFilterClause() != null) { try { filterClause = new UsedByLink().getWhereClause(RequestContext.get().getVariablesSecureApp(), "", alertRule.getFilterClause()); } catch (ServletException e) { throw new IllegalStateException(e); } final String sql = "select * from AD_ALERT where ISACTIVE='Y'" + " AND AD_CLIENT_ID " + OBDal.getInstance().getReadableClientsInClause() + " AND AD_ORG_ID " + OBDal.getInstance().getReadableOrganizationsInClause() + " AND AD_ALERTRULE_ID = ? " + (filterClause == null ? "" : filterClause); final SQLQuery sqlQuery = OBDal.getInstance().getSession().createSQLQuery(sql) .addEntity(Alert.ENTITY_NAME); sqlQuery.setParameter(0, alertRule.getId()); try { @SuppressWarnings("unchecked") List<Alert> alertsWithFilterClause = sqlQuery.list(); log.debug("Alert " + alertRule.getName() + " (" + alertRule.getId() + ") - SQL:'" + sql + "' - Rows: " + alertsWithFilterClause.size()); for (Alert alert : alertsWithFilterClause) { alertIds.add((String) DalUtil.getId(alert)); } } catch (SQLGrammarException e) { log.error("An error has ocurred when trying to process the alerts: " + e.getMessage(), e); } } } return alertIds; }
From source file:org.openbravo.erpCommon.ad_forms.DocInvoice.java
/** * Update Product Info. - Costing (PriceLastInv) - PO (PriceLastInv) * //from ww w .j ava2 s.c om * @param C_AcctSchema_ID * accounting schema */ public void updateProductInfo(String C_AcctSchema_ID, ConnectionProvider conn, Connection con) { log4jDocInvoice.debug("updateProductInfo - C_Invoice_ID=" + this.Record_ID); /** * @todo Last.. would need to compare document/last updated date would need to maintain * LastPriceUpdateDate on _PO and _Costing */ // update Product PO info // should only be once, but here for every AcctSchema // ignores multiple lines with same product - just uses first int no = 0; try { no = DocInvoiceData.updateProductPO(con, conn, Record_ID); log4jDocInvoice.debug("M_Product_PO - Updated=" + no); } catch (ServletException e) { log4jDocInvoice.warn(e); if (e.getMessage().contains("@NoConversionRate@")) { setMessageResult(Utility.translateError(conn, RequestContext.get().getVariablesSecureApp(), OBContext.getOBContext().getLanguage().getId(), e.getMessage())); throw new IllegalStateException(); } } }
From source file:org.openbravo.erpCommon.businessUtility.AuditTrailPopup.java
private void printGridDataHistory(HttpServletResponse response, VariablesSecureApp vars, String tableId, String tabId, String recordId, String userId, String fieldId, String strDateFrom, String strDateTo, String strOrderCols, String strOrderDirs, String strOffset, String strPageSize, String strNewFilter) throws IOException, ServletException { log4j.debug("DATA_HISTORY: tableId: " + tableId + " recordId: " + recordId); long s1 = System.currentTimeMillis(); String hql = "as f where f.tab.id = :tabId and (f.displayed = true or f.column.reference.id = '13')"; OBQuery<Field> qf = OBDal.getInstance().createQuery(Field.class, hql); qf.setNamedParameter("tabId", tabId); List<Field> fieldList = qf.list(); Map<String, Field> fields = new HashMap<String, Field>(fieldList.size()); for (Field f : fieldList) { fields.put(f.getColumn().getId(), f); }// w w w . jav a 2 s. c o m FieldProvider[] data = null; String type = "Hidden"; String title = ""; String description = ""; String strNumRows = "0"; int offset = Integer.valueOf(strOffset).intValue(); int pageSize = Integer.valueOf(strPageSize).intValue(); // parse dateTime filter fields String strDateFormat = vars.getJavaDataTimeFormat(); SimpleDateFormat dateFormat = new SimpleDateFormat(strDateFormat); Date dateFrom = parseDate(strDateFrom, dateFormat); Date dateTo = parseDate(strDateTo, dateFormat); // get columnId matching the fieldId String columnId = ""; if (fieldId != null && !fieldId.isEmpty()) { Field field = OBDal.getInstance().get(Field.class, fieldId); columnId = field.getColumn().getId(); } try { if (strNewFilter.equals("1") || strNewFilter.equals("")) { // New filter or first load -> get total rows for filter strNumRows = getCountRowsHistory(tableId, fields.keySet(), recordId, userId, columnId, dateFrom, dateTo); vars.setSessionValue("AuditTrail.numrows", strNumRows); } else { strNumRows = vars.getSessionValue("AuditTrail.numrows"); } // get data (paged by offset, pageSize) data = getDataRowsHistory(vars, tableId, tabId, fields, recordId, userId, columnId, dateFrom, dateTo, offset, pageSize, vars.getLanguage()); } catch (ServletException e) { log4j.error("Error getting row data: ", e); OBError myError = Utility.translateError(this, vars, vars.getLanguage(), e.getMessage()); if (!myError.isConnectionAvailable()) { bdErrorAjax(response, "Error", "Connection Error", "No database connection"); return; } else { type = myError.getType(); title = myError.getTitle(); if (!myError.getMessage().startsWith("<![CDATA[")) description = "<![CDATA[" + myError.getMessage() + "]]>"; else description = myError.getMessage(); } } catch (Exception e) { log4j.error("Error getting row data: ", e); type = "Error"; title = "Error"; if (e.getMessage().startsWith("<![CDATA[")) description = "<![CDATA[" + e.getMessage() + "]]>"; else description = e.getMessage(); } if (!type.startsWith("<![CDATA[")) type = "<![CDATA[" + type + "]]>"; if (!title.startsWith("<![CDATA[")) title = "<![CDATA[" + title + "]]>"; if (!description.startsWith("<![CDATA[")) description = "<![CDATA[" + description + "]]>"; StringBuffer strRowsData = new StringBuffer(); strRowsData.append("<xml-data>\n"); strRowsData.append(" <status>\n"); strRowsData.append(" <type>").append(type).append("</type>\n"); strRowsData.append(" <title>").append(title).append("</title>\n"); strRowsData.append(" <description>").append(description).append("</description>\n"); strRowsData.append(" </status>\n"); strRowsData.append(" <rows numRows=\"").append(strNumRows).append("\">\n"); if (data != null && data.length > 0) { for (int j = 0; j < data.length; j++) { strRowsData.append(" <tr>\n"); for (String columnname : colNamesHistory) { strRowsData.append(" <td><![CDATA["); // formatting already done strRowsData.append(data[j].getField(columnname)); strRowsData.append("]]></td>\n"); } strRowsData.append(" </tr>\n"); } } strRowsData.append(" </rows>\n"); strRowsData.append("</xml-data>\n"); response.setContentType("text/xml; charset=UTF-8"); response.setHeader("Cache-Control", "no-cache"); PrintWriter out = response.getWriter(); out.print(strRowsData.toString()); out.close(); long s2 = System.currentTimeMillis(); log4j.debug("printGridDataHistory took: " + (s2 - s1)); }