=== removed file 'expr.patch' --- expr.patch 2015-04-29 11:33:31 +0000 +++ expr.patch 1970-01-01 00:00:00 +0000 @@ -1,196 +0,0 @@ -=== modified file 'dhis-2/dhis-support/dhis-support-system/pom.xml' ---- dhis-2/dhis-support/dhis-support-system/pom.xml 2015-04-15 14:58:13 +0000 -+++ dhis-2/dhis-support/dhis-support-system/pom.xml 2015-04-29 11:11:42 +0000 -@@ -171,6 +171,10 @@ - com.google.guava - guava - -+ -+ org.apache.commons -+ commons-jexl -+ - - - ../../ - -=== added file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ExpressionUtils.java' ---- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ExpressionUtils.java 1970-01-01 00:00:00 +0000 -+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ExpressionUtils.java 2015-04-29 11:02:25 +0000 -@@ -0,0 +1,66 @@ -+package org.hisp.dhis.system.util; -+ -+/* -+ * Copyright (c) 2004-2015, University of Oslo -+ * All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions are met: -+ * Redistributions of source code must retain the above copyright notice, this -+ * list of conditions and the following disclaimer. -+ * -+ * Redistributions in binary form must reproduce the above copyright notice, -+ * this list of conditions and the following disclaimer in the documentation -+ * and/or other materials provided with the distribution. -+ * Neither the name of the HISP project nor the names of its contributors may -+ * be used to endorse or promote products derived from this software without -+ * specific prior written permission. -+ * -+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ */ -+ -+import java.util.Map; -+ -+import org.apache.commons.jexl2.Expression; -+import org.apache.commons.jexl2.JexlContext; -+import org.apache.commons.jexl2.JexlEngine; -+import org.apache.commons.jexl2.MapContext; -+ -+/** -+ * @author Lars Helge Overland -+ */ -+public class ExpressionUtils -+{ -+ private static final JexlEngine JEXL = new JexlEngine(); -+ -+ static -+ { -+ JEXL.setCache( 512 ); -+ JEXL.setSilent( false ); -+ } -+ -+ public static Object evaluate( String expression, Map vars ) -+ { -+ Expression exp = JEXL.createExpression( expression ); -+ -+ JexlContext context = vars != null ? new MapContext( vars ) : new MapContext( vars ); -+ -+ return exp.evaluate( context ); -+ } -+ -+ public static boolean isTrue( String expression, Map vars ) -+ { -+ Boolean result = (Boolean) evaluate( expression, vars ); -+ -+ return result != null ? result : false; -+ } -+} - -=== added file 'dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ExpressionUtilsTest.java' ---- dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ExpressionUtilsTest.java 1970-01-01 00:00:00 +0000 -+++ dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ExpressionUtilsTest.java 2015-04-29 11:11:12 +0000 -@@ -0,0 +1,81 @@ -+package org.hisp.dhis.system.util; -+ -+/* -+ * Copyright (c) 2004-2015, University of Oslo -+ * All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions are met: -+ * Redistributions of source code must retain the above copyright notice, this -+ * list of conditions and the following disclaimer. -+ * -+ * Redistributions in binary form must reproduce the above copyright notice, -+ * this list of conditions and the following disclaimer in the documentation -+ * and/or other materials provided with the distribution. -+ * Neither the name of the HISP project nor the names of its contributors may -+ * be used to endorse or promote products derived from this software without -+ * specific prior written permission. -+ * -+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ */ -+ -+import static org.junit.Assert.assertFalse; -+import static org.junit.Assert.assertTrue; -+ -+import java.util.HashMap; -+import java.util.Map; -+ -+import org.junit.Test; -+ -+/** -+ * @author Lars Helge Overland -+ */ -+public class ExpressionUtilsTest -+{ -+ @Test -+ public void testIsTrue() -+ { -+ assertTrue( ExpressionUtils.isTrue( "2 > 1", null ) ); -+ assertTrue( ExpressionUtils.isTrue( "(2 * 3) == 6", null ) ); -+ assertTrue( ExpressionUtils.isTrue( "\"a\" == \"a\"", null ) ); -+ assertTrue( ExpressionUtils.isTrue( "'b' == 'b'", null ) ); -+ assertTrue( ExpressionUtils.isTrue( "('b' == 'b') && ('c' == 'c')", null ) ); -+ assertTrue( ExpressionUtils.isTrue( "'goat' == 'goat'", null ) ); -+ -+ assertFalse( ExpressionUtils.isTrue( "2 < 1", null ) ); -+ assertFalse( ExpressionUtils.isTrue( "(2 * 3) == 8", null ) ); -+ assertFalse( ExpressionUtils.isTrue( "\"a\" == \"b\"", null ) ); -+ assertFalse( ExpressionUtils.isTrue( "'b' == 'c'", null ) ); -+ assertFalse( ExpressionUtils.isTrue( "'goat' == 'cow'", null ) ); -+ } -+ -+ @Test -+ public void testIsTrueWithVars() -+ { -+ Map vars = new HashMap(); -+ -+ vars.put( "v1", "4" ); -+ vars.put( "v2", "12" ); -+ vars.put( "v3", "goat" ); -+ vars.put( "v4", "horse" ); -+ -+ assertTrue( ExpressionUtils.isTrue( "v1 > 1", vars ) ); -+ assertTrue( ExpressionUtils.isTrue( "v2 < 18", vars ) ); -+ assertTrue( ExpressionUtils.isTrue( "v3 == 'goat'", vars ) ); -+ assertTrue( ExpressionUtils.isTrue( "v4 == 'horse'", vars ) ); -+ -+ assertFalse( ExpressionUtils.isTrue( "v1 < 1", vars ) ); -+ assertFalse( ExpressionUtils.isTrue( "v2 > 18", vars ) ); -+ assertFalse( ExpressionUtils.isTrue( "v3 == 'cow'", vars ) ); -+ assertFalse( ExpressionUtils.isTrue( "v4 == 'goat'", vars ) ); -+ } -+} - -=== modified file 'dhis-2/pom.xml' ---- dhis-2/pom.xml 2015-03-31 08:46:53 +0000 -+++ dhis-2/pom.xml 2015-04-29 11:12:30 +0000 -@@ -584,6 +584,11 @@ - 2.4.2 - - -+ org.apache.commons -+ commons-jexl -+ 2.1.1 -+ -+ - junit - junit - 4.12 -@@ -781,6 +786,7 @@ - postgresql - 9.3-1102-jdbc41 - -+ - - - net.sf.jasperreports -