mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-25 17:04:54 +00:00
Make restoring patch attributes consistent across entities (#13961)
* Make restoring patch attributes consistent across entities * Fix test failures * Fix test failures
This commit is contained in:
parent
10d8ec84fe
commit
e367f557a6
@ -75,11 +75,8 @@ public class ChartRepository extends EntityRepository<Chart> {
|
||||
@Override
|
||||
public void restorePatchAttributes(Chart original, Chart updated) {
|
||||
// Patch can't make changes to following fields. Ignore the changes
|
||||
updated
|
||||
.withFullyQualifiedName(original.getFullyQualifiedName())
|
||||
.withName(original.getName())
|
||||
.withService(original.getService())
|
||||
.withId(original.getId());
|
||||
super.restorePatchAttributes(original, updated);
|
||||
updated.withService(original.getService());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,6 +48,7 @@ public class ClassificationRepository extends EntityRepository<Classification> {
|
||||
"");
|
||||
quoteFqn = true;
|
||||
supportsSearch = true;
|
||||
renameAllowed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -110,7 +111,6 @@ public class ClassificationRepository extends EntityRepository<Classification> {
|
||||
@Transaction
|
||||
@Override
|
||||
public void entitySpecificUpdate() {
|
||||
// TODO handle name change
|
||||
// TODO mutuallyExclusive from false to true?
|
||||
recordChange("mutuallyExclusive", original.getMutuallyExclusive(), updated.getMutuallyExclusive());
|
||||
recordChange("disabled", original.getDisabled(), updated.getDisabled());
|
||||
@ -125,6 +125,7 @@ public class ClassificationRepository extends EntityRepository<Classification> {
|
||||
}
|
||||
// Classification name changed - update tag names starting from classification and all the children tags
|
||||
LOG.info("Classification name changed from {} to {}", original.getName(), updated.getName());
|
||||
setFullyQualifiedName(updated);
|
||||
daoCollection.tagDAO().updateFqn(original.getName(), updated.getName());
|
||||
daoCollection
|
||||
.tagUsageDAO()
|
||||
|
@ -146,12 +146,8 @@ public class ContainerRepository extends EntityRepository<Container> {
|
||||
@Override
|
||||
public void restorePatchAttributes(Container original, Container updated) {
|
||||
// Patch can't make changes to following fields. Ignore the changes
|
||||
updated
|
||||
.withFullyQualifiedName(original.getFullyQualifiedName())
|
||||
.withService(original.getService())
|
||||
.withParent(original.getParent())
|
||||
.withName(original.getName())
|
||||
.withId(original.getId());
|
||||
super.restorePatchAttributes(original, updated);
|
||||
updated.withService(original.getService()).withParent(original.getParent());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -174,11 +174,8 @@ public class DashboardDataModelRepository extends EntityRepository<DashboardData
|
||||
@Override
|
||||
public void restorePatchAttributes(DashboardDataModel original, DashboardDataModel updated) {
|
||||
// Patch can't make changes to following fields. Ignore the changes
|
||||
updated
|
||||
.withFullyQualifiedName(original.getFullyQualifiedName())
|
||||
.withName(original.getName())
|
||||
.withService(original.getService())
|
||||
.withId(original.getId());
|
||||
super.restorePatchAttributes(original, updated);
|
||||
updated.withService(original.getService());
|
||||
}
|
||||
|
||||
private void applyTags(List<Column> columns) {
|
||||
|
@ -118,11 +118,8 @@ public class DashboardRepository extends EntityRepository<Dashboard> {
|
||||
@Override
|
||||
public void restorePatchAttributes(Dashboard original, Dashboard updated) {
|
||||
// Patch can't make changes to following fields. Ignore the changes
|
||||
updated
|
||||
.withId(original.getId())
|
||||
.withFullyQualifiedName(original.getFullyQualifiedName())
|
||||
.withName(original.getName())
|
||||
.withService(original.getService());
|
||||
super.restorePatchAttributes(original, updated);
|
||||
updated.withService(original.getService());
|
||||
}
|
||||
|
||||
private void populateService(Dashboard dashboard) {
|
||||
|
@ -92,6 +92,7 @@ public class DataProductRepository extends EntityRepository<DataProduct> {
|
||||
|
||||
@Override
|
||||
public void restorePatchAttributes(DataProduct original, DataProduct updated) {
|
||||
super.restorePatchAttributes(original, updated);
|
||||
updated.withDomain(original.getDomain()); // Domain can't be changed
|
||||
}
|
||||
|
||||
|
@ -112,11 +112,8 @@ public class DatabaseRepository extends EntityRepository<Database> {
|
||||
@Override
|
||||
public void restorePatchAttributes(Database original, Database updated) {
|
||||
// Patch can't make changes to following fields. Ignore the changes
|
||||
updated
|
||||
.withFullyQualifiedName(original.getFullyQualifiedName())
|
||||
.withName(original.getName())
|
||||
.withService(original.getService())
|
||||
.withId(original.getId());
|
||||
super.restorePatchAttributes(original, updated);
|
||||
updated.withService(original.getService());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,11 +124,8 @@ public class DatabaseSchemaRepository extends EntityRepository<DatabaseSchema> {
|
||||
@Override
|
||||
public void restorePatchAttributes(DatabaseSchema original, DatabaseSchema updated) {
|
||||
// Patch can't make changes to following fields. Ignore the changes
|
||||
updated
|
||||
.withFullyQualifiedName(original.getFullyQualifiedName())
|
||||
.withName(original.getName())
|
||||
.withService(original.getService())
|
||||
.withId(original.getId());
|
||||
super.restorePatchAttributes(original, updated);
|
||||
updated.withService(original.getService());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,12 +43,6 @@ public class DocumentRepository extends EntityRepository<Document> {
|
||||
doc.setFullyQualifiedName(doc.getFullyQualifiedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restorePatchAttributes(Document original, Document updated) {
|
||||
// Patch can't make changes to following fields. Ignore the changes
|
||||
updated.withName(original.getName()).withId(original.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Document setFields(Document document, Fields fields) {
|
||||
return document;
|
||||
|
@ -97,6 +97,7 @@ public class DomainRepository extends EntityRepository<Domain> {
|
||||
|
||||
@Override
|
||||
public void restorePatchAttributes(Domain original, Domain updated) {
|
||||
super.restorePatchAttributes(original, updated);
|
||||
updated.withParent(original.getParent()); // Parent can't be changed
|
||||
updated.withChildren(original.getChildren()); // Children can't be changed
|
||||
}
|
||||
|
@ -211,6 +211,7 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
||||
@Getter protected final boolean supportsReviewers;
|
||||
@Getter protected final boolean supportsExperts;
|
||||
protected boolean quoteFqn = false; // Entity FQNS not hierarchical such user, teams, services need to be quoted
|
||||
protected boolean renameAllowed = false; // Entity can be renamed
|
||||
|
||||
/** Fields that can be updated during PATCH operation */
|
||||
@Getter private final Fields patchFields;
|
||||
@ -370,7 +371,10 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
||||
* stored in the original entity.
|
||||
*/
|
||||
public void restorePatchAttributes(T original, T updated) {
|
||||
/* Nothing to restore during PATCH */
|
||||
updated.setId(original.getId());
|
||||
updated.setName(renameAllowed ? updated.getName() : original.getName());
|
||||
updated.setFullyQualifiedName(original.getFullyQualifiedName());
|
||||
updated.setChangeDescription(original.getChangeDescription());
|
||||
}
|
||||
|
||||
/** Set fullyQualifiedName of an entity */
|
||||
|
@ -93,11 +93,6 @@ public class EventSubscriptionRepository extends EntityRepository<EventSubscript
|
||||
// No relationships to store beyond what is stored in the super class
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restorePatchAttributes(EventSubscription original, EventSubscription updated) {
|
||||
updated.withId(original.getId()).withName(original.getName());
|
||||
}
|
||||
|
||||
private SubscriptionPublisher getPublisher(UUID id) {
|
||||
return subscriptionPublisherMap.get(id);
|
||||
}
|
||||
|
@ -269,6 +269,7 @@ public class GlossaryRepository extends EntityRepository<Glossary> {
|
||||
public class GlossaryUpdater extends EntityUpdater {
|
||||
public GlossaryUpdater(Glossary original, Glossary updated, Operation operation) {
|
||||
super(original, updated, operation);
|
||||
renameAllowed = true;
|
||||
}
|
||||
|
||||
@Transaction
|
||||
@ -285,6 +286,7 @@ public class GlossaryRepository extends EntityRepository<Glossary> {
|
||||
}
|
||||
// Glossary name changed - update tag names starting from glossary and all the children tags
|
||||
LOG.info("Glossary name changed from {} to {}", original.getName(), updated.getName());
|
||||
setFullyQualifiedName(updated);
|
||||
daoCollection.glossaryTermDAO().updateFqn(original.getName(), updated.getName());
|
||||
daoCollection
|
||||
.tagUsageDAO()
|
||||
|
@ -82,6 +82,7 @@ public class GlossaryTermRepository extends EntityRepository<GlossaryTerm> {
|
||||
PATCH_FIELDS,
|
||||
UPDATE_FIELDS);
|
||||
supportsSearch = true;
|
||||
renameAllowed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -177,6 +178,7 @@ public class GlossaryTermRepository extends EntityRepository<GlossaryTerm> {
|
||||
@Override
|
||||
public void restorePatchAttributes(GlossaryTerm original, GlossaryTerm updated) {
|
||||
// Patch can't update Children
|
||||
super.restorePatchAttributes(original, updated);
|
||||
updated.withChildren(original.getChildren());
|
||||
}
|
||||
|
||||
@ -435,6 +437,7 @@ public class GlossaryTermRepository extends EntityRepository<GlossaryTerm> {
|
||||
CatalogExceptionMessage.systemEntityRenameNotAllowed(original.getName(), entityType));
|
||||
}
|
||||
// Glossary term name changed - update the FQNs of the children terms to reflect this
|
||||
setFullyQualifiedName(updated);
|
||||
LOG.info("Glossary term name changed from {} to {}", original.getName(), updated.getName());
|
||||
daoCollection.glossaryTermDAO().updateFqn(original.getFullyQualifiedName(), updated.getFullyQualifiedName());
|
||||
daoCollection
|
||||
@ -455,6 +458,7 @@ public class GlossaryTermRepository extends EntityRepository<GlossaryTerm> {
|
||||
UUID newGlossaryId = getId(updated.getGlossary());
|
||||
boolean glossaryChanged = !Objects.equals(oldGlossaryId, newGlossaryId);
|
||||
|
||||
setFullyQualifiedName(updated); // Update the FQN since the parent has changed
|
||||
daoCollection.glossaryTermDAO().updateFqn(original.getFullyQualifiedName(), updated.getFullyQualifiedName());
|
||||
daoCollection
|
||||
.tagUsageDAO()
|
||||
|
@ -103,11 +103,8 @@ public class MlModelRepository extends EntityRepository<MlModel> {
|
||||
@Override
|
||||
public void restorePatchAttributes(MlModel original, MlModel updated) {
|
||||
// Patch can't make changes to following fields. Ignore the changes
|
||||
updated
|
||||
.withFullyQualifiedName(original.getFullyQualifiedName())
|
||||
.withService(original.getService())
|
||||
.withName(original.getName())
|
||||
.withId(original.getId());
|
||||
super.restorePatchAttributes(original, updated);
|
||||
updated.withService(original.getService());
|
||||
}
|
||||
|
||||
private void setMlFeatureSourcesFQN(List<MlFeatureSource> mlSources) {
|
||||
|
@ -56,12 +56,6 @@ public class PersonaRepository extends EntityRepository<Persona> {
|
||||
return persona;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restorePatchAttributes(Persona original, Persona updated) {
|
||||
// Patch can't make changes to following fields. Ignore the changes
|
||||
updated.withName(original.getName()).withId(original.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(Persona persona, boolean update) {
|
||||
validateUsers(persona.getUsers());
|
||||
|
@ -210,11 +210,8 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
|
||||
@Override
|
||||
public void restorePatchAttributes(Pipeline original, Pipeline updated) {
|
||||
// Patch can't make changes to following fields. Ignore the changes
|
||||
updated
|
||||
.withFullyQualifiedName(original.getFullyQualifiedName())
|
||||
.withName(original.getName())
|
||||
.withService(original.getService())
|
||||
.withId(original.getId());
|
||||
super.restorePatchAttributes(original, updated);
|
||||
updated.withService(original.getService());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,12 +65,6 @@ public class RoleRepository extends EntityRepository<Role> {
|
||||
return findFrom(role.getId(), Entity.ROLE, Relationship.HAS, Entity.TEAM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restorePatchAttributes(Role original, Role updated) {
|
||||
// Patch can't make changes to following fields. Ignore the changes
|
||||
updated.withName(original.getName()).withId(original.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* If policy does not exist for this role, create a new entity reference. The actual policy gets created within the
|
||||
* storeEntity method call.
|
||||
|
@ -170,12 +170,8 @@ public class TableRepository extends EntityRepository<Table> {
|
||||
@Override
|
||||
public void restorePatchAttributes(Table original, Table updated) {
|
||||
// Patch can't make changes to following fields. Ignore the changes.
|
||||
updated
|
||||
.withFullyQualifiedName(original.getFullyQualifiedName())
|
||||
.withName(original.getName())
|
||||
.withDatabase(original.getDatabase())
|
||||
.withService(original.getService())
|
||||
.withId(original.getId());
|
||||
super.restorePatchAttributes(original, updated);
|
||||
updated.withDatabase(original.getDatabase()).withService(original.getService());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,6 +41,7 @@ public class TagRepository extends EntityRepository<Tag> {
|
||||
public TagRepository() {
|
||||
super(TagResource.TAG_COLLECTION_PATH, Entity.TAG, Tag.class, Entity.getCollectionDAO().tagDAO(), "", "");
|
||||
supportsSearch = true;
|
||||
renameAllowed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -67,6 +68,7 @@ public class TagRepository extends EntityRepository<Tag> {
|
||||
|
||||
@Override
|
||||
public void restorePatchAttributes(Tag original, Tag updated) {
|
||||
super.restorePatchAttributes(original, updated);
|
||||
updated.setChildren(original.getChildren());
|
||||
}
|
||||
|
||||
@ -153,6 +155,7 @@ public class TagRepository extends EntityRepository<Tag> {
|
||||
}
|
||||
// Category name changed - update tag names starting from classification and all the children tags
|
||||
LOG.info("Tag name changed from {} to {}", original.getName(), updated.getName());
|
||||
setFullyQualifiedName(updated);
|
||||
daoCollection.tagDAO().updateFqn(original.getFullyQualifiedName(), updated.getFullyQualifiedName());
|
||||
daoCollection
|
||||
.tagUsageDAO()
|
||||
@ -176,6 +179,7 @@ public class TagRepository extends EntityRepository<Tag> {
|
||||
UUID newCategoryId = getId(updated.getClassification());
|
||||
boolean classificationChanged = !Objects.equals(oldCategoryId, newCategoryId);
|
||||
|
||||
setFullyQualifiedName(updated);
|
||||
daoCollection.tagDAO().updateFqn(original.getFullyQualifiedName(), updated.getFullyQualifiedName());
|
||||
daoCollection
|
||||
.tagUsageDAO()
|
||||
|
@ -125,7 +125,7 @@ public class TeamRepository extends EntityRepository<Team> {
|
||||
@Override
|
||||
public void restorePatchAttributes(Team original, Team updated) {
|
||||
// Patch can't make changes to following fields. Ignore the changes
|
||||
updated.withName(original.getName()).withId(original.getId());
|
||||
super.restorePatchAttributes(original, updated);
|
||||
updated.withInheritedRoles(original.getInheritedRoles());
|
||||
}
|
||||
|
||||
|
@ -136,9 +136,8 @@ public class UserRepository extends EntityRepository<User> {
|
||||
@Override
|
||||
public void restorePatchAttributes(User original, User updated) {
|
||||
// Patch can't make changes to following fields. Ignore the changes
|
||||
super.restorePatchAttributes(original, updated);
|
||||
updated
|
||||
.withId(original.getId())
|
||||
.withName(original.getName())
|
||||
.withInheritedRoles(original.getInheritedRoles())
|
||||
.withAuthenticationMechanism(original.getAuthenticationMechanism());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user