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