details: https://code.openbravo.com/erp/devel/pi/rev/d1bf16311eab changeset: 29652:d1bf16311eab user: Mark <markmm82 <at> gmail.com> date: Thu Jun 09 11:05:00 2016 -0400 summary: Fixes issue 30455: Add support for multiple filtering in Stock Reservation P&E
Added support for multiple criteria filtering in getGridData method details: https://code.openbravo.com/erp/devel/pi/rev/bf09b8450ffa changeset: 29653:bf09b8450ffa user: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com> date: Wed Jun 15 13:54:21 2016 +0200 summary: Related to issue 30455: Code review improvements Added also support for multiple criteria filtering in getWarehouseFilterData, getStorageFilterData, getAttributeSetValueFilterData and getOrderLineSetValueFilterData methods. Add criteria.has("fieldName") check to avoid NPE. details: https://code.openbravo.com/erp/devel/pi/rev/e6e019dabbbb changeset: 29654:e6e019dabbbb user: Sanjota <sanjota.nelagi <at> promantia.com> date: Wed Jun 15 16:55:44 2016 +0200 summary: Fixes issue 33165: Improve attribute error message when processing a shipment Give related order and order line information when throwing productWithoutAttributeSet error message to be able to know which order line is wrong when generating a shipment from Create Shipments From Orders window. details: https://code.openbravo.com/erp/devel/pi/rev/e67484476dfd changeset: 29655:e67484476dfd user: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com> date: Thu Jun 16 11:17:08 2016 +0200 summary: Related to issue 33165: Code review improvements diffstat: src-db/database/model/functions/M_INOUT_POST.xml | 26 +- src/org/openbravo/common/datasource/StockReservationPickAndEditDataSource.java | 129 +++++---- 2 files changed, 87 insertions(+), 68 deletions(-) diffs (221 lines): diff -r 21698df6e4fe -r e67484476dfd src-db/database/model/functions/M_INOUT_POST.xml --- a/src-db/database/model/functions/M_INOUT_POST.xml Thu Jun 16 10:04:13 2016 +0200 +++ b/src-db/database/model/functions/M_INOUT_POST.xml Thu Jun 16 11:17:08 2016 +0200 @@ -95,6 +95,8 @@ v_QtyAux NUMBER; v_Count NUMBER:=0; v_Line VARCHAR2(10) ; + v_OrderDocumentNo C_ORDER.DocumentNo%TYPE; + v_OrderLineNo C_ORDERLINE.Line%TYPE; v_OrderID_old VARCHAR2(32); Cur_MILines RECORD; FINISH_PROCESS BOOLEAN:=false; @@ -353,18 +355,26 @@ IF (v_Count=0) THEN RAISE_APPLICATION_ERROR(-20000, '@NotCorrectOrgDoctypeShipment@') ; END IF; - SELECT COUNT(*), MAX(M.line) - INTO v_Count, v_line - FROM M_InOutLine M, - M_Product P - WHERE M.M_PRODUCT_ID=P.M_PRODUCT_ID - AND P.M_ATTRIBUTESET_ID IS NOT NULL + SELECT COUNT(*), MAX(M.line), MAX(O.documentno), Max(OL.line) + INTO v_Count, v_line, v_OrderDocumentNo, v_OrderLineNo + FROM M_InOutLine M + JOIN M_Product P + ON M.m_product_id = P.m_product_id + LEFT JOIN C_OrderLine OL + ON M.c_orderline_id = OL.c_orderline_id + LEFT JOIN C_Order O + ON OL.c_order_id = O.c_order_id + WHERE P.M_ATTRIBUTESET_ID IS NOT NULL AND (P.ATTRSETVALUETYPE IS NULL OR P.ATTRSETVALUETYPE <> 'F') AND (SELECT ISONEATTRSETVALREQUIRED FROM M_ATTRIBUTESET WHERE M_ATTRIBUTESET_ID = P.M_ATTRIBUTESET_ID) = 'Y' AND COALESCE(M.M_ATTRIBUTESETINSTANCE_ID, '0') = '0' AND M.M_INOUT_ID=v_Record_ID; - IF v_Count<>0 THEN - RAISE_APPLICATION_ERROR(-20000, '@Inline@'||' '||v_line||' '||'@productWithoutAttributeSet@') ; + IF (v_Count <> 0) THEN + IF (v_orderDocumentNo IS NULL) THEN + RAISE_APPLICATION_ERROR(-20000, '@Inline@'||' '||v_line||' '||'@productWithoutAttributeSet@'); + ELSE + RAISE_APPLICATION_ERROR(-20000, '@Inline@'||' '||v_line||' '||'@productWithoutAttributeSet@'||'. '||'@INS_POREFERENCE@'||' '||v_OrderDocumentNo||' '||'@line@'||' '||v_OrderLineNo); + END IF; END IF; SELECT COUNT(*), MAX(M.line) INTO v_Count, v_Line diff -r 21698df6e4fe -r e67484476dfd src/org/openbravo/common/datasource/StockReservationPickAndEditDataSource.java --- a/src/org/openbravo/common/datasource/StockReservationPickAndEditDataSource.java Thu Jun 16 10:04:13 2016 +0200 +++ b/src/org/openbravo/common/datasource/StockReservationPickAndEditDataSource.java Thu Jun 16 11:17:08 2016 +0200 @@ -150,20 +150,7 @@ private List<Map<String, Object>> getOrderLineSetValueFilterData(Map<String, String> parameters) { List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); - Map<String, String> filterCriteria = new HashMap<String, String>(); - try { - // Builds the criteria based on the fetch parameters - JSONArray criterias = (JSONArray) JsonUtils.buildCriteria(parameters).get("criteria"); - for (int i = 0; i < criterias.length(); i++) { - final JSONObject criteria = criterias.getJSONObject(i); - if (criteria.has("fieldName")) { - filterCriteria.put(criteria.getString("fieldName"), - criteria.has("value") ? criteria.getString("value") : criteria.toString()); - } - } - } catch (JSONException e) { - log4j.error("Error while building the criteria", e); - } + Map<String, String> filterCriteria = buildCriteria(parameters); OBContext.setAdminMode(); try { for (OrderLine o : getOrderLineFromGrid(filterCriteria.get("orderLine$_identifier"), @@ -206,18 +193,7 @@ private List<Map<String, Object>> getWarehouseFilterData(Map<String, String> parameters) { List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); - Map<String, String> filterCriteria = new HashMap<String, String>(); - try { - // Builds the criteria based on the fetch parameters - JSONArray criterias = (JSONArray) JsonUtils.buildCriteria(parameters).get("criteria"); - for (int i = 0; i < criterias.length(); i++) { - final JSONObject criteria = criterias.getJSONObject(i); - filterCriteria.put(criteria.getString("fieldName"), - criteria.has("value") ? criteria.getString("value") : criteria.toString()); - } - } catch (JSONException e) { - log4j.error("Error while building the criteria", e); - } + Map<String, String> filterCriteria = buildCriteria(parameters); OBContext.setAdminMode(); try { for (Warehouse o : getWarehouseFromGrid(filterCriteria.get("warehouse$_identifier"), @@ -342,18 +318,7 @@ private List<Map<String, Object>> getStorageFilterData(Map<String, String> parameters) { List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); - Map<String, String> filterCriteria = new HashMap<String, String>(); - try { - // Builds the criteria based on the fetch parameters - JSONArray criterias = (JSONArray) JsonUtils.buildCriteria(parameters).get("criteria"); - for (int i = 0; i < criterias.length(); i++) { - final JSONObject criteria = criterias.getJSONObject(i); - filterCriteria.put(criteria.getString("fieldName"), - criteria.has("value") ? criteria.getString("value") : criteria.toString()); - } - } catch (JSONException e) { - log4j.error("Error while building the criteria", e); - } + Map<String, String> filterCriteria = buildCriteria(parameters); OBContext.setAdminMode(); try { for (Locator o : getStorageBinFromGrid(filterCriteria.get("storageBin$_identifier"), @@ -462,20 +427,7 @@ private List<Map<String, Object>> getAttributeSetValueFilterData(Map<String, String> parameters) { List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); - Map<String, String> filterCriteria = new HashMap<String, String>(); - try { - // Builds the criteria based on the fetch parameters - JSONArray criterias = (JSONArray) JsonUtils.buildCriteria(parameters).get("criteria"); - for (int i = 0; i < criterias.length(); i++) { - final JSONObject criteria = criterias.getJSONObject(i); - if (criteria.has("fieldName")) { - filterCriteria.put(criteria.getString("fieldName"), - criteria.has("value") ? criteria.getString("value") : criteria.toString()); - } - } - } catch (JSONException e) { - log4j.error("Error while building the criteria", e); - } + Map<String, String> filterCriteria = buildCriteria(parameters); OBContext.setAdminMode(); try { for (AttributeSetInstance o : getAttributeSetValueFromGrid( @@ -531,14 +483,33 @@ if (criteria.has("criteria") && criteria.has("operator")) { JSONArray mySon = new JSONArray(criteria.getString("criteria")); for (int j = 0; j < mySon.length(); j++) { - if (filterCriteria.containsKey(mySon.getJSONObject(j).getString("fieldName"))) { - JSONArray values = new JSONArray(filterCriteria.get(mySon.getJSONObject(j).getString( - "fieldName"))); - filterCriteria.put(mySon.getJSONObject(j).getString("fieldName"), - values.put(mySon.getJSONObject(j)).toString()); - } else { - filterCriteria.put(mySon.getJSONObject(j).getString("fieldName"), new JSONArray() - .put(mySon.getJSONObject(j)).toString()); + final JSONObject criteria2 = mySon.getJSONObject(j); + if (criteria2.has("criteria") && criteria2.has("operator")) { + JSONArray mySonSon = new JSONArray(criteria2.getString("criteria")); + for (int k = 0; k < mySonSon.length(); k++) { + final JSONObject criteria3 = mySonSon.getJSONObject(k); + if (criteria3.has("fieldName")) { + if (filterCriteria.containsKey(criteria3.getString("fieldName"))) { + JSONArray values = new JSONArray(filterCriteria.get(criteria3 + .getString("fieldName"))); + filterCriteria.put(criteria3.getString("fieldName"), values.put(criteria3) + .toString()); + } else { + filterCriteria.put(criteria3.getString("fieldName"), + new JSONArray().put(criteria3).toString()); + } + } + } + } else if (criteria2.has("fieldName")) { + if (filterCriteria.containsKey(criteria2.getString("fieldName"))) { + JSONArray values = new JSONArray(filterCriteria.get(criteria2 + .getString("fieldName"))); + filterCriteria.put(criteria2.getString("fieldName"), values.put(criteria2) + .toString()); + } else { + filterCriteria.put(criteria2.getString("fieldName"), new JSONArray().put(criteria2) + .toString()); + } } } // lessOrEqual @@ -1657,6 +1628,44 @@ return (BigDecimal) query.uniqueResult(); } + private Map<String, String> buildCriteria(Map<String, String> parameters) { + Map<String, String> filterCriteria = new HashMap<String, String>(); + + try { + // Builds the criteria based on the fetch parameters + JSONArray criterias = (JSONArray) JsonUtils.buildCriteria(parameters).get("criteria"); + for (int i = 0; i < criterias.length(); i++) { + final JSONObject criteria1 = criterias.getJSONObject(i); + if (criteria1.has("criteria") && criteria1.has("operator")) { + JSONArray mySon = new JSONArray(criteria1.getString("criteria")); + for (int j = 0; j < mySon.length(); j++) { + final JSONObject criteria2 = mySon.getJSONObject(j); + if (criteria2.has("criteria") && criteria2.has("operator")) { + JSONArray mySonSon = new JSONArray(criteria2.getString("criteria")); + for (int k = 0; k < mySonSon.length(); k++) { + final JSONObject criteria3 = mySonSon.getJSONObject(k); + if (criteria3.has("fieldName")) { + filterCriteria.put(criteria3.getString("fieldName"), + criteria3.has("value") ? criteria3.getString("value") : criteria3.toString()); + } + } + } else if (criteria2.has("fieldName")) { + filterCriteria.put(criteria2.getString("fieldName"), + criteria2.has("value") ? criteria2.getString("value") : criteria2.toString()); + } + } + } else if (criteria1.has("fieldName")) { + filterCriteria.put(criteria1.getString("fieldName"), + criteria1.has("value") ? criteria1.getString("value") : criteria1.toString()); + } + } + } catch (JSONException e) { + log4j.error("Error while building the criteria", e); + } + + return filterCriteria; + } + @Override protected int getCount(Map<String, String> parameters) { // TODO Auto-generated method stub ------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. http://pubads.g.doubleclick.net/gampad/clk?id=1444514421&iu=/41014381 _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits