Move storing common relationships to base EntityRepository (#12164)

This commit is contained in:
Suresh Srinivas 2023-06-29 19:54:05 -07:00 committed by GitHub
parent d901366af5
commit b88f5519ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 18 additions and 77 deletions

View File

@ -71,8 +71,6 @@ public class ChartRepository extends EntityRepository<Chart> {
public void storeRelationships(Chart chart) {
EntityReference service = chart.getService();
addRelationship(service.getId(), chart.getId(), service.getType(), Entity.CHART, Relationship.CONTAINS);
storeOwner(chart, chart.getOwner());
applyTags(chart);
}
@Override

View File

@ -68,7 +68,7 @@ public class ClassificationRepository extends EntityRepository<Classification> {
@Override
public void storeRelationships(Classification entity) {
/* No Relationships */
// No relationships to store beyond what is stored in the super class
}
private int getTermCount(Classification category) {

View File

@ -166,7 +166,6 @@ public class ContainerRepository extends EntityRepository<Container> {
@Override
public void storeRelationships(Container container) {
// store each relationship separately in the entity_relationship table
EntityReference service = container.getService();
addRelationship(service.getId(), container.getId(), service.getType(), CONTAINER, Relationship.CONTAINS);
@ -176,8 +175,6 @@ public class ContainerRepository extends EntityRepository<Container> {
if (parentReference != null) {
addRelationship(parentReference.getId(), container.getId(), CONTAINER, CONTAINER, Relationship.CONTAINS);
}
storeOwner(container, container.getOwner());
applyTags(container);
}
@Override

View File

@ -138,8 +138,6 @@ public class DashboardDataModelRepository extends EntityRepository<DashboardData
service.getType(),
Entity.DASHBOARD_DATA_MODEL,
Relationship.CONTAINS);
storeOwner(dashboardDataModel, dashboardDataModel.getOwner());
applyTags(dashboardDataModel);
}
@Override

View File

@ -157,12 +157,6 @@ public class DashboardRepository extends EntityRepository<Dashboard> {
dashboard.getId(), dataModel.getId(), Entity.DASHBOARD, Entity.DASHBOARD_DATA_MODEL, Relationship.HAS);
}
}
// Add owner relationship
storeOwner(dashboard, dashboard.getOwner());
// Add tag to dashboard relationship
applyTags(dashboard);
}
@Override

View File

@ -88,6 +88,6 @@ public class DataInsightChartRepository extends EntityRepository<DataInsightChar
@Override
public void storeRelationships(DataInsightChart entity) {
storeOwner(entity, entity.getOwner());
// No relationships to store beyond what is stored in the super class
}
}

View File

