diff --git a/common/.classpath b/common/.classpath index ac1214e7bf805fa2d58fa060dadd812500601e69..df9d86de38585f0d17b5a5b65d9d8b2bdbc598c7 100644 --- a/common/.classpath +++ b/common/.classpath @@ -20,7 +20,7 @@ <classpathentry kind="lib" path="/libraries/cisd-base/cisd-base-test.jar" sourcepath="/libraries/cisd-base/cisd-base-src.zip"/> <classpathentry kind="lib" path="/libraries/cisd-base/cisd-base.jar" sourcepath="/libraries/cisd-base/cisd-base-src.zip"/> <classpathentry kind="lib" path="/libraries/fast-md5/fast-md5.jar" sourcepath="/libraries/fast-md5/src.zip"/> - <classpathentry kind="lib" path="/libraries/jython/jython.jar" sourcepath="/libraries/jython/src.zip"/> + <classpathentry kind="lib" path="/libraries/jython/jython.jar" sourcepath="/libraries/jython/jython_src.zip"/> <classpathentry kind="lib" path="/libraries/commons-httpclient/commons-httpclient.jar" sourcepath="/libraries/commons-httpclient/src.zip"/> <classpathentry kind="lib" path="/libraries/commons-logging/commons-logging.jar" sourcepath="/libraries/commons-logging/src.zip"/> <classpathentry kind="lib" path="/libraries/jaxb/jaxb-api.jar" sourcepath="/libraries/jaxb/jaxb-api-src.zip"/> diff --git a/common/source/java/ch/systemsx/cisd/common/evaluator/Evaluator.java b/common/source/java/ch/systemsx/cisd/common/evaluator/Evaluator.java index ed543e06047fde81f59b4870c28d429e8e2fa349..ea3ea599abbab6924dba61ea27ecccb4f35ed5a3 100644 --- a/common/source/java/ch/systemsx/cisd/common/evaluator/Evaluator.java +++ b/common/source/java/ch/systemsx/cisd/common/evaluator/Evaluator.java @@ -1,5 +1,3 @@ -package ch.systemsx.cisd.common.evaluator; - /* * Copyright 2009 ETH Zuerich, CISD * @@ -16,17 +14,22 @@ package ch.systemsx.cisd.common.evaluator; * limitations under the License. */ +package ch.systemsx.cisd.common.evaluator; + import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import org.apache.commons.lang.StringUtils; +import org.python.core.CompileMode; +import org.python.core.CompilerFlags; +import org.python.core.Py; +import org.python.core.PyBoolean; import org.python.core.PyCode; import org.python.core.PyException; import org.python.core.PyFloat; import org.python.core.PyFunction; import org.python.core.PyInteger; -import org.python.core.PyJavaInstance; import org.python.core.PyList; import org.python.core.PyLong; import org.python.core.PyNone; @@ -34,7 +37,6 @@ import org.python.core.PyObject; import org.python.core.PyString; import org.python.core.PyStringMap; import org.python.core.PySystemState; -import org.python.core.__builtin__; import org.python.util.PythonInterpreter; /** @@ -45,7 +47,7 @@ import org.python.util.PythonInterpreter; * <ol> * <li>Construct an {@link Evaluator} with an appropriate expression.</li> * <li>Set all variables needed for evaluation via {@link #set(String, Object)}</li> - * <li>Call one of {@link #getType()}, {@link #evalAsString()}, {@link #evalToBoolean()}, + * <li>Call one of {@link #getType()}, {@link #evalAsString}, {@link #evalToBoolean()}, * {@link #evalToInt()}, {@link #evalToBigInt()}, {@link #evalToDouble()}.</li> * <li>Repeat from step 2</li> * </ol> @@ -73,7 +75,7 @@ public final class Evaluator */ public enum ReturnType { - INTEGER_OR_BOOLEAN, BIGINT, DOUBLE, STRING, OTHER + BOOLEAN, INTEGER, BIGINT, DOUBLE, STRING, OTHER } /** @@ -173,7 +175,7 @@ public final class Evaluator if (pyObject instanceof PyFunction == false) { throw new PyException(new PyString("Not a function"), "'" + functionName - + "' is of type " + pyObject.getType().getFullName() + "."); + + "' is of type " + pyObject.getType().getName() + "."); } PyFunction func = (PyFunction) pyObject; PyObject[] pyArgs = new PyObject[args.length]; @@ -204,7 +206,7 @@ public final class Evaluator { return new PyString((String) javaObject); } - return new PyJavaInstance(javaObject); + return Py.java2py(javaObject); } /** @@ -215,8 +217,8 @@ public final class Evaluator { try { - return __builtin__.compile("__result__=(" + expression + ")", "expression: " - + expression, "exec"); + return Py.compile_flags("__result__=(" + expression + ")", "expression: " + expression, + CompileMode.exec, new CompilerFlags()); } catch (PyException ex) { throw toEvaluatorException(ex, expression); @@ -255,9 +257,12 @@ public final class Evaluator { doEval(); final Object obj = getInterpreterResult(); - if (obj instanceof PyInteger) + if (obj instanceof PyBoolean) { - return ReturnType.INTEGER_OR_BOOLEAN; + return ReturnType.BOOLEAN; + } else if (obj instanceof PyInteger) + { + return ReturnType.INTEGER; } else if (obj instanceof PyLong) { return ReturnType.BIGINT; @@ -276,16 +281,19 @@ public final class Evaluator /** * Evaluates the expression of this evaluator and returns the result. Use this method if you do * not know what will be the result type. + * <p> + * <i>This is a legacy function to mimic the old Jython 2.2 Evaluator's behavior which will only + * return Long, Double or String and doesn't know boolean.</i> * * @return evaluation result which can be of Long, Double or String type. All other types are * converted to String representation except {@link PyNone} that represents null value * and will be converted to <code>null</code>. */ - public Object eval() + public Object evalLegacy2_2() { doEval(); final PyObject obj = getInterpreterResult(); - Object result = translateToJava(obj); + Object result = translateToJavaLegacy(obj); if (result != null && result instanceof Long == false && result instanceof Double == false && result instanceof String == false) { @@ -294,7 +302,19 @@ public final class Evaluator return result; } - private Object translateToJava(final PyObject obj) + /** + * Evaluates the expression of this evaluator and returns the result. Use this method if you do + * not know what will be the result type. + * + * @return evaluation result as translated by the Jython interpreter.. + */ + public Object eval() + { + doEval(); + return translateToJava(getInterpreterResult()); + } + + private Object translateToJavaLegacy(final PyObject obj) { if (obj instanceof PyInteger) { @@ -315,18 +335,20 @@ public final class Evaluator List<Object> list = new ArrayList<Object>(); for (int i = 0, n = pyList.size(); i < n; i++) { - list.add(translateToJava(array[i])); + list.add(translateToJavaLegacy(array[i])); } return list; - } else if (obj instanceof PyJavaInstance) - { - return ((PyJavaInstance) obj).__tojava__(Object.class); } else { - return obj == null ? null : obj.toString(); + return translateToJava(obj); } } + private Object translateToJava(final PyObject obj) + { + return (obj == null) ? null : obj.__tojava__(Object.class); + } + private PyObject getInterpreterResult() { return interpreter.get("__result__"); @@ -341,12 +363,12 @@ public final class Evaluator doEval(); try { - return ((PyInteger) getInterpreterResult()).getValue() > 0; + return ((PyBoolean) getInterpreterResult()).getValue() > 0; } catch (ClassCastException ex) { final ReturnType type = getType(); - throw new EvaluatorException("Expected a result of type " - + ReturnType.INTEGER_OR_BOOLEAN + ", found " + type); + throw new EvaluatorException("Expected a result of type " + ReturnType.INTEGER + + ", found " + type); } } @@ -363,8 +385,8 @@ public final class Evaluator } catch (ClassCastException ex) { final ReturnType type = getType(); - throw new EvaluatorException("Expected a result of type " - + ReturnType.INTEGER_OR_BOOLEAN + ", found " + type); + throw new EvaluatorException("Expected a result of type " + ReturnType.INTEGER + + ", found " + type); } } @@ -404,6 +426,21 @@ public final class Evaluator } } + /** + * Evaluates the expression of this evaluator and returns the result as a String. This method + * can always be called. + * <p> + * <i>This is a legacy function to mimic the old Jython 2.2 Evaluator's behavior which first + * translates to Long and Double and doesn't know boolean.</i> + * <p> + * NOTE: null will be returned if expression results in {@link PyNone} + */ + public String evalAsStringLegacy2_2() throws EvaluatorException + { + Object result = evalLegacy2_2(); + return result == null ? null : result.toString(); + } + /** * Evaluates the expression of this evaluator and returns the result as a String. This method * can always be called. @@ -436,13 +473,10 @@ public final class Evaluator { Exception exception = null; PyObject value = ex.value; - if (value instanceof PyJavaInstance) + Object object = value.__tojava__(Object.class); + if (object instanceof Exception) { - Object object = ((PyJavaInstance) value).__tojava__(Object.class); - if (object instanceof Exception) - { - exception = (Exception) object; - } + exception = (Exception) object; } String msg = extractExceptionMessage(ex); if (expressionOrNull != null) diff --git a/common/sourceTest/java/ch/systemsx/cisd/common/evaluator/EvaluatorTest.java b/common/sourceTest/java/ch/systemsx/cisd/common/evaluator/EvaluatorTest.java index f113c15bcfc6f3f94af709931305dc35004b0513..77d6e320df1ed707c8fa36cd5a2a88266b69a9d9 100644 --- a/common/sourceTest/java/ch/systemsx/cisd/common/evaluator/EvaluatorTest.java +++ b/common/sourceTest/java/ch/systemsx/cisd/common/evaluator/EvaluatorTest.java @@ -99,12 +99,12 @@ public class EvaluatorTest extends AssertJUnit public static class Functions { - public static double Min(double a, double b) + public static double MinDbl(double a, double b) { return (a < b) ? a : b; } - public static double Min(double... vals) + public static double MinDbl(double[] vals) { double result = Double.MAX_VALUE; for (double v : vals) @@ -117,20 +117,21 @@ public class EvaluatorTest extends AssertJUnit return result; } - public static int Min(int a, int b) + public static int MinInt(int a, int b) { return (a < b) ? a : b; } + } @Test public void testFunctionEval() { - Evaluator eval = new Evaluator("Min(1,2)", Functions.class, null); + Evaluator eval = new Evaluator("MinInt(1,2)", Functions.class, null); assertEquals(1, eval.evalToInt()); - eval = new Evaluator("Min([1,2,0.1])", Functions.class, null); + eval = new Evaluator("MinDbl([1,2,0.1])", Functions.class, null); assertEquals(0.1, eval.evalToDouble(), 1e-15); - eval = new Evaluator("Min(v)", Functions.class, null); + eval = new Evaluator("MinDbl(v)", Functions.class, null); eval.set("v", new double[] { 1, 2, -99.9, 3 }); assertEquals(-99.9, eval.evalToDouble(), 1e-15); @@ -149,7 +150,7 @@ public class EvaluatorTest extends AssertJUnit { final Evaluator eval = new Evaluator("a"); eval.set("a", 2); - assertEquals(ReturnType.INTEGER_OR_BOOLEAN, eval.getType()); + assertEquals(ReturnType.INTEGER, eval.getType()); eval.set("a", "2"); assertEquals(ReturnType.STRING, eval.getType()); } @@ -178,15 +179,16 @@ public class EvaluatorTest extends AssertJUnit { final Evaluator eval = new Evaluator("a"); eval.set("a", true); - assertEquals(ReturnType.INTEGER_OR_BOOLEAN, eval.getType()); - assertEquals("1", eval.evalAsString()); + assertEquals(ReturnType.BOOLEAN, eval.getType()); + assertEquals("true", eval.evalAsString()); try { eval.evalToDouble(); + fail("Type mismatch not detected."); } catch (EvaluatorException ex) { assertEquals(ex.getMessage(), - "Expected a result of type DOUBLE, found INTEGER_OR_BOOLEAN", ex.getMessage()); + "Expected a result of type DOUBLE, found BOOLEAN", ex.getMessage()); } } @@ -245,7 +247,7 @@ public class EvaluatorTest extends AssertJUnit Evaluator evaluator = new Evaluator("", null, "def get():\n return ['a','b']"); Object result = evaluator.evalFunction("get"); assertEquals("Result " + result.getClass(), true, result instanceof List); - assertEquals("[a, b]", result.toString()); + assertEquals("['a', 'b']", result.toString()); } @Test @@ -258,7 +260,9 @@ public class EvaluatorTest extends AssertJUnit fail("EvaluatorException expected"); } catch (EvaluatorException ex) { - assertEquals("Error evaluating 'hello(world)': NameError: unknown", ex.getMessage()); + assertEquals( + "Error evaluating 'hello(world)': NameError: global name 'unknown' is not defined", + ex.getMessage()); } } @@ -316,7 +320,7 @@ public class EvaluatorTest extends AssertJUnit } catch (EvaluatorException ex) { assertEquals("Error evaluating 'hello()': TypeError: " - + "hello() takes at least 1 argument (0 given)", ex.getMessage()); + + "hello() takes exactly 1 argument (0 given)", ex.getMessage()); } } @@ -331,7 +335,7 @@ public class EvaluatorTest extends AssertJUnit } catch (EvaluatorException ex) { assertEquals("Error evaluating 'hello(world, universe)': TypeError: " - + "hello() too many arguments; expected 1 got 2", ex.getMessage()); + + "hello() takes exactly 1 argument (2 given)", ex.getMessage()); } } @@ -347,7 +351,7 @@ public class EvaluatorTest extends AssertJUnit } catch (EvaluatorException ex) { assertEquals("Error evaluating 'get(world, universe)': AttributeError: " - + "'string' object has no attribute 'get'", ex.getMessage()); + + "'str' object has no attribute 'get'", ex.getMessage()); } } diff --git a/datastore_server/.classpath b/datastore_server/.classpath index 6f8cb8ff0360c2606619b4b46636be9038132412..14e4742a6c6e51e3e90e16f02d75b91558a268f7 100644 --- a/datastore_server/.classpath +++ b/datastore_server/.classpath @@ -4,7 +4,6 @@ <classpathentry kind="src" path="resource"/> <classpathentry kind="src" path="sourceTest/java"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="lib" path="/libraries/jython/standalone/jython.jar" sourcepath="/Users/gpawel/Downloads/jython_installer-2.2.1.jar"/> <classpathentry combineaccessrules="false" exported="true" kind="src" path="/common"/> <classpathentry kind="lib" path="/libraries/log4j/log4j.jar" sourcepath="/libraries/log4j/src.zip"/> <classpathentry kind="lib" path="/libraries/commons-lang/commons-lang.jar" sourcepath="/libraries/commons-lang/src.zip"/> @@ -71,5 +70,6 @@ <classpathentry kind="lib" path="/libraries/poi/ooxml-lib/xmlbeans-2.3.0.jar"/> <classpathentry kind="lib" path="/libraries/ftpserver/ftpserver-core.jar"/> <classpathentry kind="lib" path="/libraries/mina/mina-core.jar"/> + <classpathentry kind="lib" path="/libraries/jython/jython.jar" sourcepath="/libraries/jython/jython_src.zip"/> <classpathentry kind="output" path="targets/classes"/> </classpath> diff --git a/datastore_server/build/build.xml b/datastore_server/build/build.xml index 784f88a139653c6bb00763bdbadaeb8775f4656d..99b94a69f8047c5a472d8230780021947f03d329 100644 --- a/datastore_server/build/build.xml +++ b/datastore_server/build/build.xml @@ -150,9 +150,6 @@ <copy file="${lib}/jython/jython.jar" todir="${dist.datastore_server.lib}" /> <copy file="${lib}/mina/mina-core.jar" todir="${dist.datastore_server.lib}" /> <copy file="${lib}/ftpserver/ftpserver-core.jar" todir="${dist.datastore_server.lib}" /> - <copy todir="${dist.datastore_server.lib}/jython-lib" > - <fileset dir="${lib}/jython/jython-lib" /> - </copy> <copy file="${lib}/truezip/truezip.jar" todir="${dist.datastore_server.lib}" /> <copy todir="${dist.datastore_server.lib}/${dss_upload_gui}" > <fileset dir="${dist.dss_upload_gui.lib}" /> @@ -283,7 +280,7 @@ <copy file="${lib}/commons-httpclient/commons-httpclient.jar" todir="${dist.dss_client.lib}" /> <copy file="${lib}/spring/spring.jar" todir="${dist.dss_client.lib}" /> <copy file="${lib}/jline/jline.jar" todir="${dist.dss_client.lib}" /> - <copy file="${lib}/jython/standalone/jython.jar" todir="${dist.dss_client.lib}" /> + <copy file="${lib}/jython/jython.jar" todir="${dist.dss_client.lib}" /> <copy file="${lib}/poi/poi-3.7-20101029.jar" todir="${dist.dss_client.lib}" /> <copy file="${lib}/poi/poi-ooxml-3.7-20101029.jar" todir="${dist.dss_client.lib}" /> <copy file="${lib}/poi/poi-ooxml-schemas-3.7-20101029.jar" todir="${dist.dss_client.lib}" /> @@ -400,7 +397,7 @@ <param name="jar" value="stream-supporting-httpinvoker.jar" /> </antcall> <antcall target="copy-and-sign-jar"> - <param name="dir" value="${lib}/jython/standalone" /> + <param name="dir" value="${lib}/jython" /> <param name="jar" value="jython.jar" /> </antcall> <antcall target="copy-and-sign-jar"> diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/DataSetRegistrationService.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/DataSetRegistrationService.java index ed13b1384a4e3f1dee116dab12f57b5766517632..a937efa69b1169d1b40da26a432981f10b7a315e 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/DataSetRegistrationService.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/DataSetRegistrationService.java @@ -298,7 +298,7 @@ public class DataSetRegistrationService<T extends DataSetInformation> implements return encounteredErrors; } - protected IDataSetRegistrationDetailsFactory<T> getDataSetRegistrationDetailsFactory() + public IDataSetRegistrationDetailsFactory<T> getDataSetRegistrationDetailsFactory() { return dataSetRegistrationDetailsFactory; } diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetHandler.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetHandler.java index e0fa3ee68af987ee35f235f25c32f8fc8254ff38..9ef358fcf7e55ed2a26257b03f0e5a4f6116097b 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetHandler.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetHandler.java @@ -101,7 +101,7 @@ public class JythonTopLevelDataSetHandler<T extends DataSetInformation> extends } @Override - protected void handleDataSet(File dataSetFile, DataSetRegistrationService<T> genericService) + public void handleDataSet(File dataSetFile, DataSetRegistrationService<T> genericService) throws Throwable { // Load the script @@ -221,7 +221,7 @@ public class JythonTopLevelDataSetHandler<T extends DataSetInformation> extends { try { - PyFunction function = (PyFunction) interpreter.get(functionName, PyFunction.class); + PyFunction function = interpreter.get(functionName, PyFunction.class); return function; } catch (Exception e) { @@ -317,7 +317,7 @@ public class JythonTopLevelDataSetHandler<T extends DataSetInformation> extends } } - protected static class JythonDataSetRegistrationService<T extends DataSetInformation> extends + public static class JythonDataSetRegistrationService<T extends DataSetInformation> extends DataSetRegistrationService<T> { private final PythonInterpreter interpreter; diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/validation/ValidationScriptRunner.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/validation/ValidationScriptRunner.java index 9e450cd5fd77b6644b074620a73b840c206507bb..80503292525d76fcd2480fe45f249a6925df3fd2 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/validation/ValidationScriptRunner.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/validation/ValidationScriptRunner.java @@ -146,7 +146,7 @@ public class ValidationScriptRunner { try { - PyFunction function = (PyFunction) interpreter.get(functionName, PyFunction.class); + PyFunction function = interpreter.get(functionName, PyFunction.class); return function; } catch (Exception e) { diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetRegistratorTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetRegistratorTest.java index a91d9ae12786a9777452ea748d336a3038baec69..13a64e918e23a09acdb0e2fda87e12d4c275f972 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetRegistratorTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetRegistratorTest.java @@ -1150,7 +1150,7 @@ public class JythonTopLevelDataSetRegistratorTest extends AbstractFileSystemTest ((JythonDataSetRegistrationService<DataSetInformation>) service) .getInterpreter(); didRollbackServiceFunctionRun = - (Boolean) interpreter.get("didRollbackServiceFunctionRun", Boolean.class); + interpreter.get("didRollbackServiceFunctionRun", Boolean.class); } @Override @@ -1165,7 +1165,7 @@ public class JythonTopLevelDataSetRegistratorTest extends AbstractFileSystemTest ((JythonDataSetRegistrationService<DataSetInformation>) service) .getInterpreter(); didRollbackDataSetRegistrationFunctionRun = - (Boolean) interpreter.get("didRollbackServiceFunctionRun", Boolean.class); + interpreter.get("didRollbackServiceFunctionRun", Boolean.class); } @Override @@ -1182,7 +1182,7 @@ public class JythonTopLevelDataSetRegistratorTest extends AbstractFileSystemTest ((JythonDataSetRegistrationService<DataSetInformation>) service) .getInterpreter(); didRollbackTransactionFunctionRunHappen = - (Boolean) interpreter.get("didTransactionRollbackHappen", Boolean.class); + interpreter.get("didTransactionRollbackHappen", Boolean.class); } @Override @@ -1196,7 +1196,7 @@ public class JythonTopLevelDataSetRegistratorTest extends AbstractFileSystemTest ((JythonDataSetRegistrationService<DataSetInformation>) service) .getInterpreter(); didCommitTransactionFunctionRunHappen = - (Boolean) interpreter.get("didTransactionCommitHappen", Boolean.class); + interpreter.get("didTransactionCommitHappen", Boolean.class); } @Override diff --git a/openbis/build/build.xml b/openbis/build/build.xml index a4e192fcf6edadc523671a963fc4c8dd17165a55..b739cdb300f7bc355baf59c0d913c0c4e8d72b96 100644 --- a/openbis/build/build.xml +++ b/openbis/build/build.xml @@ -723,10 +723,6 @@ <lib dir="${lib}/jython"> <include name="jython.jar" /> </lib> - <!-- modules for jython scripting --> - <webinf dir="${lib}/jython/"> - <include name="jython-lib/**/*.*" /> - </webinf> </war> <!-- Does some cleaning. --> <delete file="${jar.file}" failonerror="true" /> diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/ColumnDefinition.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/ColumnDefinition.java index 370119023c8f531c171158a73bbf9bf72a810b78..67d79c522f8819a21f7a6063fd5eb39ffbae5629 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/ColumnDefinition.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/ColumnDefinition.java @@ -25,7 +25,7 @@ package ch.systemsx.cisd.openbis.generic.client.web.server.calculator; * * @author Franz-Josef Elmer */ -class ColumnDefinition +public class ColumnDefinition { private final String columnID; private final ITableDataProvider provider; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/ColumnGroup.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/ColumnGroup.java index 01f6832676e8c2d70674f16dfa0a5b513a9ddc05..ace1228476225c2b767c59c3de6606c6a07eee10 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/ColumnGroup.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/ColumnGroup.java @@ -26,7 +26,7 @@ import java.util.List; * * @author Franz-Josef Elmer */ -class ColumnGroup +public class ColumnGroup { private final String propertyValue; private final List<Object> values; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/Row.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/Row.java index 3e8dff34ce15a6e2497f4d2cddcda72346039c28..c79c2c637b783c992e763832409eea3fd8c47db5 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/Row.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/Row.java @@ -35,7 +35,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ISerializableComparable * * @author Franz-Josef Elmer */ -final class Row +public final class Row { private final Map<String, List<ColumnDefinition>> definitionsByProperties = new HashMap<String, List<ColumnDefinition>>(); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/RowCalculator.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/RowCalculator.java index f3d7af2e31457c8e9430ba5bdecff4af8ce2c38f..175a5f753d44a29a1336a56eaf5cf48cfd13748f 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/RowCalculator.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/RowCalculator.java @@ -28,7 +28,7 @@ import ch.systemsx.cisd.openbis.generic.shared.calculator.AbstractCalculator; /** * @author Franz-Josef Elmer */ -class RowCalculator extends AbstractCalculator +public class RowCalculator extends AbstractCalculator { private final Row row; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/calculator/DynamicPropertyAdaptor.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/calculator/DynamicPropertyAdaptor.java index 4a4d0749ab28918865e47aeafd60b22beb369a6f..314a0e77f96750d8af015de8cf8c5768d6d370bc 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/calculator/DynamicPropertyAdaptor.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/calculator/DynamicPropertyAdaptor.java @@ -29,7 +29,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.EntityTypePropertyTypePE; * * @author Piotr Buczek */ -class DynamicPropertyAdaptor implements IEntityPropertyAdaptor +public class DynamicPropertyAdaptor implements IEntityPropertyAdaptor { /** state of lazy evaluation of the property value (analogy to graph search) */ private enum State diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/calculator/DynamicPropertyFunctions.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/calculator/DynamicPropertyFunctions.java index 8eb7e7eee3393abdb96ebf92a005f776ace89374..dd3f2cf97db3be255347ad717ebab862a20f1ad6 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/calculator/DynamicPropertyFunctions.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/calculator/DynamicPropertyFunctions.java @@ -25,7 +25,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MaterialIdentifier; * * @author Piotr Buczek */ -final class DynamicPropertyFunctions +public final class DynamicPropertyFunctions { /** * @return String representation of material identifier for given material code and material diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/calculator/XmlPropertyAdaptor.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/calculator/XmlPropertyAdaptor.java index 88e7ef2d7f34cf085a3c3ef2bbff421ccea8b604..5aebf854808eb3449afb9801cd39a2be32ef8ae2 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/calculator/XmlPropertyAdaptor.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/calculator/XmlPropertyAdaptor.java @@ -26,7 +26,7 @@ import ch.systemsx.cisd.openbis.generic.shared.util.XmlUtils; * * @author Piotr Buczek */ -class XmlPropertyAdaptor extends BasicPropertyAdaptor +public class XmlPropertyAdaptor extends BasicPropertyAdaptor { private final String xsltTransformation; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/calculator/AbstractCalculator.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/calculator/AbstractCalculator.java index 8fb658111e4517d706efbfb3d1e19d51c44039c5..61687562acb6def5495284b59b5ca1f13d5e44f8 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/calculator/AbstractCalculator.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/calculator/AbstractCalculator.java @@ -49,7 +49,7 @@ public class AbstractCalculator public PrimitiveValue getTypedResult() { - Object value = evaluator.eval(); + Object value = evaluator.evalLegacy2_2(); if (value == null) { return PrimitiveValue.NULL; @@ -88,12 +88,12 @@ public class AbstractCalculator public String evalAsString() throws EvaluatorException { - return evaluator.evalAsString(); + return evaluator.evalAsStringLegacy2_2(); } public Object eval() throws EvaluatorException { - return evaluator.eval(); + return evaluator.evalLegacy2_2(); } } \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/calculator/StandardFunctions.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/calculator/StandardFunctions.java index c4610eae9e4924bf5ab48ad081672b118d2655f7..72976e74a34ea690ce48a5b64abd520b8ad374a8 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/calculator/StandardFunctions.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/calculator/StandardFunctions.java @@ -41,7 +41,7 @@ import ch.systemsx.cisd.common.utilities.ExceptionUtils; * * @author Franz-Josef Elmer */ -final class StandardFunctions +public final class StandardFunctions { static final Double DOUBLE_DEFAULT_VALUE = new Double(-Double.MAX_VALUE); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/CachedResultSetManagerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/CachedResultSetManagerTest.java index c68706ffaf6c01f5c98508fb8879c3b8893d033a..74bbb35a033f08e2ae50397c4291f8e89fc2c9e7 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/CachedResultSetManagerTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/CachedResultSetManagerTest.java @@ -115,7 +115,6 @@ public final class CachedResultSetManagerTest extends AssertJUnit { resultSetConfig.setAvailableColumns(new LinkedHashSet<IColumnDefinition<DataHolder>>( cols.values())); - System.out.println(resultSetConfig.getAvailableColumns().size()); if (columnFilters.isEmpty() == false) { resultSetConfig.setFilters(GridFilters.createColumnFilter(columnFilters)); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/CustomColumnUtilsTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/CustomColumnUtilsTest.java index 73bbc123f90938d8b4435a1b138bba686080dad4..a4ed41e054f3d1fa6eaf7b27819bda675f745c40 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/CustomColumnUtilsTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/CustomColumnUtilsTest.java @@ -39,6 +39,7 @@ public class CustomColumnUtilsTest extends AssertJUnit private static final class MockDataProvider implements ITableDataProvider { private final String expectedColumnID; + private final List<List<? extends Comparable<?>>> rows; MockDataProvider(String expectedColumnID, List<? extends Comparable<?>>... rows) @@ -74,7 +75,7 @@ public class CustomColumnUtilsTest extends AssertJUnit return null; } } - + GridCustomColumn customColumn; List<GridCustomColumn> customColumns; @@ -105,9 +106,10 @@ public class CustomColumnUtilsTest extends AssertJUnit public void testCorrectExpression() { customColumn.setExpression("row.col('VALUE') + 10"); - - List<PrimitiveValue> values = GridExpressionUtils.evalCustomColumn(dataProvider, customColumn, false); - + + List<PrimitiveValue> values = + GridExpressionUtils.evalCustomColumn(dataProvider, customColumn, false); + assertEquals("[52]", values.toString()); } @@ -120,9 +122,12 @@ public class CustomColumnUtilsTest extends AssertJUnit // incorrect expression customColumn.setExpression("junk + 10"); - List<PrimitiveValue> values = GridExpressionUtils.evalCustomColumn(dataProvider, customColumn, false); - - assertEquals("[Error. Please contact 'Jane Doe <jane.doe@nowhere.com>', who defined this column.]", values.toString()); + List<PrimitiveValue> values = + GridExpressionUtils.evalCustomColumn(dataProvider, customColumn, false); + + assertEquals( + "[Error. Please contact 'Jane Doe <jane.doe@nowhere.com>', who defined this column.]", + values.toString()); } @Test @@ -131,10 +136,12 @@ public class CustomColumnUtilsTest extends AssertJUnit // incorrect expression customColumn.setExpression("junk + 10"); - List<PrimitiveValue> values = GridExpressionUtils.evalCustomColumn(dataProvider, customColumn, true); + List<PrimitiveValue> values = + GridExpressionUtils.evalCustomColumn(dataProvider, customColumn, true); - assertEquals("[Error: (Error evaluating 'junk + 10': NameError: junk).]", values.toString()); + assertEquals( + "[Error: (Error evaluating 'junk + 10': NameError: name 'junk' is not defined).]", + values.toString()); } - } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ScriptBOTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ScriptBOTest.java index 0956a1503a18e59f7660cd6e24900181004b2f9b..60933aeb880d5af85bbe61499913b179e759b920 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ScriptBOTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ScriptBOTest.java @@ -53,10 +53,13 @@ public final class ScriptBOTest extends AbstractBOTest { { ScriptType.DYNAMIC_PROPERTY, - "Error evaluating '1+': SyntaxError: ('invalid syntax', " - + "('expression: 1+', 1, 15, '__result__=(1+)'))" }, - { ScriptType.MANAGED_PROPERTY, - "SyntaxError: ('invalid syntax', ('<string>', 1, 3, '1+'))" } + "Error evaluating '1+': SyntaxError: " + + "(\"no viable alternative at input ')'\", " + + "('expression: 1+', 1, 14, '__result__=(1+)\\n'))" }, + { + ScriptType.MANAGED_PROPERTY, + "SyntaxError: (\"no viable alternative at input '\\\\n\\\\n'\", " + + "('<string>', 1, 2, '1+\\n'))" } }; } @@ -126,7 +129,8 @@ public final class ScriptBOTest extends AbstractBOTest } @Test(dataProvider = "scriptTypes") - public final void testDefineAndSaveScriptCompilationFail(ScriptType scriptType, String expectedErrorMessage) + public final void testDefineAndSaveScriptCompilationFail(ScriptType scriptType, + String expectedErrorMessage) { final ScriptBO scriptBO = createScriptBO(); final DatabaseInstancePE instance = createDatabaseInstance(); @@ -239,7 +243,8 @@ public final class ScriptBOTest extends AbstractBOTest } @Test(dataProvider = "scriptTypes") - public void testUpdateScriptNotChanged(ScriptType scriptType, String expectedErrorMessage) throws Exception + public void testUpdateScriptNotChanged(ScriptType scriptType, String expectedErrorMessage) + throws Exception { final ScriptBO scriptBO = createScriptBO(); @@ -282,7 +287,8 @@ public final class ScriptBOTest extends AbstractBOTest @SuppressWarnings("deprecation") @Test(dataProvider = "scriptTypes") - public void testUpdateScriptChanged(final ScriptType scriptType, String expectedErrorMessage) throws Exception + public void testUpdateScriptChanged(final ScriptType scriptType, String expectedErrorMessage) + throws Exception { final ScriptBO scriptBO = createScriptBO(); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/DynamicPropertyEvaluatorTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/DynamicPropertyEvaluatorTest.java index c29152784b2db599b1391cfb0e2a7cb275516b0e..036b58e6e7fad80df8950360298839c24a1a4ece 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/DynamicPropertyEvaluatorTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/DynamicPropertyEvaluatorTest.java @@ -150,7 +150,9 @@ public class DynamicPropertyEvaluatorTest extends AbstractBOTest assertEquals(expectedDp1ErrorValue, dp1Error.getValue()); assertEquals(properties.size() + "", dp2.getValue()); final String expectedDp3ErrorValue = - expectedErrorMessage("Error evaluating '" + s3 + "': AttributeError: getCode"); + expectedErrorMessage("Error evaluating '" + s3 + + "': AttributeError: 'ch.systemsx.cisd.openbis.generic.server.business.b'" + + " object has no attribute 'getCode'"); assertEquals(expectedDp3ErrorValue, dp3Error.getValue()); } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/calculator/DynamicPropertyCalculatorTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/calculator/DynamicPropertyCalculatorTest.java index cc90c988b647999ab11cb283f4e8c2703181b9c0..70d3a8d18c22bdb9ff13d044c71f036195ad82c0 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/calculator/DynamicPropertyCalculatorTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/calculator/DynamicPropertyCalculatorTest.java @@ -127,7 +127,7 @@ public class DynamicPropertyCalculatorTest extends AssertJUnit fail("expected EvaluatorException"); } catch (EvaluatorException e) { - final String expectedMsg = "Error evaluating 'calculate()': NameError: calculate"; + final String expectedMsg = "Error evaluating 'calculate()': NameError: name 'calculate' is not defined"; assertEquals("expected exception message: " + expectedMsg, expectedMsg, e.getMessage()); } } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/ManagedPropertyEvaluatorTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/ManagedPropertyEvaluatorTest.java index 900619eccab116730b8b77cbc8fc8a7a2842a593..cbdde2e1240d7c9fa0791f212897812870de98b9 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/ManagedPropertyEvaluatorTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/ManagedPropertyEvaluatorTest.java @@ -71,8 +71,8 @@ public class ManagedPropertyEvaluatorTest extends AssertJUnit fail("EvaluatorException expected"); } catch (EvaluatorException ex) { - assertEquals("SyntaxError: ('invalid syntax', ('<string>', 1, 4, 'a ='))", - ex.getMessage()); + assertEquals("SyntaxError: (\"no viable alternative at input '='\", " + + "('<string>', 1, 2, 'a =\\n'))", ex.getMessage()); } } @@ -306,7 +306,7 @@ public class ManagedPropertyEvaluatorTest extends AssertJUnit } catch (EvaluatorException ex) { assertEquals("Function 'batchColumnNames' doesn't return a List " - + "but an object of type 'java.lang.Long': 42", ex.getMessage()); + + "but an object of type 'java.lang.Integer': 42", ex.getMessage()); } } diff --git a/sanofi/.classpath b/sanofi/.classpath index dc1aac1a05c9f18d34503f26441c2ecaa11697f0..b33c8c47a8d577a2558a2e91e97b70f7a5ec7e70 100644 --- a/sanofi/.classpath +++ b/sanofi/.classpath @@ -21,9 +21,9 @@ <classpathentry kind="lib" path="/libraries/spring/spring.jar" sourcepath="/libraries/spring/src.jar"/> <classpathentry kind="lib" path="/libraries/cisd-args4j/cisd-args4j.jar" sourcepath="/libraries/cisd-args4j/cisd-args4j-src.zip"/> <classpathentry kind="lib" path="/libraries/poi/poi-3.7-20101029.jar"/> - <classpathentry kind="lib" path="/libraries/jython/standalone/jython.jar" sourcepath="/Users/gpawel/Downloads/jython_installer-2.2.1.jar"/> <classpathentry combineaccessrules="false" kind="src" path="/datastore_server"/> <classpathentry combineaccessrules="false" kind="src" path="/openbis"/> <classpathentry kind="lib" path="/libraries/eodsql/eodsql.jar" sourcepath="/libraries/eodsql/eodsql_src.zip"/> + <classpathentry kind="lib" path="/libraries/jython/jython.jar" sourcepath="/libraries/jython/jython_src.zip"/> <classpathentry kind="output" path="targets/classes"/> </classpath> diff --git a/screening/build/build.xml b/screening/build/build.xml index 7826973eb4cee48a336e84fd0db38dcb170196ae..5a04c171121a9427b2431ced2bdb441410e53a11 100644 --- a/screening/build/build.xml +++ b/screening/build/build.xml @@ -353,7 +353,7 @@ <param name="jar" value="ij.jar" /> </antcall> <antcall target="copy-and-sign-jar"> - <param name="dir" value="${lib}/jython/standalone" /> + <param name="dir" value="${lib}/jython" /> <param name="jar" value="jython.jar" /> </antcall> <zip destfile="${jars.to.be.signed.zip}" @@ -501,7 +501,7 @@ <zipfileset src="${lib}/jline/jline.jar" /> <zipfileset src="${lib}/cisd-args4j/cisd-args4j.jar" /> <zipfileset src="${lib}/cisd-base/cisd-base.jar" /> - <zipfileset src="${lib}/jython/standalone/jython.jar" /> + <zipfileset src="${lib}/jython/jython.jar" /> </recursive-jar> <recursive-jar destfile="${dist.screening-api-batteries-included.jar}"> <zipfileset src="${dist.screening-api.lib}/spring-ext.jar" /> @@ -570,7 +570,7 @@ <zipfileset src="${lib}/jline/jline.jar" /> <zipfileset src="${lib}/cisd-args4j/cisd-args4j.jar" /> <zipfileset src="${lib}/cisd-base/cisd-base.jar" /> - <zipfileset src="${lib}/jython/standalone/jython.jar" /> + <zipfileset src="${lib}/jython/jython.jar" /> </recursive-jar> <recursive-jar destfile="${dist.screening-api-batteries-included.jar}"> <zipfileset src="${dist.screening-api.lib}/spring-ext.jar" />