Class DatalakeStorage
java.lang.Object
com.michelin.cert.redscan.utils.datalake.DatalakeStorage
Datalake storage.
- Author:
- Maxime ESCOURBIAC, Axel REMACK
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanInsert a new object in ElasticSearch.static booleancreateObject(String index, String id) Insert a new object in ElasticSearch.static booleancreateObject(String index, String id, kong.unirest.json.JSONObject jsonObject) Insert a new object in ElasticSearch.static booleanDelete an object from ElasticSearch.static booleandeleteObject(String index, String id) Delete an object from ElasticSearch.static kong.unirest.json.JSONObjectgetObject(DatalakeStorageItem item) Retrieve an object from Elastic search.static kong.unirest.json.JSONObjectgetObject(DatalakeStorageItem item, String id) Retrieve an object from Elastic search.static kong.unirest.json.JSONObjectRetrieve an object from Elastic search.static kong.unirest.json.JSONObjectgetObjects(DatalakeStorageItem item, kong.unirest.json.JSONObject query) Search objects.static kong.unirest.json.JSONObjectgetObjects(DatalakeStorageItem item, kong.unirest.json.JSONObject query, String page, String size) Search objects with pagination.static kong.unirest.json.JSONObjectgetObjects(DatalakeStorageItem item, kong.unirest.json.JSONObject query, String page, String size, kong.unirest.json.JSONObject sort) Search objects with sorting and pagination.static kong.unirest.json.JSONObjectgetObjects(DatalakeStorageItem item, kong.unirest.json.JSONObject query, kong.unirest.json.JSONObject sort) Search objects with sorting.static kong.unirest.json.JSONObjectgetObjects(String index, kong.unirest.json.JSONObject query, String page, String size, kong.unirest.json.JSONObject sort) Search objects with pagination.static kong.unirest.json.JSONObjectgetObjects(String index, kong.unirest.json.JSONObject query, kong.unirest.json.JSONObject sort) Search objects.static voidInit the datalake storage.static booleanremoveObjectField(DatalakeStorageItem item, String key) Remove a specific field for an object.static booleanupsertObjectField(DatalakeStorageItem item, String key, Object value) Insert or Update a specific field for an object.static booleanupsertObjectField(String index, String id, String key, Object value) Insert or Update a specific field for an object.
-
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
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
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
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
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.
-