svn commit: r1757981 - in /ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar: ExpressionUiHelper.java TemporalExpressionWorker.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1757981 - in /ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar: ExpressionUiHelper.java TemporalExpressionWorker.java

Arun Patidar-4
Author: arunpatidar
Date: Sat Aug 27 10:08:52 2016
New Revision: 1757981

URL: http://svn.apache.org/viewvc?rev=1757981&view=rev
Log:
Applied patch from jira issue - OFBIZ-7913 - Enforce noninstantiability to TemporalExpressionWorker class. Thanks Rishi Solanki and Pratik Kulshreshth for your contribution.

Modified:
    ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/ExpressionUiHelper.java
    ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/TemporalExpressionWorker.java

Modified: ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/ExpressionUiHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/ExpressionUiHelper.java?rev=1757981&r1=1757980&r2=1757981&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/ExpressionUiHelper.java (original)
+++ ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/ExpressionUiHelper.java Sat Aug 27 10:08:52 2016
@@ -124,10 +124,10 @@ public class ExpressionUiHelper {
      * <code>description</code> entry and a <code>value</code> entry.
      */
     public static List<Map<String, Object>> getExpressionTypeList(Map<String, Object> uiLabelMap) {
-        int listSize = TemporalExpressionWorker.ExpressionTypeList.length;
+        int listSize = TemporalExpressionWorker.getExpressionTypeList().length;
         List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(listSize);
         for (int i = 0; i < listSize; i++) {
-            String exprType = TemporalExpressionWorker.ExpressionTypeList[i];
+            String exprType = TemporalExpressionWorker.getExpressionTypeList()[i];
             result.add(UtilMisc.toMap("description", uiLabelMap.get("TemporalExpression_" + exprType), "value", exprType));
         }
         return result;

Modified: ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/TemporalExpressionWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/TemporalExpressionWorker.java?rev=1757981&r1=1757980&r2=1757981&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/TemporalExpressionWorker.java (original)
+++ ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/TemporalExpressionWorker.java Sat Aug 27 10:08:52 2016
@@ -30,30 +30,32 @@ import org.apache.ofbiz.entity.GenericVa
 import org.apache.ofbiz.entity.util.EntityQuery;
 
 /** TemporalExpression persistence worker. */
-public class TemporalExpressionWorker {
+public final class TemporalExpressionWorker {
 
     public final static String module = TemporalExpressionWorker.class.getName();
 
     // Temporal expression type constants
-    public final static String DateRange = "DATE_RANGE";
-    public final static String DayInMonth = "DAY_IN_MONTH";
-    public final static String DayOfMonthRange = "DAY_OF_MONTH_RANGE";
-    public final static String DayOfWeekRange = "DAY_OF_WEEK_RANGE";
-    public final static String Difference = "DIFFERENCE";
-    public final static String Frequency = "FREQUENCY";
-    public final static String HourRange = "HOUR_RANGE";
-    public final static String Intersection = "INTERSECTION";
-    public final static String MinuteRange = "MINUTE_RANGE";
-    public final static String MonthRange = "MONTH_RANGE";
-    public final static String Substitution = "SUBSTITUTION";
-    public final static String Union = "UNION";
-    public final static String ExpressionTypeList[] = {DateRange, DayInMonth, DayOfMonthRange, DayOfWeekRange,
+    private final static String DateRange = "DATE_RANGE";
+    private final static String DayInMonth = "DAY_IN_MONTH";
+    private final static String DayOfMonthRange = "DAY_OF_MONTH_RANGE";
+    private final static String DayOfWeekRange = "DAY_OF_WEEK_RANGE";
+    private final static String Difference = "DIFFERENCE";
+    private final static String Frequency = "FREQUENCY";
+    private final static String HourRange = "HOUR_RANGE";
+    private final static String Intersection = "INTERSECTION";
+    private final static String MinuteRange = "MINUTE_RANGE";
+    private final static String MonthRange = "MONTH_RANGE";
+    private final static String Substitution = "SUBSTITUTION";
+    private final static String Union = "UNION";
+    private final static String ExpressionTypeList[] = {DateRange, DayInMonth, DayOfMonthRange, DayOfWeekRange,
         Difference, Frequency, HourRange, Intersection, MinuteRange, MonthRange, Substitution, Union};
 
     // Temporal expression assoc type constants
-    public final static String INCLUDE = "INCLUDE";
-    public final static String EXCLUDE = "EXCLUDE";
-    public final static String SUBSTITUTE = "SUBSTITUTE";
+    private final static String INCLUDE = "INCLUDE";
+    private final static String EXCLUDE = "EXCLUDE";
+    private final static String SUBSTITUTE = "SUBSTITUTE";
+
+    private TemporalExpressionWorker () {}
 
     /** Get a <code>TemporalExpression</code> from persistent storage.
      * @param delegator
@@ -143,7 +145,7 @@ public class TemporalExpressionWorker {
         return TemporalExpressions.NullExpression;
     }
 
-    protected static Set<TemporalExpression> getChildExpressions(Delegator delegator, String tempExprId) throws GenericEntityException {
+    private static Set<TemporalExpression> getChildExpressions(Delegator delegator, String tempExprId) throws GenericEntityException {
         List<GenericValue> valueList = EntityQuery.use(delegator).from("TemporalExpressionAssoc").where("fromTempExprId", tempExprId).cache(true).queryList();
         if (UtilValidate.isEmpty(valueList)) {
             throw new IllegalArgumentException("tempExprId argument invalid - no child expressions found");
@@ -155,8 +157,12 @@ public class TemporalExpressionWorker {
         return exprList;
     }
 
-    protected static TemporalExpression setExpressionId(GenericValue value, TemporalExpression expression) {
+    private static TemporalExpression setExpressionId(GenericValue value, TemporalExpression expression) {
         expression.setId(value.getString("tempExprId"));
         return expression;
     }
+
+    public static String[] getExpressionTypeList() {
+        return ExpressionTypeList;
+    }
 }