Class DatalakeStorage

java.lang.Object
com.michelin.cert.redscan.utils.datalake.DatalakeStorage

public class DatalakeStorage extends Object
Datalake storage.
Author:
Maxime ESCOURBIAC, Axel REMACK
  • Method Details

    • init

      public static void init(String elasticSearchUrl, String elasticSearchUser, String elasticSearchPassword)
      Init the datalake storage.
      Parameters:
      elasticSearchUrl - Elastic Search url (ex: http://10.124.2.25:9200 )
      elasticSearchUser - Elastic Search user.
      elasticSearchPassword - Elastic Search password.
    • getObjects

      public static kong.unirest.json.JSONObject getObjects(DatalakeStorageItem item, kong.unirest.json.JSONObject query, kong.unirest.json.JSONObject sort) throws DatalakeStorageException
      Search objects with sorting.
      Parameters:
      item - Datalake storage item.
      query - Elastic search query.
      sort - Elastic sort query.
      Returns:
      Objects corresponding to the query.
      Throws:
      DatalakeStorageException - Exception with the storage.
    • getObjects

      public static kong.unirest.json.JSONObject getObjects(DatalakeStorageItem item, kong.unirest.json.JSONObject query) throws DatalakeStorageException
      Search objects.
      Parameters:
      item - Datalake storage item.
      query - Elastic search query.
      Returns:
      Objects corresponding to the query.
      Throws:
      DatalakeStorageException - Exception with the storage.
    • getObjects

      public static kong.unirest.json.JSONObject getObjects(String index, kong.unirest.json.JSONObject query, kong.unirest.json.JSONObject sort) throws DatalakeStorageException
      Search objects.
      Parameters:
      index - ElasticSearch index.
      query - Elastic search query.
      sort - Elastic sort query.
      Returns:
      Objects corresponding to the query.
      Throws:
      DatalakeStorageException - Exception with the storage.
    • getObjects

      public static kong.unirest.json.JSONObject getObjects(DatalakeStorageItem item, kong.unirest.json.JSONObject query, String page, String size, kong.unirest.json.JSONObject sort) throws DatalakeStorageException
      Search objects with sorting and pagination.
      Parameters:
      item - Datalake storage item.
      query - Elastic search query.
      page - Page number.
      size - Number of items in each page.
      sort - Elastic sort query.
      Returns:
      Objects corresponding to the query.
      Throws:
      DatalakeStorageException - Exception with the storage.
    • getObjects

      public static kong.unirest.json.JSONObject getObjects(DatalakeStorageItem item, kong.unirest.json.JSONObject query, String page, String size) throws DatalakeStorageException
      Search objects with pagination.
      Parameters:
      item - Datalake storage item.
      query - Elastic search query.
      page - Page number.
      size - Number of items in each page.
      Returns:
      Objects corresponding to the query.
      Throws:
      DatalakeStorageException - Exception with the storage.
    • getObjects

      public static kong.unirest.json.JSONObject getObjects(String index, kong.unirest.json.JSONObject query, String page, String size, kong.unirest.json.JSONObject sort) throws DatalakeStorageException
      Search objects with pagination.
      Parameters:
      index - ElasticSearch index.
      query - Elastic search query.
      page - Page number.
      size - Number of items in each page.
      sort - Elastic sort query.
      Returns:
      Objects corresponding to the query.
      Throws:
      DatalakeStorageException - Exception with the storage.
    • getObject

      public static kong.unirest.json.JSONObject getObject(DatalakeStorageItem item) throws DatalakeStorageException
      Retrieve an object from Elastic search.
      Parameters:
      item - Item model to retrieve.
      Returns:
      The object corresponding to the model.
      Throws:
      DatalakeStorageException - Exception with the storage.
    • getObject

      public static kong.unirest.json.JSONObject getObject(DatalakeStorageItem item, String id) throws DatalakeStorageException
      Retrieve an object from Elastic search.
      Parameters:
      item - Item model to retrieve.
      id - Item id.
      Returns:
      The object corresponding to the model.
      Throws:
      DatalakeStorageException - Exception with the storage.
    • getObject

      public static kong.unirest.json.JSONObject getObject(String index, String id) throws DatalakeStorageException
      Retrieve an object from Elastic search.
      Parameters:
      index - ElasticSearch index.
      id - Item id.
      Returns:
      The object corresponding to the model.
      Throws:
      DatalakeStorageException - Exception with the storage.
    • createObject

      public static boolean createObject(DatalakeStorageItem item) throws DatalakeStorageException
      Insert a new object in ElasticSearch.
      Parameters:
      item - Item model to create.
      Returns:
      True if the creation is successful.
      Throws:
      DatalakeStorageException - Exception with the storage.
    • createObject

      public static boolean createObject(String index, String id) throws DatalakeStorageException
      Insert a new object in ElasticSearch.
      Parameters:
      index - ElasticSearch index.
      id - Item id.
      Returns:
      True if the creation is successful.
      Throws:
      DatalakeStorageException - Exception with the storage.
    • createObject

      public static boolean createObject(String index, String id, kong.unirest.json.JSONObject jsonObject) throws DatalakeStorageException
      Insert a new object in ElasticSearch.
      Parameters:
      index - ElasticSearch index.
      id - Item id.
      jsonObject - Initial JSON object
      Returns:
      True if the creation is successful.
      Throws:
      DatalakeStorageException - Exception with the storage.
    • deleteObject

      public static boolean deleteObject(DatalakeStorageItem item) throws DatalakeStorageException
      Delete an object from ElasticSearch.
      Parameters:
      item - Item model to delete.
      Returns:
      True if the deletion is successful.
      Throws:
      DatalakeStorageException - Exception with the storage.
    • deleteObject

      public static boolean deleteObject(String index, String id) throws DatalakeStorageException
      Delete an object from ElasticSearch.
      Parameters:
      index - ElasticSearch index.
      id - Item id.
      Returns:
      True if the deletion is successful.
      Throws:
      DatalakeStorageException - Exception with the storage.
    • upsertObjectField

      public static boolean upsertObjectField(DatalakeStorageItem item, String key, Object value) throws DatalakeStorageException
      Insert or Update a specific field for an object.
      Parameters:
      item - Item model to upsert.
      key - Key to upsert.
      value - Value to upsert.
      Returns:
      True if the upsertion was successful.
      Throws:
      DatalakeStorageException - Exception with the storage.
    • upsertObjectField

      public static boolean upsertObjectField(String index, String id, String key, Object value) throws DatalakeStorageException
      Insert or Update a specific field for an object.
      Parameters:
      index - ElasticSearch index.
      id - Item id.
      key - Key to upsert.
      value - Value to upsert.
      Returns:
      True if the upsertion was successful.
      Throws:
      DatalakeStorageException - Exception with the storage.
    • removeObjectField

      public static boolean removeObjectField(DatalakeStorageItem item, String key) throws DatalakeStorageException
      Remove a specific field for an object.
      Parameters:
      item - Item model to upsert.
      key - Key to delete.
      Returns:
      True if the deletion was successful.
      Throws:
      DatalakeStorageException - Exception with the storage.