@ -70,9 +70,6 @@ public class DatabaseRepository extends EntityRepository<Database> {
public void storeRelationships(Database database) {
EntityReference service = database.getService();
addRelationship(service.getId(), database.getId(), service.getType(), Entity.DATABASE, Relationship.CONTAINS);
storeOwner(database, database.getOwner());
// Add tag to database relationship
applyTags(database);
}
private List<EntityReference> getSchemas(Database database) throws IOException {

View File

@ -79,9 +79,6 @@ public class DatabaseSchemaRepository extends EntityRepository<DatabaseSchema> {
EntityReference database = schema.getDatabase();
addRelationship(
database.getId(), schema.getId(), database.getType(), Entity.DATABASE_SCHEMA, Relationship.CONTAINS);
storeOwner(schema, schema.getOwner());
// Add tag to databaseSchema relationship
applyTags(schema);
}
private List<EntityReference> getTables(DatabaseSchema schema) throws IOException {

View File

@ -549,6 +549,12 @@ public abstract class EntityRepository<T extends EntityInterface> {
validateExtension(entity);
}
public void storeRelationshipsInternal(T entity) throws IOException {
storeOwner(entity, entity.getOwner());
applyTags(entity);
storeRelationships(entity);
}
T setFieldsInternal(T entity, Fields fields) throws IOException {
entity.setOwner(fields.contains(FIELD_OWNER) ? getOwner(entity) : null);
entity.setTags(fields.contains(FIELD_TAGS) ? getTags(entity.getFullyQualifiedName()) : null);
@ -877,7 +883,7 @@ public abstract class EntityRepository<T extends EntityInterface> {
private T createNewEntity(T entity) throws IOException {
storeEntity(entity, false);
storeExtension(entity);
storeRelationships(entity);
storeRelationshipsInternal(entity);
setInheritedFields(entity);
return entity;
}
@ -921,8 +927,7 @@ public abstract class EntityRepository<T extends EntityInterface> {
String entityJson,
Long timestamp,
String operation,
boolean update)
throws JsonProcessingException {
boolean update) {
String fqnHash = FullyQualifiedName.buildHash(fullyQualifiedName);
if (update) {
daoCollection

View File

@ -84,7 +84,7 @@ public class EventSubscriptionRepository extends EntityRepository<EventSubscript
@Override
public void storeRelationships(EventSubscription entity) {
storeOwner(entity, entity.getOwner());
// No relationships to store beyond what is stored in the super class
}
@Override

View File

@ -97,8 +97,6 @@ public class GlossaryRepository extends EntityRepository<Glossary> {
@Override
public void storeRelationships(Glossary glossary) {
storeOwner(glossary, glossary.getOwner());
applyTags(glossary);
for (EntityReference reviewer : listOrEmpty(glossary.getReviewers())) {
addRelationship(reviewer.getId(), glossary.getId(), Entity.USER, Entity.GLOSSARY, Relationship.REVIEWS);
}

View File

@ -157,7 +157,6 @@ public class GlossaryTermRepository extends EntityRepository<GlossaryTerm> {
public void storeRelationships(GlossaryTerm entity) {
addGlossaryRelationship(entity);
addParentRelationship(entity);
storeOwner(entity, entity.getOwner());
for (EntityReference relTerm : listOrEmpty(entity.getRelatedTerms())) {
// Make this bidirectional relationship
addRelationship(entity.getId(), relTerm.getId(), GLOSSARY_TERM, GLOSSARY_TERM, Relationship.RELATED_TO, true);
@ -165,8 +164,6 @@ public class GlossaryTermRepository extends EntityRepository<GlossaryTerm> {
for (EntityReference reviewer : listOrEmpty(entity.getReviewers())) {
addRelationship(reviewer.getId(), entity.getId(), Entity.USER, GLOSSARY_TERM, Relationship.REVIEWS);
}
applyTags(entity);
}
@Override

View File

@ -128,8 +128,6 @@ public class IngestionPipelineRepository extends EntityRepository<IngestionPipel
service.getType(),
Entity.INGESTION_PIPELINE,
Relationship.CONTAINS);
storeOwner(ingestionPipeline, ingestionPipeline.getOwner());
applyTags(ingestionPipeline);
}
@Override

View File

@ -94,8 +94,6 @@ public class KpiRepository extends EntityRepository<Kpi> {
public void storeRelationships(Kpi kpi) {
// Add relationship from Kpi to dataInsightChart
addRelationship(kpi.getId(), kpi.getDataInsightChart().getId(), KPI, DATA_INSIGHT_CHART, Relationship.USES);
// Add kpi owner relationship
storeOwner(kpi, kpi.getOwner());
}
@Transaction

View File

@ -75,8 +75,6 @@ public class MetricsRepository extends EntityRepository<Metrics> {
public void storeRelationships(Metrics metrics) {
EntityReference service = metrics.getService();
addRelationship(service.getId(), metrics.getId(), service.getType(), Entity.METRICS, Relationship.CONTAINS);
storeOwner(metrics, metrics.getOwner());
applyTags(metrics);
}
private EntityReference getService(EntityReference service) throws IOException { // Get service by service ID

View File

@ -161,8 +161,6 @@ public class MlModelRepository extends EntityRepository<MlModel> {
EntityReference service = mlModel.getService();
addRelationship(service.getId(), mlModel.getId(), service.getType(), MLMODEL, Relationship.CONTAINS);
storeOwner(mlModel, mlModel.getOwner());
setDashboard(mlModel, mlModel.getDashboard());
if (mlModel.getDashboard() != null) {
@ -172,7 +170,6 @@ public class MlModelRepository extends EntityRepository<MlModel> {
}
setMlFeatureSourcesLineage(mlModel);
applyTags(mlModel);
}
/**

View File

@ -212,12 +212,6 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
public void storeRelationships(Pipeline pipeline) {
EntityReference service = pipeline.getService();
addRelationship(service.getId(), pipeline.getId(), service.getType(), Entity.PIPELINE, Relationship.CONTAINS);
// Add owner relationship
storeOwner(pipeline, pipeline.getOwner());
// Add tag to pipeline relationship
applyTags(pipeline);
}
@Override

View File

@ -96,8 +96,7 @@ public class PolicyRepository extends EntityRepository<Policy> {
@Override
public void storeRelationships(Policy policy) {
// Add policy owner relationship.
storeOwner(policy, policy.getOwner());
// No relationships to store beyond what is stored in the super class
}
@Override

View File

@ -108,12 +108,6 @@ public class QueryRepository extends EntityRepository<Query> {
entityRef.getId(), queryEntity.getId(), entityRef.getType(), Entity.QUERY, Relationship.MENTIONED_IN);
}
}
// Add table owner relationship
storeOwner(queryEntity, queryEntity.getOwner());
// Add tag to table relationship
applyTags(queryEntity);
}
@Override

View File

@ -52,8 +52,6 @@ public class ReportRepository extends EntityRepository<Report> {
public void storeRelationships(Report report) {
EntityReference service = report.getService();
addRelationship(service.getId(), report.getId(), service.getType(), Entity.CHART, Relationship.CONTAINS);
storeOwner(report, report.getOwner());
applyTags(report);
}
private EntityReference getService(Report report) {

View File

@ -87,10 +87,7 @@ public abstract class ServiceEntityRepository<
@Override
public void storeRelationships(T service) {
// Add owner relationship
storeOwner(service, service.getOwner());
// add tags relationship
applyTags(service);
// No relationships to store beyond what is stored in the super class
}
public T addTestConnectionResult(UUID serviceId, TestConnectionResult testConnectionResult) throws IOException {

View File

@ -643,12 +643,6 @@ public class TableRepository extends EntityRepository<Table> {
public void storeRelationships(Table table) {
// Add relationship from database to table
addRelationship(table.getDatabaseSchema().getId(), table.getId(), DATABASE_SCHEMA, TABLE, Relationship.CONTAINS);
// Add table owner relationship
storeOwner(table, table.getOwner());
// Add tag to table relationship
applyTags(table);
}
@Override

View File

@ -154,8 +154,6 @@ public class TeamRepository extends EntityRepository<Team> {
@Override
public void storeRelationships(Team team) {
// Add team owner relationship
storeOwner(team, team.getOwner());
for (EntityReference user : listOrEmpty(team.getUsers())) {
addRelationship(team.getId(), user.getId(), TEAM, Entity.USER, Relationship.HAS);
}

View File

@ -197,8 +197,6 @@ public class TestCaseRepository extends EntityRepository<TestCase> {
// Add relationship from test definition to test
addRelationship(
test.getTestDefinition().getId(), test.getId(), TEST_DEFINITION, TEST_CASE, Relationship.APPLIED_TO);
// Add test owner relationship
storeOwner(test, test.getOwner());
}
@Transaction

View File

@ -66,7 +66,7 @@ public class TestConnectionDefinitionRepository extends EntityRepository<TestCon
@Override
public void storeRelationships(TestConnectionDefinition entity) {
storeOwner(entity, entity.getOwner());
// No relationships to store beyond what is stored in the super class
}
@Override

View File

@ -44,7 +44,7 @@ public class TestDefinitionRepository extends EntityRepository<TestDefinition> {
@Override
public void storeRelationships(TestDefinition entity) {
storeOwner(entity, entity.getOwner());
// No relationships to store beyond what is stored in the super class
}
@Override

View File

@ -77,7 +77,6 @@ public class TestSuiteRepository extends EntityRepository<TestSuite> {
@Override
public void storeRelationships(TestSuite entity) throws IOException {
storeOwner(entity, entity.getOwner());
if (entity.getExecutable()) {
storeExecutableRelationship(entity);
}

View File

@ -114,8 +114,6 @@ public class TopicRepository extends EntityRepository<Topic> {
@Override
public void storeRelationships(Topic topic) {
setService(topic, topic.getService());
storeOwner(topic, topic.getOwner());
applyTags(topic);
}
@Override

View File

@ -78,7 +78,7 @@ public class TypeRepository extends EntityRepository<Type> {
@Override
public void storeRelationships(Type type) {
/* Nothing to do */
// No relationships to store beyond what is stored in the super class
}
private void updateTypeMap(Type entity) {

View File

@ -48,7 +48,7 @@ public class WebAnalyticEventRepository extends EntityRepository<WebAnalyticEven
@Override
public void storeRelationships(WebAnalyticEvent entity) {
storeOwner(entity, entity.getOwner());
// No relationships to store beyond what is stored in the super class
}
@Transaction

View File

@ -67,7 +67,7 @@ public class WorkflowRepository extends EntityRepository<Workflow> {
@Override
public void storeRelationships(Workflow entity) {
storeOwner(entity, entity.getOwner());
// No relationships to store beyond what is stored in the super class
}
@Override