Improved: Add missing ‘static’ modifier for private methods
(OFBIZ-11098) In order to make it clear when a method is not depending on the internal state of an object, it is a good practice to declare it as static. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-plugins/trunk@1860939 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -83,15 +83,15 @@ public class ProductDocument implements LuceneDocument {
|
||||
|
||||
// Product Fields
|
||||
doc.add(new StringField("productId", productId, Field.Store.YES));
|
||||
this.addTextField(doc, "productName", product.getString("productName"), false, "fullText", delegator);
|
||||
this.addTextField(doc, "internalName", product.getString("internalName"), false, "fullText", delegator);
|
||||
this.addTextField(doc, "brandName", product.getString("brandName"), false, "fullText", delegator);
|
||||
this.addTextField(doc, "description", product.getString("description"), false, "fullText", delegator);
|
||||
this.addTextField(doc, "longDescription", product.getString("longDescription"), false, "fullText", delegator);
|
||||
addTextField(doc, "productName", product.getString("productName"), false, "fullText", delegator);
|
||||
addTextField(doc, "internalName", product.getString("internalName"), false, "fullText", delegator);
|
||||
addTextField(doc, "brandName", product.getString("brandName"), false, "fullText", delegator);
|
||||
addTextField(doc, "description", product.getString("description"), false, "fullText", delegator);
|
||||
addTextField(doc, "longDescription", product.getString("longDescription"), false, "fullText", delegator);
|
||||
doc.add(new LongPoint("introductionDate", quantizeTimestampToDays(product.getTimestamp("introductionDate"))));
|
||||
nextReIndex = this.checkSetNextReIndex(product.getTimestamp("introductionDate"), nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(product.getTimestamp("introductionDate"), nextReIndex);
|
||||
doc.add(new LongPoint("salesDiscontinuationDate", quantizeTimestampToDays(product.getTimestamp("salesDiscontinuationDate"))));
|
||||
nextReIndex = this.checkSetNextReIndex(product.getTimestamp("salesDiscontinuationDate"), nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(product.getTimestamp("salesDiscontinuationDate"), nextReIndex);
|
||||
doc.add(new StringField("isVariant", product.get("isVariant") != null && product.getBoolean("isVariant") ? "true" : "false", Field.Store.NO));
|
||||
|
||||
// ProductFeature Fields, check that at least one of the fields is set to be indexed
|
||||
@@ -100,36 +100,36 @@ public class ProductDocument implements LuceneDocument {
|
||||
!"0".equals(EntityUtilProperties.getPropertyValue("prodsearch", "index.weight.ProductFeatureAndAppl.idCode", "0", delegator))) {
|
||||
|
||||
List<GenericValue> productFeatureAndAppls = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId).queryList();
|
||||
productFeatureAndAppls = this.filterByThruDate(productFeatureAndAppls);
|
||||
productFeatureAndAppls = filterByThruDate(productFeatureAndAppls);
|
||||
|
||||
for (GenericValue productFeatureAndAppl: productFeatureAndAppls) {
|
||||
Timestamp fromDate = productFeatureAndAppl.getTimestamp("fromDate");
|
||||
Timestamp thruDate = productFeatureAndAppl.getTimestamp("thruDate");
|
||||
if (fromDate != null && fromDate.after(UtilDateTime.nowTimestamp())) {
|
||||
// fromDate is after now, update reindex date but don't index the feature
|
||||
nextReIndex = this.checkSetNextReIndex(fromDate, nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(fromDate, nextReIndex);
|
||||
continue;
|
||||
} else if (thruDate != null) {
|
||||
nextReIndex = this.checkSetNextReIndex(thruDate, nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(thruDate, nextReIndex);
|
||||
}
|
||||
doc.add(new StringField("productFeatureId", productFeatureAndAppl.getString("productFeatureId"), Field.Store.NO));
|
||||
doc.add(new StringField("productFeatureCategoryId", productFeatureAndAppl.getString("productFeatureCategoryId"), Field.Store.NO));
|
||||
doc.add(new StringField("productFeatureTypeId", productFeatureAndAppl.getString("productFeatureTypeId"), Field.Store.NO));
|
||||
this.addTextField(doc, "featureDescription", productFeatureAndAppl.getString("description"), false, "fullText", delegator);
|
||||
this.addTextField(doc, "featureAbbreviation", productFeatureAndAppl.getString("abbrev"), false, "fullText", delegator);
|
||||
this.addTextField(doc, "featureCode", productFeatureAndAppl.getString("idCode"), false, "fullText", delegator);
|
||||
addTextField(doc, "featureDescription", productFeatureAndAppl.getString("description"), false, "fullText", delegator);
|
||||
addTextField(doc, "featureAbbreviation", productFeatureAndAppl.getString("abbrev"), false, "fullText", delegator);
|
||||
addTextField(doc, "featureCode", productFeatureAndAppl.getString("idCode"), false, "fullText", delegator);
|
||||
// Get the ProductFeatureGroupIds
|
||||
List<GenericValue> productFeatureGroupAppls = EntityQuery.use(delegator).from("ProductFeatureGroupAppl").where("productFeatureId", productFeatureAndAppl.get("productFeatureId")).queryList();
|
||||
productFeatureGroupAppls = this.filterByThruDate(productFeatureGroupAppls);
|
||||
productFeatureGroupAppls = filterByThruDate(productFeatureGroupAppls);
|
||||
for (GenericValue productFeatureGroupAppl : productFeatureGroupAppls) {
|
||||
fromDate = productFeatureGroupAppl.getTimestamp("fromDate");
|
||||
thruDate = productFeatureGroupAppl.getTimestamp("thruDate");
|
||||
if (fromDate != null && fromDate.after(UtilDateTime.nowTimestamp())) {
|
||||
// fromDate is after now, update reindex date but don't index the feature
|
||||
nextReIndex = this.checkSetNextReIndex(fromDate, nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(fromDate, nextReIndex);
|
||||
continue;
|
||||
} else if (thruDate != null) {
|
||||
nextReIndex = this.checkSetNextReIndex(thruDate, nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(thruDate, nextReIndex);
|
||||
}
|
||||
doc.add(new StringField("productFeatureGroupId", productFeatureGroupAppl.getString("productFeatureGroupId"), Field.Store.NO));
|
||||
}
|
||||
@@ -142,8 +142,8 @@ public class ProductDocument implements LuceneDocument {
|
||||
|
||||
List<GenericValue> productAttributes = EntityQuery.use(delegator).from("ProductAttribute").where("productId", productId).queryList();
|
||||
for (GenericValue productAttribute: productAttributes) {
|
||||
this.addTextField(doc, "attributeName", productAttribute.getString("attrName"), false, "fullText", delegator);
|
||||
this.addTextField(doc, "attributeValue", productAttribute.getString("attrValue"), false, "fullText", delegator);
|
||||
addTextField(doc, "attributeName", productAttribute.getString("attrName"), false, "fullText", delegator);
|
||||
addTextField(doc, "attributeValue", productAttribute.getString("attrValue"), false, "fullText", delegator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class ProductDocument implements LuceneDocument {
|
||||
String idValue = goodIdentification.getString("idValue");
|
||||
doc.add(new StringField("goodIdentificationTypeId", goodIdentificationTypeId, Field.Store.NO));
|
||||
doc.add(new StringField(goodIdentificationTypeId + "_GoodIdentification", idValue, Field.Store.NO));
|
||||
this.addTextField(doc, "identificationValue", idValue, false, "fullText", delegator);
|
||||
addTextField(doc, "identificationValue", idValue, false, "fullText", delegator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,18 +163,18 @@ public class ProductDocument implements LuceneDocument {
|
||||
if ("Y".equals(product.getString("isVirtual"))) {
|
||||
if (!"0".equals(EntityUtilProperties.getPropertyValue("prodsearch", "index.weight.Variant.Product.productId", "0", delegator))) {
|
||||
List<GenericValue> variantProductAssocs = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT").queryList();
|
||||
variantProductAssocs = this.filterByThruDate(variantProductAssocs);
|
||||
variantProductAssocs = filterByThruDate(variantProductAssocs);
|
||||
for (GenericValue variantProductAssoc: variantProductAssocs) {
|
||||
Timestamp fromDate = variantProductAssoc.getTimestamp("fromDate");
|
||||
Timestamp thruDate = variantProductAssoc.getTimestamp("thruDate");
|
||||
if (fromDate != null && fromDate.after(UtilDateTime.nowTimestamp())) {
|
||||
// fromDate is after now, update reindex date but don't index the feature
|
||||
nextReIndex = this.checkSetNextReIndex(fromDate, nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(fromDate, nextReIndex);
|
||||
continue;
|
||||
} else if (thruDate != null) {
|
||||
nextReIndex = this.checkSetNextReIndex(thruDate, nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(thruDate, nextReIndex);
|
||||
}
|
||||
this.addTextField(doc, "variantProductId", variantProductAssoc.getString("productIdTo"), false, "fullText", delegator);
|
||||
addTextField(doc, "variantProductId", variantProductAssoc.getString("productIdTo"), false, "fullText", delegator);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,21 +189,21 @@ public class ProductDocument implements LuceneDocument {
|
||||
}
|
||||
|
||||
List<GenericValue> productContentAndInfos = EntityQuery.use(delegator).from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", productContentTypeId).queryList();
|
||||
productContentAndInfos = this.filterByThruDate(productContentAndInfos);
|
||||
productContentAndInfos = filterByThruDate(productContentAndInfos);
|
||||
for (GenericValue productContentAndInfo: productContentAndInfos) {
|
||||
Timestamp fromDate = productContentAndInfo.getTimestamp("fromDate");
|
||||
Timestamp thruDate = productContentAndInfo.getTimestamp("thruDate");
|
||||
if (fromDate != null && fromDate.after(UtilDateTime.nowTimestamp())) {
|
||||
// fromDate is after now, update reindex date but don't index the feature
|
||||
nextReIndex = this.checkSetNextReIndex(fromDate, nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(fromDate, nextReIndex);
|
||||
continue;
|
||||
} else if (thruDate != null) {
|
||||
nextReIndex = this.checkSetNextReIndex(thruDate, nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(thruDate, nextReIndex);
|
||||
}
|
||||
try {
|
||||
Map<String, Object> drContext = UtilMisc.<String, Object>toMap("product", product);
|
||||
String contentText = DataResourceWorker.renderDataResourceAsText(null, delegator, productContentAndInfo.getString("dataResourceId"), drContext, null, null, false);
|
||||
this.addTextField(doc, "content", contentText, false, "fullText", delegator);
|
||||
addTextField(doc, "content", contentText, false, "fullText", delegator);
|
||||
} catch (IOException e1) {
|
||||
Debug.logError(e1, "Error getting content text to index", module);
|
||||
} catch (GeneralException e1) {
|
||||
@@ -225,16 +225,16 @@ public class ProductDocument implements LuceneDocument {
|
||||
|
||||
// Index ProductPrices, uses dynamic fields in the format ${productPriceTypeId}_${productPricePurposeId}_${currencyUomId}_${productStoreGroupId}_price
|
||||
List<GenericValue> productPrices = product.getRelated("ProductPrice", null, null, false);
|
||||
productPrices = this.filterByThruDate(productPrices);
|
||||
productPrices = filterByThruDate(productPrices);
|
||||
for (GenericValue productPrice : productPrices) {
|
||||
Timestamp fromDate = productPrice.getTimestamp("fromDate");
|
||||
Timestamp thruDate = productPrice.getTimestamp("thruDate");
|
||||
if (fromDate != null && fromDate.after(UtilDateTime.nowTimestamp())) {
|
||||
// fromDate is after now, update reindex date but don't index the feature
|
||||
nextReIndex = this.checkSetNextReIndex(fromDate, nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(fromDate, nextReIndex);
|
||||
continue;
|
||||
} else if (thruDate != null) {
|
||||
nextReIndex = this.checkSetNextReIndex(thruDate, nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(thruDate, nextReIndex);
|
||||
}
|
||||
StringBuilder fieldNameSb = new StringBuilder();
|
||||
fieldNameSb.append(productPrice.getString("productPriceTypeId"));
|
||||
@@ -250,17 +250,17 @@ public class ProductDocument implements LuceneDocument {
|
||||
|
||||
// Index ProductSuppliers
|
||||
List<GenericValue> supplierProducts = product.getRelated("SupplierProduct", null, null, false);
|
||||
supplierProducts = this.filterByThruDate(supplierProducts, "availableThruDate");
|
||||
supplierProducts = filterByThruDate(supplierProducts, "availableThruDate");
|
||||
Set<String> supplierPartyIds = new TreeSet<>();
|
||||
for (GenericValue supplierProduct : supplierProducts) {
|
||||
Timestamp fromDate = supplierProduct.getTimestamp("availableFromDate");
|
||||
Timestamp thruDate = supplierProduct.getTimestamp("availableThruDate");
|
||||
if (fromDate != null && fromDate.after(UtilDateTime.nowTimestamp())) {
|
||||
// fromDate is after now, update reindex date but don't index the feature
|
||||
nextReIndex = this.checkSetNextReIndex(fromDate, nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(fromDate, nextReIndex);
|
||||
continue;
|
||||
} else if (thruDate != null) {
|
||||
nextReIndex = this.checkSetNextReIndex(thruDate, nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(thruDate, nextReIndex);
|
||||
}
|
||||
supplierPartyIds.add(supplierProduct.getString("partyId"));
|
||||
}
|
||||
@@ -279,7 +279,7 @@ public class ProductDocument implements LuceneDocument {
|
||||
}
|
||||
|
||||
// An attempt to boost/weight values in a similar manner to what OFBiz product search does.
|
||||
private void addTextField(Document doc, String fieldName, String value, boolean store, String fullTextFieldName, Delegator delegator) {
|
||||
private static void addTextField(Document doc, String fieldName, String value, boolean store,String fullTextFieldName, Delegator delegator) {
|
||||
if (fieldName == null) return;
|
||||
|
||||
Field field = new TextField(fieldName, checkValue(value), (store? Field.Store.YES: Field.Store.NO));
|
||||
@@ -289,14 +289,14 @@ public class ProductDocument implements LuceneDocument {
|
||||
}
|
||||
}
|
||||
|
||||
private String checkValue(String value) {
|
||||
private static String checkValue(String value) {
|
||||
if (UtilValidate.isEmpty(value)) {
|
||||
return NULL_STRING;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private Timestamp checkSetNextReIndex(Timestamp nextValue, Timestamp currentValue) {
|
||||
private static Timestamp checkSetNextReIndex(Timestamp nextValue, Timestamp currentValue) {
|
||||
// nextValue is null, stick with what we've got
|
||||
if (nextValue == null) return currentValue;
|
||||
// currentValue is null so use nextValue
|
||||
@@ -313,11 +313,11 @@ public class ProductDocument implements LuceneDocument {
|
||||
EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, UtilDateTime.nowTimestamp())
|
||||
);
|
||||
|
||||
private List<GenericValue> filterByThruDate(List<GenericValue> values) {
|
||||
private static List<GenericValue> filterByThruDate(List<GenericValue> values) {
|
||||
return EntityUtil.filterByCondition(values, THRU_DATE_ONLY_CONDITION);
|
||||
}
|
||||
|
||||
private List<GenericValue> filterByThruDate(List<GenericValue> values, String thruDateName) {
|
||||
private static List<GenericValue> filterByThruDate(List<GenericValue> values, String thruDateName) {
|
||||
return EntityUtil.filterByCondition(values, EntityCondition.makeCondition(
|
||||
EntityCondition.makeCondition(thruDateName, EntityOperator.EQUALS, null),
|
||||
EntityOperator.OR,
|
||||
@@ -329,7 +329,7 @@ public class ProductDocument implements LuceneDocument {
|
||||
Timestamp nextReIndex = null;
|
||||
Set<String> indexedCategoryIds = new TreeSet<>();
|
||||
List<GenericValue> productCategoryMembers = product.getRelated("ProductCategoryMember", null, null, false);
|
||||
productCategoryMembers = this.filterByThruDate(productCategoryMembers);
|
||||
productCategoryMembers = filterByThruDate(productCategoryMembers);
|
||||
|
||||
for (GenericValue productCategoryMember: productCategoryMembers) {
|
||||
String productCategoryId = productCategoryMember.getString("productCategoryId");
|
||||
@@ -340,12 +340,12 @@ public class ProductDocument implements LuceneDocument {
|
||||
Timestamp thruDate = productCategoryMember.getTimestamp("thruDate");
|
||||
if (fromDate != null && fromDate.after(UtilDateTime.nowTimestamp())) {
|
||||
// fromDate is after now, update reindex date but don't index the feature
|
||||
nextReIndex = this.checkSetNextReIndex(fromDate, nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(fromDate, nextReIndex);
|
||||
continue;
|
||||
} else if (thruDate != null) {
|
||||
nextReIndex = this.checkSetNextReIndex(thruDate, nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(thruDate, nextReIndex);
|
||||
}
|
||||
nextReIndex = this.checkSetNextReIndex(
|
||||
nextReIndex = checkSetNextReIndex(
|
||||
this.getParentCategories(doc, productCategoryMember.getRelatedOne("ProductCategory", false), indexedCategoryIds),
|
||||
nextReIndex);
|
||||
}
|
||||
@@ -358,18 +358,18 @@ public class ProductDocument implements LuceneDocument {
|
||||
|
||||
private Timestamp getParentCategories(Document doc, GenericValue productCategory, Set<String> indexedCategoryIds, Set<String> indexedCatalogIds) throws GenericEntityException {
|
||||
Timestamp nextReIndex = null;
|
||||
nextReIndex = this.getCategoryCatalogs(doc, productCategory, indexedCatalogIds);
|
||||
nextReIndex = getCategoryCatalogs(doc, productCategory, indexedCatalogIds);
|
||||
List<GenericValue> productCategoryRollups = productCategory.getRelated("CurrentProductCategoryRollup", null, null, false);
|
||||
productCategoryRollups = this.filterByThruDate(productCategoryRollups);
|
||||
productCategoryRollups = filterByThruDate(productCategoryRollups);
|
||||
for (GenericValue productCategoryRollup : productCategoryRollups) {
|
||||
Timestamp fromDate = productCategoryRollup.getTimestamp("fromDate");
|
||||
Timestamp thruDate = productCategoryRollup.getTimestamp("thruDate");
|
||||
if (fromDate != null && fromDate.after(UtilDateTime.nowTimestamp())) {
|
||||
// fromDate is after now, update reindex date but don't index now
|
||||
nextReIndex = this.checkSetNextReIndex(fromDate, nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(fromDate, nextReIndex);
|
||||
continue;
|
||||
} else if (thruDate != null) {
|
||||
nextReIndex = this.checkSetNextReIndex(thruDate, nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(thruDate, nextReIndex);
|
||||
}
|
||||
// Skip if we've done this category already
|
||||
if (!indexedCategoryIds.add(productCategoryRollup.getString("parentProductCategoryId"))) {
|
||||
@@ -377,7 +377,7 @@ public class ProductDocument implements LuceneDocument {
|
||||
}
|
||||
GenericValue parentProductCategory = productCategoryRollup.getRelatedOne("ParentProductCategory", false);
|
||||
doc.add(new StringField("productCategoryId", parentProductCategory.getString("productCategoryId"), Field.Store.NO));
|
||||
nextReIndex = this.checkSetNextReIndex(
|
||||
nextReIndex = checkSetNextReIndex(
|
||||
this.getParentCategories(doc, parentProductCategory, indexedCategoryIds),
|
||||
nextReIndex
|
||||
);
|
||||
@@ -385,19 +385,19 @@ public class ProductDocument implements LuceneDocument {
|
||||
return nextReIndex;
|
||||
}
|
||||
|
||||
private Timestamp getCategoryCatalogs(Document doc, GenericValue productCategory, Set<String> indexedCatalogIds) throws GenericEntityException {
|
||||
private static Timestamp getCategoryCatalogs(Document doc, GenericValue productCategory, Set<String> indexedCatalogIds) throws GenericEntityException {
|
||||
Timestamp nextReIndex = null;
|
||||
List<GenericValue> prodCatalogCategories = productCategory.getRelated("ProdCatalogCategory", null, null, false);
|
||||
prodCatalogCategories = this.filterByThruDate(prodCatalogCategories);
|
||||
prodCatalogCategories = filterByThruDate(prodCatalogCategories);
|
||||
for (GenericValue prodCatalogCategory : prodCatalogCategories) {
|
||||
Timestamp fromDate = prodCatalogCategory.getTimestamp("fromDate");
|
||||
Timestamp thruDate = prodCatalogCategory.getTimestamp("thruDate");
|
||||
if (fromDate != null && fromDate.after(UtilDateTime.nowTimestamp())) {
|
||||
// fromDate is after now, update reindex date but don't index now
|
||||
nextReIndex = this.checkSetNextReIndex(fromDate, nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(fromDate, nextReIndex);
|
||||
continue;
|
||||
} else if (thruDate != null) {
|
||||
nextReIndex = this.checkSetNextReIndex(thruDate, nextReIndex);
|
||||
nextReIndex = checkSetNextReIndex(thruDate, nextReIndex);
|
||||
}
|
||||
// Skip if we've done this catalog already
|
||||
if (!indexedCatalogIds.add(prodCatalogCategory.getString("prodCatalogId"))) {
|
||||
@@ -408,7 +408,7 @@ public class ProductDocument implements LuceneDocument {
|
||||
return nextReIndex;
|
||||
}
|
||||
|
||||
private long quantizeTimestampToDays(Timestamp date) {
|
||||
private static long quantizeTimestampToDays(Timestamp date) {
|
||||
long quantizedDate = 0;
|
||||
if (date != null) {
|
||||
quantizedDate = date.getTime()/24/3600;
|
||||
|
||||
Reference in New Issue
Block a user