mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-29 19:05:16 +00:00
12803.part2 - Display names are not updated in entity references (#12829)
This commit is contained in:
parent
59a135a7f7
commit
8acc1f61ec
@ -42,7 +42,6 @@ public class CatalogGenericExceptionMapper implements ExceptionMapper<Throwable>
|
|||||||
@Override
|
@Override
|
||||||
public Response toResponse(Throwable ex) {
|
public Response toResponse(Throwable ex) {
|
||||||
LOG.debug(ex.getMessage());
|
LOG.debug(ex.getMessage());
|
||||||
ex.printStackTrace();
|
|
||||||
if (ex instanceof ProcessingException
|
if (ex instanceof ProcessingException
|
||||||
|| ex instanceof IllegalArgumentException
|
|| ex instanceof IllegalArgumentException
|
||||||
|| ex instanceof javax.ws.rs.BadRequestException) {
|
|| ex instanceof javax.ws.rs.BadRequestException) {
|
||||||
|
@ -40,7 +40,7 @@ public class BotRepository extends EntityRepository<Bot> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Bot clearFields(Bot entity, Fields fields) {
|
public Bot clearFields(Bot entity, Fields fields) {
|
||||||
return entity; // Nothing to do
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -74,10 +74,7 @@ public class ChartRepository extends EntityRepository<Chart> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Chart setFields(Chart chart, Fields fields) {
|
public Chart setFields(Chart chart, Fields fields) {
|
||||||
if (chart.getService() == null) {
|
return chart.withService(getContainer(chart.getId()));
|
||||||
chart.setService(getContainer(chart.getId()));
|
|
||||||
}
|
|
||||||
return chart;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,6 +32,7 @@ import org.openmetadata.schema.type.TagLabel.TagSource;
|
|||||||
import org.openmetadata.service.Entity;
|
import org.openmetadata.service.Entity;
|
||||||
import org.openmetadata.service.exception.CatalogExceptionMessage;
|
import org.openmetadata.service.exception.CatalogExceptionMessage;
|
||||||
import org.openmetadata.service.jdbi3.CollectionDAO.EntityRelationshipRecord;
|
import org.openmetadata.service.jdbi3.CollectionDAO.EntityRelationshipRecord;
|
||||||
|
import org.openmetadata.service.jdbi3.EntityRepository.EntityUpdater;
|
||||||
import org.openmetadata.service.resources.tags.ClassificationResource;
|
import org.openmetadata.service.resources.tags.ClassificationResource;
|
||||||
import org.openmetadata.service.util.EntityUtil.Fields;
|
import org.openmetadata.service.util.EntityUtil.Fields;
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ public class ClassificationRepository extends EntityRepository<Classification> {
|
|||||||
dao,
|
dao,
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
|
quoteFqn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -55,13 +57,8 @@ public class ClassificationRepository extends EntityRepository<Classification> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Classification setFields(Classification classification, Fields fields) {
|
public Classification setFields(Classification classification, Fields fields) {
|
||||||
if (fields.contains("termCount")) {
|
classification.withTermCount(fields.contains("termCount") ? getTermCount(classification) : null);
|
||||||
classification.withTermCount(getTermCount(classification));
|
return classification.withUsageCount(fields.contains("usageCount") ? getUsageCount(classification) : null);
|
||||||
}
|
|
||||||
if (fields.contains("usageCount")) {
|
|
||||||
classification.withUsageCount(getUsageCount(classification));
|
|
||||||
}
|
|
||||||
return classification;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -86,18 +83,12 @@ public class ClassificationRepository extends EntityRepository<Classification> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getTermCount(Classification classification) {
|
private int getTermCount(Classification classification) {
|
||||||
if (classification.getTermCount() != null) {
|
|
||||||
return classification.getTermCount();
|
|
||||||
}
|
|
||||||
ListFilter filter =
|
ListFilter filter =
|
||||||
new ListFilter(Include.NON_DELETED).addQueryParam("parent", classification.getFullyQualifiedName());
|
new ListFilter(Include.NON_DELETED).addQueryParam("parent", classification.getFullyQualifiedName());
|
||||||
return daoCollection.tagDAO().listCount(filter);
|
return daoCollection.tagDAO().listCount(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer getUsageCount(Classification classification) {
|
private Integer getUsageCount(Classification classification) {
|
||||||
if (classification.getUsageCount() != null) {
|
|
||||||
return classification.getUsageCount();
|
|
||||||
}
|
|
||||||
return daoCollection.tagUsageDAO().getTagCount(TagSource.CLASSIFICATION.ordinal(), classification.getName());
|
return daoCollection.tagUsageDAO().getTagCount(TagSource.CLASSIFICATION.ordinal(), classification.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import static org.openmetadata.service.Entity.STORAGE_SERVICE;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.json.JsonPatch;
|
import javax.json.JsonPatch;
|
||||||
import org.openmetadata.schema.EntityInterface;
|
import org.openmetadata.schema.EntityInterface;
|
||||||
@ -48,8 +47,7 @@ public class ContainerRepository extends EntityRepository<Container> {
|
|||||||
@Override
|
@Override
|
||||||
public Container setFields(Container container, EntityUtil.Fields fields) {
|
public Container setFields(Container container, EntityUtil.Fields fields) {
|
||||||
setDefaultFields(container);
|
setDefaultFields(container);
|
||||||
container.setChildren(fields.contains("children") ? getChildrenContainers(container) : container.getChildren());
|
container.setParent(fields.contains("parent") ? getParent(container) : container.getParent());
|
||||||
container.setParent(fields.contains("parent") ? getParentContainer(container) : container.getParent());
|
|
||||||
if (container.getDataModel() != null) {
|
if (container.getDataModel() != null) {
|
||||||
populateDataModelColumnTags(fields.contains(FIELD_TAGS), container.getDataModel().getColumns());
|
populateDataModelColumnTags(fields.contains(FIELD_TAGS), container.getDataModel().getColumns());
|
||||||
}
|
}
|
||||||
@ -58,6 +56,7 @@ public class ContainerRepository extends EntityRepository<Container> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Container clearFields(Container container, EntityUtil.Fields fields) {
|
public Container clearFields(Container container, EntityUtil.Fields fields) {
|
||||||
|
container.setChildren(fields.contains("children") ? getChildren(container) : null);
|
||||||
container.setParent(fields.contains("parent") ? container.getParent() : null);
|
container.setParent(fields.contains("parent") ? container.getParent() : null);
|
||||||
return container.withDataModel(fields.contains("dataModel") ? container.getDataModel() : null);
|
return container.withDataModel(fields.contains("dataModel") ? container.getDataModel() : null);
|
||||||
}
|
}
|
||||||
@ -69,33 +68,12 @@ public class ContainerRepository extends EntityRepository<Container> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntityReference getParentContainer(Container container) {
|
|
||||||
if (container == null) return null;
|
|
||||||
return container.getParent() != null
|
|
||||||
? container.getParent()
|
|
||||||
: getFromEntityRef(container.getId(), Relationship.CONTAINS, CONTAINER, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setDefaultFields(Container container) {
|
private void setDefaultFields(Container container) {
|
||||||
if (container.getService() != null) {
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EntityReference parentServiceRef =
|
EntityReference parentServiceRef =
|
||||||
getFromEntityRef(container.getId(), Relationship.CONTAINS, STORAGE_SERVICE, true);
|
getFromEntityRef(container.getId(), Relationship.CONTAINS, STORAGE_SERVICE, true);
|
||||||
container.withService(parentServiceRef);
|
container.withService(parentServiceRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getChildrenContainers(Container container) {
|
|
||||||
if (container == null) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
return !nullOrEmpty(container.getChildren())
|
|
||||||
? container.getChildren()
|
|
||||||
: findTo(container.getId(), CONTAINER, Relationship.CONTAINS, CONTAINER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFullyQualifiedName(Container container) {
|
public void setFullyQualifiedName(Container container) {
|
||||||
if (container.getParent() != null) {
|
if (container.getParent() != null) {
|
||||||
|
@ -161,12 +161,10 @@ public class DashboardDataModelRepository extends EntityRepository<DashboardData
|
|||||||
// TODO move this to base class?
|
// TODO move this to base class?
|
||||||
private void getColumnTags(boolean setTags, List<Column> columns) {
|
private void getColumnTags(boolean setTags, List<Column> columns) {
|
||||||
for (Column c : listOrEmpty(columns)) {
|
for (Column c : listOrEmpty(columns)) {
|
||||||
if (c.getTags() == null) {
|
|
||||||
c.setTags(setTags ? getTags(c.getFullyQualifiedName()) : c.getTags());
|
c.setTags(setTags ? getTags(c.getFullyQualifiedName()) : c.getTags());
|
||||||
getColumnTags(setTags, c.getChildren());
|
getColumnTags(setTags, c.getChildren());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void applyTags(List<Column> columns) {
|
private void applyTags(List<Column> columns) {
|
||||||
// Add column level tags by adding tag to column relationship
|
// Add column level tags by adding tag to column relationship
|
||||||
|
@ -83,16 +83,10 @@ public class DashboardRepository extends EntityRepository<Dashboard> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dashboard setFields(Dashboard dashboard, Fields fields) {
|
public Dashboard setFields(Dashboard dashboard, Fields fields) {
|
||||||
if (dashboard.getService() == null) {
|
|
||||||
dashboard.setService(getContainer(dashboard.getId()));
|
dashboard.setService(getContainer(dashboard.getId()));
|
||||||
}
|
|
||||||
if (dashboard.getCharts() == null) {
|
|
||||||
dashboard.setCharts(fields.contains("charts") ? getRelatedEntities(dashboard, Entity.CHART) : null);
|
dashboard.setCharts(fields.contains("charts") ? getRelatedEntities(dashboard, Entity.CHART) : null);
|
||||||
}
|
|
||||||
if (dashboard.getDataModels() == null) {
|
|
||||||
dashboard.setDataModels(
|
dashboard.setDataModels(
|
||||||
fields.contains("dataModels") ? getRelatedEntities(dashboard, Entity.DASHBOARD_DATA_MODEL) : null);
|
fields.contains("dataModels") ? getRelatedEntities(dashboard, Entity.DASHBOARD_DATA_MODEL) : null);
|
||||||
}
|
|
||||||
if (dashboard.getUsageSummary() == null) {
|
if (dashboard.getUsageSummary() == null) {
|
||||||
dashboard.withUsageSummary(
|
dashboard.withUsageSummary(
|
||||||
fields.contains("usageSummary")
|
fields.contains("usageSummary")
|
||||||
@ -187,10 +181,9 @@ public class DashboardRepository extends EntityRepository<Dashboard> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getRelatedEntities(Dashboard dashboard, String entityType) {
|
private List<EntityReference> getRelatedEntities(Dashboard dashboard, String entityType) {
|
||||||
if (dashboard == null) {
|
return dashboard == null
|
||||||
return Collections.emptyList();
|
? Collections.emptyList()
|
||||||
}
|
: findTo(dashboard.getId(), Entity.DASHBOARD, Relationship.HAS, entityType);
|
||||||
return findTo(dashboard.getId(), Entity.DASHBOARD, Relationship.HAS, entityType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handles entity updated from PUT and POST operation. */
|
/** Handles entity updated from PUT and POST operation. */
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
package org.openmetadata.service.jdbi3;
|
package org.openmetadata.service.jdbi3;
|
||||||
|
|
||||||
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
|
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
|
||||||
import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -51,13 +50,6 @@ public class DataProductRepository extends EntityRepository<DataProduct> {
|
|||||||
return entity.withExperts(fields.contains("experts") ? entity.getExperts() : null);
|
return entity.withExperts(fields.contains("experts") ? entity.getExperts() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO to to inheritance for experts
|
|
||||||
private List<EntityReference> getExperts(DataProduct entity) {
|
|
||||||
return !nullOrEmpty(entity.getExperts())
|
|
||||||
? entity.getExperts()
|
|
||||||
: findTo(entity.getId(), Entity.DATA_PRODUCT, Relationship.EXPERT, Entity.USER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepare(DataProduct entity) {
|
public void prepare(DataProduct entity) {
|
||||||
// Parent, Experts, Owner are already validated
|
// Parent, Experts, Owner are already validated
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
package org.openmetadata.service.jdbi3;
|
package org.openmetadata.service.jdbi3;
|
||||||
|
|
||||||
import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
|
|
||||||
import static org.openmetadata.schema.type.Include.ALL;
|
import static org.openmetadata.schema.type.Include.ALL;
|
||||||
import static org.openmetadata.service.Entity.DATABASE_SERVICE;
|
import static org.openmetadata.service.Entity.DATABASE_SERVICE;
|
||||||
import static org.openmetadata.service.Entity.FIELD_DOMAIN;
|
import static org.openmetadata.service.Entity.FIELD_DOMAIN;
|
||||||
@ -25,6 +24,7 @@ import org.openmetadata.schema.type.EntityReference;
|
|||||||
import org.openmetadata.schema.type.Include;
|
import org.openmetadata.schema.type.Include;
|
||||||
import org.openmetadata.schema.type.Relationship;
|
import org.openmetadata.schema.type.Relationship;
|
||||||
import org.openmetadata.service.Entity;
|
import org.openmetadata.service.Entity;
|
||||||
|
import org.openmetadata.service.jdbi3.EntityRepository.EntityUpdater;
|
||||||
import org.openmetadata.service.resources.databases.DatabaseResource;
|
import org.openmetadata.service.resources.databases.DatabaseResource;
|
||||||
import org.openmetadata.service.util.EntityUtil;
|
import org.openmetadata.service.util.EntityUtil;
|
||||||
import org.openmetadata.service.util.EntityUtil.Fields;
|
import org.openmetadata.service.util.EntityUtil.Fields;
|
||||||
@ -71,18 +71,13 @@ public class DatabaseRepository extends EntityRepository<Database> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getSchemas(Database database) {
|
private List<EntityReference> getSchemas(Database database) {
|
||||||
if (database == null) {
|
return database == null
|
||||||
return null;
|
? null
|
||||||
}
|
|
||||||
return !nullOrEmpty(database.getDatabaseSchemas())
|
|
||||||
? database.getDatabaseSchemas()
|
|
||||||
: findTo(database.getId(), Entity.DATABASE, Relationship.CONTAINS, Entity.DATABASE_SCHEMA);
|
: findTo(database.getId(), Entity.DATABASE, Relationship.CONTAINS, Entity.DATABASE_SCHEMA);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Database setFields(Database database, Fields fields) {
|
public Database setFields(Database database, Fields fields) {
|
||||||
if (database.getService() == null) {
|
|
||||||
database.setService(getContainer(database.getId()));
|
database.setService(getContainer(database.getId()));
|
||||||
}
|
|
||||||
database.setDatabaseSchemas(
|
database.setDatabaseSchemas(
|
||||||
fields.contains("databaseSchemas") ? getSchemas(database) : database.getDatabaseSchemas());
|
fields.contains("databaseSchemas") ? getSchemas(database) : database.getDatabaseSchemas());
|
||||||
if (database.getUsageSummary() == null) {
|
if (database.getUsageSummary() == null) {
|
||||||
|
@ -26,6 +26,7 @@ import org.openmetadata.schema.type.EntityReference;
|
|||||||
import org.openmetadata.schema.type.Include;
|
import org.openmetadata.schema.type.Include;
|
||||||
import org.openmetadata.schema.type.Relationship;
|
import org.openmetadata.schema.type.Relationship;
|
||||||
import org.openmetadata.service.Entity;
|
import org.openmetadata.service.Entity;
|
||||||
|
import org.openmetadata.service.jdbi3.EntityRepository.EntityUpdater;
|
||||||
import org.openmetadata.service.resources.databases.DatabaseSchemaResource;
|
import org.openmetadata.service.resources.databases.DatabaseSchemaResource;
|
||||||
import org.openmetadata.service.util.EntityUtil;
|
import org.openmetadata.service.util.EntityUtil;
|
||||||
import org.openmetadata.service.util.EntityUtil.Fields;
|
import org.openmetadata.service.util.EntityUtil.Fields;
|
||||||
@ -73,10 +74,9 @@ public class DatabaseSchemaRepository extends EntityRepository<DatabaseSchema> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getTables(DatabaseSchema schema) {
|
private List<EntityReference> getTables(DatabaseSchema schema) {
|
||||||
if (schema == null) {
|
return schema == null
|
||||||
return Collections.emptyList();
|
? Collections.emptyList()
|
||||||
}
|
: findTo(schema.getId(), Entity.DATABASE_SCHEMA, Relationship.CONTAINS, Entity.TABLE);
|
||||||
return findTo(schema.getId(), Entity.DATABASE_SCHEMA, Relationship.CONTAINS, Entity.TABLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatabaseSchema setFields(DatabaseSchema schema, Fields fields) {
|
public DatabaseSchema setFields(DatabaseSchema schema, Fields fields) {
|
||||||
@ -92,12 +92,10 @@ public class DatabaseSchemaRepository extends EntityRepository<DatabaseSchema> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setDefaultFields(DatabaseSchema schema) {
|
private void setDefaultFields(DatabaseSchema schema) {
|
||||||
EntityReference databaseRef = schema.getDatabase() != null ? schema.getDatabase() : getContainer(schema.getId());
|
EntityReference databaseRef = getContainer(schema.getId());
|
||||||
if (schema.getService() == null) {
|
|
||||||
Database database = Entity.getEntity(databaseRef, "", Include.ALL);
|
Database database = Entity.getEntity(databaseRef, "", Include.ALL);
|
||||||
schema.withDatabase(databaseRef).withService(database.getService());
|
schema.withDatabase(databaseRef).withService(database.getService());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatabaseSchema setInheritedFields(DatabaseSchema schema, Fields fields) {
|
public DatabaseSchema setInheritedFields(DatabaseSchema schema, Fields fields) {
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
package org.openmetadata.service.jdbi3;
|
package org.openmetadata.service.jdbi3;
|
||||||
|
|
||||||
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
|
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
|
||||||
import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
|
|
||||||
import static org.openmetadata.service.Entity.DOMAIN;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -44,34 +42,13 @@ public class DomainRepository extends EntityRepository<Domain> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Domain setFields(Domain entity, Fields fields) {
|
public Domain setFields(Domain entity, Fields fields) {
|
||||||
entity.withParent(fields.contains("parent") ? getParent(entity) : entity.getParent());
|
return entity.withParent(fields.contains("parent") ? getParent(entity) : entity.getParent());
|
||||||
entity.withChildren(fields.contains("children") ? getChildren(entity) : entity.getChildren());
|
|
||||||
return entity.withExperts(fields.contains("experts") ? getExperts(entity) : entity.getExperts());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Domain clearFields(Domain entity, Fields fields) {
|
public Domain clearFields(Domain entity, Fields fields) {
|
||||||
entity.withParent(fields.contains("parent") ? entity.getParent() : null);
|
entity.withParent(fields.contains("parent") ? entity.getParent() : null);
|
||||||
entity.withChildren(fields.contains("children") ? entity.getChildren() : null);
|
return entity;
|
||||||
return entity.withExperts(fields.contains("experts") ? entity.getExperts() : null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private EntityReference getParent(Domain entity) {
|
|
||||||
return entity.getParent() != null
|
|
||||||
? entity.getParent()
|
|
||||||
: getFromEntityRef(entity.getId(), Relationship.CONTAINS, DOMAIN, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<EntityReference> getChildren(Domain entity) {
|
|
||||||
return !nullOrEmpty(entity.getChildren())
|
|
||||||
? entity.getChildren()
|
|
||||||
: findTo(entity.getId(), DOMAIN, Relationship.CONTAINS, DOMAIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<EntityReference> getExperts(Domain entity) {
|
|
||||||
return !nullOrEmpty(entity.getExperts())
|
|
||||||
? entity.getExperts()
|
|
||||||
: findTo(entity.getId(), Entity.DOMAIN, Relationship.EXPERT, Entity.USER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -681,6 +681,9 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
|||||||
entity.setDomain(fields.contains(FIELD_DOMAIN) ? getDomain(entity) : entity.getDomain());
|
entity.setDomain(fields.contains(FIELD_DOMAIN) ? getDomain(entity) : entity.getDomain());
|
||||||
entity.setDataProducts(fields.contains(FIELD_DATA_PRODUCTS) ? getDataProducts(entity) : entity.getDataProducts());
|
entity.setDataProducts(fields.contains(FIELD_DATA_PRODUCTS) ? getDataProducts(entity) : entity.getDataProducts());
|
||||||
entity.setFollowers(fields.contains(FIELD_FOLLOWERS) ? getFollowers(entity) : entity.getFollowers());
|
entity.setFollowers(fields.contains(FIELD_FOLLOWERS) ? getFollowers(entity) : entity.getFollowers());
|
||||||
|
entity.setChildren(fields.contains("children") ? getChildren(entity) : entity.getChildren());
|
||||||
|
entity.setExperts(fields.contains("experts") ? getExperts(entity) : entity.getExperts());
|
||||||
|
entity.setReviewers(fields.contains("reviewers") ? getReviewers(entity) : entity.getReviewers());
|
||||||
setFields(entity, fields);
|
setFields(entity, fields);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
@ -692,6 +695,9 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
|||||||
entity.setDomain(fields.contains(FIELD_DOMAIN) ? entity.getDomain() : null);
|
entity.setDomain(fields.contains(FIELD_DOMAIN) ? entity.getDomain() : null);
|
||||||
entity.setDataProducts(fields.contains(FIELD_DATA_PRODUCTS) ? entity.getDataProducts() : null);
|
entity.setDataProducts(fields.contains(FIELD_DATA_PRODUCTS) ? entity.getDataProducts() : null);
|
||||||
entity.setFollowers(fields.contains(FIELD_FOLLOWERS) ? entity.getFollowers() : null);
|
entity.setFollowers(fields.contains(FIELD_FOLLOWERS) ? entity.getFollowers() : null);
|
||||||
|
entity.setChildren(fields.contains("children") ? entity.getChildren() : null);
|
||||||
|
entity.setExperts(fields.contains("experts") ? entity.getExperts() : null);
|
||||||
|
entity.setReviewers(fields.contains("reviewers") ? entity.getReviewers() : null);
|
||||||
clearFields(entity, fields);
|
clearFields(entity, fields);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
@ -964,13 +970,17 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
|||||||
Entity.getFeedRepository().deleteByAbout(entityInterface.getId());
|
Entity.getFeedRepository().deleteByAbout(entityInterface.getId());
|
||||||
|
|
||||||
// Remove entity from the cache
|
// Remove entity from the cache
|
||||||
CACHE_WITH_ID.invalidate(new ImmutablePair<>(entityType, entityInterface.getId()));
|
invalidate(entityInterface);
|
||||||
CACHE_WITH_NAME.invalidate(new ImmutablePair<>(entityType, entityInterface.getFullyQualifiedName()));
|
|
||||||
|
|
||||||
// Finally, delete the entity
|
// Finally, delete the entity
|
||||||
dao.delete(id);
|
dao.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void invalidate(T entity) {
|
||||||
|
CACHE_WITH_ID.invalidate(new ImmutablePair<>(entityType, entity.getId()));
|
||||||
|
CACHE_WITH_NAME.invalidate(new ImmutablePair<>(entityType, entity.getFullyQualifiedName()));
|
||||||
|
}
|
||||||
|
|
||||||
@Transaction
|
@Transaction
|
||||||
public PutResponse<T> deleteFollower(String updatedBy, UUID entityId, UUID userId) {
|
public PutResponse<T> deleteFollower(String updatedBy, UUID entityId, UUID userId) {
|
||||||
T entity = find(entityId, NON_DELETED);
|
T entity = find(entityId, NON_DELETED);
|
||||||
@ -1034,8 +1044,7 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
|||||||
if (update) {
|
if (update) {
|
||||||
dao.update(entity.getId(), entity.getFullyQualifiedName(), JsonUtils.pojoToJson(entity));
|
dao.update(entity.getId(), entity.getFullyQualifiedName(), JsonUtils.pojoToJson(entity));
|
||||||
LOG.info("Updated {}:{}:{}", entityType, entity.getId(), entity.getFullyQualifiedName());
|
LOG.info("Updated {}:{}:{}", entityType, entity.getId(), entity.getFullyQualifiedName());
|
||||||
CACHE_WITH_ID.invalidate(new ImmutablePair<>(entityType, entity.getId()));
|
invalidate(entity);
|
||||||
CACHE_WITH_NAME.invalidate(new ImmutablePair<>(entityType, entity.getFullyQualifiedName()));
|
|
||||||
} else {
|
} else {
|
||||||
dao.insert(entity, entity.getFullyQualifiedName());
|
dao.insert(entity, entity.getFullyQualifiedName());
|
||||||
LOG.info("Created {}:{}:{}", entityType, entity.getId(), entity.getFullyQualifiedName());
|
LOG.info("Created {}:{}:{}", entityType, entity.getId(), entity.getFullyQualifiedName());
|
||||||
@ -1172,8 +1181,8 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Object getExtension(T entity) {
|
public Object getExtension(T entity) {
|
||||||
if (!supportsExtension || entity.getExtension() != null) {
|
if (!supportsExtension) {
|
||||||
return entity.getExtension();
|
return null;
|
||||||
}
|
}
|
||||||
String fieldFQNPrefix = TypeRegistry.getCustomPropertyFQNPrefix(entityType);
|
String fieldFQNPrefix = TypeRegistry.getCustomPropertyFQNPrefix(entityType);
|
||||||
List<ExtensionRecord> records =
|
List<ExtensionRecord> records =
|
||||||
@ -1260,7 +1269,7 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected List<TagLabel> getTags(T entity) {
|
protected List<TagLabel> getTags(T entity) {
|
||||||
return !supportsTags || !nullOrEmpty(entity.getTags()) ? entity.getTags() : getTags(entity.getFullyQualifiedName());
|
return !supportsTags ? null : getTags(entity.getFullyQualifiedName());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<TagLabel> getTags(String fqn) {
|
protected List<TagLabel> getTags(String fqn) {
|
||||||
@ -1268,11 +1277,8 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected List<EntityReference> getFollowers(T entity) {
|
protected List<EntityReference> getFollowers(T entity) {
|
||||||
if (!supportsFollower || entity == null) {
|
return !supportsFollower || entity == null
|
||||||
return Collections.emptyList();
|
? Collections.emptyList()
|
||||||
}
|
|
||||||
return !nullOrEmpty(entity.getFollowers())
|
|
||||||
? entity.getFollowers()
|
|
||||||
: findFrom(entity.getId(), entityType, Relationship.FOLLOWS, Entity.USER);
|
: findFrom(entity.getId(), entityType, Relationship.FOLLOWS, Entity.USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1500,22 +1506,31 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public EntityReference getOwner(T entity) {
|
public EntityReference getOwner(T entity) {
|
||||||
return !supportsOwner || entity.getOwner() != null
|
return !supportsOwner ? null : getFromEntityRef(entity.getId(), Relationship.OWNS, null, false);
|
||||||
? entity.getOwner()
|
|
||||||
: getFromEntityRef(entity.getId(), Relationship.OWNS, null, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityReference getDomain(T entity) {
|
public EntityReference getDomain(T entity) {
|
||||||
return entity.getDomain() != null
|
return getFromEntityRef(entity.getId(), Relationship.HAS, DOMAIN, false);
|
||||||
? entity.getDomain()
|
|
||||||
: getFromEntityRef(entity.getId(), Relationship.HAS, DOMAIN, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getDataProducts(T entity) {
|
private List<EntityReference> getDataProducts(T entity) {
|
||||||
if (!supportsDataProducts || nullOrEmpty(entity.getDataProducts())) {
|
return !supportsDataProducts ? null : findFrom(entity.getId(), entityType, Relationship.HAS, DATA_PRODUCT);
|
||||||
return entity.getDataProducts();
|
|
||||||
}
|
}
|
||||||
return findFrom(entity.getId(), entityType, Relationship.HAS, DATA_PRODUCT);
|
|
||||||
|
protected EntityReference getParent(T entity) {
|
||||||
|
return getFromEntityRef(entity.getId(), Relationship.CONTAINS, entityType, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List<EntityReference> getChildren(T entity) {
|
||||||
|
return findTo(entity.getId(), entityType, Relationship.CONTAINS, entityType);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List<EntityReference> getReviewers(T entity) {
|
||||||
|
return findFrom(entity.getId(), entityType, Relationship.REVIEWS, Entity.USER);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List<EntityReference> getExperts(T entity) {
|
||||||
|
return findTo(entity.getId(), entityType, Relationship.EXPERT, Entity.USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityReference getOwner(EntityReference ref) {
|
public EntityReference getOwner(EntityReference ref) {
|
||||||
|
@ -80,14 +80,12 @@ public class GlossaryRepository extends EntityRepository<Glossary> {
|
|||||||
@Override
|
@Override
|
||||||
public Glossary setFields(Glossary glossary, Fields fields) {
|
public Glossary setFields(Glossary glossary, Fields fields) {
|
||||||
glossary.setTermCount(fields.contains("termCount") ? getTermCount(glossary) : glossary.getTermCount());
|
glossary.setTermCount(fields.contains("termCount") ? getTermCount(glossary) : glossary.getTermCount());
|
||||||
glossary.setReviewers(fields.contains("reviewers") ? getReviewers(glossary) : glossary.getReviewers());
|
|
||||||
return glossary.withUsageCount(fields.contains("usageCount") ? getUsageCount(glossary) : glossary.getUsageCount());
|
return glossary.withUsageCount(fields.contains("usageCount") ? getUsageCount(glossary) : glossary.getUsageCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Glossary clearFields(Glossary glossary, Fields fields) {
|
public Glossary clearFields(Glossary glossary, Fields fields) {
|
||||||
glossary.setTermCount(fields.contains("termCount") ? glossary.getTermCount() : null);
|
glossary.setTermCount(fields.contains("termCount") ? glossary.getTermCount() : null);
|
||||||
glossary.setReviewers(fields.contains("reviewers") ? glossary.getReviewers() : null);
|
|
||||||
return glossary.withUsageCount(fields.contains("usageCount") ? glossary.getUsageCount() : null);
|
return glossary.withUsageCount(fields.contains("usageCount") ? glossary.getUsageCount() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,15 +111,10 @@ public class GlossaryRepository extends EntityRepository<Glossary> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Integer getUsageCount(Glossary glossary) {
|
private Integer getUsageCount(Glossary glossary) {
|
||||||
return glossary.getUsageCount() != null
|
return daoCollection.tagUsageDAO().getTagCount(TagSource.GLOSSARY.ordinal(), glossary.getName());
|
||||||
? glossary.getUsageCount()
|
|
||||||
: daoCollection.tagUsageDAO().getTagCount(TagSource.GLOSSARY.ordinal(), glossary.getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer getTermCount(Glossary glossary) {
|
private Integer getTermCount(Glossary glossary) {
|
||||||
if (glossary.getTermCount() != null) {
|
|
||||||
return glossary.getTermCount();
|
|
||||||
}
|
|
||||||
ListFilter filter =
|
ListFilter filter =
|
||||||
new ListFilter(Include.NON_DELETED).addQueryParam("parent", FullyQualifiedName.build(glossary.getName()));
|
new ListFilter(Include.NON_DELETED).addQueryParam("parent", FullyQualifiedName.build(glossary.getName()));
|
||||||
return daoCollection.glossaryTermDAO().listCount(filter);
|
return daoCollection.glossaryTermDAO().listCount(filter);
|
||||||
@ -151,12 +144,6 @@ public class GlossaryRepository extends EntityRepository<Glossary> {
|
|||||||
return glossaryCsv.importCsv(csv, dryRun);
|
return glossaryCsv.importCsv(csv, dryRun);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getReviewers(Glossary entity) {
|
|
||||||
return !nullOrEmpty(entity.getReviewers())
|
|
||||||
? entity.getReviewers()
|
|
||||||
: findFrom(entity.getId(), Entity.GLOSSARY, Relationship.REVIEWS, Entity.USER);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class GlossaryCsv extends EntityCsv<GlossaryTerm> {
|
public static class GlossaryCsv extends EntityCsv<GlossaryTerm> {
|
||||||
public static final CsvDocumentation DOCUMENTATION = getCsvDocumentation(Entity.GLOSSARY);
|
public static final CsvDocumentation DOCUMENTATION = getCsvDocumentation(Entity.GLOSSARY);
|
||||||
public static final List<CsvHeader> HEADERS = DOCUMENTATION.getHeaders();
|
public static final List<CsvHeader> HEADERS = DOCUMENTATION.getHeaders();
|
||||||
|
@ -72,17 +72,13 @@ public class GlossaryTermRepository extends EntityRepository<GlossaryTerm> {
|
|||||||
@Override
|
@Override
|
||||||
public GlossaryTerm setFields(GlossaryTerm entity, Fields fields) {
|
public GlossaryTerm setFields(GlossaryTerm entity, Fields fields) {
|
||||||
entity.withGlossary(getGlossary(entity)).withParent(getParent(entity));
|
entity.withGlossary(getGlossary(entity)).withParent(getParent(entity));
|
||||||
entity.setChildren(fields.contains("children") ? getChildren(entity) : entity.getChildren());
|
|
||||||
entity.setRelatedTerms(fields.contains("relatedTerms") ? getRelatedTerms(entity) : entity.getRelatedTerms());
|
entity.setRelatedTerms(fields.contains("relatedTerms") ? getRelatedTerms(entity) : entity.getRelatedTerms());
|
||||||
entity.setReviewers(fields.contains(FIELD_REVIEWERS) ? getReviewers(entity) : entity.getReviewers());
|
|
||||||
return entity.withUsageCount(fields.contains("usageCount") ? getUsageCount(entity) : entity.getUsageCount());
|
return entity.withUsageCount(fields.contains("usageCount") ? getUsageCount(entity) : entity.getUsageCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GlossaryTerm clearFields(GlossaryTerm entity, Fields fields) {
|
public GlossaryTerm clearFields(GlossaryTerm entity, Fields fields) {
|
||||||
entity.setChildren(fields.contains("children") ? entity.getChildren() : null);
|
|
||||||
entity.setRelatedTerms(fields.contains("relatedTerms") ? entity.getRelatedTerms() : null);
|
entity.setRelatedTerms(fields.contains("relatedTerms") ? entity.getRelatedTerms() : null);
|
||||||
entity.setReviewers(fields.contains(FIELD_REVIEWERS) ? entity.getReviewers() : null);
|
|
||||||
return entity.withUsageCount(fields.contains("usageCount") ? entity.getUsageCount() : null);
|
return entity.withUsageCount(fields.contains("usageCount") ? entity.getUsageCount() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,33 +127,11 @@ public class GlossaryTermRepository extends EntityRepository<GlossaryTerm> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Integer getUsageCount(GlossaryTerm term) {
|
private Integer getUsageCount(GlossaryTerm term) {
|
||||||
return term.getUsageCount() != null
|
return daoCollection.tagUsageDAO().getTagCount(TagSource.GLOSSARY.ordinal(), term.getFullyQualifiedName());
|
||||||
? term.getUsageCount()
|
|
||||||
: daoCollection.tagUsageDAO().getTagCount(TagSource.GLOSSARY.ordinal(), term.getFullyQualifiedName());
|
|
||||||
}
|
|
||||||
|
|
||||||
private EntityReference getParent(GlossaryTerm entity) {
|
|
||||||
return entity.getParent() != null
|
|
||||||
? entity.getParent()
|
|
||||||
: getFromEntityRef(entity.getId(), Relationship.CONTAINS, GLOSSARY_TERM, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<EntityReference> getChildren(GlossaryTerm entity) {
|
|
||||||
return !nullOrEmpty(entity.getChildren())
|
|
||||||
? entity.getChildren()
|
|
||||||
: findTo(entity.getId(), GLOSSARY_TERM, Relationship.CONTAINS, GLOSSARY_TERM);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getRelatedTerms(GlossaryTerm entity) {
|
private List<EntityReference> getRelatedTerms(GlossaryTerm entity) {
|
||||||
return !nullOrEmpty(entity.getRelatedTerms())
|
return findBoth(entity.getId(), GLOSSARY_TERM, Relationship.RELATED_TO, GLOSSARY_TERM);
|
||||||
? entity.getRelatedTerms()
|
|
||||||
: findBoth(entity.getId(), GLOSSARY_TERM, Relationship.RELATED_TO, GLOSSARY_TERM);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<EntityReference> getReviewers(GlossaryTerm entity) {
|
|
||||||
return !nullOrEmpty(entity.getReviewers())
|
|
||||||
? entity.getReviewers()
|
|
||||||
: findFrom(entity.getId(), GLOSSARY_TERM, Relationship.REVIEWS, Entity.USER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,12 +45,9 @@ public class KpiRepository extends EntityRepository<Kpi> {
|
|||||||
@Override
|
@Override
|
||||||
public Kpi setFields(Kpi kpi, EntityUtil.Fields fields) {
|
public Kpi setFields(Kpi kpi, EntityUtil.Fields fields) {
|
||||||
kpi.setDataInsightChart(fields.contains("dataInsightChart") ? getDataInsightChart(kpi) : kpi.getDataInsightChart());
|
kpi.setDataInsightChart(fields.contains("dataInsightChart") ? getDataInsightChart(kpi) : kpi.getDataInsightChart());
|
||||||
if (kpi.getKpiResult() == null) {
|
return kpi.withKpiResult(
|
||||||
kpi.withKpiResult(
|
|
||||||
fields.contains(KPI_RESULT_FIELD) ? getKpiResult(kpi.getFullyQualifiedName()) : kpi.getKpiResult());
|
fields.contains(KPI_RESULT_FIELD) ? getKpiResult(kpi.getFullyQualifiedName()) : kpi.getKpiResult());
|
||||||
}
|
}
|
||||||
return kpi;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Kpi clearFields(Kpi kpi, EntityUtil.Fields fields) {
|
public Kpi clearFields(Kpi kpi, EntityUtil.Fields fields) {
|
||||||
@ -155,9 +152,7 @@ public class KpiRepository extends EntityRepository<Kpi> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private EntityReference getDataInsightChart(Kpi kpi) {
|
private EntityReference getDataInsightChart(Kpi kpi) {
|
||||||
return kpi.getDataInsightChart() != null
|
return getToEntityRef(kpi.getId(), Relationship.USES, DATA_INSIGHT_CHART, true);
|
||||||
? kpi.getDataInsightChart()
|
|
||||||
: getToEntityRef(kpi.getId(), Relationship.USES, DATA_INSIGHT_CHART, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public KpiResult getKpiResult(String fqn) {
|
public KpiResult getKpiResult(String fqn) {
|
||||||
|
@ -38,9 +38,7 @@ public class MetricsRepository extends EntityRepository<Metrics> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Metrics setFields(Metrics metrics, Fields fields) {
|
public Metrics setFields(Metrics metrics, Fields fields) {
|
||||||
if (metrics.getService() == null) {
|
|
||||||
metrics.setService(getContainer(metrics.getId())); // service is a default field
|
metrics.setService(getContainer(metrics.getId())); // service is a default field
|
||||||
}
|
|
||||||
if (metrics.getUsageSummary() == null) {
|
if (metrics.getUsageSummary() == null) {
|
||||||
metrics.withUsageSummary(
|
metrics.withUsageSummary(
|
||||||
fields.contains("usageSummary")
|
fields.contains("usageSummary")
|
||||||
|
@ -76,9 +76,7 @@ public class MlModelRepository extends EntityRepository<MlModel> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MlModel setFields(MlModel mlModel, Fields fields) {
|
public MlModel setFields(MlModel mlModel, Fields fields) {
|
||||||
if (mlModel.getService() == null) {
|
|
||||||
mlModel.setService(getContainer(mlModel.getId()));
|
mlModel.setService(getContainer(mlModel.getId()));
|
||||||
}
|
|
||||||
mlModel.setDashboard(fields.contains("dashboard") ? getDashboard(mlModel) : mlModel.getDashboard());
|
mlModel.setDashboard(fields.contains("dashboard") ? getDashboard(mlModel) : mlModel.getDashboard());
|
||||||
if (mlModel.getUsageSummary() == null) {
|
if (mlModel.getUsageSummary() == null) {
|
||||||
mlModel.withUsageSummary(
|
mlModel.withUsageSummary(
|
||||||
@ -279,12 +277,7 @@ public class MlModelRepository extends EntityRepository<MlModel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private EntityReference getDashboard(MlModel mlModel) {
|
private EntityReference getDashboard(MlModel mlModel) {
|
||||||
if (mlModel == null) {
|
return mlModel == null ? null : getToEntityRef(mlModel.getId(), Relationship.USES, DASHBOARD, false);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return mlModel.getDashboard() != null
|
|
||||||
? mlModel.getDashboard()
|
|
||||||
: getToEntityRef(mlModel.getId(), Relationship.USES, DASHBOARD, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDashboard(MlModel mlModel, EntityReference dashboard) {
|
public void setDashboard(MlModel mlModel, EntityReference dashboard) {
|
||||||
|
@ -100,9 +100,7 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Pipeline setFields(Pipeline pipeline, Fields fields) {
|
public Pipeline setFields(Pipeline pipeline, Fields fields) {
|
||||||
if (pipeline.getService() == null) {
|
|
||||||
pipeline.setService(getContainer(pipeline.getId()));
|
pipeline.setService(getContainer(pipeline.getId()));
|
||||||
}
|
|
||||||
getTaskTags(fields.contains(FIELD_TAGS), pipeline.getTasks());
|
getTaskTags(fields.contains(FIELD_TAGS), pipeline.getTasks());
|
||||||
return pipeline.withPipelineStatus(
|
return pipeline.withPipelineStatus(
|
||||||
fields.contains("pipelineStatus") ? getPipelineStatus(pipeline) : pipeline.getPipelineStatus());
|
fields.contains("pipelineStatus") ? getPipelineStatus(pipeline) : pipeline.getPipelineStatus());
|
||||||
@ -115,9 +113,6 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private PipelineStatus getPipelineStatus(Pipeline pipeline) {
|
private PipelineStatus getPipelineStatus(Pipeline pipeline) {
|
||||||
if (pipeline.getPipelineStatus() != null) {
|
|
||||||
return pipeline.getPipelineStatus();
|
|
||||||
}
|
|
||||||
return JsonUtils.readValue(
|
return JsonUtils.readValue(
|
||||||
getLatestExtensionFromTimeseries(pipeline.getFullyQualifiedName(), PIPELINE_STATUS_EXTENSION),
|
getLatestExtensionFromTimeseries(pipeline.getFullyQualifiedName(), PIPELINE_STATUS_EXTENSION),
|
||||||
PipelineStatus.class);
|
PipelineStatus.class);
|
||||||
|
@ -15,7 +15,6 @@ package org.openmetadata.service.jdbi3;
|
|||||||
|
|
||||||
import static java.lang.Boolean.FALSE;
|
import static java.lang.Boolean.FALSE;
|
||||||
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
|
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
|
||||||
import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
|
|
||||||
import static org.openmetadata.schema.type.MetadataOperation.EDIT_ALL;
|
import static org.openmetadata.schema.type.MetadataOperation.EDIT_ALL;
|
||||||
import static org.openmetadata.schema.type.MetadataOperation.VIEW_ALL;
|
import static org.openmetadata.schema.type.MetadataOperation.VIEW_ALL;
|
||||||
import static org.openmetadata.service.Entity.ALL_RESOURCES;
|
import static org.openmetadata.service.Entity.ALL_RESOURCES;
|
||||||
@ -64,16 +63,12 @@ public class PolicyRepository extends EntityRepository<Policy> {
|
|||||||
|
|
||||||
/* Get all the teams that use this policy */
|
/* Get all the teams that use this policy */
|
||||||
private List<EntityReference> getTeams(Policy policy) {
|
private List<EntityReference> getTeams(Policy policy) {
|
||||||
return !nullOrEmpty(policy.getTeams())
|
return findFrom(policy.getId(), POLICY, Relationship.HAS, Entity.TEAM);
|
||||||
? policy.getTeams()
|
|
||||||
: findFrom(policy.getId(), POLICY, Relationship.HAS, Entity.TEAM);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get all the roles that use this policy */
|
/* Get all the roles that use this policy */
|
||||||
private List<EntityReference> getRoles(Policy policy) {
|
private List<EntityReference> getRoles(Policy policy) {
|
||||||
return !nullOrEmpty(policy.getRoles())
|
return findFrom(policy.getId(), POLICY, Relationship.HAS, Entity.ROLE);
|
||||||
? policy.getRoles()
|
|
||||||
: findFrom(policy.getId(), POLICY, Relationship.HAS, Entity.ROLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,8 +42,7 @@ public class QueryRepository extends EntityRepository<Query> {
|
|||||||
public Query setFields(Query entity, EntityUtil.Fields fields) {
|
public Query setFields(Query entity, EntityUtil.Fields fields) {
|
||||||
entity.setVotes(fields.contains("votes") ? getVotes(entity) : entity.getVotes());
|
entity.setVotes(fields.contains("votes") ? getVotes(entity) : entity.getVotes());
|
||||||
entity.setQueryUsedIn(fields.contains(QUERY_USED_IN_FIELD) ? getQueryUsage(entity) : entity.getQueryUsedIn());
|
entity.setQueryUsedIn(fields.contains(QUERY_USED_IN_FIELD) ? getQueryUsage(entity) : entity.getQueryUsedIn());
|
||||||
entity.setUsers(fields.contains("users") ? getQueryUsers(entity) : entity.getUsers());
|
return entity.withUsers(fields.contains("users") ? getQueryUsers(entity) : entity.getUsers());
|
||||||
return entity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -54,23 +53,15 @@ public class QueryRepository extends EntityRepository<Query> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<EntityReference> getQueryUsage(Query queryEntity) {
|
public List<EntityReference> getQueryUsage(Query queryEntity) {
|
||||||
if (queryEntity == null) {
|
return queryEntity == null
|
||||||
return Collections.emptyList();
|
? Collections.emptyList()
|
||||||
}
|
: findFrom(queryEntity.getId(), Entity.QUERY, Relationship.MENTIONED_IN, null);
|
||||||
if (!nullOrEmpty(queryEntity.getQueryUsedIn())) {
|
|
||||||
return queryEntity.getQueryUsedIn();
|
|
||||||
}
|
|
||||||
return findFrom(queryEntity.getId(), Entity.QUERY, Relationship.MENTIONED_IN, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EntityReference> getQueryUsers(Query queryEntity) {
|
public List<EntityReference> getQueryUsers(Query queryEntity) {
|
||||||
if (queryEntity == null) {
|
return queryEntity == null
|
||||||
return Collections.emptyList();
|
? Collections.emptyList()
|
||||||
}
|
: findFrom(queryEntity.getId(), Entity.QUERY, Relationship.USES, USER);
|
||||||
if (!nullOrEmpty(queryEntity.getUsers())) {
|
|
||||||
return queryEntity.getUsers();
|
|
||||||
}
|
|
||||||
return findFrom(queryEntity.getId(), Entity.QUERY, Relationship.USES, USER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,9 +30,7 @@ public class ReportRepository extends EntityRepository<Report> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Report setFields(Report report, Fields fields) {
|
public Report setFields(Report report, Fields fields) {
|
||||||
if (report.getService() == null) {
|
|
||||||
report.setService(getService(report)); // service is a default field
|
report.setService(getService(report)); // service is a default field
|
||||||
}
|
|
||||||
if (report.getUsageSummary() == null) {
|
if (report.getUsageSummary() == null) {
|
||||||
report.withUsageSummary(
|
report.withUsageSummary(
|
||||||
fields.contains("usageSummary")
|
fields.contains("usageSummary")
|
||||||
|
@ -15,7 +15,6 @@ package org.openmetadata.service.jdbi3;
|
|||||||
|
|
||||||
import static java.lang.Boolean.FALSE;
|
import static java.lang.Boolean.FALSE;
|
||||||
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
|
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
|
||||||
import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
|
|
||||||
import static org.openmetadata.service.Entity.POLICIES;
|
import static org.openmetadata.service.Entity.POLICIES;
|
||||||
import static org.openmetadata.service.util.EntityUtil.entityReferenceMatch;
|
import static org.openmetadata.service.util.EntityUtil.entityReferenceMatch;
|
||||||
|
|
||||||
@ -54,21 +53,15 @@ public class RoleRepository extends EntityRepository<Role> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getPolicies(@NonNull Role role) {
|
private List<EntityReference> getPolicies(@NonNull Role role) {
|
||||||
return !nullOrEmpty(role.getPolicies())
|
return findTo(role.getId(), Entity.ROLE, Relationship.HAS, Entity.POLICY);
|
||||||
? role.getPolicies()
|
|
||||||
: findTo(role.getId(), Entity.ROLE, Relationship.HAS, Entity.POLICY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getUsers(@NonNull Role role) {
|
private List<EntityReference> getUsers(@NonNull Role role) {
|
||||||
return !nullOrEmpty(role.getUsers())
|
return findFrom(role.getId(), Entity.ROLE, Relationship.HAS, Entity.USER);
|
||||||
? role.getUsers()
|
|
||||||
: findFrom(role.getId(), Entity.ROLE, Relationship.HAS, Entity.USER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getTeams(@NonNull Role role) {
|
private List<EntityReference> getTeams(@NonNull Role role) {
|
||||||
return !nullOrEmpty(role.getTeams())
|
return findFrom(role.getId(), Entity.ROLE, Relationship.HAS, Entity.TEAM);
|
||||||
? role.getTeams()
|
|
||||||
: findFrom(role.getId(), Entity.ROLE, Relationship.HAS, Entity.TEAM);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,7 +58,6 @@ public abstract class ServiceEntityRepository<
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T setFields(T entity, EntityUtil.Fields fields) {
|
public T setFields(T entity, EntityUtil.Fields fields) {
|
||||||
// TODO add getPipelines to ServiceEntityInterface
|
|
||||||
entity.setPipelines(fields.contains("pipelines") ? getIngestionPipelines(entity) : null);
|
entity.setPipelines(fields.contains("pipelines") ? getIngestionPipelines(entity) : null);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,6 @@ public class TableRepository extends EntityRepository<Table> {
|
|||||||
@Override
|
@Override
|
||||||
public Table setFields(Table table, Fields fields) {
|
public Table setFields(Table table, Fields fields) {
|
||||||
setDefaultFields(table);
|
setDefaultFields(table);
|
||||||
// TODO fix this
|
|
||||||
if (table.getUsageSummary() == null) {
|
if (table.getUsageSummary() == null) {
|
||||||
table.setUsageSummary(
|
table.setUsageSummary(
|
||||||
fields.contains("usageSummary")
|
fields.contains("usageSummary")
|
||||||
@ -172,9 +171,7 @@ public class TableRepository extends EntityRepository<Table> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setDefaultFields(Table table) {
|
private void setDefaultFields(Table table) {
|
||||||
EntityReference schemaRef =
|
EntityReference schemaRef = getContainer(table.getId());
|
||||||
table.getDatabaseSchema() != null ? table.getDatabaseSchema() : getContainer(table.getId());
|
|
||||||
// TODO optimize
|
|
||||||
DatabaseSchema schema = Entity.getEntity(schemaRef, "", ALL);
|
DatabaseSchema schema = Entity.getEntity(schemaRef, "", ALL);
|
||||||
table.withDatabaseSchema(schemaRef).withDatabase(schema.getDatabase()).withService(schema.getService());
|
table.withDatabaseSchema(schemaRef).withDatabase(schema.getDatabase()).withService(schema.getService());
|
||||||
}
|
}
|
||||||
@ -295,9 +292,6 @@ public class TableRepository extends EntityRepository<Table> {
|
|||||||
|
|
||||||
@Transaction
|
@Transaction
|
||||||
public TestSuite getTestSuite(Table table) {
|
public TestSuite getTestSuite(Table table) {
|
||||||
if (table.getTestSuite() != null) {
|
|
||||||
return table.getTestSuite();
|
|
||||||
}
|
|
||||||
List<CollectionDAO.EntityRelationshipRecord> entityRelationshipRecords =
|
List<CollectionDAO.EntityRelationshipRecord> entityRelationshipRecords =
|
||||||
daoCollection.relationshipDAO().findTo(table.getId().toString(), TABLE, Relationship.CONTAINS.ordinal());
|
daoCollection.relationshipDAO().findTo(table.getId().toString(), TABLE, Relationship.CONTAINS.ordinal());
|
||||||
Optional<CollectionDAO.EntityRelationshipRecord> testSuiteRelationshipRecord =
|
Optional<CollectionDAO.EntityRelationshipRecord> testSuiteRelationshipRecord =
|
||||||
@ -778,12 +772,10 @@ public class TableRepository extends EntityRepository<Table> {
|
|||||||
// TODO duplicated code
|
// TODO duplicated code
|
||||||
private void getColumnTags(boolean setTags, List<Column> columns) {
|
private void getColumnTags(boolean setTags, List<Column> columns) {
|
||||||
for (Column c : listOrEmpty(columns)) {
|
for (Column c : listOrEmpty(columns)) {
|
||||||
if (c.getTags() == null) {
|
|
||||||
c.setTags(setTags ? getTags(c.getFullyQualifiedName()) : c.getTags());
|
c.setTags(setTags ? getTags(c.getFullyQualifiedName()) : c.getTags());
|
||||||
getColumnTags(setTags, c.getChildren());
|
getColumnTags(setTags, c.getChildren());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void validateTableFQN(String fqn) {
|
private void validateTableFQN(String fqn) {
|
||||||
try {
|
try {
|
||||||
@ -904,9 +896,6 @@ public class TableRepository extends EntityRepository<Table> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TableJoins getJoins(Table table) {
|
private TableJoins getJoins(Table table) {
|
||||||
if (table.getJoins() != null) {
|
|
||||||
return table.getJoins();
|
|
||||||
}
|
|
||||||
String today = RestUtil.DATE_FORMAT.format(new Date());
|
String today = RestUtil.DATE_FORMAT.format(new Date());
|
||||||
String todayMinus30Days = CommonUtil.getDateStringByOffset(RestUtil.DATE_FORMAT, today, -30);
|
String todayMinus30Days = CommonUtil.getDateStringByOffset(RestUtil.DATE_FORMAT, today, -30);
|
||||||
return new TableJoins()
|
return new TableJoins()
|
||||||
@ -994,11 +983,9 @@ public class TableRepository extends EntityRepository<Table> {
|
|||||||
// Add custom metrics info to columns if requested
|
// Add custom metrics info to columns if requested
|
||||||
List<Column> columns = table.getColumns();
|
List<Column> columns = table.getColumns();
|
||||||
for (Column c : listOrEmpty(columns)) {
|
for (Column c : listOrEmpty(columns)) {
|
||||||
if (nullOrEmpty(c.getCustomMetrics())) {
|
|
||||||
c.setCustomMetrics(setMetrics ? getCustomMetrics(table, c.getName()) : c.getCustomMetrics());
|
c.setCustomMetrics(setMetrics ? getCustomMetrics(table, c.getName()) : c.getCustomMetrics());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void validateEntityLinkFieldExists(EntityLink entityLink, TaskType taskType) {
|
private void validateEntityLinkFieldExists(EntityLink entityLink, TaskType taskType) {
|
||||||
if (entityLink.getFieldName() == null) {
|
if (entityLink.getFieldName() == null) {
|
||||||
|
@ -115,7 +115,6 @@ public class TagRepository extends EntityRepository<Tag> {
|
|||||||
@Override
|
@Override
|
||||||
public Tag setFields(Tag tag, Fields fields) {
|
public Tag setFields(Tag tag, Fields fields) {
|
||||||
tag.withClassification(getClassification(tag)).withParent(getParent(tag));
|
tag.withClassification(getClassification(tag)).withParent(getParent(tag));
|
||||||
tag.setChildren(fields.contains("children") ? getChildren(tag) : tag.getChildren());
|
|
||||||
if (fields.contains("usageCount")) {
|
if (fields.contains("usageCount")) {
|
||||||
tag.withUsageCount(getUsageCount(tag));
|
tag.withUsageCount(getUsageCount(tag));
|
||||||
}
|
}
|
||||||
@ -124,7 +123,6 @@ public class TagRepository extends EntityRepository<Tag> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Tag clearFields(Tag tag, Fields fields) {
|
public Tag clearFields(Tag tag, Fields fields) {
|
||||||
tag.setChildren(fields.contains("children") ? tag.getChildren() : null);
|
|
||||||
return tag.withUsageCount(fields.contains("usageCount") ? tag.getUsageCount() : null);
|
return tag.withUsageCount(fields.contains("usageCount") ? tag.getUsageCount() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,21 +132,8 @@ public class TagRepository extends EntityRepository<Tag> {
|
|||||||
: daoCollection.tagUsageDAO().getTagCount(TagSource.CLASSIFICATION.ordinal(), tag.getFullyQualifiedName());
|
: daoCollection.tagUsageDAO().getTagCount(TagSource.CLASSIFICATION.ordinal(), tag.getFullyQualifiedName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getChildren(Tag entity) {
|
|
||||||
// Don't use cache to handle tag name changes
|
|
||||||
return !nullOrEmpty(entity.getChildren())
|
|
||||||
? entity.getChildren()
|
|
||||||
: findTo(entity.getId(), TAG, Relationship.CONTAINS, TAG);
|
|
||||||
}
|
|
||||||
|
|
||||||
private EntityReference getParent(Tag tag) {
|
|
||||||
return tag.getParent() != null ? tag.getParent() : getFromEntityRef(tag.getId(), Relationship.CONTAINS, TAG, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private EntityReference getClassification(Tag tag) {
|
private EntityReference getClassification(Tag tag) {
|
||||||
return tag.getClassification() != null
|
return getFromEntityRef(tag.getId(), Relationship.CONTAINS, Entity.CLASSIFICATION, true);
|
||||||
? tag.getClassification()
|
|
||||||
: getFromEntityRef(tag.getId(), Relationship.CONTAINS, Entity.CLASSIFICATION, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addClassificationRelationship(Tag term) {
|
private void addClassificationRelationship(Tag term) {
|
||||||
|
@ -95,14 +95,9 @@ public class TeamRepository extends EntityRepository<Team> {
|
|||||||
team.setDefaultRoles(fields.contains(DEFAULT_ROLES) ? getDefaultRoles(team) : team.getDefaultRoles());
|
team.setDefaultRoles(fields.contains(DEFAULT_ROLES) ? getDefaultRoles(team) : team.getDefaultRoles());
|
||||||
team.setInheritedRoles(fields.contains(DEFAULT_ROLES) ? getInheritedRoles(team) : team.getInheritedRoles());
|
team.setInheritedRoles(fields.contains(DEFAULT_ROLES) ? getInheritedRoles(team) : team.getInheritedRoles());
|
||||||
team.setParents(fields.contains(PARENTS_FIELD) ? getParents(team) : team.getParents());
|
team.setParents(fields.contains(PARENTS_FIELD) ? getParents(team) : team.getParents());
|
||||||
if (team.getChildren() == null) {
|
|
||||||
team.setChildren(fields.contains("children") ? getChildren(team.getId()) : team.getChildren());
|
|
||||||
}
|
|
||||||
team.setPolicies(fields.contains("policies") ? getPolicies(team) : team.getPolicies());
|
team.setPolicies(fields.contains("policies") ? getPolicies(team) : team.getPolicies());
|
||||||
team.setChildrenCount(fields.contains("childrenCount") ? getChildrenCount(team) : team.getChildrenCount());
|
team.setChildrenCount(fields.contains("childrenCount") ? getChildrenCount(team) : team.getChildrenCount());
|
||||||
if (team.getUserCount() == null) {
|
|
||||||
team.setUserCount(fields.contains("userCount") ? getUserCount(team.getId()) : team.getUserCount());
|
team.setUserCount(fields.contains("userCount") ? getUserCount(team.getId()) : team.getUserCount());
|
||||||
}
|
|
||||||
return team;
|
return team;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +109,6 @@ public class TeamRepository extends EntityRepository<Team> {
|
|||||||
team.setDefaultRoles(fields.contains(DEFAULT_ROLES) ? team.getDefaultRoles() : null);
|
team.setDefaultRoles(fields.contains(DEFAULT_ROLES) ? team.getDefaultRoles() : null);
|
||||||
team.setInheritedRoles(fields.contains(DEFAULT_ROLES) ? team.getInheritedRoles() : null);
|
team.setInheritedRoles(fields.contains(DEFAULT_ROLES) ? team.getInheritedRoles() : null);
|
||||||
team.setParents(fields.contains(PARENTS_FIELD) ? team.getParents() : null);
|
team.setParents(fields.contains(PARENTS_FIELD) ? team.getParents() : null);
|
||||||
team.setChildren(fields.contains("children") ? team.getChildren() : null);
|
|
||||||
team.setPolicies(fields.contains("policies") ? team.getPolicies() : null);
|
team.setPolicies(fields.contains("policies") ? team.getPolicies() : null);
|
||||||
team.setChildrenCount(fields.contains("childrenCount") ? team.getChildrenCount() : null);
|
team.setChildrenCount(fields.contains("childrenCount") ? team.getChildrenCount() : null);
|
||||||
return team.withUserCount(fields.contains("userCount") ? team.getUserCount() : null);
|
return team.withUserCount(fields.contains("userCount") ? team.getUserCount() : null);
|
||||||
@ -345,7 +339,7 @@ public class TeamRepository extends EntityRepository<Team> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getUsers(Team team) {
|
private List<EntityReference> getUsers(Team team) {
|
||||||
return !nullOrEmpty(team.getUsers()) ? team.getUsers() : findTo(team.getId(), TEAM, Relationship.HAS, Entity.USER);
|
return findTo(team.getId(), TEAM, Relationship.HAS, Entity.USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityRelationshipRecord> getUsersRelationshipRecords(UUID teamId) {
|
private List<EntityRelationshipRecord> getUsersRelationshipRecords(UUID teamId) {
|
||||||
@ -371,19 +365,14 @@ public class TeamRepository extends EntityRepository<Team> {
|
|||||||
|
|
||||||
private List<EntityReference> getOwns(Team team) {
|
private List<EntityReference> getOwns(Team team) {
|
||||||
// Compile entities owned by the team
|
// Compile entities owned by the team
|
||||||
return !nullOrEmpty(team.getOwns()) ? team.getOwns() : findTo(team.getId(), TEAM, Relationship.OWNS, null);
|
return findTo(team.getId(), TEAM, Relationship.OWNS, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getDefaultRoles(Team team) {
|
private List<EntityReference> getDefaultRoles(Team team) {
|
||||||
return !nullOrEmpty(team.getDefaultRoles())
|
return findTo(team.getId(), TEAM, Relationship.HAS, Entity.ROLE);
|
||||||
? team.getDefaultRoles()
|
|
||||||
: findTo(team.getId(), TEAM, Relationship.HAS, Entity.ROLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getParents(Team team) {
|
private List<EntityReference> getParents(Team team) {
|
||||||
if (!nullOrEmpty(team.getParents())) {
|
|
||||||
return team.getParents();
|
|
||||||
}
|
|
||||||
List<EntityReference> parents = findFrom(team.getId(), TEAM, Relationship.PARENT_OF, TEAM);
|
List<EntityReference> parents = findFrom(team.getId(), TEAM, Relationship.PARENT_OF, TEAM);
|
||||||
if (organization != null && listOrEmpty(parents).isEmpty() && !team.getId().equals(organization.getId())) {
|
if (organization != null && listOrEmpty(parents).isEmpty() && !team.getId().equals(organization.getId())) {
|
||||||
return new ArrayList<>(List.of(organization.getEntityReference()));
|
return new ArrayList<>(List.of(organization.getEntityReference()));
|
||||||
@ -403,7 +392,12 @@ public class TeamRepository extends EntityRepository<Team> {
|
|||||||
return parents;
|
return parents;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getChildren(UUID teamId) {
|
@Override
|
||||||
|
protected List<EntityReference> getChildren(Team team) {
|
||||||
|
return getChildren(team.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List<EntityReference> getChildren(UUID teamId) {
|
||||||
if (teamId.equals(organization.getId())) { // For organization all the parentless teams are children
|
if (teamId.equals(organization.getId())) { // For organization all the parentless teams are children
|
||||||
List<String> children = daoCollection.teamDAO().listTeamsUnderOrganization(teamId.toString());
|
List<String> children = daoCollection.teamDAO().listTeamsUnderOrganization(teamId.toString());
|
||||||
return EntityUtil.populateEntityReferencesById(EntityUtil.strToIds(children), Entity.TEAM);
|
return EntityUtil.populateEntityReferencesById(EntityUtil.strToIds(children), Entity.TEAM);
|
||||||
@ -412,11 +406,11 @@ public class TeamRepository extends EntityRepository<Team> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Integer getChildrenCount(Team team) {
|
private Integer getChildrenCount(Team team) {
|
||||||
return team.getChildrenCount() != null ? team.getChildrenCount() : getChildren(team.getId()).size();
|
return !nullOrEmpty(team.getChildren()) ? team.getChildren().size() : getChildren(team).size();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getPolicies(Team team) {
|
private List<EntityReference> getPolicies(Team team) {
|
||||||
return !nullOrEmpty(team.getPolicies()) ? team.getPolicies() : findTo(team.getId(), TEAM, Relationship.HAS, POLICY);
|
return findTo(team.getId(), TEAM, Relationship.HAS, POLICY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateChildren(Team team) {
|
private void populateChildren(Team team) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.openmetadata.service.jdbi3;
|
package org.openmetadata.service.jdbi3;
|
||||||
|
|
||||||
import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
|
|
||||||
import static org.openmetadata.service.Entity.TEST_CASE;
|
import static org.openmetadata.service.Entity.TEST_CASE;
|
||||||
import static org.openmetadata.service.Entity.TEST_DEFINITION;
|
import static org.openmetadata.service.Entity.TEST_DEFINITION;
|
||||||
import static org.openmetadata.service.Entity.TEST_SUITE;
|
import static org.openmetadata.service.Entity.TEST_SUITE;
|
||||||
@ -122,9 +121,6 @@ public class TestCaseRepository extends EntityRepository<TestCase> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private EntityReference getTestSuite(TestCase test) {
|
private EntityReference getTestSuite(TestCase test) {
|
||||||
if (test.getTestSuite() != null) {
|
|
||||||
return test.getTestSuite();
|
|
||||||
}
|
|
||||||
// `testSuite` field returns the executable `testSuite` linked to that testCase
|
// `testSuite` field returns the executable `testSuite` linked to that testCase
|
||||||
List<CollectionDAO.EntityRelationshipRecord> records =
|
List<CollectionDAO.EntityRelationshipRecord> records =
|
||||||
findFromRecords(test.getId(), entityType, Relationship.CONTAINS, TEST_SUITE);
|
findFromRecords(test.getId(), entityType, Relationship.CONTAINS, TEST_SUITE);
|
||||||
@ -139,9 +135,6 @@ public class TestCaseRepository extends EntityRepository<TestCase> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<TestSuite> getTestSuites(TestCase test) {
|
private List<TestSuite> getTestSuites(TestCase test) {
|
||||||
if (!nullOrEmpty(test.getTestSuites())) {
|
|
||||||
return test.getTestSuites();
|
|
||||||
}
|
|
||||||
// `testSuites` field returns all the `testSuite` (executable and logical) linked to that testCase
|
// `testSuites` field returns all the `testSuite` (executable and logical) linked to that testCase
|
||||||
List<CollectionDAO.EntityRelationshipRecord> records =
|
List<CollectionDAO.EntityRelationshipRecord> records =
|
||||||
findFromRecords(test.getId(), entityType, Relationship.CONTAINS, TEST_SUITE);
|
findFromRecords(test.getId(), entityType, Relationship.CONTAINS, TEST_SUITE);
|
||||||
@ -152,9 +145,7 @@ public class TestCaseRepository extends EntityRepository<TestCase> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private EntityReference getTestDefinition(TestCase test) {
|
private EntityReference getTestDefinition(TestCase test) {
|
||||||
return test.getTestDefinition() != null
|
return getFromEntityRef(test.getId(), Relationship.APPLIED_TO, TEST_DEFINITION, true);
|
||||||
? test.getTestDefinition()
|
|
||||||
: getFromEntityRef(test.getId(), Relationship.APPLIED_TO, TEST_DEFINITION, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateTestParameters(
|
private void validateTestParameters(
|
||||||
@ -279,9 +270,6 @@ public class TestCaseRepository extends EntityRepository<TestCase> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TestCaseResult getTestCaseResult(TestCase testCase) {
|
private TestCaseResult getTestCaseResult(TestCase testCase) {
|
||||||
if (testCase.getTestCaseResult() != null) {
|
|
||||||
return testCase.getTestCaseResult();
|
|
||||||
}
|
|
||||||
return JsonUtils.readValue(
|
return JsonUtils.readValue(
|
||||||
getLatestExtensionFromTimeseries(testCase.getFullyQualifiedName(), TESTCASE_RESULT_EXTENSION),
|
getLatestExtensionFromTimeseries(testCase.getFullyQualifiedName(), TESTCASE_RESULT_EXTENSION),
|
||||||
TestCaseResult.class);
|
TestCaseResult.class);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.openmetadata.service.jdbi3;
|
package org.openmetadata.service.jdbi3;
|
||||||
|
|
||||||
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
|
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
|
||||||
import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
|
|
||||||
import static org.openmetadata.service.Entity.TEST_CASE;
|
import static org.openmetadata.service.Entity.TEST_CASE;
|
||||||
import static org.openmetadata.service.Entity.TEST_SUITE;
|
import static org.openmetadata.service.Entity.TEST_SUITE;
|
||||||
import static org.openmetadata.service.jdbi3.TestCaseRepository.TESTCASE_RESULT_EXTENSION;
|
import static org.openmetadata.service.jdbi3.TestCaseRepository.TESTCASE_RESULT_EXTENSION;
|
||||||
@ -53,9 +52,6 @@ public class TestSuiteRepository extends EntityRepository<TestSuite> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TestSummary getTestSummary(TestSuite entity) {
|
private TestSummary getTestSummary(TestSuite entity) {
|
||||||
if (entity.getSummary() != null) {
|
|
||||||
return entity.getSummary();
|
|
||||||
}
|
|
||||||
List<EntityReference> testCases = getTestCases(entity);
|
List<EntityReference> testCases = getTestCases(entity);
|
||||||
List<String> testCaseFQNs =
|
List<String> testCaseFQNs =
|
||||||
testCases.stream().map(EntityReference::getFullyQualifiedName).collect(Collectors.toList());
|
testCases.stream().map(EntityReference::getFullyQualifiedName).collect(Collectors.toList());
|
||||||
@ -70,9 +66,7 @@ public class TestSuiteRepository extends EntityRepository<TestSuite> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getTestCases(TestSuite entity) {
|
private List<EntityReference> getTestCases(TestSuite entity) {
|
||||||
return !nullOrEmpty(entity.getTests())
|
return findTo(entity.getId(), TEST_SUITE, Relationship.CONTAINS, TEST_CASE);
|
||||||
? entity.getTests()
|
|
||||||
: findTo(entity.getId(), TEST_SUITE, Relationship.CONTAINS, TEST_CASE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -120,9 +120,7 @@ public class TopicRepository extends EntityRepository<Topic> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Topic setFields(Topic topic, Fields fields) {
|
public Topic setFields(Topic topic, Fields fields) {
|
||||||
if (topic.getService() == null) {
|
|
||||||
topic.setService(getContainer(topic.getId()));
|
topic.setService(getContainer(topic.getId()));
|
||||||
}
|
|
||||||
if (topic.getMessageSchema() != null) {
|
if (topic.getMessageSchema() != null) {
|
||||||
getFieldTags(fields.contains(FIELD_TAGS), topic.getMessageSchema().getSchemaFields());
|
getFieldTags(fields.contains(FIELD_TAGS), topic.getMessageSchema().getSchemaFields());
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package org.openmetadata.service.jdbi3;
|
package org.openmetadata.service.jdbi3;
|
||||||
|
|
||||||
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
|
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
|
||||||
import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
|
|
||||||
import static org.openmetadata.schema.type.Include.NON_DELETED;
|
import static org.openmetadata.schema.type.Include.NON_DELETED;
|
||||||
import static org.openmetadata.service.Entity.FIELD_DESCRIPTION;
|
import static org.openmetadata.service.Entity.FIELD_DESCRIPTION;
|
||||||
import static org.openmetadata.service.util.EntityUtil.customFieldMatch;
|
import static org.openmetadata.service.util.EntityUtil.customFieldMatch;
|
||||||
@ -127,9 +126,6 @@ public class TypeRepository extends EntityRepository<Type> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<CustomProperty> getCustomProperties(Type type) {
|
private List<CustomProperty> getCustomProperties(Type type) {
|
||||||
if (!nullOrEmpty(type.getCustomProperties())) {
|
|
||||||
return type.getCustomProperties();
|
|
||||||
}
|
|
||||||
if (type.getCategory().equals(Category.Field)) {
|
if (type.getCategory().equals(Category.Field)) {
|
||||||
return null; // Property type fields don't support custom properties
|
return null; // Property type fields don't support custom properties
|
||||||
}
|
}
|
||||||
|
@ -121,10 +121,6 @@ public class UserRepository extends EntityRepository<User> {
|
|||||||
if (Boolean.TRUE.equals(user.getIsBot())) {
|
if (Boolean.TRUE.equals(user.getIsBot())) {
|
||||||
return null; // No inherited roles for bots
|
return null; // No inherited roles for bots
|
||||||
}
|
}
|
||||||
if (!nullOrEmpty(user.getInheritedRoles())) {
|
|
||||||
return user.getInheritedRoles();
|
|
||||||
}
|
|
||||||
getTeams(user);
|
|
||||||
return SubjectContext.getRolesForTeams(getTeams(user));
|
return SubjectContext.getRolesForTeams(getTeams(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,9 +251,6 @@ public class UserRepository extends EntityRepository<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getOwns(User user) {
|
private List<EntityReference> getOwns(User user) {
|
||||||
if (user.getOwns() != null) {
|
|
||||||
return user.getOwns();
|
|
||||||
}
|
|
||||||
// Compile entities owned by the user
|
// Compile entities owned by the user
|
||||||
List<EntityRelationshipRecord> ownedEntities =
|
List<EntityRelationshipRecord> ownedEntities =
|
||||||
daoCollection.relationshipDAO().findTo(user.getId().toString(), USER, Relationship.OWNS.ordinal());
|
daoCollection.relationshipDAO().findTo(user.getId().toString(), USER, Relationship.OWNS.ordinal());
|
||||||
@ -273,7 +266,7 @@ public class UserRepository extends EntityRepository<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getFollows(User user) {
|
private List<EntityReference> getFollows(User user) {
|
||||||
return user.getFollows() != null ? user.getFollows() : findTo(user.getId(), USER, Relationship.FOLLOWS, null);
|
return findTo(user.getId(), USER, Relationship.FOLLOWS, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityReference> getTeamChildren(UUID teamId) {
|
private List<EntityReference> getTeamChildren(UUID teamId) {
|
||||||
@ -307,14 +300,11 @@ public class UserRepository extends EntityRepository<User> {
|
|||||||
|
|
||||||
/* Get all the roles that user has been assigned and inherited from the team to User entity */
|
/* Get all the roles that user has been assigned and inherited from the team to User entity */
|
||||||
private List<EntityReference> getRoles(User user) {
|
private List<EntityReference> getRoles(User user) {
|
||||||
return user.getRoles() != null ? user.getRoles() : findTo(user.getId(), USER, Relationship.HAS, Entity.ROLE);
|
return findTo(user.getId(), USER, Relationship.HAS, Entity.ROLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get all the teams that user belongs to User entity */
|
/* Get all the teams that user belongs to User entity */
|
||||||
public List<EntityReference> getTeams(User user) {
|
public List<EntityReference> getTeams(User user) {
|
||||||
if (!nullOrEmpty(user.getTeams())) {
|
|
||||||
return user.getTeams();
|
|
||||||
}
|
|
||||||
List<EntityReference> teams = findFrom(user.getId(), USER, Relationship.HAS, Entity.TEAM);
|
List<EntityReference> teams = findFrom(user.getId(), USER, Relationship.HAS, Entity.TEAM);
|
||||||
// Filter deleted teams
|
// Filter deleted teams
|
||||||
teams = listOrEmpty(teams).stream().filter(team -> !team.getDeleted()).collect(Collectors.toList());
|
teams = listOrEmpty(teams).stream().filter(team -> !team.getDeleted()).collect(Collectors.toList());
|
||||||
|
@ -93,7 +93,7 @@ import org.openmetadata.service.util.ResultList;
|
|||||||
public class TagResource extends EntityResource<Tag, TagRepository> {
|
public class TagResource extends EntityResource<Tag, TagRepository> {
|
||||||
private final CollectionDAO daoCollection;
|
private final CollectionDAO daoCollection;
|
||||||
public static final String TAG_COLLECTION_PATH = "/v1/tags/";
|
public static final String TAG_COLLECTION_PATH = "/v1/tags/";
|
||||||
static final String FIELDS = "children, usageCount";
|
static final String FIELDS = "parent,children,usageCount";
|
||||||
|
|
||||||
static class TagList extends ResultList<Tag> {
|
static class TagList extends ResultList<Tag> {
|
||||||
/* Required for serde */
|
/* Required for serde */
|
||||||
|
@ -82,6 +82,18 @@ public interface EntityInterface {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default List<EntityReference> getChildren() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
default List<EntityReference> getReviewers() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
default List<EntityReference> getExperts() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
default EntityReference getDomain() {
|
default EntityReference getDomain() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -124,6 +136,18 @@ public interface EntityInterface {
|
|||||||
/* no-op implementation to be overridden */
|
/* no-op implementation to be overridden */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default void setChildren(List<EntityReference> entityReference) {
|
||||||
|
/* no-op implementation to be overridden */
|
||||||
|
}
|
||||||
|
|
||||||
|
default void setReviewers(List<EntityReference> entityReference) {
|
||||||
|
/* no-op implementation to be overridden */
|
||||||
|
}
|
||||||
|
|
||||||
|
default void setExperts(List<EntityReference> entityReference) {
|
||||||
|
/* no-op implementation to be overridden */
|
||||||
|
}
|
||||||
|
|
||||||
default void setDomain(EntityReference entityReference) {
|
default void setDomain(EntityReference entityReference) {
|
||||||
/* no-op implementation to be overridden */
|
/* no-op implementation to be overridden */
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
"javaInterfaces": ["org.openmetadata.schema.EntityInterface"],
|
"javaInterfaces": ["org.openmetadata.schema.EntityInterface"],
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"entityName": {
|
"entityName": {
|
||||||
"description": "Name of a table. Expected to be unique within a database.",
|
"description": "Name of a pipeline. Expected to be unique within a pipeline service.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
"maxLength": 128,
|
"maxLength": 128,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user