Difference between revisions of "Motu Client Java"

From Gcube Wiki
Jump to: navigation, search
(Usage)
(Usage)
Line 33: Line 33:
 
<source lang="java5" highlight="4">
 
<source lang="java5" highlight="4">
 
   client.setPreferredDownloadSize(20*SizeUtils.MB);
 
   client.setPreferredDownloadSize(20*SizeUtils.MB);
 +
</source>
 +
 +
== Retrieving the product catalogue ==
 +
 +
A catalogue containing all services published by the Motu server can be obtained with:
 +
 +
<source lang="java5" highlight="4">
 +
  MotuCatalogue catalogue = client.getCatalogue();
 +
  Collection<ServiceMetadata> services = catalogue.getServices();
 +
</source>
 +
 +
A service usually contain different products (datasets). Typically there are products for different time resolution and/or different variables.
 +
 +
<source lang="java5" highlight="4">
 +
  // get the list of products for a service
 +
  Collection<ProductMetadataInfo> products = service.getProducts();
 +
</source>
 +
 +
Product metadata can be obtained with:
 +
 +
<source lang="java5" highlight="4">
 +
  ProductMetadataInfo product = ...;
 +
 +
  // get timestamps for which there are data available
 +
  List<Calendar> times = product.getAvailableTimeCodes();
 +
 +
  // the oldest timestamp in the dataset
 +
  Calendar start = getFirstAvailableTimeCode();
 +
 +
  // the most recent timestamp in the dataset
 +
  Calendar start = getLastAvailableTimeCode();
 +
 +
  // get the time resolution of the dataset (in hours)
 +
  Long hours = getTimeResolution();
 +
 +
  // get a list of depths for which there are data available
 +
  List<Double> depths = getAvailableDepths();
 +
 
</source>
 
</source>
  

Revision as of 17:54, 29 November 2017

Overview

Usage

Configure your project

Maven coordinates:

  <dependency>
    <groupId>org.gcube.dataanalysis</groupId>
    <artifactId>motu-client</artifactId>
    <version>[1.0.0, 2.0.0)</version>
  </dependency>

Create a client

As a first step, you need to create a MotuClient object providing enough information to connect to the corresponding server:

  MotuClient client = new MotuClient("server endpoint");
  client.setUsername("username");
  client.setPassword("password");

Setting the preferred download size

You can optionally specify the size of chunks to be downloaded. If not provided, the client will use the maximum size allowed by the server (currently most servers allow between 1 and 2 GB).

  client.setPreferredDownloadSize(20*SizeUtils.MB);

Retrieving the product catalogue

A catalogue containing all services published by the Motu server can be obtained with:

  MotuCatalogue catalogue = client.getCatalogue();
  Collection<ServiceMetadata> services = catalogue.getServices();

A service usually contain different products (datasets). Typically there are products for different time resolution and/or different variables.

  // get the list of products for a service
  Collection<ProductMetadataInfo> products = service.getProducts();

Product metadata can be obtained with:

  ProductMetadataInfo product = ...;
 
  // get timestamps for which there are data available
  List<Calendar> times = product.getAvailableTimeCodes(); 
  // the oldest timestamp in the dataset
  Calendar start = getFirstAvailableTimeCode();
 
  // the most recent timestamp in the dataset
  Calendar start = getLastAvailableTimeCode();
 
  // get the time resolution of the dataset (in hours)
  Long hours = getTimeResolution();
 
  // get a list of depths for which there are data available
  List<Double> depths = getAvailableDepths();

Under the hood

TODO

References