mirror of
https://github.com/datahub-project/datahub.git
synced 2025-07-30 21:10:07 +00:00

1.0.34: Downrank inactive users in user search query 1.0.33: Refactor clients to remove snapshot builder 1.0.32: Adding client & integration test for get_all 1.0.30: Implement other clients for corp groups 1.0.28: Add resources for search and autocomplete for corp groups 1.0.27: Start using BaseClient from metadata-models 1.0.26: Add get_all resource for CorpUsers metadata-models 38.1.12 -> 50.0.6: 50.0.2: Fix removed field update logic for all entities 49.0.1: Add dataset graph builder with DownstreamOf relationship 48.0.3: support query dao with traverse paths 47.0.2: refactor the query dao with relationship filter model 47.0.1: Fix for creating duplicate nodes when label for the node is missing 46.0.21: extend filter model with relationship direction 46.0.19: add unit test for entities partial update 46.0.16: Allow relationship filter in the model and query dao 46.0.15: support relationship directions for multi hop query 46.0.14: Implementing reportsto relationship builder and corpuser graph builder 46.0.10: refactor query dao interface using nullable to replace optional 46.0.9: Rename Mock Utils to Test Utils in Metadata-models mp 46.0.6: Remove search index config from metadata models 46.0.2: neo4j query DAO with relationships directions support 45.1.7: refactoring the graph relationship builders 45.1.5: Use correct total count in search response 45.1.3: Fix issue with empty search query filter 45.1.2: Fix a bug with autocomplete limit param 45.0.3: Change platform field type in the dataset search document 45.0.2: implement multi hops query DAO with interface 5 45.0.1: Moving dataset browsePaths build logic from wherehows-samza 44.0.2: implement interface 2 in query DAO 40.0.2: Only return records which exist in the DB after getting search hits 39.0.0: Add a getAuditor method to BaseSnapshotResource rather than taking it in as a constructor argument 38.1.13: Move BaseClient to metadata-models out of GMS template 38.1.12: Remove default filtering on removed field for get_all MP_VERSION=corp-identity-gms:1.0.40 MP_VERSION=metadata-models:50.0.6 MP_VERSION=wherehows-samza:1.0.56 This commit is automatically generated by li-opensource tool.
224 lines
13 KiB
Java
224 lines
13 KiB
Java
package com.linkedin.metadata.dao;
|
|
|
|
import com.linkedin.data.template.RecordTemplate;
|
|
import com.linkedin.metadata.dao.utils.Statement;
|
|
import com.linkedin.metadata.query.CriterionArray;
|
|
import com.linkedin.metadata.query.Filter;
|
|
import com.linkedin.metadata.query.RelationshipFilter;
|
|
import java.util.List;
|
|
import javax.annotation.Nonnull;
|
|
import javax.annotation.Nullable;
|
|
import org.javatuples.Triplet;
|
|
|
|
|
|
/**
|
|
* A base class for all Query DAOs.
|
|
*
|
|
* Query DAO is a standardized interface to query the centralized graph DB.
|
|
* See http://go/gma for more details.
|
|
*/
|
|
public abstract class BaseQueryDAO {
|
|
|
|
/**
|
|
* Finds a list of entities of a specific type based on the given filter on the entity
|
|
*
|
|
* @param entityClass the entity class to query
|
|
* @param filter the filter to apply when querying
|
|
* @param offset the offset query should start at. Ignored if set to a negative value.
|
|
* @param count the maximum number of entities to return. Ignored if set to a non-positive value.
|
|
*
|
|
* @param <ENTITY> returned entity type. Must be a type defined in com.linkedin.metadata.entity.
|
|
* @return a list of entities that match the conditions specified in {@code filter}
|
|
*/
|
|
@Nonnull
|
|
public abstract <ENTITY extends RecordTemplate> List<ENTITY> findEntities(@Nonnull Class<ENTITY> entityClass,
|
|
@Nonnull Filter filter, int offset, int count);
|
|
|
|
/**
|
|
* Finds a list of entities of a specific type using a raw graph query statement.
|
|
*
|
|
* @param entityClass the entity class to query
|
|
* @param queryStatement a {@link Statement} with query text and parameters
|
|
*
|
|
* @param <ENTITY> returned entity type. Must be a type defined in com.linkedin.metadata.entity.
|
|
* @return a list of entities from the outcome of the query statement
|
|
*/
|
|
@Nonnull
|
|
public abstract <ENTITY extends RecordTemplate> List<ENTITY> findEntities(@Nonnull Class<ENTITY> entityClass,
|
|
@Nonnull Statement queryStatement);
|
|
|
|
/**
|
|
* Finds a list of entities containing a mixture of different types using a graph query.
|
|
*
|
|
* @param queryStatement a {@link Statement} with query text and parameters
|
|
* @return a list of entities from the outcome of the query statement
|
|
*/
|
|
@Nonnull
|
|
public abstract List<RecordTemplate> findMixedTypesEntities(@Nonnull Statement queryStatement);
|
|
|
|
/**
|
|
* Finds a list of entities through certain relationships given an entity filter
|
|
* For more details on design and use cases, refer to interface 1 in go/gma/graph/dao
|
|
*
|
|
* @param sourceEntityClass the source entity class to query
|
|
* @param sourceEntityFilter the filter to apply to the source entity when querying
|
|
* @param destinationEntityClass the destination entity class for result entity types
|
|
* @param destinationEntityFilter the filter to apply to the destination entity when querying
|
|
* @param relationshipType the type of relationship to query
|
|
* @param relationshipFilter the filter to apply to relationship when querying including the direction
|
|
* @param offset the offset query should start at. Ignored if set to a negative value.
|
|
* @param count the maximum number of entities to return. Ignored if set to a non-positive value.
|
|
*
|
|
* @param <SRC_ENTITY> source ENTITY type. Must be a type defined in com.linkedin.metadata.entity.
|
|
* @param <DEST_ENTITY> destination ENTITY type. Must be a type defined in com.linkedin.metadata.entity.
|
|
* @param <RELATIONSHIP> returned relationship type. Must be a type defined in com.linkedin.metadata.relationship.
|
|
* @return a list of entities that match the conditions specified in {@code filter}
|
|
*/
|
|
@Nonnull
|
|
public <SRC_ENTITY extends RecordTemplate, DEST_ENTITY extends RecordTemplate, RELATIONSHIP extends RecordTemplate>
|
|
List<RecordTemplate> findEntities(
|
|
@Nullable Class<SRC_ENTITY> sourceEntityClass, @Nonnull Filter sourceEntityFilter,
|
|
@Nullable Class<DEST_ENTITY> destinationEntityClass, @Nonnull Filter destinationEntityFilter,
|
|
@Nonnull Class<RELATIONSHIP> relationshipType, @Nonnull RelationshipFilter relationshipFilter,
|
|
int offset, int count) {
|
|
return findEntities(sourceEntityClass, sourceEntityFilter, destinationEntityClass, destinationEntityFilter,
|
|
relationshipType, relationshipFilter, 1, 1, offset, count);
|
|
}
|
|
|
|
/**
|
|
* Finds a list of entities of a specific type via multiple hops traversal based on the given relationship filter and source/destination entity filter.
|
|
*
|
|
* @param sourceEntityClass the source entity class to query
|
|
* @param sourceEntityFilter the filter to apply to the source entity when querying
|
|
* @param destinationEntityClass the destination entity class
|
|
* @param destinationEntityFilter the filter to apply to the destination entity when querying
|
|
* @param relationshipType the type of relationship to query
|
|
* @param relationshipFilter the filter to apply to relationship when querying
|
|
* @param minHops the lower bound of hops for graph traversing.
|
|
* @param maxHops the upper bound of hops for graph traversing.
|
|
* @param offset the offset query should start at. Ignored if set to a negative value.
|
|
* @param count the maximum number of entities to return. Ignored if set to a non-positive value.
|
|
*
|
|
* @param <SRC_ENTITY> source ENTITY type. Must be a type defined in com.linkedin.metadata.entity.
|
|
* @param <DEST_ENTITY> destination ENTITY type. Must be a type defined in com.linkedin.metadata.entity.
|
|
* @param <RELATIONSHIP> returned relationship type. Must be a type defined in com.linkedin.metadata.relationship.
|
|
* @return a list of entities that match the conditions specified in {@code filter}
|
|
*/
|
|
@Nonnull
|
|
public abstract <SRC_ENTITY extends RecordTemplate, DEST_ENTITY extends RecordTemplate, RELATIONSHIP extends RecordTemplate>
|
|
List<RecordTemplate> findEntities(
|
|
@Nullable Class<SRC_ENTITY> sourceEntityClass, @Nonnull Filter sourceEntityFilter,
|
|
@Nullable Class<DEST_ENTITY> destinationEntityClass, @Nonnull Filter destinationEntityFilter,
|
|
@Nonnull Class<RELATIONSHIP> relationshipType, @Nonnull RelationshipFilter relationshipFilter, int minHops,
|
|
int maxHops, int offset, int count);
|
|
|
|
/**
|
|
* Finds a list of entities based on the given traversing paths.
|
|
*
|
|
* @param sourceEntityClass the source entity class as the starting point for the query
|
|
* @param sourceEntityFilter the filter to apply to the source entity when querying
|
|
* @param traversePaths specify the traverse paths via a list of <relationship type, relationship filter, intermediate entities>
|
|
* @param count the maximum number of entities to return. Ignored if set to a non-positive value.
|
|
*
|
|
* @param <SRC_ENTITY> source ENTITY type. Starting point of the traverse path. Must be a type defined in com.linkedin.metadata.entity.
|
|
* @param <INTER_ENTITY> intermediate entity type on the traverse path. Must be a type defined in com.linkedin.metadata.entity.
|
|
* @param <RELATIONSHIP> relationship type on the traverse path. Must be a type defined in com.linkedin.metadata.relationship.
|
|
* @return a list of entities that match the conditions specified in {@code filter}
|
|
*/
|
|
@Nonnull
|
|
public abstract <SRC_ENTITY extends RecordTemplate, RELATIONSHIP extends RecordTemplate, INTER_ENTITY extends RecordTemplate>
|
|
List<RecordTemplate> findEntities(
|
|
@Nullable Class<SRC_ENTITY> sourceEntityClass, @Nonnull Filter sourceEntityFilter,
|
|
@Nonnull List<Triplet<Class<RELATIONSHIP>, RelationshipFilter, Class<INTER_ENTITY>>> traversePaths, int offset, int count);
|
|
|
|
/**
|
|
* Finds a list of relationships of a specific type based on the given relationship filter and source entity filter.
|
|
*
|
|
* @param sourceEntityClass the source entity class to query
|
|
* @param sourceEntityFilter the filter to apply to the source entity when querying
|
|
* @param relationshipType the type of relationship to query
|
|
* @param relationshipFilter the filter to apply to relationship when querying
|
|
* @param offset the offset query should start at. Ignored if set to a negative value.
|
|
* @param count the maximum number of entities to return. Ignored if set to a non-positive value.
|
|
*
|
|
* @param <ENTITY> source ENTITY type. Must be a type defined in com.linkedin.metadata.entity.
|
|
* @param <RELATIONSHIP> returned relationship type. Must be a type defined in com.linkedin.metadata.relationship.
|
|
* @return a list of relationships that match the conditions specified in {@code filter}
|
|
*/
|
|
@Nonnull
|
|
public <ENTITY extends RecordTemplate, RELATIONSHIP extends RecordTemplate> List<RELATIONSHIP> findRelationshipsFromSource(
|
|
@Nullable Class<ENTITY> sourceEntityClass, @Nonnull Filter sourceEntityFilter,
|
|
@Nonnull Class<RELATIONSHIP> relationshipType, @Nonnull Filter relationshipFilter, int offset, int count) {
|
|
return findRelationships(sourceEntityClass, sourceEntityFilter, null,
|
|
new Filter().setCriteria(new CriterionArray()), relationshipType, relationshipFilter, offset, count);
|
|
}
|
|
|
|
/**
|
|
* Finds a list of relationships of a specific type based on the given relationship filter and destination entity filter.
|
|
*
|
|
* @param destinationEntityClass the destination entity class
|
|
* @param destinationEntityFilter the filter to apply to the destination entity when querying
|
|
* @param relationshipType the type of relationship to query
|
|
* @param relationshipFilter the filter to apply to relationship when querying
|
|
* @param offset the offset query should start at. Ignored if set to a negative value.
|
|
* @param count the maximum number of entities to return. Ignored if set to a non-positive value.
|
|
*
|
|
* @param <ENTITY> destination ENTITY type. Must be a type defined in com.linkedin.metadata.entity.
|
|
* @param <RELATIONSHIP> returned relationship type. Must be a type defined in com.linkedin.metadata.relationship.
|
|
* @return a list of relationships that match the conditions specified in {@code filter}
|
|
*/
|
|
@Nonnull
|
|
public <ENTITY extends RecordTemplate, RELATIONSHIP extends RecordTemplate> List<RELATIONSHIP> findRelationshipsFromDestination(
|
|
@Nullable Class<ENTITY> destinationEntityClass, @Nonnull Filter destinationEntityFilter,
|
|
@Nonnull Class<RELATIONSHIP> relationshipType, @Nonnull Filter relationshipFilter, int offset, int count) {
|
|
return findRelationships(null, new Filter().setCriteria(new CriterionArray()), destinationEntityClass,
|
|
destinationEntityFilter, relationshipType, relationshipFilter, offset, count);
|
|
}
|
|
|
|
/**
|
|
* Finds a list of relationships of a specific type based on the given relationship filter and source/destination entity filter.
|
|
*
|
|
* @param sourceEntityClass the source entity class to query
|
|
* @param sourceEntityFilter the filter to apply to the source entity when querying
|
|
* @param destinationEntityClass the destination entity class
|
|
* @param destinationEntityFilter the filter to apply to the destination entity when querying
|
|
* @param relationshipType the type of relationship to query
|
|
* @param relationshipFilter the filter to apply to relationship when querying
|
|
* @param offset the offset query should start at. Ignored if set to a negative value.
|
|
* @param count the maximum number of entities to return. Ignored if set to a non-positive value.
|
|
*
|
|
* @param <SRC_ENTITY> source ENTITY type. Must be a type defined in com.linkedin.metadata.entity.
|
|
* @param <DEST_ENTITY> destination ENTITY type. Must be a type defined in com.linkedin.metadata.entity.
|
|
* @param <RELATIONSHIP> returned relationship type. Must be a type defined in com.linkedin.metadata.relationship.
|
|
* @return a list of relationships that match the conditions specified in {@code filter}
|
|
*/
|
|
@Nonnull
|
|
public abstract <SRC_ENTITY extends RecordTemplate, DEST_ENTITY extends RecordTemplate, RELATIONSHIP extends RecordTemplate>
|
|
List<RELATIONSHIP> findRelationships(
|
|
@Nullable Class<SRC_ENTITY> sourceEntityClass, @Nonnull Filter sourceEntityFilter,
|
|
@Nullable Class<DEST_ENTITY> destinationEntityClass, @Nonnull Filter destinationEntityFilter,
|
|
@Nonnull Class<RELATIONSHIP> relationshipType, @Nonnull Filter relationshipFilter, int offset, int count);
|
|
|
|
/**
|
|
* Finds a list of relationships of a specific type using a graph query.
|
|
*
|
|
* @param relationshipClass the relationship class to query
|
|
* @param queryStatement a {@link Statement} with query text and parameters
|
|
*
|
|
* @param <RELATIONSHIP> returned relationship type. Must be a type defined in com.linkedin.metadata.relationship.
|
|
* @return a list of relationships from the outcome of the query statement
|
|
*/
|
|
@Nonnull
|
|
public abstract <RELATIONSHIP extends RecordTemplate> List<RELATIONSHIP> findRelationships(
|
|
@Nonnull Class<RELATIONSHIP> relationshipClass, @Nonnull Statement queryStatement);
|
|
|
|
/**
|
|
* Finds a list of relationships containing a mixture of different types using a graph query.
|
|
*
|
|
* @param queryStatement a {@link Statement} with query text and parameters
|
|
* @return a list of relationships from the outcome of the query statement
|
|
*/
|
|
@Nonnull
|
|
public abstract List<RecordTemplate> findMixedTypesRelationships(@Nonnull Statement queryStatement);
|
|
}
|