Interface DBSConnection

    • Method Detail

      • close

        void close()
        Closes this connection.
        Specified by:
        close in interface AutoCloseable
      • getRootId

        String getRootId()
        Gets the root id.
        Returns:
        the root id.
      • generateNewId

        String generateNewId()
        Generates a new id for a document.
        Returns:
        the new id
      • readState

        State readState​(String id)
        Reads the state of a document.
        Parameters:
        id - the document id
        Returns:
        the document state, or null if not found
      • readPartialState

        default State readPartialState​(String id,
                                       Collection<String> keys)
        Reads the partial state of a document.
        Parameters:
        id - the document id
        keys - the keys to read
        Returns:
        the document partial state, or null if not found
        Since:
        9.10
      • readStates

        List<State> readStates​(List<String> ids)
        Reads the states of several documents.

        The returned states may be in a different order than the ids.

        Parameters:
        ids - the document ids
        Returns:
        the document states, an element by be null if not found
      • createState

        void createState​(State state)
        Creates a document.
        Parameters:
        state - the document state
      • createStates

        default void createStates​(List<State> states)
        Creates documents.
        Parameters:
        states - the document states
      • deleteStates

        void deleteStates​(Set<String> ids)
        Deletes a set of document.
        Parameters:
        ids - the document ids
      • readChildState

        State readChildState​(String parentId,
                             String name,
                             Set<String> ignored)
        Reads the state of a child document.
        Parameters:
        parentId - the parent document id
        name - the name of the child
        ignored - a set of document ids that should not be considered
        Returns:
        the state of the child document, or null if not found
      • hasChild

        boolean hasChild​(String parentId,
                         String name,
                         Set<String> ignored)
        Checks if a document has a child with the given name
        Parameters:
        parentId - the parent document id
        name - the name of the child
        ignored - a set of document ids that should not be considered
        Returns:
        true if the child exists, false if not
      • queryKeyValue

        List<State> queryKeyValue​(String key,
                                  Object value,
                                  Set<String> ignored)
        Queries the repository for documents having key = value.
        Parameters:
        key - the key
        value - the value
        ignored - a set of document ids that should not be considered
        Returns:
        the document states matching the query
      • queryKeyValue

        List<State> queryKeyValue​(String key1,
                                  Object value1,
                                  String key2,
                                  Object value2,
                                  Set<String> ignored)
        Queries the repository for documents having key1 = value1 and key2 = value2.
        Parameters:
        key1 - the first key
        value1 - the first value
        key2 - the second key
        value2 - the second value
        ignored - a set of document ids that should not be considered
        Returns:
        the document states matching the query
      • queryKeyValueWithOperator

        List<State> queryKeyValueWithOperator​(String key1,
                                              Object value1,
                                              String key2,
                                              DBSConnection.DBSQueryOperator operator,
                                              Object value2,
                                              Set<String> ignored)
        Queries the repository for documents having key1 = value1 and key2 ${operator} value2.
        Parameters:
        key1 - the first key
        value1 - the first value
        key2 - the second key
        operator - the operator to apply between key2 and value2
        value2 - the second value
        ignored - a set of document ids that should not be considered
        Returns:
        the document states matching the query
        Since:
        11.1
      • getDescendants

        Stream<State> getDescendants​(String id,
                                     Set<String> keys)
        Returns a stream of descendants from a given root document, in no particular order. This does not include information about the root document itself.

        THE STREAM MUST BE CLOSED WHEN DONE to release resources.

        Parameters:
        id - the root document id
        keys - what to collect about the descendants in addition to their ids
        Returns:
        a stream of States; THE STREAM MUST BE CLOSED WHEN DONE
        Since:
        9.3
      • getDescendants

        default Stream<State> getDescendants​(String id,
                                             Set<String> keys,
                                             int limit)
        Returns a stream of descendants from a given root document, in no particular order. This does not include information about the root document itself.

        THE STREAM MUST BE CLOSED WHEN DONE to release resources.

        Parameters:
        id - the root document id
        keys - what to collect about the descendants in addition to their ids
        limit - the maximum number of descendants to return
        Returns:
        a stream of States; THE STREAM MUST BE CLOSED WHEN DONE
        Since:
        9.10
      • queryKeyValuePresence

        boolean queryKeyValuePresence​(String key,
                                      String value,
                                      Set<String> ignored)
        Queries the repository to check if there are documents having key = value.
        Parameters:
        key - the key
        value - the value
        ignored - a set of document ids that should not be considered
        Returns:
        true if the query matches at least one document, false if the query matches nothing
      • queryAndFetch

        PartialList<Map<String,​Serializable>> queryAndFetch​(DBSExpressionEvaluator evaluator,
                                                                  OrderByClause orderByClause,
                                                                  boolean distinctDocuments,
                                                                  int limit,
                                                                  int offset,
                                                                  int countUpTo)
        Queries the repository for documents matching a NXQL query, and returns a projection of the documents.
        Parameters:
        evaluator - the map-based evaluator for the query
        orderByClause - an ORDER BY clause
        distinctDocuments - true if the projection should return a maximum of one row per document
        limit - the limit on the number of documents to return
        offset - the offset in the list of documents to return
        countUpTo - if -1, count the total size without offset/limit.
        If 0, don't count the total size, set it to -1 .
        If n, count the total number if there are less than n documents otherwise set the total size to -2.
        Returns:
        a partial list of maps containing the NXQL projections requested, and the total size according to countUpTo
      • scroll

        ScrollResult<String> scroll​(DBSExpressionEvaluator evaluator,
                                    int batchSize,
                                    int keepAliveSeconds)
        Executes the given query and returns the first batch of results containing id of documents, next batch must be requested within the keepAliveSeconds delay.
        Since:
        8.4
      • scroll

        ScrollResult<String> scroll​(String scrollId)
        Get the next batch of results containing id of documents, the scrollId is part of the previous ScrollResult response.
        Since:
        8.4