Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java Mon Nov 10 18:20:53 2008 @@ -92,9 +92,7 @@ } if (UtilValidate.isNotEmpty(featureIdSet)) { - Iterator<String> featureIdIter = featureIdSet.iterator(); - while (featureIdIter.hasNext()) { - String productFeatureId = featureIdIter.next(); + for (String productFeatureId: featureIdSet) { productSearchConstraintList.add(new FeatureConstraint(productFeatureId, null)); } } @@ -125,11 +123,7 @@ // now find all sub-categories, filtered by effective dates, and call this routine for them try { List<GenericValue> productCategoryRollupList = delegator.findByAndCache("ProductCategoryRollup", UtilMisc.toMap("parentProductCategoryId", productCategoryId)); - - Iterator<GenericValue> productCategoryRollupIter = productCategoryRollupList.iterator(); - while (productCategoryRollupIter.hasNext()) { - GenericValue productCategoryRollup = productCategoryRollupIter.next(); - + for (GenericValue productCategoryRollup: productCategoryRollupList) { String subProductCategoryId = productCategoryRollup.getString("productCategoryId"); if (productCategoryIdSet.contains(subProductCategoryId)) { // if this category has already been traversed, no use doing it again; this will also avoid infinite loops @@ -202,9 +196,7 @@ public void addProductSearchConstraints(List<ProductSearchConstraint> productSearchConstraintList) { // Go through the constraints and add them in - Iterator<ProductSearchConstraint> productSearchConstraintIter = productSearchConstraintList.iterator(); - while (productSearchConstraintIter.hasNext()) { - ProductSearchConstraint constraint = productSearchConstraintIter.next(); + for (ProductSearchConstraint constraint: productSearchConstraintList) { constraint.addConstraint(this); } } @@ -283,10 +275,7 @@ if (andKeywordFixedSet.size() > 0) { // add up the relevancyWeight fields from all keyword member entities for a total to sort by - Iterator<String> keywordIter = andKeywordFixedSet.iterator(); - while (keywordIter.hasNext()) { - String keyword = keywordIter.next(); - + for (String keyword: andKeywordFixedSet) { // make index based values and increment String entityAlias = "PK" + index; String prefix = "pk" + index; @@ -312,9 +301,7 @@ } } if (keywordFixedOrSetAndList.size() > 0) { - Iterator<Set<String>> keywordFixedOrSetAndIter = keywordFixedOrSetAndList.iterator(); - while (keywordFixedOrSetAndIter.hasNext()) { - Set<String> keywordFixedOrSet = keywordFixedOrSetAndIter.next(); + for (Set<String> keywordFixedOrSet: keywordFixedOrSetAndList) { // make index based values and increment String entityAlias = "PK" + index; String prefix = "pk" + index; @@ -324,9 +311,7 @@ dynamicViewEntity.addAlias(entityAlias, prefix + "Keyword", "keyword", null, null, null, null); dynamicViewEntity.addViewLink("PROD", entityAlias, Boolean.FALSE, ModelKeyMap.makeKeyMapList("productId")); List<EntityCondition> keywordOrList = FastList.newInstance(); - Iterator<String> keywordIter = keywordFixedOrSet.iterator(); - while (keywordIter.hasNext()) { - String keyword = keywordIter.next(); + for (String keyword: keywordFixedOrSet) { keywordOrList.add(EntityCondition.makeCondition(prefix + "Keyword", EntityOperator.LIKE, keyword)); } entityConditionList.add(EntityCondition.makeCondition(keywordOrList, EntityOperator.OR)); @@ -368,9 +353,7 @@ EntityCondition topCond = null; if (includeCategoryIds.size() > 0) { - Iterator<String> includeCategoryIdIter = includeCategoryIds.iterator(); - while (includeCategoryIdIter.hasNext()) { - String includeCategoryId = includeCategoryIdIter.next(); + for (String includeCategoryId: includeCategoryIds) { String categoryPrefix = "pcm" + this.index; String entityAlias = "PCM" + this.index; this.index++; @@ -386,9 +369,7 @@ } } if (includeFeatureIds.size() > 0) { - Iterator<String> includeFeatureIdIter = includeFeatureIds.iterator(); - while (includeFeatureIdIter.hasNext()) { - String includeFeatureId = includeFeatureIdIter.next(); + for (String includeFeatureId: includeFeatureIds) { String featurePrefix = "pfa" + this.index; String entityAlias = "PFA" + this.index; this.index++; @@ -404,9 +385,7 @@ } } if (includeFeatureCategoryIds.size() > 0) { - Iterator<String> includeFeatureCategoryIdIter = includeFeatureCategoryIds.iterator(); - while (includeFeatureCategoryIdIter.hasNext()) { - String includeFeatureCategoryId = includeFeatureCategoryIdIter.next(); + for (String includeFeatureCategoryId: includeFeatureCategoryIds) { String featurePrefix = "pfa" + this.index; String entityAlias = "PFA" + this.index; String otherFeaturePrefix = "pfe" + this.index; @@ -426,9 +405,7 @@ } } if (includeFeatureGroupIds.size() > 0) { - Iterator<String> includeFeatureGroupIdIter = includeFeatureGroupIds.iterator(); - while (includeFeatureGroupIdIter.hasNext()) { - String includeFeatureGroupId = includeFeatureGroupIdIter.next(); + for (String includeFeatureGroupId: includeFeatureGroupIds) { String featurePrefix = "pfa" + this.index; String entityAlias = "PFA" + this.index; String otherFeaturePrefix = "pfga" + this.index; @@ -516,9 +493,7 @@ alwIncCondList.add(EntityCondition.makeCondition(featurePrefix + "ProductFeatureId", EntityOperator.IN, alwaysIncludeFeatureIds)); } if (alwaysIncludeFeatureCategoryIds.size() > 0) { - Iterator<String> alwaysIncludeFeatureCategoryIdIter = alwaysIncludeFeatureCategoryIds.iterator(); - while (alwaysIncludeFeatureCategoryIdIter.hasNext()) { - String alwaysIncludeFeatureCategoryId = alwaysIncludeFeatureCategoryIdIter.next(); + for (String alwaysIncludeFeatureCategoryId: alwaysIncludeFeatureCategoryIds) { String featurePrefix = "pfa" + this.index; String entityAlias = "PFA" + this.index; String otherFeaturePrefix = "pfe" + this.index; @@ -538,9 +513,7 @@ } } if (alwaysIncludeFeatureGroupIds.size() > 0) { - Iterator<String> alwaysIncludeFeatureGroupIdIter = alwaysIncludeFeatureGroupIds.iterator(); - while (alwaysIncludeFeatureGroupIdIter.hasNext()) { - String alwaysIncludeFeatureGroupId = alwaysIncludeFeatureGroupIdIter.next(); + for (String alwaysIncludeFeatureGroupId: alwaysIncludeFeatureGroupIds) { String featurePrefix = "pfa" + this.index; String entityAlias = "PFA" + this.index; String otherFeaturePrefix = "pfga" + this.index; @@ -566,9 +539,7 @@ // handle includeFeatureIdOrSetAndList and alwaysIncludeFeatureIdOrSetAndList if (includeFeatureIdOrSetAndList.size() > 0) { - Iterator<Set<String>> includeFeatureIdOrSetAndIter = includeFeatureIdOrSetAndList.iterator(); - while (includeFeatureIdOrSetAndIter.hasNext()) { - Set<String> includeFeatureIdOrSet = includeFeatureIdOrSetAndIter.next(); + for (Set<String> includeFeatureIdOrSet: includeFeatureIdOrSetAndList) { String featurePrefix = "pfa" + this.index; String entityAlias = "PFA" + this.index; this.index++; @@ -584,9 +555,7 @@ } } if (alwaysIncludeFeatureIdOrSetAndList.size() > 0) { - Iterator<Set<String>> alwaysIncludeFeatureIdOrSetAndIter = alwaysIncludeFeatureIdOrSetAndList.iterator(); - while (alwaysIncludeFeatureIdOrSetAndIter.hasNext()) { - Set<String> alwaysIncludeFeatureIdOrSet = alwaysIncludeFeatureIdOrSetAndIter.next(); + for (Set<String> alwaysIncludeFeatureIdOrSet: alwaysIncludeFeatureIdOrSetAndList) { String featurePrefix = "pfa" + this.index; String entityAlias = "PFA" + this.index; this.index++; @@ -604,9 +573,7 @@ // handle includeCategoryIdOrSetAndList and alwaysIncludeCategoryIdOrSetAndList if (includeCategoryIdOrSetAndList.size() > 0) { - Iterator<Set<String>> includeCategoryIdOrSetAndIter = includeCategoryIdOrSetAndList.iterator(); - while (includeCategoryIdOrSetAndIter.hasNext()) { - Set<String> includeCategoryIdOrSet = includeCategoryIdOrSetAndIter.next(); + for (Set<String> includeCategoryIdOrSet: includeCategoryIdOrSetAndList) { String categoryPrefix = "pcm" + this.index; String entityAlias = "PCM" + this.index; this.index++; @@ -622,9 +589,7 @@ } } if (alwaysIncludeCategoryIdOrSetAndList.size() > 0) { - Iterator<Set<String>> alwaysIncludeCategoryIdOrSetAndIter = alwaysIncludeCategoryIdOrSetAndList.iterator(); - while (alwaysIncludeCategoryIdOrSetAndIter.hasNext()) { - Set<String> alwaysIncludeCategoryIdOrSet = alwaysIncludeCategoryIdOrSetAndIter.next(); + for (Set<String> alwaysIncludeCategoryIdOrSet: alwaysIncludeCategoryIdOrSetAndList) { String categoryPrefix = "pcm" + this.index; String entityAlias = "PCM" + this.index; this.index++; @@ -762,9 +727,7 @@ /* StringBuilder lineMsg = new StringBuilder("Got search result line: "); - Iterator<String> fieldsToSelectIter = fieldsToSelect.iterator(); - while (fieldsToSelectIter.hasNext()) { - String fieldName = fieldsToSelectIter.next(); + for (String fieldName: fieldsToSelect) { lineMsg.append(fieldName); lineMsg.append("="); lineMsg.append(searchResult.get(fieldName)); @@ -823,10 +786,8 @@ productSearchResult.set("searchDate", nowTimestamp); productSearchResult.create(); - Iterator<GenericValue> productSearchConstraintIter = productSearchConstraintList.iterator(); int seqId = 1; - while (productSearchConstraintIter.hasNext()) { - GenericValue productSearchConstraint = productSearchConstraintIter.next(); + for (GenericValue productSearchConstraint: productSearchConstraintList) { productSearchConstraint.set("productSearchResultId", productSearchResultId); productSearchConstraint.set("constraintSeqId", Integer.toString(seqId)); productSearchConstraint.create(); @@ -870,9 +831,7 @@ public void addConstraint(ProductSearchContext productSearchContext) { List<String> productCategoryIds = FastList.newInstance(); - Iterator<GenericValue> itCat = productCategories.iterator(); - while (itCat.hasNext()) { - GenericValue category = itCat.next(); + for (GenericValue category: productCategories) { productCategoryIds.add(category.getString("productCategoryId")); } @@ -1283,13 +1242,11 @@ // add in productSearchConstraint, don't worry about the productSearchResultId or constraintSeqId, those will be fill in later StringBuilder featureIdInfo = new StringBuilder(); - Iterator<String> featureIdIter = this.productFeatureIdSet.iterator(); - while (featureIdIter.hasNext()) { - String featureId = featureIdIter.next(); - featureIdInfo.append(featureId); - if (featureIdIter.hasNext()) { + for (String featureId: this.productFeatureIdSet) { + if (featureIdInfo.length() > 0) { featureIdInfo.append(","); } + featureIdInfo.append(featureId); } productSearchContext.productSearchConstraintList.add(productSearchContext.getDelegator().makeValue("ProductSearchConstraint", UtilMisc.toMap("constraintName", constraintName, "infoString", featureIdInfo.toString()))); @@ -1298,9 +1255,10 @@ public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed, Locale locale) { StringBuilder infoOut = new StringBuilder(); try { - Iterator<String> featureIdIter = this.productFeatureIdSet.iterator(); - while (featureIdIter.hasNext()) { - String featureId = featureIdIter.next(); + for (String featureId: this.productFeatureIdSet) { + if (infoOut.length() > 0) { + infoOut.append(", "); + } GenericValue productFeature = delegator.findByPrimaryKeyCache("ProductFeature", UtilMisc.toMap("productFeatureId", featureId)); GenericValue productFeatureType = productFeature == null ? null : productFeature.getRelatedOneCache("ProductFeatureType"); if (productFeatureType == null) { @@ -1317,9 +1275,6 @@ infoOut.append(productFeature.getString("description")); } - if (featureIdIter.hasNext()) { - infoOut.append(", "); - } } } catch (GenericEntityException e) { Debug.logError(e, "Error finding ProductFeature and Type information for constraint pretty print", module); @@ -1373,9 +1328,7 @@ Set<String> fullKeywordSet = new TreeSet<String>(); // expand the keyword list according to the thesaurus and create a new set of keywords - Iterator<String> keywordIter = keywordSet.iterator(); - while (keywordIter.hasNext()) { - String keyword = keywordIter.next(); + for (String keyword: keywordSet) { Set<String> expandedSet = new TreeSet<String>(); boolean replaceEntered = KeywordSearchUtil.expandKeywordForSearch(keyword, expandedSet, delegator); fullKeywordSet.addAll(expandedSet); @@ -1399,9 +1352,7 @@ Set<String> keywordSet = KeywordSearchUtil.makeKeywordSet(this.keywordsString, null, true); // expand the keyword list according to the thesaurus and create a new set of keywords - Iterator<String> keywordIter = keywordSet.iterator(); - while (keywordIter.hasNext()) { - String keyword = keywordIter.next(); + for (String keyword: keywordSet) { Set<String> expandedSet = new TreeSet<String>(); boolean replaceEntered = KeywordSearchUtil.expandKeywordForSearch(keyword, expandedSet, productSearchContext.getDelegator()); if (!replaceEntered) { @@ -2097,10 +2048,7 @@ // add up the relevancyWeight fields from all keyword member entities for a total to sort by ComplexAlias complexAlias = new ComplexAlias("+"); - Iterator<String> keywordIter = keywordList.iterator(); - while (keywordIter.hasNext()) { - String keyword = keywordIter.next(); - + for (String keyword: keywordList) { // make index based values and increment String entityAlias = "PK" + index; String prefix = "pk" + index; @@ -2130,9 +2078,7 @@ orderByList.add("-totalRelevancy"); fieldsToSelect.add("totalRelevancy"); List<EntityCondition> keywordOrList = new FastList.newInstance(); - Iterator<String> keywordIter = keywordList.iterator(); - while (keywordIter.hasNext()) { - String keyword = keywordIter.next(); + for (String keyword: keywordList) { keywordOrList.add(EntityCondition.makeCondition(prefix + "Keyword", EntityOperator.LIKE, keyword)); } entityConditionList.add(EntityCondition.makeCondition(keywordOrList, EntityOperator.OR)); @@ -2143,9 +2089,7 @@ // Features if (UtilValidate.isNotEmpty(featureIdSet)) { - Iterator<String> featureIdIter = featureIdSet.iterator(); - while (featureIdIter.hasNext()) { - String productFeatureId = featureIdIter.next(); + for (String productFeatureID: featureIdSet) { // make index based values and increment String entityAlias = "PFA" + index; String prefix = "pfa" + index; Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java Mon Nov 10 18:20:53 2008 @@ -19,7 +19,6 @@ package org.ofbiz.product.product; import java.sql.Timestamp; -import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -151,9 +150,7 @@ List<GenericValue> pcmList = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productCategoryId", productCategoryId, "productId", productId )); //set those thrudate to that specificed maybe remove then add new one - Iterator<GenericValue> pcmListIter=pcmList.iterator(); - while (pcmListIter.hasNext()) { - GenericValue pcm = pcmListIter.next(); + for (GenericValue pcm: pcmList) { if (pcm.get("thruDate") == null) { pcm.set("thruDate", thruDate); pcm.store(); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java Mon Nov 10 18:20:53 2008 @@ -22,7 +22,6 @@ import java.sql.Timestamp; import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -269,9 +268,7 @@ if (productSearchConstraintList == null) { return constraintStrings; } - Iterator<ProductSearchConstraint> productSearchConstraintIter = productSearchConstraintList.iterator(); - while (productSearchConstraintIter.hasNext()) { - ProductSearchConstraint productSearchConstraint = productSearchConstraintIter.next(); + for (ProductSearchConstraint productSearchConstraint: productSearchConstraintList) { if (productSearchConstraint == null) continue; String constraintString = productSearchConstraint.prettyPrintConstraint(delegator, detailed, locale); if (UtilValidate.isNotEmpty(constraintString)) { @@ -374,9 +371,7 @@ Set<String> keywords = FastSet.newInstance(); List<ProductSearchConstraint> constraintList = ProductSearchOptions.getConstraintList(session); if (constraintList != null) { - Iterator<ProductSearchConstraint> constraintIter = constraintList.iterator(); - while (constraintIter.hasNext()) { - ProductSearchConstraint constraint = constraintIter.next(); + for (ProductSearchConstraint constraint: constraintList) { if (constraint instanceof KeywordConstraint) { KeywordConstraint keywordConstraint = (KeywordConstraint) constraint; Set<String> keywordSet = keywordConstraint.makeFullKeywordSet(delegator); @@ -395,9 +390,7 @@ } if (UtilValidate.isNotEmpty(productStoreKeywordOvrdList)) { - Iterator<GenericValue> productStoreKeywordOvrdIter = productStoreKeywordOvrdList.iterator(); - while (productStoreKeywordOvrdIter.hasNext()) { - GenericValue productStoreKeywordOvrd = productStoreKeywordOvrdIter.next(); + for (GenericValue productStoreKeywordOvrd: productStoreKeywordOvrdList) { String ovrdKeyword = productStoreKeywordOvrd.getString("keyword"); if (keywords.contains(ovrdKeyword)) { String targetTypeEnumId = productStoreKeywordOvrd.getString("targetTypeEnumId"); @@ -478,9 +471,7 @@ if (featureIds == null || featureIds.size() == 0) { return; } - Iterator<String> featureIdIter = featureIds.iterator(); - while (featureIdIter.hasNext()) { - String productFeatureId = featureIdIter.next(); + for (String productFeatureId: featureIds) { searchAddConstraint(new FeatureConstraint(productFeatureId, exclude), session); } } @@ -612,9 +603,7 @@ } } - Iterator<String> parameterNameIter = parameters.keySet().iterator(); - while (parameterNameIter.hasNext()) { - String parameterName = parameterNameIter.next(); + for (String parameterName: parameters.keySet()) { if (parameterName.startsWith("SEARCH_FEAT") && !parameterName.startsWith("SEARCH_FEAT_EXC")) { String productFeatureId = (String) parameters.get(parameterName); if (productFeatureId != null && productFeatureId.length() > 0) { @@ -893,8 +882,7 @@ pli = delegator.find("ProductCategoryMember", EntityCondition.makeCondition(addOnTopProdCondList, EntityOperator.AND), null, UtilMisc.toSet("productId", "sequenceNum"), UtilMisc.toList("sequenceNum"), findOpts); addOnTopProductCategoryMembers = pli.getPartialList(lowIndex, viewSize); addOnTopListSize = addOnTopProductCategoryMembers.size(); - for (int i = 0; i < addOnTopProductCategoryMembers.size(); i++) { - GenericValue alwaysAddProductCategoryMember = addOnTopProductCategoryMembers.get(i); + for (GenericValue alwaysAddProductCategoryMember: addOnTopProductCategoryMembers) { productIds.add(alwaysAddProductCategoryMember.getString("productId")); } // attempt to get the full size @@ -974,16 +962,13 @@ StringBuilder searchParamString = new StringBuilder(); List<ProductSearchConstraint> constraintList = productSearchOptions.getConstraintList(); - Iterator<ProductSearchConstraint> constraintIter = constraintList.iterator(); - int categoriesCount = 0; int featuresCount = 0; int featureCategoriesCount = 0; int featureGroupsCount = 0; int keywordsCount = 0; boolean isNotFirst = false; - while (constraintIter.hasNext()) { - ProductSearchConstraint psc = constraintIter.next(); + for (ProductSearchConstraint psc: constraintList) { if (psc instanceof ProductSearch.CategoryConstraint) { ProductSearch.CategoryConstraint cc = (ProductSearch.CategoryConstraint) psc; categoriesCount++; Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java Mon Nov 10 18:20:53 2008 @@ -81,18 +81,13 @@ // All the variants for this products are retrieved Map<String, Object> resVariants = prodFindAllVariants(dctx, context); List<GenericValue> variants = UtilGenerics.checkList(resVariants.get("assocProducts")); - GenericValue oneVariant = null; - Iterator<GenericValue> variantsIt = variants.iterator(); - while (variantsIt.hasNext()) { - oneVariant = variantsIt.next(); + for (GenericValue oneVariant: variants) { // For every variant, all the standard features are retrieved Map<String, String> feaContext = FastMap.newInstance(); feaContext.put("productId", oneVariant.getString("productIdTo")); feaContext.put("type", "STANDARD_FEATURE"); Map<String, Object> resFeatures = prodGetFeatures(dctx, feaContext); List<GenericValue> features = UtilGenerics.checkList(resFeatures.get("productFeatures")); - Iterator<GenericValue> featuresIt = features.iterator(); - GenericValue oneFeature = null; boolean variantFound = true; // The variant is discarded if at least one of its standard features // has the same type of one of the selected features but a different feature id. @@ -102,8 +97,7 @@ // Variant2: (COLOR, Black), (SIZE, Small) --> ok // Variant3: (COLOR, Black), (SIZE, Small), (IMAGE, SkyLine) --> ok // Variant4: (COLOR, Black), (IMAGE, SkyLine) --> ok - while (featuresIt.hasNext()) { - oneFeature = featuresIt.next(); + for (GenericValue oneFeature: features) { if (selectedFeatures.containsKey(oneFeature.getString("productFeatureTypeId"))) { if (!selectedFeatures.containsValue(oneFeature.getString("productFeatureId"))) { variantFound = false; @@ -156,9 +150,8 @@ Map<String, String> fields = UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "SELECTABLE_FEATURE"); List<String> order = UtilMisc.toList("sequenceNum", "productFeatureTypeId"); List<GenericValue> features = delegator.findByAndCache("ProductFeatureAndAppl", fields, order); - Iterator<GenericValue> i = features.iterator(); - while (i.hasNext()) { - featureSet.add(i.next().getString("productFeatureTypeId")); + for (GenericValue v: features) { + featureSet.add(v.getString("productFeatureTypeId")); } //if (Debug.infoOn()) Debug.logInfo("" + featureSet, module); } catch (GenericEntityException e) { @@ -205,10 +198,9 @@ return ServiceUtil.returnSuccess(); } List<String> items = FastList.newInstance(); - Iterator<GenericValue> i = variants.iterator(); - while (i.hasNext()) { - String productIdTo = i.next().getString("productIdTo"); + for (GenericValue variant: variants) { + String productIdTo = variant.getString("productIdTo"); // first check to see if intro and discontinue dates are within range GenericValue productTo = null; @@ -282,10 +274,7 @@ return ServiceUtil.returnError(UtilProperties.getMessage(resource,"productservices.empty_list_of_selectable_features_found", locale)); } Map<String, List<String>> features = FastMap.newInstance(); - Iterator<GenericValue> sFIt = selectableFeatures.iterator(); - - while (sFIt.hasNext()) { - GenericValue v = sFIt.next(); + for (GenericValue v: selectableFeatures) { String featureType = v.getString("productFeatureTypeId"); String feature = v.getString("description"); @@ -520,13 +509,10 @@ } // loop through items and make the lists - Iterator<String> itemIterator = items.iterator(); - - while (itemIterator.hasNext()) { + for (String thisItem: items) { // ------------------------------- // Gather the necessary data // ------------------------------- - String thisItem = itemIterator.next(); if (Debug.verboseOn()) Debug.logVerbose("ThisItem: " + thisItem, module); List<GenericValue> features = null; @@ -545,10 +531,7 @@ if (Debug.verboseOn()) Debug.logVerbose("Features: " + features, module); // ------------------------------- - Iterator<GenericValue> featuresIterator = features.iterator(); - - while (featuresIterator.hasNext()) { - GenericValue item = featuresIterator.next(); + for (GenericValue item: features) { String itemKey = item.getString("description"); if (tempGroup.containsKey(itemKey)) { @@ -572,11 +555,7 @@ throw new IllegalArgumentException("Cannot build feature tree: orderFeatureList is null for orderKey=" + orderKey); } - Iterator<String> featureListIt = orderFeatureList.iterator(); - - while (featureListIt.hasNext()) { - String featureStr = featureListIt.next(); - + for (String featureStr: orderFeatureList) { if (tempGroup.containsKey(featureStr)) group.put(featureStr, tempGroup.get(featureStr)); } @@ -594,9 +573,7 @@ } // loop through the keysets and get the sub-groups - Iterator<String> groupIterator = group.keySet().iterator(); - while (groupIterator.hasNext()) { - String key = groupIterator.next(); + for (String key: group.keySet()) { List<String> itemList = UtilGenerics.checkList(group.get(key)); if (UtilValidate.isNotEmpty(itemList)) { @@ -614,10 +591,7 @@ private static Map<String, GenericValue> makeVariantSample(GenericDelegator delegator, Map<String, List<String>> featureList, List<String> items, String feature) { Map<String, GenericValue> tempSample = FastMap.newInstance(); Map<String, GenericValue> sample = new LinkedHashMap<String, GenericValue>(); - Iterator<String> itemIt = items.iterator(); - - while (itemIt.hasNext()) { - String productId = itemIt.next(); + for (String productId: items) { List<GenericValue> features = null; try { @@ -631,11 +605,7 @@ } catch (GenericEntityException e) { throw new IllegalStateException("Problem reading relation: " + e.getMessage()); } - Iterator<GenericValue> featureIt = features.iterator(); - - while (featureIt.hasNext()) { - GenericValue featureAppl = featureIt.next(); - + for (GenericValue featureAppl: features) { try { GenericValue product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", productId)); @@ -649,11 +619,7 @@ // Sort the sample based on the feature list. List<String> features = featureList.get(feature); - Iterator<String> fi = features.iterator(); - - while (fi.hasNext()) { - String f = fi.next(); - + for (String f: features) { if (tempSample.containsKey(f)) sample.put(f, tempSample.get(f)); } @@ -801,9 +767,7 @@ //note: should support both direct productIds and GoodIdentification entries (what to do if more than one GoodID? Add all? Map<String, GenericValue> variantProductsById = FastMap.newInstance(); - Iterator<String> variantProductIdIter = prelimVariantProductIds.iterator(); - while (variantProductIdIter.hasNext()) { - String variantProductId = variantProductIdIter.next(); + for (String variantProductId: prelimVariantProductIds) { if (UtilValidate.isEmpty(variantProductId)) { // not sure why this happens, but seems to from time to time with the split method continue; @@ -825,9 +789,7 @@ Debug.logWarning("Warning creating a virtual with variants: the ID [" + variantProductId + "] was not a productId and resulted in [" + goodIdentificationList.size() + "] GoodIdentification records: " + goodIdentificationList, module); } - Iterator<GenericValue> goodIdentificationIter = goodIdentificationList.iterator(); - while (goodIdentificationIter.hasNext()) { - GenericValue goodIdentification = goodIdentificationIter.next(); + for (GenericValue goodIdentification: goodIdentificationList) { GenericValue giProduct = goodIdentification.getRelatedOne("Product"); if (giProduct != null) { variantProductsById.put(giProduct.getString("productId"), giProduct); @@ -845,12 +807,8 @@ productFeatureIds.add(productFeatureIdTwo); productFeatureIds.add(productFeatureIdThree); - Iterator<String> featureProductIdIter = featureProductIds.iterator(); - while (featureProductIdIter.hasNext()) { - Iterator<String> productFeatureIdIter = productFeatureIds.iterator(); - String featureProductId = featureProductIdIter.next(); - while (productFeatureIdIter.hasNext()) { - String productFeatureId = productFeatureIdIter.next(); + for (String featureProductId: featureProductIds) { + for (String productFeatureId: productFeatureIds) { if (UtilValidate.isNotEmpty(productFeatureId)) { GenericValue productFeatureAppl = delegator.makeValue("ProductFeatureAppl", UtilMisc.toMap("productId", featureProductId, "productFeatureId", productFeatureId, @@ -860,10 +818,8 @@ } } - Iterator<GenericValue> variantProductIter = variantProductsById.values().iterator(); - while (variantProductIter.hasNext()) { + for (GenericValue variantProduct: variantProductsById.values()) { // for each variant product set: isVirtual=N, isVariant=Y, introductionDate=now - GenericValue variantProduct = variantProductIter.next(); variantProduct.set("isVirtual", "N"); variantProduct.set("isVariant", "Y"); variantProduct.set("introductionDate", nowTimestamp); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java Mon Nov 10 18:20:53 2008 @@ -19,7 +19,6 @@ package org.ofbiz.product.product; import java.sql.Timestamp; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -87,9 +86,7 @@ List<GenericValue> passocList = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", virtualProductId, "productIdTo", productOne.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT")); passocList = EntityUtil.filterByDate(passocList); if (passocList.size() > 0) { - Iterator<GenericValue> passocIter = passocList.iterator(); - while (passocIter.hasNext()) { - GenericValue passoc = passocIter.next(); + for (GenericValue passoc: passocList) { passoc.set("thruDate", nowTimestamp); passoc.store(); } @@ -152,9 +149,7 @@ String productId = product.getString("productId"); List<GenericValue> productCategoryMemberList = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productId", productId)); if (productCategoryMemberList.size() > 0) { - Iterator<GenericValue> productCategoryMemberIter = productCategoryMemberList.iterator(); - while (productCategoryMemberIter.hasNext()) { - GenericValue productCategoryMember = productCategoryMemberIter.next(); + for (GenericValue productCategoryMember: productCategoryMemberList) { // coded this way rather than a removeByAnd so it can be easily changed... productCategoryMember.remove(); } @@ -204,9 +199,7 @@ if (productCategoryMemberList.size() > 1) { // remove all except the first... productCategoryMemberList.remove(0); - Iterator<GenericValue> productCategoryMemberIter = productCategoryMemberList.iterator(); - while (productCategoryMemberIter.hasNext()) { - GenericValue productCategoryMember = productCategoryMemberIter.next(); + for (GenericValue productCategoryMember: productCategoryMemberList) { productCategoryMember.remove(); } numSoFar++; @@ -264,11 +257,8 @@ Debug.logInfo("Found " + valueList.size() + " virtual products with one variant to turn into a stand alone product.", module); int numWithOneOnly = 0; - Iterator<GenericValue> valueIter = valueList.iterator(); - while (valueIter.hasNext()) { + for (GenericValue value: valueList) { // has only one variant period, is it valid? should already be discontinued if not - GenericValue value = valueIter.next(); - String productId = value.getString("productId"); List<GenericValue> paList = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT")); paList = EntityUtil.filterByDate(paList); @@ -302,9 +292,7 @@ Debug.logInfo("Found " + valueMultiList.size() + " virtual products with one VALID variant to pull the variant from to make a stand alone product.", module); int numWithOneValid = 0; - Iterator<GenericValue> valueMultiIter = valueMultiList.iterator(); - while (valueMultiIter.hasNext()) { - GenericValue value = valueMultiIter.next(); + for (GenericValue value: valueMultiList) { // has only one valid variant String productId = value.getString("productId"); @@ -456,9 +444,7 @@ protected static void duplicateRelated(GenericValue product, String title, String relatedEntityName, String productIdField, String variantProductId, Timestamp nowTimestamp, boolean removeOld, GenericDelegator delegator, boolean test) throws GenericEntityException { List<GenericValue> relatedList = EntityUtil.filterByDate(product.getRelated(title + relatedEntityName), nowTimestamp); - Iterator<GenericValue> relatedIter = relatedList.iterator(); - while (relatedIter.hasNext()) { - GenericValue relatedValue = relatedIter.next(); + for (GenericValue relatedValue: relatedList) { GenericValue newRelatedValue = (GenericValue) relatedValue.clone(); newRelatedValue.set(productIdField, variantProductId); @@ -669,9 +655,7 @@ // do sub-categories first so all feature groups will be in place List<GenericValue> subCategoryList = delegator.findByAnd("ProductCategoryRollup", UtilMisc.toMap("parentProductCategoryId", productCategoryId)); if (doSubCategories) { - Iterator<GenericValue> subCategoryIter = subCategoryList.iterator(); - while (subCategoryIter.hasNext()) { - GenericValue productCategoryRollup = subCategoryIter.next(); + for (GenericValue productCategoryRollup: subCategoryList) { attachProductFeaturesToCategory(productCategoryRollup.getString("productCategoryId"), productFeatureTypeIdsToInclude, productFeatureTypeIdsToExclude, delegator, true, nowTimestamp); } } @@ -679,9 +663,7 @@ // now get all features for this category and make associated feature groups Map<String, Set<String>> productFeatureIdByTypeIdSetMap = FastMap.newInstance(); List<GenericValue> productCategoryMemberList = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productCategoryId", productCategoryId)); - Iterator<GenericValue> productCategoryMemberIter = productCategoryMemberList.iterator(); - while (productCategoryMemberIter.hasNext()) { - GenericValue productCategoryMember = productCategoryMemberIter.next(); + for (GenericValue productCategoryMember: productCategoryMemberList) { String productId = productCategoryMember.getString("productId"); EntityCondition condition = EntityCondition.makeCondition(UtilMisc.toList( EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId), @@ -709,9 +691,7 @@ productFeatureAndApplEli.close(); } - Iterator<Map.Entry<String, Set<String>>> productFeatureIdByTypeIdSetIter = productFeatureIdByTypeIdSetMap.entrySet().iterator(); - while (productFeatureIdByTypeIdSetIter.hasNext()) { - Map.Entry<String, Set<String>> entry = productFeatureIdByTypeIdSetIter.next(); + for (Map.Entry<String, Set<String>> entry: productFeatureIdByTypeIdSetMap.entrySet()) { String productFeatureTypeId = entry.getKey(); Set<String> productFeatureIdSet = entry.getValue(); @@ -733,9 +713,7 @@ } // now put all of the features in the group, if there is not already a valid feature placement there... - Iterator<String> productFeatureIdIter = productFeatureIdSet.iterator(); - while (productFeatureIdIter.hasNext()) { - String productFeatureId = productFeatureIdIter.next(); + for (String productFeatureId: productFeatureIdSet) { EntityCondition condition = EntityCondition.makeCondition(UtilMisc.toList( EntityCondition.makeCondition("productFeatureId", EntityOperator.EQUALS, productFeatureId), EntityCondition.makeCondition("productFeatureGroupId", EntityOperator.EQUALS, productFeatureGroupId), @@ -751,9 +729,7 @@ } // now get all feature groups associated with sub-categories and associate them with this category - Iterator<GenericValue> subCategoryIter = subCategoryList.iterator(); - while (subCategoryIter.hasNext()) { - GenericValue productCategoryRollup = subCategoryIter.next(); + for (GenericValue productCategoryRollup: subCategoryList) { String subProductCategoryId = productCategoryRollup.getString("productCategoryId"); EntityCondition condition = EntityCondition.makeCondition(UtilMisc.toList( EntityCondition.makeCondition("productCategoryId", EntityOperator.EQUALS, subProductCategoryId), Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java Mon Nov 10 18:20:53 2008 @@ -18,7 +18,6 @@ *******************************************************************************/ package org.ofbiz.product.product; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; @@ -99,11 +98,8 @@ // If no GEOs are configured the default is TRUE return true; } - Iterator<GenericValue> productGeosIt = null; // exclusion - productGeosIt = excludeGeos.iterator(); - while (productGeosIt.hasNext()) { - GenericValue productGeo = productGeosIt.next(); + for (GenericValue productGeo: excludeGeos) { List<GenericValue> excludeGeoGroup = GeoWorker.expandGeoGroup(productGeo.getString("geoId"), delegator); if (GeoWorker.containsGeo(excludeGeoGroup, postalAddress.getString("countryGeoId"), delegator) || GeoWorker.containsGeo(excludeGeoGroup, postalAddress.getString("stateProvinceGeoId"), delegator) || @@ -116,9 +112,7 @@ return true; } // inclusion - productGeosIt = includeGeos.iterator(); - while (productGeosIt.hasNext()) { - GenericValue productGeo = productGeosIt.next(); + for (GenericValue productGeo: includeGeos) { List<GenericValue> includeGeoGroup = GeoWorker.expandGeoGroup(productGeo.getString("geoId"), delegator); if (GeoWorker.containsGeo(includeGeoGroup, postalAddress.getString("countryGeoId"), delegator) || GeoWorker.containsGeo(includeGeoGroup, postalAddress.getString("stateProvinceGeoId"), delegator) || @@ -189,9 +183,7 @@ public static String getAggregatedInstanceId(GenericDelegator delegator, String aggregatedProductId, String configId) throws GenericEntityException { List<GenericValue> productAssocs = getAggregatedAssocs(delegator, aggregatedProductId); if (UtilValidate.isNotEmpty(productAssocs) && UtilValidate.isNotEmpty(configId)) { - Iterator<GenericValue> pai = productAssocs.iterator(); - while (pai.hasNext()) { - GenericValue productAssoc = pai.next(); + for (GenericValue productAssoc: productAssocs) { GenericValue product = productAssoc.getRelatedOne("AssocProduct"); if (configId.equals(product.getString("configId"))) { return productAssoc.getString("productIdTo"); @@ -273,13 +265,9 @@ public static boolean isProductInventoryAvailableByFacility(ProductConfigWrapper productConfig, String inventoryFacilityId, double quantity, LocalDispatcher dispatcher) throws GenericServiceException { boolean available = true; List<ConfigOption> options = productConfig.getSelectedOptions(); - Iterator<ConfigOption> optionsIt = options.iterator(); - while (optionsIt.hasNext()) { - ConfigOption ci = optionsIt.next(); + for (ConfigOption ci: options) { List<GenericValue> products = ci.getComponents(); - Iterator<GenericValue> productsIt = products.iterator(); - while (productsIt.hasNext()) { - GenericValue product = productsIt.next(); + for (GenericValue product: products) { String productId = product.getString("productId"); Double cmpQuantity = product.getDouble("quantity"); double neededQty = 1.0; @@ -356,9 +344,7 @@ List<GenericValue> variantDistinguishingFeatures = delegator.findByAndCache("ProductFeatureAndAppl", UtilMisc.toMap("productId", variantProduct.get("productId"), "productFeatureApplTypeId", "DISTINGUISHING_FEAT")); // Debug.logInfo("Found variantDistinguishingFeatures: " + variantDistinguishingFeatures, module); - Iterator<GenericValue> variantDistinguishingFeatureIter = UtilMisc.toIterator(EntityUtil.filterByDate(variantDistinguishingFeatures)); - while (variantDistinguishingFeatureIter != null && variantDistinguishingFeatureIter.hasNext()) { - GenericValue variantDistinguishingFeature = variantDistinguishingFeatureIter.next(); + for (GenericValue variantDistinguishingFeature: EntityUtil.filterByDate(variantDistinguishingFeatures)) { GenericValue dummyFeature = delegator.makeValue("ProductFeature"); dummyFeature.setAllFields(variantDistinguishingFeature, true, null, null); distFeatures.add(dummyFeature); @@ -367,19 +353,15 @@ List<GenericValue> virtualSelectableFeatures = delegator.findByAndCache("ProductFeatureAndAppl", UtilMisc.toMap("productId", virtualProductId, "productFeatureApplTypeId", "SELECTABLE_FEATURE")); // Debug.logInfo("Found virtualSelectableFeatures: " + virtualSelectableFeatures, module); - Iterator<GenericValue> virtualSelectableFeatureIter = UtilMisc.toIterator(EntityUtil.filterByDate(virtualSelectableFeatures)); Set<String> virtualSelectableFeatureIds = FastSet.newInstance(); - while (virtualSelectableFeatureIter != null && virtualSelectableFeatureIter.hasNext()) { - GenericValue virtualSelectableFeature = virtualSelectableFeatureIter.next(); + for (GenericValue virtualSelectableFeature: EntityUtil.filterByDate(virtualSelectableFeatures)) { virtualSelectableFeatureIds.add(virtualSelectableFeature.getString("productFeatureId")); } List<GenericValue> variantStandardFeatures = delegator.findByAndCache("ProductFeatureAndAppl", UtilMisc.toMap("productId", variantProduct.get("productId"), "productFeatureApplTypeId", "STANDARD_FEATURE")); // Debug.logInfo("Found variantStandardFeatures: " + variantStandardFeatures, module); - Iterator<GenericValue> variantStandardFeatureIter = UtilMisc.toIterator(EntityUtil.filterByDate(variantStandardFeatures)); - while (variantStandardFeatureIter != null && variantStandardFeatureIter.hasNext()) { - GenericValue variantStandardFeature = variantStandardFeatureIter.next(); + for (GenericValue variantStandardFeature: EntityUtil.filterByDate(variantStandardFeatures)) { if (virtualSelectableFeatureIds.contains(variantStandardFeature.get("productFeatureId"))) { GenericValue dummyFeature = delegator.makeValue("ProductFeature"); dummyFeature.setAllFields(variantStandardFeature, true, null, null); @@ -404,18 +386,16 @@ // Debug.logInfo("Found distinguishing features: " + distFeatures, module); StringBuilder nameBuf = new StringBuilder(); - Iterator<GenericValue> distFeatIter = distFeatures.iterator(); - while (distFeatIter.hasNext()) { - GenericValue productFeature = distFeatIter.next(); + for (GenericValue productFeature: distFeatures) { + if (nameBuf.length() > 0) { + nameBuf.append(", "); + } GenericValue productFeatureType = productFeature.getRelatedOneCache("ProductFeatureType"); if (productFeatureType != null) { nameBuf.append(productFeatureType.get("description", locale)); nameBuf.append(":"); } nameBuf.append(productFeature.get("description", locale)); - if (distFeatIter.hasNext()) { - nameBuf.append(", "); - } } return nameBuf.toString(); } @@ -469,8 +449,7 @@ productAppls = product.getRelatedByAnd("ProductFeatureAppl", UtilMisc.toMap("productFeatureApplTypeId", productFeatureApplTypeId)); } - for (int i = 0; i < productAppls.size(); i++) { - GenericValue productAppl = productAppls.get(i); + for (GenericValue productAppl: productAppls) { features.add(productAppl.getRelatedOne("ProductFeature")); } features = EntityUtil.orderBy(features, UtilMisc.toList("description")); @@ -513,11 +492,9 @@ List<String> order = UtilMisc.toList("productFeatureTypeId", "sequenceNum"); List<GenericValue> features = delegator.findByAndCache("ProductFeatureAndAppl", fields, order); List<GenericValue> featuresSorted = EntityUtil.orderBy(features, order); - Iterator<GenericValue> it = featuresSorted.iterator(); String oldType = null; List<Map<String,String>> featureList = FastList.newInstance(); - while(it.hasNext()) { - GenericValue productFeatureAppl = it.next(); + for (GenericValue productFeatureAppl: featuresSorted) { if (oldType == null || !oldType.equals(productFeatureAppl.getString("productFeatureTypeId"))) { // use first entry for type and description if (oldType != null) { @@ -570,9 +547,7 @@ } if (productFeatureAppls != null) { - Iterator<GenericValue> i = productFeatureAppls.iterator(); - while (i.hasNext()) { - GenericValue appl = i.next(); + for (GenericValue appl: productFeatureAppls) { String featureType = appl.getString("productFeatureTypeId"); List<GenericValue> features = featureMap.get(featureType); if (features == null) { @@ -593,11 +568,7 @@ if (UtilValidate.isNotEmpty(orderHeaderAdjustments)) { List<GenericValue> filteredAdjs = filterOrderAdjustments(orderHeaderAdjustments, includeOther, includeTax, includeShipping, false, false); - Iterator<GenericValue> adjIt = filteredAdjs.iterator(); - - while (adjIt.hasNext()) { - GenericValue orderAdjustment = adjIt.next(); - + for (GenericValue orderAdjustment: filteredAdjs) { adjTotal += calcOrderAdjustment(orderAdjustment, subTotal); } } @@ -620,11 +591,7 @@ List<GenericValue> newOrderAdjustmentsList = FastList.newInstance(); if (UtilValidate.isNotEmpty(adjustments)) { - Iterator<GenericValue> adjIt = adjustments.iterator(); - - while (adjIt.hasNext()) { - GenericValue orderAdjustment = adjIt.next(); - + for (GenericValue orderAdjustment: adjustments) { boolean includeAdjustment = false; if ("SALES_TAX".equals(orderAdjustment.getString("orderAdjustmentTypeId"))) { @@ -711,9 +678,7 @@ double ratingTally = 0; double numRatings = 0; if (reviews != null) { - Iterator<GenericValue> i = reviews.iterator(); - while (i.hasNext()) { - GenericValue productReview = i.next(); + for (GenericValue productReview: reviews) { Double rating = productReview.getDouble("productRating"); if (rating != null) { ratingTally += rating.doubleValue(); @@ -995,18 +960,14 @@ // find associated refurb items, we want serial number for main item or any refurb items too List<GenericValue> refubProductAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_REFURB"))); - Iterator<GenericValue> refubProductAssocIter = refubProductAssocs.iterator(); - while (refubProductAssocIter.hasNext()) { - GenericValue refubProductAssoc = refubProductAssocIter.next(); + for (GenericValue refubProductAssoc: refubProductAssocs) { productIdSet.add(refubProductAssoc.getString("productIdTo")); } // see if this is a refurb productId to, and find product(s) it is a refurb of List<GenericValue> refubProductToAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productIdTo", productId, "productAssocTypeId", "PRODUCT_REFURB"))); - Iterator<GenericValue> refubProductToAssocIter = refubProductToAssocs.iterator(); - while (refubProductToAssocIter.hasNext()) { - GenericValue refubProductToAssoc = refubProductToAssocIter.next(); + for (GenericValue refubProductToAssoc: refubProductToAssocs) { productIdSet.add(refubProductToAssoc.getString("productId")); } @@ -1019,21 +980,15 @@ String variantProductId = null; try { - Iterator<String> featureIter = selectedFeatures.iterator(); - while (featureIter.hasNext()) { - String paramValue = featureIter.next(); + for (String paramValue: selectedFeatures) { // find incompatibilities.. List<GenericValue> incompatibilityVariants = delegator.findByAndCache("ProductFeatureIactn", UtilMisc.toMap("productId", productId, "productFeatureIactnTypeId","FEATURE_IACTN_INCOMP")); - Iterator<GenericValue> incompIter = incompatibilityVariants.iterator(); - while (incompIter.hasNext()) { - GenericValue incompatibilityVariant = incompIter.next(); + for (GenericValue incompatibilityVariant: incompatibilityVariants) { String featur = incompatibilityVariant.getString("productFeatureId"); if(paramValue.equals(featur)){ String featurTo = incompatibilityVariant.getString("productFeatureIdTo"); - Iterator<String> featureToIter = selectedFeatures.iterator(); - while (featureToIter.hasNext()) { - String paramValueTo = featureToIter.next(); + for (String paramValueTo: selectedFeatures) { if(featurTo.equals(paramValueTo)){ GenericValue featureFrom = (GenericValue) delegator.findByPrimaryKey("ProductFeature", UtilMisc.toMap("productFeatureId", featur)); GenericValue featureTo = (GenericValue) delegator.findByPrimaryKey("ProductFeature", UtilMisc.toMap("productFeatureId", featurTo)); @@ -1050,16 +1005,12 @@ // find dependencies.. List<GenericValue> dependenciesVariants = delegator.findByAndCache("ProductFeatureIactn", UtilMisc.toMap("productId", productId, "productFeatureIactnTypeId","FEATURE_IACTN_DEPEND")); - Iterator<GenericValue> dpIter = dependenciesVariants.iterator(); - while (dpIter.hasNext()) { - GenericValue dpVariant = dpIter.next(); + for (GenericValue dpVariant: dependenciesVariants) { String featur = dpVariant.getString("productFeatureId"); if(paramValue.equals(featur)){ String featurTo = dpVariant.getString("productFeatureIdTo"); - Iterator<String> featureToIter = selectedFeatures.iterator(); boolean found = false; - while (featureToIter.hasNext()) { - String paramValueTo = featureToIter.next(); + for (String paramValueTo: selectedFeatures) { if(featurTo.equals(paramValueTo)){ found = true; break; @@ -1079,13 +1030,10 @@ // find variant // Debug.log("=====try to find variant for product: " + productId + " and features: " + selectedFeatures); List<GenericValue> productAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId","PRODUCT_VARIANT"))); - Iterator <GenericValue> assocIter = productAssocs.iterator(); boolean productFound = false; -nextProd: while(assocIter.hasNext()) { - GenericValue productAssoc = assocIter.next(); - Iterator <String> fIter = selectedFeatures.iterator(); - while (fIter.hasNext()) { - String featureId = fIter.next(); +nextProd: + for (GenericValue productAssoc: productAssocs) { + for (String featureId: selectedFeatures) { List<GenericValue> pAppls = delegator.findByAndCache("ProductFeatureAppl", UtilMisc.toMap("productId", productAssoc.getString("productIdTo"), "productFeatureId", featureId, "productFeatureApplTypeId","STANDARD_FEATURE")); if (UtilValidate.isEmpty(pAppls)) { continue nextProd; @@ -1114,17 +1062,13 @@ GenericValue productFeatureAppl = delegator.makeValue("ProductFeatureAppl", UtilMisc.toMap("productId", product.getString("productId"), "productFeatureApplTypeId", "STANDARD_FEATURE")); productFeatureAppl.put("fromDate", UtilDateTime.nowTimestamp()); - Iterator <String> selectedFeatureIter = selectedFeatures.iterator(); - while (selectedFeatureIter.hasNext()) { - String productFeatureId = selectedFeatureIter.next(); + for (String productFeatureId: selectedFeatures) { productFeatureAppl.put("productFeatureId", productFeatureId); productFeatureAppl.create(); } //add standard features too List<GenericValue> stdFeaturesAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAppl", UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE"))); - Iterator <GenericValue> stdFeatureIter = stdFeaturesAppls.iterator(); - while (stdFeatureIter.hasNext()) { - GenericValue stdFeaturesAppl = stdFeatureIter.next(); + for (GenericValue stdFeaturesAppl: stdFeaturesAppls) { stdFeaturesAppl.put("productId", product.getString("productId")); stdFeaturesAppl.create(); } @@ -1133,13 +1077,10 @@ * add these to the price of the virtual product, store the result as the default price on the variant you created. */ List<GenericValue> productPrices = EntityUtil.filterByDate(delegator.findByAnd("ProductPrice", UtilMisc.toMap("productId", productId))); - Iterator <GenericValue> ppIter = productPrices.iterator(); - while (ppIter.hasNext()) { - GenericValue productPrice = ppIter.next(); - Iterator <String> sfIter = selectedFeatures.iterator(); - while (sfIter.hasNext()) { - List <GenericValue> productFeaturePrices = EntityUtil.filterByDate(delegator.findByAnd("ProductFeaturePrice", - UtilMisc.toMap("productFeatureId", sfIter.next(), "productPriceTypeId", productPrice.getString("productPriceTypeId")))); + for (GenericValue productPrice: productPrices) { + for (String selectedFeaturedId: selectedFeatures) { + List<GenericValue> productFeaturePrices = EntityUtil.filterByDate(delegator.findByAnd("ProductFeaturePrice", + UtilMisc.toMap("productFeatureId", selectedFeaturedId, "productPriceTypeId", productPrice.getString("productPriceTypeId")))); if (UtilValidate.isNotEmpty(productFeaturePrices)) { GenericValue productFeaturePrice = productFeaturePrices.get(0); if (UtilValidate.isNotEmpty(productFeaturePrice)) { @@ -1161,18 +1102,14 @@ // copy the supplier List<GenericValue> supplierProducts = delegator.findByAndCache("SupplierProduct", UtilMisc.toMap("productId", productId)); - Iterator <GenericValue> SPite = supplierProducts.iterator(); - while (SPite.hasNext()) { - GenericValue supplierProduct = SPite.next(); + for (GenericValue supplierProduct: supplierProducts) { supplierProduct.set("productId", product.getString("productId")); supplierProduct.create(); } // copy the content List<GenericValue> productContents = delegator.findByAndCache("ProductContent", UtilMisc.toMap("productId", productId)); - Iterator <GenericValue> productContentsTte = productContents.iterator(); - while (productContentsTte.hasNext()) { - GenericValue productContent = productContentsTte.next(); + for (GenericValue productContent: productContents) { productContent.set("productId", product.getString("productId")); productContent.create(); } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java Mon Nov 10 18:20:53 2008 @@ -90,9 +90,8 @@ return responseMsgs; } - for (int i = 0; i < fileItems.size(); i++) { + for (File item: fileItems) { // read all xls file and create workbook one by one. - File item = fileItems.get(i); List<Map<String, Object>> products = FastList.newInstance(); List<Map<String, Object>> inventoryItems = FastList.newInstance(); POIFSFileSystem fs = null; Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java Mon Nov 10 18:20:53 2008 @@ -18,7 +18,6 @@ *******************************************************************************/ package org.ofbiz.product.store; -import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -225,10 +224,7 @@ List<GenericValue> returnShippingMethods = UtilMisc.makeListWritable(shippingMethods); if (shippingMethods != null) { - Iterator<GenericValue> i = shippingMethods.iterator(); - while (i.hasNext()) { - GenericValue method = i.next(); - //Debug.logInfo("Checking Shipping Method : " + method.getString("shipmentMethodTypeId"), module); + for (GenericValue method: shippingMethods) { // test min/max weight first Double minWeight = method.getDouble("minWeight"); @@ -265,9 +261,7 @@ boolean allMatch = false; if (itemSizes != null) { allMatch = true; - Iterator<Double> isi = itemSizes.iterator(); - while (isi.hasNext()) { - Double size = isi.next(); + for (Double size: itemSizes) { if (size.doubleValue() < minSize.doubleValue()) { allMatch = false; } @@ -283,9 +277,7 @@ boolean allMatch = false; if (itemSizes != null) { allMatch = true; - Iterator<Double> isi = itemSizes.iterator(); - while (isi.hasNext()) { - Double size = isi.next(); + for (Double size: itemSizes) { if (size.doubleValue() > maxSize.doubleValue()) { allMatch = false; } @@ -384,9 +376,7 @@ } if (includedFeatures != null) { boolean foundOne = false; - Iterator<GenericValue> ifet = includedFeatures.iterator(); - while (ifet.hasNext()) { - GenericValue appl = ifet.next(); + for (GenericValue appl: includedFeatures) { if (featureIdMap.containsKey(appl.getString("productFeatureId"))) { foundOne = true; break; @@ -407,9 +397,7 @@ Debug.logError(e, "Unable to lookup ProductFeatureGroupAppl records for group : " + excludeFeatures, module); } if (excludedFeatures != null) { - Iterator<GenericValue> ifet = excludedFeatures.iterator(); - while (ifet.hasNext()) { - GenericValue appl = ifet.next(); + for (GenericValue appl: excludedFeatures) { if (featureIdMap.containsKey(appl.getString("productFeatureId"))) { returnShippingMethods.remove(method); //Debug.logInfo("Removed shipping method due to an exluded feature being found : " + appl.getString("productFeatureId"), module); @@ -483,9 +471,7 @@ Debug.log("getSurvey for product " + productId,module); // limit by product if (!UtilValidate.isEmpty(productId) && !UtilValidate.isEmpty(storeSurveys)) { - Iterator<GenericValue> ssi = storeSurveys.iterator(); - while (ssi.hasNext()) { - GenericValue surveyAppl = ssi.next(); + for (GenericValue surveyAppl: storeSurveys) { GenericValue product = null; String virtualProductId = null; @@ -520,9 +506,7 @@ Debug.logError(e, "Unable to get ProductCategoryMemebr records for survey application : " + surveyAppl, module); } if (categoryMembers != null) { - Iterator<GenericValue> cmi = categoryMembers.iterator(); - while (cmi.hasNext()) { - GenericValue member = cmi.next(); + for (GenericValue member: categoryMembers) { if (productId != null && productId.equals(member.getString("productId"))) { surveys.add(surveyAppl); break; @@ -700,12 +684,8 @@ } if (UtilValidate.isNotEmpty(productFacilities)) { - Iterator<GenericValue> pfIter = productFacilities.iterator(); - - while (pfIter.hasNext()) { + for (GenericValue pfValue: productFacilities) { try { - GenericValue pfValue = pfIter.next(); - isInventoryAvailable = ProductWorker.isProductInventoryAvailableByFacility(productConfig, pfValue.getString("facilityId"), quantity, dispatcher); if (isInventoryAvailable == true) { return isInventoryAvailable; Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java Mon Nov 10 18:20:53 2008 @@ -20,7 +20,6 @@ import java.sql.Timestamp; import java.util.Calendar; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -188,9 +187,7 @@ return ServiceUtil.returnError(msg); } - Iterator<GenericValue> productSubscriptionResourceIter = productSubscriptionResourceList.iterator(); - while (productSubscriptionResourceIter.hasNext()) { - GenericValue productSubscriptionResource = productSubscriptionResourceIter.next(); + for (GenericValue productSubscriptionResource: productSubscriptionResourceList) { Long useTime = productSubscriptionResource.getLong("useTime"); Integer newUseTime = Integer.valueOf(0); if (useTime != null) { @@ -246,9 +243,7 @@ Timestamp orderCreatedDate = (Timestamp) orderHeader.get("orderDate"); subContext.put("orderCreatedDate", orderCreatedDate); List<GenericValue> orderItemList = orderHeader.getRelated("OrderItem"); - Iterator<GenericValue> orderItemIter = orderItemList.iterator(); - while (orderItemIter.hasNext()) { - GenericValue orderItem = orderItemIter.next(); + for (GenericValue orderItem: orderItemList) { Double qty = orderItem.getDouble("quantity"); String productId = orderItem.getString("productId"); if (UtilValidate.isEmpty(productId)) { Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java Mon Nov 10 18:20:53 2008 @@ -20,7 +20,6 @@ package org.ofbiz.product.supplier; import java.util.Collection; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -136,8 +135,7 @@ if (partyId != null && UtilValidate.isNotEmpty(features)) { // loop through all the features, find the related SupplierProductFeature for the given partyId, and // substitue description and idCode - for (Iterator<GenericValue> fI = features.iterator(); fI.hasNext(); ) { - GenericValue nextFeature = fI.next(); + for (GenericValue nextFeature: features) { List<GenericValue> supplierFeatures = EntityUtil.filterByAnd(nextFeature.getRelated("SupplierProductFeature"), UtilMisc.toMap("partyId", partyId)); GenericValue supplierFeature = null; Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java Mon Nov 10 18:20:53 2008 @@ -18,7 +18,6 @@ *******************************************************************************/ package org.ofbiz.shipment.packing; -import java.util.Iterator; import java.util.Map; import org.ofbiz.base.util.Debug; @@ -96,9 +95,7 @@ Map<String, String> wgtInfo = UtilGenerics.checkMap(context.get("wgtInfo")); if (selInfo != null) { - Iterator<String> i = selInfo.keySet().iterator(); - while (i.hasNext()) { - String rowKey = i.next(); + for (String rowKey: selInfo.keySet()) { String orderItemSeqId = iteInfo.get(rowKey); String prdStr = prdInfo.get(rowKey); if (UtilValidate.isEmpty(prdStr)) { @@ -281,10 +278,9 @@ public static double setSessionPackageWeights(PackingSession session, Map<String, String> packageWeights) { double shippableWeight = 0; if (! UtilValidate.isEmpty(packageWeights)) { - Iterator<String> pwit = packageWeights.keySet().iterator(); - while (pwit.hasNext()) { - String packageSeqId = pwit.next(); - String packageWeightStr = packageWeights.get(packageSeqId); + for (Map.Entry<String, String> entry: packageWeights.entrySet()) { + String packageSeqId = entry.getKey(); + String packageWeightStr = entry.getValue(); if (UtilValidate.isNotEmpty(packageWeightStr)) { double packageWeight = UtilMisc.toDouble(packageWeights.get(packageSeqId)); session.setPackageWeight(Integer.parseInt(packageSeqId), Double.valueOf(packageWeight)); |
Free forum by Nabble | Edit this page |