Class DataSourceService


  • public final class DataSourceService
    extends java.lang.Object
    DataSourceService
    • Method Detail

      • getDataSources

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

        public static DataSource getDataSource​(java.lang.String strId)
        Get a Data Source from its ID
        Parameters:
        strId - The ID
        Returns:
        The Data Source
      • processFullIndexing

        public static void processFullIndexing​(DataSource dataSource,
                                               boolean bReset)
        Insert data from a DataSource into Elastic Search
        Parameters:
        sbLogs - A log buffer
        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​(java.lang.StringBuilder sbLogs,
                                                      DataSource dataSource,
                                                      java.util.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,
                                         java.lang.String strId,
                                         java.lang.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,
                                         java.lang.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,
                                      java.lang.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 java.lang.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 java.lang.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,
                                                          java.util.List<DataObject> dataObjectList)
        Complete the data source with the external attributes and set elastic docuement id
        Parameters:
        dataSource - the data source
        dataObject - the data object
      • getIdDocument

        public static java.lang.String getIdDocument​(java.lang.String strIdDataSource,
                                                     java.lang.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,
                                        java.util.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