Class DataSourceService

java.lang.Object
fr.paris.lutece.plugins.elasticdata.service.DataSourceService

public final class DataSourceService extends Object
DataSourceService
  • Method Details

    • getDataSources

      public static Collection<DataSource> getDataSources()
      Gets all data sources found into Spring context files
      Returns:
      The list
    • getDataSource

      public static DataSource getDataSource(String strId)
      Get a Data Source from its ID. The data sources are loaded at the first call, whichever method is called first.
      Parameters:
      strId - The ID
      Returns:
      The Data Source, or null if no data source has this ID
    • processFullIndexing

      public static void processFullIndexing(DataSource dataSource, boolean bReset)
      Insert data from a DataSource into Elastic Search
      Parameters:
      dataSource - The data source
      bReset - if the index should be reset before inserting
      Throws:
      fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException - If an error occurs accessing to ElasticSearch
    • processIncrementalIndexing

      public static void processIncrementalIndexing(DataSource dataSource, DataObject dataObject) throws fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException
      Insert one dataObject from a DataSource into Elastic Search
      Parameters:
      dataSource - The data source
      dataObject - The data object
      Throws:
      fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException - If an error occurs accessing to ElasticSearch
    • processIncrementalIndexing

      public static void processIncrementalIndexing(StringBuilder sbLogs, DataSource dataSource, Collection<DataObject> dataObject) throws fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException
      Insert a dataObject from a DataSource into Elastic Search
      Parameters:
      sbLogs - A log buffer
      dataSource - The data source
      dataObject - The collection of data object
      Throws:
      fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException
    • partialUpdate

      public static void partialUpdate(DataSource dataSource, String strId, Object object) throws fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException
      Partial Updates to Documents
      Parameters:
      dataSource - The data source
      strId - The document id
      object - The object
      Throws:
      fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException - Exception If an error occurs accessing to ElasticSearch
    • deleteByQuery

      public static void deleteByQuery(DataSource dataSource, String strQuery) throws fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException
      Delete a documents by Query
      Parameters:
      dataSource - the data source
      strQuery - the query
      Throws:
      fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException - Exception If an error occurs accessing to ElasticSearch
    • deleteById

      public static void deleteById(DataSource dataSource, String strId) throws fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException
      Delete a document based on its id in the index
      Parameters:
      dataSource - The data source
      strId - The id
      Throws:
      fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException - Exception If an error occurs accessing to ElasticSearch
    • insertDataAllDatasources

      public static String insertDataAllDatasources(boolean bReset)
      Insert All data sources
      Parameters:
      bReset - Reset the index before inserting
      Returns:
      The logs of the process
      Throws:
      fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException - If an error occurs accessing to ElasticSearch
    • insertDataAllDatasources

      public static String insertDataAllDatasources(boolean bReset, boolean bDaemon)
      Insert All data sources
      Parameters:
      bReset - Reset the index before inserting
      bDaemon - If called by a daemon
      Returns:
      The logs of the process
    • getElastic

      public static fr.paris.lutece.plugins.libraryelastic.util.Elastic getElastic()
      Return elastic connection
    • completeDataObjectWithFullData

      public static void completeDataObjectWithFullData(DataSource dataSource, DataObject dataObject)
      Complete the data source with the external attributes and set elastic docuement id
      Parameters:
      dataSource - the data source
      dataObject - the data object
    • completeDataObjectWithFullData

      public static void completeDataObjectWithFullData(DataSource dataSource, List<DataObject> dataObjectList)
      Complete the data source with the external attributes and set elastic docuement id
      Parameters:
      dataSource - the data source
      dataObjectList - the data object list
    • getIdDocument

      public static String getIdDocument(String strIdDataSource, String strIdDataObject)
      Return the unique id of the elastic document
      Parameters:
      strIdDataSource - the data source id
      strIdDataObject - the data object id
    • insertObjects

      public static int insertObjects(fr.paris.lutece.plugins.libraryelastic.util.Elastic elastic, DataSource dataSource, Iterator<DataObject> iterateDataObjects) throws fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException
      Insert a list of object in bulk mode
      Parameters:
      elastic - The Elastic Server
      dataSource - The data source
      iterateDataObjects - The iterator of objects
      Returns:
      the number of documents posted
      Throws:
      fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException - If a problem occurs connecting the server
    • updateIndexingStatus

      public static void updateIndexingStatus(DataSource dataSource, int nCount)
      Update indexing status of the datasource
      Parameters:
      dataSource - the data source
      nCount - the count of objects processed