mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-25 08:50:18 +00:00
parent
b8863648d6
commit
76f8664522
@ -23,12 +23,10 @@ import org.jdbi.v3.sqlobject.statement.SqlUpdate;
|
||||
import org.jdbi.v3.sqlobject.transaction.Transaction;
|
||||
import org.openmetadata.catalog.type.AuditLog;
|
||||
import org.openmetadata.catalog.util.EntityUtil;
|
||||
|
||||
import org.openmetadata.catalog.util.JsonUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -39,7 +37,6 @@ public abstract class AuditLogRepository {
|
||||
@CreateSqlObject
|
||||
abstract AuditLogDAO auditLogDAO();
|
||||
|
||||
|
||||
@Transaction
|
||||
public List<AuditLog> list() throws IOException {
|
||||
List<String> jsons = auditLogDAO().list();
|
||||
@ -59,7 +56,7 @@ public abstract class AuditLogRepository {
|
||||
public List<AuditLog> getByEntityType(String entityType) throws IOException {
|
||||
List<String> jsons = auditLogDAO().findByEntityType(entityType);
|
||||
List<AuditLog> auditLogs = new ArrayList<>();
|
||||
for (String json: jsons) {
|
||||
for (String json : jsons) {
|
||||
auditLogs.add(JsonUtils.readValue(json, AuditLog.class));
|
||||
}
|
||||
return auditLogs;
|
||||
@ -76,7 +73,6 @@ public abstract class AuditLogRepository {
|
||||
auditLogDAO().delete(id);
|
||||
}
|
||||
|
||||
|
||||
public interface AuditLogDAO {
|
||||
@SqlUpdate("INSERT INTO audit_log (json) VALUES (:json)")
|
||||
void insert(@Bind("json") String json);
|
||||
@ -95,6 +91,5 @@ public abstract class AuditLogRepository {
|
||||
|
||||
@SqlUpdate("DELETE FROM audit_log_entity WHERE id = :id")
|
||||
int delete(@Bind("id") String id);
|
||||
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ import org.openmetadata.catalog.resources.charts.ChartResource;
|
||||
import org.openmetadata.catalog.type.EntityReference;
|
||||
import org.openmetadata.catalog.type.TagLabel;
|
||||
import org.openmetadata.catalog.util.EntityInterface;
|
||||
import org.openmetadata.catalog.util.EntityUpdater3;
|
||||
import org.openmetadata.catalog.util.EntityUpdater;
|
||||
import org.openmetadata.catalog.util.EntityUtil;
|
||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||
import org.openmetadata.catalog.util.JsonUtils;
|
||||
@ -296,7 +296,7 @@ public class ChartRepository extends EntityRepository<Chart> {
|
||||
/**
|
||||
* Handles entity updated from PUT and POST operation.
|
||||
*/
|
||||
public class ChartUpdater extends EntityUpdater3 {
|
||||
public class ChartUpdater extends EntityUpdater {
|
||||
final Chart orig;
|
||||
final Chart updated;
|
||||
|
||||
|
@ -28,7 +28,7 @@ import org.openmetadata.catalog.resources.dashboards.DashboardResource.Dashboard
|
||||
import org.openmetadata.catalog.type.EntityReference;
|
||||
import org.openmetadata.catalog.type.TagLabel;
|
||||
import org.openmetadata.catalog.util.EntityInterface;
|
||||
import org.openmetadata.catalog.util.EntityUpdater3;
|
||||
import org.openmetadata.catalog.util.EntityUpdater;
|
||||
import org.openmetadata.catalog.util.EntityUtil;
|
||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||
import org.openmetadata.catalog.util.JsonUtils;
|
||||
@ -341,7 +341,7 @@ public class DashboardRepository extends EntityRepository<Dashboard> {
|
||||
/**
|
||||
* Handles entity updated from PUT and POST operation.
|
||||
*/
|
||||
public class DashboardUpdater extends EntityUpdater3 {
|
||||
public class DashboardUpdater extends EntityUpdater {
|
||||
final Dashboard orig;
|
||||
final Dashboard updated;
|
||||
|
||||
|
@ -28,7 +28,7 @@ import org.openmetadata.catalog.resources.databases.DatabaseResource.DatabaseLis
|
||||
import org.openmetadata.catalog.type.EntityReference;
|
||||
import org.openmetadata.catalog.type.TagLabel;
|
||||
import org.openmetadata.catalog.util.EntityInterface;
|
||||
import org.openmetadata.catalog.util.EntityUpdater3;
|
||||
import org.openmetadata.catalog.util.EntityUpdater;
|
||||
import org.openmetadata.catalog.util.EntityUtil;
|
||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||
import org.openmetadata.catalog.util.JsonUtils;
|
||||
@ -291,7 +291,7 @@ public class DatabaseRepository extends EntityRepository<Database> {
|
||||
/**
|
||||
* Handles entity updated from PUT and POST operation.
|
||||
*/
|
||||
public class DatabaseUpdater extends EntityUpdater3 {
|
||||
public class DatabaseUpdater extends EntityUpdater {
|
||||
final Database orig;
|
||||
final Database updated;
|
||||
|
||||
|
@ -25,7 +25,7 @@ import org.openmetadata.catalog.resources.metrics.MetricsResource.MetricsList;
|
||||
import org.openmetadata.catalog.type.EntityReference;
|
||||
import org.openmetadata.catalog.type.TagLabel;
|
||||
import org.openmetadata.catalog.util.EntityInterface;
|
||||
import org.openmetadata.catalog.util.EntityUpdater3;
|
||||
import org.openmetadata.catalog.util.EntityUpdater;
|
||||
import org.openmetadata.catalog.util.EntityUtil;
|
||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||
import org.openmetadata.catalog.util.JsonUtils;
|
||||
@ -225,7 +225,7 @@ public class MetricsRepository extends EntityRepository<Metrics> {
|
||||
/**
|
||||
* Handles entity updated from PUT and POST operation.
|
||||
*/
|
||||
public class MetricsUpdater extends EntityUpdater3 {
|
||||
public class MetricsUpdater extends EntityUpdater {
|
||||
final Metrics orig;
|
||||
final Metrics updated;
|
||||
|
||||
|
@ -26,7 +26,7 @@ import org.openmetadata.catalog.resources.models.ModelResource.ModelList;
|
||||
import org.openmetadata.catalog.type.EntityReference;
|
||||
import org.openmetadata.catalog.type.TagLabel;
|
||||
import org.openmetadata.catalog.util.EntityInterface;
|
||||
import org.openmetadata.catalog.util.EntityUpdater3;
|
||||
import org.openmetadata.catalog.util.EntityUpdater;
|
||||
import org.openmetadata.catalog.util.EntityUtil;
|
||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||
import org.openmetadata.catalog.util.JsonUtils;
|
||||
@ -309,7 +309,7 @@ public class ModelRepository extends EntityRepository<Model> {
|
||||
/**
|
||||
* Handles entity updated from PUT and POST operation.
|
||||
*/
|
||||
public class ModelUpdater extends EntityUpdater3 {
|
||||
public class ModelUpdater extends EntityUpdater {
|
||||
final Model orig;
|
||||
final Model updated;
|
||||
|
||||
|
@ -28,7 +28,7 @@ import org.openmetadata.catalog.resources.pipelines.PipelineResource.PipelineLis
|
||||
import org.openmetadata.catalog.type.EntityReference;
|
||||
import org.openmetadata.catalog.type.TagLabel;
|
||||
import org.openmetadata.catalog.util.EntityInterface;
|
||||
import org.openmetadata.catalog.util.EntityUpdater3;
|
||||
import org.openmetadata.catalog.util.EntityUpdater;
|
||||
import org.openmetadata.catalog.util.EntityUtil;
|
||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||
import org.openmetadata.catalog.util.JsonUtils;
|
||||
@ -40,7 +40,6 @@ import javax.ws.rs.core.Response.Status;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -64,6 +63,7 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
|
||||
public static String getFQN(Pipeline pipeline) {
|
||||
return (pipeline.getService().getName() + "." + pipeline.getName());
|
||||
}
|
||||
|
||||
@Transaction
|
||||
public Pipeline create(Pipeline pipeline) throws IOException {
|
||||
validateRelationships(pipeline);
|
||||
@ -89,7 +89,7 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
|
||||
|
||||
@Transaction
|
||||
public Pipeline patch(String id, String user, JsonPatch patch) throws IOException {
|
||||
Pipeline original = setFields(validatePipeline(id), PIPELINE_PATCH_FIELDS);
|
||||
Pipeline original = setFields(dao.pipelineDAO().findEntityById(id), PIPELINE_PATCH_FIELDS);
|
||||
Pipeline updated = JsonUtils.applyPatch(original, patch, Pipeline.class);
|
||||
updated.withUpdatedBy(user).withUpdatedAt(new Date());
|
||||
patch(original, updated);
|
||||
@ -128,7 +128,7 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
|
||||
|
||||
public static List<EntityReference> toEntityReference(List<Task> tasks) {
|
||||
List<EntityReference> refList = new ArrayList<>();
|
||||
for (Task task: tasks) {
|
||||
for (Task task : tasks) {
|
||||
refList.add(EntityUtil.getEntityReference(task));
|
||||
}
|
||||
return refList;
|
||||
@ -229,7 +229,8 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
|
||||
updated.withFullyQualifiedName(original.getFullyQualifiedName()).withName(original.getName())
|
||||
.withService(original.getService()).withId(original.getId());
|
||||
validateRelationships(updated);
|
||||
PipelineRepository.PipelineUpdater pipelineUpdater = new PipelineRepository.PipelineUpdater(original, updated, true);
|
||||
PipelineRepository.PipelineUpdater pipelineUpdater = new PipelineRepository.PipelineUpdater(original, updated,
|
||||
true);
|
||||
pipelineUpdater.updateAll();
|
||||
pipelineUpdater.store();
|
||||
}
|
||||
@ -295,7 +296,7 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
|
||||
// Remove any existing tasks associated with this pipeline
|
||||
List<Task> existingTasks = getTasks(pipeline);
|
||||
if (existingTasks != null) {
|
||||
for (Task task: existingTasks) {
|
||||
for (Task task : existingTasks) {
|
||||
dao.relationshipDAO().delete(pipelineId, task.getId().toString(), Relationship.CONTAINS.ordinal());
|
||||
}
|
||||
}
|
||||
@ -307,10 +308,6 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
|
||||
}
|
||||
}
|
||||
|
||||
private Pipeline validatePipeline(String id) throws IOException {
|
||||
return dao.pipelineDAO().findEntityById(id);
|
||||
}
|
||||
|
||||
static class PipelineEntityInterface implements EntityInterface {
|
||||
private final Pipeline pipeline;
|
||||
|
||||
@ -367,12 +364,13 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
|
||||
/**
|
||||
* Handles entity updated from PUT and POST operation.
|
||||
*/
|
||||
public class PipelineUpdater extends EntityUpdater3 {
|
||||
public class PipelineUpdater extends EntityUpdater {
|
||||
final Pipeline orig;
|
||||
final Pipeline updated;
|
||||
|
||||
public PipelineUpdater(Pipeline orig, Pipeline updated, boolean patchOperation) {
|
||||
super(new PipelineRepository.PipelineEntityInterface(orig), new PipelineRepository.PipelineEntityInterface(updated), patchOperation, dao.relationshipDAO(),
|
||||
super(new PipelineRepository.PipelineEntityInterface(orig),
|
||||
new PipelineRepository.PipelineEntityInterface(updated), patchOperation, dao.relationshipDAO(),
|
||||
dao.tagDAO());
|
||||
this.orig = orig;
|
||||
this.updated = updated;
|
||||
@ -385,7 +383,8 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
|
||||
|
||||
private void updateTasks() throws IOException {
|
||||
// Airflow lineage backend gets executed per task in a DAG. This means we will not a get full picture of the
|
||||
// pipeline in each call. Hence we may create a pipeline and add a single task when one task finishes in a pipeline
|
||||
// pipeline in each call. Hence we may create a pipeline and add a single task when one task finishes in a
|
||||
// pipeline
|
||||
// in the next task run we may have to update. To take care of this we will merge the tasks
|
||||
if (updated.getTasks() == null) {
|
||||
updated.setTasks(orig.getTasks());
|
||||
|
@ -37,7 +37,7 @@ import org.openmetadata.catalog.type.TableJoins;
|
||||
import org.openmetadata.catalog.type.TableProfile;
|
||||
import org.openmetadata.catalog.type.TagLabel;
|
||||
import org.openmetadata.catalog.util.EntityInterface;
|
||||
import org.openmetadata.catalog.util.EntityUpdater3;
|
||||
import org.openmetadata.catalog.util.EntityUpdater;
|
||||
import org.openmetadata.catalog.util.EntityUtil;
|
||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||
import org.openmetadata.catalog.util.EventUtils;
|
||||
@ -665,7 +665,7 @@ public class TableRepository extends EntityRepository<Table> {
|
||||
/**
|
||||
* Handles entity updated from PUT and POST operation.
|
||||
*/
|
||||
public class TableUpdater extends EntityUpdater3 {
|
||||
public class TableUpdater extends EntityUpdater {
|
||||
final Table orig;
|
||||
final Table updated;
|
||||
|
||||
|
@ -27,7 +27,7 @@ import org.openmetadata.catalog.resources.tasks.TaskResource.TaskList;
|
||||
import org.openmetadata.catalog.type.EntityReference;
|
||||
import org.openmetadata.catalog.type.TagLabel;
|
||||
import org.openmetadata.catalog.util.EntityInterface;
|
||||
import org.openmetadata.catalog.util.EntityUpdater3;
|
||||
import org.openmetadata.catalog.util.EntityUpdater;
|
||||
import org.openmetadata.catalog.util.EntityUtil;
|
||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||
import org.openmetadata.catalog.util.JsonUtils;
|
||||
@ -285,7 +285,7 @@ public class TaskRepository extends EntityRepository<Task> {
|
||||
/**
|
||||
* Handles entity updated from PUT and POST operation.
|
||||
*/
|
||||
public class TaskUpdater extends EntityUpdater3 {
|
||||
public class TaskUpdater extends EntityUpdater {
|
||||
final Task orig;
|
||||
final Task updated;
|
||||
|
||||
|
@ -27,7 +27,7 @@ import org.openmetadata.catalog.resources.teams.TeamResource.TeamList;
|
||||
import org.openmetadata.catalog.type.EntityReference;
|
||||
import org.openmetadata.catalog.type.TagLabel;
|
||||
import org.openmetadata.catalog.util.EntityInterface;
|
||||
import org.openmetadata.catalog.util.EntityUpdater3;
|
||||
import org.openmetadata.catalog.util.EntityUpdater;
|
||||
import org.openmetadata.catalog.util.EntityUtil;
|
||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||
import org.openmetadata.catalog.util.JsonUtils;
|
||||
@ -227,7 +227,7 @@ public class TeamRepository extends EntityRepository<Team> {
|
||||
/**
|
||||
* Handles entity updated from PUT and POST operation.
|
||||
*/
|
||||
public class TeamUpdater extends EntityUpdater3 {
|
||||
public class TeamUpdater extends EntityUpdater {
|
||||
final Team orig;
|
||||
final Team updated;
|
||||
|
||||
|
@ -27,7 +27,7 @@ import org.openmetadata.catalog.resources.topics.TopicResource.TopicList;
|
||||
import org.openmetadata.catalog.type.EntityReference;
|
||||
import org.openmetadata.catalog.type.TagLabel;
|
||||
import org.openmetadata.catalog.util.EntityInterface;
|
||||
import org.openmetadata.catalog.util.EntityUpdater3;
|
||||
import org.openmetadata.catalog.util.EntityUpdater;
|
||||
import org.openmetadata.catalog.util.EntityUtil;
|
||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||
import org.openmetadata.catalog.util.JsonUtils;
|
||||
@ -300,7 +300,7 @@ public class TopicRepository extends EntityRepository<Topic> {
|
||||
/**
|
||||
* Handles entity updated from PUT and POST operation.
|
||||
*/
|
||||
public class TopicUpdater extends EntityUpdater3 {
|
||||
public class TopicUpdater extends EntityUpdater {
|
||||
final Topic orig;
|
||||
final Topic updated;
|
||||
|
||||
|
@ -26,7 +26,7 @@ import org.openmetadata.catalog.resources.teams.UserResource.UserList;
|
||||
import org.openmetadata.catalog.type.EntityReference;
|
||||
import org.openmetadata.catalog.type.TagLabel;
|
||||
import org.openmetadata.catalog.util.EntityInterface;
|
||||
import org.openmetadata.catalog.util.EntityUpdater3;
|
||||
import org.openmetadata.catalog.util.EntityUpdater;
|
||||
import org.openmetadata.catalog.util.EntityUtil;
|
||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||
import org.openmetadata.catalog.util.JsonUtils;
|
||||
@ -321,7 +321,7 @@ public class UserRepository extends EntityRepository<User> {
|
||||
/**
|
||||
* Handles entity updated from PUT and POST operation.
|
||||
*/
|
||||
public class UserUpdater extends EntityUpdater3 {
|
||||
public class UserUpdater extends EntityUpdater {
|
||||
final User orig;
|
||||
final User updated;
|
||||
|
||||
|
@ -17,15 +17,15 @@ import java.util.List;
|
||||
* - description
|
||||
* - tags
|
||||
* - owner
|
||||
*
|
||||
* <p>
|
||||
* This class handles tracking all the changes in an update operation and also versioning
|
||||
* of the entity.
|
||||
*
|
||||
* <p>
|
||||
* Concrete implementations need to implement update for other fields. See
|
||||
* {@link TableRepository.TableUpdater} for an example implementation.
|
||||
*/
|
||||
public abstract class EntityUpdater3 {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(EntityUpdater3.class);
|
||||
public abstract class EntityUpdater {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(EntityUpdater.class);
|
||||
private final EntityInterface originalEntity;
|
||||
private final EntityInterface updatedEntity;
|
||||
private final EntityRelationshipDAO relationshipDAO;
|
||||
@ -37,7 +37,7 @@ public abstract class EntityUpdater3 {
|
||||
protected List<String> fieldsDeleted = new ArrayList<>();
|
||||
protected boolean majorVersionChange = false;
|
||||
|
||||
public EntityUpdater3(EntityInterface originalEntity, EntityInterface updatedEntity, boolean patchOperation,
|
||||
public EntityUpdater(EntityInterface originalEntity, EntityInterface updatedEntity, boolean patchOperation,
|
||||
EntityRelationshipDAO relationshipDAO, TagDAO tagDAO) {
|
||||
this.originalEntity = originalEntity;
|
||||
this.updatedEntity = updatedEntity;
|
@ -42,7 +42,6 @@ import org.openmetadata.catalog.jdbi3.CollectionDAO.EntityRelationshipDAO;
|
||||
import org.openmetadata.catalog.jdbi3.CollectionDAO.MetricsDAO;
|
||||
import org.openmetadata.catalog.jdbi3.CollectionDAO.ModelDAO;
|
||||
import org.openmetadata.catalog.jdbi3.CollectionDAO.PipelineDAO;
|
||||
import org.openmetadata.catalog.jdbi3.Relationship;
|
||||
import org.openmetadata.catalog.jdbi3.CollectionDAO.ReportDAO;
|
||||
import org.openmetadata.catalog.jdbi3.CollectionDAO.TableDAO;
|
||||
import org.openmetadata.catalog.jdbi3.CollectionDAO.TagDAO;
|
||||
@ -51,6 +50,7 @@ import org.openmetadata.catalog.jdbi3.CollectionDAO.TeamDAO;
|
||||
import org.openmetadata.catalog.jdbi3.CollectionDAO.TopicDAO;
|
||||
import org.openmetadata.catalog.jdbi3.CollectionDAO.UsageDAO;
|
||||
import org.openmetadata.catalog.jdbi3.CollectionDAO.UserDAO;
|
||||
import org.openmetadata.catalog.jdbi3.Relationship;
|
||||
import org.openmetadata.catalog.resources.charts.ChartResource;
|
||||
import org.openmetadata.catalog.resources.dashboards.DashboardResource;
|
||||
import org.openmetadata.catalog.resources.databases.DatabaseResource;
|
||||
@ -211,6 +211,7 @@ public final class EntityUtil {
|
||||
}
|
||||
return owner;
|
||||
}
|
||||
|
||||
public static void setOwner(EntityRelationshipDAO dao, UUID ownedEntityId, String ownedEntityType,
|
||||
EntityReference owner) {
|
||||
// Add relationship owner --- owns ---> ownedEntity
|
||||
@ -253,8 +254,6 @@ public final class EntityUtil {
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static EntityReference getEntityReference3(EntityReference ref, TableDAO tableDAO, DatabaseDAO databaseDAO,
|
||||
MetricsDAO metricsDAO, DashboardDAO dashboardDAO,
|
||||
ReportDAO reportDAO, TopicDAO topicDAO, ChartDAO chartDAO,
|
||||
@ -528,29 +527,6 @@ public final class EntityUtil {
|
||||
.withName(user.getName()).withType(Entity.USER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply tags {@code tagLabels} to the entity or field identified by {@code targetFQN}
|
||||
*/
|
||||
public static void applyTags(org.openmetadata.catalog.jdbi3.TagDAO tagDAO, List<TagLabel> tagLabels, String targetFQN) throws IOException {
|
||||
for (TagLabel tagLabel : Optional.ofNullable(tagLabels).orElse(Collections.emptyList())) {
|
||||
String json = tagDAO.findTag(tagLabel.getTagFQN());
|
||||
if (json == null) {
|
||||
// Invalid TagLabel
|
||||
throw EntityNotFoundException.byMessage(CatalogExceptionMessage.entityNotFound(Tag.class.getSimpleName(),
|
||||
tagLabel.getTagFQN()));
|
||||
}
|
||||
Tag tag = JsonUtils.readValue(json, Tag.class);
|
||||
|
||||
// Apply tagLabel to targetFQN that identifies an entity or field
|
||||
tagDAO.applyTag(tagLabel.getTagFQN(), targetFQN, tagLabel.getLabelType().ordinal(),
|
||||
tagLabel.getState().ordinal());
|
||||
|
||||
// Apply derived tags
|
||||
List<TagLabel> derivedTags = getDerivedTags(tagLabel, tag);
|
||||
applyTags(tagDAO, derivedTags, targetFQN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply tags {@code tagLabels} to the entity or field identified by {@code targetFQN}
|
||||
*/
|
||||
@ -573,6 +549,7 @@ public final class EntityUtil {
|
||||
applyTags(tagDAO, derivedTags, targetFQN);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<TagLabel> getDerivedTags(TagLabel tagLabel, Tag tag) {
|
||||
List<TagLabel> derivedTags = new ArrayList<>();
|
||||
for (String fqn : Optional.ofNullable(tag.getAssociatedTags()).orElse(Collections.emptyList())) {
|
||||
@ -581,28 +558,6 @@ public final class EntityUtil {
|
||||
return derivedTags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate given list of tags and add derived tags to it
|
||||
*/
|
||||
public static List<TagLabel> addDerivedTags(org.openmetadata.catalog.jdbi3.TagDAO tagDAO, List<TagLabel> tagLabels) throws IOException {
|
||||
List<TagLabel> updatedTagLabels = new ArrayList<>();
|
||||
for (TagLabel tagLabel : Optional.ofNullable(tagLabels).orElse(Collections.emptyList())) {
|
||||
String json = tagDAO.findTag(tagLabel.getTagFQN());
|
||||
if (json == null) {
|
||||
// Invalid TagLabel
|
||||
throw EntityNotFoundException.byMessage(CatalogExceptionMessage.entityNotFound(Tag.class.getSimpleName(),
|
||||
tagLabel.getTagFQN()));
|
||||
}
|
||||
Tag tag = JsonUtils.readValue(json, Tag.class);
|
||||
updatedTagLabels.add(tagLabel);
|
||||
|
||||
// Apply derived tags
|
||||
List<TagLabel> derivedTags = getDerivedTags(tagLabel, tag);
|
||||
updatedTagLabels = EntityUtil.mergeTags(updatedTagLabels, derivedTags);
|
||||
}
|
||||
return updatedTagLabels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate given list of tags and add derived tags to it
|
||||
*/
|
||||
@ -624,12 +579,9 @@ public final class EntityUtil {
|
||||
}
|
||||
return updatedTagLabels;
|
||||
}
|
||||
public static void removeTags(org.openmetadata.catalog.jdbi3.TagDAO tagDAO, String fullyQualifiedName) {
|
||||
tagDAO.deleteTags(fullyQualifiedName);
|
||||
}
|
||||
|
||||
public static void removeTagsByPrefix(org.openmetadata.catalog.jdbi3.TagDAO tagDAO, String fullyQualifiedName) {
|
||||
tagDAO.deleteTagsByPrefix(fullyQualifiedName);
|
||||
public static void removeTags(TagDAO tagDAO, String fullyQualifiedName) {
|
||||
tagDAO.deleteTags(fullyQualifiedName);
|
||||
}
|
||||
|
||||
public static void removeTagsByPrefix(TagDAO tagDAO, String fullyQualifiedName) {
|
||||
@ -685,6 +637,7 @@ public final class EntityUtil {
|
||||
}
|
||||
return followers;
|
||||
}
|
||||
|
||||
public static class Fields {
|
||||
private final List<String> fieldList;
|
||||
|
||||
@ -719,7 +672,7 @@ public final class EntityUtil {
|
||||
return null;
|
||||
}
|
||||
List<EntityReference> refList = new ArrayList<>();
|
||||
for (Chart chart: charts) {
|
||||
for (Chart chart : charts) {
|
||||
refList.add(EntityUtil.getEntityReference(chart));
|
||||
}
|
||||
return refList;
|
||||
|
Loading…
x
Reference in New Issue
Block a user