From cd6eedc2c3bc2091dfb1e7f7b4e24844fb60ebf9 Mon Sep 17 00:00:00 2001 From: Michael Brohl Date: Sat, 19 Sep 2015 14:27:54 +0000 Subject: [PATCH] Applied patch for OFBIZ-6632: Incorrect comparison in TemporalExpressionWorker.java This patch introduces some constants for the expression types and corrects the wrong comparison. Thanks Vyom Jain for spotting this issue and Martin Becker for providing the patch. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1704043 13f79535-47bb-0310-9956-ffa450edef68 --- framework/service/entitydef/entitymodel.xml | 4 ++-- .../calendar/TemporalExpressionWorker.java | 17 +++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/framework/service/entitydef/entitymodel.xml b/framework/service/entitydef/entitymodel.xml index 545c044e33..8b78ef618a 100644 --- a/framework/service/entitydef/entitymodel.xml +++ b/framework/service/entitydef/entitymodel.xml @@ -158,8 +158,8 @@ under the License. The "parent" expression The "child" expression Expression association type. - When applied to DIFFERENCE expression types, valid values are INCLUDED or EXCLUDED. - When applied to SUBSTITUTION expression types, valid values are INCLUDED, EXCLUDED, or SUBSTITUTE. + When applied to DIFFERENCE expression types, valid values are INCLUDE or EXCLUDE. + When applied to SUBSTITUTION expression types, valid values are INCLUDE, EXCLUDE, or SUBSTITUTE. diff --git a/framework/service/src/org/ofbiz/service/calendar/TemporalExpressionWorker.java b/framework/service/src/org/ofbiz/service/calendar/TemporalExpressionWorker.java index 5dac131f1f..93aeba2e04 100644 --- a/framework/service/src/org/ofbiz/service/calendar/TemporalExpressionWorker.java +++ b/framework/service/src/org/ofbiz/service/calendar/TemporalExpressionWorker.java @@ -34,7 +34,7 @@ public class TemporalExpressionWorker { public final static String module = TemporalExpressionWorker.class.getName(); - // Temporal expression constants + // 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"; @@ -50,6 +50,11 @@ public class TemporalExpressionWorker { public 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"; + /** Get a TemporalExpression from persistent storage. * @param delegator * @param tempExprId @@ -96,9 +101,9 @@ public class TemporalExpressionWorker { GenericValue inclAssoc = null; GenericValue exclAssoc = null; for (GenericValue childExpression : childExpressions) { - if ("INCLUDE".equals(childExpression.get("exprAssocType"))) { + if (INCLUDE.equals(childExpression.get("exprAssocType"))) { inclAssoc = childExpression; - } else if ("EXCLUDE".equals(childExpression.get("exprAssocType"))) { + } else if (EXCLUDE.equals(childExpression.get("exprAssocType"))) { exclAssoc = childExpression; } } @@ -121,11 +126,11 @@ public class TemporalExpressionWorker { GenericValue exclAssoc = null; GenericValue substAssoc = null; for (GenericValue childExpression : childExpressions) { - if ("INCLUDE".equals(childExpression.get("exprAssocType"))) { + if (INCLUDE.equals(childExpression.get("exprAssocType"))) { inclAssoc = childExpression; - } else if ("EXCLUDE".equals(childExpression.get("exprAssocType"))) { + } else if (EXCLUDE.equals(childExpression.get("exprAssocType"))) { exclAssoc = childExpression; - } else if ("SUBSTITUTION".equals(childExpression.get("exprAssocType"))) { + } else if (SUBSTITUTE.equals(childExpression.get("exprAssocType"))) { substAssoc = childExpression; } }