diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/CatalogApplication.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/CatalogApplication.java index 00b0b52a6fc..d73b754df4d 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/CatalogApplication.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/CatalogApplication.java @@ -63,8 +63,6 @@ public class CatalogApplication extends Application { private Injector injector; private Authorizer authorizer; - public CatalogApplication() {} - @Override public void run(CatalogApplicationConfig catalogConfig, Environment environment) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, @@ -176,7 +174,9 @@ public class CatalogApplication extends Application { .manage( new Managed() { @Override - public void start() {} + public void start() { + LOG.info("Application starting"); + } @Override public void stop() { diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/exception/CatalogGenericExceptionMapper.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/exception/CatalogGenericExceptionMapper.java index e8769889f80..071f24d9209 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/exception/CatalogGenericExceptionMapper.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/exception/CatalogGenericExceptionMapper.java @@ -38,8 +38,6 @@ import org.slf4j.LoggerFactory; public class CatalogGenericExceptionMapper implements ExceptionMapper { private static final Logger LOG = LoggerFactory.getLogger(CatalogGenericExceptionMapper.class); - public CatalogGenericExceptionMapper() {} - @Override public Response toResponse(Throwable ex) { if (ex instanceof ProcessingException || ex instanceof IllegalArgumentException) { diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/BotsRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/BotsRepository.java index 7d8336ba3dc..fc797f59560 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/BotsRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/BotsRepository.java @@ -16,14 +16,12 @@ package org.openmetadata.catalog.jdbi3; import java.io.IOException; import java.net.URI; import java.util.Date; -import java.util.List; import java.util.UUID; import org.openmetadata.catalog.Entity; import org.openmetadata.catalog.entity.Bots; import org.openmetadata.catalog.resources.bots.BotsResource; import org.openmetadata.catalog.type.ChangeDescription; import org.openmetadata.catalog.type.EntityReference; -import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.util.EntityInterface; import org.openmetadata.catalog.util.EntityUtil.Fields; @@ -36,7 +34,10 @@ public class BotsRepository extends EntityRepository { dao.botsDAO(), dao, Fields.EMPTY_FIELDS, - Fields.EMPTY_FIELDS); + Fields.EMPTY_FIELDS, + false, + false, + false); } @Override @@ -45,7 +46,9 @@ public class BotsRepository extends EntityRepository { } @Override - public void restorePatchAttributes(Bots original, Bots update) {} + public void restorePatchAttributes(Bots original, Bots update) { + /* Nothing to do */ + } @Override public EntityInterface getEntityInterface(Bots entity) { @@ -53,15 +56,19 @@ public class BotsRepository extends EntityRepository { } @Override - public void prepare(Bots entity) {} - - @Override - public void storeEntity(Bots entity, boolean update) throws IOException { - daoCollection.botsDAO().insert(entity); + public void prepare(Bots entity) { + /* Nothing to do */ } @Override - public void storeRelationships(Bots entity) {} + public void storeEntity(Bots entity, boolean update) throws IOException { + store(entity.getId(), entity, update); + } + + @Override + public void storeRelationships(Bots entity) { + /* Nothing to do */ + } public static class BotsEntityInterface implements EntityInterface { private final Bots entity; @@ -85,21 +92,11 @@ public class BotsRepository extends EntityRepository { return entity.getDisplayName(); } - @Override - public EntityReference getOwner() { - return null; - } - @Override public String getFullyQualifiedName() { return entity.getName(); } - @Override - public List getTags() { - return null; - } - @Override public Double getVersion() { return entity.getVersion(); @@ -120,11 +117,6 @@ public class BotsRepository extends EntityRepository { return entity.getHref(); } - @Override - public List getFollowers() { - throw new UnsupportedOperationException("Dashboard service does not support followers"); - } - @Override public ChangeDescription getChangeDescription() { return entity.getChangeDescription(); @@ -177,9 +169,6 @@ public class BotsRepository extends EntityRepository { entity.setChangeDescription(changeDescription); } - @Override - public void setOwner(EntityReference owner) {} - @Override public void setDeleted(boolean flag) { entity.setDeleted(flag); @@ -189,8 +178,5 @@ public class BotsRepository extends EntityRepository { public Bots withHref(URI href) { return entity.withHref(href); } - - @Override - public void setTags(List tags) {} } } diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/ChartRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/ChartRepository.java index 4df2d762492..ab189c11a8a 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/ChartRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/ChartRepository.java @@ -31,7 +31,6 @@ import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.util.EntityInterface; import org.openmetadata.catalog.util.EntityUtil; import org.openmetadata.catalog.util.EntityUtil.Fields; -import org.openmetadata.catalog.util.JsonUtils; public class ChartRepository extends EntityRepository { private static final Fields CHART_UPDATE_FIELDS = new Fields(ChartResource.FIELD_LIST, "owner"); @@ -45,7 +44,10 @@ public class ChartRepository extends EntityRepository { dao.chartDAO(), dao, CHART_PATCH_FIELDS, - CHART_UPDATE_FIELDS); + CHART_UPDATE_FIELDS, + true, + true, + true); } public static String getFQN(Chart chart) { @@ -71,11 +73,7 @@ public class ChartRepository extends EntityRepository { // Don't store owner, database, href and tags as JSON. Build it on the fly based on relationships chart.withOwner(null).withService(null).withHref(null).withTags(null); - if (update) { - daoCollection.chartDAO().update(chart.getId(), JsonUtils.pojoToJson(chart)); - } else { - daoCollection.chartDAO().insert(chart); - } + store(chart.getId(), chart, update); // Restore the relationships chart.withOwner(owner).withService(service).withTags(tags); @@ -96,25 +94,6 @@ public class ChartRepository extends EntityRepository { applyTags(chart); } - private void applyTags(Chart chart) { - // Add chart level tags by adding tag to chart relationship - EntityUtil.applyTags(daoCollection.tagDAO(), chart.getTags(), chart.getFullyQualifiedName()); - chart.setTags(getTags(chart.getFullyQualifiedName())); // Update tag to handle additional derived tags - } - - public EntityReference getOwner(Chart chart) throws IOException { - return chart != null - ? EntityUtil.populateOwner( - chart.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO(), daoCollection.teamDAO()) - : null; - } - - private void setOwner(Chart chart, EntityReference owner) { - EntityUtil.setOwner(daoCollection.relationshipDAO(), chart.getId(), Entity.CHART, owner); - // TODO not required - chart.setOwner(owner); - } - @Override public Chart setFields(Chart chart, Fields fields) throws IOException { chart.setService(getService(chart)); @@ -139,16 +118,6 @@ public class ChartRepository extends EntityRepository { return new ChartEntityInterface(entity); } - private List getFollowers(Chart chart) throws IOException { - return chart == null - ? null - : EntityUtil.getFollowers(chart.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO()); - } - - private List getTags(String fqn) { - return daoCollection.tagDAO().getTags(fqn); - } - private EntityReference getService(Chart chart) throws IOException { EntityReference ref = EntityUtil.getService(daoCollection.relationshipDAO(), chart.getId(), Entity.DASHBOARD_SERVICE); diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DashboardRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DashboardRepository.java index 73ff14ec26c..1c52772781f 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DashboardRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DashboardRepository.java @@ -35,7 +35,6 @@ import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.util.EntityInterface; import org.openmetadata.catalog.util.EntityUtil; import org.openmetadata.catalog.util.EntityUtil.Fields; -import org.openmetadata.catalog.util.JsonUtils; public class DashboardRepository extends EntityRepository { private static final Fields DASHBOARD_UPDATE_FIELDS = new Fields(DashboardResource.FIELD_LIST, "owner,tags,charts"); @@ -49,7 +48,10 @@ public class DashboardRepository extends EntityRepository { dao.dashboardDAO(), dao, DASHBOARD_PATCH_FIELDS, - DASHBOARD_UPDATE_FIELDS); + DASHBOARD_UPDATE_FIELDS, + true, + true, + true); } public static String getFQN(Dashboard dashboard) { @@ -92,10 +94,6 @@ public class DashboardRepository extends EntityRepository { .withId(original.getId()); } - private List getTags(String fqn) { - return daoCollection.tagDAO().getTags(fqn); - } - private EntityReference getService(Dashboard dashboard) throws IOException { EntityReference ref = EntityUtil.getService(daoCollection.relationshipDAO(), dashboard.getId(), Entity.DASHBOARD_SERVICE); @@ -154,11 +152,7 @@ public class DashboardRepository extends EntityRepository { // Don't store owner, database, href and tags as JSON. Build it on the fly based on relationships dashboard.withOwner(null).withHref(null).withTags(null).withService(null); - if (update) { - daoCollection.dashboardDAO().update(dashboard.getId(), JsonUtils.pojoToJson(dashboard)); - } else { - daoCollection.dashboardDAO().insert(dashboard); - } + store(dashboard.getId(), dashboard, update); // Restore the relationships dashboard.withOwner(owner).withTags(tags).withService(service); @@ -189,30 +183,6 @@ public class DashboardRepository extends EntityRepository { return new DashboardUpdater(original, updated, patchOperation); } - private EntityReference getOwner(Dashboard dashboard) throws IOException { - return dashboard == null - ? null - : EntityUtil.populateOwner( - dashboard.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO(), daoCollection.teamDAO()); - } - - public void setOwner(Dashboard dashboard, EntityReference owner) { - EntityUtil.setOwner(daoCollection.relationshipDAO(), dashboard.getId(), Entity.DASHBOARD, owner); - dashboard.setOwner(owner); - } - - private void applyTags(Dashboard dashboard) { - // Add dashboard level tags by adding tag to dashboard relationship - EntityUtil.applyTags(daoCollection.tagDAO(), dashboard.getTags(), dashboard.getFullyQualifiedName()); - dashboard.setTags(getTags(dashboard.getFullyQualifiedName())); // Update tag to handle additional derived tags - } - - private List getFollowers(Dashboard dashboard) throws IOException { - return dashboard == null - ? null - : EntityUtil.getFollowers(dashboard.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO()); - } - private List getCharts(Dashboard dashboard) throws IOException { if (dashboard == null) { return null; diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DashboardServiceRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DashboardServiceRepository.java index 1e9556dabed..d7110dd7212 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DashboardServiceRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DashboardServiceRepository.java @@ -17,7 +17,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import java.io.IOException; import java.net.URI; import java.util.Date; -import java.util.List; import java.util.UUID; import javax.ws.rs.core.UriInfo; import org.openmetadata.catalog.Entity; @@ -26,7 +25,6 @@ import org.openmetadata.catalog.resources.services.dashboard.DashboardServiceRes import org.openmetadata.catalog.type.ChangeDescription; import org.openmetadata.catalog.type.EntityReference; import org.openmetadata.catalog.type.Schedule; -import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.util.EntityInterface; import org.openmetadata.catalog.util.EntityUtil; import org.openmetadata.catalog.util.EntityUtil.Fields; @@ -41,7 +39,10 @@ public class DashboardServiceRepository extends EntityRepository getTags() { - return null; - } - @Override public Double getVersion() { return entity.getVersion(); @@ -158,11 +149,6 @@ public class DashboardServiceRepository extends EntityRepository getFollowers() { - throw new UnsupportedOperationException("Dashboard service does not support followers"); - } - @Override public ChangeDescription getChangeDescription() { return entity.getChangeDescription(); @@ -183,11 +169,6 @@ public class DashboardServiceRepository extends EntityRepository tags) {} } public class DashboardServiceUpdater extends EntityUpdater { diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DatabaseRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DatabaseRepository.java index fd9487b0284..743fb6b3608 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DatabaseRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DatabaseRepository.java @@ -31,7 +31,6 @@ import org.openmetadata.catalog.jdbi3.DatabaseServiceRepository.DatabaseServiceE import org.openmetadata.catalog.resources.databases.DatabaseResource; import org.openmetadata.catalog.type.ChangeDescription; import org.openmetadata.catalog.type.EntityReference; -import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.util.EntityInterface; import org.openmetadata.catalog.util.EntityUtil; import org.openmetadata.catalog.util.EntityUtil.Fields; @@ -49,7 +48,10 @@ public class DatabaseRepository extends EntityRepository { dao.databaseDAO(), dao, DATABASE_PATCH_FIELDS, - DATABASE_UPDATE_FIELDS); + DATABASE_UPDATE_FIELDS, + false, + true, + false); } public static String getFQN(Database database) { @@ -102,13 +104,6 @@ public class DatabaseRepository extends EntityRepository { EntityUtil.setOwner(daoCollection.relationshipDAO(), database.getId(), Entity.DATABASE, database.getOwner()); } - public EntityReference getOwner(Database database) throws IOException { - return database != null - ? EntityUtil.populateOwner( - database.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO(), daoCollection.teamDAO()) - : null; - } - private List getTables(Database database) throws IOException { if (database == null) { return null; @@ -232,11 +227,6 @@ public class DatabaseRepository extends EntityRepository { return entity.getFullyQualifiedName(); } - @Override - public List getTags() { - return null; - } - @Override public Double getVersion() { return entity.getVersion(); @@ -257,11 +247,6 @@ public class DatabaseRepository extends EntityRepository { return entity.getHref(); } - @Override - public List getFollowers() { - throw new UnsupportedOperationException("Database does not support followers"); - } - @Override public EntityReference getEntityReference() { return new EntityReference() @@ -328,8 +313,5 @@ public class DatabaseRepository extends EntityRepository { public ChangeDescription getChangeDescription() { return entity.getChangeDescription(); } - - @Override - public void setTags(List tags) {} } } diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DatabaseServiceRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DatabaseServiceRepository.java index 1e0aac75227..bb1b7ac5dc5 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DatabaseServiceRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DatabaseServiceRepository.java @@ -17,7 +17,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import java.io.IOException; import java.net.URI; import java.util.Date; -import java.util.List; import java.util.UUID; import org.openmetadata.catalog.Entity; import org.openmetadata.catalog.entity.services.DatabaseService; @@ -25,11 +24,9 @@ import org.openmetadata.catalog.resources.services.database.DatabaseServiceResou import org.openmetadata.catalog.type.ChangeDescription; import org.openmetadata.catalog.type.EntityReference; import org.openmetadata.catalog.type.JdbcInfo; -import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.util.EntityInterface; import org.openmetadata.catalog.util.EntityUtil; import org.openmetadata.catalog.util.EntityUtil.Fields; -import org.openmetadata.catalog.util.JsonUtils; public class DatabaseServiceRepository extends EntityRepository { public static final String COLLECTION_PATH = "v1/services/databaseServices"; @@ -42,7 +39,10 @@ public class DatabaseServiceRepository extends EntityRepository dao.dbServiceDAO(), dao, Fields.EMPTY_FIELDS, - Fields.EMPTY_FIELDS); + Fields.EMPTY_FIELDS, + false, + false, + false); } @Override @@ -51,7 +51,9 @@ public class DatabaseServiceRepository extends EntityRepository } @Override - public void restorePatchAttributes(DatabaseService original, DatabaseService updated) {} + public void restorePatchAttributes(DatabaseService original, DatabaseService updated) { + /* Nothing to do */ + } @Override public EntityInterface getEntityInterface(DatabaseService entity) { @@ -65,15 +67,14 @@ public class DatabaseServiceRepository extends EntityRepository @Override public void storeEntity(DatabaseService service, boolean update) throws IOException { - if (update) { - daoCollection.dbServiceDAO().update(service.getId(), JsonUtils.pojoToJson(service)); - } else { - daoCollection.dbServiceDAO().insert(service); - } + service.withHref(null); + store(service.getId(), service, update); } @Override - public void storeRelationships(DatabaseService entity) {} + public void storeRelationships(DatabaseService entity) { + /* Nothing to do */ + } @Override public EntityUpdater getUpdater(DatabaseService original, DatabaseService updated, boolean patchOperation) { @@ -102,21 +103,11 @@ public class DatabaseServiceRepository extends EntityRepository return entity.getDisplayName(); } - @Override - public EntityReference getOwner() { - return null; - } - @Override public String getFullyQualifiedName() { return entity.getName(); } - @Override - public List getTags() { - return null; - } - @Override public Double getVersion() { return entity.getVersion(); @@ -137,11 +128,6 @@ public class DatabaseServiceRepository extends EntityRepository return entity.getHref(); } - @Override - public List getFollowers() { - throw new UnsupportedOperationException("Database service does not support followers"); - } - @Override public ChangeDescription getChangeDescription() { return entity.getChangeDescription(); @@ -162,11 +148,6 @@ public class DatabaseServiceRepository extends EntityRepository return entity; } - @Override - public EntityReference getContainer() { - return null; - } - @Override public void setId(UUID id) { entity.setId(id); @@ -194,9 +175,6 @@ public class DatabaseServiceRepository extends EntityRepository entity.setChangeDescription(changeDescription); } - @Override - public void setOwner(EntityReference owner) {} - @Override public void setDeleted(boolean flag) { entity.setDeleted(flag); @@ -206,9 +184,6 @@ public class DatabaseServiceRepository extends EntityRepository public DatabaseService withHref(URI href) { return entity.withHref(href); } - - @Override - public void setTags(List tags) {} } public class DatabaseServiceUpdater extends EntityUpdater { diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/EntityRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/EntityRepository.java index ab5c208f8fa..e79cf4f4130 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/EntityRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/EntityRepository.java @@ -98,6 +98,9 @@ public abstract class EntityRepository { protected final EntityDAO dao; protected final CollectionDAO daoCollection; protected boolean softDelete = true; + protected final boolean supportsTags; + protected final boolean supportsOwner; + protected final boolean supportsFollower; /** Fields that can be updated during PATCH operation */ private final Fields patchFields; @@ -112,7 +115,10 @@ public abstract class EntityRepository { EntityDAO entityDAO, CollectionDAO collectionDAO, Fields patchFields, - Fields putFields) { + Fields putFields, + boolean supportsTags, + boolean supportsOwner, + boolean supportsFollower) { this.collectionPath = collectionPath; this.entityClass = entityClass; this.dao = entityDAO; @@ -120,6 +126,9 @@ public abstract class EntityRepository { this.patchFields = patchFields; this.putFields = putFields; this.entityName = entityName; + this.supportsTags = supportsTags; + this.supportsOwner = supportsOwner; + this.supportsFollower = supportsFollower; Entity.registerEntity(entityName, dao, this); } @@ -436,6 +445,51 @@ public abstract class EntityRepository { return entity; } + protected void store(UUID id, T entity, boolean update) throws JsonProcessingException { + if (update) { + dao.update(id, JsonUtils.pojoToJson(entity)); + } else { + dao.insert(entity); + } + } + + protected EntityReference getOwner(T entity) throws IOException { + EntityInterface entityInterface = getEntityInterface(entity); + return supportsOwner && entity != null + ? EntityUtil.populateOwner( + entityInterface.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO(), daoCollection.teamDAO()) + : null; + } + + protected void setOwner(T entity, EntityReference owner) { + if (supportsOwner) { + EntityInterface entityInterface = getEntityInterface(entity); + EntityUtil.setOwner(daoCollection.relationshipDAO(), entityInterface.getId(), entityName, owner); + entityInterface.setOwner(owner); + } + } + + protected void applyTags(T entity) { + if (supportsTags) { + // Add entity level tags by adding tag to the entity relationship + EntityInterface entityInterface = getEntityInterface(entity); + EntityUtil.applyTags(daoCollection.tagDAO(), entityInterface.getTags(), entityInterface.getFullyQualifiedName()); + // Update tag to handle additional derived tags + entityInterface.setTags(getTags(entityInterface.getFullyQualifiedName())); + } + } + + protected List getTags(String fqn) { + return !supportsOwner ? null : daoCollection.tagDAO().getTags(fqn); + } + + protected List getFollowers(T entity) throws IOException { + EntityInterface entityInterface = getEntityInterface(entity); + return !supportsFollower || entity == null + ? null + : EntityUtil.getFollowers(entityInterface.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO()); + } + public T withHref(UriInfo uriInfo, T entity) { if (uriInfo == null) { return entity; diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/IngestionRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/IngestionRepository.java index 9010580c45e..1e96aaf26d3 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/IngestionRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/IngestionRepository.java @@ -30,7 +30,6 @@ import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.util.EntityInterface; import org.openmetadata.catalog.util.EntityUtil; import org.openmetadata.catalog.util.EntityUtil.Fields; -import org.openmetadata.catalog.util.JsonUtils; public class IngestionRepository extends EntityRepository { private static final Fields INGESTION_UPDATE_FIELDS = @@ -46,7 +45,10 @@ public class IngestionRepository extends EntityRepository { dao.ingestionDAO(), dao, INGESTION_PATCH_FIELDS, - INGESTION_UPDATE_FIELDS); + INGESTION_UPDATE_FIELDS, + true, + true, + false); } public static String getFQN(Ingestion ingestion) { @@ -77,10 +79,6 @@ public class IngestionRepository extends EntityRepository { return new IngestionEntityInterface(entity); } - private List getTags(String fqn) { - return daoCollection.tagDAO().getTags(fqn); - } - @Override public void prepare(Ingestion ingestion) throws IOException { ingestion.setService(getService(ingestion.getService())); @@ -100,11 +98,7 @@ public class IngestionRepository extends EntityRepository { // Don't store owner, dashboard, href and tags as JSON. Build it on the fly based on relationships ingestion.withOwner(null).withHref(null).withTags(null); - if (update) { - daoCollection.ingestionDAO().update(ingestion.getId(), JsonUtils.pojoToJson(ingestion)); - } else { - daoCollection.ingestionDAO().insert(ingestion); - } + store(ingestion.getId(), ingestion, update); // Restore the relationships ingestion.withOwner(owner).withService(service).withTags(tags); @@ -130,24 +124,6 @@ public class IngestionRepository extends EntityRepository { return new IngestionUpdater(original, updated, patchOperation); } - private EntityReference getOwner(Ingestion ingestion) throws IOException { - return ingestion == null - ? null - : EntityUtil.populateOwner( - ingestion.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO(), daoCollection.teamDAO()); - } - - public void setOwner(Ingestion ingestion, EntityReference owner) { - EntityUtil.setOwner(daoCollection.relationshipDAO(), ingestion.getId(), Entity.INGESTION, owner); - ingestion.setOwner(owner); - } - - private void applyTags(Ingestion ingestion) { - // Add ingestion level tags by adding tag to ingestion relationship - EntityUtil.applyTags(daoCollection.tagDAO(), ingestion.getTags(), ingestion.getFullyQualifiedName()); - ingestion.setTags(getTags(ingestion.getFullyQualifiedName())); // Update tag to handle additional derived tags - } - private EntityReference getService(Ingestion ingestion) throws IOException { EntityReference ref = EntityUtil.getService(daoCollection.relationshipDAO(), ingestion.getId()); return getService(Objects.requireNonNull(ref)); @@ -245,12 +221,6 @@ public class IngestionRepository extends EntityRepository { return entity.getService(); } - @Override - public List getFollowers() { - // Ingestion does not have followers. - return null; - } - @Override public void setId(UUID id) { entity.setId(id); diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/LocationRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/LocationRepository.java index 6ae050b67b3..164960219e9 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/LocationRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/LocationRepository.java @@ -51,7 +51,10 @@ public class LocationRepository extends EntityRepository { dao.locationDAO(), dao, LOCATION_PATCH_FIELDS, - LOCATION_UPDATE_FIELDS); + LOCATION_UPDATE_FIELDS, + true, + true, + true); } @Override @@ -185,11 +188,7 @@ public class LocationRepository extends EntityRepository { // Don't store owner, href and tags as JSON. Build it on the fly based on relationships location.withOwner(null).withService(null).withHref(null).withTags(null); - if (update) { - daoCollection.locationDAO().update(location.getId(), JsonUtils.pojoToJson(location)); - } else { - daoCollection.locationDAO().insert(location); - } + store(location.getId(), location, update); // Restore the relationships location.withOwner(owner).withService(service).withTags(tags); @@ -217,19 +216,6 @@ public class LocationRepository extends EntityRepository { return new LocationUpdater(original, updated, patchOperation); } - public EntityReference getOwner(Location location) throws IOException { - return location != null - ? EntityUtil.populateOwner( - location.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO(), daoCollection.teamDAO()) - : null; - } - - private List getFollowers(Location location) throws IOException { - return location == null - ? null - : EntityUtil.getFollowers(location.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO()); - } - private EntityReference getService(Location location) throws IOException { EntityReference ref = EntityUtil.getService(daoCollection.relationshipDAO(), location.getId(), Entity.STORAGE_SERVICE); @@ -259,16 +245,6 @@ public class LocationRepository extends EntityRepository { } } - private void applyTags(Location location) { - // Add location level tags by adding tag to location relationship - EntityUtil.applyTags(daoCollection.tagDAO(), location.getTags(), location.getFullyQualifiedName()); - location.setTags(getTags(location.getFullyQualifiedName())); // Update tag to handle additional derived tags - } - - private List getTags(String fqn) { - return daoCollection.tagDAO().getTags(fqn); - } - public static class LocationEntityInterface implements EntityInterface { private final Location entity; diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/MessagingServiceRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/MessagingServiceRepository.java index 25669d91a71..9e60d43a561 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/MessagingServiceRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/MessagingServiceRepository.java @@ -25,11 +25,9 @@ import org.openmetadata.catalog.entity.services.MessagingService; import org.openmetadata.catalog.resources.services.messaging.MessagingServiceResource; import org.openmetadata.catalog.type.ChangeDescription; import org.openmetadata.catalog.type.EntityReference; -import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.util.EntityInterface; import org.openmetadata.catalog.util.EntityUtil; import org.openmetadata.catalog.util.EntityUtil.Fields; -import org.openmetadata.catalog.util.JsonUtils; public class MessagingServiceRepository extends EntityRepository { @@ -41,7 +39,10 @@ public class MessagingServiceRepository extends EntityRepository getEntityInterface(MessagingService entity) { @@ -64,15 +67,14 @@ public class MessagingServiceRepository extends EntityRepository getTags() { - return null; - } - @Override public Double getVersion() { return entity.getVersion(); @@ -136,11 +128,6 @@ public class MessagingServiceRepository extends EntityRepository getFollowers() { - throw new UnsupportedOperationException("Messaging service does not support followers"); - } - @Override public ChangeDescription getChangeDescription() { return entity.getChangeDescription(); @@ -161,11 +148,6 @@ public class MessagingServiceRepository extends EntityRepository tags) {} } public class MessagingServiceUpdater extends EntityUpdater { diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/MetricsRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/MetricsRepository.java index 4cf20805a4b..5bd7f276c6e 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/MetricsRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/MetricsRepository.java @@ -29,7 +29,6 @@ import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.util.EntityInterface; import org.openmetadata.catalog.util.EntityUtil; import org.openmetadata.catalog.util.EntityUtil.Fields; -import org.openmetadata.catalog.util.JsonUtils; public class MetricsRepository extends EntityRepository { private static final Fields METRICS_UPDATE_FIELDS = new Fields(MetricsResource.FIELD_LIST, "owner"); @@ -42,7 +41,10 @@ public class MetricsRepository extends EntityRepository { dao.metricsDAO(), dao, Fields.EMPTY_FIELDS, - METRICS_UPDATE_FIELDS); + METRICS_UPDATE_FIELDS, + true, + true, + true); } public static String getFQN(Metrics metrics) { @@ -59,7 +61,9 @@ public class MetricsRepository extends EntityRepository { } @Override - public void restorePatchAttributes(Metrics original, Metrics updated) {} + public void restorePatchAttributes(Metrics original, Metrics updated) { + /* Nothing to do */ + } @Override public EntityInterface getEntityInterface(Metrics entity) { @@ -84,11 +88,7 @@ public class MetricsRepository extends EntityRepository { // Don't store owner, database, href and tags as JSON. Build it on the fly based on relationships metrics.withOwner(null).withService(null).withHref(null).withTags(null); - if (update) { - daoCollection.metricsDAO().update(metrics.getId(), JsonUtils.pojoToJson(metrics)); - } else { - daoCollection.metricsDAO().insert(metrics); - } + store(metrics.getId(), metrics, update); // Restore the relationships metrics.withOwner(owner).withService(service).withTags(tags); @@ -121,28 +121,6 @@ public class MetricsRepository extends EntityRepository { throw new IllegalArgumentException(CatalogExceptionMessage.invalidServiceEntity(service.getType(), Entity.METRICS)); } - private EntityReference getOwner(Metrics metrics) throws IOException { - return metrics == null - ? null - : EntityUtil.populateOwner( - metrics.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO(), daoCollection.teamDAO()); - } - - public void setOwner(Metrics metrics, EntityReference owner) { - EntityUtil.setOwner(daoCollection.relationshipDAO(), metrics.getId(), Entity.METRICS, owner); - metrics.setOwner(owner); - } - - private void applyTags(Metrics metrics) { - // Add chart level tags by adding tag to chart relationship - EntityUtil.applyTags(daoCollection.tagDAO(), metrics.getTags(), metrics.getFullyQualifiedName()); - metrics.setTags(getTags(metrics.getFullyQualifiedName())); // Update tag to handle additional derived tags - } - - private List getTags(String fqn) { - return daoCollection.tagDAO().getTags(fqn); - } - static class MetricsEntityInterface implements EntityInterface { private final Metrics entity; @@ -200,11 +178,6 @@ public class MetricsRepository extends EntityRepository { return entity.getHref(); } - @Override - public List getFollowers() { - throw new UnsupportedOperationException("Metrics does not support followers"); - } - @Override public ChangeDescription getChangeDescription() { return entity.getChangeDescription(); @@ -222,7 +195,7 @@ public class MetricsRepository extends EntityRepository { @Override public Metrics getEntity() { - return null; + return entity; } @Override @@ -231,7 +204,9 @@ public class MetricsRepository extends EntityRepository { } @Override - public void setId(UUID id) {} + public void setId(UUID id) { + entity.setId(id); + } @Override public void setDescription(String description) { diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/MlModelRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/MlModelRepository.java index 2437eb927e2..cd0cc521c66 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/MlModelRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/MlModelRepository.java @@ -37,7 +37,6 @@ import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.util.EntityInterface; import org.openmetadata.catalog.util.EntityUtil; import org.openmetadata.catalog.util.EntityUtil.Fields; -import org.openmetadata.catalog.util.JsonUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,7 +56,10 @@ public class MlModelRepository extends EntityRepository { dao.mlModelDAO(), dao, MODEL_PATCH_FIELDS, - MODEL_UPDATE_FIELDS); + MODEL_UPDATE_FIELDS, + true, + true, + true); } public static String getFQN(MlModel model) { @@ -99,10 +101,6 @@ public class MlModelRepository extends EntityRepository { return new MlModelEntityInterface(entity); } - private List getTags(String fqn) { - return daoCollection.tagDAO().getTags(fqn); - } - private void setMlFeatureSourcesFQN(List mlSources) { mlSources.forEach( s -> { @@ -172,11 +170,7 @@ public class MlModelRepository extends EntityRepository { // Don't store owner, dashboard, href and tags as JSON. Build it on the fly based on relationships mlModel.withOwner(null).withDashboard(null).withHref(null).withTags(null); - if (update) { - daoCollection.mlModelDAO().update(mlModel.getId(), JsonUtils.pojoToJson(mlModel)); - } else { - daoCollection.mlModelDAO().insert(mlModel); - } + store(mlModel.getId(), mlModel, update); // Restore the relationships mlModel.withOwner(owner).withDashboard(dashboard).withTags(tags); @@ -206,13 +200,6 @@ public class MlModelRepository extends EntityRepository { return new MlModelUpdater(original, updated, patchOperation); } - private EntityReference getOwner(MlModel mlModel) throws IOException { - return mlModel == null - ? null - : EntityUtil.populateOwner( - mlModel.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO(), daoCollection.teamDAO()); - } - private EntityReference getDashboard(MlModel mlModel) throws IOException { if (mlModel != null) { List ids = @@ -247,18 +234,6 @@ public class MlModelRepository extends EntityRepository { .deleteFrom(mlModel.getId().toString(), Relationship.USES.ordinal(), Entity.DASHBOARD); } - private void applyTags(MlModel mlModel) { - // Add model level tags by adding tag to model relationship - EntityUtil.applyTags(daoCollection.tagDAO(), mlModel.getTags(), mlModel.getFullyQualifiedName()); - mlModel.setTags(getTags(mlModel.getFullyQualifiedName())); // Update tag to handle additional derived tags - } - - private List getFollowers(MlModel model) throws IOException { - return model == null - ? null - : EntityUtil.getFollowers(model.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO()); - } - public static class MlModelEntityInterface implements EntityInterface { private final MlModel entity; diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/PipelineRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/PipelineRepository.java index 48a82048fab..b9da2833244 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/PipelineRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/PipelineRepository.java @@ -38,7 +38,6 @@ import org.openmetadata.catalog.type.Task; import org.openmetadata.catalog.util.EntityInterface; import org.openmetadata.catalog.util.EntityUtil; import org.openmetadata.catalog.util.EntityUtil.Fields; -import org.openmetadata.catalog.util.JsonUtils; public class PipelineRepository extends EntityRepository { private static final Fields PIPELINE_UPDATE_FIELDS = new Fields(PipelineResource.FIELD_LIST, "owner,tags,tasks"); @@ -52,7 +51,10 @@ public class PipelineRepository extends EntityRepository { dao.pipelineDAO(), dao, PIPELINE_PATCH_FIELDS, - PIPELINE_UPDATE_FIELDS); + PIPELINE_UPDATE_FIELDS, + true, + true, + true); } public static String getFQN(Pipeline pipeline) { @@ -95,10 +97,6 @@ public class PipelineRepository extends EntityRepository { return new PipelineEntityInterface(entity); } - private List getTags(String fqn) { - return daoCollection.tagDAO().getTags(fqn); - } - @Override public void prepare(Pipeline pipeline) throws IOException { populateService(pipeline); @@ -117,11 +115,7 @@ public class PipelineRepository extends EntityRepository { // Don't store owner, database, href and tags as JSON. Build it on the fly based on relationships pipeline.withOwner(null).withService(null).withHref(null).withTags(null); - if (update) { - daoCollection.pipelineDAO().update(pipeline.getId(), JsonUtils.pojoToJson(pipeline)); - } else { - daoCollection.pipelineDAO().insert(pipeline); - } + store(pipeline.getId(), pipeline, update); // Restore the relationships pipeline.withOwner(owner).withService(service).withTags(tags); @@ -173,30 +167,6 @@ public class PipelineRepository extends EntityRepository { throw new IllegalArgumentException(CatalogExceptionMessage.invalidServiceEntity(entityType, Entity.PIPELINE)); } - private EntityReference getOwner(Pipeline pipeline) throws IOException { - return pipeline == null - ? null - : EntityUtil.populateOwner( - pipeline.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO(), daoCollection.teamDAO()); - } - - public void setOwner(Pipeline pipeline, EntityReference owner) { - EntityUtil.setOwner(daoCollection.relationshipDAO(), pipeline.getId(), Entity.PIPELINE, owner); - pipeline.setOwner(owner); - } - - private void applyTags(Pipeline pipeline) { - // Add pipeline level tags by adding tag to pipeline relationship - EntityUtil.applyTags(daoCollection.tagDAO(), pipeline.getTags(), pipeline.getFullyQualifiedName()); - pipeline.setTags(getTags(pipeline.getFullyQualifiedName())); // Update tag to handle additional derived tags - } - - private List getFollowers(Pipeline pipeline) throws IOException { - return pipeline == null - ? null - : EntityUtil.getFollowers(pipeline.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO()); - } - public static class PipelineEntityInterface implements EntityInterface { private final Pipeline entity; diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/PipelineServiceRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/PipelineServiceRepository.java index 046bf3280a0..f232dd7c028 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/PipelineServiceRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/PipelineServiceRepository.java @@ -16,14 +16,12 @@ package org.openmetadata.catalog.jdbi3; import java.io.IOException; import java.net.URI; import java.util.Date; -import java.util.List; import java.util.UUID; import org.openmetadata.catalog.Entity; import org.openmetadata.catalog.entity.services.PipelineService; import org.openmetadata.catalog.resources.services.pipeline.PipelineServiceResource; import org.openmetadata.catalog.type.ChangeDescription; import org.openmetadata.catalog.type.EntityReference; -import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.util.EntityInterface; import org.openmetadata.catalog.util.EntityUtil; import org.openmetadata.catalog.util.EntityUtil.Fields; @@ -38,7 +36,10 @@ public class PipelineServiceRepository extends EntityRepository dao.pipelineServiceDAO(), dao, Fields.EMPTY_FIELDS, - Fields.EMPTY_FIELDS); + Fields.EMPTY_FIELDS, + false, + false, + false); } @Override @@ -47,7 +48,9 @@ public class PipelineServiceRepository extends EntityRepository } @Override - public void restorePatchAttributes(PipelineService original, PipelineService updated) {} + public void restorePatchAttributes(PipelineService original, PipelineService updated) { + /* Nothing to do */ + } @Override public EntityInterface getEntityInterface(PipelineService entity) { @@ -69,7 +72,9 @@ public class PipelineServiceRepository extends EntityRepository } @Override - public void storeRelationships(PipelineService entity) {} + public void storeRelationships(PipelineService entity) { + /* Nothing to do */ + } @Override public EntityUpdater getUpdater(PipelineService original, PipelineService updated, boolean patchOperation) { @@ -98,21 +103,11 @@ public class PipelineServiceRepository extends EntityRepository return entity.getDisplayName(); } - @Override - public EntityReference getOwner() { - return null; - } - @Override public String getFullyQualifiedName() { return entity.getName(); } - @Override - public List getTags() { - return null; - } - @Override public Double getVersion() { return entity.getVersion(); @@ -133,11 +128,6 @@ public class PipelineServiceRepository extends EntityRepository return entity.getHref(); } - @Override - public List getFollowers() { - throw new UnsupportedOperationException("Pipeline service does not support followers"); - } - @Override public ChangeDescription getChangeDescription() { return entity.getChangeDescription(); @@ -158,11 +148,6 @@ public class PipelineServiceRepository extends EntityRepository return entity; } - @Override - public EntityReference getContainer() { - return null; - } - @Override public void setId(UUID id) { entity.setId(id); @@ -190,9 +175,6 @@ public class PipelineServiceRepository extends EntityRepository entity.setChangeDescription(changeDescription); } - @Override - public void setOwner(EntityReference owner) {} - @Override public void setDeleted(boolean flag) { entity.setDeleted(flag); @@ -202,9 +184,6 @@ public class PipelineServiceRepository extends EntityRepository public PipelineService withHref(URI href) { return entity.withHref(href); } - - @Override - public void setTags(List tags) {} } public class PipelineServiceUpdater extends EntityUpdater { diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/PolicyRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/PolicyRepository.java index a11a820d86c..6cad209ccbd 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/PolicyRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/PolicyRepository.java @@ -28,7 +28,6 @@ import org.openmetadata.catalog.resources.policies.PolicyResource; import org.openmetadata.catalog.type.ChangeDescription; import org.openmetadata.catalog.type.EntityReference; import org.openmetadata.catalog.type.PolicyType; -import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.util.EntityInterface; import org.openmetadata.catalog.util.EntityUtil; import org.openmetadata.catalog.util.EntityUtil.Fields; @@ -49,7 +48,10 @@ public class PolicyRepository extends EntityRepository { dao.policyDAO(), dao, POLICY_PATCH_FIELDS, - POLICY_UPDATE_FIELDS); + POLICY_UPDATE_FIELDS, + false, + true, + false); } public static String getFQN(Policy policy) { @@ -85,7 +87,9 @@ public class PolicyRepository extends EntityRepository { } @Override - public void restorePatchAttributes(Policy original, Policy updated) {} + public void restorePatchAttributes(Policy original, Policy updated) { + /* Nothing to do */ + } @Override public EntityInterface getEntityInterface(Policy entity) { @@ -125,11 +129,7 @@ public class PolicyRepository extends EntityRepository { // Don't store owner, location and href as JSON. Build it on the fly based on relationships policy.withOwner(null).withLocation(null).withHref(null); - if (update) { - daoCollection.policyDAO().update(policy.getId(), JsonUtils.pojoToJson(policy)); - } else { - daoCollection.policyDAO().insert(policy); - } + store(policy.getId(), policy, update); // Restore the relationships policy.withOwner(owner).withLocation(location).withHref(href); @@ -182,18 +182,6 @@ public class PolicyRepository extends EntityRepository { // No validation errors, if execution reaches here. } - private EntityReference getOwner(Policy policy) throws IOException { - return policy == null - ? null - : EntityUtil.populateOwner( - policy.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO(), daoCollection.teamDAO()); - } - - private void setOwner(Policy policy, EntityReference owner) { - EntityUtil.setOwner(daoCollection.relationshipDAO(), policy.getId(), Entity.POLICY, owner); - policy.setOwner(owner); - } - private void setLocation(Policy policy, EntityReference location) { if (location == null || location.getId() == null) { return; @@ -240,12 +228,6 @@ public class PolicyRepository extends EntityRepository { return entity.getFullyQualifiedName(); } - @Override - public List getTags() { - // Policy does not have tags. - return null; - } - public List getRules() { return entity.getRules(); } @@ -270,12 +252,6 @@ public class PolicyRepository extends EntityRepository { return entity.getHref(); } - @Override - public List getFollowers() { - // Policy does not have followers. - return null; - } - @Override public EntityReference getEntityReference() { return new EntityReference() @@ -291,11 +267,6 @@ public class PolicyRepository extends EntityRepository { return entity; } - @Override - public EntityReference getContainer() { - return null; - } - @Override public void setId(UUID id) { entity.setId(id); @@ -323,11 +294,6 @@ public class PolicyRepository extends EntityRepository { entity.setChangeDescription(changeDescription); } - @Override - public void setTags(List tags) { - // Policy does not have tags. - } - @Override public void setOwner(EntityReference owner) { entity.setOwner(owner); diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/ReportRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/ReportRepository.java index 3688d362240..f49bcf59606 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/ReportRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/ReportRepository.java @@ -39,7 +39,10 @@ public class ReportRepository extends EntityRepository { dao.reportDAO(), dao, Fields.EMPTY_FIELDS, - REPORT_UPDATE_FIELDS); + REPORT_UPDATE_FIELDS, + true, + true, + true); } @Override @@ -68,8 +71,8 @@ public class ReportRepository extends EntityRepository { @Override public void storeEntity(Report report, boolean update) throws IOException { - // TODO add right checks - daoCollection.reportDAO().insert(report); + report.setHref(null); + store(report.getId(), report, update); } @Override @@ -101,18 +104,6 @@ public class ReportRepository extends EntityRepository { } } - private EntityReference getOwner(Report report) throws IOException { - return report == null - ? null - : EntityUtil.populateOwner( - report.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO(), daoCollection.teamDAO()); - } - - public void setOwner(Report report, EntityReference owner) { - EntityUtil.setOwner(daoCollection.relationshipDAO(), report.getId(), Entity.REPORT, owner); - report.setOwner(owner); - } - public static class ReportEntityInterface implements EntityInterface { private final Report entity; @@ -170,11 +161,6 @@ public class ReportRepository extends EntityRepository { return entity.getHref(); } - @Override - public List getFollowers() { - throw new UnsupportedOperationException("Report does not support followers"); - } - @Override public ChangeDescription getChangeDescription() { return entity.getChangeDescription(); diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/RoleRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/RoleRepository.java index 38b5e62790e..47b617bbd9e 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/RoleRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/RoleRepository.java @@ -16,7 +16,6 @@ package org.openmetadata.catalog.jdbi3; import java.io.IOException; import java.net.URI; import java.util.Date; -import java.util.List; import java.util.UUID; import org.openmetadata.catalog.Entity; import org.openmetadata.catalog.entity.teams.Role; @@ -24,10 +23,8 @@ import org.openmetadata.catalog.exception.CatalogExceptionMessage; import org.openmetadata.catalog.resources.teams.RoleResource; import org.openmetadata.catalog.type.ChangeDescription; import org.openmetadata.catalog.type.EntityReference; -import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.util.EntityInterface; import org.openmetadata.catalog.util.EntityUtil.Fields; -import org.openmetadata.catalog.util.JsonUtils; public class RoleRepository extends EntityRepository { static final Fields ROLE_UPDATE_FIELDS = new Fields(RoleResource.FIELD_LIST, null); @@ -41,7 +38,10 @@ public class RoleRepository extends EntityRepository { dao.roleDAO(), dao, ROLE_PATCH_FIELDS, - ROLE_UPDATE_FIELDS); + ROLE_UPDATE_FIELDS, + false, + false, + false); } @Override @@ -62,22 +62,21 @@ public class RoleRepository extends EntityRepository { } @Override - public void prepare(Role role) throws IOException {} + public void prepare(Role role) throws IOException { + /* Nothing to do */ + } @Override public void storeEntity(Role role, boolean update) throws IOException { // Don't store href as JSON. Build it on the fly based on relationships role.withHref(null); - - if (update) { - daoCollection.roleDAO().update(role.getId(), JsonUtils.pojoToJson(role)); - } else { - daoCollection.roleDAO().insert(role); - } + store(role.getId(), role, update); } @Override - public void storeRelationships(Role role) {} + public void storeRelationships(Role role) { + /* Nothing to do */ + } @Override public EntityUpdater getUpdater(Role original, Role updated, boolean patchOperation) { @@ -106,21 +105,11 @@ public class RoleRepository extends EntityRepository { return entity.getDisplayName(); } - @Override - public EntityReference getOwner() { - return null; - } - @Override public String getFullyQualifiedName() { return entity.getName(); } - @Override - public List getTags() { - return null; - } - @Override public Double getVersion() { return entity.getVersion(); @@ -141,11 +130,6 @@ public class RoleRepository extends EntityRepository { return entity.getHref(); } - @Override - public List getFollowers() { - throw new UnsupportedOperationException("Role does not support followers"); - } - @Override public EntityReference getEntityReference() { return new EntityReference() @@ -162,11 +146,6 @@ public class RoleRepository extends EntityRepository { return entity; } - @Override - public EntityReference getContainer() { - return null; - } - @Override public void setId(UUID id) { entity.setId(id); @@ -194,9 +173,6 @@ public class RoleRepository extends EntityRepository { entity.setChangeDescription(changeDescription); } - @Override - public void setOwner(EntityReference owner) {} - @Override public void setDeleted(boolean flag) { entity.setDeleted(flag); @@ -211,9 +187,6 @@ public class RoleRepository extends EntityRepository { public ChangeDescription getChangeDescription() { return entity.getChangeDescription(); } - - @Override - public void setTags(List tags) {} } /** Handles entity updated from PUT and POST operation. */ diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/StorageServiceRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/StorageServiceRepository.java index 9a664f5379d..848605bb13a 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/StorageServiceRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/StorageServiceRepository.java @@ -18,16 +18,13 @@ import static org.openmetadata.catalog.util.EntityUtil.Fields; import java.io.IOException; import java.net.URI; import java.util.Date; -import java.util.List; import java.util.UUID; import org.openmetadata.catalog.Entity; import org.openmetadata.catalog.entity.services.StorageService; import org.openmetadata.catalog.resources.services.storage.StorageServiceResource; import org.openmetadata.catalog.type.ChangeDescription; import org.openmetadata.catalog.type.EntityReference; -import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.util.EntityInterface; -import org.openmetadata.catalog.util.JsonUtils; public class StorageServiceRepository extends EntityRepository { public StorageServiceRepository(CollectionDAO dao) { @@ -38,7 +35,10 @@ public class StorageServiceRepository extends EntityRepository { dao.storageServiceDAO(), dao, Fields.EMPTY_FIELDS, - Fields.EMPTY_FIELDS); + Fields.EMPTY_FIELDS, + false, + false, + false); } @Override @@ -47,7 +47,9 @@ public class StorageServiceRepository extends EntityRepository { } @Override - public void restorePatchAttributes(StorageService original, StorageService updated) {} + public void restorePatchAttributes(StorageService original, StorageService updated) { + /* Nothing to do */ + } @Override public EntityInterface getEntityInterface(StorageService entity) { @@ -55,19 +57,19 @@ public class StorageServiceRepository extends EntityRepository { } @Override - public void prepare(StorageService entity) {} - - @Override - public void storeEntity(StorageService service, boolean update) throws IOException { - if (update) { - daoCollection.storageServiceDAO().update(service.getId(), JsonUtils.pojoToJson(service)); - } else { - daoCollection.storageServiceDAO().insert(service); - } + public void prepare(StorageService entity) { + /* Nothing to do */ } @Override - public void storeRelationships(StorageService entity) {} + public void storeEntity(StorageService service, boolean update) throws IOException { + store(service.getId(), service, update); + } + + @Override + public void storeRelationships(StorageService entity) { + /* Nothing to do */ + } public static class StorageServiceEntityInterface implements EntityInterface { private final StorageService entity; @@ -91,21 +93,11 @@ public class StorageServiceRepository extends EntityRepository { return entity.getDisplayName(); } - @Override - public EntityReference getOwner() { - return null; - } - @Override public String getFullyQualifiedName() { return entity.getName(); } - @Override - public List getTags() { - return null; - } - @Override public Double getVersion() { return entity.getVersion(); @@ -126,11 +118,6 @@ public class StorageServiceRepository extends EntityRepository { return entity.getHref(); } - @Override - public List getFollowers() { - throw new UnsupportedOperationException("Storage service does not support followers"); - } - @Override public ChangeDescription getChangeDescription() { return entity.getChangeDescription(); @@ -151,11 +138,6 @@ public class StorageServiceRepository extends EntityRepository { return entity; } - @Override - public EntityReference getContainer() { - return null; - } - @Override public void setId(UUID id) { entity.setId(id); @@ -183,9 +165,6 @@ public class StorageServiceRepository extends EntityRepository { entity.setChangeDescription(changeDescription); } - @Override - public void setOwner(EntityReference owner) {} - @Override public void setDeleted(boolean flag) { entity.setDeleted(flag); @@ -195,8 +174,5 @@ public class StorageServiceRepository extends EntityRepository { public StorageService withHref(URI href) { return entity.withHref(href); } - - @Override - public void setTags(List tags) {} } } diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TableRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TableRepository.java index 397cb2a8ce4..35e27e5a763 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TableRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TableRepository.java @@ -82,7 +82,10 @@ public class TableRepository extends EntityRepository { dao.tableDAO(), dao, TABLE_PATCH_FIELDS, - TABLE_UPDATE_FIELDS); + TABLE_UPDATE_FIELDS, + true, + true, + true); } @Override @@ -362,11 +365,7 @@ public class TableRepository extends EntityRepository
{ table.setColumns(cloneWithoutTags(columnWithTags)); table.getColumns().forEach(column -> column.setTags(null)); - if (update) { - daoCollection.tableDAO().update(table.getId(), JsonUtils.pojoToJson(table)); - } else { - daoCollection.tableDAO().insert(table); - } + store(table.getId(), table, update); // Restore the relationships table.withOwner(owner).withDatabase(database).withTags(tags).withColumns(columnWithTags).withService(service); @@ -427,9 +426,10 @@ public class TableRepository extends EntityRepository
{ } } - private void applyTags(Table table) { + @Override + public void applyTags(Table table) { // Add table level tags by adding tag to table relationship - EntityUtil.applyTags(daoCollection.tagDAO(), table.getTags(), table.getFullyQualifiedName()); + super.applyTags(table); applyTags(table.getColumns()); } @@ -454,23 +454,6 @@ public class TableRepository extends EntityRepository
{ } } - private EntityReference getOwner(Table table) throws IOException { - return table == null - ? null - : EntityUtil.populateOwner( - table.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO(), daoCollection.teamDAO()); - } - - private List getFollowers(Table table) throws IOException { - return table == null - ? null - : EntityUtil.getFollowers(table.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO()); - } - - private List getTags(String fqn) { - return daoCollection.tagDAO().getTags(fqn); - } - private void getColumnTags(boolean setTags, List columns) { for (Column c : Optional.ofNullable(columns).orElse(Collections.emptyList())) { c.setTags(setTags ? getTags(c.getFullyQualifiedName()) : null); diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TeamRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TeamRepository.java index c89aaf9c2a0..9b0b30783b1 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TeamRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TeamRepository.java @@ -31,11 +31,9 @@ import org.openmetadata.catalog.exception.CatalogExceptionMessage; import org.openmetadata.catalog.resources.teams.TeamResource; import org.openmetadata.catalog.type.ChangeDescription; import org.openmetadata.catalog.type.EntityReference; -import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.util.EntityInterface; import org.openmetadata.catalog.util.EntityUtil; import org.openmetadata.catalog.util.EntityUtil.Fields; -import org.openmetadata.catalog.util.JsonUtils; public class TeamRepository extends EntityRepository { static final Fields TEAM_UPDATE_FIELDS = new Fields(TeamResource.FIELD_LIST, "profile,users"); @@ -49,7 +47,10 @@ public class TeamRepository extends EntityRepository { dao.teamDAO(), dao, TEAM_PATCH_FIELDS, - TEAM_UPDATE_FIELDS); + TEAM_UPDATE_FIELDS, + false, + false, + false); } public List getUsers(List userIds) { @@ -106,11 +107,7 @@ public class TeamRepository extends EntityRepository { // Don't store users, href as JSON. Build it on the fly based on relationships team.withUsers(null).withHref(null); - if (update) { - daoCollection.teamDAO().update(team.getId(), JsonUtils.pojoToJson(team)); - } else { - daoCollection.teamDAO().insert(team); - } + store(team.getId(), team, update); // Restore the relationships team.withUsers(users); @@ -167,21 +164,11 @@ public class TeamRepository extends EntityRepository { return entity.getDisplayName(); } - @Override - public EntityReference getOwner() { - return null; - } - @Override public String getFullyQualifiedName() { return entity.getName(); } - @Override - public List getTags() { - return null; - } - @Override public Double getVersion() { return entity.getVersion(); @@ -202,11 +189,6 @@ public class TeamRepository extends EntityRepository { return entity.getHref(); } - @Override - public List getFollowers() { - throw new UnsupportedOperationException("Team does not support followers"); - } - @Override public EntityReference getEntityReference() { return new EntityReference() @@ -223,11 +205,6 @@ public class TeamRepository extends EntityRepository { return entity; } - @Override - public EntityReference getContainer() { - return null; - } - @Override public void setId(UUID id) { entity.setId(id); @@ -255,9 +232,6 @@ public class TeamRepository extends EntityRepository { entity.setChangeDescription(changeDescription); } - @Override - public void setOwner(EntityReference owner) {} - @Override public void setDeleted(boolean flag) { entity.setDeleted(flag); @@ -272,9 +246,6 @@ public class TeamRepository extends EntityRepository { public ChangeDescription getChangeDescription() { return entity.getChangeDescription(); } - - @Override - public void setTags(List tags) {} } /** Handles entity updated from PUT and POST operation. */ diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TopicRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TopicRepository.java index 243b87647cd..98e430b0099 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TopicRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TopicRepository.java @@ -25,7 +25,6 @@ import org.openmetadata.catalog.Entity; import org.openmetadata.catalog.entity.data.Topic; import org.openmetadata.catalog.entity.services.MessagingService; import org.openmetadata.catalog.exception.CatalogExceptionMessage; -import org.openmetadata.catalog.jdbi3.EntityRepository.EntityUpdater; import org.openmetadata.catalog.jdbi3.MessagingServiceRepository.MessagingServiceEntityInterface; import org.openmetadata.catalog.resources.topics.TopicResource; import org.openmetadata.catalog.type.ChangeDescription; @@ -35,7 +34,6 @@ import org.openmetadata.catalog.type.topic.CleanupPolicy; import org.openmetadata.catalog.util.EntityInterface; import org.openmetadata.catalog.util.EntityUtil; import org.openmetadata.catalog.util.EntityUtil.Fields; -import org.openmetadata.catalog.util.JsonUtils; public class TopicRepository extends EntityRepository { private static final Fields TOPIC_UPDATE_FIELDS = new Fields(TopicResource.FIELD_LIST, "owner,tags"); @@ -53,7 +51,10 @@ public class TopicRepository extends EntityRepository { dao.topicDAO(), dao, TOPIC_PATCH_FIELDS, - TOPIC_UPDATE_FIELDS); + TOPIC_UPDATE_FIELDS, + true, + true, + true); } @Transaction @@ -81,11 +82,7 @@ public class TopicRepository extends EntityRepository { // Don't store owner, database, href and tags as JSON. Build it on the fly based on relationships topic.withOwner(null).withService(null).withHref(null).withTags(null); - if (update) { - daoCollection.topicDAO().update(topic.getId(), JsonUtils.pojoToJson(topic)); - } else { - daoCollection.topicDAO().insert(topic); - } + store(topic.getId(), topic, update); // Restore the relationships topic.withOwner(owner).withService(service).withTags(tags); @@ -98,23 +95,6 @@ public class TopicRepository extends EntityRepository { applyTags(topic); } - private void applyTags(Topic topic) { - // Add topic level tags by adding tag to topic relationship - EntityUtil.applyTags(daoCollection.tagDAO(), topic.getTags(), topic.getFullyQualifiedName()); - topic.setTags(getTags(topic.getFullyQualifiedName())); // Update tag to handle additional derived tags - } - - public EntityReference getOwner(Topic topic) throws IOException { - return topic != null - ? EntityUtil.populateOwner( - topic.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO(), daoCollection.teamDAO()) - : null; - } - - private void setOwner(Topic topic, EntityReference owner) { - EntityUtil.setOwner(daoCollection.relationshipDAO(), topic.getId(), Entity.TOPIC, owner); - } - @Override public Topic setFields(Topic topic, Fields fields) throws IOException { topic.setService(getService(topic)); @@ -125,7 +105,9 @@ public class TopicRepository extends EntityRepository { } @Override - public void restorePatchAttributes(Topic original, Topic updated) {} + public void restorePatchAttributes(Topic original, Topic updated) { + /* Nothing to do */ + } @Override public EntityRepository.EntityUpdater getUpdater(Topic original, Topic updated, boolean patchOperation) { @@ -137,16 +119,6 @@ public class TopicRepository extends EntityRepository { return new TopicEntityInterface(entity); } - private List getFollowers(Topic topic) throws IOException { - return topic == null - ? null - : EntityUtil.getFollowers(topic.getId(), daoCollection.relationshipDAO(), daoCollection.userDAO()); - } - - private List getTags(String fqn) { - return daoCollection.tagDAO().getTags(fqn); - } - private EntityReference getService(Topic topic) throws IOException { if (topic == null) { return null; diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/UserRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/UserRepository.java index e2829f925ae..d9a83332be2 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/UserRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/UserRepository.java @@ -33,11 +33,9 @@ import org.openmetadata.catalog.exception.CatalogExceptionMessage; import org.openmetadata.catalog.resources.teams.UserResource; import org.openmetadata.catalog.type.ChangeDescription; import org.openmetadata.catalog.type.EntityReference; -import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.util.EntityInterface; import org.openmetadata.catalog.util.EntityUtil; import org.openmetadata.catalog.util.EntityUtil.Fields; -import org.openmetadata.catalog.util.JsonUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,7 +52,10 @@ public class UserRepository extends EntityRepository { dao.userDAO(), dao, USER_PATCH_FIELDS, - USER_UPDATE_FIELDS); + USER_UPDATE_FIELDS, + false, + false, + false); } @Override @@ -74,11 +75,7 @@ public class UserRepository extends EntityRepository { // Don't store roles, teams and href as JSON. Build it on the fly based on relationships user.withRoles(null).withTeams(null).withHref(null); - if (update) { - daoCollection.userDAO().update(user.getId(), JsonUtils.pojoToJson(user)); - } else { - daoCollection.userDAO().insert(user); - } + store(user.getId(), user, update); // Restore the relationships user.withRoles(roles).withTeams(teams); @@ -133,10 +130,6 @@ public class UserRepository extends EntityRepository { daoCollection.relationshipDAO().findTo(user.getId().toString(), FOLLOWS.ordinal())); } - private User validateUser(UUID userId) throws IOException { - return daoCollection.userDAO().findEntityById(userId); - } - public List validateRoles(List roleIds) throws IOException { if (roleIds == null) { return Collections.emptyList(); // Return an empty roles list @@ -221,21 +214,11 @@ public class UserRepository extends EntityRepository { return entity.getDisplayName(); } - @Override - public EntityReference getOwner() { - return null; - } - @Override public String getFullyQualifiedName() { return entity.getName(); } - @Override - public List getTags() { - return null; - } - @Override public Double getVersion() { return entity.getVersion(); @@ -256,11 +239,6 @@ public class UserRepository extends EntityRepository { return entity.getHref(); } - @Override - public List getFollowers() { - throw new UnsupportedOperationException("User does not support followers"); - } - @Override public EntityReference getEntityReference() { return new EntityReference() @@ -277,11 +255,6 @@ public class UserRepository extends EntityRepository { return entity; } - @Override - public EntityReference getContainer() { - return null; - } - @Override public void setId(UUID id) { entity.setId(id); @@ -309,9 +282,6 @@ public class UserRepository extends EntityRepository { entity.setChangeDescription(changeDescription); } - @Override - public void setOwner(EntityReference owner) {} - @Override public void setDeleted(boolean flag) { entity.setDeleted(flag); @@ -326,9 +296,6 @@ public class UserRepository extends EntityRepository { public ChangeDescription getChangeDescription() { return entity.getChangeDescription(); } - - @Override - public void setTags(List tags) {} } /** Handles entity updated from PUT and POST operation. */ diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/WebhookRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/WebhookRepository.java index df6df7aa69a..f2a0088638a 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/WebhookRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/WebhookRepository.java @@ -48,12 +48,10 @@ import org.openmetadata.catalog.type.ChangeEvent; import org.openmetadata.catalog.type.EntityReference; import org.openmetadata.catalog.type.EventType; import org.openmetadata.catalog.type.FailureDetails; -import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.type.Webhook; import org.openmetadata.catalog.type.Webhook.Status; import org.openmetadata.catalog.util.EntityInterface; import org.openmetadata.catalog.util.EntityUtil.Fields; -import org.openmetadata.catalog.util.JsonUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -69,7 +67,10 @@ public class WebhookRepository extends EntityRepository { dao.webhookDAO(), dao, Fields.EMPTY_FIELDS, - Fields.EMPTY_FIELDS); + Fields.EMPTY_FIELDS, + false, + false, + false); } @Override @@ -90,11 +91,7 @@ public class WebhookRepository extends EntityRepository { @Override public void storeEntity(Webhook entity, boolean update) throws IOException { entity.setHref(null); - if (update) { - daoCollection.webhookDAO().update(entity.getId(), JsonUtils.pojoToJson(entity)); - } else { - daoCollection.webhookDAO().insert(entity); - } + store(entity.getId(), entity, update); } @Override @@ -191,21 +188,11 @@ public class WebhookRepository extends EntityRepository { return entity.getName(); } - @Override - public EntityReference getOwner() { - return null; - } - @Override public String getFullyQualifiedName() { return entity.getName(); } - @Override - public List getTags() { - return null; - } - @Override public Double getVersion() { return entity.getVersion(); @@ -236,21 +223,11 @@ public class WebhookRepository extends EntityRepository { return entity.getHref(); } - @Override - public List getFollowers() { - return null; - } - @Override public Webhook getEntity() { return entity; } - @Override - public EntityReference getContainer() { - return null; - } - @Override public ChangeDescription getChangeDescription() { return entity.getChangeDescription(); @@ -267,7 +244,9 @@ public class WebhookRepository extends EntityRepository { } @Override - public void setDisplayName(String displayName) {} + public void setDisplayName(String displayName) { + /* No display name */ + } @Override public void setUpdateDetails(String updatedBy, Date updatedAt) { @@ -281,9 +260,6 @@ public class WebhookRepository extends EntityRepository { entity.setChangeDescription(changeDescription); } - @Override - public void setOwner(EntityReference owner) {} - @Override public void setDeleted(boolean flag) { entity.setDeleted(flag); @@ -293,9 +269,6 @@ public class WebhookRepository extends EntityRepository { public Webhook withHref(URI href) { return entity.withHref(href); } - - @Override - public void setTags(List tags) {} } /** diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/resources/version/VersionResource.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/resources/version/VersionResource.java index 7daf6857df7..e7fe9b8f73a 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/resources/version/VersionResource.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/resources/version/VersionResource.java @@ -52,8 +52,6 @@ public class VersionResource { } } - public VersionResource() {} - @GET @Operation( summary = "Get version of metadata service", diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/security/NoopAuthorizer.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/security/NoopAuthorizer.java index e6684852599..4e91b15a135 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/security/NoopAuthorizer.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/security/NoopAuthorizer.java @@ -22,7 +22,9 @@ public class NoopAuthorizer implements Authorizer { private static final Logger LOG = LoggerFactory.getLogger(NoopAuthorizer.class); @Override - public void init(AuthorizerConfiguration config, Jdbi jdbi) {} + public void init(AuthorizerConfiguration config, Jdbi jdbi) { + /* Nothing to do */ + } @Override public boolean hasPermissions(AuthenticationContext ctx, EntityReference entityOwnership) { diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/util/EntityInterface.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/util/EntityInterface.java index fca6b6de100..ed66bf64f2b 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/util/EntityInterface.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/util/EntityInterface.java @@ -29,11 +29,15 @@ public interface EntityInterface { String getDisplayName(); - EntityReference getOwner(); + default EntityReference getOwner() { + return null; + } String getFullyQualifiedName(); - List getTags(); + default List getTags() { + return null; + } Double getVersion(); @@ -43,7 +47,9 @@ public interface EntityInterface { URI getHref(); - List getFollowers(); + default List getFollowers() { + return null; + } ChangeDescription getChangeDescription(); @@ -51,13 +57,17 @@ public interface EntityInterface { T getEntity(); - EntityReference getContainer(); + default EntityReference getContainer() { + return null; + } void setId(UUID id); void setDescription(String description); - void setTags(List tags); + default void setTags(List tags) { + return; + }; void setDisplayName(String displayName); @@ -65,7 +75,9 @@ public interface EntityInterface { void setChangeDescription(Double newVersion, ChangeDescription changeDescription); - void setOwner(EntityReference owner); + default void setOwner(EntityReference owner) { + return; + }; void setDeleted(boolean flag);