Difference between revisions of "Motu Client Java"

From Gcube Wiki
Jump to: navigation, search
(Usage)
(Retrieving the product catalogue)
Line 60: Line 60:
  
 
   // the oldest timestamp in the dataset
 
   // the oldest timestamp in the dataset
   Calendar start = getFirstAvailableTimeCode();
+
   Calendar start = product.getFirstAvailableTimeCode();
  
 
   // the most recent timestamp in the dataset
 
   // the most recent timestamp in the dataset
   Calendar start = getLastAvailableTimeCode();
+
   Calendar end = product.getLastAvailableTimeCode();
  
 
   // get the time resolution of the dataset (in hours)
 
   // get the time resolution of the dataset (in hours)
   Long hours = getTimeResolution();
+
   Long hours = product.getTimeResolution();
  
 
   // get a list of depths for which there are data available
 
   // get a list of depths for which there are data available
   List<Double> depths = getAvailableDepths();
+
   List<Double> depths = product.getAvailableDepths();
 +
 
 +
  // get the lowest depth value (i.e. closer to the surface)
 +
  Double depth = product.getFirstAvailableDepth();
 +
 
 +
  // get the highest depth value (i.e. the deeper level)
 +
  Double depth = product.getLastAvailableDepth();
 +
 
 +
  // get the set of variables in the dataset
 +
  Collection<Variable> variables = product.getVariables();
  
 
</source>
 
</source>

Revision as of 16:57, 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 = product.getFirstAvailableTimeCode();
 
  // the most recent timestamp in the dataset
  Calendar end = product.getLastAvailableTimeCode();
 
  // get the time resolution of the dataset (in hours)
  Long hours = product.getTimeResolution();
 
  // get a list of depths for which there are data available
  List<Double> depths = product.getAvailableDepths();
 
  // get the lowest depth value (i.e. closer to the surface)
  Double depth = product.getFirstAvailableDepth();
 
  // get the highest depth value (i.e. the deeper level)
  Double depth = product.getLastAvailableDepth();
 
  // get the set of variables in the dataset
  Collection<Variable> variables = product.getVariables();

Under the hood

TODO

References