You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2009/03/27 18:01:38 UTC
svn commit: r759254 [1/4] - in /ofbiz/trunk/applications/product/src: ./
org/ofbiz/product/catalog/ org/ofbiz/product/category/
org/ofbiz/product/config/ org/ofbiz/product/feature/
org/ofbiz/product/inventory/ org/ofbiz/product/price/ org/ofbiz/product...
Author: doogie
Date: Fri Mar 27 17:01:36 2009
New Revision: 759254
URL: http://svn.apache.org/viewvc?rev=759254&view=rev
Log:
Fix lines that *only* have 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/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/ProductWorker.java
ofbiz/trunk/applications/product/src/org/ofbiz/product/promo/PromoServices.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/PackingServices.java
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.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
Modified: ofbiz/trunk/applications/product/src/ShipmentScaleApplet.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/ShipmentScaleApplet.java?rev=759254&r1=759253&r2=759254&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/ShipmentScaleApplet.java (original)
+++ ofbiz/trunk/applications/product/src/ShipmentScaleApplet.java Fri Mar 27 17:01:36 2009
@@ -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 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();
/*
@@ -66,11 +66,11 @@
e.printStackTrace();
}
}
-
+
public void paint() {
-
+
}
-
+
public void configurePort(String port) throws UnsupportedCommOperationException, IOException {
try {
portId = CommPortIdentifier.getPortIdentifier(port);
@@ -84,20 +84,20 @@
// 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();
out = serialPort.getOutputStream();
-
+
try {
serialPort.addEventListener(this);
} catch (TooManyListenersException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
serialPort.enableReceiveTimeout(30);
serialPort.notifyOnDataAvailable(true);
serialPort.notifyOnBreakInterrupt(true);
@@ -135,7 +135,7 @@
}
//inputBuffer.append("(" + newData + ")");
}
-
+
} catch (IOException ex) {
System.err.println(ex);
return;
@@ -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";
@@ -170,20 +170,20 @@
out.flush();
serialPort.sendBreak(1000);
}
-
+
public void close() throws IOException {
out.close();
in.close();
serialPort.close();
}
-
+
public static void main(String args[]) throws Exception {
ShipmentScaleApplet applet = new ShipmentScaleApplet();
applet.sendMessage();
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,7 +200,7 @@
}
setWeight(weight);
}
-
+
// calls the setWeight(weight) JavaScript function on the current page
private void setWeight(String weight) {
JSObject win = JSObject.getWindow(this);
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=759254&r1=759253&r2=759254&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 Fri Mar 27 17:01:36 2009
@@ -45,13 +45,13 @@
* 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);
}
@@ -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);
@@ -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;
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=759254&r1=759253&r2=759254&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 Fri Mar 27 17:01:36 2009
@@ -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,7 +122,7 @@
CategoryWorker.setTrail(request, trail);
categoryId = pathElements.get(pathElements.size() - 1);
}
-
+
if (categoryId != null) {
request.setAttribute("productCategoryId", categoryId);
}
@@ -130,7 +130,7 @@
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=759254&r1=759253&r2=759254&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 Fri Mar 27 17:01:36 2009
@@ -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;
}
-
+
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=759254&r1=759253&r2=759254&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 Fri Mar 27 17:01:36 2009
@@ -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=759254&r1=759253&r2=759254&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 Fri Mar 27 17:01:36 2009
@@ -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,19 +443,19 @@
}
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);
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=759254&r1=759253&r2=759254&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 Fri Mar 27 17:01:36 2009
@@ -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=759254&r1=759253&r2=759254&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 Fri Mar 27 17:01:36 2009
@@ -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()) {
@@ -117,10 +117,10 @@
} 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();
@@ -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;
@@ -173,7 +173,7 @@
}
}
}
-
+
/**
* First search persisted configurations and update configWrapper.configId if found.
* Otherwise store ProductConfigWrapper to ProductConfigConfig entity and updates configWrapper.configId with new configId
@@ -223,7 +223,7 @@
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
-
+
}
}
if (UtilValidate.isNotEmpty(configsToCheck)) {
@@ -234,7 +234,7 @@
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;
@@ -250,7 +250,7 @@
}
}
}
-
+
boolean match = true;
for (ProductConfigWrapper.ConfigOption anOption : selectedOptions) {
if (match && anOption.hasVirtualComponent()) {
@@ -263,7 +263,7 @@
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);
configOptionProductOption.set("configItemId",configItemId);
@@ -279,14 +279,14 @@
}
}
}
-
+
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,10 +296,10 @@
} 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) {
@@ -316,7 +316,7 @@
}
}
}
-
+
if (selectedOptions.size() > 0) {
if (nextId) {
configId = delegator.getNextSeqId("ProductConfigConfig");
@@ -362,13 +362,13 @@
}
}
}
-
+
//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=759254&r1=759253&r2=759254&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 Fri Mar 27 17:01:36 2009
@@ -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);
@@ -170,7 +170,7 @@
}
}
}
-
+
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);
@@ -265,13 +265,13 @@
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) {
@@ -298,7 +298,7 @@
}
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();
@@ -325,11 +325,11 @@
}
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);
@@ -360,23 +360,23 @@
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;
@@ -575,7 +575,7 @@
// TODO: get the component's availability date
}
}
-
+
public ConfigOption(ConfigOption co) {
configOption = GenericValue.create(co.configOption);
componentList = FastList.newInstance();
@@ -588,7 +588,7 @@
selected = co.selected;
comments = co.getComments();
}
-
+
public void recalculateOptionPrice(ProductConfigWrapper pcw) throws Exception {
optionListPrice = BigDecimal.ZERO;
optionPrice = BigDecimal.ZERO;
@@ -597,11 +597,11 @@
BigDecimal price = BigDecimal.ZERO;
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));
}
-
+
// Get the component's price
Map<String, Object> fieldMap = UtilMisc.toMap("product", oneComponentProduct, "prodCatalogId", pcw.catalogId, "webSiteId", pcw.webSiteId,
"currencyUomId", pcw.currencyUomId, "productPricePurposeId", "COMPONENT_PRICE", "autoUserLogin", pcw.autoUserLogin);
@@ -643,27 +643,27 @@
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)) {
@@ -672,7 +672,7 @@
return optionListPrice;
}
}
-
+
public BigDecimal getOffsetPrice() {
ConfigOption defaultConfigOption = parentConfigItem.getDefault();
if (parentConfigItem.isSingleChoice() && UtilValidate.isNotEmpty(defaultConfigOption)) {
@@ -681,7 +681,7 @@
return optionPrice;
}
}
-
+
public boolean isDefault() {
ConfigOption defaultConfigOption = parentConfigItem.getDefault();
if (this.equals(defaultConfigOption)) {
@@ -689,7 +689,7 @@
}
return false;
}
-
+
public boolean hasVirtualComponent () {
List <GenericValue> components = getComponents();
if (UtilValidate.isNotEmpty(components)) {
@@ -702,7 +702,7 @@
return false;
}
-
+
public boolean isVirtualComponent (GenericValue component) {
int index = getComponents().indexOf(component);
if (index != -1) {
@@ -715,19 +715,19 @@
}
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;
}
@@ -739,7 +739,7 @@
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=759254&r1=759253&r2=759254&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 Fri Mar 27 17:01:36 2009
@@ -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=759254&r1=759253&r2=759254&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 Fri Mar 27 17:01:36 2009
@@ -42,15 +42,15 @@
* 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:
* ProductCategory -> ProductFeatureCategoryAppl -> ProductFeatureCategory -> ProductFeature.
* Returns a Map of Lists of ProductFeature GenericValue objects organized by productFeatureTypeId.
@@ -58,7 +58,7 @@
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 {
@@ -83,7 +83,7 @@
} 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);
@@ -92,7 +92,7 @@
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);
}
@@ -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,10 +210,10 @@
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;
@@ -222,7 +222,7 @@
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")) {
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ProductFeatureServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ProductFeatureServices.java?rev=759254&r1=759253&r2=759254&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ProductFeatureServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ProductFeatureServices.java Fri Mar 27 17:01:36 2009
@@ -51,7 +51,7 @@
public static final String module = ProductFeatureServices.class.getName();
public static final String resource = "ProductUiLabels";
-
+
/*
* Parameters: productFeatureCategoryId, productFeatureGroupId, productId, productFeatureApplTypeId
* Result: productFeaturesByType, a Map of all product features from productFeatureCategoryId, group by productFeatureType -> List of productFeatures
@@ -68,11 +68,11 @@
*/
String valueToSearch = (String) context.get("productFeatureCategoryId");
String productFeatureApplTypeId = (String) context.get("productFeatureApplTypeId");
-
+
String entityToSearch = "ProductFeature";
String fieldToSearch = "productFeatureCategoryId";
List<String> orderBy = UtilMisc.toList("productFeatureTypeId", "description");
-
+
if (valueToSearch == null && context.get("productFeatureGroupId") != null) {
entityToSearch = "ProductFeatureGroupAndAppl";
fieldToSearch = "productFeatureGroupId";
@@ -84,18 +84,18 @@
valueToSearch = (String) context.get("productId");
orderBy = UtilMisc.toList("sequenceNum", "productFeatureApplTypeId", "productFeatureTypeId", "description");
}
-
+
if (valueToSearch == null) {
return ServiceUtil.returnError("This service requires a productId, a productFeatureGroupId, or a productFeatureCategoryId to run.");
}
-
+
try {
// get all product features in this feature category
List<GenericValue> allFeatures = delegator.findByAnd(entityToSearch, UtilMisc.toMap(fieldToSearch, valueToSearch), orderBy);
-
+
if (entityToSearch.equals("ProductFeatureAndAppl") && productFeatureApplTypeId != null)
allFeatures = EntityUtil.filterByAnd(allFeatures, UtilMisc.toMap("productFeatureApplTypeId", productFeatureApplTypeId));
-
+
List<String> featureTypes = FastList.newInstance();
Map<String, List<GenericValue>> featuresByType = new LinkedHashMap<String, List<GenericValue>>();
for (GenericValue feature: allFeatures) {
@@ -120,7 +120,7 @@
}
return results;
}
-
+
/*
* Parameter: productId, productFeatureAppls (a List of ProductFeatureAndAppl entities of features applied to productId)
* Result: variantProductIds: a List of productIds of variants with those features
@@ -132,7 +132,7 @@
String productId = (String) context.get("productId");
List<String> curProductFeatureAndAppls = UtilGenerics.checkList(context.get("productFeatureAppls"));
List<String> existingVariantProductIds = FastList.newInstance();
-
+
try {
/*
* get a list of all products which are associated with the current one as PRODUCT_VARIANT and for each one,
@@ -183,38 +183,38 @@
public static Map<String, Object> getVariantCombinations(DispatchContext dctx, Map<String, ? extends Object> context) {
Map<String, Object> results = FastMap.newInstance();
LocalDispatcher dispatcher = dctx.getDispatcher();
-
+
String productId = (String) context.get("productId");
-
+
try {
Map<String, Object> featuresResults = dispatcher.runSync("getProductFeaturesByType", UtilMisc.toMap("productId", productId));
Map<String, List<GenericValue>> features;
-
+
if (featuresResults.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_SUCCESS)) {
features = UtilGenerics.checkMap(featuresResults.get("productFeaturesByType"));
} else {
return ServiceUtil.returnError((String) featuresResults.get(ModelService.ERROR_MESSAGE_LIST));
}
-
+
// need to keep 2 lists, oldCombinations and newCombinations, and keep swapping them after each looping. Otherwise, you'll get a
// concurrent modification exception
List<Map<String, Object>> oldCombinations = FastList.newInstance();
-
+
// loop through each feature type
for (Map.Entry<String, List<GenericValue>> entry: features.entrySet()) {
String currentFeatureType = entry.getKey();
List<GenericValue> currentFeatures = entry.getValue();
-
+
List<Map<String, Object>> newCombinations = FastList.newInstance();
List<Map<String, Object>> combinations;
-
+
// start with either existing combinations or from scratch
if (oldCombinations.size() > 0) {
combinations = oldCombinations;
} else {
combinations = FastList.newInstance();
}
-
+
// in both cases, use each feature of current feature type's idCode and
// product feature and add it to the id code and product feature applications
// of the next variant. just a matter of whether we're starting with an
@@ -264,11 +264,11 @@
oldCombinations = newCombinations; // save the newly expanded list as oldCombinations
}
}
-
+
int defaultCodeCounter = 1;
Set<String> defaultVariantProductIds = FastSet.newInstance(); // this map will contain the codes already used (as keys)
defaultVariantProductIds.add(productId);
-
+
// now figure out which of these combinations already have productIds associated with them
for (Map<String, Object> combination: oldCombinations) {
// Verify if the default code is already used, if so add a numeric suffix
@@ -287,7 +287,7 @@
Debug.logError(ex, ex.getMessage(), module);
return ServiceUtil.returnError(ex.getMessage());
}
-
+
return results;
}