Commit 19cdead3 authored by Matija Obreza's avatar Matija Obreza
Browse files

Converted to Maven modules project

parent 2944140a
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="target/generated-sources/swagger/src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
target
.settings/
.classpath
......@@ -5,11 +5,6 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
......@@ -17,7 +12,6 @@
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
......@@ -2,16 +2,45 @@
The GLIS test environment is accessible at <https://glistest.planttreaty.org/>
# Using the glis-client Java library
# Using the Java library
We provide different flavors of the library (with different dependencies):
- **[glis-client-okhttp-gson](okhttp-gson)**
- **[glis-client-jersey2](jersey2)**
- **[glis-client-resttemplate](resttemplate)** using Spring REST Template
- [glis-client-resteasy](resteasy) (currently fails to build)
## Maven users
Add this dependency to your project's POM:
### OK HTTP + GSON
```xml
<dependency>
<groupId>org.genesys-pgr</groupId>
<artifactId>glis-client-okhttp-gson</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
```
### Jersey2
```xml
<dependency>
<groupId>org.genesys-pgr</groupId>
<artifactId>glis-client</artifactId>
<artifactId>glis-client-jersey2</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
```
### Spring REST template
```xml
<dependency>
<groupId>org.genesys-pgr</groupId>
<artifactId>glis-client-resttemplate</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
......@@ -22,9 +51,11 @@ Add this dependency to your project's POM:
Add this dependency to your project's build file:
```groovy
compile "org.genesys-pgr:glis-client:1.0-SNAPSHOT"
compile "org.genesys-pgr:glis-client-okhttp-gson:1.0-SNAPSHOT"
```
... and similar for other flavors.
## Test and Production GLIS environment
To change the base URL of the GLIS api server (i.e. switch between production and testing environments) you must change the `ApiClient` setting:
......
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>glis-client-jersey2</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
# GLIS API Client
### Maven users
Add this dependency to your project's POM:
```xml
<dependency>
<groupId>org.genesys</groupId>
<artifactId>glis-client-jersey2</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
```
### Gradle users
Add this dependency to your project's build file:
```groovy
compile "org.genesys:glis-client-jersey2:1.0-SNAPSHOT"
```
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.genesys-pgr</groupId>
<artifactId>glis-client-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>glis-client-jersey2</artifactId>
<packaging>jar</packaging>
<name>GLIS API client (jersey2)</name>
<description>API client for the Global Information System for plant genetic resources for food and agriculture (PGRFA) with jersey2</description>
<properties>
<swagger-codegen.language>java</swagger-codegen.language>
<swagger-codegen.library>jersey2</swagger-codegen.library>
<jersey-version>2.22.2</jersey-version>
<jackson-version>2.7.5</jackson-version>
</properties>
<dependencies>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger-core.version}</version>
</dependency>
<!-- HTTP client: jersey-client -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey-version}</version>
</dependency>
<!-- JSON processing: jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime-version}</version>
</dependency>
<!-- Base64 encoding that works in both JVM and Android -->
<dependency>
<groupId>com.brsanthu</groupId>
<artifactId>migbase64</artifactId>
<version>2.2</version>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
</plugins>
</build>
</project>
/*
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.genesys.glis.v1.api;
import org.genesys.glis.v1.invoker.ApiClient;
import org.genesys.glis.v1.invoker.auth.HttpBasicAuth;
import org.junit.BeforeClass;
public abstract class BaseApiTest {
public static final String THE_DOI = "10.0155/1";
protected static String GLIS_USERNAME = System.getenv("GLIS_USERNAME");
protected static String GLIS_PASSWORD = System.getenv("GLIS_PASSWORD");
protected static ApiClient defaultClient;
@BeforeClass
public static void config() {
defaultClient = new ApiClient();
if ("true".equals(System.getenv("GLIS_DEBUG"))) {
defaultClient.setDebugging(true);
}
// Configure HTTP basic authorization: glis_auth
HttpBasicAuth easySmtaAuth = (HttpBasicAuth) defaultClient.getAuthentication("easySmta");
easySmtaAuth.setUsername(GLIS_USERNAME);
System.out.println("Using GLIS username " + easySmtaAuth.getUsername());
easySmtaAuth.setPassword(GLIS_PASSWORD);
}
}
/*
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.genesys.glis.v1.api;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.List;
import org.genesys.glis.v1.invoker.ApiException;
import org.genesys.glis.v1.model.PGRFA;
import org.genesys.glis.v1.model.Relationship;
import org.genesys.glis.v1.model.Term;
import org.junit.Test;
/**
* API tests for QueryApi
*/
public class QueryApiTest extends BaseApiTest {
private final QueryApi api = new QueryApi(defaultClient);
/**
* Get PGRFA relationships
*
* Multiple status values can be provided with comma separated strings
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void listRelationshipsTest() throws ApiException {
String role = null;
String oper = null;
List<Relationship> response = api.listRelationships(THE_DOI, role, oper);
assertThat(response.size(), greaterThan(0));
}
/**
* GLIS vocabularies
*
* To describe the kind of information that will be found in the targets, GLIS adopts a simple controlled vocabulary.
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void listTermsTest() throws ApiException {
List<String> acceptLanguage = Arrays.asList("en");
List<Term> response = api.listTerms(acceptLanguage);
assertThat(response.size(), greaterThan(0));
}
/**
* Find passport data on PGRFA in GLIS
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void searchTest() throws ApiException {
Integer page = null;
Integer perPage = null;
// String doi = null;
String identifier = null;
String genus = null;
String species = null;
String name = null;
String holdwiews = null;
String holdpid = null;
String holdname = null;
String holdcountry = null;
String methodcode = null;
String provwiews = null;
String provpid = null;
String provname = null;
String provcountry = null;
String provenance = null;
String collwiews = null;
String collpid = null;
String collname = null;
String collcountry = null;
String bredwiews = null;
String bredpid = null;
String bredname = null;
String bredcountry = null;
String biostatus = null;
String mlsstatus = null;
String targetkw = null;
List<PGRFA> response = api.search(page, perPage, THE_DOI, identifier, genus, species, name, holdwiews, holdpid, holdname, holdcountry, methodcode, provwiews, provpid, provname, provcountry, provenance, collwiews, collpid, collname, collcountry, bredwiews, bredpid, bredname, bredcountry, biostatus, mlsstatus, targetkw);
assertThat(response.size(), greaterThan(0));
}
}
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>glis-client-okhttp-gson</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
# GLIS API Client
### Maven users
Add this dependency to your project's POM:
```xml
<dependency>
<groupId>org.genesys</groupId>
<artifactId>glis-client-okhttp-gson</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
```
### Gradle users
Add this dependency to your project's build file:
```groovy
compile "org.genesys:glis-client-okhttp-gson:1.0-SNAPSHOT"
```
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.genesys-pgr</groupId>
<artifactId>glis-client-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>glis-client-okhttp-gson</artifactId>
<packaging>jar</packaging>
<name>GLIS API client (okhttp-gson)</name>
<url>https://gitlab.croptrust.org/genesys-pgr/glis-client</url>
<description>API client for the Global Information System for plant genetic resources for food and agriculture (PGRFA) with okhttp+gson</description>
<properties>
<swagger-codegen.language>java</swagger-codegen.language>
<swagger-codegen.library>okhttp-gson</swagger-codegen.library>
<okhttp-version>2.7.5</okhttp-version>
<gson-version>2.6.2</gson-version>
</properties>
<dependencies>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger-core.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp-version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>logging-interceptor</artifactId>
<version>${okhttp-version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson-version}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime-version}</version>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
</plugins>
</build>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.genesys-pgr</groupId>
<artifactId>glis-client-project</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>glis-client-parent</artifactId>
<packaging>pom</packaging>
<name>GLIS API client parent</name>
<description>Parent POM to build a module</description>
<build>
<plugins>
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>${swagger-codegen.version}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/../swagger/v1/glis.yml</inputSpec>
<language>${swagger-codegen.language}</language>
<library>${swagger-codegen.library}</library>
<modelPackage>org.genesys.glis.v1.model</modelPackage>
<apiPackage>org.genesys.glis.v1.api</apiPackage>
<invokerPackage>org.genesys.glis.v1.invoker</invokerPackage>
<output>${generated-sources-path}</output>
<configOptions>
<sourceFolder>${generated-sources-java-path}</sourceFolder>
<groupId>org.genesys</groupId>
<artifactId>glis-client-${swagger-codegen.library}</artifactId>
<artifactVersion>1.0-SNAPSHOT</artifactVersion>
<artifactUrl>https://gitlab.croptrust.org/genesys-pgr/glis-client</artifactUrl>
<artifactDescription>Java API client for the Global Information System for plant genetic resources for food and agriculture (PGRFA) using ${swagger-codegen.library}</artifactDescription>
<scmConnection>git@gitlab.croptrust.org:genesys-pgr/glis-client.git</scmConnection>
<scmDeveloperConnection>git@gitlab.croptrust.org:genesys-pgr/glis-client.git</scmDeveloperConnection>
<scmUrl>https://gitlab.croptrust.org/genesys-pgr/glis-client.git</scmUrl>
<developerName>Matija Obreza</developerName>
<developerEmail>matija.obreza@croptrust.org</developerEmail>
<developerOrganization>Global Crop Diversity Trust</developerOrganization>
<developerOrganizationUrl>https://www.croptrust.org</developerOrganizationUrl>
<licenseName>Apache 2.0</licenseName>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<!-- TODO for eclipse/m2e users: install the m2e connector 'buildhelper' by selecting 'Discover new m2e connectors' while hovering over the follwoing execution tag -->
<execution>
<id>add-generated-source</id>
<phase>initialize</phase>
<goals>