java.lang.Object
org.odpi.openmetadata.adapters.repositoryservices.xtdb.repositoryconnector.readops.AbstractReadOperation
org.odpi.openmetadata.adapters.repositoryservices.xtdb.repositoryconnector.readops.AbstractGraphOperation
Direct Known Subclasses:
GetEntityNeighborhood, GetLinkingEntities, GetRelatedEntities

public abstract class AbstractGraphOperation extends AbstractReadOperation
Base class that all graph operations should implement.
  • Field Details

    • startEntityGUID

      protected final String startEntityGUID
    • limitResultsByStatus

      protected final List<InstanceStatus> limitResultsByStatus
  • Constructor Details

    • AbstractGraphOperation

      protected AbstractGraphOperation(XTDBOMRSRepositoryConnector xtdb, String startEntityGUID, List<InstanceStatus> limitResultsByStatus, Date asOfTime)
      Create a new search operation.
      Parameters:
      xtdb - connectivity to XTDB
      startEntityGUID - unique identifier of the starting entity for the traversal
      limitResultsByStatus - list of statuses by which to limit results
      asOfTime - the point-in-time for which to retrieve results
  • Method Details

    • findNeighborhood

      protected InstanceGraph findNeighborhood(xtdb.api.IXtdbDatasource db, List<String> entityTypeGUIDs, List<String> relationshipTypeGUIDs, List<String> limitResultsByClassification, int level, boolean includeRelationships) throws EntityNotKnownException, RepositoryErrorException
      Find the entities and relationships that radiate out from the supplied entity GUID. The results are scoped by the provided type GUIDs, other limiters, and the level.
      Parameters:
      db - already-opened point-in-time view of the datasource from which to retrieve
      entityTypeGUIDs - list of entity types to include in the query results (null means include all)
      relationshipTypeGUIDs - list of relationship types to include in the query results (null means include all)
      limitResultsByClassification - list of classifications that must be present on all returned entities
      level - the number of relationships out from the starting entity that
      includeRelationships - whether to include relationships in the resulting graph (true) or not (false)
      Returns:
      InstanceGraph of the neighborhood
      Throws:
      EntityNotKnownException - if the starting point of the neighborhood traversals cannot be found in the repository
      RepositoryErrorException - if any issue closing open XTDB resources, or if the query runs longer than the defined threshold (default: 30s)
    • getNextLevelNeighbors

      protected Set<List<?>> getNextLevelNeighbors(xtdb.api.IXtdbDatasource db, List<String> startingPoints, List<String> entityTypeGUIDs, List<String> relationshipTypeGUIDs, List<InstanceStatus> limitResultsByStatus, List<String> limitResultsByClassification, Set<String> entityGUIDsVisited, Set<String> relationshipGUIDsVisited) throws RepositoryTimeoutException
      Find the entities and relationships that radiate out directly from the supplied list of entity GUIDs. The results are scoped by the provided type GUIDs, other limiters, and the level.
      Parameters:
      db - already opened point-in-time view of the database
      startingPoints - list of entity GUIDs from which we should start radiating outwards
      entityTypeGUIDs - list of entity types to include in the query results (null means include all)
      relationshipTypeGUIDs - list of relationship types to include in the query results (null means include all)
      limitResultsByStatus - list of statuses to restrict results (null means include all)
      limitResultsByClassification - list of classifications that must be present on all returned entities
      entityGUIDsVisited - set of unique identifiers of entities that have already been visited
      relationshipGUIDsVisited - set of unique identifiers of relationships that have already been visited
      Returns:
      Set<List<?>> of the immediate neighbors of the specified starting point GUIDs, as graph tuples [[:entityRef :relationshipRef]]
      Throws:
      RepositoryTimeoutException - if the query runs longer than the defined threshold (default: 30s)
    • findDirectNeighbors

      protected Collection<List<?>> findDirectNeighbors(xtdb.api.IXtdbDatasource db, String entityGUID, List<String> entityTypeGUIDs, List<String> relationshipTypeGUIDs, List<InstanceStatus> limitResultsByStatus, List<String> limitResultsByClassification) throws TimeoutException
      Find the immediate neighbors (1-degree separated entities and the relationships between) using the provided criteria.
      Parameters:
      db - already opened point-in-view of the database
      entityGUID - of the entity for which to find immediate relationships
      entityTypeGUIDs - of the entity type definitions by which to restrict entities in the results
      relationshipTypeGUIDs - of the relationship type definitions by which to restrict relationships in the results
      limitResultsByStatus - by which to limit relationships
      limitResultsByClassification - by which to limit the entities in the results
      Returns:
      Collection<List<?>> of tuples of relationships and entities found in the results
      Throws:
      TimeoutException - if the query runs longer than the defined threshold (default: 30s)
    • resultsToGraph

      protected InstanceGraph resultsToGraph(xtdb.api.IXtdbDatasource db, Collection<List<?>> xtdbResults, Set<String> entityGUIDsVisited, Set<String> relationshipGUIDsVisited, boolean includeRelationships)
      Translate the collection of XTDB tuple results (from a graph query) into an Egeria InstanceGraph.
      Parameters:
      db - already opened point-in-time view of the database
      xtdbResults - list of result tuples, e.g. from a neighborhood or other graph search
      entityGUIDsVisited - the list of entity GUIDs that have already been retrieved
      relationshipGUIDsVisited - the list of relationship GUIDs that have already been retrieved
      includeRelationships - whether to include relationships in the resulting graph (true) or not (false)
      Returns:
      InstanceGraph
    • getEntityRefFromGraphTuple

      protected String getEntityRefFromGraphTuple(List<?> tuple)
      Retrieve the entity reference from the provided graph query result.
      Parameters:
      tuple - graph query result
      Returns:
      String reference for the entity