From 0c69017221b4ff462dd9964652136bb17e1eb0d4 Mon Sep 17 00:00:00 2001 From: etorres Date: Wed, 30 Dec 2015 17:12:10 +0100 Subject: [PATCH] Change version to 0.9.3 --- .../org.eclipse.wst.common.component | 4 +- lvl-project/lvl-auth/pom.xml | 2 +- lvl-project/lvl-bundle/pom.xml | 2 +- lvl-project/lvl-bundle/src/main/etc/lvl.xml | 1 + lvl-project/lvl-core/pom.xml | 2 +- .../eu/eubrazilcc/lvl/core/LvlInstance.java | 2 +- .../lvl/core/conf/ConfigurationManager.java | 14 ++- .../core/http/client/HttpClientProvider.java | 26 ++++- .../lvl/core/tapir/TapirClient.java | 5 +- .../lvl-core/src/main/resources/lvl.xml | 3 +- .../eu/eubrazilcc/lvl/core/TapirTest.java | 2 +- .../org.eclipse.wst.common.component | 4 +- lvl-project/lvl-service/pom.xml | 2 +- .../eubrazilcc/lvl/service/CloserService.java | 4 + .../lvl/service/cache/CacheWarmer.java | 104 ++++++++++++++++++ .../lvl/service/io/ImportSamplesTask.java | 23 ++-- .../LeishmaniaSampleResourceTest.java | 2 +- .../service/testable/TaskResourceTest.java | 63 +++++------ lvl-project/lvl-storage/pom.xml | 2 +- lvl-project/lvl-test/pom.xml | 2 +- lvl-project/pom.xml | 2 +- pom.xml | 2 +- 22 files changed, 208 insertions(+), 65 deletions(-) create mode 100644 lvl-project/lvl-service/src/main/java/eu/eubrazilcc/lvl/service/cache/CacheWarmer.java diff --git a/lvl-project/lvl-auth/.settings/org.eclipse.wst.common.component b/lvl-project/lvl-auth/.settings/org.eclipse.wst.common.component index a2c35a89..5271256e 100644 --- a/lvl-project/lvl-auth/.settings/org.eclipse.wst.common.component +++ b/lvl-project/lvl-auth/.settings/org.eclipse.wst.common.component @@ -4,10 +4,10 @@ - + uses - + uses diff --git a/lvl-project/lvl-auth/pom.xml b/lvl-project/lvl-auth/pom.xml index b439b248..197b8d45 100644 --- a/lvl-project/lvl-auth/pom.xml +++ b/lvl-project/lvl-auth/pom.xml @@ -27,7 +27,7 @@ that you distribute must include a readable copy of the "NOTICE" text file. eu.eubrazilcc.lvl lvl-project - 0.9.2 + 0.9.3 .. diff --git a/lvl-project/lvl-bundle/pom.xml b/lvl-project/lvl-bundle/pom.xml index a5484bd0..e6d77078 100644 --- a/lvl-project/lvl-bundle/pom.xml +++ b/lvl-project/lvl-bundle/pom.xml @@ -27,7 +27,7 @@ that you distribute must include a readable copy of the "NOTICE" text file. eu.eubrazilcc.lvl lvl-project - 0.9.2 + 0.9.3 .. diff --git a/lvl-project/lvl-bundle/src/main/etc/lvl.xml b/lvl-project/lvl-bundle/src/main/etc/lvl.xml index e2190fb3..9dcd57bb 100644 --- a/lvl-project/lvl-bundle/src/main/etc/lvl.xml +++ b/lvl-project/lvl-bundle/src/main/etc/lvl.xml @@ -172,6 +172,7 @@ that you distribute must include a readable copy of the "NOTICE" text file. http://rs.tdwg.org/dwc/dwcore/CollectionCode http://rs.tdwg.org/dwc/dwcore/CollectionCode equals "$COLLECTION" http://rs.tdwg.org/dwc/dwcore/CatalogNumber + 3000 clioc:FIOCRUZ-CLIOC colfleb:FIOCRUZ-COLFLEB diff --git a/lvl-project/lvl-core/pom.xml b/lvl-project/lvl-core/pom.xml index 64c4d8bf..b3d806a7 100644 --- a/lvl-project/lvl-core/pom.xml +++ b/lvl-project/lvl-core/pom.xml @@ -27,7 +27,7 @@ that you distribute must include a readable copy of the "NOTICE" text file. eu.eubrazilcc.lvl lvl-project - 0.9.2 + 0.9.3 .. diff --git a/lvl-project/lvl-core/src/main/java/eu/eubrazilcc/lvl/core/LvlInstance.java b/lvl-project/lvl-core/src/main/java/eu/eubrazilcc/lvl/core/LvlInstance.java index d749c402..701dff5f 100644 --- a/lvl-project/lvl-core/src/main/java/eu/eubrazilcc/lvl/core/LvlInstance.java +++ b/lvl-project/lvl-core/src/main/java/eu/eubrazilcc/lvl/core/LvlInstance.java @@ -180,7 +180,7 @@ public String toString() { .add("links", links) .add("urlSafeId", urlSafeInstanceId) .add("instanceId", instanceId) - .add("roles",roles) + .add("roles", roles) .add("heartbeat", heartbeat.orNull()) .add("location", location) .toString(); diff --git a/lvl-project/lvl-core/src/main/java/eu/eubrazilcc/lvl/core/conf/ConfigurationManager.java b/lvl-project/lvl-core/src/main/java/eu/eubrazilcc/lvl/core/conf/ConfigurationManager.java index f6422552..3e77630a 100644 --- a/lvl-project/lvl-core/src/main/java/eu/eubrazilcc/lvl/core/conf/ConfigurationManager.java +++ b/lvl-project/lvl-core/src/main/java/eu/eubrazilcc/lvl/core/conf/ConfigurationManager.java @@ -291,7 +291,7 @@ private Configuration configuration() { final String portalEndpoint = getString("portal.endpoint", configuration, foundNameList, null); final String wfHostname = getString("workflow.endpoint.hostname", configuration, foundNameList, "localhost"); final boolean wfSecure = getBoolean("workflow.endpoint.secure", configuration, foundNameList, false); - final int wfPort = getInteger("workflow.endpoint.port", configuration, foundNameList, wfSecure ? 443 : 80); + final int wfPort = getInteger("workflow.endpoint.port", configuration, foundNameList, wfSecure ? 443 : 80); final String wfUsername = getString("workflow.credentials.username", configuration, foundNameList, null); final String wfPasswd = getString("workflow.credentials.password", configuration, foundNameList, null); // get secondary property will return null if the requested property is missing @@ -412,6 +412,7 @@ public String apply(final Object obj) { final String concept = getString(name + ".concept", configuration, foundNameList, null); final String filter = getString(name + ".filter", configuration, foundNameList, null); final String orderby = getString(name + ".orderby", configuration, foundNameList, null); + final int maxElements = getInteger(name + ".maxElements", configuration, foundNameList, 3000); final List collections = getStringList(name + ".collections.collection", Pattern.compile("^[\\w]+:[\\w-]+$"), configuration, foundNameList, null); final Map collectionsMap = newHashMap(); if (collections != null) { @@ -420,7 +421,7 @@ public String apply(final Object obj) { collectionsMap.put(tokens[0], tokens[1]); } } - return new TapirCollection(url, outputModel, concept, filter, orderby, collectionsMap); + return new TapirCollection(url, outputModel, concept, filter, orderby, maxElements, collectionsMap); } private static String subsEnvVars(final String path, final boolean ensureWriting) { @@ -670,15 +671,17 @@ public static class TapirCollection { private final String concept; private final String filter; private final String orderby; + private final int maxElements; private final Map collections; public TapirCollection(final URL url, final String outputModel, final String concept, final String filter, final String orderby, - final Map collections) { + final int maxElements, final Map collections) { this.url = url; this.outputModel = outputModel; this.concept = concept; this.filter = filter; this.orderby = orderby; + this.maxElements = maxElements; this.collections = collections; } @@ -701,6 +704,10 @@ public String getFilter() { public String getOrderby() { return orderby; } + + public int getMaxElements() { + return maxElements; + } public Map getCollections() { return collections; @@ -714,6 +721,7 @@ public String toString() { .add("concept", concept) .add("filter", filter) .add("orderby", orderby) + .add("maxElements", maxElements) .add("collections", collections) .toString(); } diff --git a/lvl-project/lvl-core/src/main/java/eu/eubrazilcc/lvl/core/http/client/HttpClientProvider.java b/lvl-project/lvl-core/src/main/java/eu/eubrazilcc/lvl/core/http/client/HttpClientProvider.java index 9cdb2bae..6899644b 100644 --- a/lvl-project/lvl-core/src/main/java/eu/eubrazilcc/lvl/core/http/client/HttpClientProvider.java +++ b/lvl-project/lvl-core/src/main/java/eu/eubrazilcc/lvl/core/http/client/HttpClientProvider.java @@ -97,20 +97,34 @@ public long getKeepAliveDuration(final HttpResponse response, final HttpContext } }; private final CloseableHttpClient httpClient; - private final List requests = synchronizedList(new ArrayList()); + private final List requests = synchronizedList(new ArrayList()); private HttpClientProvider() { + this(-1); + } + + private HttpClientProvider(final int timeoutMs) { final ConnectionConfig connConfig = ConnectionConfig.custom() .setCharset(Consts.UTF_8) .build(); connManager.setDefaultConnectionConfig(connConfig); connManager.setMaxTotal(100); connManager.setDefaultMaxPerRoute(10); + final RequestConfig requestConfig = timeoutMs > 0 ? defaultRequestConfig(timeoutMs) : RequestConfig.DEFAULT; httpClient = HttpClients.custom() .setConnectionManager(connManager) .setKeepAliveStrategy(keepAliveStrategy) + .setDefaultRequestConfig(requestConfig) .evictExpiredConnections() - .evictIdleConnections(30l, TimeUnit.SECONDS) + .evictIdleConnections(timeoutMs > 0 ? timeoutMs/1000l : 30l, TimeUnit.SECONDS) + .build(); + } + + private static RequestConfig defaultRequestConfig(final int timeoutMs) { + return RequestConfig.copy(RequestConfig.DEFAULT) + .setSocketTimeout(timeoutMs) + .setConnectTimeout(timeoutMs) + .setConnectionRequestTimeout(timeoutMs) .build(); } @@ -141,7 +155,11 @@ public void dispose(final Http1_1Request request) { } public static HttpClientProvider create() { - return new HttpClientProvider(); + return create(-1); + } + + public static HttpClientProvider create(final int timeoutMs) { + return new HttpClientProvider(timeoutMs); } @Override @@ -253,7 +271,7 @@ public Void handleResponse(final HttpResponse response) throws IOException { } private HttpUriRequest createHttpRequest() { - HttpUriRequest httpRequest = null; + HttpUriRequest httpRequest = null; if (HttpGet.METHOD_NAME.equals(method)) { httpRequest = RequestBuilder.get(uri) .setVersion(HttpVersion.HTTP_1_1) diff --git a/lvl-project/lvl-core/src/main/java/eu/eubrazilcc/lvl/core/tapir/TapirClient.java b/lvl-project/lvl-core/src/main/java/eu/eubrazilcc/lvl/core/tapir/TapirClient.java index a88a9d67..ed9d10c1 100644 --- a/lvl-project/lvl-core/src/main/java/eu/eubrazilcc/lvl/core/tapir/TapirClient.java +++ b/lvl-project/lvl-core/src/main/java/eu/eubrazilcc/lvl/core/tapir/TapirClient.java @@ -71,8 +71,10 @@ public abstract class TapirClient implements AutoCloseable { public static final String XPATH_TO_DWCSET = "/*[local-name()=\"response\"]" + "/*[local-name()=\"search\"]" + "/*[local-name()=\"SimpleDarwinRecordSet\"]"; + + public static final int TIMEOUT_MS = 120000; - private final HttpClientProvider httpClient = HttpClientProvider.create(); + private final HttpClientProvider httpClient = HttpClientProvider.create(TIMEOUT_MS); protected ResponseType count(final String url, final String concept, final String filter) throws URISyntaxException, IOException { final URIBuilder uriBuilder = new URIBuilder(url); @@ -83,7 +85,6 @@ protected ResponseType count(final String url, final String concept, final Strin uriBuilder.addParameter("concept", concept); uriBuilder.addParameter("filter", filter); final String url2 = uriBuilder.build().toString(); - final HttpClientProvider httpClient = HttpClientProvider.create(); return httpClient.request(url2).get().handleResponse(new ResponseHandler() { @Override public ResponseType handleResponse(final HttpResponse response) throws ClientProtocolException, IOException { diff --git a/lvl-project/lvl-core/src/main/resources/lvl.xml b/lvl-project/lvl-core/src/main/resources/lvl.xml index 9d738c6a..7cc1ee64 100644 --- a/lvl-project/lvl-core/src/main/resources/lvl.xml +++ b/lvl-project/lvl-core/src/main/resources/lvl.xml @@ -172,10 +172,11 @@ that you distribute must include a readable copy of the "NOTICE" text file. http://rs.tdwg.org/dwc/dwcore/CollectionCode http://rs.tdwg.org/dwc/dwcore/CollectionCode equals "$COLLECTION" http://rs.tdwg.org/dwc/dwcore/CatalogNumber + 3000 clioc:FIOCRUZ-CLIOC colfleb:FIOCRUZ-COLFLEB - + \ No newline at end of file diff --git a/lvl-project/lvl-core/src/test/java/eu/eubrazilcc/lvl/core/TapirTest.java b/lvl-project/lvl-core/src/test/java/eu/eubrazilcc/lvl/core/TapirTest.java index cb12a3b3..413a5587 100644 --- a/lvl-project/lvl-core/src/test/java/eu/eubrazilcc/lvl/core/TapirTest.java +++ b/lvl-project/lvl-core/src/test/java/eu/eubrazilcc/lvl/core/TapirTest.java @@ -64,7 +64,7 @@ public class TapirTest extends LeishvlTestCase { public TapirTest() { - super(true); + super(false); } @Rule diff --git a/lvl-project/lvl-service/.settings/org.eclipse.wst.common.component b/lvl-project/lvl-service/.settings/org.eclipse.wst.common.component index 0b14ae90..3f78c8e5 100644 --- a/lvl-project/lvl-service/.settings/org.eclipse.wst.common.component +++ b/lvl-project/lvl-service/.settings/org.eclipse.wst.common.component @@ -4,10 +4,10 @@ - + uses - + uses diff --git a/lvl-project/lvl-service/pom.xml b/lvl-project/lvl-service/pom.xml index 66ba9a44..724f8b6f 100644 --- a/lvl-project/lvl-service/pom.xml +++ b/lvl-project/lvl-service/pom.xml @@ -27,7 +27,7 @@ that you distribute must include a readable copy of the "NOTICE" text file. eu.eubrazilcc.lvl lvl-project - 0.9.2 + 0.9.3 .. diff --git a/lvl-project/lvl-service/src/main/java/eu/eubrazilcc/lvl/service/CloserService.java b/lvl-project/lvl-service/src/main/java/eu/eubrazilcc/lvl/service/CloserService.java index efee8b12..c9f6ede5 100644 --- a/lvl-project/lvl-service/src/main/java/eu/eubrazilcc/lvl/service/CloserService.java +++ b/lvl-project/lvl-service/src/main/java/eu/eubrazilcc/lvl/service/CloserService.java @@ -28,6 +28,7 @@ import static eu.eubrazilcc.lvl.core.concurrent.TaskStorage.TASK_STORAGE; import static eu.eubrazilcc.lvl.core.conf.ConfigurationFinder.findConfigurationFiles; import static eu.eubrazilcc.lvl.core.conf.ConfigurationManager.CONFIG_MANAGER; +import static eu.eubrazilcc.lvl.service.cache.CacheWarmer.CACHE_WARMER; import static eu.eubrazilcc.lvl.service.workflow.esc.ESCentralConnector.ESCENTRAL_CONN; import static eu.eubrazilcc.lvl.storage.activemq.ActiveMQConnector.ACTIVEMQ_CONN; import static eu.eubrazilcc.lvl.storage.mongodb.MongoDBConnector.MONGODB_CONN; @@ -75,6 +76,9 @@ public void preload() { // load e-SC connector and register it for closing ESCENTRAL_CONN.preload(); register(ESCENTRAL_CONN); + // load cache warmer and register it for closing + CACHE_WARMER.preload(); + register(CACHE_WARMER); } @Override diff --git a/lvl-project/lvl-service/src/main/java/eu/eubrazilcc/lvl/service/cache/CacheWarmer.java b/lvl-project/lvl-service/src/main/java/eu/eubrazilcc/lvl/service/cache/CacheWarmer.java new file mode 100644 index 00000000..3fd406e6 --- /dev/null +++ b/lvl-project/lvl-service/src/main/java/eu/eubrazilcc/lvl/service/cache/CacheWarmer.java @@ -0,0 +1,104 @@ +/* + * Copyright 2014-2015 EUBrazilCC (EU‐Brazil Cloud Connect) + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://ec.europa.eu/idabc/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + +package eu.eubrazilcc.lvl.service.cache; + +import static eu.eubrazilcc.lvl.core.concurrent.TaskScheduler.TASK_SCHEDULER; +import static eu.eubrazilcc.lvl.service.cache.GeolocationCache.findNearbyLeishmaniaSequences; +import static eu.eubrazilcc.lvl.service.cache.GeolocationCache.findNearbySandflySequences; +import static eu.eubrazilcc.lvl.service.cache.StatisticsCache.leishmaniaStats; +import static eu.eubrazilcc.lvl.service.cache.StatisticsCache.sandflyStats; +import static org.slf4j.LoggerFactory.getLogger; + +import java.io.IOException; +import java.net.URL; +import java.util.Collection; +import java.util.concurrent.TimeUnit; + +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.WebTarget; + +import org.glassfish.jersey.client.ClientProperties; +import org.glassfish.jersey.jackson.JacksonFeature; +import org.glassfish.jersey.media.multipart.MultiPartFeature; +import org.glassfish.jersey.media.sse.SseFeature; +import org.slf4j.Logger; + +import eu.eubrazilcc.lvl.core.Closeable2; +import eu.eubrazilcc.lvl.core.geojson.LngLatAlt; +import eu.eubrazilcc.lvl.core.geojson.Point; +import eu.eubrazilcc.lvl.service.rest.jackson.MapperProvider; + +/** + * Warms up (or pre-populates) a cache with record updates. + * @author Erik Torres + */ +public enum CacheWarmer implements Closeable2 { + + CACHE_WARMER; + + private static final Logger LOGGER = getLogger(CacheWarmer.class); + + private static final String BASE_URI = "http://localhost/lvl-service/rest/v1"; + + @Override + public void setup(final Collection urls) { } + + @Override + public void preload() { + // create client + final Client client = ClientBuilder.newBuilder() + .register(MapperProvider.class) + .register(JacksonFeature.class) + .register(SseFeature.class) + .register(MultiPartFeature.class) + .build(); + final WebTarget target = client.target(BASE_URI); + target.property(ClientProperties.FOLLOW_REDIRECTS, true); + // schedule periodic updates + TASK_SCHEDULER.scheduleAtFixedRate(new Runnable() { + @Override + public void run() { + // sandflies global vector and heat maps, collection statistics + findNearbySandflySequences(Point.builder().coordinates(LngLatAlt.builder().coordinates(0.0, 0.0).build()).build(), + 6500000.0, true, false); + findNearbySandflySequences(Point.builder().coordinates(LngLatAlt.builder().coordinates(0.0, 0.0).build()).build(), + 6500000.0, true, true); + sandflyStats(); + // leishmania global vector and heat maps, collection statistics + findNearbyLeishmaniaSequences(Point.builder().coordinates(LngLatAlt.builder().coordinates(0.0, 0.0).build()).build(), + 6500000.0, true, false); + findNearbyLeishmaniaSequences(Point.builder().coordinates(LngLatAlt.builder().coordinates(0.0, 0.0).build()).build(), + 6500000.0, true, true); + leishmaniaStats(); + } + }, 30l, 3600l, TimeUnit.SECONDS); // repeat every 1 hour + LOGGER.info("Cache warmer initialized successfully"); + } + + @Override + public void close() throws IOException { + LOGGER.info("Cache warmer shutdown successfully"); + } + +} \ No newline at end of file diff --git a/lvl-project/lvl-service/src/main/java/eu/eubrazilcc/lvl/service/io/ImportSamplesTask.java b/lvl-project/lvl-service/src/main/java/eu/eubrazilcc/lvl/service/io/ImportSamplesTask.java index c296769b..612796cf 100644 --- a/lvl-project/lvl-service/src/main/java/eu/eubrazilcc/lvl/service/io/ImportSamplesTask.java +++ b/lvl-project/lvl-service/src/main/java/eu/eubrazilcc/lvl/service/io/ImportSamplesTask.java @@ -38,6 +38,7 @@ import static eu.eubrazilcc.lvl.storage.security.PermissionHelper.DATA_CURATOR_ROLE; import static java.util.concurrent.TimeUnit.MINUTES; import static org.slf4j.LoggerFactory.getLogger; +import static eu.eubrazilcc.lvl.core.conf.ConfigurationManager.CONFIG_MANAGER; import java.util.AbstractMap.SimpleImmutableEntry; import java.util.List; @@ -155,15 +156,15 @@ public Integer call() throws Exception { private List> importSplinkSubTasks(final SpeciesLinkConnector splink) { final List> subTasks = newArrayList(); setStatus("Counting collection items"); - final int count = (int)splink.count(collection.getKey()); + final int count = (int)splink.count(collection.getKey()); checkState(count > 0l, "It expected that the collection had elements"); pending.addAndGet(count); final Range range = Range.closedOpen(0, count); - final int STEP = 100; + final int STEP = CONFIG_MANAGER.getSpeciesLink().getMaxElements(); int i = 0; do { - subTasks.add(TASK_RUNNER.submit(importSplinkSubTask(splink, i, STEP))); - i += STEP; + subTasks.add(TASK_RUNNER.submit(importSplinkSubTask(splink, i, STEP))); + i += STEP; } while (range.contains(i)); LOGGER.trace(String.format("Collection %s items count: %d", collection.getValue(), count)); return subTasks; @@ -175,10 +176,10 @@ private Callable importSplinkSubTask(final SpeciesLinkConnector splink, private int expected = 0; @Override public Integer call() throws Exception { - setStatus(String.format("Fetching samples from %s", collection)); + setStatus(String.format("Fetching samples from %s", collection.getValue())); try { // fetch samples from remote data source - final SimpleDarwinRecordSet dwcSet = splink.fetch(collection.getKey(), start, limit); + final SimpleDarwinRecordSet dwcSet = splink.fetch(collection.getKey(), start, limit); // import samples into the local database if (dwcSet != null && dwcSet.getSimpleDarwinRecord() != null) { expected = dwcSet.getSimpleDarwinRecord().size(); @@ -193,9 +194,13 @@ public Integer call() throws Exception { } } if (catalogNumber != null) { - dao.insert(sample); - } - fetchCount++; + try { + dao.insert(sample); + fetchCount++; + } catch (Exception e) { + LOGGER.error("Failed to import sample", e); + } + } else fetchCount++; // update progress int fetchedCount = fetched.incrementAndGet(); setProgress(100.0d * fetchedCount / pending.get()); diff --git a/lvl-project/lvl-service/src/test/java/eu/eubrazilcc/lvl/service/testable/LeishmaniaSampleResourceTest.java b/lvl-project/lvl-service/src/test/java/eu/eubrazilcc/lvl/service/testable/LeishmaniaSampleResourceTest.java index 5a6e8796..bc6ae7bb 100644 --- a/lvl-project/lvl-service/src/test/java/eu/eubrazilcc/lvl/service/testable/LeishmaniaSampleResourceTest.java +++ b/lvl-project/lvl-service/src/test/java/eu/eubrazilcc/lvl/service/testable/LeishmaniaSampleResourceTest.java @@ -91,7 +91,7 @@ public void test() throws Exception { .withCollectionCode("Fiocruz-CLIOC") .withBasisOfRecord("L") .withOccurrenceID("523692851") - .withCatalogNumber("IOCL 0001") + .withCatalogNumber("IOCL 1001") .withRecordedBy("001 - Mauro Célio de Almeida Marzochi") .withYear(yearAsXMLGregorianCalendar(1979)) .withCountry("Brasil") diff --git a/lvl-project/lvl-service/src/test/java/eu/eubrazilcc/lvl/service/testable/TaskResourceTest.java b/lvl-project/lvl-service/src/test/java/eu/eubrazilcc/lvl/service/testable/TaskResourceTest.java index 7106d5ae..3c869e88 100644 --- a/lvl-project/lvl-service/src/test/java/eu/eubrazilcc/lvl/service/testable/TaskResourceTest.java +++ b/lvl-project/lvl-service/src/test/java/eu/eubrazilcc/lvl/service/testable/TaskResourceTest.java @@ -23,7 +23,6 @@ package eu.eubrazilcc.lvl.service.testable; import static com.google.common.collect.Lists.newArrayList; -import static eu.eubrazilcc.lvl.service.Task.TaskType.IMPORT_LEISHMANIA_SAMPLES; import static eu.eubrazilcc.lvl.service.Task.TaskType.IMPORT_SANDFLY_SEQ; import static eu.eubrazilcc.lvl.storage.oauth2.security.OAuth2Common.HEADER_AUTHORIZATION; import static eu.eubrazilcc.lvl.storage.oauth2.security.OAuth2SecurityManager.bearerHeader; @@ -64,9 +63,9 @@ public TaskResourceTest(final TestContext testCtxt) { super(testCtxt, TaskResourceTest.class, false); } - public void test() throws Exception { - // test import sandfly sequences from GenBank - final Path path = TaskResource.class.getAnnotation(Path.class); + public void test() throws Exception { + // test import sequences from GenBank + final Path path = TaskResource.class.getAnnotation(Path.class); Task task = Task.builder() .type(IMPORT_SANDFLY_SEQ) .ids(newArrayList("353470160", "353483325", "384562886")) @@ -76,19 +75,19 @@ public void test() throws Exception { .request() .header(HEADER_AUTHORIZATION, bearerHeader(testCtxt.token("root"))) .post(entity(task, APPLICATION_JSON)); - assertThat("Create import sandflies task response is not null", response, notNullValue()); - assertThat("Create import sandflies task response is CREATED", response.getStatus(), equalTo(CREATED.getStatusCode())); - assertThat("Create import sandflies task response is not empty", response.getEntity(), notNullValue()); + assertThat("Create import sequences task response is not null", response, notNullValue()); + assertThat("Create import sequences task response is CREATED", response.getStatus(), equalTo(CREATED.getStatusCode())); + assertThat("Create import sequences task response is not empty", response.getEntity(), notNullValue()); String payload = response.readEntity(String.class); - assertThat("Create import sandflies task response entity is not null", payload, notNullValue()); - assertThat("Create import sandflies task response entity is empty", isBlank(payload)); + assertThat("Create import sequences task response entity is not null", payload, notNullValue()); + assertThat("Create import sequences task response entity is empty", isBlank(payload)); // conditional output - printMsg(" >> Create import sandflies task response body (JSON), empty is OK: " + payload); - printMsg(" >> Create import sandflies task response JAX-RS object: " + response); - printMsg(" >> Create import sandflies task HTTP headers: " + response.getStringHeaders()); + printMsg(" >> Create import sequences task response body (JSON), empty is OK: " + payload); + printMsg(" >> Create import sequences task response JAX-RS object: " + response); + printMsg(" >> Create import sequences task HTTP headers: " + response.getStringHeaders()); URI location = new URI((String)response.getHeaders().get("Location").get(0)); - // test import sandflies task progress + // test import sequences task progress EventInput eventInput = testCtxt.target().path(path.value()) .path("progress") .path(getName(location.getPath())) @@ -111,13 +110,13 @@ public void test() throws Exception { assertThat("Progress event data is not empty", isNotBlank(data)); final Progress progress = testCtxt.jsonMapper().readValue(data, Progress.class); assertThat("Progress event decoded object is not null", progress, notNullValue()); - assertThat("Import sandflies task does not have errors", !progress.isHasErrors()); + assertThat("Import sequences task does not have errors", !progress.isHasErrors()); // conditional output printMsg(" >> Event [" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:S z").format(new Date()) + "]: id=" + id + "; name=" + name + "; data=" + data + "; object=" + progress); } - // repeat the import new sandflies task to test how the subscription is made from a client using the JavaScript EventSource interface + // repeat the import new sequences task to test how the subscription is made from a client using the JavaScript EventSource interface task = Task.builder() .type(IMPORT_SANDFLY_SEQ) .ids(newArrayList("430902590")) @@ -125,13 +124,13 @@ public void test() throws Exception { response = testCtxt.target().path(path.value()).request() .header(HEADER_AUTHORIZATION, bearerHeader(testCtxt.token("root"))) .post(entity(task, APPLICATION_JSON)); - assertThat("Create import sandflies task response is CREATED", response.getStatus(), equalTo(CREATED.getStatusCode())); - assertThat("Create import sandflies task response is not empty", response.getEntity(), notNullValue()); + assertThat("Create import sequences task response is CREATED", response.getStatus(), equalTo(CREATED.getStatusCode())); + assertThat("Create import sequences task response is not empty", response.getEntity(), notNullValue()); payload = response.readEntity(String.class); // conditional output - printMsg(" >> Create import sandflies task response body (JSON), empty is OK: " + payload); - printMsg(" >> Create import sandflies task response JAX-RS object: " + response); - printMsg(" >> Create import sandflies task HTTP headers: " + response.getStringHeaders()); + printMsg(" >> Create import sequences task response body (JSON), empty is OK: " + payload); + printMsg(" >> Create import sequences task response JAX-RS object: " + response); + printMsg(" >> Create import sequences task HTTP headers: " + response.getStringHeaders()); location = new URI((String)response.getHeaders().get("Location").get(0)); eventInput = testCtxt.target().path(path.value()) @@ -151,31 +150,33 @@ public void test() throws Exception { assertThat("Progress event data is not empty", isNotBlank(data)); final Progress progress = testCtxt.jsonMapper().readValue(data, Progress.class); assertThat("Progress event decoded object is not null", progress, notNullValue()); - assertThat("Import sandflies task does not have errors", !progress.isHasErrors()); + assertThat("Import sequences task does not have errors", !progress.isHasErrors()); // conditional output printMsg(" >> Event [" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:S z").format(new Date()) + "]: object=" + progress); } // test import samples from speciesLink task = Task.builder() - .type(IMPORT_LEISHMANIA_SAMPLES) + .type(eu.eubrazilcc.lvl.service.Task.TaskType.IMPORT_LEISHMANIA_SAMPLES) .ids(newArrayList("IOCL 0001")) + // .type(eu.eubrazilcc.lvl.service.Task.TaskType.IMPORT_SANDFLY_SAMPLES) + // .ids(newArrayList("051/75")) .build(); response = testCtxt.target().path(path.value()) .request() .header(HEADER_AUTHORIZATION, bearerHeader(testCtxt.token("root"))) .post(entity(task, APPLICATION_JSON)); - assertThat("Create import leishmania task response is not null", response, notNullValue()); - assertThat("Create import leishmania task response is CREATED", response.getStatus(), equalTo(CREATED.getStatusCode())); - assertThat("Create import leishmania task response is not empty", response.getEntity(), notNullValue()); + assertThat("Create import samples task response is not null", response, notNullValue()); + assertThat("Create import samples task response is CREATED", response.getStatus(), equalTo(CREATED.getStatusCode())); + assertThat("Create import samples task response is not empty", response.getEntity(), notNullValue()); payload = response.readEntity(String.class); - assertThat("Create import leishmania task response entity is not null", payload, notNullValue()); - assertThat("Create import leishmania task response entity is empty", isBlank(payload)); + assertThat("Create import samples task response entity is not null", payload, notNullValue()); + assertThat("Create import samples task response entity is empty", isBlank(payload)); // conditional output - printMsg(" >> Create import leishmania task response body (JSON), empty is OK: " + payload); - printMsg(" >> Create import leishmania task response JAX-RS object: " + response); - printMsg(" >> Create import leishmania task HTTP headers: " + response.getStringHeaders()); + printMsg(" >> Create import samples task response body (JSON), empty is OK: " + payload); + printMsg(" >> Create import samples task response JAX-RS object: " + response); + printMsg(" >> Create import samples task HTTP headers: " + response.getStringHeaders()); location = new URI((String)response.getHeaders().get("Location").get(0)); eventInput = testCtxt.target().path(path.value()) @@ -195,7 +196,7 @@ public void test() throws Exception { assertThat("Progress event data is not empty", isNotBlank(data)); final Progress progress = testCtxt.jsonMapper().readValue(data, Progress.class); assertThat("Progress event decoded object is not null", progress, notNullValue()); - assertThat("Import leishmania task does not have errors", !progress.isHasErrors()); + assertThat("Import samples task does not have errors", !progress.isHasErrors()); // conditional output printMsg(" >> Event [" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:S z").format(new Date()) + "]: object=" + progress); } diff --git a/lvl-project/lvl-storage/pom.xml b/lvl-project/lvl-storage/pom.xml index a0d7e3da..4b5bc4aa 100644 --- a/lvl-project/lvl-storage/pom.xml +++ b/lvl-project/lvl-storage/pom.xml @@ -27,7 +27,7 @@ that you distribute must include a readable copy of the "NOTICE" text file. eu.eubrazilcc.lvl lvl-project - 0.9.2 + 0.9.3 .. diff --git a/lvl-project/lvl-test/pom.xml b/lvl-project/lvl-test/pom.xml index 0fed98e0..24b00efd 100644 --- a/lvl-project/lvl-test/pom.xml +++ b/lvl-project/lvl-test/pom.xml @@ -27,7 +27,7 @@ that you distribute must include a readable copy of the "NOTICE" text file. eu.eubrazilcc.lvl lvl-project - 0.9.2 + 0.9.3 .. diff --git a/lvl-project/pom.xml b/lvl-project/pom.xml index a9f4c3ab..df0ec7e1 100644 --- a/lvl-project/pom.xml +++ b/lvl-project/pom.xml @@ -26,7 +26,7 @@ that you distribute must include a readable copy of the "NOTICE" text file. eu.eubrazilcc.lvl leishmaniasis-virtual-lab - 0.9.2 + 0.9.3 .. diff --git a/pom.xml b/pom.xml index 8c96e219..698e9780 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ that you distribute must include a readable copy of the "NOTICE" text file. eu.eubrazilcc.lvl leishmaniasis-virtual-lab - 0.9.2 + 0.9.3 pom leishmaniasis-virtual-laboratory - BOM