Author: doogie
Date: Sat Mar 21 23:44:24 2009 New Revision: 757089 URL: http://svn.apache.org/viewvc?rev=757089&view=rev Log: Fix purely empty whitespace lines, and remove trailing whitespace. Modified: ofbiz/trunk/applications/product/src/ShipmentScaleApplet.java ofbiz/trunk/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CatalogUrlServlet.java ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryWorker.java ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWorker.java ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapperException.java ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ParametricSearch.java ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ProductFeatureServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/image/ScaleImage.java ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryWorker.java ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductEvents.java ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java ofbiz/trunk/applications/product/src/org/ofbiz/product/product/VariantEvents.java ofbiz/trunk/applications/product/src/org/ofbiz/product/promo/PromoServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductHelper.java ofbiz/trunk/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreSurveyWrapper.java ofbiz/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/test/InventoryItemTransferTest.java ofbiz/trunk/applications/product/src/org/ofbiz/product/test/StockMovesTest.java ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingEvent.java ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSessionLine.java ofbiz/trunk/applications/product/src/org/ofbiz/shipment/picklist/PickListServices.java ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentEvents.java ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsMockApiServlet.java ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServicesTests.java Modified: ofbiz/trunk/applications/product/src/ShipmentScaleApplet.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/ShipmentScaleApplet.java?rev=757089&r1=757088&r2=757089&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/ShipmentScaleApplet.java (original) +++ ofbiz/trunk/applications/product/src/ShipmentScaleApplet.java Sat Mar 21 23:44:24 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -40,16 +40,16 @@ * ShipmentScaleApplet - Applet for reading weight from a scale and input into the browser */ public class ShipmentScaleApplet extends Applet implements SerialPortEventListener, CommPortOwnershipListener { - - private AppletContext ctx = null; - + + private AppletContext ctx = null; + private CommPortIdentifier portId = null; private SerialPort serialPort = null; private boolean portOpen = false; - + private InputStream in = null; private OutputStream out = null; - + public void init() { this.ctx = this.getAppletContext(); /* @@ -62,15 +62,15 @@ */ try { this.sendFakeMessage(); - } catch (IOException e) { + } catch (IOException e) { e.printStackTrace(); } } - + public void paint() { - + } - + public void configurePort(String port) throws UnsupportedCommOperationException, IOException { try { portId = CommPortIdentifier.getPortIdentifier(port); @@ -83,25 +83,25 @@ } catch (PortInUseException e) { // TODO Auto-generated catch block e.printStackTrace(); - } - - serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); - serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_OUT); - - in = serialPort.getInputStream(); + } + + serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); + serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_OUT); + + in = serialPort.getInputStream(); out = serialPort.getOutputStream(); - + try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { // TODO Auto-generated catch block e.printStackTrace(); } - - serialPort.enableReceiveTimeout(30); + + serialPort.enableReceiveTimeout(30); serialPort.notifyOnDataAvailable(true); - serialPort.notifyOnBreakInterrupt(true); - portId.addPortOwnershipListener(this); + serialPort.notifyOnBreakInterrupt(true); + portId.addPortOwnershipListener(this); this.portOpen = true; } @@ -130,12 +130,12 @@ inputBuffer.append('|'); } else if ('\n' == (char)newData) { inputBuffer.append(""); - } else { + } else { inputBuffer.append((char)newData); } //inputBuffer.append("(" + newData + ")"); - } - + } + } catch (IOException ex) { System.err.println(ex); return; @@ -143,13 +143,13 @@ } // Append received data to messageAreaIn. - checkResponse(inputBuffer.toString()); + checkResponse(inputBuffer.toString()); break; // If break event append BREAK RECEIVED message. case SerialPortEvent.BI: break; - } + } } /* (non-Javadoc) @@ -157,9 +157,9 @@ */ public void ownershipChange(int arg0) { // TODO Auto-generated method stub - + } - + // send the code to the scale and requests the weight public void sendMessage() throws IOException { String message = "W\r"; @@ -168,22 +168,22 @@ out.write((int)msgChars[i]); } out.flush(); - serialPort.sendBreak(1000); + serialPort.sendBreak(1000); } - + public void close() throws IOException { out.close(); in.close(); - serialPort.close(); + serialPort.close(); } - + public static void main(String args[]) throws Exception { ShipmentScaleApplet applet = new ShipmentScaleApplet(); applet.sendMessage(); - applet.close(); + applet.close(); } - - + + // validates the response from the scale and calls the set method private void checkResponse(String response) { StringTokenizer token = new StringTokenizer(response, "|"); @@ -192,7 +192,7 @@ setWeight(weightStr); } } - + private void sendFakeMessage() throws IOException { String weight = this.getParameter("fakeWeight"); if (weight == null) { @@ -200,10 +200,10 @@ } setWeight(weight); } - + // calls the setWeight(weight) JavaScript function on the current page private void setWeight(String weight) { - JSObject win = JSObject.getWindow(this); + JSObject win = JSObject.getWindow(this); String[] args = { weight }; win.call("setWeight", args); } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java?rev=757089&r1=757088&r2=757089&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java Sat Mar 21 23:44:24 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -45,18 +45,18 @@ * CatalogWorker - Worker class for catalog related functionality */ public class CatalogWorker { - + public static final String module = CatalogWorker.class.getName(); public static String getWebSiteId(ServletRequest request) { return WebSiteWorker.getWebSiteId(request); } - + public static GenericValue getWebSite(ServletRequest request) { return WebSiteWorker.getWebSite(request); } - public static List<String> getAllCatalogIds(ServletRequest request) { + public static List<String> getAllCatalogIds(ServletRequest request) { List<String> catalogIds = FastList.newInstance(); List<GenericValue> catalogs = null; GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); @@ -72,7 +72,7 @@ } return catalogIds; } - + public static List<GenericValue> getStoreCatalogs(ServletRequest request) { String productStoreId = ProductStoreWorker.getProductStoreId(request); GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); @@ -111,7 +111,7 @@ } return null; } - + public static List<GenericValue> getProdCatalogCategories(ServletRequest request, String prodCatalogId, String prodCatalogCategoryTypeId) { GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); return getProdCatalogCategories(delegator, prodCatalogId, prodCatalogCategoryTypeId); @@ -137,7 +137,7 @@ /** * Retrieves the current prodCatalogId. First it will attempt to find it from a special * request parameter or session attribute named CURRENT_CATALOG_ID. Failing that, it will - * get the first catalog from the database as specified in getCatalogIdsAvailable(). + * get the first catalog from the database as specified in getCatalogIdsAvailable(). * If this behavior is undesired, give the user a selectable list of catalogs. */ public static String getCurrentCatalogId(ServletRequest request) { @@ -166,7 +166,7 @@ } return prodCatalogId; } - + public static List<String> getCatalogIdsAvailable(ServletRequest request) { List<GenericValue> partyCatalogs = getPartyCatalogs(request); List<GenericValue> storeCatalogs = getStoreCatalogs(request); @@ -178,13 +178,13 @@ List<GenericValue> partyCatalogs = getPartyCatalogs(delegator, partyId); return getCatalogIdsAvailable(partyCatalogs, storeCatalogs); } - + public static List<String> getCatalogIdsAvailable(List<GenericValue> partyCatalogs, List<GenericValue> storeCatalogs) { List<String> categoryIds = FastList.newInstance(); List<GenericValue> allCatalogLinks = FastList.newInstance(); if (partyCatalogs != null) allCatalogLinks.addAll(partyCatalogs); if (storeCatalogs != null) allCatalogLinks.addAll(storeCatalogs); - + if (allCatalogLinks.size() > 0) { for (GenericValue catalogLink: allCatalogLinks) { categoryIds.add(catalogLink.getString("prodCatalogId")); @@ -192,7 +192,7 @@ } return categoryIds; } - + public static String getCatalogName(ServletRequest request) { return getCatalogName(request, getCurrentCatalogId(request)); } @@ -222,7 +222,7 @@ return StringUtil.cleanUpPathPrefix(contentPathPrefix); } - + public static String getTemplatePathPrefix(ServletRequest request) { GenericValue prodCatalog = getProdCatalog(request, getCurrentCatalogId(request)); @@ -247,11 +247,11 @@ return null; } } - + public static String getCatalogTopCategoryId(ServletRequest request) { return getCatalogTopCategoryId(request, getCurrentCatalogId(request)); } - + public static String getCatalogTopCategoryId(ServletRequest request, String prodCatalogId) { if (prodCatalogId == null || prodCatalogId.length() <= 0) return null; @@ -265,11 +265,11 @@ return null; } } - + public static String getCatalogSearchCategoryId(ServletRequest request) { return getCatalogSearchCategoryId(request, getCurrentCatalogId(request)); } - + public static String getCatalogSearchCategoryId(ServletRequest request, String prodCatalogId) { return getCatalogSearchCategoryId((GenericDelegator) request.getAttribute("delegator"), prodCatalogId); } @@ -312,7 +312,7 @@ public static String getCatalogPromotionsCategoryId(ServletRequest request) { return getCatalogPromotionsCategoryId(request, getCurrentCatalogId(request)); } - + public static String getCatalogPromotionsCategoryId(ServletRequest request, String prodCatalogId) { if (prodCatalogId == null || prodCatalogId.length() <= 0) return null; @@ -346,11 +346,11 @@ } return false; } - + public static String getCatalogQuickaddCategoryPrimary(ServletRequest request) { return getCatalogQuickaddCategoryPrimary(request, getCurrentCatalogId(request)); } - + public static String getCatalogQuickaddCategoryPrimary(ServletRequest request, String prodCatalogId) { if (prodCatalogId == null || prodCatalogId.length() <= 0) return null; @@ -364,11 +364,11 @@ return null; } } - + public static Collection<String> getCatalogQuickaddCategories(ServletRequest request) { return getCatalogQuickaddCategories(request, getCurrentCatalogId(request)); } - + public static Collection<String> getCatalogQuickaddCategories(ServletRequest request, String prodCatalogId) { if (prodCatalogId == null || prodCatalogId.length() <= 0) return null; @@ -383,5 +383,5 @@ } return categoryIds; - } + } } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CatalogUrlServlet.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CatalogUrlServlet.java?rev=757089&r1=757088&r2=757089&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CatalogUrlServlet.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CatalogUrlServlet.java Sat Mar 21 23:44:24 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -44,7 +44,7 @@ public class CatalogUrlServlet extends HttpServlet { public static final String module = CatalogUrlServlet.class.getName(); - + public static final String CATALOG_URL_MOUNT_POINT = "products"; public static final String CONTROL_MOUNT_POINT = "control"; public static final String PRODUCT_REQUEST = "product"; @@ -73,10 +73,10 @@ */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { GenericDelegator delegator = (GenericDelegator) getServletContext().getAttribute("delegator"); - + String pathInfo = request.getPathInfo(); List<String> pathElements = StringUtil.split(pathInfo, "/"); - + // look for productId String productId = null; try { @@ -92,7 +92,7 @@ } catch (GenericEntityException e) { Debug.logError(e, "Error looking up product info for ProductUrl with path info [" + pathInfo + "]: " + e.toString(), module); } - + // get category info going with the IDs that remain String categoryId = null; if (pathElements.size() == 1) { @@ -106,7 +106,7 @@ if (trail == null) { trail = FastList.newInstance(); } - + if (trail.contains(pathElements.get(0))) { // first category is in the trail, so remove it everything after that and fill it in with the list from the pathInfo int firstElementIndex = trail.indexOf(pathElements.get(0)); @@ -122,15 +122,15 @@ CategoryWorker.setTrail(request, trail); categoryId = pathElements.get(pathElements.size() - 1); } - + if (categoryId != null) { request.setAttribute("productCategoryId", categoryId); } - // setup the data and forward the request + // setup the data and forward the request if (productId != null) { request.setAttribute("product_id", productId); } - + RequestDispatcher rd = request.getRequestDispatcher("/" + CONTROL_MOUNT_POINT + "/" + (productId != null ? PRODUCT_REQUEST : CATEGORY_REQUEST)); rd.forward(request, response); } @@ -141,7 +141,7 @@ public void destroy() { super.destroy(); } - + public static String makeCatalogUrl(HttpServletRequest request, String productId, String currentCategoryId, String previousCategoryId) { StringBuilder urlBuilder = new StringBuilder(); urlBuilder.append(request.getSession().getServletContext().getContextPath()); @@ -149,7 +149,7 @@ urlBuilder.append("/"); } urlBuilder.append(CATALOG_URL_MOUNT_POINT); - + if (UtilValidate.isNotEmpty(currentCategoryId)) { List<String> trail = CategoryWorker.getTrail(request); trail = CategoryWorker.adjustTrail(trail, currentCategoryId, previousCategoryId); @@ -159,12 +159,12 @@ urlBuilder.append(trailCategoryId); } } - + if (UtilValidate.isNotEmpty(productId)) { urlBuilder.append("/p_"); urlBuilder.append(productId); } - + return urlBuilder.toString(); } } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java?rev=757089&r1=757088&r2=757089&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java Sat Mar 21 23:44:24 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -49,7 +49,7 @@ * Category Content Worker: gets category content to display */ public class CategoryContentWrapper implements ContentWrapper { - + public static final String module = CategoryContentWrapper.class.getName(); protected LocalDispatcher dispatcher; @@ -60,25 +60,25 @@ public static CategoryContentWrapper makeCategoryContentWrapper(GenericValue productCategory, HttpServletRequest request) { return new CategoryContentWrapper(productCategory, request); } - + public CategoryContentWrapper(LocalDispatcher dispatcher, GenericValue productCategory, Locale locale, String mimeTypeId) { this.dispatcher = dispatcher; this.productCategory = productCategory; this.locale = locale; - this.mimeTypeId = mimeTypeId; + this.mimeTypeId = mimeTypeId; } - + public CategoryContentWrapper(GenericValue productCategory, HttpServletRequest request) { this.dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); this.productCategory = productCategory; this.locale = UtilHttp.getLocale(request); this.mimeTypeId = "text/html"; } - + public StringUtil.StringWrapper get(String prodCatContentTypeId) { return StringUtil.makeStringWrapper(getProductCategoryContentAsText(productCategory, prodCatContentTypeId, locale, mimeTypeId, productCategory.getDelegator(), dispatcher)); } - + public static String getProductCategoryContentAsText(GenericValue productCategory, String prodCatContentTypeId, HttpServletRequest request) { LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); return getProductCategoryContentAsText(productCategory, prodCatContentTypeId, UtilHttp.getLocale(request), "text/html", productCategory.getDelegator(), dispatcher); @@ -87,7 +87,7 @@ public static String getProductCategoryContentAsText(GenericValue productCategory, String prodCatContentTypeId, Locale locale, LocalDispatcher dispatcher) { return getProductCategoryContentAsText(productCategory, prodCatContentTypeId, locale, null, null, dispatcher); } - + public static String getProductCategoryContentAsText(GenericValue productCategory, String prodCatContentTypeId, Locale locale, String mimeTypeId, GenericDelegator delegator, LocalDispatcher dispatcher) { String candidateFieldName = ModelUtil.dbNameToVarName(prodCatContentTypeId); try { @@ -107,16 +107,16 @@ return productCategory.getString(candidateFieldName); } } - + public static void getProductCategoryContentAsText(String productCategoryId, GenericValue productCategory, String prodCatContentTypeId, Locale locale, String mimeTypeId, GenericDelegator delegator, LocalDispatcher dispatcher, Writer outWriter) throws GeneralException, IOException { if (productCategoryId == null && productCategory != null) { productCategoryId = productCategory.getString("productCategoryId"); } - + if (delegator == null && productCategory != null) { delegator = productCategory.getDelegator(); } - + if (UtilValidate.isEmpty(mimeTypeId)) { mimeTypeId = "text/html"; } @@ -124,7 +124,7 @@ if (delegator == null) { throw new GeneralRuntimeException("Unable to find a delegator to use!"); } - + String candidateFieldName = ModelUtil.dbNameToVarName(prodCatContentTypeId); ModelEntity categoryModel = delegator.getModelEntity("ProductCategory"); if (categoryModel.isField(candidateFieldName)) { @@ -139,7 +139,7 @@ } } } - + List<GenericValue> categoryContentList = delegator.findByAndCache("ProductCategoryContent", UtilMisc.toMap("productCategoryId", productCategoryId, "prodCatContentTypeId", prodCatContentTypeId), UtilMisc.toList("-fromDate")); categoryContentList = EntityUtil.filterByDate(categoryContentList); GenericValue categoryContent = EntityUtil.getFirst(categoryContentList); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java?rev=757089&r1=757088&r2=757089&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java Sat Mar 21 23:44:24 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -49,7 +49,7 @@ * CategoryServices - Category Services */ public class CategoryServices { - + public static final String module = CategoryServices.class.getName(); public static Map<String, Object> getCategoryMembers(DispatchContext dctx, Map<String, ? extends Object> context) { @@ -101,7 +101,7 @@ if (activeOnly) { productCategoryMembers = EntityUtil.filterByDate(productCategoryMembers, true); } - + if (productId != null && index == null) { for (GenericValue v: productCategoryMembers) { @@ -139,7 +139,7 @@ } return result; } - + private static String getCategoryFindEntityName(GenericDelegator delegator, List<String> orderByFields) { // allow orderByFields to contain fields from the Product entity, if there are such fields String entityName = "ProductCategoryMember"; @@ -150,14 +150,14 @@ orderByFields.add("sequenceNum"); orderByFields.add("productId"); } - + ModelEntity productModel = delegator.getModelEntity("Product"); ModelEntity productCategoryMemberModel = delegator.getModelEntity("ProductCategoryMember"); for (String orderByField: orderByFields) { // Get the real field name from the order by field removing ascending/descending order if (UtilValidate.isNotEmpty(orderByField)) { int startPos = 0, endPos = orderByField.length(); - + if (orderByField.endsWith(" DESC")) { endPos -= 5; } else if (orderByField.endsWith(" ASC")) { @@ -167,12 +167,12 @@ } else if (orderByField.startsWith("+")) { startPos++; } - + if (startPos != 0 || endPos != orderByField.length()) { orderByField = orderByField.substring(startPos, endPos); } } - + if (!productCategoryMemberModel.isField(orderByField)) { if (productModel.isField(orderByField)) { entityName = "ProductAndCategoryMember"; @@ -191,11 +191,11 @@ String productCategoryId = (String) context.get("productCategoryId"); boolean limitView = ((Boolean) context.get("limitView")).booleanValue(); int defaultViewSize = ((Integer) context.get("defaultViewSize")).intValue(); - + List<String> orderByFields = UtilGenerics.checkList(context.get("orderByFields")); if (orderByFields == null) orderByFields = FastList.newInstance(); String entityName = getCategoryFindEntityName(delegator, orderByFields); - + String prodCatalogId = (String) context.get("prodCatalogId"); boolean useCacheForMembers = (context.get("useCacheForMembers") == null || ((Boolean) context.get("useCacheForMembers")).booleanValue()); @@ -209,7 +209,7 @@ if (checkViewAllow) { viewProductCategoryId = CatalogWorker.getCatalogViewAllowCategoryId(delegator, prodCatalogId); } - + Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); int viewIndex = 1; @@ -218,7 +218,7 @@ } catch (Exception e) { viewIndex = 1; } - + int viewSize = defaultViewSize; try { viewSize = Integer.valueOf((String) context.get("viewSizeString")).intValue(); @@ -246,7 +246,7 @@ lowIndex = 0; highIndex = 0; } - + List<GenericValue> productCategoryMembers = null; if (productCategory != null) { try { @@ -283,12 +283,12 @@ mainCondList.add(EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, nowTimestamp))); } EntityCondition mainCond = EntityCondition.makeCondition(mainCondList, EntityOperator.AND); - + // set distinct on EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); // using list iterator EntityListIterator pli = delegator.find(entityName, mainCond, null, null, orderByFields, findOpts); - + // get the partial list for this page if (limitView) { if (viewProductCategoryId != null) { @@ -321,7 +321,7 @@ // fiter out the view allow productCategoryMembers = CategoryWorker.filterProductsInCategory(delegator, productCategoryMembers, viewProductCategoryId); } - + listSize = productCategoryMembers.size(); lowIndex = 1; highIndex = listSize; @@ -331,11 +331,11 @@ if (productCategoryMembers == null) { productCategoryMembers = FastList.newInstance(); } - + if (highIndex > listSize) { highIndex = listSize; } - + // close the list iterator pli.close(); } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryWorker.java?rev=757089&r1=757088&r2=757089&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryWorker.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryWorker.java Sat Mar 21 23:44:24 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -276,7 +276,7 @@ String previousCategory = (String) requestParameters.get("pcategory"); setTrail(request, currentCategory, previousCategory); } - + public static void setTrail(ServletRequest request, String currentCategory, String previousCategory) { if (Debug.verboseOn()) Debug.logVerbose("[CategoryWorker.setTrail] Start: previousCategory=" + previousCategory + " currentCategory=" + currentCategory, module); @@ -290,7 +290,7 @@ crumb = adjustTrail(crumb, currentCategory, previousCategory); setTrail(request, crumb); } - + public static List<String> adjustTrail(List<String> origTrail, String currentCategoryId, String previousCategoryId) { List<String> trail = FastList.newInstance(); if (origTrail != null) { @@ -344,7 +344,7 @@ // add the current category to the end of the list trail.add(currentCategoryId); if (Debug.verboseOn()) Debug.logVerbose("[CategoryWorker.setTrail] Continuing list: Added currentCategory: " + currentCategoryId, module); - + return trail; } @@ -434,7 +434,7 @@ if (productCategoryId == null) return newList; if (valueObjects == null) return null; - + for (GenericValue curValue: valueObjects) { String productId = curValue.getString(productIdFieldName); if (isProductInCategory(delegator, productId, productCategoryId)) { @@ -443,25 +443,25 @@ } return newList; } - + public static void getCategoryContentWrappers(Map<String, CategoryContentWrapper> catContentWrappers, List<GenericValue> categoryList, HttpServletRequest request) throws GenericEntityException { if (catContentWrappers == null || categoryList == null) { return; } for (GenericValue cat: categoryList) { String productCategoryId = (String) cat.get("productCategoryId"); - + if (catContentWrappers.containsKey(productCategoryId)) { // if this ID is already in the Map, skip it (avoids inefficiency, infinite recursion, etc.) continue; } - + CategoryContentWrapper catContentWrapper = new CategoryContentWrapper(cat, request); catContentWrappers.put(productCategoryId, catContentWrapper); List<GenericValue> subCat = getRelatedCategoriesRet(request, "subCatList", productCategoryId, true); - if (subCat != null) { + if (subCat != null) { getCategoryContentWrappers(catContentWrappers, subCat, request ); - } + } } } } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java?rev=757089&r1=757088&r2=757089&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java Sat Mar 21 23:44:24 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -47,36 +47,36 @@ */ @SuppressWarnings("serial") public class ProductConfigItemContentWrapper implements java.io.Serializable { - + public static final String module = ProductConfigItemContentWrapper.class.getName(); protected LocalDispatcher dispatcher; protected GenericValue productConfigItem; protected Locale locale; protected String mimeTypeId; - + public static ProductConfigItemContentWrapper makeProductConfigItemContentWrapper(GenericValue productConfigItem, HttpServletRequest request) { return new ProductConfigItemContentWrapper(productConfigItem, request); } - + public ProductConfigItemContentWrapper(LocalDispatcher dispatcher, GenericValue productConfigItem, Locale locale, String mimeTypeId) { this.dispatcher = dispatcher; this.productConfigItem = productConfigItem; this.locale = locale; this.mimeTypeId = mimeTypeId; } - + public ProductConfigItemContentWrapper(GenericValue productConfigItem, HttpServletRequest request) { this.dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); this.productConfigItem = productConfigItem; this.locale = UtilHttp.getLocale(request); this.mimeTypeId = "text/html"; } - + public String get(String confItemContentTypeId) { return getProductConfigItemContentAsText(productConfigItem, confItemContentTypeId, locale, mimeTypeId, productConfigItem.getDelegator(), dispatcher); } - + public static String getProductConfigItemContentAsText(GenericValue productConfigItem, String confItemContentTypeId, HttpServletRequest request) { LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); return getProductConfigItemContentAsText(productConfigItem, confItemContentTypeId, UtilHttp.getLocale(request), "text/html", productConfigItem.getDelegator(), dispatcher); @@ -85,7 +85,7 @@ public static String getProductConfigItemContentAsText(GenericValue productConfigItem, String confItemContentTypeId, Locale locale, LocalDispatcher dispatcher) { return getProductConfigItemContentAsText(productConfigItem, confItemContentTypeId, locale, null, null, dispatcher); } - + public static String getProductConfigItemContentAsText(GenericValue productConfigItem, String confItemContentTypeId, Locale locale, String mimeTypeId, GenericDelegator delegator, LocalDispatcher dispatcher) { String candidateFieldName = ModelUtil.dbNameToVarName(confItemContentTypeId); try { @@ -105,20 +105,20 @@ return productConfigItem.getString(candidateFieldName); } } - + public static void getProductConfigItemContentAsText(String configItemId, GenericValue productConfigItem, String confItemContentTypeId, Locale locale, String mimeTypeId, GenericDelegator delegator, LocalDispatcher dispatcher, Writer outWriter) throws GeneralException, IOException { if (configItemId == null && productConfigItem != null) { configItemId = productConfigItem.getString("configItemId"); } - + if (delegator == null && productConfigItem != null) { delegator = productConfigItem.getDelegator(); } - + if (UtilValidate.isEmpty(mimeTypeId)) { mimeTypeId = "text/html"; } - + String candidateFieldName = ModelUtil.dbNameToVarName(confItemContentTypeId); //Debug.logInfo("candidateFieldName=" + candidateFieldName, module); ModelEntity productConfigItemModel = delegator.getModelEntity("ProductConfigItem"); @@ -134,7 +134,7 @@ } } } - + List<GenericValue> productConfigItemContentList = delegator.findByAndCache("ProdConfItemContent", UtilMisc.toMap("configItemId", configItemId, "confItemContentTypeId", confItemContentTypeId), UtilMisc.toList("-fromDate")); productConfigItemContentList = EntityUtil.filterByDate(productConfigItemContentList); GenericValue productConfigItemContent = EntityUtil.getFirst(productConfigItemContentList); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWorker.java?rev=757089&r1=757088&r2=757089&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWorker.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWorker.java Sat Mar 21 23:44:24 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -46,7 +46,7 @@ * Product Config Worker class to reduce code in templates. */ public class ProductConfigWorker { - + public static final String module = ProductConfigWorker.class.getName(); public static final String resource = "ProductUiLabels"; public static final String SEPARATOR = "::"; // cache key separator @@ -81,13 +81,13 @@ } return configWrapper; } - + public static void fillProductConfigWrapper(ProductConfigWrapper configWrapper, HttpServletRequest request) { int numOfQuestions = configWrapper.getQuestions().size(); for (int k = 0; k < numOfQuestions; k++) { String[] opts = request.getParameterValues(Integer.toString(k)); if (opts == null) { - + // check for standard item comments ProductConfigWrapper.ConfigItem question = configWrapper.getQuestions().get(k); if (question.isStandard()) { @@ -99,7 +99,7 @@ configWrapper.setSelected(k, i, comments); } catch (Exception e) { Debug.logWarning(e.getMessage(), module); - } + } } i++; } @@ -117,15 +117,15 @@ } else { comments = request.getParameter("comments_" + k + "_" + cnt); } - + configWrapper.setSelected(k, cnt, comments); ProductConfigWrapper.ConfigOption option = configWrapper.getItemOtion(k, cnt); - + // set selected variant products if (UtilValidate.isNotEmpty(option) && (option.hasVirtualComponent())) { List<GenericValue> components = option.getComponents(); int variantIndex = 0; - for (int i = 0; i < components.size(); i++) { + for (int i = 0; i < components.size(); i++) { GenericValue component = components.get(i); if (option.isVirtualComponent(component)) { String productParamName = "add_product_id" + k + "_" + cnt + "_" + variantIndex; @@ -133,7 +133,7 @@ if (UtilValidate.isEmpty(selectedProdcutId)) { Debug.logWarning("ERROR: Request param [" + productParamName + "] not found!", module); } else { - + // handle also feature tree virtual variant methods if (ProductWorker.isVirtual((GenericDelegator)request.getAttribute("delegator"), selectedProdcutId)) { if ("VV_FEATURETREE".equals(ProductWorker.getProductvirtualVariantMethod((GenericDelegator)request.getAttribute("delegator"), selectedProdcutId))) { @@ -146,12 +146,12 @@ selectedFeatures.add(request.getParameterValues(paramName)[0]); } } - + // check if features are selected if (UtilValidate.isEmpty(selectedFeatures)) { Debug.logWarning("ERROR: No features selected for productId [" + selectedProdcutId+ "]", module); } - + String variantProductId = ProductWorker.getVariantFromFeatureTree(selectedProdcutId, selectedFeatures, (GenericDelegator)request.getAttribute("delegator")); if (UtilValidate.isNotEmpty(variantProductId)) { selectedProdcutId = variantProductId; @@ -166,21 +166,21 @@ variantIndex ++; } } - } + } } catch (Exception e) { Debug.logWarning(e.getMessage(), module); } } } } - + /** * First search persisted configurations and update configWrapper.configId if found. * Otherwise store ProductConfigWrapper to ProductConfigConfig entity and updates configWrapper.configId with new configId * This method persists only the selected options, price data is lost. * @param ProductConfigWrapper * @param delegator - */ + */ public static void storeProductConfigWrapper(ProductConfigWrapper configWrapper, GenericDelegator delegator) { if (configWrapper == null || (!configWrapper.isCompleted())) return; String configId = null; @@ -190,7 +190,7 @@ for (ConfigItem ci: questions) { String configItemId = null; Long sequenceNum = null; - List<ProductConfigWrapper.ConfigOption> selectedOptions = FastList.newInstance(); + List<ProductConfigWrapper.ConfigOption> selectedOptions = FastList.newInstance(); List<ConfigOption> options = ci.getOptions(); if (ci.isStandard()) { selectedOptions.addAll(options); @@ -210,36 +210,36 @@ List<GenericValue> configs = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configItemId",configItemId,"sequenceNum", sequenceNum)); for (GenericValue productConfigConfig: configs) { for (ConfigOption oneOption: selectedOptions) { - String configOptionId = oneOption.configOption.getString("configOptionId"); + String configOptionId = oneOption.configOption.getString("configOptionId"); if (productConfigConfig.getString("configOptionId").equals(configOptionId)) { String comments = oneOption.getComments() != null ? oneOption.getComments() : ""; if ((UtilValidate.isEmpty(comments) && UtilValidate.isEmpty(productConfigConfig.getString("description"))) || comments.equals(productConfigConfig.getString("description"))) { configsToCheck.add(productConfigConfig); - } + } } - } + } } } catch (GenericEntityException e) { Debug.logError(e, module); } - - } + + } } if (UtilValidate.isNotEmpty(configsToCheck)) { for (GenericValue productConfigConfig: configsToCheck) { String tempConfigId = productConfigConfig.getString("configId"); try { List<GenericValue> tempResult = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configId",tempConfigId)); - if (tempResult.size() == selectedOptionSize && configsToCheck.containsAll(tempResult)) { + if (tempResult.size() == selectedOptionSize && configsToCheck.containsAll(tempResult)) { List<GenericValue> configOptionProductOptions = delegator.findByAnd("ConfigOptionProductOption", UtilMisc.toMap("configId",tempConfigId)); if (UtilValidate.isNotEmpty(configOptionProductOptions)) { - + // check for variant product equality for (ConfigItem ci: questions) { String configItemId = null; Long sequenceNum = null; - List<ProductConfigWrapper.ConfigOption> selectedOptions = FastList.newInstance(); + List<ProductConfigWrapper.ConfigOption> selectedOptions = FastList.newInstance(); List<ConfigOption> options = ci.getOptions(); if (ci.isStandard()) { selectedOptions.addAll(options); @@ -249,11 +249,11 @@ selectedOptions.add(oneOption); } } - } - + } + boolean match = true; for (ProductConfigWrapper.ConfigOption anOption : selectedOptions) { - if (match && anOption.hasVirtualComponent()) { + if (match && anOption.hasVirtualComponent()) { List<GenericValue> components = anOption.getComponents(); for (GenericValue aComponent : components) { if (anOption.isVirtualComponent(aComponent)) { @@ -263,11 +263,11 @@ String configOptionId = anOption.configOption.getString("configOptionId"); configItemId = ci.getConfigItemAssoc().getString("configItemId"); sequenceNum = ci.getConfigItemAssoc().getLong("sequenceNum"); - - GenericValue configOptionProductOption = delegator.makeValue("ConfigOptionProductOption"); - configOptionProductOption.set("configId", tempConfigId); + + GenericValue configOptionProductOption = delegator.makeValue("ConfigOptionProductOption"); + configOptionProductOption.set("configId", tempConfigId); configOptionProductOption.set("configItemId",configItemId); - configOptionProductOption.set("sequenceNum", sequenceNum); + configOptionProductOption.set("sequenceNum", sequenceNum); configOptionProductOption.set("configOptionId", configOptionId); configOptionProductOption.set("productId", optionProductId); configOptionProductOption.set("productOptionId", optionProductOptionId); @@ -278,15 +278,15 @@ } } } - } - + } + if (match && (UtilValidate.isEmpty(configOptionProductOptions))) { configWrapper.configId = tempConfigId; Debug.logInfo("Existing configuration found with configId:"+ tempConfigId, module); return; } - } - + } + } else { configWrapper.configId = tempConfigId; Debug.logInfo("Existing configuration found with configId:"+ tempConfigId, module); @@ -296,16 +296,16 @@ } catch (GenericEntityException e) { Debug.logError(e, module); } - + } } - + //Current configuration is not found in ProductConfigConfig entity. So lets store this one boolean nextId = true; for (ConfigItem ci: questions) { String configItemId = null; Long sequenceNum = null; - List<ProductConfigWrapper.ConfigOption> selectedOptions = FastList.newInstance(); + List<ProductConfigWrapper.ConfigOption> selectedOptions = FastList.newInstance(); List<ConfigOption> options = ci.getOptions(); if (ci.isStandard()) { selectedOptions.addAll(options); @@ -316,7 +316,7 @@ } } } - + if (selectedOptions.size() > 0) { if (nextId) { configId = delegator.getNextSeqId("ProductConfigConfig"); @@ -334,14 +334,14 @@ productConfigConfig.put("configItemId", configItemId); productConfigConfig.put("sequenceNum", sequenceNum); productConfigConfig.put("configOptionId", configOptionId); - productConfigConfig.put("description", description); + productConfigConfig.put("description", description); toBeStored.add(productConfigConfig); - if (oneOption.hasVirtualComponent()) { - List<GenericValue> components = oneOption.getComponents(); + if (oneOption.hasVirtualComponent()) { + List<GenericValue> components = oneOption.getComponents(); for (GenericValue component: components) { if (oneOption.isVirtualComponent(component)) { - String componentOption = (String)oneOption.componentOptions.get(component.getString("productId")); + String componentOption = (String)oneOption.componentOptions.get(component.getString("productId")); GenericValue configOptionProductOption = delegator.makeValue("ConfigOptionProductOption"); configOptionProductOption.put("configId", configId); configOptionProductOption.put("configItemId", configItemId); @@ -351,24 +351,24 @@ configOptionProductOption.put("productOptionId", componentOption); toBeStored.add(configOptionProductOption); } - } + } } - try { + try { delegator.storeAll(toBeStored); } catch (GenericEntityException e) { configId = null; Debug.logWarning(e.getMessage(), module); } - } - } + } + } } - + //save configId to configWrapper, so we can use it in shopping cart operations configWrapper.configId = configId; Debug.logInfo("New configId created:"+ configId, module); return; } - + /** * Creates a new ProductConfigWrapper for productId and configures it according to ProductConfigConfig entity with configId * ProductConfigConfig entity stores only the selected options, and the product price is calculated from input params Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java?rev=757089&r1=757088&r2=757089&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java Sat Mar 21 23:44:24 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -46,7 +46,7 @@ */ public class ProductConfigWrapper implements Serializable { - + public static final String module = ProductConfigWrapper.class.getName(); protected LocalDispatcher dispatcher; @@ -62,11 +62,11 @@ protected BigDecimal defaultPrice = BigDecimal.ZERO; protected String configId = null; // Id of persisted ProductConfigWrapper protected List<ConfigItem> questions = null; // ProductConfigs - + /** Creates a new instance of ProductConfigWrapper */ public ProductConfigWrapper() { } - + public ProductConfigWrapper(GenericDelegator delegator, LocalDispatcher dispatcher, String productId, String productStoreId, String catalogId, String webSiteId, String currencyUomId, Locale locale, GenericValue autoUserLogin) throws Exception { init(delegator, dispatcher, productId, productStoreId, catalogId, webSiteId, currencyUomId, locale, autoUserLogin); } @@ -101,7 +101,7 @@ this.currencyUomId = currencyUomId; this.delegator = delegator; this.autoUserLogin = autoUserLogin; - + // get the list Price, the base Price Map<String, Object> priceContext = UtilMisc.toMap("product", product, "prodCatalogId", catalogId, "webSiteId", webSiteId, "productStoreId", productStoreId, "currencyUomId", currencyUomId, "autoUserLogin", autoUserLogin); @@ -169,8 +169,8 @@ } } } - } - + } + public void resetConfig() { for (ConfigItem ci: questions) { if (!ci.isStandard()) { @@ -182,7 +182,7 @@ } } } - + public void setDefaultConfig() { resetConfig(); for (ConfigItem ci: questions) { @@ -197,11 +197,11 @@ } } } - + public String getConfigId() { return configId; } - + public boolean equals(Object obj) { if (!(obj instanceof ProductConfigWrapper)) { return false; @@ -230,11 +230,11 @@ public List<ConfigItem> getQuestions() { return questions; } - + public GenericValue getProduct() { return product; } - + public void setSelected(int question, int option, String comments) throws Exception { ConfigItem ci = questions.get(question); List<ConfigOption> avalOptions = ci.getOptions(); @@ -254,7 +254,7 @@ theOption.setComments(comments); } } - + public void setSelected(int question, int option, int component, String componentOption) throws Exception { // set variant products ConfigOption theOption = getItemOtion(question, option); @@ -263,15 +263,15 @@ if (theOption.isVirtualComponent(oneComponent)) { if (theOption.componentOptions == null) { theOption.componentOptions = FastMap.newInstance(); - } + } theOption.componentOptions.put(oneComponent.getString("productId"), componentOption); - + // recalculate option price theOption.recalculateOptionPrice(this); - + } - } - + } + public List<ConfigOption> getSelectedOptions() { List<ConfigOption> selectedOptions = FastList.newInstance(); for (ConfigItem ci: questions) { @@ -297,8 +297,8 @@ } } return defaultOptions; - } - + } + public BigDecimal getTotalListPrice() { BigDecimal totalListPrice = listPrice; List<ConfigOption> options = getSelectedOptions(); @@ -307,7 +307,7 @@ } return totalListPrice; } - + public BigDecimal getTotalPrice() { BigDecimal totalPrice = basePrice; List<ConfigOption> options = getSelectedOptions(); @@ -316,7 +316,7 @@ } return totalPrice; } - + private void setDefaultPrice() { BigDecimal totalPrice = basePrice; List<ConfigOption> options = getDefaultOptions(); @@ -324,12 +324,12 @@ totalPrice = totalPrice.add(oneOption.getPrice()); } defaultPrice = totalPrice; - } - + } + public BigDecimal getDefaultPrice() { return defaultPrice; } - + public boolean isCompleted() { boolean completed = true; for (ConfigItem ci: questions) { @@ -350,7 +350,7 @@ } return completed; } - + public ConfigOption getItemOtion(int itemIndex, int optionIndex) { if (questions.size() > itemIndex) { ConfigItem ci = questions.get(itemIndex); @@ -358,25 +358,25 @@ if (options.size() > optionIndex) { ConfigOption co = options.get(optionIndex); return co; - } + } } - + return null; } - + public class ConfigItem implements java.io.Serializable { GenericValue configItem = null; GenericValue configItemAssoc = null; ProductConfigItemContentWrapper content = null; List<ConfigOption> options = null; boolean first = true; - + public ConfigItem(GenericValue questionAssoc) throws Exception { configItemAssoc = questionAssoc; configItem = configItemAssoc.getRelatedOne("ConfigItemProductConfigItem"); options = FastList.newInstance(); } - + public ConfigItem(ConfigItem ci) { configItem = GenericValue.create(ci.configItem); configItemAssoc = GenericValue.create(ci.configItemAssoc); @@ -391,15 +391,15 @@ public void setContent(Locale locale, String mimeTypeId) { content = new ProductConfigItemContentWrapper(dispatcher, configItem, locale, mimeTypeId); } - + public ProductConfigItemContentWrapper getContent() { return content; } - + public GenericValue getConfigItem() { return configItem; } - + public GenericValue getConfigItemAssoc() { return configItemAssoc; } @@ -407,31 +407,31 @@ public boolean isStandard() { return configItemAssoc.getString("configTypeId").equals("STANDARD"); } - + public boolean isSingleChoice() { return configItem.getString("configItemTypeId").equals("SINGLE"); } - + public boolean isMandatory() { return configItemAssoc.getString("isMandatory") != null && configItemAssoc.getString("isMandatory").equals("Y"); } - + public boolean isFirst() { return first; } - + public void setFirst(boolean newValue) { first = newValue; } - + public void addOption(ConfigOption option) { options.add(option); } - + public List<ConfigOption> getOptions() { return options; } - + public String getQuestion() { String question = ""; if (UtilValidate.isNotEmpty(configItemAssoc.getString("description"))) { @@ -469,7 +469,7 @@ } return false; } - + public ConfigOption getSelected() { for (ConfigOption oneOption: getOptions()) { if (oneOption.isSelected()) { @@ -478,7 +478,7 @@ } return null; } - + public ConfigOption getDefault() { String defaultConfigOptionId = configItemAssoc.getString("defaultConfigOptionId"); if (UtilValidate.isNotEmpty(defaultConfigOptionId)) { @@ -491,7 +491,7 @@ } return null; } - + public boolean equals(Object obj) { if (obj == null || !(obj instanceof ConfigItem)) { return false; @@ -517,7 +517,7 @@ return configItem.getString("configItemId"); } } - + public class ConfigOption implements java.io.Serializable { BigDecimal optionListPrice = BigDecimal.ZERO; BigDecimal optionPrice = BigDecimal.ZERO; @@ -529,7 +529,7 @@ boolean available = true; ConfigItem parentConfigItem = null; String comments = null; // comments for production run entered during ordering - + public ConfigOption(GenericDelegator delegator, LocalDispatcher dispatcher, GenericValue option, ConfigItem configItem, String catalogId, String webSiteId, String currencyUomId, GenericValue autoUserLogin) throws Exception { configOption = option; parentConfigItem = configItem; @@ -543,7 +543,7 @@ Map<String, Object> priceMap = dispatcher.runSync("calculateProductPrice", fieldMap); BigDecimal componentListPrice = (BigDecimal) priceMap.get("listPrice"); BigDecimal componentPrice = (BigDecimal) priceMap.get("price"); - Boolean validPriceFound = (Boolean)priceMap.get("validPriceFound"); + Boolean validPriceFound = (Boolean)priceMap.get("validPriceFound"); BigDecimal mult = BigDecimal.ONE; if (oneComponent.getBigDecimal("quantity") != null) { mult = oneComponent.getBigDecimal("quantity"); @@ -557,7 +557,7 @@ } if (componentPrice != null) { price = componentPrice; - } + } } else { fieldMap.put("productPricePurposeId", "PURCHASE"); Map<String, Object> purchasePriceResultMap = dispatcher.runSync("calculateProductPrice", fieldMap); @@ -575,7 +575,7 @@ // TODO: get the component's availability date } } - + public ConfigOption(ConfigOption co) { configOption = GenericValue.create(co.configOption); componentList = FastList.newInstance(); @@ -588,18 +588,18 @@ selected = co.selected; comments = co.getComments(); } - + public void recalculateOptionPrice(ProductConfigWrapper pcw) throws Exception { optionListPrice = BigDecimal.ZERO; optionPrice = BigDecimal.ZERO; for (GenericValue oneComponent: componentList) { BigDecimal listPrice = BigDecimal.ZERO; BigDecimal price = BigDecimal.ZERO; - GenericValue oneComponentProduct = oneComponent.getRelatedOne("ProductProduct"); - String variantProductId = componentOptions.get(oneComponent.getString("productId")); - + GenericValue oneComponentProduct = oneComponent.getRelatedOne("ProductProduct"); + String variantProductId = componentOptions.get(oneComponent.getString("productId")); + if (UtilValidate.isNotEmpty(variantProductId)) { - oneComponentProduct = pcw.delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", variantProductId)); + oneComponentProduct = pcw.delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", variantProductId)); } // Get the component's price @@ -608,7 +608,7 @@ Map<String, Object> priceMap = dispatcher.runSync("calculateProductPrice", fieldMap); BigDecimal componentListPrice = (BigDecimal) priceMap.get("listPrice"); BigDecimal componentPrice = (BigDecimal) priceMap.get("price"); - Boolean validPriceFound = (Boolean)priceMap.get("validPriceFound"); + Boolean validPriceFound = (Boolean)priceMap.get("validPriceFound"); BigDecimal mult = BigDecimal.ONE; if (oneComponent.getBigDecimal("quantity") != null) { mult = oneComponent.getBigDecimal("quantity"); @@ -619,7 +619,7 @@ if (validPriceFound.booleanValue()) { if (componentListPrice != null) { listPrice = componentListPrice; - } + } if (componentPrice != null) { price = componentPrice; } @@ -638,50 +638,50 @@ optionListPrice = optionListPrice.add(listPrice.multiply(mult)); optionPrice = optionPrice.add(price.multiply(mult)); } - } + } public String getDescription() { return (configOption.getString("description") != null? configOption.getString("description"): "no description"); } - + public String getId() { return configOption.getString("configOptionId"); } - + public String getComments() { return comments; } - + public void setComments(String comments) { this.comments = comments; } - + public BigDecimal getListPrice() { return optionListPrice; } - + public BigDecimal getPrice() { return optionPrice; } - + public BigDecimal getOffsetListPrice() { ConfigOption defaultConfigOption = parentConfigItem.getDefault(); if (parentConfigItem.isSingleChoice() && UtilValidate.isNotEmpty(defaultConfigOption)) { - return optionListPrice.subtract(defaultConfigOption.getListPrice()); + return optionListPrice.subtract(defaultConfigOption.getListPrice()); } else { // can select multiple or no default; show full price return optionListPrice; } } - + public BigDecimal getOffsetPrice() { ConfigOption defaultConfigOption = parentConfigItem.getDefault(); if (parentConfigItem.isSingleChoice() && UtilValidate.isNotEmpty(defaultConfigOption)) { - return optionPrice.subtract(defaultConfigOption.getPrice()); + return optionPrice.subtract(defaultConfigOption.getPrice()); } else { // can select multiple or no default; show full price return optionPrice; } } - + public boolean isDefault() { ConfigOption defaultConfigOption = parentConfigItem.getDefault(); if (this.equals(defaultConfigOption)) { @@ -689,57 +689,57 @@ } return false; } - + public boolean hasVirtualComponent () { List <GenericValue> components = getComponents(); if (UtilValidate.isNotEmpty(components)) { for (GenericValue component : components) { if (isVirtualComponent(component)) { - return true; + return true; } - } + } } return false; } - + public boolean isVirtualComponent (GenericValue component) { int index = getComponents().indexOf(component); if (index != -1) { try { GenericValue product = component.getRelatedOne("ProductProduct"); - return "Y".equals(product.getString("isVirtual")); + return "Y".equals(product.getString("isVirtual")); } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), module); - } + } } return false; } - + public boolean isSelected() { return selected; } - + public void setSelected(boolean newValue) { selected = newValue; } - + public boolean isAvailable() { return available; } - + public void setAvailable(boolean newValue) { available = newValue; } public List<GenericValue> getComponents() { return componentList; - } + } public Map<String, String> getComponentOptions() { return componentOptions; } - + public boolean equals(Object obj) { if (obj == null || !(obj instanceof ConfigOption)) { return false; @@ -748,14 +748,14 @@ if (componentOptions != null && !componentOptions.equals(co.getComponentOptions())) { return false; } - + return isSelected() == co.isSelected(); } - + public String toString() { return configOption.getString("configItemId") + "/" + configOption.getString("configOptionId") + (isSelected()? "*": ""); } } - + } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapperException.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapperException.java?rev=757089&r1=757088&r2=757089&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapperException.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapperException.java Sat Mar 21 23:44:24 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -20,10 +20,10 @@ package org.ofbiz.product.config; public class ProductConfigWrapperException extends Exception { - + /** Creates a new instance of ProductConfigWrapperException */ public ProductConfigWrapperException(String message) { super(message); } - + } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ParametricSearch.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ParametricSearch.java?rev=757089&r1=757088&r2=757089&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ParametricSearch.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ParametricSearch.java Sat Mar 21 23:44:24 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -42,29 +42,29 @@ * Utilities for parametric search based on features. */ public class ParametricSearch { - + public static final String module = ParametricSearch.class.getName(); - + public static final int DEFAULT_PER_TYPE_MAX_SIZE = 1000; - + // DEJ20060427 not used right now, could be removed if that circumstance persists //public static UtilCache featureAllCache = new UtilCache("custom.FeaturePerTypeAll", 0, 600000, true); //public static UtilCache featureByCategoryCache = new UtilCache("custom.FeaturePerTypeByCategory", 0, 600000, true); - - /** Gets all features associated with the specified category through: + + /** Gets all features associated with the specified category through: * ProductCategory -> ProductFeatureCategoryAppl -> ProductFeatureCategory -> ProductFeature. - * Returns a Map of Lists of ProductFeature GenericValue objects organized by productFeatureTypeId. + * Returns a Map of Lists of ProductFeature GenericValue objects organized by productFeatureTypeId. */ public static Map<String, List<GenericValue>> makeCategoryFeatureLists(String productCategoryId, GenericDelegator delegator) { return makeCategoryFeatureLists(productCategoryId, delegator, DEFAULT_PER_TYPE_MAX_SIZE); } - + public static Map<String, List<GenericValue>> makeCategoryFeatureLists(String productCategoryId, GenericDelegator delegator, int perTypeMaxSize) { Map<String, Map<String, GenericValue>> productFeaturesByTypeMap = FastMap.newInstance(); try { List<GenericValue> productFeatureCategoryAppls = delegator.findByAndCache("ProductFeatureCategoryAppl", UtilMisc.toMap("productCategoryId", productCategoryId)); productFeatureCategoryAppls = EntityUtil.filterByDate(productFeatureCategoryAppls, true); - if (productFeatureCategoryAppls != null) { + if (productFeatureCategoryAppls != null) { for (GenericValue productFeatureCategoryAppl: productFeatureCategoryAppls) { List<GenericValue> productFeatures = delegator.findByAndCache("ProductFeature", UtilMisc.toMap("productFeatureCategoryId", productFeatureCategoryAppl.get("productFeatureCategoryId"))); for (GenericValue productFeature: productFeatures) { @@ -83,16 +83,16 @@ } catch (GenericEntityException e) { Debug.logError(e, "Error getting feature categories associated with the category with ID: " + productCategoryId, module); } - + try { List<GenericValue> productFeatureCatGrpAppls = delegator.findByAndCache("ProductFeatureCatGrpAppl", UtilMisc.toMap("productCategoryId", productCategoryId)); productFeatureCatGrpAppls = EntityUtil.filterByDate(productFeatureCatGrpAppls, true); - if (productFeatureCatGrpAppls != null) { + if (productFeatureCatGrpAppls != null) { for (GenericValue productFeatureCatGrpAppl: productFeatureCatGrpAppls) { List<GenericValue> productFeatureGroupAppls = delegator.findByAndCache("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", productFeatureCatGrpAppl.get("productFeatureGroupId"))); for (GenericValue productFeatureGroupAppl: productFeatureGroupAppls) { GenericValue productFeature = delegator.findByPrimaryKeyCache("ProductFeature", UtilMisc.toMap("productFeatureId", productFeatureGroupAppl.get("productFeatureId"))); - + String productFeatureTypeId = productFeature.getString("productFeatureTypeId"); Map<String, GenericValue> featuresByType = productFeaturesByTypeMap.get(productFeatureTypeId); if (featuresByType == null) { @@ -108,17 +108,17 @@ } catch (GenericEntityException e) { Debug.logError(e, "Error getting feature groups associated with the category with ID: " + productCategoryId, module); } - + // now before returning, order the features in each list by description Map<String, List<GenericValue>> productFeaturesByTypeMapSorted = FastMap.newInstance(); for (Map.Entry<String, Map<String, GenericValue>> entry: productFeaturesByTypeMap.entrySet()) { List<GenericValue> sortedFeatures = EntityUtil.orderBy(entry.getValue().values(), UtilMisc.toList("description")); productFeaturesByTypeMapSorted.put(entry.getKey(), sortedFeatures); } - + return productFeaturesByTypeMapSorted; } - + public static Map<String, List<GenericValue>> getAllFeaturesByType(GenericDelegator delegator) { return getAllFeaturesByType(delegator, DEFAULT_PER_TYPE_MAX_SIZE); } @@ -138,7 +138,7 @@ if (featuresByType.size() > perTypeMaxSize) { if (!typesWithOverflowMessages.contains(productFeatureTypeId)) { typesWithOverflowMessages.add(productFeatureTypeId); - // TODO: uh oh, how do we pass this message back? no biggie for now + // TODO: uh oh, how do we pass this message back? no biggie for now } } else { featuresByType.add(productFeature); @@ -150,17 +150,17 @@ } return productFeaturesByTypeMap; } - + public static Map<String, String> makeFeatureIdByTypeMap(ServletRequest request) { Map<String, Object> parameters = UtilHttp.getParameterMap((HttpServletRequest) request); return makeFeatureIdByTypeMap(parameters); } - + /** Handles parameters coming in prefixed with "pft_" where the text in the key following the prefix is a productFeatureTypeId and the value is a productFeatureId; meant to be used with drop-downs and such */ public static Map<String, String> makeFeatureIdByTypeMap(Map<String, Object> parameters) { Map<String, String> featureIdByType = FastMap.newInstance(); if (parameters == null) return featureIdByType; - + for (Map.Entry<String, Object> entry: parameters.entrySet()) { String parameterName = entry.getKey(); @@ -172,15 +172,15 @@ } } } - + return featureIdByType; } - + /** Handles parameters coming in prefixed with "SEARCH_FEAT" where the parameter value is a productFeatureId; meant to be used with text entry boxes or check-boxes and such */ public static List<String> makeFeatureIdListFromPrefixed(Map<String, Object> parameters) { List<String> featureIdList = FastList.newInstance(); if (parameters == null) return featureIdList; - + for (Map.Entry<String, Object> entry: parameters.entrySet()) { String parameterName = entry.getKey(); if (parameterName.startsWith("SEARCH_FEAT")) { @@ -190,15 +190,15 @@ } } } - + return featureIdList; } - + public static String makeFeatureIdByTypeString(Map<String, String> featureIdByType) { if (featureIdByType == null || featureIdByType.size() == 0) { return ""; } - + StringBuilder outSb = new StringBuilder(); for (Map.Entry<String, String> entry: featureIdByType.entrySet()) { if (outSb.length() > 0) { @@ -210,19 +210,19 @@ outSb.append('='); outSb.append(productFeatureId); } - + return outSb.toString(); } - + /** - * Handles parameters coming in prefixed with "SEARCH_PROD_FEAT_CAT" - * where the parameter value is a productFeatureCategoryId; - * meant to be used with text entry boxes or check-boxes and such + * Handles parameters coming in prefixed with "SEARCH_PROD_FEAT_CAT" + * where the parameter value is a productFeatureCategoryId; + * meant to be used with text entry boxes or check-boxes and such **/ public static List<String> makeProductFeatureCategoryIdListFromPrefixed(Map<String, Object> parameters) { List<String> prodFeatureCategoryIdList = FastList.newInstance(); if (parameters == null) return prodFeatureCategoryIdList; - + for (Map.Entry<String, Object> entry: parameters.entrySet()) { String parameterName = entry.getKey(); if (parameterName.startsWith("SEARCH_PROD_FEAT_CAT")) { |
Free forum by Nabble | Edit this page |