diff --git a/README.md b/README.md index b0d2c2865279cc50b209e5da5fe424e0f9c60744..355f410b4b23947bd22ba9fe197e726eb794072e 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@  # VIPSCommon -This is a jar file that contains the entities and util classes that are used throughout the VIPS system +This is a jar file that contains the entities and util classes that are used throughout the VIPS system. ## Requirements -* Java >= 14 +* Java >= 17 +* **TODO** What else? ## Development +**TODO TODO** diff --git a/pom.xml b/pom.xml index cf4bd351a3c785c194af35807561accd3511b80f..acff07d9dc5a0acaee0a62fe9cfe6a2c561e5f03 100755 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ </parent> <artifactId>VIPSCommon</artifactId> - <version>2.0.2</version> + <version>2.0.3-SNAPSHOT</version> <packaging>jar</packaging> <name>VIPSCommon</name> @@ -19,61 +19,54 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>3.8.1</version> + <version>4.13.2</version> <scope>test</scope> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> - <version>2.13.1</version> + <version>2.16.1</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-jsr310</artifactId> - <version>2.13.1</version> + <version>2.16.1</version> <type>jar</type> </dependency> <dependency> <groupId>commons-validator</groupId> <artifactId>commons-validator</artifactId> - <version>1.7</version> + <version>1.8.0</version> <type>jar</type> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> - <version>2.13.1</version> + <version>2.16.1</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> - <version>2.13.1</version> + <version>2.16.1</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> - <version>4.5.13</version> + <version>4.5.14</version> <type>jar</type> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> - <version>4.4.15</version> - <type>jar</type> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.python</groupId> - <artifactId>jython-standalone</artifactId> - <version>2.7.2</version> + <version>4.4.16</version> <type>jar</type> <scope>provided</scope> </dependency> <dependency> <groupId>org.locationtech.jts</groupId> <artifactId>jts-core</artifactId> - <version>1.18.2</version> + <version>1.19.0</version> <type>jar</type> </dependency> <dependency> @@ -91,27 +84,32 @@ <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> - <version>2.11.0</version> + <version>2.15.1</version> </dependency> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> - <version>1.15</version> + <version>1.16.0</version> </dependency> <dependency> <groupId>com.ibm.icu</groupId> <artifactId>icu4j</artifactId> - <version>70.1</version> + <version>74.2</version> </dependency> <dependency> <groupId>org.geotools</groupId> <artifactId>gt-api</artifactId> - <version>20.5</version> + <version>30.1</version> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt-main</artifactId> + <version>30.1</version> </dependency> <dependency> <groupId>org.geotools</groupId> <artifactId>gt-epsg-hsql</artifactId> - <version>20.5</version> + <version>30.1</version> </dependency> <dependency> <groupId>com.kjetland</groupId> @@ -127,13 +125,13 @@ <!--groupId>com.github.bjornharrtell</groupId--> <groupId>org.wololo</groupId> <artifactId>jts2geojson</artifactId> - <version>0.16.1</version> + <version>0.18.1</version> </dependency> <!-- https://mvnrepository.com/artifact/org.jscience/jscience --> <dependency> <groupId>javax.measure</groupId> <artifactId>unit-api</artifactId> - <version>2.1.3</version> + <version>2.2</version> </dependency> <dependency> <groupId>tec.units</groupId> @@ -184,7 +182,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> - <version>3.3.1</version> + <version>3.6.3</version> <configuration> <tags> <tag> @@ -199,20 +197,20 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>3.0.0-M5</version> + <version>3.2.3</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>3.8.1</version> + <version>3.12.1</version> <configuration> - <source>1.8</source> - <target>1.8</target> + <source>17</source> + <target>17</target> </configuration> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> - <version>3.3.0</version> + <version>3.6.0</version> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000000000000000000000000000000000000..7b1272e1ef0afce5b3b143a628c6f8cb36ca9fe8 --- /dev/null +++ b/renovate.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "baseBranches": ["renovate-updates"] +} diff --git a/src/main/java/no/nibio/vips/gis/GISUtil.java b/src/main/java/no/nibio/vips/gis/GISUtil.java index 201af6d24ac4bac34dd3652d5315437ae7710060..d669deb445ca0de0f23dd83f132ddb16cddf42f3 100644 --- a/src/main/java/no/nibio/vips/gis/GISUtil.java +++ b/src/main/java/no/nibio/vips/gis/GISUtil.java @@ -28,12 +28,12 @@ import org.locationtech.jts.geom.PrecisionModel; import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.geotools.geometry.jts.JTS; +import org.geotools.api.referencing.FactoryException; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; +import org.geotools.api.referencing.operation.MathTransform; +import org.geotools.api.referencing.operation.TransformException; import org.geotools.referencing.CRS; -import org.opengis.referencing.FactoryException; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.operation.MathTransform; -import org.opengis.referencing.operation.TransformException; +import org.geotools.geometry.jts.JTS; import org.wololo.geojson.Feature; import org.wololo.geojson.FeatureCollection; import org.wololo.geojson.GeoJSONFactory; diff --git a/src/main/java/no/nibio/vips/model/JythonModel.java b/src/main/java/no/nibio/vips/model/JythonModel.java deleted file mode 100644 index a14860538656b097474eea9ebe720098900caa9a..0000000000000000000000000000000000000000 --- a/src/main/java/no/nibio/vips/model/JythonModel.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2017 NIBIO <http://www.nibio.no/>. - * - * This file is part of VIPSCommon. - * VIPSCommon is free software: you can redistribute it and/or modify - * it under the terms of the NIBIO Open Source License as published by - * NIBIO, either version 1 of the License, or (at your option) any - * later version. - * - * VIPSCommon is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * NIBIO Open Source License for more details. - * - * You should have received a copy of the NIBIO Open Source License - * along with VIPSCommon. If not, see <http://www.nibio.no/licenses/>. - * - */ - -package no.nibio.vips.model; - -import org.python.util.PythonInterpreter; - -/** - * When implementing a model using Jython (Python on the Java Virtual Machine), - * you must extend this class. - * - * @copyright 2017 <a href="http://www.nibio.no/">NIBIO</a> - * @author Tor-Einar Skog <tor-einar.skog@nibio.no> - */ -public abstract class JythonModel{ - - public JythonModel() - { - // Adding possible paths to the python module - PythonInterpreter interpreter = new PythonInterpreter(); - interpreter.exec("import sys"); - // Adding path to the containing JAR (if any) or code source - String jarPath = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath(); - // For some reason weird prefixes and suffixes are added to the path. We try to - // remove them. This removal might ned to be revised when new deployment situations occur - jarPath = jarPath.replaceFirst("file:", "").replace("!", ""); - interpreter.exec("sys.path.append('" + jarPath + "python')"); - //interpreter.exec("print sys.path"); - } - - /** - * Assumes the python modules are found under the [jarPath]/python folder - * @param moduleName - * @param className - * @return - */ - protected Model getPythonModel(String moduleName, String className){ - JythonObjectFactory f = new JythonObjectFactory( - Model.class, moduleName, className - ); - return (Model) f.createObject(); - } -} diff --git a/src/main/java/no/nibio/vips/model/JythonObjectFactory.java b/src/main/java/no/nibio/vips/model/JythonObjectFactory.java deleted file mode 100644 index 88dad9c58d07e565273fe021c67ad9cbfa351afa..0000000000000000000000000000000000000000 --- a/src/main/java/no/nibio/vips/model/JythonObjectFactory.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2017 NIBIO <http://www.nibio.no/>. - * - * This file is part of VIPSCommon. - * VIPSCommon is free software: you can redistribute it and/or modify - * it under the terms of the NIBIO Open Source License as published by - * NIBIO, either version 1 of the License, or (at your option) any - * later version. - * - * VIPSCommon is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * NIBIO Open Source License for more details. - * - * You should have received a copy of the NIBIO Open Source License - * along with VIPSCommon. If not, see <http://www.nibio.no/licenses/>. - * - */ - -package no.nibio.vips.model; - -/** - * @copyright 2017 <a href="http://www.nibio.no/">NIBIO</a> - * @author Tor-Einar Skog <tor-einar.skog@nibio.no> - */ -import java.util.Properties; -import org.python.core.Py; -import org.python.core.PyObject; -import org.python.core.PySystemState; - -/** - * Jython Object Factory using PySystemState - * Found here: http://www.jython.org/jythonbook/en/1.0/JythonAndJavaIntegration.html#more-efficient-version-of-loosely-coupled-object-factory - */ -public class JythonObjectFactory { - - private final Class interfaceType; - private final PyObject klass; - - // Constructor obtains a reference to the importer, module, and the class name - public JythonObjectFactory(PySystemState state, Class interfaceType, String moduleName, String className) { - this.interfaceType = interfaceType; - PyObject importer = state.getBuiltins().__getitem__(Py.newString("__import__")); - PyObject module = importer.__call__(Py.newString(moduleName)); - klass = module.__getattr__(className); - //System.err.println("module=" + module + ",class=" + klass); - } - - // This constructor passes through to the other constructor - public JythonObjectFactory(Class interfaceType, String moduleName, String className) { - this(new PySystemState(), interfaceType, moduleName, className); - } - - // All of the followng methods return - // a coerced Jython object based upon the pieces of information - // that were passed into the factory. The differences are - // between them are the number of arguments that can be passed - // in as arguents to the object. - - public Object createObject() { - return klass.__call__().__tojava__(interfaceType); - } - - - public Object createObject(Object arg1) { - return klass.__call__(Py.java2py(arg1)).__tojava__(interfaceType); - } - - public Object createObject(Object arg1, Object arg2) { - return klass.__call__(Py.java2py(arg1), Py.java2py(arg2)).__tojava__(interfaceType); - } - - public Object createObject(Object arg1, Object arg2, Object arg3) - { - return klass.__call__(Py.java2py(arg1), Py.java2py(arg2), - Py.java2py(arg3)).__tojava__(interfaceType); - } - - public Object createObject(Object args[], String keywords[]) { - PyObject convertedArgs[] = new PyObject[args.length]; - for (int i = 0; i < args.length; i++) { - convertedArgs[i] = Py.java2py(args[i]); - } - - return klass.__call__(convertedArgs, keywords).__tojava__(interfaceType); - } - - public Object createObject(Object... args) { - return createObject(args, Py.NoKeywords); - } - - /** - * Adds user.dir into python.path to make Jython look for python modules in working directory in all cases - * (both standalone and not standalone modes) - * @param props - * @return props - */ -private Properties setDefaultPythonPath(Properties props) { - String pythonPathProp = props.getProperty("python.path"); - String new_value; - if (pythonPathProp==null) - { - new_value = System.getProperty("user.dir"); - } else { - new_value = pythonPathProp +java.io.File.pathSeparator + System.getProperty("user.dir") + java.io.File.pathSeparator; - } - props.setProperty("python.path",new_value); - return props; -} - -} diff --git a/src/main/java/no/nibio/vips/util/WeatherUtil.java b/src/main/java/no/nibio/vips/util/WeatherUtil.java index 3217888fc6f9b9cdc22d5db435901cf5127b4865..486503d4cf933179519e0a7d4ed335de5048e941 100755 --- a/src/main/java/no/nibio/vips/util/WeatherUtil.java +++ b/src/main/java/no/nibio/vips/util/WeatherUtil.java @@ -1024,7 +1024,7 @@ public class WeatherUtil { { newObs.setValue(0.0); } - System.out.println("Appending this: " + newObs); + //System.out.println("Appending this: " + newObs); list.add(newObs); } } diff --git a/src/test/java/no/nibio/vips/ipmdecisions/DataTransformerTest.java b/src/test/java/no/nibio/vips/ipmdecisions/DataTransformerTest.java index 3a3bab6fd878ffffd2f8d409df0a7b2f9057e9e3..0baceddf2197988cc59af6002dca5716dbfdc226 100644 --- a/src/test/java/no/nibio/vips/ipmdecisions/DataTransformerTest.java +++ b/src/test/java/no/nibio/vips/ipmdecisions/DataTransformerTest.java @@ -67,7 +67,7 @@ public class DataTransformerTest extends TestCase { try { List<WeatherObservation> result = instance.getVIPSWeatherData(IPMWeatherData); - result.forEach(obs->System.out.println(obs)); + //result.forEach(obs->System.out.println(obs)); assertEquals(IPMWeatherData.getLocationWeatherData().get(0).getLength() * IPMWeatherData.getLocationWeatherData().get(0).getWidth(), result.size()); }catch(DataTransformerException ex) { diff --git a/src/test/java/no/nibio/vips/util/WeatherUtilTest.java b/src/test/java/no/nibio/vips/util/WeatherUtilTest.java index b6cd185b386dfd83d2e1b07ed71ac7192e1c00cc..885ad984efe9911dabb056f02a56bb79f2d79828 100755 --- a/src/test/java/no/nibio/vips/util/WeatherUtilTest.java +++ b/src/test/java/no/nibio/vips/util/WeatherUtilTest.java @@ -369,7 +369,7 @@ public class WeatherUtilTest extends TestCase { // Test 1 // Result have same length as input data assertEquals(TM.size(), result.size()); // Starts with same timestamp - result.stream().forEach(o->System.out.println(o)); + //result.stream().forEach(o->System.out.println(o)); assertEquals(TM.get(0).getTimeMeasured(), result.get(0).getTimeMeasured()); // Ends with same timestamp assertEquals(TM.get(TM.size()-1).getTimeMeasured(), result.get(TM.size()-1).getTimeMeasured()); diff --git a/src/test/java/no/nibio/vips/util/WebUtilTest.java b/src/test/java/no/nibio/vips/util/WebUtilTest.java index d696966fdb3e6ee16e9dc0609ea17fae7c92ae6c..bd41cb64749705b80ccaf4a2a7bc0bc104035be0 100755 --- a/src/test/java/no/nibio/vips/util/WebUtilTest.java +++ b/src/test/java/no/nibio/vips/util/WebUtilTest.java @@ -124,7 +124,7 @@ public class WebUtilTest extends TestCase { Map<String, String[]> arrP = new HashMap<>(); arrP.put("wp", weatherParams); String result = WebUtil.getOutputFromPostRequest(URL, queryParams, arrP); - System.out.println(result); + //System.out.println(result); assertNotNull(expResult, result); }