You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by pa...@apache.org on 2020/06/22 15:48:54 UTC
[ofbiz-framework] branch trunk updated: Improved: Replace for-loop
with forEach loop(OFBIZ-11829)
This is an automated email from the ASF dual-hosted git repository.
pawan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push:
new 15c005f Improved: Replace for-loop with forEach loop(OFBIZ-11829)
15c005f is described below
commit 15c005fa426af8d9fe681e560fa6edd2ce39171e
Author: Pawan Verma <pa...@hotwaxsystems.com>
AuthorDate: Mon Jun 22 21:17:49 2020 +0530
Improved: Replace for-loop with forEach loop(OFBIZ-11829)
Also modified some checkstyle issues.
Set checkstyleMain.maxErrors to 26684 (-61)
Thanks: Jacques for the review.
---
.../accounting/thirdparty/gosoftware/RitaApi.java | 10 ++---
.../thirdparty/valuelink/ValueLinkApi.java | 8 ++--
.../ofbiz/content/ContentManagementServices.java | 3 +-
.../content/content/ContentServicesComplex.java | 7 +--
.../ofbiz/content/content/ContentWorker.java | 22 ++++-----
.../ofbiz/content/content/PermissionRecorder.java | 15 +++----
.../content/content/UploadContentAndImage.java | 8 ++--
.../ofbiz/content/data/DataResourceWorker.java | 10 ++---
.../apache/ofbiz/content/layout/LayoutEvents.java | 7 +--
.../apache/ofbiz/content/layout/LayoutWorker.java | 4 +-
.../apache/ofbiz/manufacturing/bom/BOMHelper.java | 4 +-
.../apache/ofbiz/manufacturing/bom/BOMNode.java | 41 +++++++++--------
.../ofbiz/manufacturing/bom/BOMServices.java | 52 +++++++++++-----------
.../apache/ofbiz/manufacturing/bom/BOMTree.java | 8 ++--
.../manufacturing/jobshopmgt/ProductionRun.java | 25 +++++------
.../jobshopmgt/ProductionRunHelper.java | 3 +-
.../jobshopmgt/ProductionRunServices.java | 36 +++++++--------
build.gradle | 2 +-
18 files changed, 125 insertions(+), 140 deletions(-)
diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java
index fa1cd52..880e801 100644
--- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java
+++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java
@@ -185,14 +185,14 @@ public class RitaApi {
}
String[] lines = resp.split("\n");
- for (int i = 0; i < lines.length; i++) {
- Debug.logInfo(lines[i], MODULE);
- if (!".".equals(lines[i].trim())) {
- String[] lineSplit = lines[i].trim().split(" ", 2);
+ for (String line : lines) {
+ Debug.logInfo(line, MODULE);
+ if (!".".equals(line.trim())) {
+ String[] lineSplit = line.trim().split(" ", 2);
if (lineSplit != null && lineSplit.length == 2) {
docMap.put(lineSplit[0], lineSplit[1]);
} else {
- Debug.logWarning("Line split error - " + lines[i], MODULE);
+ Debug.logWarning("Line split error - " + line, MODULE);
}
} else {
break;
diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java
index c1e7adf..f5c06e6 100644
--- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java
+++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java
@@ -817,8 +817,8 @@ public class ValueLinkApi {
protected byte[] getPinCheckSum(byte[] pinBytes) {
byte[] checkSum = new byte[1];
checkSum[0] = 0;
- for (int i = 0; i < pinBytes.length; i++) {
- checkSum[0] += pinBytes[i];
+ for (byte pinByte : pinBytes) {
+ checkSum[0] += pinByte;
}
return checkSum;
}
@@ -996,8 +996,8 @@ public class ValueLinkApi {
// create a List of Maps for each set of values
List<Map<String, String>> valueMap = new LinkedList<>();
- for (int i = 0; i < valueList.size(); i++) {
- valueMap.add(StringUtil.createMap(StringUtil.split(keys, "|"), StringUtil.split(valueList.get(i), "|")));
+ for (String s : valueList) {
+ valueMap.add(StringUtil.createMap(StringUtil.split(keys, "|"), StringUtil.split(s, "|")));
}
if (debug) {
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java b/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java
index 477c199..ee2d49e 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java
@@ -1598,8 +1598,7 @@ public class ContentManagementServices {
contentRevisionMap.put("newDataResourceId", result.get("dataResourceId"));
contentRevisionMap.put("oldDataResourceId", oldDataResourceId);
// need committedByPartyId
- for (int i=0; i < parentList.size(); i++) {
- String thisContentId = parentList.get(i);
+ for (String thisContentId : parentList) {
contentRevisionMap.put("contentId", thisContentId);
result = dispatcher.runSync("persistContentRevisionAndItem", contentRevisionMap);
if (ServiceUtil.isError(result)) {
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentServicesComplex.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentServicesComplex.java
index cd5a321..3a57d1c 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentServicesComplex.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentServicesComplex.java
@@ -138,9 +138,10 @@ public class ContentServicesComplex {
} catch (GenericEntityException e) {
return ServiceUtil.returnError(e.getMessage());
}
- for (int i=0; i < relatedAssocs.size(); i++) {
- GenericValue a = relatedAssocs.get(i);
- if (Debug.verboseOn()) Debug.logVerbose(" contentId:" + a.get("contentId") + " To:" + a.get("caContentIdTo") + " fromDate:" + a.get("caFromDate") + " thruDate:" + a.get("caThruDate") + " AssocTypeId:" + a.get("caContentAssocTypeId"), null);
+ for (GenericValue a : relatedAssocs) {
+ if (Debug.verboseOn())
+ Debug.logVerbose(" contentId:" + a.get("contentId") + " To:" + a.get("caContentIdTo") + " fromDate:" + a.get("caFromDate") +
+ " thruDate:" + a.get("caThruDate") + " AssocTypeId:" + a.get("caContentAssocTypeId"), null);
}
Map<String, Object> results = new HashMap<>();
results.put("entityList", relatedAssocs);
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java
index f3838a4..7e69048 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java
@@ -481,20 +481,17 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
contentTypeId = (String) content.get("contentTypeId");
List<GenericValue> topicList = content.getRelated("ToContentAssoc", UtilMisc.toMap("contentAssocTypeId", "TOPIC"), null, false);
List<String> topics = new LinkedList<>();
- for (int i = 0; i < topicList.size(); i++) {
- GenericValue assoc = topicList.get(i);
+ for (GenericValue assoc : topicList) {
topics.add(assoc.getString("contentId"));
}
List<GenericValue> keywordList = content.getRelated("ToContentAssoc", UtilMisc.toMap("contentAssocTypeId", "KEYWORD"), null, false);
List<String> keywords = new LinkedList<>();
- for (int i = 0; i < keywordList.size(); i++) {
- GenericValue assoc = keywordList.get(i);
+ for (GenericValue assoc : keywordList) {
keywords.add(assoc.getString("contentId"));
}
List<GenericValue> purposeValueList = content.getRelated("ContentPurpose", null, null, true);
List<String> purposes = new LinkedList<>();
- for (int i = 0; i < purposeValueList.size(); i++) {
- GenericValue purposeValue = purposeValueList.get(i);
+ for (GenericValue purposeValue : purposeValueList) {
purposes.add(purposeValue.getString("contentPurposeTypeId"));
}
List<String> contentTypeAncestry = new LinkedList<>();
@@ -652,8 +649,7 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
List<Object> purposes = new LinkedList<>();
try {
List<GenericValue> purposeValueList = content.getRelated("ContentPurpose", null, null, true);
- for (int i = 0; i < purposeValueList.size(); i++) {
- GenericValue purposeValue = purposeValueList.get(i);
+ for (GenericValue purposeValue : purposeValueList) {
purposes.add(purposeValue.get("contentPurposeTypeId"));
}
} catch (GenericEntityException e) {
@@ -666,9 +662,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
List<Object> sections = new LinkedList<>();
try {
List<GenericValue> sectionValueList = content.getRelated("FromContentAssoc", null, null, true);
- for (int i = 0; i < sectionValueList.size(); i++) {
- GenericValue sectionValue = sectionValueList.get(i);
- String contentAssocPredicateId = (String)sectionValue.get("contentAssocPredicateId");
+ for (GenericValue sectionValue : sectionValueList) {
+ String contentAssocPredicateId = (String) sectionValue.get("contentAssocPredicateId");
if (contentAssocPredicateId != null && "categorizes".equals(contentAssocPredicateId)) {
sections.add(sectionValue.get("contentIdTo"));
}
@@ -683,9 +678,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
List<Object> topics = new LinkedList<>();
try {
List<GenericValue> topicValueList = content.getRelated("FromContentAssoc", null, null, true);
- for (int i = 0; i < topicValueList.size(); i++) {
- GenericValue topicValue = topicValueList.get(i);
- String contentAssocPredicateId = (String)topicValue.get("contentAssocPredicateId");
+ for (GenericValue topicValue : topicValueList) {
+ String contentAssocPredicateId = (String) topicValue.get("contentAssocPredicateId");
if (contentAssocPredicateId != null && "topifies".equals(contentAssocPredicateId))
topics.add(topicValue.get("contentIdTo"));
}
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/PermissionRecorder.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/PermissionRecorder.java
index 6783e0a..b9a8ccf 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/content/PermissionRecorder.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/PermissionRecorder.java
@@ -211,8 +211,7 @@ public class PermissionRecorder {
sb.append("Content Id");
sb.append("</td>");
- for (int i=0; i < fieldTitles.length; i++) {
- String opField = fieldTitles[i];
+ for (String opField : fieldTitles) {
sb.append("<td class=\"headr\">");
sb.append(opField);
sb.append("</td>");
@@ -251,10 +250,9 @@ public class PermissionRecorder {
//if (Debug.infoOn()) Debug.logInfo("renderResultRowHtml, (1):" + sb.toString(), MODULE);
String str = null;
String s = null;
- for (int i=0; i < opFields.length; i++) {
- String opField = opFields[i];
+ for (String opField : opFields) {
sb.append("<td class=\"target\">");
- s = (String)currentContentResultMap.get(opField);
+ s = (String) currentContentResultMap.get(opField);
if (s != null)
str = s;
else
@@ -273,14 +271,13 @@ public class PermissionRecorder {
sb.append("</td>");
boolean isPass = true;
- for (int i=0; i < opFields.length; i++) {
- String opField = opFields[i];
- Boolean bool = (Boolean)rMap.get(opField + "Cond");
+ for (String opField : opFields) {
+ Boolean bool = (Boolean) rMap.get(opField + "Cond");
String cls = (bool) ? "pass" : "fail";
if (!bool)
isPass = false;
sb.append("<td class=\"" + cls + "\">");
- s = (String)rMap.get(opField);
+ s = (String) rMap.get(opField);
sb.append(s);
sb.append("</td>");
}
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java
index 6380e56..386cf37 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java
@@ -102,8 +102,8 @@ public class UploadContentAndImage {
FileItem fi = null;
FileItem imageFi = null;
byte[] imageBytes = {};
- for (int i = 0; i < lst.size(); i++) {
- fi = lst.get(i);
+ for (FileItem fileItem : lst) {
+ fi = fileItem;
String fieldName = fi.getFieldName();
if (fi.isFormField()) {
String fieldStr = fi.getString();
@@ -369,8 +369,8 @@ public class UploadContentAndImage {
FileItem imageFi = null;
byte[] imageBytes;
passedParams.put("userLogin", userLogin);
- for (int i = 0; i < lst.size(); i++) {
- fi = lst.get(i);
+ for (FileItem fileItem : lst) {
+ fi = fileItem;
String fieldName = fi.getFieldName();
if (fi.isFormField()) {
String fieldStr = fi.getString();
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java
index 530c951..8d9e77f 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java
@@ -232,8 +232,8 @@ public class DataResourceWorker implements org.apache.ofbiz.widget.content.Data
GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");
passedParams.put("userLogin", userLogin);
byte[] imageBytes = null;
- for (int i = 0; i < lst.size(); i++) {
- fi = lst.get(i);
+ for (FileItem fileItem : lst) {
+ fi = fileItem;
String fieldName = fi.getFieldName();
if (fi.isFormField()) {
String fieldStr = fi.getString();
@@ -551,9 +551,9 @@ public class DataResourceWorker implements org.apache.ofbiz.widget.content.Data
File[] subs = parent.listFiles();
if (subs != null) {
int length = subs.length;
- for (int i = 0; i < length; i++) {
- if (subs[i].isDirectory()) {
- dirMap.put(subs[i].lastModified(), subs[i]);
+ for (File sub : subs) {
+ if (sub.isDirectory()) {
+ dirMap.put(sub.lastModified(), sub);
}
}
}
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutEvents.java b/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutEvents.java
index 6a11a6f..cf4dd1f 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutEvents.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutEvents.java
@@ -393,8 +393,7 @@ public class LayoutEvents {
// Can't count on records being unique
Map<String, GenericValue> beenThere = new HashMap<>();
- for (int i=0; i<entityList.size(); i++) {
- GenericValue view = entityList.get(i);
+ for (GenericValue view : entityList) {
List<Object> errorMessages = new LinkedList<>();
if (locale == null) {
locale = Locale.getDefault();
@@ -412,7 +411,9 @@ public class LayoutEvents {
String mapKey = (String) view.get("caMapKey");
Timestamp fromDate = (Timestamp) view.get("caFromDate");
Timestamp thruDate = (Timestamp) view.get("caThruDate");
- if (Debug.verboseOn()) Debug.logVerbose("in cloneLayout, contentIdFrom:" + contentIdFrom + " fromDate:" + fromDate + " thruDate:" + thruDate + " mapKey:" + mapKey, "");
+ if (Debug.verboseOn())
+ Debug.logVerbose("in cloneLayout, contentIdFrom:" + contentIdFrom + " fromDate:" + fromDate + " thruDate:" + thruDate +
+ " mapKey:" + mapKey, "");
if (beenThere.get(contentIdFrom) == null) {
serviceIn.put("contentIdFrom", contentIdFrom);
serviceIn.put("contentIdTo", newId);
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutWorker.java b/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutWorker.java
index 1fb4c85..bb99807 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutWorker.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutWorker.java
@@ -92,8 +92,8 @@ public final class LayoutWorker {
// This code finds the idField and the upload FileItems
FileItem fi = null;
FileItem imageFi = null;
- for (int i=0; i < lst.size(); i++) {
- fi = lst.get(i);
+ for (FileItem fileItem : lst) {
+ fi = fileItem;
String fieldName = fi.getFieldName();
String fieldStr = fi.getString();
if (fi.isFormField()) {
diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMHelper.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMHelper.java
index 4dc5d91..c7f4e02 100644
--- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMHelper.java
+++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMHelper.java
@@ -117,8 +117,8 @@ public final class BOMHelper {
.cache().filterByDate(inDate).queryList();
GenericValue duplicatedNode = null;
for (GenericValue oneNode : productNodesList) {
- for (int i = 0; i < productIdKeys.size(); i++) {
- if (oneNode.getString("productId").equals(productIdKeys.get(i))) {
+ for (String idKey : productIdKeys) {
+ if (oneNode.getString("productId").equals(idKey)) {
return oneNode;
}
}
diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java
index 04f900e..f7a75e9 100644
--- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java
+++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java
@@ -140,11 +140,11 @@ public class BOMNode {
List<GenericValue> productPartRules) throws GenericEntityException {
if (productPartRules != null) {
GenericValue rule = null;
- for (int i = 0; i < productPartRules.size(); i++) {
- rule = productPartRules.get(i);
- String ruleCondition = (String)rule.get("productFeature");
- String ruleOperator = (String)rule.get("ruleOperator");
- String newPart = (String)rule.get("productIdInSubst");
+ for (GenericValue productPartRule : productPartRules) {
+ rule = productPartRule;
+ String ruleCondition = (String) rule.get("productFeature");
+ String ruleOperator = (String) rule.get("ruleOperator");
+ String newPart = (String) rule.get("productIdInSubst");
BigDecimal ruleQuantity = BigDecimal.ZERO;
try {
ruleQuantity = rule.getBigDecimal("quantity");
@@ -158,8 +158,8 @@ public class BOMNode {
ruleSatisfied = true;
} else {
if (productFeatures != null) {
- for (int j = 0; j < productFeatures.size(); j++) {
- feature = productFeatures.get(j);
+ for (GenericValue productFeature : productFeatures) {
+ feature = productFeature;
if (ruleCondition.equals(feature.get("productFeatureId"))) {
ruleSatisfied = true;
break;
@@ -274,8 +274,8 @@ public class BOMNode {
Map<String, String> selectedFeatures = new HashMap<>();
if (productFeatures != null) {
GenericValue feature = null;
- for (int j = 0; j < productFeatures.size(); j++) {
- feature = productFeatures.get(j);
+ for (GenericValue productFeature : productFeatures) {
+ feature = productFeature;
selectedFeatures.put(feature.getString("productFeatureTypeId"), feature.getString("productFeatureId")); // FIXME
}
}
@@ -497,8 +497,8 @@ public class BOMNode {
sameNode.setQuantity(sameNode.getQuantity().add(quantity));
// Now (recursively) we visit the children.
BOMNode oneChildNode = null;
- for (int i = 0; i < childrenNodes.size(); i++) {
- oneChildNode = childrenNodes.get(i);
+ for (BOMNode childrenNode : childrenNodes) {
+ oneChildNode = childrenNode;
if (oneChildNode != null) {
oneChildNode.sumQuantity(nodes);
}
@@ -512,12 +512,12 @@ public class BOMNode {
BOMNode oneChildNode = null;
List<String> childProductionRuns = new LinkedList<>();
Timestamp maxEndDate = null;
- for (int i = 0; i < childrenNodes.size(); i++) {
- oneChildNode = childrenNodes.get(i);
+ for (BOMNode childrenNode : childrenNodes) {
+ oneChildNode = childrenNode;
if (oneChildNode != null) {
Map<String, Object> tmpResult = oneChildNode.createManufacturingOrder(facilityId, date, null, null, null, null, null, shipGroupSeqId, shipmentId, false, false);
- String childProductionRunId = (String)tmpResult.get("productionRunId");
- Timestamp childEndDate = (Timestamp)tmpResult.get("endDate");
+ String childProductionRunId = (String) tmpResult.get("productionRunId");
+ Timestamp childEndDate = (Timestamp) tmpResult.get("endDate");
if (maxEndDate == null) {
maxEndDate = childEndDate;
}
@@ -580,8 +580,9 @@ public class BOMNode {
if (orderId != null && orderItemSeqId != null) {
delegator.create("WorkOrderItemFulfillment", UtilMisc.toMap("workEffortId", productionRunId, "orderId", orderId, "orderItemSeqId", orderItemSeqId, "shipGroupSeqId", shipGroupSeqId));
}
- for (int i = 0; i < childProductionRuns.size(); i++) {
- delegator.create("WorkEffortAssoc", UtilMisc.toMap("workEffortIdFrom", childProductionRuns.get(i), "workEffortIdTo", productionRunId, "workEffortAssocTypeId", "WORK_EFF_PRECEDENCY", "fromDate", startDate));
+ for (String childProductionRun : childProductionRuns) {
+ delegator.create("WorkEffortAssoc", UtilMisc.toMap("workEffortIdFrom", childProductionRun
+ , "workEffortIdTo", productionRunId, "workEffortAssocTypeId", "WORK_EFF_PRECEDENCY", "fromDate", startDate));
}
}
} catch (GenericEntityException e) {
@@ -598,8 +599,7 @@ public class BOMNode {
proposedOrder.calculateStartDate(0, null, delegator, dispatcher, userLogin);
Timestamp startDate = proposedOrder.getRequirementStartDate();
minStartDate = startDate;
- for (int i = 0; i < childrenNodes.size(); i++) {
- BOMNode oneChildNode = childrenNodes.get(i);
+ for (BOMNode oneChildNode : childrenNodes) {
if (oneChildNode != null) {
Timestamp childStartDate = oneChildNode.getStartDate(facilityId, startDate, false);
if (childStartDate.compareTo(minStartDate) < 0) {
@@ -637,8 +637,7 @@ public class BOMNode {
}
}
if (UtilValidate.isNotEmpty(pfs)) {
- for (int i = 0; i < pfs.size(); i++) {
- GenericValue pf = pfs.get(i);
+ for (GenericValue pf : pfs) {
if (UtilValidate.isNotEmpty(pf.get("minimumStock")) && UtilValidate.isNotEmpty(pf.get("reorderQuantity"))) {
isWarehouseManaged = true;
break;
diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java
index cdca7c2..b1f0995 100644
--- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java
+++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java
@@ -175,8 +175,7 @@ public class BOMServices {
BOMTree tree = (BOMTree)treeResult.get("tree");
List<BOMNode> products = new LinkedList<>();
tree.print(products, llc.intValue());
- for (int i = 0; i < products.size(); i++) {
- BOMNode oneNode = products.get(i);
+ for (BOMNode oneNode : products) {
GenericValue oneProduct = oneNode.getProduct();
int lev = 0;
if (oneProduct.get("billOfMaterialLevel") != null) {
@@ -542,10 +541,10 @@ public class BOMServices {
// (search for components that needs to be packaged).
for (Map.Entry<String, Object> partyOrderShipment : partyOrderShipments.entrySet()) {
List<Map<String, Object>> orderShipmentReadMapList = UtilGenerics.cast(partyOrderShipment.getValue());
- for (int i = 0; i < orderShipmentReadMapList.size(); i++) {
- Map<String, Object> orderShipmentReadMap = UtilGenerics.cast(orderShipmentReadMapList.get(i));
- GenericValue orderShipment = (GenericValue)orderShipmentReadMap.get("orderShipment");
- OrderReadHelper orderReadHelper = (OrderReadHelper)orderShipmentReadMap.get("orderReadHelper");
+ for (Map<String, Object> stringObjectMap : orderShipmentReadMapList) {
+ Map<String, Object> orderShipmentReadMap = UtilGenerics.cast(stringObjectMap);
+ GenericValue orderShipment = (GenericValue) orderShipmentReadMap.get("orderShipment");
+ OrderReadHelper orderReadHelper = (OrderReadHelper) orderShipmentReadMap.get("orderReadHelper");
GenericValue orderItem = orderReadHelper.getOrderItem(orderShipment.getString("orderItemSeqId"));
// getProductsInPackages
Map<String, Object> serviceContext = new HashMap<>();
@@ -563,7 +562,8 @@ public class BOMServices {
List<BOMNode> productsInPackages = UtilGenerics.cast(serviceResult.get("productsInPackages"));
if (productsInPackages.size() == 1) {
BOMNode root = productsInPackages.get(0);
- String rootProductId = (root.getSubstitutedNode() != null? root.getSubstitutedNode().getProduct().getString("productId"): root.getProduct().getString("productId"));
+ String rootProductId = (root.getSubstitutedNode() != null ? root.getSubstitutedNode().getProduct().getString("productId")
+ : root.getProduct().getString("productId"));
if (orderItem.getString("productId").equals(rootProductId)) {
productsInPackages = null;
}
@@ -582,10 +582,10 @@ public class BOMServices {
for (Map.Entry<String, Object> partyOrderShipment : partyOrderShipments.entrySet()) {
Map<String, List<Map<String, Object>>> boxTypeContent = new HashMap<>();
List<Map<String, Object>> orderShipmentReadMapList = UtilGenerics.cast(partyOrderShipment.getValue());
- for (int i = 0; i < orderShipmentReadMapList.size(); i++) {
- Map<String, Object> orderShipmentReadMap = UtilGenerics.cast(orderShipmentReadMapList.get(i));
- GenericValue orderShipment = (GenericValue)orderShipmentReadMap.get("orderShipment");
- OrderReadHelper orderReadHelper = (OrderReadHelper)orderShipmentReadMap.get("orderReadHelper");
+ for (Map<String, Object> objectMap : orderShipmentReadMapList) {
+ Map<String, Object> orderShipmentReadMap = UtilGenerics.cast(objectMap);
+ GenericValue orderShipment = (GenericValue) orderShipmentReadMap.get("orderShipment");
+ OrderReadHelper orderReadHelper = (OrderReadHelper) orderShipmentReadMap.get("orderReadHelper");
List<BOMNode> productsInPackages = UtilGenerics.cast(orderShipmentReadMap.get("productsInPackages"));
if (productsInPackages != null) {
// there are subcomponents:
@@ -655,19 +655,19 @@ public class BOMServices {
boxWidth = BigDecimal.ZERO;
}
String shipmentPackageSeqId = null;
- for (int i = 0; i < contentList.size(); i++) {
- Map<String, Object> contentMap = UtilGenerics.cast(contentList.get(i));
+ for (Map<String, Object> stringObjectMap : contentList) {
+ Map<String, Object> contentMap = UtilGenerics.cast(stringObjectMap);
Map<String, Object> content = UtilGenerics.cast(contentMap.get("content"));
- OrderReadHelper orderReadHelper = (OrderReadHelper)content.get("orderReadHelper");
+ OrderReadHelper orderReadHelper = (OrderReadHelper) content.get("orderReadHelper");
List<BOMNode> productsInPackages = UtilGenerics.cast(content.get("productsInPackages"));
- GenericValue orderShipment = (GenericValue)content.get("orderShipment");
+ GenericValue orderShipment = (GenericValue) content.get("orderShipment");
GenericValue product = null;
BigDecimal quantity = BigDecimal.ZERO;
boolean subProduct = contentMap.containsKey("componentIndex");
if (subProduct) {
// multi package
- Integer index = (Integer)contentMap.get("componentIndex");
+ Integer index = (Integer) contentMap.get("componentIndex");
BOMNode component = productsInPackages.get(index);
product = component.getProduct();
quantity = component.getQuantity();
@@ -714,7 +714,7 @@ public class BOMServices {
if (ServiceUtil.isError(serviceResult)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult));
}
- shipmentPackageSeqId = (String)serviceResult.get("shipmentPackageSeqId");
+ shipmentPackageSeqId = (String) serviceResult.get("shipmentPackageSeqId");
} catch (GenericServiceException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingPackageConfiguratorError", locale));
}
@@ -724,17 +724,17 @@ public class BOMServices {
Map<String, Object> inputMap = null;
if (subProduct) {
inputMap = UtilMisc.toMap("shipmentId", orderShipment.getString("shipmentId"),
- "shipmentPackageSeqId", shipmentPackageSeqId,
- "shipmentItemSeqId", orderShipment.getString("shipmentItemSeqId"),
- "subProductId", product.getString("productId"),
- "userLogin", userLogin,
- "subProductQuantity", qty);
+ "shipmentPackageSeqId", shipmentPackageSeqId,
+ "shipmentItemSeqId", orderShipment.getString("shipmentItemSeqId"),
+ "subProductId", product.getString("productId"),
+ "userLogin", userLogin,
+ "subProductQuantity", qty);
} else {
inputMap = UtilMisc.toMap("shipmentId", orderShipment.getString("shipmentId"),
- "shipmentPackageSeqId", shipmentPackageSeqId,
- "shipmentItemSeqId", orderShipment.getString("shipmentItemSeqId"),
- "userLogin", userLogin,
- "quantity", qty);
+ "shipmentPackageSeqId", shipmentPackageSeqId,
+ "shipmentItemSeqId", orderShipment.getString("shipmentItemSeqId"),
+ "userLogin", userLogin,
+ "quantity", qty);
}
Map<String, Object> serviceResult = dispatcher.runSync("createShipmentPackageContent", inputMap);
if (ServiceUtil.isError(serviceResult)) {
diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMTree.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMTree.java
index a8e2d08..ab09655 100644
--- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMTree.java
+++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMTree.java
@@ -107,8 +107,8 @@ public class BOMTree {
.queryList();
List<GenericValue> productFeatures = new LinkedList<>();
GenericValue oneProductFeatureAppl = null;
- for (int i = 0; i < productFeaturesAppl.size(); i++) {
- oneProductFeatureAppl = productFeaturesAppl.get(i);
+ for (GenericValue genericValue : productFeaturesAppl) {
+ oneProductFeatureAppl = genericValue;
productFeatures.add(oneProductFeatureAppl.getRelatedOne("ProductFeature", false));
}
// If the product is manufactured as a different product,
@@ -303,8 +303,8 @@ public class BOMTree {
List<BOMNode> nodeArr = new LinkedList<>();
List<String> productsId = new LinkedList<>();
print(nodeArr);
- for (int i = 0; i < nodeArr.size(); i++) {
- productsId.add((nodeArr.get(i)).getProduct().getString("productId"));
+ for (BOMNode bomNode : nodeArr) {
+ productsId.add(bomNode.getProduct().getString("productId"));
}
return productsId;
}
diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRun.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRun.java
index 9cccfee..4f1a9b1 100644
--- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRun.java
+++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRun.java
@@ -141,14 +141,12 @@ public class ProductionRun {
}
productionRun.store();
if (productionRunRoutingTasks != null) {
- for (Iterator<GenericValue> iter = productionRunRoutingTasks.iterator(); iter.hasNext();) {
- GenericValue routingTask = iter.next();
+ for (GenericValue routingTask : productionRunRoutingTasks) {
routingTask.store();
}
}
if (productionRunComponents != null) {
- for (Iterator<GenericValue> iter = productionRunComponents.iterator(); iter.hasNext();) {
- GenericValue component = iter.next();
+ for (GenericValue component : productionRunComponents) {
component.store();
}
}
@@ -205,8 +203,7 @@ public class ProductionRun {
this.quantityIsUpdated = true;
this.updateCompletionDate = true;
if (productionRunComponents == null) getProductionRunComponents();
- for (Iterator<GenericValue> iter = productionRunComponents.iterator(); iter.hasNext();) {
- GenericValue component = iter.next();
+ for (GenericValue component : productionRunComponents) {
componentQuantity = component.getBigDecimal("estimatedQuantity");
component.set("estimatedQuantity", componentQuantity.divide(previousQuantity, 10, RoundingMode.HALF_UP).multiply(newQuantity).doubleValue());
}
@@ -260,15 +257,14 @@ public class ProductionRun {
getProductionRunRoutingTasks();
if (quantity == null) getQuantity();
Timestamp endDate=null;
- for (Iterator<GenericValue> iter = productionRunRoutingTasks.iterator(); iter.hasNext();) {
- GenericValue routingTask = iter.next();
+ for (GenericValue routingTask : productionRunRoutingTasks) {
if (priority.compareTo(routingTask.getLong("priority")) <= 0) {
// Calculate the estimatedCompletionDate
long totalTime = ProductionRun.getEstimatedTaskTime(routingTask, quantity, dispatcher);
- endDate = TechDataServices.addForward(TechDataServices.getTechDataCalendar(routingTask),startDate, totalTime);
+ endDate = TechDataServices.addForward(TechDataServices.getTechDataCalendar(routingTask), startDate, totalTime);
// update the routingTask
- routingTask.set("estimatedStartDate",startDate);
- routingTask.set("estimatedCompletionDate",endDate);
+ routingTask.set("estimatedStartDate", startDate);
+ routingTask.set("estimatedCompletionDate", endDate);
startDate = endDate;
}
}
@@ -335,9 +331,10 @@ public class ProductionRun {
try {
productionRunComponents = new LinkedList<>();
GenericValue routingTask;
- for (Iterator<GenericValue> iter = productionRunRoutingTasks.iterator(); iter.hasNext();) {
- routingTask = iter.next();
- productionRunComponents.addAll(routingTask.getRelated("WorkEffortGoodStandard", UtilMisc.toMap("workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED"),null, false));
+ for (GenericValue productionRunRoutingTask : productionRunRoutingTasks) {
+ routingTask = productionRunRoutingTask;
+ productionRunComponents.addAll(routingTask.getRelated("WorkEffortGoodStandard"
+ , UtilMisc.toMap("workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED"), null, false));
}
} catch (GenericEntityException e) {
Debug.logWarning(e.getMessage(), MODULE);
diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java
index 9b9bbb7..2177934 100644
--- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java
+++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java
@@ -90,8 +90,7 @@ public final class ProductionRunHelper {
.where("workEffortIdTo", productionRunId,
"workEffortAssocTypeId", "WORK_EFF_PRECEDENCY")
.filterByDate().queryList();
- for (int i = 0; i < linkedWorkEfforts.size(); i++) {
- GenericValue link = linkedWorkEfforts.get(i);
+ for (GenericValue link : linkedWorkEfforts) {
getLinkedProductionRuns(delegator, dispatcher, link.getString("workEffortIdFrom"), productionRuns);
}
}
diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
index 7ad8481..e812a56 100644
--- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
+++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
@@ -705,12 +705,11 @@ public class ProductionRunServices {
.where("workEffortIdTo", productionRunId,
"workEffortAssocTypeId", "WORK_EFF_PRECEDENCY")
.filterByDate().queryList();
- for (int i = 0; i < mandatoryWorkEfforts.size(); i++) {
- GenericValue mandatoryWorkEffortAssoc = mandatoryWorkEfforts.get(i);
+ for (GenericValue mandatoryWorkEffortAssoc : mandatoryWorkEfforts) {
GenericValue mandatoryWorkEffort = mandatoryWorkEffortAssoc.getRelatedOne("FromWorkEffort", false);
if (!("PRUN_COMPLETED".equals(mandatoryWorkEffort.getString("currentStatusId")) ||
- "PRUN_RUNNING".equals(mandatoryWorkEffort.getString("currentStatusId")) ||
- "PRUN_CLOSED".equals(mandatoryWorkEffort.getString("currentStatusId")))) {
+ "PRUN_RUNNING".equals(mandatoryWorkEffort.getString("currentStatusId")) ||
+ "PRUN_CLOSED".equals(mandatoryWorkEffort.getString("currentStatusId")))) {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingProductionRunStatusNotChangedMandatoryProductionRunNotCompleted", locale));
}
}
@@ -828,8 +827,8 @@ public class ProductionRunServices {
GenericValue oneTask = null;
boolean allTaskCompleted = true;
boolean allPrecTaskCompletedOrRunning = true;
- for (int i = 0; i < tasks.size(); i++) {
- oneTask = tasks.get(i);
+ for (GenericValue task : tasks) {
+ oneTask = task;
if (oneTask.getString("workEffortId").equals(taskId)) {
theTask = oneTask;
} else {
@@ -1026,25 +1025,24 @@ public class ProductionRunServices {
List<GenericValue> productCostComponentCalcs = EntityQuery.use(delegator).from("ProductCostComponentCalc")
.where("productId", productionRun.getProductProduced().get("productId"))
.orderBy("sequenceNum").queryList();
- for (int i = 0; i < productCostComponentCalcs.size(); i++) {
- GenericValue productCostComponentCalc = productCostComponentCalcs.get(i);
+ for (GenericValue productCostComponentCalc : productCostComponentCalcs) {
GenericValue costComponentCalc = productCostComponentCalc.getRelatedOne("CostComponentCalc", false);
GenericValue customMethod = costComponentCalc.getRelatedOne("CustomMethod", false);
if (customMethod == null) {
// TODO: not supported for CostComponentCalc entries directly associated to a product
Debug.logWarning("Unable to create cost component for cost component calc with id [" + costComponentCalc.getString("costComponentCalcId") + "] because customMethod is not set", MODULE);
} else {
- Map<String, Object> costMethodResult = dispatcher.runSync(customMethod.getString("customMethodName"),
+ Map<String, Object> costMethodResult = dispatcher.runSync(customMethod.getString("customMethodName"),
UtilMisc.toMap("productCostComponentCalc", productCostComponentCalc,
"costComponentCalc", costComponentCalc,
"costComponentTypePrefix", "ACTUAL",
"baseCost", totalCost,
- "currencyUomId", (String)partyAccountingPreference.get("baseCurrencyUomId"),
+ "currencyUomId", (String) partyAccountingPreference.get("baseCurrencyUomId"),
"userLogin", userLogin));
if (ServiceUtil.isError(costMethodResult)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(costMethodResult));
}
- BigDecimal productCostAdjustment = (BigDecimal)costMethodResult.get("productCostAdjustment");
+ BigDecimal productCostAdjustment = (BigDecimal) costMethodResult.get("productCostAdjustment");
totalCost = totalCost.add(productCostAdjustment);
Map<String, Object> inMap = UtilMisc.<String, Object>toMap("userLogin", userLogin, "workEffortId", productionRunId);
inMap.put("costComponentCalcId", costComponentCalc.getString("costComponentCalcId"));
@@ -1357,24 +1355,24 @@ public class ProductionRunServices {
Long priority = (Long) context.get("priority");
List<GenericValue> pRRoutingTasks = productionRun.getProductionRunRoutingTasks();
boolean first = true;
- for (Iterator<GenericValue> iter = pRRoutingTasks.iterator(); iter.hasNext();) {
- GenericValue routingTask = iter.next();
- if (priority.equals(routingTask.get("priority")) && ! routingTaskId.equals(routingTask.get("workEffortId")))
+ for (GenericValue routingTask : pRRoutingTasks) {
+ if (priority.equals(routingTask.get("priority")) && !routingTaskId.equals(routingTask.get("workEffortId")))
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingRoutingTaskSeqIdAlreadyExist", locale));
if (routingTaskId.equals(routingTask.get("workEffortId"))) {
routingTask.set("estimatedSetupMillis", ((BigDecimal) context.get("estimatedSetupMillis")).doubleValue());
- routingTask.set("estimatedMilliSeconds", ( (BigDecimal) context.get("estimatedMilliSeconds")).doubleValue());
+ routingTask.set("estimatedMilliSeconds", ((BigDecimal) context.get("estimatedMilliSeconds")).doubleValue());
if (first) { // for the first routingTask the estimatedStartDate update imply estimatedStartDate productonRun update
- if (! estimatedStartDate.equals(pRestimatedStartDate)) {
+ if (!estimatedStartDate.equals(pRestimatedStartDate)) {
productionRun.setEstimatedStartDate(estimatedStartDate);
}
}
// the priority has been changed
- if (! priority.equals(routingTask.get("priority"))) {
+ if (!priority.equals(routingTask.get("priority"))) {
routingTask.set("priority", priority);
// update the routingTask List and re-read it to be able to have it sorted with the new value
- if (! productionRun.store()) {
- Debug.logError("productionRun.store(), in routingTask.priority update, fail for productionRunId ="+productionRunId,MODULE);
+ if (!productionRun.store()) {
+ Debug.logError("productionRun.store(), in routingTask.priority update, fail for productionRunId ="
+ + productionRunId, MODULE);
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingProductionRunNotUpdated", locale));
}
productionRun.clearRoutingTasksList();
diff --git a/build.gradle b/build.gradle
index 496673e..a1f5ae7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -287,7 +287,7 @@ checkstyle {
// the sum of errors found last time it was changed after using the
// ‘checkstyle’ tool present in the framework and in the official
// plugins.
- tasks.checkstyleMain.maxErrors = 26735
+ tasks.checkstyleMain.maxErrors = 26684
// Currently there are a lot of errors so we need to temporarily
// hide them to avoid polluting the terminal output.
showViolations = false