Interface GraphComputeService

  • All Superinterfaces:
    java.lang.AutoCloseable, VitamAutoCloseable, VitamCache<java.lang.String,​org.bson.Document>
    All Known Implementing Classes:
    GraphComputeServiceImpl

    public interface GraphComputeService
    extends VitamCache<java.lang.String,​org.bson.Document>, VitamAutoCloseable
    This class get units where calculated data are modified Zip generated files and store the zipped file in the offer.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String $_INC  
      static java.lang.String $_SET  
      static java.lang.String $_UNSET  
      static java.lang.Integer concurrencyLevel  
      static java.util.concurrent.ExecutorService executor  
      static int START_DEPTH  
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void bulkElasticsearch​(MetadataCollections metaDaCollection, java.util.List<org.bson.Document> collection)
      Bulk save in elasticsearch
      void bulkElasticsearch​(MetadataCollections metaDaCollection, java.util.Set<java.lang.String> collection)
      Bulk save in elasticsearch
      void bulkUpdateMongo​(MetadataCollections metaDaCollection, java.util.List<com.mongodb.client.model.WriteModel<org.bson.Document>> collection)
      Bulk write in mongodb
      GraphComputeResponse computeGraph​(com.fasterxml.jackson.databind.JsonNode queryDSL)
      If workflow of compute graph in progress, do not execute this method Should be exposed in the API
      default void computeGraph​(MetadataCollections metadataCollections, java.util.List<org.bson.Document> documents, boolean invalidateComputedInheritedRules)
      Generic method to calculate graph for unit and object group
      GraphComputeResponse computeGraph​(MetadataCollections metadataCollections, java.util.Set<java.lang.String> unitsId, boolean computeObjectGroupGraph, boolean invalidateComputedInheritedRules)
      Compute graph for unit/got from all parents
      default void computeObjectGroupGraph​(java.util.Set<java.lang.String> originatingAgencies, java.util.Set<java.lang.String> unitParents, java.util.List<java.lang.String> up)
      For ObjectGroup, we only get graph data (sps) from only unit represents (up) We do not loop over all parent of parent until root units As not concurrence expected, no problem of inconsistency, Else, if parallel compute is needed, then, we have to loop over all units (until root units) or to implements optimistic lock on _glpd
      default com.mongodb.client.model.UpdateOneModel<org.bson.Document> computeObjectGroupGraph​(org.bson.Document document)
      Create update model for ObjectGroup
      default com.mongodb.client.model.UpdateOneModel<org.bson.Document> computeUnitGraph​(org.bson.Document document, boolean invalidateComputedInheritedRules)
      Create update model for Unit
      default void computeUnitGraphUsingDirectParents​(java.util.List<GraphRelation> graphRels, java.lang.String unitId, java.util.List<java.lang.String> up, int currentDepth)
      Recursive method that compute graph using only _up With global (by reference variable graphRels, we get all needed informations from all parent of the given unit unitId.
      boolean isInProgress()  
      default void preLoadCache​(java.util.List<org.bson.Document> documents)
      Get data from database and pre-populate unitCache
    • Method Detail

      • computeGraph

        GraphComputeResponse computeGraph​(com.fasterxml.jackson.databind.JsonNode queryDSL)
                                   throws MetaDataException
        If workflow of compute graph in progress, do not execute this method Should be exposed in the API
        Returns:
        the map of collection:number of treated documents
        Throws:
        MetaDataException
      • computeGraph

        GraphComputeResponse computeGraph​(MetadataCollections metadataCollections,
                                          java.util.Set<java.lang.String> unitsId,
                                          boolean computeObjectGroupGraph,
                                          boolean invalidateComputedInheritedRules)
        Compute graph for unit/got from all parents
        Parameters:
        metadataCollections - the collection concerned by the build of the graph
        unitsId - the collection of units subject of computing graph
        computeObjectGroupGraph - true mean compute graph
        invalidateComputedInheritedRules -
        Returns:
        The collection of object group treated or to be treated bu an other process. This collection contains got's id of concerning units. Empty collection is returned if computeGraph of object group.
      • preLoadCache

        default void preLoadCache​(java.util.List<org.bson.Document> documents)
                           throws MetaDataException
        Get data from database and pre-populate unitCache
        Parameters:
        documents -
        Throws:
        MetaDataException
      • computeGraph

        default void computeGraph​(MetadataCollections metadataCollections,
                                  java.util.List<org.bson.Document> documents,
                                  boolean invalidateComputedInheritedRules)
                           throws MetaDataException
        Generic method to calculate graph for unit and object group
        Parameters:
        metadataCollections - the type the collection (Unit or ObjectGroup)
        documents - the concerning collection of documents
        invalidateComputedInheritedRules -
        Throws:
        MetaDataException
      • computeUnitGraph

        default com.mongodb.client.model.UpdateOneModel<org.bson.Document> computeUnitGraph​(org.bson.Document document,
                                                                                            boolean invalidateComputedInheritedRules)
                                                                                     throws VitamRuntimeException
        Create update model for Unit
        Parameters:
        document -
        Returns:
        UpdateOneModel for Unit
        Throws:
        MetaDataException
        VitamRuntimeException
      • computeObjectGroupGraph

        default com.mongodb.client.model.UpdateOneModel<org.bson.Document> computeObjectGroupGraph​(org.bson.Document document)
                                                                                            throws VitamRuntimeException
        Create update model for ObjectGroup
        Parameters:
        document -
        Returns:
        UpdateOneModel for ObjectGroup
        Throws:
        MetaDataException
        VitamRuntimeException
      • computeUnitGraphUsingDirectParents

        default void computeUnitGraphUsingDirectParents​(java.util.List<GraphRelation> graphRels,
                                                        java.lang.String unitId,
                                                        java.util.List<java.lang.String> up,
                                                        int currentDepth)
                                                 throws VitamRuntimeException
        Recursive method that compute graph using only _up With global (by reference variable graphRels, we get all needed informations from all parent of the given unit unitId.
        Parameters:
        graphRels -
        unitId -
        up -
        currentDepth - the current depth, initially equals to 1
        Throws:
        java.util.concurrent.ExecutionException
        VitamRuntimeException
      • computeObjectGroupGraph

        default void computeObjectGroupGraph​(java.util.Set<java.lang.String> originatingAgencies,
                                             java.util.Set<java.lang.String> unitParents,
                                             java.util.List<java.lang.String> up)
                                      throws VitamRuntimeException
        For ObjectGroup, we only get graph data (sps) from only unit represents (up) We do not loop over all parent of parent until root units As not concurrence expected, no problem of inconsistency, Else, if parallel compute is needed, then, we have to loop over all units (until root units) or to implements optimistic lock on _glpd
        Parameters:
        originatingAgencies -
        unitParents -
        up -
        Throws:
        VitamRuntimeException
      • bulkUpdateMongo

        void bulkUpdateMongo​(MetadataCollections metaDaCollection,
                             java.util.List<com.mongodb.client.model.WriteModel<org.bson.Document>> collection)
                      throws DatabaseException
        Bulk write in mongodb
        Parameters:
        metaDaCollection -
        collection -
        Throws:
        DatabaseException
      • bulkElasticsearch

        void bulkElasticsearch​(MetadataCollections metaDaCollection,
                               java.util.Set<java.lang.String> collection)
                        throws DatabaseException
        Bulk save in elasticsearch
        Parameters:
        metaDaCollection -
        collection - of id of documents
        Throws:
        DatabaseException
      • bulkElasticsearch

        void bulkElasticsearch​(MetadataCollections metaDaCollection,
                               java.util.List<org.bson.Document> collection)
                        throws DatabaseException
        Bulk save in elasticsearch
        Parameters:
        metaDaCollection -
        collection - of documents
        Throws:
        DatabaseException
      • isInProgress

        boolean isInProgress()