diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/ReindexEntitiesClient.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/ReindexEntitiesClient.java index 3d0d3eab9cff..954f85137571 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/ReindexEntitiesClient.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/ReindexEntitiesClient.java @@ -65,7 +65,7 @@ public void recreateAndAwait(final List refs, final Duration ma * "type must not be null". */ public void recreateAndAwait( - final String entityType, final List entities) { + final String entityType, final List> entities) { if (entities == null || entities.isEmpty()) { throw new IllegalArgumentException("entity list must not be empty"); } @@ -87,13 +87,13 @@ public void recreateAndAwait( * live-index path that runs after entity creation. */ public void awaitIndexed( - final String entityType, final List entities) { + final String entityType, final List> entities) { awaitIndexed(entityType, entities, DEFAULT_WAIT); } public void awaitIndexed( final String entityType, - final List entities, + final List> entities, final Duration maxWait) { final List refs = entities.stream() diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/EntityCases.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/EntityCases.java index adf785e0f4dc..e375bab189d1 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/EntityCases.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/EntityCases.java @@ -20,13 +20,13 @@ public final class EntityCases { private final String entityType; - private final Function minimal; + private final Function> minimal; private final ShapeContext ctx; private final List cases = new ArrayList<>(); public EntityCases( final String entityType, - final Function minimal, + final Function> minimal, final ShapeContext ctx) { this.entityType = entityType; this.minimal = minimal; @@ -36,7 +36,7 @@ public EntityCases( public EntityCases add( final String dimension, final Rung rung, - final BiFunction apply) { + final BiFunction, Rung, EntityInterface> apply) { cases.add( new PlannedCase( entityType, dimension, rung, () -> apply.apply(minimal.apply(ctx), rung), null)); diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/EntityShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/EntityShapeProfile.java index d0e9c9b03eb1..e23980c7dbc2 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/EntityShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/EntityShapeProfile.java @@ -18,7 +18,7 @@ public interface EntityShapeProfile { String entityType(); - EntityInterface minimal(ShapeContext ctx); + EntityInterface minimal(ShapeContext ctx); default List entitySpecificCases(ShapeContext ctx) { return List.of(); diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/PlannedCase.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/PlannedCase.java index e9027a4a7478..73159da9d8b5 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/PlannedCase.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/PlannedCase.java @@ -19,7 +19,7 @@ public record PlannedCase( String entityType, String dimension, Rung rung, - Supplier entity, + Supplier> entity, FieldProbe probe) { public String label() { diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/ShapeCanary.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/ShapeCanary.java index 980b896909b5..4edbdc28e816 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/ShapeCanary.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/ShapeCanary.java @@ -38,7 +38,7 @@ public ShapeCanary(final SearchRepository searchRepository, final SearchClient h } public ShapeResult index( - final String entityType, final EntityInterface entity, final FieldProbe probe) { + final String entityType, final EntityInterface entity, final FieldProbe probe) { final String docId = entity.getId().toString(); // Built before the try: JsonUtils.pojoToJson reports a serialization bug as a // JsonParsingException caused by a JsonProcessingException, which extends IOException -- so @@ -98,7 +98,7 @@ public static final class ShapeTransportException extends RuntimeException { * refusing an unindexable shape, so it must surface as an error rather than masquerade as * REJECTED (which is reserved for the write below). */ - private String buildDoc(final String entityType, final EntityInterface entity) { + private String buildDoc(final String entityType, final EntityInterface entity) { final SearchIndex index = searchRepository.getSearchIndexFactory().buildIndex(entityType, entity); return JsonUtils.pojoToJson(index.buildSearchIndexDoc()); diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/ShapeMutation.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/ShapeMutation.java index fd7637e456d2..5a2f66c42cc1 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/ShapeMutation.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/ShapeMutation.java @@ -18,11 +18,11 @@ public interface ShapeMutation { String dimension(); - boolean appliesTo(EntityInterface entity); + boolean appliesTo(EntityInterface entity); List ladder(); - EntityInterface apply(EntityInterface entity, Rung rung); + EntityInterface apply(EntityInterface entity, Rung rung); default FieldProbe probe(Rung rung) { return null; diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/CustomPropertiesBreadthMutation.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/CustomPropertiesBreadthMutation.java index 2111c9ec4b0a..259b4838fcd0 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/CustomPropertiesBreadthMutation.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/CustomPropertiesBreadthMutation.java @@ -35,7 +35,7 @@ public String dimension() { * the filter type-aware. */ @Override - public boolean appliesTo(final EntityInterface entity) { + public boolean appliesTo(final EntityInterface entity) { boolean serializesExtension; try { serializesExtension = @@ -52,7 +52,7 @@ public List ladder() { } @Override - public EntityInterface apply(final EntityInterface entity, final Rung rung) { + public EntityInterface apply(final EntityInterface entity, final Rung rung) { final Map props = new LinkedHashMap<>(); for (int i = 0; i < rung.magnitude(); i++) { props.put("prop_" + i, "value_" + i); diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/DescriptionSizeMutation.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/DescriptionSizeMutation.java index 406215be0ec7..398ad8e6fc6a 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/DescriptionSizeMutation.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/DescriptionSizeMutation.java @@ -25,7 +25,7 @@ public String dimension() { } @Override - public boolean appliesTo(final EntityInterface entity) { + public boolean appliesTo(final EntityInterface entity) { return true; } @@ -35,7 +35,7 @@ public List ladder() { } @Override - public EntityInterface apply(final EntityInterface entity, final Rung rung) { + public EntityInterface apply(final EntityInterface entity, final Rung rung) { entity.setDescription("x".repeat(rung.magnitude())); return entity; } diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/FollowersCountMutation.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/FollowersCountMutation.java index 1417bf77a19f..89a20a335f83 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/FollowersCountMutation.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/FollowersCountMutation.java @@ -27,7 +27,7 @@ public String dimension() { } @Override - public boolean appliesTo(final EntityInterface entity) { + public boolean appliesTo(final EntityInterface entity) { return true; } @@ -37,7 +37,7 @@ public List ladder() { } @Override - public EntityInterface apply(final EntityInterface entity, final Rung rung) { + public EntityInterface apply(final EntityInterface entity, final Rung rung) { final List followers = new ArrayList<>(rung.magnitude()); for (int i = 0; i < rung.magnitude(); i++) { followers.add(new EntityReference().withId(UUID.randomUUID()).withType("user")); diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/KeywordIgnoreAboveMutation.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/KeywordIgnoreAboveMutation.java index 07831d87bb40..ece6ffe56f21 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/KeywordIgnoreAboveMutation.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/KeywordIgnoreAboveMutation.java @@ -28,7 +28,7 @@ public String dimension() { } @Override - public boolean appliesTo(final EntityInterface entity) { + public boolean appliesTo(final EntityInterface entity) { return true; } @@ -38,7 +38,7 @@ public List ladder() { } @Override - public EntityInterface apply(final EntityInterface entity, final Rung rung) { + public EntityInterface apply(final EntityInterface entity, final Rung rung) { entity.setDisplayName(value(rung)); return entity; } diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/OwnersCountMutation.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/OwnersCountMutation.java index d6793dbc73d7..0abf9b0a1529 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/OwnersCountMutation.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/OwnersCountMutation.java @@ -29,7 +29,7 @@ public String dimension() { } @Override - public boolean appliesTo(final EntityInterface entity) { + public boolean appliesTo(final EntityInterface entity) { return true; } @@ -50,7 +50,7 @@ public List ladder() { } @Override - public EntityInterface apply(final EntityInterface entity, final Rung rung) { + public EntityInterface apply(final EntityInterface entity, final Rung rung) { final List owners = new ArrayList<>(rung.magnitude()); for (int i = 0; i < rung.magnitude(); i++) { owners.add( diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/TagsCountMutation.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/TagsCountMutation.java index 21c0cfc24b49..dcf23a9ff583 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/TagsCountMutation.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/mutations/TagsCountMutation.java @@ -26,7 +26,7 @@ public String dimension() { } @Override - public boolean appliesTo(final EntityInterface entity) { + public boolean appliesTo(final EntityInterface entity) { return true; } @@ -36,7 +36,7 @@ public List ladder() { } @Override - public EntityInterface apply(final EntityInterface entity, final Rung rung) { + public EntityInterface apply(final EntityInterface entity, final Rung rung) { final List tags = new ArrayList<>(rung.magnitude()); for (int i = 0; i < rung.magnitude(); i++) { tags.add( diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/ApiCollectionShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/ApiCollectionShapeProfile.java index b952907042ec..fca8281abf59 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/ApiCollectionShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/ApiCollectionShapeProfile.java @@ -26,7 +26,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new APICollection() .withId(ctx.id()) .withName("apiCollection") diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/ApiEndpointShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/ApiEndpointShapeProfile.java index eed419db98c9..5cf3f28714d8 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/ApiEndpointShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/ApiEndpointShapeProfile.java @@ -34,7 +34,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new APIEndpoint() .withId(ctx.id()) .withName("endpoint") @@ -53,13 +53,13 @@ public List entitySpecificCases(final ShapeContext ctx) { .build(); } - private EntityInterface requestFields(final EntityInterface entity, final Rung rung) { + private EntityInterface requestFields(final EntityInterface entity, final Rung rung) { final APIEndpoint endpoint = (APIEndpoint) entity; endpoint.setRequestSchema(new APISchema().withSchemaFields(fields("req_", rung.magnitude()))); return endpoint; } - private EntityInterface responseFields(final EntityInterface entity, final Rung rung) { + private EntityInterface responseFields(final EntityInterface entity, final Rung rung) { final APIEndpoint endpoint = (APIEndpoint) entity; endpoint.setResponseSchema(new APISchema().withSchemaFields(fields("resp_", rung.magnitude()))); return endpoint; diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/ChartShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/ChartShapeProfile.java index 44afdd5a2263..3d7b521d122c 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/ChartShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/ChartShapeProfile.java @@ -26,7 +26,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new Chart() .withId(ctx.id()) .withName("chart") diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/ContainerShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/ContainerShapeProfile.java index 69f924d29483..19f7d8ddfed8 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/ContainerShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/ContainerShapeProfile.java @@ -34,7 +34,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new Container() .withId(ctx.id()) .withName("container") @@ -49,7 +49,7 @@ public List entitySpecificCases(final ShapeContext ctx) { .build(); } - private EntityInterface dataModelColumns(final EntityInterface entity, final Rung rung) { + private EntityInterface dataModelColumns(final EntityInterface entity, final Rung rung) { final Container container = (Container) entity; final List columns = new ArrayList<>(rung.magnitude()); for (int i = 0; i < rung.magnitude(); i++) { diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DashboardDataModelShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DashboardDataModelShapeProfile.java index 0763749c0111..9d8297b31244 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DashboardDataModelShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DashboardDataModelShapeProfile.java @@ -33,7 +33,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new DashboardDataModel() .withId(ctx.id()) .withName("dataModel") @@ -50,7 +50,7 @@ public List entitySpecificCases(final ShapeContext ctx) { .build(); } - private EntityInterface columns(final EntityInterface entity, final Rung rung) { + private EntityInterface columns(final EntityInterface entity, final Rung rung) { final DashboardDataModel model = (DashboardDataModel) entity; final List columns = new ArrayList<>(rung.magnitude()); for (int i = 0; i < rung.magnitude(); i++) { diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DashboardShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DashboardShapeProfile.java index 444ff009709c..00b59424edd7 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DashboardShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DashboardShapeProfile.java @@ -33,7 +33,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new Dashboard() .withId(ctx.id()) .withName("dashboard") @@ -48,7 +48,7 @@ public List entitySpecificCases(final ShapeContext ctx) { .build(); } - private EntityInterface charts(final EntityInterface entity, final Rung rung) { + private EntityInterface charts(final EntityInterface entity, final Rung rung) { final Dashboard dashboard = (Dashboard) entity; final List charts = new ArrayList<>(rung.magnitude()); for (int i = 0; i < rung.magnitude(); i++) { diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DataProductShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DataProductShapeProfile.java index 61f638f798ee..51531e9eb87e 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DataProductShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DataProductShapeProfile.java @@ -26,7 +26,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new DataProduct() .withId(ctx.id()) .withName("dataProduct") diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DatabaseSchemaShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DatabaseSchemaShapeProfile.java index b1b3b4c68e28..41c75fbd43b6 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DatabaseSchemaShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DatabaseSchemaShapeProfile.java @@ -26,7 +26,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new DatabaseSchema() .withId(ctx.id()) .withName("schema") diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DatabaseShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DatabaseShapeProfile.java index c462f16342fd..20e9b619bde8 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DatabaseShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DatabaseShapeProfile.java @@ -26,7 +26,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new Database() .withId(ctx.id()) .withName("database") diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DomainShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DomainShapeProfile.java index 998df3e89fef..060581e74fcb 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DomainShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/DomainShapeProfile.java @@ -26,7 +26,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new Domain() .withId(ctx.id()) .withName("domain") diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/GlossaryShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/GlossaryShapeProfile.java index 18fb3f6dff8d..b4b805bf1e79 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/GlossaryShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/GlossaryShapeProfile.java @@ -26,7 +26,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new Glossary() .withId(ctx.id()) .withName("glossary") diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/GlossaryTermShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/GlossaryTermShapeProfile.java index 0a53e0f0d237..80fef3e1ad22 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/GlossaryTermShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/GlossaryTermShapeProfile.java @@ -33,7 +33,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new GlossaryTerm() .withId(ctx.id()) .withName("term") @@ -50,7 +50,7 @@ public List entitySpecificCases(final ShapeContext ctx) { .build(); } - private EntityInterface synonyms(final EntityInterface entity, final Rung rung) { + private EntityInterface synonyms(final EntityInterface entity, final Rung rung) { final GlossaryTerm term = (GlossaryTerm) entity; final List synonyms = new ArrayList<>(rung.magnitude()); for (int i = 0; i < rung.magnitude(); i++) { diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/MetricShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/MetricShapeProfile.java index f2b5b9edcc78..850e0a5a51b3 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/MetricShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/MetricShapeProfile.java @@ -26,7 +26,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new Metric() .withId(ctx.id()) .withName("metric") diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/MlModelShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/MlModelShapeProfile.java index cb22bb201d08..42e0d14e1ece 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/MlModelShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/MlModelShapeProfile.java @@ -32,7 +32,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new MlModel() .withId(ctx.id()) .withName("model") @@ -49,7 +49,7 @@ public List entitySpecificCases(final ShapeContext ctx) { .build(); } - private EntityInterface features(final EntityInterface entity, final Rung rung) { + private EntityInterface features(final EntityInterface entity, final Rung rung) { final MlModel model = (MlModel) entity; final List features = new ArrayList<>(rung.magnitude()); for (int i = 0; i < rung.magnitude(); i++) { diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/PipelineShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/PipelineShapeProfile.java index 34368939b552..bd71fa65ba81 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/PipelineShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/PipelineShapeProfile.java @@ -32,7 +32,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new Pipeline() .withId(ctx.id()) .withName("pipeline") @@ -49,7 +49,7 @@ public List entitySpecificCases(final ShapeContext ctx) { .build(); } - private EntityInterface tasks(final EntityInterface entity, final Rung rung) { + private EntityInterface tasks(final EntityInterface entity, final Rung rung) { final Pipeline pipeline = (Pipeline) entity; final List tasks = new ArrayList<>(rung.magnitude()); for (int i = 0; i < rung.magnitude(); i++) { diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/QueryShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/QueryShapeProfile.java index c004b2aafcc9..b69b933ff22c 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/QueryShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/QueryShapeProfile.java @@ -30,7 +30,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new Query() .withId(ctx.id()) .withName("query") @@ -46,7 +46,7 @@ public List entitySpecificCases(final ShapeContext ctx) { .build(); } - private EntityInterface queryText(final EntityInterface entity, final Rung rung) { + private EntityInterface queryText(final EntityInterface entity, final Rung rung) { final Query query = (Query) entity; query.setQuery("SELECT " + "a".repeat(rung.magnitude())); return query; diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/SearchIndexShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/SearchIndexShapeProfile.java index 2315a603ffa3..8209220388c5 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/SearchIndexShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/SearchIndexShapeProfile.java @@ -33,7 +33,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new SearchIndex() .withId(ctx.id()) .withName("index") @@ -50,7 +50,7 @@ public List entitySpecificCases(final ShapeContext ctx) { .build(); } - private EntityInterface fields(final EntityInterface entity, final Rung rung) { + private EntityInterface fields(final EntityInterface entity, final Rung rung) { final SearchIndex index = (SearchIndex) entity; final List fields = new ArrayList<>(rung.magnitude()); for (int i = 0; i < rung.magnitude(); i++) { diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/StoredProcedureShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/StoredProcedureShapeProfile.java index caf4deb4949d..a8b24bf1d3e0 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/StoredProcedureShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/StoredProcedureShapeProfile.java @@ -31,7 +31,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new StoredProcedure() .withId(ctx.id()) .withName("proc") @@ -47,7 +47,7 @@ public List entitySpecificCases(final ShapeContext ctx) { .build(); } - private EntityInterface code(final EntityInterface entity, final Rung rung) { + private EntityInterface code(final EntityInterface entity, final Rung rung) { final StoredProcedure proc = (StoredProcedure) entity; proc.setStoredProcedureCode(new StoredProcedureCode().withCode("x".repeat(rung.magnitude()))); return proc; diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/TableShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/TableShapeProfile.java index e92c57a6d2ce..c2f431990a07 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/TableShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/TableShapeProfile.java @@ -33,7 +33,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new Table() .withId(ctx.id()) .withName("table") @@ -54,7 +54,7 @@ public List entitySpecificCases(final ShapeContext ctx) { return cases.build(); } - private EntityInterface flatColumns(final EntityInterface entity, final Rung rung) { + private EntityInterface flatColumns(final EntityInterface entity, final Rung rung) { final Table table = (Table) entity; final List columns = new ArrayList<>(rung.magnitude()); for (int i = 0; i < rung.magnitude(); i++) { @@ -64,7 +64,7 @@ private EntityInterface flatColumns(final EntityInterface entity, final Rung run return table; } - private EntityInterface nestedColumns(final EntityInterface entity, final Rung rung) { + private EntityInterface nestedColumns(final EntityInterface entity, final Rung rung) { final Table table = (Table) entity; Column leaf = new Column().withName("leaf").withDataType(ColumnDataType.STRING); for (int depth = 0; depth < rung.magnitude(); depth++) { diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/TopicShapeProfile.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/TopicShapeProfile.java index db4740e37edf..e735b0db8c28 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/TopicShapeProfile.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/search/shape/profiles/TopicShapeProfile.java @@ -34,7 +34,7 @@ public String entityType() { } @Override - public EntityInterface minimal(final ShapeContext ctx) { + public EntityInterface minimal(final ShapeContext ctx) { return new Topic() .withId(ctx.id()) .withName("topic") @@ -49,7 +49,7 @@ public List entitySpecificCases(final ShapeContext ctx) { .build(); } - private EntityInterface fields(final EntityInterface entity, final Rung rung) { + private EntityInterface fields(final EntityInterface entity, final Rung rung) { final Topic topic = (Topic) entity; final List fields = new ArrayList<>(rung.magnitude()); for (int i = 0; i < rung.magnitude(); i++) { diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/BaseEntityIT.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/BaseEntityIT.java index 89781a5ba4b2..cce98ab853a2 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/BaseEntityIT.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/BaseEntityIT.java @@ -69,6 +69,7 @@ import org.openmetadata.sdk.services.teams.RoleService; import org.openmetadata.sdk.services.teams.UserService; import org.openmetadata.service.Entity; +import org.openmetadata.service.governance.EntityStatusAdapter; import org.openmetadata.service.jdbi3.EntityRepository; import org.openmetadata.service.util.TestUtils; @@ -94,7 +95,7 @@ */ @Slf4j @ExtendWith(TestNamespaceExtension.class) -public abstract class BaseEntityIT { +public abstract class BaseEntityIT, K> { // =================================================================== // ABSTRACT METHODS - Must be implemented by subclasses @@ -2985,7 +2986,7 @@ void test_fieldFetchers(TestNamespace ns) { // =================================================================== /** Stage a minimal entity of this type starts in when its create request carries none. */ - protected EntityStatus expectedInitialEntityStatus() { + protected Enum expectedInitialEntityStatus() { return EntityStatus.UNPROCESSED; } @@ -2993,7 +2994,7 @@ protected EntityStatus expectedInitialEntityStatus() { * Stages the lifecycle tests move an entity through, in order. Entity types that restrict which * stage may follow which override this with a path their rules allow. */ - protected List entityStatusPath() { + protected List> entityStatusPath() { return List.of( EntityStatus.DRAFT, EntityStatus.IN_REVIEW, @@ -3035,7 +3036,7 @@ void entityStatus_patchMovesThroughEveryStage(TestNamespace ns) { T created = createEntity(createMinimalRequest(ns)); T entity = getEntity(created.getId().toString()); - for (EntityStatus stage : entityStatusPath()) { + for (Enum stage : entityStatusPath()) { entity = moveToEntityStatus(entity, stage); } @@ -3053,7 +3054,7 @@ void entityStatus_putWithoutStageKeepsTheStage(TestNamespace ns) { K request = createMinimalRequest(ns); T created = createEntity(request); T current = getEntity(created.getId().toString()); - EntityStatus stage = + Enum stage = stageWorkflows().isEmpty() ? moveToEntityStatus(current, entityStatusPath().getLast()).getEntityStatus() : current.getEntityStatus(); @@ -3075,7 +3076,7 @@ void entityStatus_bulkUpsertWithoutStageKeepsTheStage(TestNamespace ns) { stageWorkflows().isEmpty(), getEntityType() + " stage is owned by an active workflow"); K request = createMinimalRequest(ns); T created = createEntity(request); - EntityStatus stage = + Enum stage = moveToEntityStatus(getEntity(created.getId().toString()), entityStatusPath().getLast()) .getEntityStatus(); @@ -3096,10 +3097,14 @@ void entityStatus_directChangeRejectedWhileWorkflowOwnsStage(TestNamespace ns) { stageWorkflows().isEmpty(), "no active workflow owns the " + getEntityType() + " stage"); T created = createEntity(createMinimalRequest(ns)); T entity = getEntity(created.getId().toString()); - EntityStatus stage = entity.getEntityStatus(); + Enum stage = entity.getEntityStatus(); - entity.setEntityStatus( - stage == EntityStatus.DEPRECATED ? EntityStatus.ARCHIVED : EntityStatus.DEPRECATED); + EntityStatusAdapter.forEntityType(entity.getClass()) + .write( + entity, + stage.toString().equals(EntityStatus.DEPRECATED.value()) + ? EntityStatus.ARCHIVED.value() + : EntityStatus.DEPRECATED.value()); ApiAssertions.assertForbidden( () -> patchEntity(created.getId().toString(), entity), @@ -3113,38 +3118,38 @@ void entityStatus_moveOutsideTheTypesLifecycleIsRejected(TestNamespace ns) { supportsEntityStatus && supportsPatch, getEntityType() + " stage cannot be patched"); EntityTypeLifecycle lifecycle = entityTypeLifecycle().orElseThrow(); T created = createEntity(createMinimalRequest(ns)); - EntityStatus stage = created.getEntityStatus(); + String stage = created.getEntityStatus().toString(); assertTrue( lifecycle.getStages().contains(stage), "A new " + getEntityType() + " starts in a stage of its lifecycle"); - Optional outside = stageNotReachableFrom(lifecycle, stage); + Optional outside = stageNotReachableFrom(lifecycle, stage); Assumptions.assumeTrue( outside.isPresent(), getEntityType() + " can move from " + stage + " to any stage"); T entity = getEntity(created.getId().toString()); - entity.setEntityStatus(outside.get()); + EntityStatusAdapter.forEntityType(entity.getClass()).write(entity, outside.get()); ApiAssertions.assertBadRequest( () -> patchEntity(created.getId().toString(), entity), "The " + getEntityType() + " lifecycle has no move from " + stage + " to " + outside.get()); - assertEquals(stage, getEntity(created.getId().toString()).getEntityStatus()); + assertEquals(stage, getEntity(created.getId().toString()).getEntityStatus().toString()); } - private static Optional stageNotReachableFrom( - EntityTypeLifecycle lifecycle, EntityStatus stage) { - List reachable = + private static Optional stageNotReachableFrom( + EntityTypeLifecycle lifecycle, String stage) { + List reachable = lifecycle.getTransitions().stream() - .filter(move -> move.getFrom() == stage) + .filter(move -> move.getFrom().equals(stage)) .flatMap(move -> move.getTo().stream()) .toList(); - return Arrays.stream(EntityStatus.values()) - .filter(candidate -> candidate != stage && !reachable.contains(candidate)) + return lifecycle.getStages().stream() + .filter(candidate -> !candidate.equals(stage) && !reachable.contains(candidate)) .findFirst(); } - private T moveToEntityStatus(T entity, EntityStatus stage) { + private T moveToEntityStatus(T entity, Enum stage) { T moved = entity; if (entity.getEntityStatus() != stage) { - entity.setEntityStatus(stage); + EntityStatusAdapter.forEntityType(entity.getClass()).write(entity, stage.toString()); moved = patchEntity(entity.getId().toString(), entity); assertEquals(stage, moved.getEntityStatus(), "PATCH must move the entity to " + stage); } @@ -3152,7 +3157,7 @@ private T moveToEntityStatus(T entity, EntityStatus stage) { } // An entity's href names its collection, which is also where a PUT upserts it. - private static String collectionPathOf(EntityInterface entity) { + private static String collectionPathOf(EntityInterface entity) { String entityPath = entity.getHref().getPath(); String collectionPath = entityPath.substring(0, entityPath.lastIndexOf('/')); return collectionPath.substring(collectionPath.indexOf("/v1/")); @@ -6321,7 +6326,7 @@ protected String getImportExportContainerName(TestNamespace ns) { return null; // Override in subclasses that support import/export } - protected String getCsvImportContainerName(TestNamespace ns, EntityInterface entity) { + protected String getCsvImportContainerName(TestNamespace ns, EntityInterface entity) { return getImportExportContainerName(ns); } @@ -6329,12 +6334,12 @@ protected String importCsvForEntity(String containerName, String csvData, boolea return getEntityService().importCsv(containerName, csvData, dryRun); } - protected EntityInterface createCsvImportRegressionEntity(TestNamespace ns) { + protected EntityInterface createCsvImportRegressionEntity(TestNamespace ns) { return createEntity(createRequest(ns.prefix("csvNullChangeDescription"), ns)); } @SuppressWarnings("unchecked") - protected EntityInterface patchCsvImportRegressionEntity(EntityInterface entity) { + protected EntityInterface patchCsvImportRegressionEntity(EntityInterface entity) { return patchEntity(entity.getId().toString(), (T) entity); } @@ -6342,12 +6347,12 @@ protected String getCsvImportRegressionEntityType() { return getEntityType(); } - protected EntityInterface getCsvImportRegressionEntityByName(String fqn) { + protected EntityInterface getCsvImportRegressionEntityByName(String fqn) { return getEntityByName(fqn); } @SuppressWarnings("unchecked") - protected String generateCsvImportRegressionData(TestNamespace ns, EntityInterface entity) { + protected String generateCsvImportRegressionData(TestNamespace ns, EntityInterface entity) { T csvUpdate = prepareCsvImportRegressionUpdate(ns, (T) entity); return generateValidCsvData(ns, List.of(csvUpdate)); } @@ -6586,13 +6591,13 @@ protected CsvImportResult performImportCsv( } @SuppressWarnings("unchecked") - private void persistEntityWithoutChangeDescription(String entityType, EntityInterface entity) { + private void persistEntityWithoutChangeDescription(String entityType, EntityInterface entity) { // These integration tests run in-process with the OpenMetadata server, so this can seed // persisted state that is not reachable through public APIs. invalidateCacheForEntity // drops the cross-thread Guava L1 entry and bumps the write epoch, which is what the // CSV import request (handled on a different Jetty thread) actually reads through. - EntityRepository repository = - (EntityRepository) Entity.getEntityRepository(entityType); + EntityRepository> repository = + (EntityRepository>) Entity.getEntityRepository(entityType); repository.getDao().update(entity); EntityRepository.invalidateCacheForEntity( entityType, entity.getId(), entity.getFullyQualifiedName()); @@ -6766,9 +6771,9 @@ void test_importCsv_skipsSessionConsolidationWhenChangeDescriptionIsMissing(Test org.openmetadata.sdk.services.EntityServiceBase service = getEntityService(); Assumptions.assumeTrue(service != null, "Entity service not provided"); - EntityInterface entity = createCsvImportRegressionEntity(ns); + EntityInterface entity = createCsvImportRegressionEntity(ns); entity.setDescription("Versioned for CSV import regression"); - EntityInterface versioned = patchCsvImportRegressionEntity(entity); + EntityInterface versioned = patchCsvImportRegressionEntity(entity); Double versionBeforeImport = versioned.getVersion(); String fqn = versioned.getFullyQualifiedName(); String entityType = getCsvImportRegressionEntityType(); @@ -6794,7 +6799,7 @@ void test_importCsv_skipsSessionConsolidationWhenChangeDescriptionIsMissing(Test "Import should succeed: " + importResult.getImportResultsCsv()); assertEquals(0, importResult.getNumberOfRowsFailed()); - EntityInterface updated = getCsvImportRegressionEntityByName(fqn); + EntityInterface updated = getCsvImportRegressionEntityByName(fqn); assertTrue( updated.getVersion() > versionBeforeImport, "CSV import should create a new version"); assertNotNull(updated.getChangeDescription(), "CSV import should record a changeDescription"); diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/BaseServiceIT.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/BaseServiceIT.java index 963b4c29a59c..fc8a64a6898c 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/BaseServiceIT.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/BaseServiceIT.java @@ -35,7 +35,7 @@ * @param The service entity type (e.g., DatabaseService, DashboardService) * @param The create request type (e.g., CreateDatabaseService) */ -public abstract class BaseServiceIT +public abstract class BaseServiceIT, K extends CreateEntity> extends BaseEntityIT { // Services typically don't support patch, don't have search indices, and don't need tag testing diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ContextMemoryAnchorIT.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ContextMemoryAnchorIT.java index 358ba02bb435..0c600fa95505 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ContextMemoryAnchorIT.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ContextMemoryAnchorIT.java @@ -30,6 +30,7 @@ import org.openmetadata.schema.api.teams.CreateUser; import org.openmetadata.schema.entity.context.ContextMemory; import org.openmetadata.schema.entity.context.ContextMemorySourceType; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.MemoryShareConfig; import org.openmetadata.schema.entity.context.MemoryVisibility; import org.openmetadata.schema.entity.data.ContextFile; @@ -43,7 +44,6 @@ import org.openmetadata.schema.type.Column; import org.openmetadata.schema.type.ColumnDataType; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.MetadataOperation; import org.openmetadata.schema.utils.JsonUtils; import org.openmetadata.sdk.client.OpenMetadataClient; @@ -429,7 +429,7 @@ private static User createUser(TestNamespace ns, Role role, List domains private static CreateContextMemory entityMemory(TestNamespace ns, String name) { return new CreateContextMemory() .withName(ns.prefix(name)) - .withEntityStatus(EntityStatus.APPROVED) + .withEntityStatus(ContextMemoryStatus.APPROVED) .withQuestion("Which column holds the order total?") .withAnswer("orders.amount_usd, in US dollars.") .withShareConfig(new MemoryShareConfig().withVisibility(MemoryVisibility.ENTITY)); diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ContextMemoryIT.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ContextMemoryIT.java index 55f22da075fb..511be1262eff 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ContextMemoryIT.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ContextMemoryIT.java @@ -22,6 +22,7 @@ import org.openmetadata.schema.api.context.CreateContextMemory; import org.openmetadata.schema.entity.context.ContextMemory; import org.openmetadata.schema.entity.context.ContextMemoryScope; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.ContextMemoryType; import org.openmetadata.schema.entity.context.MemoryShareConfig; import org.openmetadata.schema.entity.context.MemorySharedPrincipal; @@ -29,13 +30,13 @@ import org.openmetadata.schema.entity.teams.User; import org.openmetadata.schema.type.EntityHistory; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.sdk.client.OpenMetadataClient; import org.openmetadata.sdk.exceptions.ForbiddenException; import org.openmetadata.sdk.exceptions.InvalidRequestException; import org.openmetadata.sdk.fluent.Users; import org.openmetadata.sdk.models.ListParams; import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.sdk.network.HttpMethod; import org.openmetadata.sdk.services.context.ContextMemoryService; /** @@ -126,21 +127,22 @@ protected String getEntityType() { } @Override - protected EntityStatus expectedInitialEntityStatus() { - return EntityStatus.UNPROCESSED; + protected ContextMemoryStatus expectedInitialEntityStatus() { + return ContextMemoryStatus.UNPROCESSED; } // Ordinary search returns trusted memories. Keep search fixtures explicitly approved while // creation and lifecycle tests continue to exercise requests that omit the stage. @Override protected CreateContextMemory createSearchRequest(TestNamespace ns) { - return createMinimalRequest(ns).withEntityStatus(EntityStatus.APPROVED); + return createMinimalRequest(ns).withEntityStatus(ContextMemoryStatus.APPROVED); } /** A memory can never go back to Draft, so its path moves between in use and archived. */ @Override - protected List entityStatusPath() { - return List.of(EntityStatus.ARCHIVED, EntityStatus.APPROVED, EntityStatus.ARCHIVED); + protected List entityStatusPath() { + return List.of( + ContextMemoryStatus.ARCHIVED, ContextMemoryStatus.APPROVED, ContextMemoryStatus.ARCHIVED); } @Override @@ -316,22 +318,22 @@ void put_contextMemoryStatusTransitions_valid_200_OK(TestNamespace ns) { .withDescription("Valid status transitions") .withQuestion("What is the status flow?") .withAnswer("Draft to Approved to Archived and back to Approved.") - .withEntityStatus(EntityStatus.DRAFT); + .withEntityStatus(ContextMemoryStatus.DRAFT); ContextMemory memory = createEntity(request); - assertEquals(EntityStatus.DRAFT, memory.getEntityStatus()); + assertEquals(ContextMemoryStatus.DRAFT, memory.getEntityStatus()); - request.withEntityStatus(EntityStatus.APPROVED); + request.withEntityStatus(ContextMemoryStatus.APPROVED); ContextMemory active = getContextMemoryService().put(request); - assertEquals(EntityStatus.APPROVED, active.getEntityStatus()); + assertEquals(ContextMemoryStatus.APPROVED, active.getEntityStatus()); - request.withEntityStatus(EntityStatus.ARCHIVED); + request.withEntityStatus(ContextMemoryStatus.ARCHIVED); ContextMemory archived = getContextMemoryService().put(request); - assertEquals(EntityStatus.ARCHIVED, archived.getEntityStatus()); + assertEquals(ContextMemoryStatus.ARCHIVED, archived.getEntityStatus()); - request.withEntityStatus(EntityStatus.APPROVED); + request.withEntityStatus(ContextMemoryStatus.APPROVED); ContextMemory reactivated = getContextMemoryService().put(request); - assertEquals(EntityStatus.APPROVED, reactivated.getEntityStatus()); + assertEquals(ContextMemoryStatus.APPROVED, reactivated.getEntityStatus()); } @Test @@ -342,12 +344,12 @@ void put_contextMemoryStatusTransition_invalid_fails(TestNamespace ns) { .withDescription("Invalid status transition") .withQuestion("Can Approved go back to Draft?") .withAnswer("No, Approved cannot revert to Draft.") - .withEntityStatus(EntityStatus.APPROVED); + .withEntityStatus(ContextMemoryStatus.APPROVED); ContextMemory memory = createEntity(request); - assertEquals(EntityStatus.APPROVED, memory.getEntityStatus()); + assertEquals(ContextMemoryStatus.APPROVED, memory.getEntityStatus()); - request.withEntityStatus(EntityStatus.DRAFT); + request.withEntityStatus(ContextMemoryStatus.DRAFT); assertThrows( Exception.class, () -> getContextMemoryService().put(request), @@ -356,17 +358,19 @@ void put_contextMemoryStatusTransition_invalid_fails(TestNamespace ns) { @Test void post_contextMemoryInStageOutsideItsLifecycle_400(TestNamespace ns) { - CreateContextMemory request = - new CreateContextMemory() - .withName(ns.prefix("status-outside-lifecycle")) - .withDescription("A memory cannot be in review") - .withQuestion("Can a memory be In Review?") - .withAnswer("No, a memory is Draft, Approved or Archived.") - .withEntityStatus(EntityStatus.IN_REVIEW); + Map request = + Map.of( + "name", ns.prefix("status-outside-lifecycle"), + "question", "Can a memory be In Review?", + "answer", "A memory uses its own status vocabulary.", + "entityStatus", "In Review"); - InvalidRequestException exception = - assertThrows(InvalidRequestException.class, () -> createEntity(request)); - assertTrue(exception.getMessage().contains("is not a lifecycle stage of contextMemory")); + assertThrows( + InvalidRequestException.class, + () -> + SdkClients.adminClient() + .getHttpClient() + .executeForString(HttpMethod.POST, "/v1/contextCenter/memories", request)); } @Test @@ -377,18 +381,18 @@ void put_statusOnlyChange_persistsAfterGet(TestNamespace ns) { .withDescription("Status-only update persistence test") .withQuestion("Does the status persist?") .withAnswer("Yes, after a status-only PUT.") - .withEntityStatus(EntityStatus.DRAFT); + .withEntityStatus(ContextMemoryStatus.DRAFT); ContextMemory memory = createEntity(request); - assertEquals(EntityStatus.DRAFT, memory.getEntityStatus()); + assertEquals(ContextMemoryStatus.DRAFT, memory.getEntityStatus()); - request.withEntityStatus(EntityStatus.APPROVED); + request.withEntityStatus(ContextMemoryStatus.APPROVED); ContextMemory putResponse = getContextMemoryService().put(request); - assertEquals(EntityStatus.APPROVED, putResponse.getEntityStatus()); + assertEquals(ContextMemoryStatus.APPROVED, putResponse.getEntityStatus()); ContextMemory fetched = getEntity(memory.getId().toString()); assertEquals( - EntityStatus.APPROVED, + ContextMemoryStatus.APPROVED, fetched.getEntityStatus(), "Status should persist after a status-only PUT update"); assertTrue( @@ -404,14 +408,14 @@ void put_statusChanges_recordVersionHistory(TestNamespace ns) { .withDescription("Status change history test") .withQuestion("Are status changes versioned?") .withAnswer("Yes, each transition bumps the version.") - .withEntityStatus(EntityStatus.DRAFT); + .withEntityStatus(ContextMemoryStatus.DRAFT); ContextMemory memory = createEntity(request); - request.withEntityStatus(EntityStatus.APPROVED); + request.withEntityStatus(ContextMemoryStatus.APPROVED); getContextMemoryService().put(request); - request.withEntityStatus(EntityStatus.ARCHIVED); + request.withEntityStatus(ContextMemoryStatus.ARCHIVED); getContextMemoryService().put(request); EntityHistory history = getVersionHistory(memory.getId()); @@ -620,7 +624,7 @@ private CreateContextMemory memoryWithVisibility( return new CreateContextMemory() .withName(ns.prefix(name)) .withDescription("Visibility indexing test") - .withEntityStatus(EntityStatus.APPROVED) + .withEntityStatus(ContextMemoryStatus.APPROVED) .withQuestion("Is this memory searchable?") .withAnswer("Visibility is enforced at query time, not at index time.") .withShareConfig(new MemoryShareConfig().withVisibility(visibility)); diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ContextMemoryLifecycleIT.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ContextMemoryLifecycleIT.java index e7d7760f812f..46362354b24e 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ContextMemoryLifecycleIT.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ContextMemoryLifecycleIT.java @@ -19,6 +19,8 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.parallel.Execution; import org.junit.jupiter.api.parallel.ExecutionMode; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; import org.openmetadata.it.bootstrap.SharedEntities; import org.openmetadata.it.util.SdkClients; import org.openmetadata.it.util.TestNamespace; @@ -26,17 +28,18 @@ import org.openmetadata.schema.api.context.CreateContextMemory; import org.openmetadata.schema.entity.context.ContextMemory; import org.openmetadata.schema.entity.context.ContextMemorySourceType; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.ContextMemoryType; import org.openmetadata.schema.entity.context.MemoryShareConfig; import org.openmetadata.schema.entity.context.MemoryVisibility; import org.openmetadata.schema.type.ChangeDescription; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.FieldChange; import org.openmetadata.schema.utils.JsonUtils; import org.openmetadata.sdk.exceptions.InvalidRequestException; import org.openmetadata.sdk.models.ListParams; import org.openmetadata.sdk.services.context.ContextMemoryService; import org.openmetadata.service.Entity; +import org.openmetadata.service.util.EntityFieldUtils; /** * Lifecycle of a context memory over the REST API. A memory is patched at most once per principal @@ -48,48 +51,74 @@ public class ContextMemoryLifecycleIT { private static final String SUPERSEDE = """ - [{"op":"replace","path":"/entityStatus","value":"Deprecated"}, + [{"op":"replace","path":"/entityStatus","value":"%s"}, {"op":"add","path":"/supersededBy","value":{"id":"%s","type":"%s"}}, {"op":"add","path":"/statusReason","value":"%s"}]"""; + @Test + void workflowFieldSetterResolvesMemoryStatusesAndRejectsOtherVocabularies(TestNamespace ns) { + ContextMemory memory = admin().create(memory(ns, "workflow-memory-status")); + EntityFieldUtils.setEntityField( + memory, + Entity.CONTEXT_MEMORY, + Entity.ADMIN_USER_NAME, + Entity.FIELD_ENTITY_STATUS, + ContextMemoryStatus.INVALIDATED.value(), + true); + assertEquals(ContextMemoryStatus.INVALIDATED, admin().get(idOf(memory)).getEntityStatus()); + assertThrows( + IllegalArgumentException.class, + () -> EntityFieldUtils.setEntityStatus(memory, "In Review")); + assertEquals(ContextMemoryStatus.INVALIDATED, admin().get(idOf(memory)).getEntityStatus()); + } + private static final String ADD_DISPUTE = """ [{"op":"add","path":"/disputes","value":[{"memory":{"id":"%s","type":"contextMemory"},\ "reason":"%s","detectedAt":1700000000000}]}]"""; - @Test - void superseding_storesTheSuccessorAndTheOwnersRestoreClearsIt(TestNamespace ns) { + @ParameterizedTest + @EnumSource( + value = ContextMemoryStatus.class, + names = {"DEPRECATED", "SUPERSEDED"}) + void superseding_storesTheSuccessorAndTheOwnersRestoreClearsIt( + ContextMemoryStatus retirementStage, TestNamespace ns) { ContextMemory keeper = admin().create(memory(ns, "keeper")); ContextMemory duplicate = admin().create(memory(ns, "duplicate").withOwners(List.of(SharedEntities.get().USER1_REF))); ContextMemory superseded = - admin().patch(idOf(duplicate), supersede(keeper, "Same fact as the keeper")); + admin() + .patch(idOf(duplicate), supersede(keeper, "Same fact as the keeper", retirementStage)); - assertEquals(EntityStatus.DEPRECATED, superseded.getEntityStatus()); + assertEquals(retirementStage, superseded.getEntityStatus()); assertEquals(keeper.getName(), superseded.getSupersededBy().getName(), "stored resolved"); assertEquals("Same fact as the keeper", superseded.getStatusReason()); assertTrue( changedFields(superseded) .containsAll(Set.of("entityStatus", "supersededBy", "statusReason"))); - ContextMemory restored = user1().patch(idOf(duplicate), status(EntityStatus.APPROVED)); + ContextMemory restored = user1().patch(idOf(duplicate), status(ContextMemoryStatus.APPROVED)); - assertEquals(EntityStatus.APPROVED, restored.getEntityStatus()); - assertNull(restored.getSupersededBy(), "leaving Deprecated clears supersededBy"); + assertEquals(ContextMemoryStatus.APPROVED, restored.getEntityStatus()); + assertNull(restored.getSupersededBy(), "leaving a superseded stage clears supersededBy"); assertNull(restored.getStatusReason(), "a status change without a reason drops the stale one"); ContextMemory previous = admin().getVersion(idOf(duplicate), superseded.getVersion()); assertEquals(keeper.getId(), previous.getSupersededBy().getId(), "history keeps the successor"); } - @Test - void superseding_withoutASuccessor_isRejected(TestNamespace ns) { + @ParameterizedTest + @EnumSource( + value = ContextMemoryStatus.class, + names = {"DEPRECATED", "SUPERSEDED"}) + void superseding_withoutASuccessor_isRejected( + ContextMemoryStatus retirementStage, TestNamespace ns) { ContextMemory memory = admin().create(memory(ns, "no-successor")); InvalidRequestException error = assertThrows( InvalidRequestException.class, - () -> admin().patch(idOf(memory), status(EntityStatus.DEPRECATED))); + () -> admin().patch(idOf(memory), status(retirementStage))); assertTrue(error.getMessage().contains("requires supersededBy")); } @@ -110,7 +139,7 @@ void aSuccessor_mustBeAnotherLiveContextMemory(TestNamespace ns) { assertThrows( InvalidRequestException.class, () -> admin().patch(idOf(memory), supersede(userId, Entity.USER, "not a memory"))); - assertEquals(EntityStatus.APPROVED, admin().get(idOf(memory)).getEntityStatus()); + assertEquals(ContextMemoryStatus.APPROVED, admin().get(idOf(memory)).getEntityStatus()); assertNull(admin().get(idOf(memory)).getSupersededBy()); } @@ -131,30 +160,38 @@ void aSuccessor_onANonDeprecatedMemory_isRejected(TestNamespace ns) { assertTrue(error.getMessage().contains("only allowed on a Deprecated memory")); } - @Test - void invalidating_keepsTheReasonAndTheOwnersRestoreDropsIt(TestNamespace ns) { + @ParameterizedTest + @EnumSource( + value = ContextMemoryStatus.class, + names = {"REJECTED", "INVALIDATED"}) + void invalidating_keepsTheReasonAndTheOwnersRestoreDropsIt( + ContextMemoryStatus retirementStage, TestNamespace ns) { ContextMemory memory = admin() .create(memory(ns, "invalidated").withOwners(List.of(SharedEntities.get().USER1_REF))); String invalidate = """ - [{"op":"replace","path":"/entityStatus","value":"Rejected"}, - {"op":"add","path":"/statusReason","value":"Anchor table sales.orders was deleted"}]"""; + [{"op":"replace","path":"/entityStatus","value":"%s"}, + {"op":"add","path":"/statusReason","value":"Anchor table sales.orders was deleted"}]""" + .formatted(retirementStage.value()); ContextMemory invalidated = admin().patch(idOf(memory), JsonUtils.readTree(invalidate)); - ContextMemory restored = user1().patch(idOf(memory), status(EntityStatus.APPROVED)); + ContextMemory restored = user1().patch(idOf(memory), status(ContextMemoryStatus.APPROVED)); + assertEquals(retirementStage, invalidated.getEntityStatus()); assertEquals("Anchor table sales.orders was deleted", invalidated.getStatusReason()); - assertEquals(EntityStatus.APPROVED, restored.getEntityStatus()); + assertEquals(ContextMemoryStatus.APPROVED, restored.getEntityStatus()); assertNull(restored.getStatusReason()); } @Test void transitionsOutsideTheTable_areRejected(TestNamespace ns) { ContextMemory keeper = admin().create(memory(ns, "table-keeper")); - ContextMemory draft = admin().create(memory(ns, "draft").withEntityStatus(EntityStatus.DRAFT)); + ContextMemory draft = + admin().create(memory(ns, "draft").withEntityStatus(ContextMemoryStatus.DRAFT)); ContextMemory invalidated = - admin().create(memory(ns, "born-invalidated").withEntityStatus(EntityStatus.REJECTED)); + admin() + .create(memory(ns, "born-invalidated").withEntityStatus(ContextMemoryStatus.REJECTED)); assertThrows( InvalidRequestException.class, @@ -164,26 +201,44 @@ void transitionsOutsideTheTable_areRejected(TestNamespace ns) { () -> admin().patch(idOf(invalidated), supersede(keeper, "invalidated"))); } - @Test - void creatingADeprecatedMemory_isRejected(TestNamespace ns) { + @ParameterizedTest + @EnumSource( + value = ContextMemoryStatus.class, + names = {"DEPRECATED", "SUPERSEDED"}) + void creatingASupersededMemoryWithoutASuccessor_isRejected( + ContextMemoryStatus retirementStage, TestNamespace ns) { assertThrows( InvalidRequestException.class, - () -> - admin() - .create(memory(ns, "born-superseded").withEntityStatus(EntityStatus.DEPRECATED))); + () -> admin().create(memory(ns, "born-superseded").withEntityStatus(retirementStage))); } @Test void creatingWithoutStatus_defaultsToUnprocessed(TestNamespace ns) { ContextMemory memory = admin().create(memory(ns, "default-unprocessed").withEntityStatus(null)); - assertEquals(EntityStatus.UNPROCESSED, memory.getEntityStatus()); + assertEquals(ContextMemoryStatus.UNPROCESSED, memory.getEntityStatus()); + } + + @ParameterizedTest + @EnumSource( + value = ContextMemoryStatus.class, + names = {"SUPERSEDED", "INVALIDATED"}) + void anUnprocessedMemoryCanBeRetired(ContextMemoryStatus stage, TestNamespace ns) { + ContextMemory pending = admin().create(memory(ns, "pending").withEntityStatus(null)); + ContextMemory keeper = admin().create(memory(ns, "pending-keeper")); + JsonNode patch = + stage == ContextMemoryStatus.SUPERSEDED ? supersede(keeper, "Duplicate") : status(stage); + + ContextMemory retired = admin().patch(idOf(pending), patch); + + assertEquals(stage, retired.getEntityStatus()); + assertEquals(stage, admin().get(idOf(pending)).getEntityStatus()); } @Test void approvingAndAmending_preservesApprovalUntilExplicitlyRequeued(TestNamespace ns) { ContextMemory pending = admin().create(memory(ns, "reviewed-memory").withEntityStatus(null)); - ContextMemory approved = admin().patch(idOf(pending), status(EntityStatus.APPROVED)); + ContextMemory approved = admin().patch(idOf(pending), status(ContextMemoryStatus.APPROVED)); ContextMemory amended = admin() .patch( @@ -192,16 +247,20 @@ void approvingAndAmending_preservesApprovalUntilExplicitlyRequeued(TestNamespace """ [{"op":"replace","path":"/answer","value":"The user-approved definition."}]""")); - assertEquals(EntityStatus.APPROVED, amended.getEntityStatus()); + assertEquals(ContextMemoryStatus.APPROVED, amended.getEntityStatus()); assertEquals("The user-approved definition.", amended.getAnswer()); - ContextMemory requeued = admin().patch(idOf(amended), status(EntityStatus.UNPROCESSED)); - assertEquals(EntityStatus.UNPROCESSED, requeued.getEntityStatus()); + ContextMemory requeued = admin().patch(idOf(amended), status(ContextMemoryStatus.UNPROCESSED)); + assertEquals(ContextMemoryStatus.UNPROCESSED, requeued.getEntityStatus()); assertEquals(amended.getAnswer(), requeued.getAnswer()); } - @Test - void statusSelectionCombinesWithSearchAndAuthorWithoutChangingOrdinarySearch(TestNamespace ns) { + @ParameterizedTest + @EnumSource( + value = ContextMemoryStatus.class, + names = {"REJECTED", "INVALIDATED"}) + void statusSelectionCombinesWithSearchAndAuthorWithoutChangingOrdinarySearch( + ContextMemoryStatus retirementStage, TestNamespace ns) { String query = "statusfilter" + UUID.randomUUID().toString().substring(0, 8); ContextMemory active = admin() @@ -215,7 +274,7 @@ void statusSelectionCombinesWithSearchAndAuthorWithoutChangingOrdinarySearch(Tes memory(ns, "status-invalidated") .withQuestion(query) .withOwners(List.of(SharedEntities.get().USER1_REF))); - admin().patch(idOf(invalidated), status(EntityStatus.REJECTED)); + admin().patch(idOf(invalidated), status(retirementStage)); admin().create(memory(ns, "other-author").withQuestion(query)); ListParams ordinary = new ListParams().setLimit(20).addFilter("q", query); @@ -224,7 +283,7 @@ void statusSelectionCombinesWithSearchAndAuthorWithoutChangingOrdinarySearch(Tes .setLimit(20) .addFilter("q", query) .addFilter("author", SharedEntities.get().USER1_REF.getId().toString()) - .addFilter("statuses", "Approved,Rejected"); + .addFilter("statuses", "Approved," + retirementStage.value()); Awaitility.await() .atMost(Duration.ofSeconds(120)) .ignoreExceptions() @@ -261,7 +320,8 @@ void disputes_areResolvedAndValidated(TestNamespace ns) { ADD_DISPUTE.formatted(other.getId(), "Fiscal Q1 starts in Feb"))); assertEquals(other.getName(), disputed.getDisputes().getFirst().getMemory().getName()); - assertEquals(EntityStatus.APPROVED, disputed.getEntityStatus(), "a dispute keeps both Active"); + assertEquals( + ContextMemoryStatus.APPROVED, disputed.getEntityStatus(), "a dispute keeps both Active"); assertTrue(changedFields(disputed).contains("disputes")); assertThrows( InvalidRequestException.class, @@ -279,12 +339,17 @@ void disputes_areResolvedAndValidated(TestNamespace ns) { JsonUtils.readTree(ADD_DISPUTE.formatted(untouched.getId(), "self")))); } - @Test - void putPreservesLifecycleWhenStatusIsOmitted(TestNamespace ns) { + @ParameterizedTest + @EnumSource( + value = ContextMemoryStatus.class, + names = {"DEPRECATED", "SUPERSEDED"}) + void putPreservesLifecycleWhenStatusIsOmitted( + ContextMemoryStatus retirementStage, TestNamespace ns) { ContextMemory keeper = admin().create(memory(ns, "put-keeper")); ContextMemory other = admin().create(memory(ns, "put-dispute")); ContextMemory original = admin().create(memory(ns, "put-lifecycle")); - ContextMemory superseded = admin().patch(idOf(original), supersede(keeper, "Duplicate fact")); + ContextMemory superseded = + admin().patch(idOf(original), supersede(keeper, "Duplicate fact", retirementStage)); admin() .patch( idOf(original), JsonUtils.readTree(ADD_DISPUTE.formatted(other.getId(), "Conflicts"))); @@ -296,12 +361,12 @@ void putPreservesLifecycleWhenStatusIsOmitted(TestNamespace ns) { .withEntityStatus(null) .withAnswer("Re-extracted answer")); - assertEquals(EntityStatus.DEPRECATED, updated.getEntityStatus()); + assertEquals(retirementStage, updated.getEntityStatus()); assertEquals(keeper.getId(), updated.getSupersededBy().getId()); assertEquals("Duplicate fact", updated.getStatusReason()); assertEquals(other.getId(), updated.getDisputes().getFirst().getMemory().getId()); assertEquals("Re-extracted answer", updated.getAnswer()); - assertEquals(EntityStatus.DEPRECATED, superseded.getEntityStatus()); + assertEquals(retirementStage, superseded.getEntityStatus()); } @Test @@ -333,7 +398,7 @@ void lifecycleReferencesMustBeReadableByTheEditor(TestNamespace ns) { assertTrue(supersedeError.getMessage().contains("readable, non-deleted")); assertTrue(disputeError.getMessage().contains("readable, non-deleted")); ContextMemory unchanged = admin().get(idOf(editable)); - assertEquals(EntityStatus.APPROVED, unchanged.getEntityStatus()); + assertEquals(ContextMemoryStatus.APPROVED, unchanged.getEntityStatus()); assertNull(unchanged.getSupersededBy()); assertTrue(listOrEmpty(unchanged.getDisputes()).isEmpty()); } @@ -342,12 +407,12 @@ void lifecycleReferencesMustBeReadableByTheEditor(TestNamespace ns) { @Test void inSessionConsolidation_doesNotReplayTransitionsBackwards(TestNamespace ns) { ContextMemory draft = - admin().create(memory(ns, "consolidated").withEntityStatus(EntityStatus.DRAFT)); + admin().create(memory(ns, "consolidated").withEntityStatus(ContextMemoryStatus.DRAFT)); - admin().patch(idOf(draft), status(EntityStatus.APPROVED)); - ContextMemory archived = admin().patch(idOf(draft), status(EntityStatus.REJECTED)); + admin().patch(idOf(draft), status(ContextMemoryStatus.APPROVED)); + ContextMemory archived = admin().patch(idOf(draft), status(ContextMemoryStatus.REJECTED)); - assertEquals(EntityStatus.REJECTED, archived.getEntityStatus()); + assertEquals(ContextMemoryStatus.REJECTED, archived.getEntityStatus()); } @Test @@ -361,7 +426,7 @@ void removingStatusIsRejectedWithoutChangingTheMemory(TestNamespace ns) { .patch( idOf(memory), JsonUtils.readTree("[{\"op\":\"remove\",\"path\":\"/entityStatus\"}]"))); - assertEquals(EntityStatus.APPROVED, admin().get(idOf(memory)).getEntityStatus()); + assertEquals(ContextMemoryStatus.APPROVED, admin().get(idOf(memory)).getEntityStatus()); } @Test @@ -382,8 +447,12 @@ void conversationExtraction_isGroundTruth_soContentEditsKeepTheSource(TestNamesp assertEquals(ContextMemoryType.LEARNING, edited.getMemoryType()); } - @Test - void aDeprecatedMemory_disappearsFromSearchButRemainsReadableById(TestNamespace ns) { + @ParameterizedTest + @EnumSource( + value = ContextMemoryStatus.class, + names = {"DEPRECATED", "SUPERSEDED"}) + void aSupersededMemory_disappearsFromSearchButRemainsReadableById( + ContextMemoryStatus retirementStage, TestNamespace ns) { ContextMemory keeper = admin().create(memory(ns, "search-keeper")); ContextMemory duplicate = admin().create(memory(ns, "search-duplicate")); @@ -394,7 +463,8 @@ void aDeprecatedMemory_disappearsFromSearchButRemainsReadableById(TestNamespace .untilAsserted( () -> assertTrue(searchMemoryById(duplicate.getId()).contains(idOf(duplicate)))); - admin().patch(idOf(duplicate), supersede(keeper, "Indexed with its successor")); + admin() + .patch(idOf(duplicate), supersede(keeper, "Indexed with its successor", retirementStage)); Awaitility.await("the superseded memory is removed from search results") .pollInterval(Duration.ofSeconds(2)) @@ -402,11 +472,15 @@ void aDeprecatedMemory_disappearsFromSearchButRemainsReadableById(TestNamespace .ignoreExceptions() .untilAsserted( () -> assertFalse(searchMemoryById(duplicate.getId()).contains(idOf(duplicate)))); - assertEquals(EntityStatus.DEPRECATED, admin().get(idOf(duplicate)).getEntityStatus()); + assertEquals(retirementStage, admin().get(idOf(duplicate)).getEntityStatus()); } - @Test - void aRejectedMemory_disappearsFromSearchButRemainsReadableById(TestNamespace ns) { + @ParameterizedTest + @EnumSource( + value = ContextMemoryStatus.class, + names = {"REJECTED", "INVALIDATED"}) + void anInvalidatedMemory_disappearsFromSearchButRemainsReadableById( + ContextMemoryStatus retirementStage, TestNamespace ns) { ContextMemory memory = admin().create(memory(ns, "search-invalidated")); Awaitility.await("the Active memory is searchable") @@ -415,14 +489,14 @@ void aRejectedMemory_disappearsFromSearchButRemainsReadableById(TestNamespace ns .ignoreExceptions() .untilAsserted(() -> assertTrue(searchMemoryById(memory.getId()).contains(idOf(memory)))); - admin().patch(idOf(memory), status(EntityStatus.REJECTED)); + admin().patch(idOf(memory), status(retirementStage)); Awaitility.await("the invalidated memory is removed from search results") .pollInterval(Duration.ofSeconds(2)) .atMost(Duration.ofSeconds(120)) .ignoreExceptions() .untilAsserted(() -> assertFalse(searchMemoryById(memory.getId()).contains(idOf(memory)))); - assertEquals(EntityStatus.REJECTED, admin().get(idOf(memory)).getEntityStatus()); + assertEquals(retirementStage, admin().get(idOf(memory)).getEntityStatus()); } private static String searchMemoryById(UUID id) { @@ -436,21 +510,30 @@ private static String searchMemoryById(UUID id) { private static CreateContextMemory memory(TestNamespace ns, String name) { return new CreateContextMemory() - .withName(ns.prefix(name)) - .withEntityStatus(EntityStatus.APPROVED) + .withName(ns.prefix(ns.shortPrefix(name))) + .withEntityStatus(ContextMemoryStatus.APPROVED) .withQuestion("Which table holds the canonical orders?") .withAnswer("sales.orders is the canonical orders table."); } private static JsonNode supersede(ContextMemory successor, String reason) { - return supersede(successor.getId(), Entity.CONTEXT_MEMORY, reason); + return supersede(successor, reason, ContextMemoryStatus.SUPERSEDED); + } + + private static JsonNode supersede( + ContextMemory successor, String reason, ContextMemoryStatus retirementStage) { + return JsonUtils.readTree( + SUPERSEDE.formatted( + retirementStage.value(), successor.getId(), Entity.CONTEXT_MEMORY, reason)); } private static JsonNode supersede(UUID successorId, String successorType, String reason) { - return JsonUtils.readTree(SUPERSEDE.formatted(successorId, successorType, reason)); + return JsonUtils.readTree( + SUPERSEDE.formatted( + ContextMemoryStatus.SUPERSEDED.value(), successorId, successorType, reason)); } - private static JsonNode status(EntityStatus status) { + private static JsonNode status(ContextMemoryStatus status) { return JsonUtils.readTree( "[{\"op\":\"replace\",\"path\":\"/entityStatus\",\"value\":\"" + status.value() + "\"}]"); } diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/EnricherBulkVsHistoryPathEquivalenceIT.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/EnricherBulkVsHistoryPathEquivalenceIT.java index 60ace385e6b5..9e6c0cbda9a4 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/EnricherBulkVsHistoryPathEquivalenceIT.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/EnricherBulkVsHistoryPathEquivalenceIT.java @@ -198,7 +198,7 @@ private Map buildContextData(String entityType, Long startTs, Lo } @SuppressWarnings("unchecked") - private T loadViaBulkPath(String entityType, T entity) { + private > T loadViaBulkPath(String entityType, T entity) { EntityRepository repo = (EntityRepository) Entity.getEntityRepository(entityType); EntityUtil.Fields allFields = repo.getFields("*"); T raw = repo.findByName(entity.getFullyQualifiedName(), Include.NON_DELETED, false); @@ -207,7 +207,7 @@ private T loadViaBulkPath(String entityType, T entit } @SuppressWarnings("unchecked") - private T loadViaVersionPath( + private > T loadViaVersionPath( String entityType, T entity, Class clazz) { EntityRepository repo = (EntityRepository) Entity.getEntityRepository(entityType); EntityRepository.EntityHistoryWithOffset history = @@ -217,7 +217,7 @@ private T loadViaVersionPath( return JsonUtils.readOrConvertValue(versions.getFirst(), clazz); } - private void assertBothPathsProduceIdenticalDiDocs( + private > void assertBothPathsProduceIdenticalDiDocs( String entityType, T entity, Class clazz) throws Exception { Long now = System.currentTimeMillis(); Long endTs = TimestampUtils.getEndOfDayTimestamp(now); diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/EntityLifecycleStagesIT.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/EntityLifecycleStagesIT.java new file mode 100644 index 000000000000..ca42c528dcd3 --- /dev/null +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/EntityLifecycleStagesIT.java @@ -0,0 +1,99 @@ +package org.openmetadata.it.tests; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Arrays; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; +import org.openmetadata.it.util.SdkClients; +import org.openmetadata.schema.api.governance.EntityLifecycleStages; +import org.openmetadata.schema.api.governance.EntityTypeLifecycle; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; +import org.openmetadata.schema.type.EntityStatus; +import org.openmetadata.sdk.network.HttpMethod; +import org.openmetadata.sdk.network.RequestOptions; +import org.openmetadata.service.Entity; + +@Execution(ExecutionMode.CONCURRENT) +class EntityLifecycleStagesIT { + @Test + void discoveryReturnsEachEntityTypesOwnVocabularyAndCompleteGraph() { + EntityLifecycleStages discovery = discover(null); + EntityTypeLifecycle memory = lifecycleOf(discovery, Entity.CONTEXT_MEMORY); + EntityTypeLifecycle table = lifecycleOf(discovery, Entity.TABLE); + assertEquals(codes(ContextMemoryStatus.values()), Set.copyOf(memory.getStages())); + assertEquals(codes(EntityStatus.values()), Set.copyOf(table.getStages())); + assertFalse(table.getStages().contains(ContextMemoryStatus.SUPERSEDED.value())); + assertTrue(discovery.getStages().contains(ContextMemoryStatus.INVALIDATED.value())); + for (EntityTypeLifecycle lifecycle : discovery.getEntityTypes()) { + assertEquals( + Set.copyOf(lifecycle.getStages()), + lifecycle.getTransitions().stream() + .map(move -> move.getFrom()) + .collect(Collectors.toSet())); + assertTrue( + lifecycle.getTransitions().stream() + .flatMap(move -> move.getTo().stream()) + .allMatch(lifecycle.getStages()::contains)); + } + } + + @Test + void discoveryScopesStatusFiltersToTheSelectedEntityType() { + EntityLifecycleStages table = discover(Entity.TABLE); + assertEquals( + List.of(Entity.TABLE), + table.getEntityTypes().stream().map(EntityTypeLifecycle::getEntityType).toList()); + assertEquals(codes(EntityStatus.values()), Set.copyOf(table.getStages())); + EntityLifecycleStages memory = discover(Entity.CONTEXT_MEMORY); + assertEquals( + List.of(Entity.CONTEXT_MEMORY), + memory.getEntityTypes().stream().map(EntityTypeLifecycle::getEntityType).toList()); + assertEquals(codes(ContextMemoryStatus.values()), Set.copyOf(memory.getStages())); + } + + @Test + void discoveryResolvesSearchAliasesAndMultipleSelectedTypes() { + EntityLifecycleStages assets = discover("dataAsset"); + assertFalse(assets.getEntityTypes().isEmpty()); + assertFalse(assets.getStages().contains(ContextMemoryStatus.SUPERSEDED.value())); + EntityLifecycleStages combined = discover(Entity.TABLE + "," + Entity.CONTEXT_MEMORY); + assertEquals( + Set.of(Entity.TABLE, Entity.CONTEXT_MEMORY), + combined.getEntityTypes().stream() + .map(EntityTypeLifecycle::getEntityType) + .collect(Collectors.toSet())); + assertTrue(combined.getStages().contains(ContextMemoryStatus.SUPERSEDED.value())); + assertTrue(combined.getStages().contains(EntityStatus.IN_REVIEW.value())); + } + + private static EntityLifecycleStages discover(String index) { + return SdkClients.adminClient() + .getHttpClient() + .execute( + HttpMethod.GET, + "/v1/metadata/types/lifecycleStages", + null, + EntityLifecycleStages.class, + index == null + ? RequestOptions.builder().build() + : RequestOptions.builder().queryParam("index", index).build()); + } + + private static EntityTypeLifecycle lifecycleOf(EntityLifecycleStages discovery, String type) { + return discovery.getEntityTypes().stream() + .filter(lifecycle -> lifecycle.getEntityType().equals(type)) + .findFirst() + .orElseThrow(); + } + + private static Set codes(Enum[] statuses) { + return Arrays.stream(statuses).map(Enum::toString).collect(Collectors.toSet()); + } +} diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/MetricResourceIT.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/MetricResourceIT.java index 56495faf76a5..8b1449aad849 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/MetricResourceIT.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/MetricResourceIT.java @@ -163,6 +163,24 @@ protected Metric getEntityByName(String fqn) { return SdkClients.adminClient().metrics().getByName(fqn); } + @Test + void list_statusFilterUsesTheMetricVocabulary(TestNamespace ns) { + Metric metric = createEntity(createMinimalRequest(ns)); + assertEquals(EntityStatus.APPROVED, metric.getEntityStatus()); + ListParams approved = new ListParams().addFilter("entityStatus", "Approved").setLimit(1000); + assertTrue( + SdkClients.adminClient().metrics().list(approved).getData().stream() + .anyMatch(candidate -> candidate.getId().equals(metric.getId()))); + for (String status : List.of("Superseded", "Invalidated")) { + assertTrue( + SdkClients.adminClient() + .metrics() + .list(new ListParams().addFilter("entityStatus", status)) + .getData() + .isEmpty()); + } + } + @Override protected Metric patchEntity(String id, Metric entity) { return SdkClients.adminClient().metrics().update(id, entity); diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/OntologyChangeSetIT.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/OntologyChangeSetIT.java index 636b298c3694..364d051af591 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/OntologyChangeSetIT.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/OntologyChangeSetIT.java @@ -46,10 +46,10 @@ import org.openmetadata.schema.api.data.OntologyChangeSetCommand; import org.openmetadata.schema.api.data.OntologyMemoryProposalStatus; import org.openmetadata.schema.entity.context.ContextMemory; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.data.Glossary; import org.openmetadata.schema.entity.data.GlossaryTerm; import org.openmetadata.schema.entity.data.OntologyChangeSet; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.OntologyAttribute; import org.openmetadata.schema.type.OntologyAttributeDataType; import org.openmetadata.schema.type.OntologyChangeOperation; @@ -132,7 +132,7 @@ void appliedTermAppearsOnItsSourceMemory(TestNamespace ns) { memories.create( new CreateContextMemory() .withName(ns.prefix("revenueMemory")) - .withEntityStatus(EntityStatus.APPROVED) + .withEntityStatus(ContextMemoryStatus.APPROVED) .withDescription("Subscription revenue definition") .withQuestion("What is monthly recurring revenue?") .withAnswer("Recurring subscription revenue in a month."))); @@ -224,7 +224,7 @@ void cannotApplyAProposalAfterItsSourceMemoryIsRejected(TestNamespace ns) { memories.create( new CreateContextMemory() .withName(ns.prefix("retiredSource")) - .withEntityStatus(EntityStatus.APPROVED) + .withEntityStatus(ContextMemoryStatus.APPROVED) .withQuestion("What is the canonical orders table?") .withAnswer("sales.orders is canonical."))); Glossary glossary = GlossaryTestFactory.createSimple(ns); @@ -258,7 +258,8 @@ void cannotApplyAProposalAfterItsSourceMemoryIsRejected(TestNamespace ns) { assertEquals( OntologyChangeSetState.DRAFT, client.ontologyChangeSets().get(changeSet.getId()).getState()); - assertEquals(EntityStatus.REJECTED, memories.get(memory.getId().toString()).getEntityStatus()); + assertEquals( + ContextMemoryStatus.REJECTED, memories.get(memory.getId().toString()).getEntityStatus()); } @Test @@ -531,7 +532,7 @@ private static Set listedIds(OpenMetadataClient client, String query) { private static CreateContextMemory memoryRequest(String name) { return new CreateContextMemory() .withName(name) - .withEntityStatus(EntityStatus.APPROVED) + .withEntityStatus(ContextMemoryStatus.APPROVED) .withDescription("Memory behind an ontology draft") .withQuestion("What is an active subscriber?") .withAnswer("A customer with a paid subscription this month."); diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/OpenLineageLineageResolutionIT.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/OpenLineageLineageResolutionIT.java index 54ad0d2b29d1..0251bd1fa617 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/OpenLineageLineageResolutionIT.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/OpenLineageLineageResolutionIT.java @@ -1087,7 +1087,7 @@ void createAllowedOnlyForDatabases_leavesNoDatabaseBehind(TestNamespace ns) thro * Entity audit fields follow the entity contract, not the edge one: the principal that posted the * event and the moment OpenMetadata created the entity, never the OpenLineage eventTime. */ - private static void assertAuditFieldsStamped(EntityInterface entity, long notBefore) { + private static void assertAuditFieldsStamped(EntityInterface entity, long notBefore) { String fqn = entity.getFullyQualifiedName(); assertEquals("admin", entity.getUpdatedBy(), "updatedBy of auto-created " + fqn); assertNotNull(entity.getUpdatedAt(), "updatedAt of auto-created " + fqn); diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ServiceLineageRefcountIT.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ServiceLineageRefcountIT.java index 960d77315367..c814ca85c8a2 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ServiceLineageRefcountIT.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ServiceLineageRefcountIT.java @@ -137,7 +137,8 @@ static Fixture create(TestNamespace ns) { } } - private static void putEdge(EntityInterface from, EntityInterface to, LineageDetails details) { + private static void putEdge( + EntityInterface from, EntityInterface to, LineageDetails details) { client() .lineage() .addLineage( @@ -149,14 +150,15 @@ private static void putEdge(EntityInterface from, EntityInterface to, LineageDet .withLineageDetails(details))); } - private static Integer assetEdges(EntityInterface from, EntityInterface to) throws Exception { + private static Integer assetEdges(EntityInterface from, EntityInterface to) + throws Exception { String response = client().getHttpClient().executeForString(HttpMethod.GET, edgePath(from, to), null); String edge = MAPPER.readTree(response).get("edge").toString(); return JsonUtils.readValue(edge, LineageDetails.class).getAssetEdges(); } - private static void assertEdgeAbsent(EntityInterface from, EntityInterface to) { + private static void assertEdgeAbsent(EntityInterface from, EntityInterface to) { OpenMetadataException notFound = assertThrows( OpenMetadataException.class, @@ -167,7 +169,7 @@ private static void assertEdgeAbsent(EntityInterface from, EntityInterface to) { assertEquals(404, notFound.getStatusCode()); } - private static String edgePath(EntityInterface from, EntityInterface to) { + private static String edgePath(EntityInterface from, EntityInterface to) { return "/v1/lineage/getLineageEdge/" + from.getId() + "/" + to.getId(); } diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TableResourceIT.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TableResourceIT.java index d59ce4aba470..c044d2c1a9d7 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TableResourceIT.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TableResourceIT.java @@ -358,7 +358,7 @@ protected String getImportExportContainerName(TestNamespace ns) { @Override protected String getCsvImportContainerName( - TestNamespace ns, org.openmetadata.schema.EntityInterface entity) { + TestNamespace ns, org.openmetadata.schema.EntityInterface entity) { return entity.getFullyQualifiedName(); } diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/mcp/McpContextMemoryVisibilityIT.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/mcp/McpContextMemoryVisibilityIT.java index c40930baaada..ae560be614cf 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/mcp/McpContextMemoryVisibilityIT.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/mcp/McpContextMemoryVisibilityIT.java @@ -9,8 +9,8 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.openmetadata.it.auth.JwtAuthProvider; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.data.Table; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.service.Entity; /** @@ -53,7 +53,7 @@ static void setup() throws Exception { "name", "mcp_vis_note_" + suffix, "entityStatus", - EntityStatus.APPROVED.value(), + ContextMemoryStatus.APPROVED.value(), "description", "MCP visibility IT", "question", @@ -102,7 +102,7 @@ private static String createSharedPill(String suffix, JsonNode sharedPrincipal) "name", "mcp_vis_pill_" + suffix, "entityStatus", - EntityStatus.APPROVED.value(), + ContextMemoryStatus.APPROVED.value(), "description", "MCP visibility IT pill", "question", @@ -131,7 +131,7 @@ private static String createAnchoredMemory( "answer", answer, "entityStatus", - EntityStatus.APPROVED.value(), + ContextMemoryStatus.APPROVED.value(), "sourceType", sourceType, "primaryEntity", diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/util/EntityValidation.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/util/EntityValidation.java index 7d14d71ff55d..2c7f98510f8f 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/util/EntityValidation.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/util/EntityValidation.java @@ -106,7 +106,7 @@ public static void fieldDeleted( * @return ChangeDescription with previousVersion set and empty field lists */ public static ChangeDescription getChangeDescription( - EntityInterface currentEntity, UpdateType updateType) { + EntityInterface currentEntity, UpdateType updateType) { if (updateType == UpdateType.REVERT) { // If reverting to a previous version, the change description comes from that version // In integration tests, we would need to fetch the previous version @@ -139,7 +139,7 @@ public static ChangeDescription getChangeDescription( * @param previousVersion Version before the update (null if CREATED) */ public static void validateVersion( - EntityInterface entity, UpdateType updateType, Double previousVersion) { + EntityInterface entity, UpdateType updateType, Double previousVersion) { switch (updateType) { case CREATED: assertEquals(0.1, entity.getVersion(), 0.001, "Created entity should have version 0.1"); @@ -199,7 +199,7 @@ public static void validateVersion( * @param expectedChange Expected ChangeDescription (can be null for CREATED) */ public static void validateChangeDescription( - EntityInterface updated, UpdateType updateType, ChangeDescription expectedChange) { + EntityInterface updated, UpdateType updateType, ChangeDescription expectedChange) { if (updateType == UpdateType.CREATED) { assertEquals(0.1, updated.getVersion(), 0.001); assertNull( diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/util/RdfTestUtils.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/util/RdfTestUtils.java index cb96512d2254..cb809eb4f09c 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/util/RdfTestUtils.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/util/RdfTestUtils.java @@ -105,7 +105,7 @@ private static String escapeSparqlString(String value) { * @param entity The entity to verify * @param rdfType The expected RDF type (e.g., "dcat:Dataset", "foaf:Agent") */ - public static void verifyEntityInRdf(EntityInterface entity, String rdfType) { + public static void verifyEntityInRdf(EntityInterface entity, String rdfType) { String escapedName = escapeSparqlString(entity.getName()); String escapedFqn = entity.getFullyQualifiedName().replace("\\", "\\\\").replace("\"", "\\\""); @@ -188,7 +188,7 @@ public static void verifyEntityNotInRdf(String entityFqn) { * * @param entity The updated entity */ - public static void verifyEntityUpdatedInRdf(EntityInterface entity) { + public static void verifyEntityUpdatedInRdf(EntityInterface entity) { String sparql = String.format( "PREFIX om: " @@ -425,7 +425,7 @@ private static String buildEntityUri(EntityReference ref) { /** * Log debug information when entity is not found in RDF. */ - private static void logDebugInfo(EntityInterface entity, String rdfType) { + private static void logDebugInfo(EntityInterface entity, String rdfType) { String debugQuery = String.format( "PREFIX om: " diff --git a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/util/TestNamespace.java b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/util/TestNamespace.java index e7e0102749bb..8fade3ac7c38 100644 --- a/openmetadata-integration-tests/src/test/java/org/openmetadata/it/util/TestNamespace.java +++ b/openmetadata-integration-tests/src/test/java/org/openmetadata/it/util/TestNamespace.java @@ -35,7 +35,7 @@ public record EntityRoot(String entityType, UUID id) {} * Register a root entity for post-test cleanup and return it unchanged, so factory call sites can * wrap their create fluently: {@code return ns.trackRoot(Entity.DATABASE_SERVICE, svc);}. */ - public T trackRoot(String entityType, T entity) { + public > T trackRoot(String entityType, T entity) { if (entity != null && entity.getId() != null) { roots.add(new EntityRoot(entityType, entity.getId())); } diff --git a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/ColumnLineageScope.java b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/ColumnLineageScope.java index 9cab5b4b53a2..8a2a971e34f0 100644 --- a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/ColumnLineageScope.java +++ b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/ColumnLineageScope.java @@ -45,7 +45,7 @@ static String requireColumnOf(String entityFqn, String columnFqn) { * all - a container's columns live under {@code dataModel}, which a plain read leaves out - cannot * disprove the column, so only the FQN-prefix check applies there. */ - static String requireColumnExists(EntityInterface entity, String columnFqn) { + static String requireColumnExists(EntityInterface entity, String columnFqn) { List fqns = JsonUtils.valueToTree(entity).findValuesAsText(FQN_FIELD); boolean readCarriesChildren = fqns.stream() diff --git a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/CommonUtils.java b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/CommonUtils.java index 9e14e83b11a1..5de0b981d439 100644 --- a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/CommonUtils.java +++ b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/CommonUtils.java @@ -37,13 +37,13 @@ public class CommonUtils { * is what stops a read path from holding an entity it is not allowed to answer with. The rule is * a no-op for entity types that have none, so callers need no per-type knowledge. */ - public static EntityInterface readEntityForCaller( + public static EntityInterface readEntityForCaller( String entityType, String fqn, String fields, Include include, SecurityContext securityContext) { - EntityInterface entity = + EntityInterface entity = Entity.getEntityByName( entityType, fqn, ContextMemoryVisibility.guardFields(entityType, fields), include); ContextMemoryVisibility.enforceVisibility(entity, securityContext); @@ -244,14 +244,14 @@ public static boolean authorizeOverwrite( Authorizer authorizer, CatalogSecurityContext securityContext, String entityType, - EntityInterface entity) { + EntityInterface entity) { String fqn = entity.getFullyQualifiedName(); // Include.ALL because createOrUpdate finds the original with ALL: a soft-deleted entity at // this name is still updated in place, so it still needs the EDIT_ALL check. boolean overwritesExisting = fqn != null && entityExistsByName(entityType, fqn, Include.ALL); if (overwritesExisting) { OperationContext editContext = new OperationContext(entityType, MetadataOperation.EDIT_ALL); - ResourceContext existing = + ResourceContext> existing = new ResourceContext<>(entityType, null, fqn, Include.ALL); authorizer.authorize(securityContext, editContext, existing); } diff --git a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/CompanyContextTool.java b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/CompanyContextTool.java index debb1a76e6de..ca557a32d9f2 100644 --- a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/CompanyContextTool.java +++ b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/CompanyContextTool.java @@ -16,8 +16,8 @@ import org.openmetadata.mcp.util.VectorPagingContract; import org.openmetadata.schema.entity.context.ContextMemory; import org.openmetadata.schema.entity.context.ContextMemorySourceType; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.MemoryVisibility; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.service.Entity; import org.openmetadata.service.exception.EntityNotFoundException; import org.openmetadata.service.limits.Limits; @@ -141,7 +141,7 @@ private static ContextMemory fetchPill(String fqn) { private static boolean isExposablePill( ContextMemory memory, CatalogSecurityContext securityContext) { return memory.getSourceType() == ContextMemorySourceType.FILE_EXTRACTION - && memory.getEntityStatus() == EntityStatus.APPROVED + && memory.getEntityStatus() == ContextMemoryStatus.APPROVED && !ContextMemoryVisibility.filterByVisibility(List.of(memory), securityContext).isEmpty(); } @@ -220,7 +220,7 @@ private static Map> searchFilters() { filters.put("entityType", List.of(Entity.CONTEXT_MEMORY)); filters.put("sourceType", List.of(ContextMemorySourceType.FILE_EXTRACTION.value())); filters.put("visibility", List.of(MemoryVisibility.SHARED.value())); - filters.put("entityStatus", List.of(EntityStatus.APPROVED.value())); + filters.put("entityStatus", List.of(ContextMemoryStatus.APPROVED.value())); return filters; } diff --git a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/CreateEntityTool.java b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/CreateEntityTool.java index 74b9715ccf53..37ecaacde57b 100644 --- a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/CreateEntityTool.java +++ b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/CreateEntityTool.java @@ -75,13 +75,13 @@ public Map execute( String entityType = CommonUtils.requireNonBlank(params.get("entityType"), "entityType"); EntityCreationSpec type = EntityCreationSpec.resolve(entityType); String userName = CommonUtils.principal(securityContext); - EntityInterface entity = buildEntity(type, params, userName); + EntityInterface entity = buildEntity(type, params, userName); Boolean requestedMutuallyExclusive = requestedMutuallyExclusive(entity); applyRepositoryDefaults(entity); authorizeCreate(authorizer, limits, securityContext, entityType, entity); RuleEngine.getInstance().evaluate(entity); - RestUtil.PutResponse response = persist(type, entity, userName); + RestUtil.PutResponse> response = persist(type, entity, userName); Map result = McpResponseUtils.compact(response.getEntity(), response.getChangeType()); @@ -95,19 +95,19 @@ private static void authorizeCreate( Limits limits, CatalogSecurityContext securityContext, String entityType, - EntityInterface entity) { + EntityInterface entity) { OperationContext operationContext = new OperationContext(entityType, MetadataOperation.CREATE); - CreateResourceContext resourceContext = + CreateResourceContext> resourceContext = new CreateResourceContext<>(entityType, entity); limits.enforceLimits(securityContext, resourceContext, operationContext); authorizer.authorize(securityContext, operationContext, resourceContext); } - private static RestUtil.PutResponse persist( - EntityCreationSpec type, EntityInterface entity, String userName) { - EntityRepository repository = type.typedRepository(); + private static RestUtil.PutResponse> persist( + EntityCreationSpec type, EntityInterface entity, String userName) { + EntityRepository> repository = type.typedRepository(); String impersonatedBy = ImpersonationContext.getImpersonatedBy(); - EntityInterface saved; + EntityInterface saved; try { saved = repository.create(null, entity, userName, impersonatedBy); } catch (RuntimeException failure) { @@ -127,7 +127,7 @@ private static RestUtil.PutResponse persist( + " FQN to modify it.", failure); } - RestUtil.PutResponse response = + RestUtil.PutResponse> response = new RestUtil.PutResponse<>(Response.Status.CREATED, saved, EventType.ENTITY_CREATED); McpChangeEventUtil.publishChangeEvent(response.getEntity(), response.getChangeType(), userName); return response; @@ -146,7 +146,7 @@ private static boolean isDuplicateKey(Throwable failure) { } /** Shared parameters plus attributes bound to the entity class owned by the repository. */ - private static EntityInterface buildEntity( + private static EntityInterface buildEntity( EntityCreationSpec type, Map params, String userName) { Set bindable = DescribeEntityTypeTool.bindableNames(type); // Before resolving anything: owners and reviewers cost a directory lookup, and a name that does @@ -156,13 +156,13 @@ private static EntityInterface buildEntity( rejectUnsupportedShared(type, bindable, params); Map attributes = attributes(type, bindable, params); requireFields(type, params, attributes); - EntityInterface entity = convert(type, attributes); + EntityInterface entity = convert(type, attributes); applySharedFields(entity, params, userName); applyMcpDefaults(entity); return entity; } - private static void applyRepositoryDefaults(EntityInterface entity) { + private static void applyRepositoryDefaults(EntityInterface entity) { if (entity instanceof Tag tag) { deriveTagClassification(tag); } @@ -208,7 +208,7 @@ private static void deriveTagClassification(Tag tag) { } private static void applySharedFields( - EntityInterface entity, Map params, String userName) { + EntityInterface entity, Map params, String userName) { entity.setId(UUID.randomUUID()); entity.setName(CommonUtils.requireNonBlank(params.get(NAME), NAME)); entity.setDescription( @@ -223,7 +223,7 @@ private static void applySharedFields( entity.setUpdatedAt(System.currentTimeMillis()); } - private static void applyMcpDefaults(EntityInterface entity) { + private static void applyMcpDefaults(EntityInterface entity) { if (entity instanceof Domain domain && domain.getDomainType() == null) { domain.setDomainType(CreateDomain.DomainType.AGGREGATE); } @@ -260,14 +260,17 @@ private static void validateMetric(Metric metric) { } } - private static Boolean requestedMutuallyExclusive(EntityInterface entity) { + private static Boolean requestedMutuallyExclusive(EntityInterface entity) { return entity instanceof Classification classification ? classification.getMutuallyExclusive() : null; } private static void addClassificationWarning( - Boolean requested, EntityInterface saved, EventType changeType, Map result) { + Boolean requested, + EntityInterface saved, + EventType changeType, + Map result) { if (requested != null && saved instanceof Classification classification && !EventType.ENTITY_CREATED.equals(changeType) @@ -440,8 +443,8 @@ private static Map asMap(Object raw) { return attributes; } - private static EntityInterface convert(EntityCreationSpec type, Map payload) { - EntityInterface entity; + private static EntityInterface convert(EntityCreationSpec type, Map payload) { + EntityInterface entity; try { entity = JsonUtils.convertValue(payload, type.entityClass()); } catch (RuntimeException e) { diff --git a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/EntityCreationSpec.java b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/EntityCreationSpec.java index 0ab3040260ee..f8ceebb021e1 100644 --- a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/EntityCreationSpec.java +++ b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/EntityCreationSpec.java @@ -16,8 +16,8 @@ /** The repository-owned information needed to create one entity type. */ record EntityCreationSpec( String entityType, - EntityRepository repository, - Class entityClass) { + EntityRepository> repository, + Class> entityClass) { /** Knowledge Page fields maintained by relationships or background processing. */ private static final Set PAGE_SYSTEM_FIELDS = @@ -53,7 +53,7 @@ record EntityCreationSpec( static EntityCreationSpec resolve(String entityType) { rejectDedicatedCreateFlow(entityType, DEDICATED_CREATE_FLOWS.get(entityType)); - EntityRepository repository; + EntityRepository> repository; try { repository = Entity.getEntityRepository(entityType); } catch (EntityNotFoundException e) { @@ -67,7 +67,7 @@ static EntityCreationSpec resolve(String entityType) { + ". Call describe_entity_type with the corrected type before creating it.", e); } - Class entityClass = repository.getEntityClass(); + Class> entityClass = repository.getEntityClass(); if (ServiceEntityInterface.class.isAssignableFrom(entityClass)) { rejectDedicatedCreateFlow( entityType, "service creation requires connection-secret masking and unmasking"); @@ -92,8 +92,8 @@ private static void rejectDedicatedCreateFlow(String entityType, String reason) } @SuppressWarnings("unchecked") - EntityRepository typedRepository() { - return (EntityRepository) repository; + EntityRepository> typedRepository() { + return (EntityRepository>) repository; } boolean hasMcpDefault(String field) { diff --git a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/GetEntityTool.java b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/GetEntityTool.java index fa5648b8df08..5669530017e0 100644 --- a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/GetEntityTool.java +++ b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/GetEntityTool.java @@ -263,7 +263,7 @@ private Map readOne( int columnLimit = McpParams.getInt(params, COLUMN_LIMIT_PARAM, NO_COLUMN_LIMIT); // Kept as the entity, not just its map: the content section needs the object, and reading it // a second time for that would be the same fetch twice in one request. - EntityInterface entity = + EntityInterface entity = CommonUtils.readEntityForCaller(entityType, fqn, "*", null, securityContext); Map entityData = JsonUtils.getMap(entity); @@ -288,7 +288,7 @@ private static Map readContentOnly( IncludeContext authorizationContext = new IncludeContext(authorizer, securityContext, entityType, fqn, null, options(params)); authorizeKnowledge(authorizationContext); - EntityInterface entity = + EntityInterface entity = CommonUtils.readEntityForCaller(entityType, fqn, "", Include.NON_DELETED, securityContext); IncludeContext contentContext = new IncludeContext( @@ -317,7 +317,7 @@ private record IncludeContext( CatalogSecurityContext securityContext, String entityType, String fqn, - EntityInterface entity, + EntityInterface entity, ContentOptions options) {} /** How the knowledge sections render, shared by {@code context} and {@code content}. */ diff --git a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/GetLineageTool.java b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/GetLineageTool.java index 2605c8f4a354..151f8dccc855 100644 --- a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/GetLineageTool.java +++ b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/GetLineageTool.java @@ -272,7 +272,7 @@ private static String requestedColumn( private static String requireExistingColumn( String entityType, String fqn, String column, CatalogSecurityContext securityContext) { ColumnLineageScope.requireColumnOf(fqn, column); - EntityInterface entity = + EntityInterface entity = CommonUtils.readEntityForCaller(entityType, fqn, "", Include.NON_DELETED, securityContext); return ColumnLineageScope.requireColumnExists(entity, column); } diff --git a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/McpChangeEventUtil.java b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/McpChangeEventUtil.java index f2eb367853fa..25affc12b267 100644 --- a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/McpChangeEventUtil.java +++ b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/McpChangeEventUtil.java @@ -12,7 +12,7 @@ public final class McpChangeEventUtil { private McpChangeEventUtil() {} - public static void publishChangeEvent( + public static > void publishChangeEvent( T entity, EventType changeType, String userName) { if (entity == null || changeType == null || changeType.equals(EventType.ENTITY_NO_CHANGE)) { return; diff --git a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/McpResponseUtils.java b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/McpResponseUtils.java index 185e2c0b1ffe..57c13e3958d6 100644 --- a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/McpResponseUtils.java +++ b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/McpResponseUtils.java @@ -33,7 +33,7 @@ public final class McpResponseUtils { private McpResponseUtils() {} - public static Map compact(EntityInterface entity, EventType changeType) { + public static Map compact(EntityInterface entity, EventType changeType) { Map doc = JsonUtils.getMap(entity); NOISE_FIELDS.forEach(doc::remove); if (Boolean.FALSE.equals(doc.get(DELETED_KEY))) { @@ -52,7 +52,7 @@ public static Map compact(EntityInterface entity, EventType chan * field names are kept: the full object carries old and new values for every field, far more than * "did my change land" needs. */ - public static Map compactPatch(EntityInterface entity, EventType changeType) { + public static Map compactPatch(EntityInterface entity, EventType changeType) { Map doc = compact(entity, changeType); doc.put(VERSION_KEY, entity.getVersion()); List changed = changedFields(entity.getChangeDescription()); diff --git a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/PatchEntityTool.java b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/PatchEntityTool.java index f91725d90bcc..d2f55b805947 100644 --- a/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/PatchEntityTool.java +++ b/openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/PatchEntityTool.java @@ -109,9 +109,10 @@ public Map execute( // policy model. CommonUtils.enforceEntityVisibility(entityType, fqn, securityContext); - EntityRepository repository = Entity.getEntityRepository(entityType); + EntityRepository> repository = + Entity.getEntityRepository(entityType); String userName = securityContext.getUserPrincipal().getName(); - RestUtil.PatchResponse response = + RestUtil.PatchResponse> response = repository.patch( null, fqn, diff --git a/openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/CompanyContextToolTest.java b/openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/CompanyContextToolTest.java index 03a444bf035c..d921ab0eab3f 100644 --- a/openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/CompanyContextToolTest.java +++ b/openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/CompanyContextToolTest.java @@ -34,12 +34,12 @@ import org.openmetadata.mcp.util.PageCursor; import org.openmetadata.schema.entity.context.ContextMemory; import org.openmetadata.schema.entity.context.ContextMemorySourceType; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.MemoryShareConfig; import org.openmetadata.schema.entity.context.MemorySharedPrincipal; import org.openmetadata.schema.entity.context.MemoryVisibility; import org.openmetadata.schema.entity.teams.User; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.service.Entity; import org.openmetadata.service.exception.EntityNotFoundException; import org.openmetadata.service.jdbi3.ContextMemoryRepository; @@ -293,7 +293,7 @@ void supersededFilePillIsNotReturnedByName() throws Exception { "pill-fqn", sharedWith( memory("pill-fqn", ContextMemorySourceType.FILE_EXTRACTION, MemoryVisibility.SHARED) - .withEntityStatus(EntityStatus.DEPRECATED), + .withEntityStatus(ContextMemoryStatus.DEPRECATED), "bob")); CatalogSecurityContext securityContext = securityContextFor("bob"); @@ -448,7 +448,7 @@ private ContextMemory memory( .withFullyQualifiedName(fqn) .withQuestion("Q") .withAnswer("A") - .withEntityStatus(EntityStatus.APPROVED) + .withEntityStatus(ContextMemoryStatus.APPROVED) .withSourceType(sourceType) .withShareConfig(new MemoryShareConfig().withVisibility(visibility)); } diff --git a/openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/CreateEntityToolTest.java b/openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/CreateEntityToolTest.java index df4d093baad7..e2398b3eb049 100644 --- a/openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/CreateEntityToolTest.java +++ b/openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/CreateEntityToolTest.java @@ -35,6 +35,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.InOrder; import org.mockito.MockedStatic; +import org.mockito.Mockito; import org.openmetadata.schema.EntityInterface; import org.openmetadata.schema.api.domains.CreateDomain; import org.openmetadata.schema.entity.automations.Workflow; @@ -96,7 +97,7 @@ void patchEntityContractOffersOnlyTheImplementedRawPatch() throws IOException { @Test void repositorySuppliesTheEntityClassAndWritePath() { - EntityRepository repository = repositoryFor(Glossary.class); + EntityRepository> repository = repositoryFor(Glossary.class); Glossary saved = new Glossary().withId(UUID.randomUUID()).withName("Finance"); saved.setFullyQualifiedName("Finance"); stubWrite(repository, saved); @@ -119,7 +120,7 @@ void repositorySuppliesTheEntityClassAndWritePath() { @Test void aTypeOutsideTheFormerEightIsResolvedFromEntity() { - EntityRepository repository = repositoryFor(Team.class); + EntityRepository> repository = repositoryFor(Team.class); Map described = withRepository( @@ -192,8 +193,8 @@ void unknownEntityTypeReturnsCorrectiveGuidance() { @Test void tagClassificationIsResolvedBeforeAuthorization() { - EntityRepository repository = repositoryFor(Tag.class); - EntityRepository classificationRepository = + EntityRepository> repository = repositoryFor(Tag.class); + EntityRepository> classificationRepository = repositoryFor(Classification.class); EntityReference parent = new EntityReference().withType(Entity.TAG).withId(UUID.randomUUID()); EntityReference resolvedParent = @@ -240,13 +241,13 @@ void tagClassificationIsResolvedBeforeAuthorization() { new CreateEntityTool().execute(authorizer, mock(Limits.class), securityContext(), input); } - ArgumentCaptor captor = ArgumentCaptor.forClass(EntityInterface.class); + ArgumentCaptor> captor = ArgumentCaptor.forClass(EntityInterface.class); verify(repository).create(isNull(), captor.capture(), anyString(), any()); Tag created = (Tag) captor.getValue(); assertEquals("PII", created.getClassification().getFullyQualifiedName()); assertEquals(resolvedClassification.getId(), created.getClassification().getId()); - ArgumentCaptor> contextCaptor = + ArgumentCaptor>> contextCaptor = ArgumentCaptor.forClass(CreateResourceContext.class); verify(authorizer).authorize(any(), any(), contextCaptor.capture()); Tag authorized = (Tag) contextCaptor.getValue().getEntity(); @@ -268,7 +269,7 @@ void tagClassificationIsResolvedBeforeAuthorization() { @Test void requiredFieldsComeFromTheRegisteredEntityClass() { - EntityRepository repository = repositoryFor(Glossary.class); + EntityRepository> repository = repositoryFor(Glossary.class); IllegalArgumentException failure = assertThrows( @@ -284,7 +285,7 @@ void requiredFieldsComeFromTheRegisteredEntityClass() { @Test void unknownAttributeIsRejectedBeforeTheRepositoryIsCalled() { - EntityRepository repository = repositoryFor(Glossary.class); + EntityRepository> repository = repositoryFor(Glossary.class); Map params = glossary(); params.put("attributes", Map.of("classification", "PII")); @@ -303,7 +304,7 @@ void unknownAttributeIsRejectedBeforeTheRepositoryIsCalled() { @Test void referenceAttributesUseTheEntitySchema() { - EntityRepository repository = repositoryFor(GlossaryTerm.class); + EntityRepository> repository = repositoryFor(GlossaryTerm.class); Map described = withRepository( Entity.GLOSSARY_TERM, @@ -318,7 +319,7 @@ void referenceAttributesUseTheEntitySchema() { @Test void anEmptyRequiredObjectIsRejectedBeforePersistence() { - EntityRepository repository = repositoryFor(Metric.class); + EntityRepository> repository = repositoryFor(Metric.class); Map params = params(); params.put("entityType", Entity.METRIC); params.put("attributes", Map.of("metricExpression", Map.of())); @@ -338,7 +339,7 @@ void anEmptyRequiredObjectIsRejectedBeforePersistence() { @Test void domainDefaultIsPreservedAfterRepositoryDrivenBinding() { - EntityRepository repository = repositoryFor(Domain.class); + EntityRepository> repository = repositoryFor(Domain.class); Domain saved = new Domain().withId(UUID.randomUUID()).withName("Marketing"); saved.setFullyQualifiedName("Marketing"); stubWrite(repository, saved); @@ -353,14 +354,14 @@ void domainDefaultIsPreservedAfterRepositoryDrivenBinding() { new CreateEntityTool() .execute(mock(Authorizer.class), mock(Limits.class), securityContext(), params)); - ArgumentCaptor captor = ArgumentCaptor.forClass(EntityInterface.class); + ArgumentCaptor> captor = ArgumentCaptor.forClass(EntityInterface.class); verify(repository).create(isNull(), captor.capture(), anyString(), any()); assertEquals(CreateDomain.DomainType.AGGREGATE, ((Domain) captor.getValue()).getDomainType()); } @Test void contextMemoryKeepsMcpProvenance() { - EntityRepository repository = repositoryFor(ContextMemory.class); + EntityRepository> repository = repositoryFor(ContextMemory.class); ContextMemory saved = new ContextMemory().withId(UUID.randomUUID()).withName("memory"); saved.setFullyQualifiedName("memory"); stubWrite(repository, saved); @@ -375,7 +376,7 @@ void contextMemoryKeepsMcpProvenance() { new CreateEntityTool() .execute(mock(Authorizer.class), mock(Limits.class), securityContext(), params)); - ArgumentCaptor captor = ArgumentCaptor.forClass(EntityInterface.class); + ArgumentCaptor> captor = ArgumentCaptor.forClass(EntityInterface.class); verify(repository).create(isNull(), captor.capture(), anyString(), any()); assertEquals( ContextMemorySourceType.REMEMBER_REQUEST, @@ -393,7 +394,7 @@ void contextMemoryKeepsMcpProvenance() { @Test void deniedCallerDoesNotReachPersistence() { - EntityRepository repository = repositoryFor(Glossary.class); + EntityRepository> repository = repositoryFor(Glossary.class); Authorizer authorizer = mock(Authorizer.class); RuleEngine ruleEngine = mock(RuleEngine.class); doThrow(new AuthorizationException("denied")).when(authorizer).authorize(any(), any(), any()); @@ -417,7 +418,7 @@ void deniedCallerDoesNotReachPersistence() { @Test void aDuplicateCreateFailureIsPropagatedWithoutUpdating() { - EntityRepository repository = repositoryFor(Glossary.class); + EntityRepository> repository = repositoryFor(Glossary.class); IllegalArgumentException duplicate = new IllegalArgumentException("already exists"); doThrow(duplicate).when(repository).create(isNull(), any(), anyString(), any()); @@ -443,7 +444,7 @@ void aDuplicateCreateFailureIsPropagatedWithoutUpdating() { @Test void aDatabaseDuplicateReturnsCreateConflictGuidanceWithoutLeakingDatabaseDetails() { - EntityRepository repository = repositoryFor(Glossary.class); + EntityRepository> repository = repositoryFor(Glossary.class); SQLException databaseFailure = new SQLException( "duplicate key value violates unique constraint glossary_name_unique", "23505"); @@ -475,7 +476,7 @@ void aDatabaseDuplicateReturnsCreateConflictGuidanceWithoutLeakingDatabaseDetail @Test void aMySqlDuplicateIsRecognizedByItsVendorCode() { - EntityRepository repository = repositoryFor(Glossary.class); + EntityRepository> repository = repositoryFor(Glossary.class); SQLException databaseFailure = new SQLException("Duplicate entry", "23000", 1062); doThrow(new RuntimeException(databaseFailure)) .when(repository) @@ -502,7 +503,7 @@ void aMySqlDuplicateIsRecognizedByItsVendorCode() { @Test void anArticleUsesTheCreatePageContract() { - EntityRepository repository = repositoryFor(Page.class); + EntityRepository> repository = repositoryFor(Page.class); Page saved = new Page().withId(UUID.randomUUID()).withName("runbook"); saved.setFullyQualifiedName("runbook"); stubWrite(repository, saved); @@ -516,7 +517,7 @@ void anArticleUsesTheCreatePageContract() { new CreateEntityTool() .execute(mock(Authorizer.class), mock(Limits.class), securityContext(), params)); - ArgumentCaptor captor = ArgumentCaptor.forClass(EntityInterface.class); + ArgumentCaptor> captor = ArgumentCaptor.forClass(EntityInterface.class); verify(repository).create(isNull(), captor.capture(), anyString(), any()); Page created = (Page) captor.getValue(); assertEquals(PageType.ARTICLE, created.getPageType()); @@ -538,7 +539,7 @@ void anArticleUsesTheCreatePageContract() { @Test void anEmptyQuickLinkIsRejectedBeforePersistence() { - EntityRepository repository = repositoryFor(Page.class); + EntityRepository> repository = repositoryFor(Page.class); Map params = params(Entity.PAGE); params.put("attributes", Map.of("pageType", PageType.QUICK_LINK.value(), "page", Map.of())); @@ -560,7 +561,7 @@ void aReferenceAttributeSaysItTakesAFullyQualifiedName() { // The eight tools this one replaced took references as plain FQN strings. The generic path // still resolves a name-only reference, but callers were told to send ids and given the // EntityReference schema blurb, so they spent a lookup they did not need. - EntityRepository repository = repositoryFor(Page.class); + EntityRepository> repository = repositoryFor(Page.class); Map described = withRepository( @@ -580,7 +581,7 @@ void aReferenceAttributeSaysItTakesAFullyQualifiedName() { @Test void anArticleBodySuppliedByTheCallerIsKept() { - EntityRepository repository = repositoryFor(Page.class); + EntityRepository> repository = repositoryFor(Page.class); Page saved = new Page().withId(UUID.randomUUID()).withName("runbook"); saved.setFullyQualifiedName("runbook"); stubWrite(repository, saved); @@ -602,7 +603,7 @@ void anArticleBodySuppliedByTheCallerIsKept() { new CreateEntityTool() .execute(mock(Authorizer.class), mock(Limits.class), securityContext(), params)); - ArgumentCaptor captor = ArgumentCaptor.forClass(EntityInterface.class); + ArgumentCaptor> captor = ArgumentCaptor.forClass(EntityInterface.class); verify(repository).create(isNull(), captor.capture(), anyString(), any()); Page created = (Page) captor.getValue(); assertNotNull( @@ -617,7 +618,7 @@ void aPageOffersOnlyTheFieldsItsCreateRequestCarries() { // written from relationships, votes and the extraction fields by background work. Offering // 'children' was the harmful one: storeRelationships reads child.getId() and a caller has no id // to give, so an accepted value would have written a relationship row with a null id. - EntityRepository repository = repositoryFor(Page.class); + EntityRepository> repository = repositoryFor(Page.class); Map described = withRepository( @@ -649,18 +650,19 @@ void aPageOffersOnlyTheFieldsItsCreateRequestCarries() { } @SuppressWarnings("unchecked") - private static EntityRepository repositoryFor( - Class entityClass) { - EntityRepository repository = mock(EntityRepository.class); - when(repository.getEntityClass()).thenReturn((Class) entityClass); + private static EntityRepository> repositoryFor( + Class> entityClass) { + EntityRepository> repository = mock(EntityRepository.class); + when(repository.getEntityClass()).thenReturn((Class>) entityClass); when(repository.getParentEntity(any(), anyString())) .thenThrow(new EntityNotFoundException("no parent")); return repository; } private static void stubWrite( - EntityRepository repository, EntityInterface saved) { - when(repository.create(isNull(), any(), anyString(), any())).thenReturn(saved); + EntityRepository> repository, EntityInterface saved) { + Mockito.>when(repository.create(isNull(), any(), anyString(), any())) + .thenReturn(saved); } private static T withRepository( @@ -712,8 +714,8 @@ private static Map params(String entityType) { } private static void assertDedicatedApiRequired( - String entityType, Class entityClass) { - EntityRepository repository = repositoryFor(entityClass); + String entityType, Class> entityClass) { + EntityRepository> repository = repositoryFor(entityClass); IllegalArgumentException createFailure = assertThrows( IllegalArgumentException.class, diff --git a/openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/McpChangeEventUtilTest.java b/openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/McpChangeEventUtilTest.java index a121d85097f8..bcb4400d34bd 100644 --- a/openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/McpChangeEventUtilTest.java +++ b/openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/McpChangeEventUtilTest.java @@ -37,7 +37,7 @@ void publishChangeEvent_nullEntity_doesNothing() { @Test void publishChangeEvent_nullChangeType_doesNothing() { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); assertThatNoException() .isThrownBy(() -> McpChangeEventUtil.publishChangeEvent(entity, null, "admin")); verify(entity, never()).getId(); @@ -45,7 +45,7 @@ void publishChangeEvent_nullChangeType_doesNothing() { @Test void publishChangeEvent_entityNoChange_doesNothing() { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); assertThatNoException() .isThrownBy( () -> @@ -55,7 +55,7 @@ void publishChangeEvent_entityNoChange_doesNothing() { @Test void publishChangeEvent_success_insertsChangeEventToDao() { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); when(entity.getId()).thenReturn(UUID.randomUUID()); ChangeEvent changeEvent = mock(ChangeEvent.class); @@ -95,7 +95,7 @@ void publishChangeEvent_success_insertsChangeEventToDao() { @Test void publishChangeEvent_daoException_isSwallowedAndDoesNotPropagate() { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); when(entity.getId()).thenReturn(UUID.randomUUID()); try (MockedStatic formatterMock = mockStatic(FormatterUtil.class)) { @@ -112,7 +112,7 @@ void publishChangeEvent_daoException_isSwallowedAndDoesNotPropagate() { @Test void publishChangeEvent_setsUserNameOnChangeEvent() { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); when(entity.getId()).thenReturn(UUID.randomUUID()); ChangeEvent changeEvent = mock(ChangeEvent.class); diff --git a/openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/PatchEntityToolTest.java b/openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/PatchEntityToolTest.java index 80a355ab2768..7787fd3ad5d3 100644 --- a/openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/PatchEntityToolTest.java +++ b/openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/PatchEntityToolTest.java @@ -80,7 +80,7 @@ void clearImpersonationContext() { @Test void execute_refusesToPatchAnotherUsersPrivateMemory() { @SuppressWarnings("unchecked") - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); ContextMemory memory = new ContextMemory() .withId(UUID.randomUUID()) @@ -128,9 +128,9 @@ void execute_passesImpersonationContextToRepository() { ImpersonationContext.setImpersonatedBy("McpApplicationBot"); @SuppressWarnings("unchecked") - EntityRepository mockRepo = mock(EntityRepository.class); - EntityInterface mockEntity = mock(EntityInterface.class); - RestUtil.PatchResponse patchResponse = + EntityRepository> mockRepo = mock(EntityRepository.class); + EntityInterface mockEntity = mock(EntityInterface.class); + RestUtil.PatchResponse> patchResponse = new RestUtil.PatchResponse<>(Response.Status.OK, mockEntity, EventType.ENTITY_UPDATED); when(mockRepo.patch(any(), any(String.class), any(), any(), any(), any(), any())) .thenReturn(patchResponse); @@ -169,9 +169,9 @@ void execute_passesImpersonationContextToRepository() { @Test void execute_withNoImpersonationContext_passesNullImpersonatedBy() { @SuppressWarnings("unchecked") - EntityRepository mockRepo = mock(EntityRepository.class); - EntityInterface mockEntity = mock(EntityInterface.class); - RestUtil.PatchResponse patchResponse = + EntityRepository> mockRepo = mock(EntityRepository.class); + EntityInterface mockEntity = mock(EntityInterface.class); + RestUtil.PatchResponse> patchResponse = new RestUtil.PatchResponse<>(Response.Status.OK, mockEntity, EventType.ENTITY_UPDATED); when(mockRepo.patch(any(), any(String.class), any(), any(), any(), any(), any())) .thenReturn(patchResponse); @@ -212,9 +212,9 @@ void execute_publishesChangeEventWithCallerUserName() { ImpersonationContext.setImpersonatedBy("McpApplicationBot"); @SuppressWarnings("unchecked") - EntityRepository mockRepo = mock(EntityRepository.class); - EntityInterface mockEntity = mock(EntityInterface.class); - RestUtil.PatchResponse patchResponse = + EntityRepository> mockRepo = mock(EntityRepository.class); + EntityInterface mockEntity = mock(EntityInterface.class); + RestUtil.PatchResponse> patchResponse = new RestUtil.PatchResponse<>(Response.Status.OK, mockEntity, EventType.ENTITY_UPDATED); when(mockRepo.patch(any(), any(String.class), any(), any(), any(), any(), any())) .thenReturn(patchResponse); @@ -243,8 +243,8 @@ void execute_publishesChangeEventWithCallerUserName() { @Test void execute_authorizesWithPatchResourceContext() { @SuppressWarnings("unchecked") - EntityRepository mockRepo = mock(EntityRepository.class); - EntityInterface mockEntity = mock(EntityInterface.class); + EntityRepository> mockRepo = mock(EntityRepository.class); + EntityInterface mockEntity = mock(EntityInterface.class); when(mockRepo.getPatchFields()).thenReturn(new Fields(Set.of())); when(mockRepo.patch(any(), any(String.class), any(), any(), any(), any(), any())) .thenReturn( @@ -342,8 +342,8 @@ void execute_validPatchReachesTheRepository(String goodPatch) { // the tool description itself advertises - because the paths do not exist in '{}'. Whether a // path exists is the repository's question to answer against the real entity. @SuppressWarnings("unchecked") - EntityRepository mockRepo = mock(EntityRepository.class); - EntityInterface mockEntity = mock(EntityInterface.class); + EntityRepository> mockRepo = mock(EntityRepository.class); + EntityInterface mockEntity = mock(EntityInterface.class); when(mockRepo.patch(any(), any(String.class), any(), any(), any(), any(), any())) .thenReturn( new RestUtil.PatchResponse<>(Response.Status.OK, mockEntity, EventType.ENTITY_UPDATED)); diff --git a/openmetadata-sdk/src/test/java/org/openmetadata/sdk/BaseSDKTest.java b/openmetadata-sdk/src/test/java/org/openmetadata/sdk/BaseSDKTest.java index abfc8199c77a..4283a696185f 100644 --- a/openmetadata-sdk/src/test/java/org/openmetadata/sdk/BaseSDKTest.java +++ b/openmetadata-sdk/src/test/java/org/openmetadata/sdk/BaseSDKTest.java @@ -78,7 +78,7 @@ protected String generateTestName(String prefix) { /** * Clean up an entity after test */ - protected void cleanupEntity(EntityInterface entity) { + protected void cleanupEntity(EntityInterface entity) { if (entity != null && entity.getId() != null) { try { // TODO: Implement generic delete once available in client @@ -90,7 +90,7 @@ protected void cleanupEntity(EntityInterface entity) { } } - private String getEntityEndpoint(EntityInterface entity) { + private String getEntityEndpoint(EntityInterface entity) { String entityType = entity.getEntityReference().getType(); return "/v1/" + entityType.toLowerCase() + "s"; } @@ -98,7 +98,7 @@ private String getEntityEndpoint(EntityInterface entity) { /** * Assert that two entities are equivalent (ignoring server-generated fields) */ - protected void assertEntitiesEqual(EntityInterface expected, EntityInterface actual) { + protected void assertEntitiesEqual(EntityInterface expected, EntityInterface actual) { // Compare key fields, ignoring server-generated ones like version, updatedAt, etc. assertEquals(expected.getName(), actual.getName()); assertEquals(expected.getDescription(), actual.getDescription()); diff --git a/openmetadata-service/src/main/java/org/openmetadata/csv/EntityCsv.java b/openmetadata-service/src/main/java/org/openmetadata/csv/EntityCsv.java index 23e43b59dffe..4596d1b6fa4c 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/csv/EntityCsv.java +++ b/openmetadata-service/src/main/java/org/openmetadata/csv/EntityCsv.java @@ -120,7 +120,7 @@ * record, and import an entity from a CSV record. */ @Slf4j -public abstract class EntityCsv { +public abstract class EntityCsv> { public static final String FIELD_ERROR_MSG = "#%s: Field %d error - %s"; public static final String IMPORT_STATUS_HEADER = "status"; public static final String IMPORT_STATUS_DETAILS = "details"; @@ -156,15 +156,15 @@ public abstract class EntityCsv { /** Holder for pending entity create/update operations */ protected static class PendingEntityOperation { - EntityInterface entity; - EntityInterface originalEntity; + EntityInterface entity; + EntityInterface originalEntity; CSVRecord csvRecord; String entityType; boolean isCreate; PendingEntityOperation( - EntityInterface entity, - EntityInterface originalEntity, + EntityInterface entity, + EntityInterface originalEntity, CSVRecord csvRecord, String entityType, boolean isCreate) { @@ -177,7 +177,7 @@ protected static class PendingEntityOperation { } // Queue for batching OpenSearch updates - processed after each batch of CSV records - protected final List pendingSearchIndexUpdates = new ArrayList<>(); + protected final List> pendingSearchIndexUpdates = new ArrayList<>(); // Queue for batching change event inserts - processed after each batch of CSV records protected final List pendingChangeEvents = new ArrayList<>(); // Track CSV results to write after batch operations complete @@ -459,7 +459,7 @@ public List getDomains( * direct relationships, so the inherited ones must be removed once the rules have run; the entity * keeps re-inheriting from its parent on read. */ - private void dropInheritedDomains(EntityInterface entity) { + private void dropInheritedDomains(EntityInterface entity) { List domains = entity.getDomains(); if (!nullOrEmpty(domains)) { List directDomains = new ArrayList<>(); @@ -508,8 +508,8 @@ protected final EntityReference getEntityReference( return getEntityReference(printer, csvRecord, fieldNumber, entityType, fqn); } - protected EntityInterface getEntityByName(String entityType, String fqn) { - EntityInterface entity = + protected EntityInterface getEntityByName(String entityType, String fqn) { + EntityInterface entity = entityType.equals(this.entityType) ? dryRunCreatedEntities.get(fqn) : null; if (entity == null) { EntityRepository entityRepository = Entity.getEntityRepository(entityType); @@ -519,7 +519,7 @@ protected EntityInterface getEntityByName(String entityType, String fqn) { } protected EntityReference getEntityReferenceByName(String entityType, String fqn) { - EntityInterface entity = + EntityInterface entity = entityType.equals(this.entityType) ? dryRunCreatedEntities.get(fqn) : null; return entity != null ? entity.getEntityReference() @@ -575,7 +575,7 @@ protected final List getEntityReferencesForGlossaryTerms( List fqnList = listOrEmpty(CsvUtil.fieldToStrings(fqns)); List refs = new ArrayList<>(); for (String fqn : fqnList) { - EntityInterface entity = getEntityByName(Entity.GLOSSARY_TERM, fqn); + EntityInterface entity = getEntityByName(Entity.GLOSSARY_TERM, fqn); if (entity == null) { deferredFailure(csvRecord, entityNotFound(fieldNumber, Entity.GLOSSARY_TERM, fqn)); return null; @@ -1194,15 +1194,15 @@ protected void createEntity(CSVPrinter resultsPrinter, CSVRecord csvRecord, T en @Transaction protected void createEntity( - CSVPrinter resultsPrinter, CSVRecord csvRecord, EntityInterface entity, String type) + CSVPrinter resultsPrinter, CSVRecord csvRecord, EntityInterface entity, String type) throws IOException { entity.setId(UUID.randomUUID()); entity.setUpdatedBy(importedBy); entity.setUpdatedAt(System.currentTimeMillis()); - EntityRepository repository = - (EntityRepository) Entity.getEntityRepository(type); + EntityRepository> repository = + (EntityRepository>) Entity.getEntityRepository(type); String violations = ValidatorUtil.validate(entity); if (violations != null) { @@ -1300,7 +1300,7 @@ private void createChangeEventAndUpdateInES(PutResponse response, String impo private void createChangeEventForUserAndUpdateInES(PutResponse response, String importedBy) { if (!response.getChangeType().equals(EventType.ENTITY_NO_CHANGE)) { T entity = response.getEntity(); - EntityInterface entityForEvent = entity; + EntityInterface entityForEvent = entity; if (entity instanceof User user) { entityForEvent = new User() @@ -1337,7 +1337,7 @@ private void createChangeEventForUserAndUpdateInES(PutResponse response, Stri } } - private void createChangeEventForBatchedEntity(EntityInterface entity, EventType eventType) { + private void createChangeEventForBatchedEntity(EntityInterface entity, EventType eventType) { ChangeEvent changeEvent = FormatterUtil.createChangeEventForEntity(importedBy, eventType, entity); Object eventEntity = changeEvent.getEntity(); @@ -1432,13 +1432,13 @@ protected void flushPendingEntityOperations() { for (Map.Entry> entry : byType.entrySet()) { String type = entry.getKey(); List ops = entry.getValue(); - EntityRepository repository = - (EntityRepository) Entity.getEntityRepository(type); + EntityRepository> repository = + (EntityRepository>) Entity.getEntityRepository(type); // Separate creates and updates - List toCreate = new ArrayList<>(); - List toUpdate = new ArrayList<>(); - List originals = new ArrayList<>(); + List> toCreate = new ArrayList<>(); + List> toUpdate = new ArrayList<>(); + List> originals = new ArrayList<>(); for (PendingEntityOperation op : ops) { if (op.isCreate) { @@ -1462,9 +1462,9 @@ protected void flushPendingEntityOperations() { try { // Batch create if (!toCreate.isEmpty()) { - List created = + List> created = repository.createManyEntitiesForImport(toCreate, importedBy); - for (EntityInterface entity : created) { + for (EntityInterface entity : created) { createChangeEventForBatchedEntity(entity, EventType.ENTITY_CREATED); pendingSearchIndexUpdates.add(entity); } @@ -1475,9 +1475,9 @@ protected void flushPendingEntityOperations() { // Batch update if (!toUpdate.isEmpty()) { - List updated = + List> updated = repository.updateManyEntitiesForImport(originals, toUpdate, importedBy, importedBy); - for (EntityInterface entity : updated) { + for (EntityInterface entity : updated) { createChangeEventForBatchedEntity(entity, EventType.ENTITY_UPDATED); pendingSearchIndexUpdates.add(entity); } @@ -1490,7 +1490,7 @@ protected void flushPendingEntityOperations() { // Fallback to individual operations for (PendingEntityOperation op : ops) { try { - PutResponse response = + PutResponse> response = repository.createOrUpdate(null, op.entity, importedBy); pendingSearchIndexUpdates.add(response.getEntity()); // Count successful individual operations as passed @@ -1518,7 +1518,7 @@ protected boolean hasPendingEntity(String entityType, String fqn) { } @SuppressWarnings("unchecked") - protected E getEntityWithDependencyResolution( + protected > E getEntityWithDependencyResolution( String entityType, String fqn, String fields, Include include) { try { return Entity.getEntityByName(entityType, fqn, fields, include); @@ -1940,7 +1940,7 @@ protected void createColumnEntity(CSVPrinter printer, CSVRecord csvRecord, Strin // Check if table is in the current batch's pending operations (not yet persisted) // If so, we add columns directly to the cached object - they'll be persisted with the table if (pendingEntityFQNs.contains(tableFQN)) { - EntityInterface cachedEntity = dryRunCreatedEntities.get(tableFQN); + EntityInterface cachedEntity = dryRunCreatedEntities.get(tableFQN); if (cachedEntity instanceof Table cachedTable) { updateColumnsFromCsvRecursive(cachedTable, csvRecord, printer); // Count this row as processed and passed - it will be persisted with the table diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/Entity.java b/openmetadata-service/src/main/java/org/openmetadata/service/Entity.java index 164515cf04d0..461b92718666 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/Entity.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/Entity.java @@ -94,7 +94,7 @@ public final class Entity { public static final String SEPARATOR = "."; // Fully qualified name separator // Canonical entity name to corresponding EntityRepository map - private static final Map> + private static final Map>> ENTITY_REPOSITORY_MAP = new HashMap<>(); private static final Map> ENTITY_TS_REPOSITORY_MAP = new HashMap<>(); @@ -454,7 +454,7 @@ public static void cleanup() { EntityIndexCapabilityRegistry.clear(); } - public static void registerEntity( + public static > void registerEntity( Class clazz, String entity, EntityRepository entityRepository) { ENTITY_REPOSITORY_MAP.put(entity, entityRepository); EntityInterface.CANONICAL_ENTITY_NAME_MAP.put(entity.toLowerCase(Locale.ROOT), entity); @@ -506,7 +506,8 @@ public static Set getEntityList() { * request terminates unexpectedly before repository-level finally blocks run. */ public static void clearRepositoryThreadLocals() { - for (EntityRepository repository : ENTITY_REPOSITORY_MAP.values()) { + for (EntityRepository> repository : + ENTITY_REPOSITORY_MAP.values()) { repository.clearParentCache(); } } @@ -533,7 +534,7 @@ public static EntityReference getEntityReferenceById( } // For regular entities, use the standard repository - EntityRepository repository = getEntityRepository(entityType); + EntityRepository> repository = getEntityRepository(entityType); include = repository.supportsSoftDelete ? include : Include.ALL; return repository.getReference(id, include); } @@ -554,7 +555,7 @@ public static List getEntityReferencesByIds( } // For regular entities, use the standard repository - EntityRepository repository = getEntityRepository(entityType); + EntityRepository> repository = getEntityRepository(entityType); include = repository.supportsSoftDelete ? include : Include.ALL; return repository.getReferences(ids, include); } @@ -564,12 +565,12 @@ public static EntityReference getEntityReferenceByName( if (fqn == null) { return null; } - EntityRepository repository = getEntityRepository(entityType); + EntityRepository> repository = getEntityRepository(entityType); return repository.getReferenceByName(fqn, include); } public static List getOwners(@NonNull EntityReference reference) { - EntityRepository repository = + EntityRepository> repository = getEntityRepository(reference.getType()); return repository.getOwners(reference); } @@ -762,9 +763,9 @@ public static List getEntityByNames( } /** Retrieve the corresponding entity repository for a given entity name. */ - public static EntityRepository getEntityRepository( + public static EntityRepository> getEntityRepository( @NonNull String entityType) { - EntityRepository entityRepository = + EntityRepository> entityRepository = ENTITY_REPOSITORY_MAP.get(entityType); if (entityRepository == null) { throw EntityNotFoundException.byMessage( @@ -786,7 +787,7 @@ public static boolean hasEntityRepository(@NonNull String entityType) { * never throw on an indexable but repository-less type. Returns {@code false} when the entity or * its reference is missing. */ - public static boolean isSearchIndexable(EntityInterface entity) { + public static boolean isSearchIndexable(EntityInterface entity) { return repositoryPolicyAllows(entity, EntityRepository::isSearchIndexable); } @@ -796,18 +797,18 @@ public static boolean isSearchIndexable(EntityInterface entity) { * its chunk documents cannot carry the filters its privacy model requires. Defaults and * null-handling match {@link #isSearchIndexable}. */ - public static boolean isVectorEmbeddable(EntityInterface entity) { + public static boolean isVectorEmbeddable(EntityInterface entity) { return repositoryPolicyAllows(entity, EntityRepository::isVectorEmbeddable); } private static boolean repositoryPolicyAllows( - EntityInterface entity, - BiPredicate, EntityInterface> policy) { + EntityInterface entity, + BiPredicate>, EntityInterface> policy) { boolean allowed = false; EntityReference entityReference = entity == null ? null : entity.getEntityReference(); String entityType = entityReference == null ? null : entityReference.getType(); if (entityType != null) { - EntityRepository repository = + EntityRepository> repository = ENTITY_REPOSITORY_MAP.get(entityType); allowed = repository == null || policy.test(repository, entity); } @@ -841,9 +842,9 @@ public static boolean isTimeSeriesEntity(@NonNull String entityTypeOrAlias) { } /** Retrieve the corresponding entity repository for a given entity name. */ - public static EntityRepository getServiceEntityRepository( + public static EntityRepository> getServiceEntityRepository( @NonNull ServiceType serviceType) { - EntityRepository entityRepository = + EntityRepository> entityRepository = ENTITY_REPOSITORY_MAP.get(SERVICE_TYPE_ENTITY_MAP.get(serviceType)); if (entityRepository == null) { throw EntityNotFoundException.byMessage( @@ -862,8 +863,9 @@ public static List getServiceEntityTypes() { return List.copyOf(SERVICE_TYPE_ENTITY_MAP.values()); } - public static List getEntityTags(String entityType, EntityInterface entity) { - EntityRepository entityRepository = getEntityRepository(entityType); + public static List getEntityTags(String entityType, EntityInterface entity) { + EntityRepository> entityRepository = + getEntityRepository(entityType); return listOrEmpty(entityRepository.getAllTags(entity)); } @@ -893,7 +895,7 @@ public static String getEntityTypeFromObject(Object object) { object.getClass().getSimpleName().toLowerCase(Locale.ROOT)); } - public static Class getEntityClassFromType(String entityType) { + public static Class> getEntityClassFromType(String entityType) { return EntityInterface.ENTITY_TYPE_TO_CLASS_MAP.get(entityType.toLowerCase(Locale.ROOT)); } @@ -1061,7 +1063,7 @@ public static List getAllServicesForLineage() { serviceTypes.remove(ServiceType.METADATA); for (ServiceType serviceType : serviceTypes) { - EntityRepository repository = + EntityRepository> repository = Entity.getServiceEntityRepository(serviceType); ListFilter filter = new ListFilter(Include.ALL); List services = diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/aicontext/AIContextBuilder.java b/openmetadata-service/src/main/java/org/openmetadata/service/aicontext/AIContextBuilder.java index ea9b7d961384..dada89e2483a 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/aicontext/AIContextBuilder.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/aicontext/AIContextBuilder.java @@ -32,6 +32,7 @@ import org.openmetadata.schema.EntityInterface; import org.openmetadata.schema.api.data.MetricExpression; import org.openmetadata.schema.entity.context.ContextMemory; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.data.GlossaryTerm; import org.openmetadata.schema.entity.data.Metric; import org.openmetadata.schema.entity.data.Page; @@ -187,12 +188,12 @@ public AIContextBuilder withSecurity(Authorizer authorizer, SecurityContext secu } public AIContext build() { - EntityInterface entity = + EntityInterface entity = Entity.getEntityByName(entityType, fqn, fieldsFor(entityType), Include.NON_DELETED); return buildForEntity(entity); } - AIContext buildForEntity(EntityInterface entity) { + AIContext buildForEntity(EntityInterface entity) { EntityLineage lineage = fetchLineage(entity); List upstreamEdges = edgeContexts(lineage, true); List downstreamEdges = edgeContexts(lineage, false); @@ -428,11 +429,11 @@ private void logDegradation(AIContext context) { * the right service without re-fetching the entity. Tables only for now — the type that backs the * analytics/SQL-generation path. */ - static EntityReference serviceRef(EntityInterface entity) { + static EntityReference serviceRef(EntityInterface entity) { return entity instanceof Table table ? table.getService() : null; } - static String serviceType(EntityInterface entity) { + static String serviceType(EntityInterface entity) { String serviceType = null; if (entity instanceof Table table && table.getServiceType() != null) { serviceType = table.getServiceType().value(); @@ -440,7 +441,7 @@ static String serviceType(EntityInterface entity) { return serviceType; } - private Observability resolveObservability(EntityInterface entity, DataQuality dataQuality) { + private Observability resolveObservability(EntityInterface entity, DataQuality dataQuality) { Observability observability = null; if (entity instanceof Table) { observability = new Observability().withDataQuality(dataQuality); @@ -458,7 +459,7 @@ private static boolean isEmpty(Observability observability) { && nullOrEmpty(observability.getColumnProfiles()); } - private void applyProfile(Observability observability, EntityInterface entity) { + private void applyProfile(Observability observability, EntityInterface entity) { if (authorizer != null && securityContext != null) { try { TableRepository repository = (TableRepository) Entity.getEntityRepository(Entity.TABLE); @@ -506,7 +507,7 @@ private static ColumnProfileSummary toColumnProfileSummary(Column column) { .withCardinalityDistribution(columnProfile.getCardinalityDistribution()); } - private DataQuality resolveDataQuality(EntityInterface entity) { + private DataQuality resolveDataQuality(EntityInterface entity) { DataQuality dataQuality = null; if (entity instanceof Table table) { EntityReference testSuiteRef = table.getTestSuite(); @@ -638,7 +639,7 @@ private static String toStringOrNull(Object value) { return value == null ? null : String.valueOf(value); } - private EntityLineage fetchLineage(EntityInterface entity) { + private EntityLineage fetchLineage(EntityInterface entity) { EntityLineage lineage = null; try { lineage = Entity.getLineageRepository().get(entityType, entity.getId().toString(), 1, 1); @@ -719,7 +720,7 @@ private static boolean supportsTags(String entityType) { return supported; } - private List resolveGlossaryTerms(EntityInterface entity) { + private List resolveGlossaryTerms(EntityInterface entity) { List items = new ArrayList<>(); for (String termFqn : capped(collectGlossaryFqns(entity), MAX_KNOWLEDGE_ITEMS)) { KnowledgeItem item = toGlossaryKnowledgeItem(termFqn); @@ -730,7 +731,7 @@ private List resolveGlossaryTerms(EntityInterface entity) { return items; } - static Set collectGlossaryFqns(EntityInterface entity) { + static Set collectGlossaryFqns(EntityInterface entity) { Set fqns = new LinkedHashSet<>(); addGlossaryFqns(entity.getTags(), fqns); if (entity instanceof Table table) { @@ -739,7 +740,7 @@ static Set collectGlossaryFqns(EntityInterface entity) { return fqns; } - static List extractClassificationTags(EntityInterface entity) { + static List extractClassificationTags(EntityInterface entity) { List tags = new ArrayList<>(); for (TagLabel tag : listOrEmpty(entity.getTags())) { if (tag.getSource() != TagLabel.TagSource.GLOSSARY) { @@ -849,7 +850,7 @@ private static boolean isApproved(GlossaryTerm term) { return status == null || status == EntityStatus.APPROVED; } - private List resolveArticles(EntityInterface entity) { + private List resolveArticles(EntityInterface entity) { List items = new ArrayList<>(); addItems( items, @@ -903,7 +904,7 @@ private void addItems( } } - private List findAttachedPills(EntityInterface entity) { + private List findAttachedPills(EntityInterface entity) { // Edge direction: primaryEntity --APPLIED_TO--> contextMemory (see ContextMemoryRepository). // The asset is the FROM side, so the pills are resolved as the TO side via findTo. List pills = new ArrayList<>(); @@ -936,7 +937,7 @@ private KnowledgeItem toPillKnowledgeItem(ContextMemory pill) { * may reach agents as current context (issue #32260). */ static boolean isActivePill(ContextMemory pill) { - return pill.getEntityStatus() == EntityStatus.APPROVED; + return pill.getEntityStatus() == ContextMemoryStatus.APPROVED; } private static String pillContent(ContextMemory pill) { @@ -949,7 +950,7 @@ private static String pillContent(ContextMemory pill) { return unescapeRichText(content); } - private List resolveMetrics(EntityInterface entity) { + private List resolveMetrics(EntityInterface entity) { List items = new ArrayList<>(); addItems( items, @@ -958,7 +959,7 @@ private List resolveMetrics(EntityInterface entity) { return items; } - private List findAttachedMetrics(EntityInterface entity) { + private List findAttachedMetrics(EntityInterface entity) { List metrics = new ArrayList<>(); try { metrics = @@ -995,7 +996,7 @@ private KnowledgeItem toMetricKnowledgeItem(EntityReference ref) { * progressive-disclosure path. Keeps the per-type extraction (metric expression, pill answer) * in one place so it matches what the bundle excerpts. */ - public static String fullContentOf(EntityInterface entity) { + public static String fullContentOf(EntityInterface entity) { String content; if (entity instanceof Metric metric) { content = metricContent(metric); @@ -1031,7 +1032,7 @@ static String metricContent(Metric metric) { return content.toString(); } - private List findAttachedPages(EntityInterface entity) { + private List findAttachedPages(EntityInterface entity) { List pages = new ArrayList<>(); try { pages = @@ -1064,7 +1065,7 @@ private KnowledgeItem toArticleKnowledgeItem(EntityReference ref) { return item; } - private AssetContext buildAssetContext(EntityInterface entity) { + private AssetContext buildAssetContext(EntityInterface entity) { AssetContext context = new AssetContext(); if (entity instanceof Table table) { context.withTable(buildTableContext(table).withSampleData(resolveSampleData(table))); @@ -1135,7 +1136,7 @@ private static GenericAssetContext buildMetricContext(Metric metric) { * {@code aiContextForeignKeyTargets} keyword list of the columns this table's foreign keys * reference. Only tables carry structural context today; other entity types are a no-op. */ - public static void applySearchFields(Map doc, EntityInterface entity) { + public static void applySearchFields(Map doc, EntityInterface entity) { if (entity instanceof Table table) { TableContext context = buildTableContext(table); doc.put("aiContext", Map.of("table", JsonUtils.getMap(context))); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/aicontext/AttachedKnowledgeBatch.java b/openmetadata-service/src/main/java/org/openmetadata/service/aicontext/AttachedKnowledgeBatch.java index 19c33557bca7..a19eafc4cab2 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/aicontext/AttachedKnowledgeBatch.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/aicontext/AttachedKnowledgeBatch.java @@ -62,10 +62,10 @@ private record Lookups( /** Resolves attached knowledge for each asset. Unknown or unloadable assets are skipped. */ public static List resolve(List assets) { - Map loaded = loadAssets(assets); + Map> loaded = loadAssets(assets); Lookups lookups = lookupKnowledge(loaded); List result = new ArrayList<>(); - for (Map.Entry entry : loaded.entrySet()) { + for (Map.Entry> entry : loaded.entrySet()) { result.add( new AssetKnowledge( entry.getKey().fullyQualifiedName(), @@ -77,8 +77,8 @@ public static List resolve(List assets) { // Keyed by the full AssetKey (type + FQN): FQNs are only unique per entity type — a chart and // a dashboard under the same service can share an FQN, and a name-only key would drop one. - private static Map loadAssets(List assets) { - Map loaded = new LinkedHashMap<>(); + private static Map> loadAssets(List assets) { + Map> loaded = new LinkedHashMap<>(); for (AssetKey key : assets.stream().limit(MAX_ASSETS).toList()) { if (!nullOrEmpty(key.fullyQualifiedName()) && !nullOrEmpty(key.entityType())) { loadAsset(key, loaded); @@ -87,7 +87,7 @@ private static Map loadAssets(List assets) return loaded; } - private static void loadAsset(AssetKey key, Map into) { + private static void loadAsset(AssetKey key, Map> into) { try { String fields = Entity.TABLE.equals(key.entityType()) ? TABLE_FIELDS : DEFAULT_FIELDS; into.putIfAbsent( @@ -99,7 +99,7 @@ private static void loadAsset(AssetKey key, Map into) } } - private static Lookups lookupKnowledge(Map loaded) { + private static Lookups lookupKnowledge(Map> loaded) { List assetIds = loaded.values().stream().map(entity -> entity.getId().toString()).toList(); Map> pageIdsByAsset = Map.of(); @@ -131,9 +131,9 @@ static List flattenIds(Map> idsByAsset) { /** Null values are cached too, so a missing/unapproved term is looked up once per batch. */ private static Map loadGlossaryTerms( - Map loaded) { + Map> loaded) { Map terms = new LinkedHashMap<>(); - for (EntityInterface entity : loaded.values()) { + for (EntityInterface entity : loaded.values()) { for (String fqn : AIContextBuilder.collectGlossaryFqns(entity)) { if (!terms.containsKey(fqn)) { terms.put(fqn, PersonaContextBuilder.loadGlossaryTerm(fqn)); @@ -143,7 +143,7 @@ private static Map loadGlossaryTerms( return terms; } - private static List itemsFor(EntityInterface asset, Lookups lookups) { + private static List itemsFor(EntityInterface asset, Lookups lookups) { List items = new ArrayList<>(); for (String fqn : AIContextBuilder.collectGlossaryFqns(asset)) { addItem(items, lookups.glossaryTerms().get(fqn)); @@ -164,7 +164,7 @@ private static void addItem(List items, KnowledgeItem item) { } } - private static KnowledgeItem knowledgeItemOf(String entityType, EntityInterface entity) { + private static KnowledgeItem knowledgeItemOf(String entityType, EntityInterface entity) { return entity == null ? null : PersonaContextBuilder.fullKnowledgeItem(entityType, entity); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/aicontext/PersonaContextBuilder.java b/openmetadata-service/src/main/java/org/openmetadata/service/aicontext/PersonaContextBuilder.java index d245b0d8760b..a5ff29e4d0b8 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/aicontext/PersonaContextBuilder.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/aicontext/PersonaContextBuilder.java @@ -557,7 +557,7 @@ private SelectedEntity buildKnowledgeSelection(ContextRule rule, Map entity = loadKnowledgeEntity(entityType, fqn); KnowledgeItem item = fullKnowledgeItem(entityType, entity); if (item == null) { return null; @@ -578,8 +578,8 @@ private SelectedEntity buildKnowledgeSelection(ContextRule rule, Map loadKnowledgeEntity(String entityType, String fqn) { + EntityInterface entity = Entity.getEntityByName(entityType, fqn, knowledgeFields(entityType), Include.NON_DELETED); if (entity instanceof Metric metric) { MetricRepository repository = (MetricRepository) Entity.getEntityRepository(Entity.METRIC); @@ -801,7 +801,7 @@ static List flatten(Collection> values) { return values.stream().flatMap(Collection::stream).distinct().toList(); } - static Map entitiesById( + static > Map entitiesById( String entityType, List ids, Class entityClass) { Map entitiesById = new HashMap<>(); if (ids.isEmpty()) { @@ -829,7 +829,7 @@ static KnowledgeItem loadGlossaryTerm(String fqn) { } } - static KnowledgeItem fullKnowledgeItem(String entityType, EntityInterface entity) { + static KnowledgeItem fullKnowledgeItem(String entityType, EntityInterface entity) { if (entity instanceof GlossaryTerm term && term.getEntityStatus() != EntityStatus.APPROVED) { return null; } @@ -1012,7 +1012,7 @@ record SelectedEntity( Map document, AIContext context, KnowledgeItem knowledgeItem, - EntityInterface knowledgeEntity) {} + EntityInterface knowledgeEntity) {} record RuleMaterialization(ContextRule rule, int matched, List entities) {} diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/aicontext/PersonaContextMarkdown.java b/openmetadata-service/src/main/java/org/openmetadata/service/aicontext/PersonaContextMarkdown.java index fc283fcd447d..e6a1948cf68a 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/aicontext/PersonaContextMarkdown.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/aicontext/PersonaContextMarkdown.java @@ -173,7 +173,7 @@ private static String renderKnowledgeEntity( if (!nullOrEmpty(item.getFullyQualifiedName())) { markdown.append('`').append(item.getFullyQualifiedName()).append("`\n"); } - EntityInterface entity = selected.knowledgeEntity(); + EntityInterface entity = selected.knowledgeEntity(); if (entity == null) { String content = PromptText.forPrompt(item.getContent()); if (!nullOrEmpty(content)) { @@ -187,7 +187,7 @@ private static String renderKnowledgeEntity( private static void appendKnowledgeSections( StringBuilder markdown, - EntityInterface entity, + EntityInterface entity, Set sections, boolean fullyRendered) { if (entity instanceof Page page) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/cache/CacheWarmupApp.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/cache/CacheWarmupApp.java index e12e030e4719..c36bdb00d541 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/cache/CacheWarmupApp.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/cache/CacheWarmupApp.java @@ -411,7 +411,7 @@ private void warmupEntityType(String entityType, int batchSize, Duration ttl) { } EntityRepository repository; EntityDAO dao; - Class entityClass; + Class> entityClass; try { repository = Entity.getEntityRepository(entityType); dao = repository.getDao(); @@ -482,7 +482,7 @@ private void warmupEntityType(String entityType, int batchSize, Duration ttl) { Map> hsetBatch = new HashMap<>(page.size() * 2); Map setBatch = new HashMap<>(page.size()); - List parsedEntities = new ArrayList<>(page.size()); + List> parsedEntities = new ArrayList<>(page.size()); // Per-page deltas — updateEntityStats adds to the running totals, so passing cumulative // counts would double-count entries from earlier pages. int pageSuccess = 0; @@ -490,7 +490,7 @@ private void warmupEntityType(String entityType, int batchSize, Duration ttl) { for (String json : page) { if (json == null || json.isEmpty()) continue; try { - EntityInterface entity = JsonUtils.readValue(json, entityClass); + EntityInterface entity = JsonUtils.readValue(json, entityClass); if (entity.getId() == null || entity.getFullyQualifiedName() == null) { pageFailed++; continue; diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/changeEvent/feed/ActivityStreamPublisher.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/changeEvent/feed/ActivityStreamPublisher.java index 2fe13b962bb5..18cd2676da55 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/changeEvent/feed/ActivityStreamPublisher.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/changeEvent/feed/ActivityStreamPublisher.java @@ -97,7 +97,7 @@ public void sendMessage(ChangeEvent changeEvent, Set recipients) } // Get the entity to extract domains - EntityInterface entity = getEntityFromChangeEvent(changeEvent); + EntityInterface entity = getEntityFromChangeEvent(changeEvent); if (entity == null) { LOG.debug( "Could not get entity for change event: {} {}", @@ -133,15 +133,15 @@ public void sendMessage(ChangeEvent changeEvent, Set recipients) } } - private EntityInterface getEntityFromChangeEvent(ChangeEvent changeEvent) { + private EntityInterface getEntityFromChangeEvent(ChangeEvent changeEvent) { try { Object entityObj = changeEvent.getEntity(); - if (entityObj instanceof EntityInterface entityInterface) { + if (entityObj instanceof EntityInterface entityInterface) { return entityInterface; } if (entityObj != null) { - Class entityClass = + Class> entityClass = Entity.getEntityClassFromType(changeEvent.getEntityType()); if (entityClass != null) { return entityObj instanceof String entityJson diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/dataContracts/DataContractValidationApp.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/dataContracts/DataContractValidationApp.java index 3600047a4a29..4c1fab1d1c72 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/dataContracts/DataContractValidationApp.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/dataContracts/DataContractValidationApp.java @@ -195,7 +195,7 @@ private int[] processDataProductContracts(DataContractRepository contractReposit } try { // Get the asset entity - EntityInterface asset = + EntityInterface asset = Entity.getEntity( assetRef.getType(), assetRef.getId(), "*", Include.NON_DELETED); @@ -254,7 +254,7 @@ private int[] processDataProductContracts(DataContractRepository contractReposit private static DataContractResult validateWithInheritance( DataContractRepository repository, DataContract dataContract) { EntityReference entityRef = dataContract.getEntity(); - EntityInterface entity = + EntityInterface entity = Entity.getEntity(entityRef.getType(), entityRef.getId(), "*", Include.NON_DELETED); return repository .validateEntityContract(entity, SYSTEM_USER) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/costAnalysis/CostAnalysisWorkflow.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/costAnalysis/CostAnalysisWorkflow.java index 3187ab9a4a6d..1b7887b7b91c 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/costAnalysis/CostAnalysisWorkflow.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/costAnalysis/CostAnalysisWorkflow.java @@ -109,7 +109,7 @@ private void initialize() throws SearchIndexException { String keysetCursor = null; while (!stopped) { - ResultList rawResult = + ResultList> rawResult = databaseServices.readNextKeyset(keysetCursor); keysetCursor = rawResult.getPaging().getAfter(); ResultList resultList = filterDatabaseServices(rawResult); @@ -186,7 +186,7 @@ public void process() throws SearchIndexException { String tableKeysetCursor = null; while (!stopped) { try { - ResultList resultList = + ResultList> resultList = source.readNextKeyset(tableKeysetCursor); tableKeysetCursor = resultList.getPaging().getAfter(); List costAnalysisTableData = @@ -359,7 +359,7 @@ private Optional processAggregatedCostAnalysisReportData( } private ResultList filterDatabaseServices( - ResultList resultList) { + ResultList> resultList) { return new ResultList<>( resultList.getData().stream() .map(object -> (DatabaseService) object) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/costAnalysis/processors/DatabaseServiceTablesProcessor.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/costAnalysis/processors/DatabaseServiceTablesProcessor.java index e061416735c9..8a4675dfdbd5 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/costAnalysis/processors/DatabaseServiceTablesProcessor.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/costAnalysis/processors/DatabaseServiceTablesProcessor.java @@ -28,7 +28,8 @@ @Slf4j public class DatabaseServiceTablesProcessor implements Processor< - List, ResultList> { + List, + ResultList>> { private final StepStats stats = new StepStats(); public DatabaseServiceTablesProcessor(int total) { @@ -37,11 +38,11 @@ public DatabaseServiceTablesProcessor(int total) { @Override public List process( - ResultList input, Map contextData) + ResultList> input, Map contextData) throws SearchIndexException { List costAnalysisTableDataList = new ArrayList<>(); try { - for (EntityInterface entity : input.getData()) { + for (EntityInterface entity : input.getData()) { Table table = (Table) entity; Optional oTableLifeCycle = Optional.empty(); Optional oSize = Optional.empty(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataAssetsWorkflow.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataAssetsWorkflow.java index 5ca7d9182f4d..64a2d723c065 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataAssetsWorkflow.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataAssetsWorkflow.java @@ -302,7 +302,7 @@ private void processSource( String keysetCursor = null; while (!stopped) { try { - ResultList batch = source.readNextKeyset(keysetCursor); + ResultList> batch = source.readNextKeyset(keysetCursor); keysetCursor = batch.getPaging().getAfter(); if (batch.getData().isEmpty()) { @@ -317,9 +317,9 @@ private void processSource( } extensions.beforeBatch(batch.getData()); - record EntityFuture(EntityInterface entity, Future future) {} + record EntityFuture(EntityInterface entity, Future future) {} List entityFutures = new ArrayList<>(); - for (EntityInterface entity : batch.getData()) { + for (EntityInterface entity : batch.getData()) { entityFutures.add( new EntityFuture( entity, diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataInsightsExtension.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataInsightsExtension.java index 1abfa115d280..49bfec421f11 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataInsightsExtension.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataInsightsExtension.java @@ -49,7 +49,7 @@ public void requireActive() { /** Enrichment can run concurrently; completion runs once, while the DI job still owns its lease. */ interface Session extends AutoCloseable { /** Allows bounded bulk lookups before the batch's concurrent enrichment starts. */ - default void beforeBatch(List entities) {} + default void beforeBatch(List> entities) {} default void enrich(Map snapshot) {} diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataInsightsExtensions.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataInsightsExtensions.java index e20c5004215d..9b380648c55b 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataInsightsExtensions.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataInsightsExtensions.java @@ -60,7 +60,7 @@ public void complete() { sessions.forEach(Session::complete); } - public void beforeBatch(List entities) { + public void beforeBatch(List> entities) { context.requireActive(); sessions.forEach(session -> session.beforeBatch(entities)); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/DataInsightsEntityEnricherProcessor.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/DataInsightsEntityEnricherProcessor.java index 0efa21febbb8..bfad503a0ccf 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/DataInsightsEntityEnricherProcessor.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/DataInsightsEntityEnricherProcessor.java @@ -40,7 +40,7 @@ @Slf4j public class DataInsightsEntityEnricherProcessor - implements Processor>, ResultList> { + implements Processor>, ResultList>> { /** * Cap on {@code LOG.warn} samples per processor lifetime for entity-level failures (i.e. @@ -102,7 +102,7 @@ public Map getEntityStats() { @Override public List> process( - ResultList input, Map contextData) + ResultList> input, Map contextData) throws SearchIndexException { try { EnrichmentContext context = buildAndValidateContext(contextData); @@ -129,7 +129,7 @@ public List> process( } public List> enrichSingle( - EntityInterface entity, Map contextData) throws SearchIndexException { + EntityInterface entity, Map contextData) throws SearchIndexException { try { EnrichmentContext context = buildAndValidateContext(contextData); return enrichEntityToSnapshots(entity, context); @@ -190,7 +190,7 @@ private EnrichmentContext buildAndValidateContext(Map contextDat * {@link EnrichmentPipeline}). */ private List> enrichEntityToSnapshots( - EntityInterface entity, EnrichmentContext context) { + EntityInterface entity, EnrichmentContext context) { try { List> snapshots = new ArrayList<>(); for (VersionedWindow window : versionResolver.resolve(entity, context)) { @@ -210,7 +210,7 @@ private List> enrichEntityToSnapshots( } private EnrichmentTarget buildTarget(VersionedWindow window, EnrichmentContext context) { - EntityInterface entity = window.entity(); + EntityInterface entity = window.entity(); Map entityMap = JsonUtils.getMap(entity); entityMap.keySet().retainAll(context.entityTypeFields()); stripNestedColumnChildren(entityMap); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/EnrichmentTarget.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/EnrichmentTarget.java index b82b1eb21bf4..1f5a239ef561 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/EnrichmentTarget.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/EnrichmentTarget.java @@ -23,7 +23,7 @@ * (only {@code id} / {@code type}). */ public record EnrichmentTarget( - EntityInterface entity, + EntityInterface entity, Map entityMap, Map changeSummary, long windowStartTimestamp, diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/VersionResolver.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/VersionResolver.java index 25f2dc90c774..39d733d884a7 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/VersionResolver.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/VersionResolver.java @@ -50,7 +50,7 @@ public final class VersionResolver { * @param context the workflow window + entity type * @return windows in newest-to-oldest order */ - public List resolve(EntityInterface latest, EnrichmentContext context) { + public List resolve(EntityInterface latest, EnrichmentContext context) { long startTs = context.workflowWindowStartTimestamp(); long endTs = context.workflowWindowEndTimestamp(); @@ -63,7 +63,7 @@ public List resolve(EntityInterface latest, EnrichmentContext c } EntityRepository entityRepository = Entity.getEntityRepository(context.entityType()); - Class entityClass = + Class> entityClass = ENTITY_TYPE_TO_CLASS_MAP.get(context.entityType().toLowerCase()); List windows = new ArrayList<>(); @@ -81,7 +81,7 @@ public List resolve(EntityInterface latest, EnrichmentContext c nextOffset = page.nextOffset(); for (Object version : versions) { - EntityInterface versionEntity = JsonUtils.readOrConvertValue(version, entityClass); + EntityInterface versionEntity = JsonUtils.readOrConvertValue(version, entityClass); // Consume isFirst up front: every continue/return below leaves it correctly false. boolean wasFirst = isFirst; isFirst = false; diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/VersionedWindow.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/VersionedWindow.java index 30c43f53b2d5..4c182a8fa933 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/VersionedWindow.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/VersionedWindow.java @@ -22,7 +22,7 @@ * out across the days in the range). */ public record VersionedWindow( - EntityInterface entity, + EntityInterface entity, long windowStartTimestamp, long windowEndTimestamp, VersionShape shape) {} diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/DescriptionStatsStep.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/DescriptionStatsStep.java index 702f25fd6a15..cc6c7b92d655 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/DescriptionStatsStep.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/DescriptionStatsStep.java @@ -35,7 +35,7 @@ public String name() { @Override public void apply(EnrichmentTarget target) { - EntityInterface entity = target.entity(); + EntityInterface entity = target.entity(); Map entityMap = target.entityMap(); entityMap.put("hasDescription", CommonUtil.nullOrEmpty(entity.getDescription()) ? 0 : 1); if (!SearchIndexUtils.hasColumns(entity)) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/EntityStatusStep.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/EntityStatusStep.java index 09603bc63161..25f69afc44f7 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/EntityStatusStep.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/EntityStatusStep.java @@ -31,8 +31,8 @@ public String name() { @Override public void apply(EnrichmentTarget target) { - EntityStatus status = target.entity().getEntityStatus(); - String value = status != null ? status.value() : EntityStatus.UNPROCESSED.value(); + Enum status = target.entity().getEntityStatus(); + String value = status != null ? status.toString() : EntityStatus.UNPROCESSED.value(); target.entityMap().put("entityStatus", value); } } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/TierStep.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/TierStep.java index f38a9098b6a5..9c313a3929b5 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/TierStep.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/TierStep.java @@ -42,7 +42,7 @@ public String name() { @Override public void apply(EnrichmentTarget target) { - EntityInterface entity = target.entity(); + EntityInterface entity = target.entity(); String tier = null; if (!NON_TIER_ENTITIES.contains(Entity.getEntityTypeFromObject(entity))) { tier = "NoTier"; diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/webAnalytics/processors/WebAnalyticsEntityViewProcessor.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/webAnalytics/processors/WebAnalyticsEntityViewProcessor.java index 18cda6464bc2..5981bfa1d5b8 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/webAnalytics/processors/WebAnalyticsEntityViewProcessor.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/webAnalytics/processors/WebAnalyticsEntityViewProcessor.java @@ -96,7 +96,7 @@ private void processEvent(WebAnalyticEventData event, Map contex if (!entityViewData.containsKey(entityFqn)) { // Create a new WebAnalyticEntityViewReportData based on the Event data. try { - EntityInterface entity = + EntityInterface entity = Entity.getEntityByName( URLDecoder.decode(entityType, StandardCharsets.UTF_8), URLDecoder.decode(entityFqn, StandardCharsets.UTF_8), diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/rdf/RdfBatchProcessor.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/rdf/RdfBatchProcessor.java index 5eed435fe57f..c8144532ce82 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/rdf/RdfBatchProcessor.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/rdf/RdfBatchProcessor.java @@ -85,7 +85,9 @@ public RdfBatchProcessor( } public BatchProcessingResult processEntities( - String entityType, List entities, BooleanSupplier stopRequested) { + String entityType, + List> entities, + BooleanSupplier stopRequested) { return processEntitiesInternal(entityType, entities, null, stopRequested); } @@ -97,7 +99,7 @@ public BatchProcessingResult processEntities( */ public BatchProcessingResult processEntitiesPreTranslated( String entityType, - List entities, + List> entities, List preTranslated, BooleanSupplier stopRequested) { return processEntitiesInternal(entityType, entities, preTranslated, stopRequested); @@ -105,7 +107,7 @@ public BatchProcessingResult processEntitiesPreTranslated( private BatchProcessingResult processEntitiesInternal( String entityType, - List entities, + List> entities, List preTranslated, BooleanSupplier stopRequested) { if (entities == null || entities.isEmpty()) { @@ -116,17 +118,17 @@ private BatchProcessingResult processEntitiesInternal( int successCount = 0; int failedCount = 0; String lastError = null; - List indexedEntities = new ArrayList<>(); + List> indexedEntities = new ArrayList<>(); // An entity whose translation failed has no write request. Count it here so a // skipped record surfaces as one failure rather than vanishing from the totals. - List writableEntities = entities; + List> writableEntities = entities; if (preTranslated != null && preTranslated.size() != entities.size()) { Set translatedIds = preTranslated.stream() .map(RdfStorageInterface.EntityWriteRequest::entityId) .collect(Collectors.toSet()); - List untranslated = + List> untranslated = entities.stream() .filter(entity -> !translatedIds.contains(entity.getId())) .collect(Collectors.toList()); @@ -254,10 +256,10 @@ private long bisectDeadlineNanos() { */ private BisectResult writePreTranslatedWithBisectFallback( String entityType, - List entities, + List> entities, List preTranslated, BooleanSupplier stopRequested, - List indexedEntities) { + List> indexedEntities) { final long deadlineNanos = bisectDeadlineNanos(); BisectResult result; if (stopRequested.getAsBoolean()) { @@ -278,10 +280,10 @@ private BisectResult writePreTranslatedWithBisectFallback( private BisectResult writeWithBisect( String entityType, - List entities, + List> entities, BooleanSupplier stopRequested, long deadlineNanos, - List indexedEntities) { + List> indexedEntities) { BisectResult result; if (stopRequested.getAsBoolean()) { result = BisectResult.EMPTY; @@ -305,10 +307,10 @@ private BisectResult writeWithBisect( private BisectResult handleBisectFailure( String entityType, - List entities, + List> entities, BooleanSupplier stopRequested, long deadlineNanos, - List indexedEntities, + List> indexedEntities, Exception cause) { BisectResult result; if (isCircuitBreakerOpen(cause)) { @@ -336,7 +338,7 @@ private BisectResult handleBisectFailure( describeError(entityType + " batch (write budget exhausted)", cause), false); } else if (entities.size() == 1) { - EntityInterface entity = entities.getFirst(); + EntityInterface entity = entities.getFirst(); LOG.error("Failed to index entity {} to RDF", entity.getId(), cause); recordEntityWriteFailures(entityType, entities, describeFailureMessage(cause)); result = @@ -354,10 +356,10 @@ private BisectResult handleBisectFailure( private BisectResult bisectHalves( String entityType, - List entities, + List> entities, BooleanSupplier stopRequested, long deadlineNanos, - List indexedEntities) { + List> indexedEntities) { int mid = entities.size() / 2; BisectResult left = writeWithBisect( @@ -366,7 +368,7 @@ private BisectResult bisectHalves( if (left.circuitOpen()) { // The breaker opened while writing the left half; every right-half // attempt would fail-fast on the same breaker. - List rightHalf = entities.subList(mid, entities.size()); + List> rightHalf = entities.subList(mid, entities.size()); recordEntityWriteFailures(entityType, rightHalf, left.lastError()); right = BisectResult.allFailed(rightHalf.size(), left.lastError(), true); } else { @@ -542,7 +544,7 @@ private String serverIdOrUnknown() { * and never throws — a failure-recording failure must not fail the write path it is describing. */ private void recordEntityWriteFailures( - String entityType, List entities, String message) { + String entityType, List> entities, String message) { if (runContext.jobId() == null || entities == null || entities.isEmpty()) { return; } @@ -663,7 +665,7 @@ private static String describeEntityError(String entityType, UUID entityId, Thro } public RelationshipProcessingResult processBatchRelationships( - String entityType, List entities) { + String entityType, List> entities) { if (entities == null || entities.isEmpty()) { return RelationshipProcessingResult.OK; } @@ -748,7 +750,7 @@ public RelationshipProcessingResult processBatchRelationships( // subsequent bulkAdd failed, batch sources lost their relationships // until the next weekly recreate-index.) Set batchSources = new HashSet<>(); - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { batchSources.add(new RdfRepository.EntitySourceRef(entityType, entity.getId())); } try { @@ -923,10 +925,10 @@ private static String describeLineageError(LineageEdgeData edge, Throwable error } RelationshipProcessingResult processGlossaryTermRelations( - List entities, BooleanSupplier stopRequested) { + List> entities, BooleanSupplier stopRequested) { List relations = new ArrayList<>(); - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { if (stopRequested.getAsBoolean()) { break; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/rdf/RdfReindexer.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/rdf/RdfReindexer.java index 4968cd0b4cfd..d1b34015fa07 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/rdf/RdfReindexer.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/rdf/RdfReindexer.java @@ -88,7 +88,7 @@ interface Listener { @FunctionalInterface interface BatchWriter { CompletableFuture submit( - String entityType, List entities) throws InterruptedException; + String entityType, List> entities) throws InterruptedException; } /** One entity type's stored rows, read a keyset page at a time. */ @@ -96,7 +96,7 @@ interface EntityPages { List readPage(KeysetCursor after, int limit); /** Deserializes rows and loads their fields; failures come back as errors, not exceptions. */ - ResultList load(List rows); + ResultList> load(List rows); KeysetCursor cursorAfter(List rows); } @@ -232,7 +232,7 @@ private CompletableFuture write(final String entityType, final Load private record WrittenPage(LoadedPage page, BatchProcessingResult result) {} private CompletableFuture submitToWriter( - final String entityType, final List entities) { + final String entityType, final List> entities) { try { return writer.submit(entityType, entities); } catch (InterruptedException e) { @@ -274,8 +274,8 @@ private void reportUnwritten(final String entityType, final int records, final T */ private LoadedPage load(final TypeRead read, final List rows) { final long startedAt = System.nanoTime(); - final ResultList loaded = read.pages.load(rows); - final List entities = new ArrayList<>(loaded.getData()); + final ResultList> loaded = read.pages.load(rows); + final List> entities = new ArrayList<>(loaded.getData()); final List errors = listOrEmpty(loaded.getErrors()); final int dropped = keepStoredData(read.entityType, errors, entities); final String firstError = errors.isEmpty() ? null : errors.getFirst().getMessage(); @@ -291,11 +291,11 @@ private LoadedPage load(final TypeRead read, final List rows) { private int keepStoredData( final String entityType, final List errors, - final List entities) { + final List> entities) { int storedOnly = 0; String storedOnlyReason = null; for (final EntityError error : errors) { - if (error.getEntity() instanceof EntityInterface entity) { + if (error.getEntity() instanceof EntityInterface entity) { LOG.debug( "RDF reindex indexes {} {} with its stored data only", entityType, entity.getId()); entities.add(entity); @@ -316,7 +316,7 @@ private int keepStoredData( } private record LoadedPage( - List entities, int dropped, String firstError, long readerTimeMs) {} + List> entities, int dropped, String firstError, long readerTimeMs) {} /** * The cursor after the last row of {@code rows} that deserializes. Walks back past rows that do @@ -355,7 +355,7 @@ public List readPage(final KeysetCursor after, final int limit) { } @Override - public ResultList load(final List rows) { + public ResultList> load(final List rows) { return repository.hydrate(rows, fields, filter); } @@ -365,7 +365,7 @@ public KeysetCursor cursorAfter(final List rows) { repository.getEntityType(), rows, row -> cursorOf(repository, filter, row)); } - private static KeysetCursor cursorOf( + private static > KeysetCursor cursorOf( final EntityRepository repository, final ListFilter filter, final String row) { final T entity = JsonUtils.readValue(row, repository.getEntityClass()); return cursorOf(JsonUtils.readTree(repository.getCursorValue(entity, filter))); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/rdf/sink/RdfBulkSink.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/rdf/sink/RdfBulkSink.java index b7b6e3da1a01..874bdda1e8e7 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/rdf/sink/RdfBulkSink.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/rdf/sink/RdfBulkSink.java @@ -109,7 +109,7 @@ private record TranslatedBatch( private record SubmittedBatch( String entityType, - List entities, + List> entities, CompletableFuture translation, CompletableFuture ack) {} @@ -132,7 +132,7 @@ public RdfBulkSink( * thread. After {@link #close()}, or once the writer has stopped, it completes exceptionally. */ public CompletableFuture submit( - String entityType, List entities) throws InterruptedException { + String entityType, List> entities) throws InterruptedException { requireOpen(); CompletableFuture translation = CompletableFuture.supplyAsync( diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchBulkSink.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchBulkSink.java index d1d719943a2a..5290024107e6 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchBulkSink.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchBulkSink.java @@ -330,7 +330,7 @@ public void write(List entities, Map contextData) throws Exce .toList(); CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new)).join(); } else { - List entityInterfaces = (List) entities; + List> entityInterfaces = (List>) entities; boolean embeddingsEnabled = isVectorEmbeddingEnabledForEntity(entityType); @@ -343,7 +343,7 @@ public void write(List entities, Map contextData) throws Exce if (embeddingsEnabled) { Map currentById = new HashMap<>(entityInterfaces.size()); - for (EntityInterface e : entityInterfaces) { + for (EntityInterface e : entityInterfaces) { currentById.put( e.getId().toString(), new ElasticSearchVectorService.EntityFingerprintInput( @@ -392,7 +392,7 @@ public void write(List entities, Map contextData) throws Exce // a semaphore so a fast reader cannot pin an unbounded number of Table entities in the // shared doc-build queue (see submitColumnIndexTask). if (Entity.TABLE.equals(entityType) && searchRepository.isColumnIndexingEnabled()) { - for (EntityInterface entity : entityInterfaces) { + for (EntityInterface entity : entityInterfaces) { submitColumnIndexTask(entity, reindexContext); } } @@ -430,7 +430,7 @@ protected StageStatsTracker extractTracker(Map contextData) { private static final int BULK_OPERATION_METADATA_OVERHEAD = 150; private void addEntity( - EntityInterface entity, + EntityInterface entity, String indexName, ReindexContext reindexContext, StageStatsTracker tracker, @@ -695,7 +695,7 @@ private void updateScriptedDocumentDirectly( } private void recordStaleReferenceWarning( - EntityInterface entity, StageStatsTracker tracker, Exception e) { + EntityInterface entity, StageStatsTracker tracker, Exception e) { recordStaleReferenceWarning( Entity.getEntityTypeFromObject(entity), entity.getId(), @@ -821,7 +821,7 @@ private void addTimeSeriesEntity( * released exactly once when the task completes (success or failure), or here if scheduling * itself fails synchronously. */ - private void submitColumnIndexTask(EntityInterface entity, ReindexContext reindexContext) { + private void submitColumnIndexTask(EntityInterface entity, ReindexContext reindexContext) { try { columnTaskSemaphore.acquire(); } catch (InterruptedException e) { @@ -860,7 +860,7 @@ private void submitColumnIndexTask(EntityInterface entity, ReindexContext reinde // Visible for testing: overridden by the column-backpressure regression test to control task // timing without standing up a real cluster. - protected void indexTableColumns(EntityInterface entity, ReindexContext reindexContext) { + protected void indexTableColumns(EntityInterface entity, ReindexContext reindexContext) { if (!(entity instanceof Table table)) { return; } @@ -1101,7 +1101,7 @@ boolean isVectorEmbeddingEnabledForEntity(String entityType) { } private String enrichWithEmbedding( - EntityInterface entity, + EntityInterface entity, String json, Map existingEmbeddingsById, StageStatsTracker tracker) { @@ -1153,7 +1153,7 @@ private String enrichWithEmbedding( } private Map fetchExistingEmbeddings( - List entities, + List> entities, Map currentById, String indexName, ReindexContext reindexContext) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchIndexSink.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchIndexSink.java index 513cb3a76f97..6e8e5ca40a74 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchIndexSink.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchIndexSink.java @@ -252,8 +252,8 @@ public void close() { } private BulkOperation convertEntityToRequest(Object entity, String entityType) { - if (entity instanceof EntityInterface) { - return getEntityInterfaceOperation(entityType, (EntityInterface) entity); + if (entity instanceof EntityInterface) { + return getEntityInterfaceOperation(entityType, (EntityInterface) entity); } else if (entity instanceof EntityTimeSeriesInterface) { return getEntityTimeSeriesInterfaceOperation(entityType, (EntityTimeSeriesInterface) entity); } else { @@ -261,7 +261,7 @@ private BulkOperation convertEntityToRequest(Object entity, String entityType) { } } - private BulkOperation getEntityInterfaceOperation(String entityType, EntityInterface entity) { + private BulkOperation getEntityInterfaceOperation(String entityType, EntityInterface entity) { IndexMapping indexMapping = Entity.getSearchRepository().getIndexMapping(entityType); String indexName = indexMapping.getIndexName(Entity.getSearchRepository().getClusterAlias()); String jsonDoc = diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchBulkSink.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchBulkSink.java index 4af6622d6ddd..b737cc5167be 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchBulkSink.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchBulkSink.java @@ -346,7 +346,7 @@ public void write(List entities, Map contextData) throws Exce .toList(); CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new)).join(); } else { - List entityInterfaces = (List) entities; + List> entityInterfaces = (List>) entities; ReindexContext reindexContext = contextData.containsKey(RECREATE_CONTEXT) ? (ReindexContext) contextData.get(RECREATE_CONTEXT) @@ -361,7 +361,7 @@ public void write(List entities, Map contextData) throws Exce if (embeddingsEnabled) { Map currentById = new HashMap<>(entityInterfaces.size()); - for (EntityInterface e : entityInterfaces) { + for (EntityInterface e : entityInterfaces) { currentById.put( e.getId().toString(), new OpenSearchVectorService.EntityFingerprintInput( @@ -410,7 +410,7 @@ public void write(List entities, Map contextData) throws Exce // a semaphore so a fast reader cannot pin an unbounded number of Table entities in the // shared doc-build queue (see submitColumnIndexTask). if (Entity.TABLE.equals(entityType) && searchRepository.isColumnIndexingEnabled()) { - for (EntityInterface entity : entityInterfaces) { + for (EntityInterface entity : entityInterfaces) { submitColumnIndexTask(entity, reindexContext); } } @@ -448,7 +448,7 @@ protected StageStatsTracker extractTracker(Map contextData) { private static final int BULK_OPERATION_METADATA_OVERHEAD = 150; private void addEntity( - EntityInterface entity, + EntityInterface entity, String indexName, ReindexContext reindexContext, StageStatsTracker tracker, @@ -469,7 +469,7 @@ private void addEntity( } private void addEntity( - EntityInterface entity, + EntityInterface entity, String indexName, ReindexContext reindexContext, StageStatsTracker tracker, @@ -745,7 +745,7 @@ private void updateScriptedDocumentDirectly( } private void recordStaleReferenceWarning( - EntityInterface entity, StageStatsTracker tracker, Exception e) { + EntityInterface entity, StageStatsTracker tracker, Exception e) { recordStaleReferenceWarning( Entity.getEntityTypeFromObject(entity), entity.getId(), @@ -871,7 +871,7 @@ private void addTimeSeriesEntity( * released exactly once when the task completes (success or failure), or here if scheduling * itself fails synchronously. */ - private void submitColumnIndexTask(EntityInterface entity, ReindexContext reindexContext) { + private void submitColumnIndexTask(EntityInterface entity, ReindexContext reindexContext) { try { columnTaskSemaphore.acquire(); } catch (InterruptedException e) { @@ -910,7 +910,7 @@ private void submitColumnIndexTask(EntityInterface entity, ReindexContext reinde // Visible for testing: overridden by the column-backpressure regression test to control task // timing without standing up a real cluster. - protected void indexTableColumns(EntityInterface entity, ReindexContext reindexContext) { + protected void indexTableColumns(EntityInterface entity, ReindexContext reindexContext) { if (!(entity instanceof Table table)) { return; } @@ -1129,7 +1129,7 @@ boolean isVectorEmbeddingEnabledForEntity(String entityType) { } private String enrichWithEmbedding( - EntityInterface entity, + EntityInterface entity, String json, Map existingEmbeddingsById, StageStatsTracker tracker, @@ -1240,7 +1240,7 @@ public int getActiveBulkRequestCount() { } private Map fetchExistingEmbeddings( - List entities, + List> entities, Map currentById, String indexName, ReindexContext reindexContext) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchIndexSink.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchIndexSink.java index db61f5587ad7..e474c8bad405 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchIndexSink.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchIndexSink.java @@ -258,8 +258,8 @@ public void close() { } private BulkOperation convertEntityToRequest(Object entity, String entityType) { - if (entity instanceof EntityInterface) { - return getEntityInterfaceOperation(entityType, (EntityInterface) entity); + if (entity instanceof EntityInterface) { + return getEntityInterfaceOperation(entityType, (EntityInterface) entity); } else if (entity instanceof EntityTimeSeriesInterface) { return getEntityTimeSeriesInterfaceOperation(entityType, (EntityTimeSeriesInterface) entity); } else { @@ -267,7 +267,7 @@ private BulkOperation convertEntityToRequest(Object entity, String entityType) { } } - private BulkOperation getEntityInterfaceOperation(String entityType, EntityInterface entity) { + private BulkOperation getEntityInterfaceOperation(String entityType, EntityInterface entity) { IndexMapping indexMapping = Entity.getSearchRepository().getIndexMapping(entityType); String indexName = indexMapping.getIndexName(Entity.getSearchRepository().getClusterAlias()); String jsonDoc = diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/DistributedSearchIndexCoordinator.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/DistributedSearchIndexCoordinator.java index a8ec1ba3f165..c0fff3346fc9 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/DistributedSearchIndexCoordinator.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/DistributedSearchIndexCoordinator.java @@ -292,7 +292,7 @@ private static List sortedDistinctTargets(List parti * make the {@code name > :afterName} predicate evaluate to NULL/false and return zero * rows. */ - private void walkAndRecord( + private > void walkAndRecord( EntityRepository repo, List sortedTargets, Map result) { ListFilter filter = repo.getReindexFilter(); String afterName = ""; @@ -338,7 +338,7 @@ private void walkAndRecord( } } - private Object deserializeLast( + private > Object deserializeLast( EntityRepository repo, List batch) { return JsonUtils.readValue(batch.get(batch.size() - 1), repo.getEntityClass()); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/PartitionWorker.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/PartitionWorker.java index 8739873d3540..9c21f572563b 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/PartitionWorker.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/PartitionWorker.java @@ -572,8 +572,8 @@ private void recordReaderFailures( for (EntityError entityError : listOrEmpty(resultList.getErrors())) { Object rawEntity = entityError.getEntity(); String entityId = null; - if (rawEntity instanceof EntityInterface) { - UUID id = ((EntityInterface) rawEntity).getId(); + if (rawEntity instanceof EntityInterface) { + UUID id = ((EntityInterface) rawEntity).getId(); if (id != null) { entityId = id.toString(); } @@ -610,7 +610,7 @@ private void recordRelationshipWarnings(String entityType, ResultList resultL Object rawEntity = warning.getEntity(); String entityId = null; String entityFqn = null; - if (rawEntity instanceof EntityInterface entity) { + if (rawEntity instanceof EntityInterface entity) { UUID id = entity.getId(); entityId = id != null ? id.toString() : null; entityFqn = entity.getFullyQualifiedName(); @@ -717,7 +717,7 @@ private void writeToSink( String normalizedEntityType = SearchIndexEntityTypes.normalizeEntityType(entityType); if (!SearchIndexEntityTypes.isTimeSeriesEntity(normalizedEntityType)) { - List entities = (List) resultList.getData(); + List> entities = (List>) resultList.getData(); ReindexingUtil.populateDocBuildContext(contextData, normalizedEntityType, entities); searchIndexSink.write(entities, contextData); } else { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/cache/BundleWarmupBatcher.java b/openmetadata-service/src/main/java/org/openmetadata/service/cache/BundleWarmupBatcher.java index 0d3c2d17d26f..e89cacf84ef8 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/cache/BundleWarmupBatcher.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/cache/BundleWarmupBatcher.java @@ -117,13 +117,15 @@ public BundleWarmupBatcher( public record BatchResult(int success, int failed) {} public BatchResult warmupBatch( - final String entityType, final List entities, final Duration ttl) { + final String entityType, + final List> entities, + final Duration ttl) { if (entities == null || entities.isEmpty()) { return new BatchResult(0, 0); } - final Map entitiesByFqnHash = new HashMap<>(entities.size() * 2); + final Map> entitiesByFqnHash = new HashMap<>(entities.size() * 2); final List fqnHashes = new ArrayList<>(entities.size()); - for (final EntityInterface entity : entities) { + for (final EntityInterface entity : entities) { if (entity.getId() == null || entity.getFullyQualifiedName() == null) { continue; } @@ -154,8 +156,8 @@ public BatchResult warmupBatch( final Map bundleKeyValues = new HashMap<>(entitiesByFqnHash.size() * 2); final String certClassification = resolveCertificationClassification(); int failed = 0; - for (final Map.Entry entry : entitiesByFqnHash.entrySet()) { - final EntityInterface entity = entry.getValue(); + for (final Map.Entry> entry : entitiesByFqnHash.entrySet()) { + final EntityInterface entity = entry.getValue(); try { final CachedReadBundle.Dto dto = new CachedReadBundle.Dto(); final Map> warmedRelations = @@ -224,7 +226,7 @@ private static String resolveCertificationClassification() { } private Map>> warmRelationships( - final String entityType, final Collection entities) { + final String entityType, final Collection> entities) { if (!warmRelationships) { return Collections.emptyMap(); } @@ -240,12 +242,12 @@ private Map>> warmRelationships( return relationsByEntity; } - private static List entityIds(final Collection entities) { - return entities.stream().map(EntityInterface::getId).map(UUID::toString).toList(); + private static List entityIds(final Collection> entities) { + return entities.stream().map(EntityInterface::getId).map(UUID::toString).toList(); } private static Map>> initRelationsByEntity( - final Collection entities) { + final Collection> entities) { final Map>> relationsByEntity = new HashMap<>(entities.size() * 2); entities.forEach(entity -> relationsByEntity.put(entity.getId(), emptyRelationshipMap())); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/context/center/ContextMemoryExtractor.java b/openmetadata-service/src/main/java/org/openmetadata/service/context/center/ContextMemoryExtractor.java index feac792c016c..86c39d0e0e6f 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/context/center/ContextMemoryExtractor.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/context/center/ContextMemoryExtractor.java @@ -10,11 +10,11 @@ import org.openmetadata.schema.entity.context.ContextMemory; import org.openmetadata.schema.entity.context.ContextMemoryScope; import org.openmetadata.schema.entity.context.ContextMemorySourceType; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.ContextMemoryType; import org.openmetadata.schema.entity.context.MemoryShareConfig; import org.openmetadata.schema.entity.context.MemoryVisibility; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.service.Entity; import org.openmetadata.service.llm.LLMCompletionClient; import org.openmetadata.service.llm.LLMCompletionException; @@ -183,7 +183,7 @@ private ContextMemory toMemory( .withSummary(pill.summary()) .withMemoryType(parseType(pill.memoryType())) .withMemoryScope(ContextMemoryScope.ENTITY_SCOPED) - .withEntityStatus(EntityStatus.APPROVED) + .withEntityStatus(ContextMemoryStatus.APPROVED) .withSourceType(sourceType) .withSourceEntity(sourceRef) .withPrimaryEntity(sourceRef) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/context/center/ContextMemoryReconciler.java b/openmetadata-service/src/main/java/org/openmetadata/service/context/center/ContextMemoryReconciler.java index 59aa8c828d98..5f227091bec5 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/context/center/ContextMemoryReconciler.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/context/center/ContextMemoryReconciler.java @@ -10,10 +10,10 @@ import org.openmetadata.schema.entity.context.ContextMemory; import org.openmetadata.schema.entity.context.ContextMemoryScope; import org.openmetadata.schema.entity.context.ContextMemorySourceType; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.MemoryShareConfig; import org.openmetadata.schema.entity.context.MemoryVisibility; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.utils.JsonUtils; import org.openmetadata.service.Entity; import org.openmetadata.service.jdbi3.ContextMemoryRepository; @@ -69,7 +69,7 @@ public ReconcileResult reuseExtractedFrom( private boolean isReusableFileMemory(ContextMemory pill) { return pill.getSourceType() == ContextMemorySourceType.FILE_EXTRACTION - && pill.getEntityStatus() == EntityStatus.APPROVED + && pill.getEntityStatus() == ContextMemoryStatus.APPROVED && pill.getMemoryScope() == ContextMemoryScope.ENTITY_SCOPED && pill.getShareConfig() != null && pill.getShareConfig().getVisibility() == MemoryVisibility.ENTITY; @@ -254,7 +254,7 @@ private boolean isAutomated(ContextMemory pill) { * stage was a reviewer's decision that re-extracting the same fact must not undo. */ private boolean isEngineManaged(ContextMemory pill) { - return isAutomated(pill) && pill.getEntityStatus() == EntityStatus.APPROVED; + return isAutomated(pill) && pill.getEntityStatus() == ContextMemoryStatus.APPROVED; } private String questionKey(ContextMemory pill) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/context/center/SemanticMemoryDuplicateFinder.java b/openmetadata-service/src/main/java/org/openmetadata/service/context/center/SemanticMemoryDuplicateFinder.java index 88195c11d270..0102509f69aa 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/context/center/SemanticMemoryDuplicateFinder.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/context/center/SemanticMemoryDuplicateFinder.java @@ -14,10 +14,10 @@ import lombok.extern.slf4j.Slf4j; import org.openmetadata.schema.entity.context.ContextMemory; import org.openmetadata.schema.entity.context.ContextMemorySourceType; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.MemoryVisibility; import org.openmetadata.schema.entity.teams.User; import org.openmetadata.schema.search.SearchRequest; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.Include; import org.openmetadata.schema.utils.JsonUtils; import org.openmetadata.service.Entity; @@ -158,7 +158,7 @@ private String keywordQuery(ContextMemory derived) { private String keywordQueryFilter() { List> filters = List.of( - Map.of("term", Map.of("entityStatus", EntityStatus.APPROVED.value())), + Map.of("term", Map.of("entityStatus", ContextMemoryStatus.APPROVED.value())), Map.of("term", Map.of("sourceType", ContextMemorySourceType.FILE_EXTRACTION.value())), Map.of("term", Map.of("visibility", MemoryVisibility.ENTITY.value()))); return JsonUtils.pojoToJson(Map.of("bool", Map.of("filter", filters))); @@ -194,7 +194,7 @@ private ContextMemory loadCandidate(Map hit, ContextMemory deriv } private boolean isReusable(ContextMemory candidate, ContextMemory derived) { - return candidate.getEntityStatus() == EntityStatus.APPROVED + return candidate.getEntityStatus() == ContextMemoryStatus.APPROVED && candidate.getSourceType() == ContextMemorySourceType.FILE_EXTRACTION && candidate.getShareConfig() != null && candidate.getShareConfig().getVisibility() == MemoryVisibility.ENTITY diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/csv/BulkImportVersioning.java b/openmetadata-service/src/main/java/org/openmetadata/service/csv/BulkImportVersioning.java index a4e7746893b9..98fab40e1032 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/csv/BulkImportVersioning.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/csv/BulkImportVersioning.java @@ -48,12 +48,13 @@ private BulkImportVersioning() {} * keeps the outcome from becoming a cross-domain existence oracle. */ public static void recordVersion( - EntityRepository versioningRepo, + EntityRepository> versioningRepo, UriInfo uriInfo, String targetFqn, String updatedBy, CsvImportResult result) { - EntityInterface target = resolveAccessibleTarget(versioningRepo, uriInfo, targetFqn, updatedBy); + EntityInterface target = + resolveAccessibleTarget(versioningRepo, uriInfo, targetFqn, updatedBy); if (target == null) { LOG.info("Skipping bulk import versioning for target '{}'", targetFqn); } else { @@ -61,17 +62,17 @@ public static void recordVersion( } } - private static EntityInterface resolveAccessibleTarget( - EntityRepository versioningRepo, + private static EntityInterface resolveAccessibleTarget( + EntityRepository> versioningRepo, UriInfo uriInfo, String targetFqn, String updatedBy) { // Resolved before the lookup so an unresolvable principal is not mistaken for a missing target. SubjectContext subjectContext = SubjectContext.getSubjectContext(updatedBy); - EntityInterface target = null; + EntityInterface target = null; try { String fields = versioningRepo.isSupportsDomains() ? Entity.FIELD_DOMAINS : ""; - EntityInterface candidate = + EntityInterface candidate = versioningRepo.getByName( uriInfo, targetFqn, diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/csv/CsvImportExportJobHandler.java b/openmetadata-service/src/main/java/org/openmetadata/service/csv/CsvImportExportJobHandler.java index 909670e9b2fb..0643aa166d3e 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/csv/CsvImportExportJobHandler.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/csv/CsvImportExportJobHandler.java @@ -105,7 +105,7 @@ public void checkpoint() { } }; - EntityRepository repository = getRepository(args.getEntityType()); + EntityRepository> repository = getRepository(args.getEntityType()); CsvImportResult result = nullOrEmpty(args.getVersioningEntityType()) ? repository.importFromCsv( @@ -131,7 +131,7 @@ public void checkpoint() { private void runExport(BackgroundJob job, CsvAsyncJobArgs args) throws IOException { String jobId = String.valueOf(job.getId()); - EntityRepository repository = getRepository(args.getEntityType()); + EntityRepository> repository = getRepository(args.getEntityType()); CsvExportProgressCallback progressCallback = new CsvExportProgressCallback() { @Override @@ -351,7 +351,8 @@ private void createBulkImportVersion( || Boolean.TRUE.equals(args.getDryRun())) { return; } - EntityRepository versioningRepo = getRepository(effectiveVersioningEntityType); + EntityRepository> versioningRepo = + getRepository(effectiveVersioningEntityType); if (!versioningRepo.supportsBulkImportVersioning()) { return; } @@ -389,8 +390,8 @@ private void handleFailure(BackgroundJob job, CsvAsyncJobArgs args, Exception ex } @SuppressWarnings("unchecked") - private EntityRepository getRepository(String entityType) { - return (EntityRepository) Entity.getEntityRepository(entityType); + private EntityRepository> getRepository(String entityType) { + return (EntityRepository>) Entity.getEntityRepository(entityType); } private String getStartedMessage(CsvAsyncJobArgs args) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/events/lifecycle/EntityLifecycleEventDispatcher.java b/openmetadata-service/src/main/java/org/openmetadata/service/events/lifecycle/EntityLifecycleEventDispatcher.java index ddb053c13f06..502eb8953e3e 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/events/lifecycle/EntityLifecycleEventDispatcher.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/events/lifecycle/EntityLifecycleEventDispatcher.java @@ -165,13 +165,14 @@ public List getHandlers() { /** * Dispatch entity created event to all applicable handlers. */ - public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { + public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { if (entity == null) return; String entityType = entity.getEntityReference().getType(); LOG.debug("Dispatching entity created event for {} {}", entityType, entity.getId()); - Supplier snapshot = new LazyEntitySnapshot(entity, EventType.ENTITY_CREATED); + Supplier> snapshot = + new LazyEntitySnapshot(entity, EventType.ENTITY_CREATED); for (EntityLifecycleEventHandler handler : getApplicableHandlers(entityType)) { executeHandler( entity, @@ -193,14 +194,14 @@ public void onEntityCreated(EntityInterface entity, SubjectContext subjectContex * clobbering B's doc with stale create-time state. So an async handler is dispatched per entity, * each keyed on its own id; a sync handler still receives the whole list once for efficiency. */ - public void onEntitiesCreated(List entities, SubjectContext subjectContext) { + public void onEntitiesCreated(List> entities, SubjectContext subjectContext) { if (entities == null || entities.isEmpty()) return; String entityType = entities.getFirst().getEntityReference().getType(); LOG.debug( "Dispatching bulk entity created event for {} {} entities", entityType, entities.size()); - Map> snapshots = + Map>> snapshots = buildSnapshots(entities, EventType.ENTITY_CREATED); for (EntityLifecycleEventHandler handler : getApplicableHandlers(entityType)) { dispatchBulkCreate(handler, entities, snapshots, subjectContext); @@ -215,11 +216,11 @@ public void onEntitiesCreated(List entities, SubjectContext sub */ private void dispatchBulkCreate( EntityLifecycleEventHandler handler, - List entities, - Map> snapshots, + List> entities, + Map>> snapshots, SubjectContext subjectContext) { if (handler.isAsync()) { - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { executeHandler( entity, snapshots.get(entity.getId()), @@ -238,13 +239,16 @@ private void dispatchBulkCreate( * Dispatch entity updated event to all applicable handlers. */ public void onEntityUpdated( - EntityInterface entity, ChangeDescription changeDescription, SubjectContext subjectContext) { + EntityInterface entity, + ChangeDescription changeDescription, + SubjectContext subjectContext) { if (entity == null) return; String entityType = entity.getEntityReference().getType(); LOG.debug("Dispatching entity updated event for {} {}", entityType, entity.getId()); - Supplier snapshot = new LazyEntitySnapshot(entity, EventType.ENTITY_UPDATED); + Supplier> snapshot = + new LazyEntitySnapshot(entity, EventType.ENTITY_UPDATED); for (EntityLifecycleEventHandler handler : getApplicableHandlers(entityType)) { executeHandler( entity, @@ -264,14 +268,14 @@ public void onEntityUpdated( * */ public void onEntitiesUpdated( - List entities, + List> entities, ChangeDescription changeDescription, SubjectContext subjectContext) { onEntitiesUpdated(entities, changeDescription, subjectContext, EntityUpdateContext.empty()); } public void onEntitiesUpdated( - List entities, + List> entities, ChangeDescription changeDescription, SubjectContext subjectContext, EntityUpdateContext updateContext) { @@ -282,7 +286,7 @@ public void onEntitiesUpdated( String entityType = entities.getFirst().getEntityReference().getType(); LOG.debug( "Dispatching bulk entity updated event for {} ({} entities)", entityType, entities.size()); - Map> snapshots = + Map>> snapshots = buildSnapshots(entities, EventType.ENTITY_UPDATED); for (EntityLifecycleEventHandler handler : getApplicableHandlers(entityType)) { dispatchBulkUpdate( @@ -303,13 +307,13 @@ public void onEntitiesUpdated( */ private void dispatchBulkUpdate( EntityLifecycleEventHandler handler, - List entities, - Map> snapshots, + List> entities, + Map>> snapshots, ChangeDescription changeDescription, SubjectContext subjectContext, EntityUpdateContext updateContext) { if (handler.isAsync()) { - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { ChangeDescription change = entity.getChangeDescription() != null ? entity.getChangeDescription() @@ -359,13 +363,14 @@ public void onEntityUpdated(EntityReference entityReference, SubjectContext subj /** * Dispatch entity deleted event to all applicable handlers. */ - public void onEntityDeleted(EntityInterface entity, SubjectContext subjectContext) { + public void onEntityDeleted(EntityInterface entity, SubjectContext subjectContext) { if (entity == null) return; String entityType = entity.getEntityReference().getType(); LOG.debug("Dispatching entity deleted event for {} {}", entityType, entity.getId()); - Supplier snapshot = new LazyEntitySnapshot(entity, EventType.ENTITY_DELETED); + Supplier> snapshot = + new LazyEntitySnapshot(entity, EventType.ENTITY_DELETED); for (EntityLifecycleEventHandler handler : getApplicableHandlers(entityType)) { executeHandler( entity, @@ -381,7 +386,7 @@ public void onEntityDeleted(EntityInterface entity, SubjectContext subjectContex * Dispatch entity soft deleted or restored event to all applicable handlers. */ public void onEntitySoftDeletedOrRestored( - EntityInterface entity, boolean isDeleted, SubjectContext subjectContext) { + EntityInterface entity, boolean isDeleted, SubjectContext subjectContext) { if (entity == null) return; String entityType = entity.getEntityReference().getType(); @@ -392,7 +397,7 @@ public void onEntitySoftDeletedOrRestored( isDeleted); EventType eventType = isDeleted ? EventType.ENTITY_SOFT_DELETED : EventType.ENTITY_RESTORED; - Supplier snapshot = new LazyEntitySnapshot(entity, eventType); + Supplier> snapshot = new LazyEntitySnapshot(entity, eventType); for (EntityLifecycleEventHandler handler : getApplicableHandlers(entityType)) { executeHandler( entity, @@ -415,11 +420,11 @@ private List getApplicableHandlers(String entityTyp } private void executeHandler( - EntityInterface entity, - Supplier snapshotSupplier, + EntityInterface entity, + Supplier> snapshotSupplier, EventType eventType, ChangeDescription changeDescription, - Consumer handlerCall, + Consumer> handlerCall, EntityLifecycleEventHandler handler) { if (!shouldProcess(handler, eventType, changeDescription)) { return; @@ -429,13 +434,13 @@ private void executeHandler( } private void executeHandlerAfterCommit( - EntityInterface entity, - Supplier snapshotSupplier, + EntityInterface entity, + Supplier> snapshotSupplier, EventType eventType, - Consumer handlerCall, + Consumer> handlerCall, EntityLifecycleEventHandler handler) { if (handler.isAsync()) { - EntityInterface snapshot = snapshotSupplier.get(); + EntityInterface snapshot = snapshotSupplier.get(); if (snapshot != null) { orderedLaneExecutor.submit( entity.getId(), laneTask(entity, eventType, () -> handlerCall.accept(snapshot))); @@ -445,10 +450,10 @@ private void executeHandlerAfterCommit( } } - private Map> buildSnapshots( - List entities, EventType eventType) { - Map> snapshots = new HashMap<>(); - for (EntityInterface entity : entities) { + private Map>> buildSnapshots( + List> entities, EventType eventType) { + Map>> snapshots = new HashMap<>(); + for (EntityInterface entity : entities) { snapshots.computeIfAbsent(entity.getId(), id -> new LazyEntitySnapshot(entity, eventType)); } return snapshots; @@ -481,8 +486,9 @@ private boolean shouldProcess( * #enqueueLaneFailureRetry}, so even a pathological serialization error still lands in the outbox * instead of escaping to the post-commit request thread. */ - private EntityInterface snapshotOrEnqueueRetry(EntityInterface entity, EventType eventType) { - EntityInterface snapshot; + private EntityInterface snapshotOrEnqueueRetry( + EntityInterface entity, EventType eventType) { + EntityInterface snapshot; try { snapshot = JsonUtils.deepCopy(entity, entity.getClass()); } catch (Throwable serializationFailure) { @@ -502,19 +508,19 @@ private EntityInterface snapshotOrEnqueueRetry(EntityInterface entity, EventType * in a single dispatch, so a wide POJO is serialized once rather than once per async handler. The * snapshot (or its failure routing) happens at most once on first {@link #get()}. */ - private final class LazyEntitySnapshot implements Supplier { - private final EntityInterface entity; + private final class LazyEntitySnapshot implements Supplier> { + private final EntityInterface entity; private final EventType eventType; private boolean computed; - private EntityInterface snapshot; + private EntityInterface snapshot; - private LazyEntitySnapshot(EntityInterface entity, EventType eventType) { + private LazyEntitySnapshot(EntityInterface entity, EventType eventType) { this.entity = entity; this.eventType = eventType; } @Override - public EntityInterface get() { + public EntityInterface get() { if (!computed) { snapshot = snapshotOrEnqueueRetry(entity, eventType); computed = true; @@ -552,7 +558,7 @@ private void executeHandlerAfterCommit( * of only logging — and so a lane-queue-full shed routes the same locator to the outbox. */ private OrderedLaneTask laneTask( - EntityInterface entity, EventType eventType, Runnable handlerExecution) { + EntityInterface entity, EventType eventType, Runnable handlerExecution) { EntityReference reference = entity.getEntityReference(); return new OrderedLaneTask( handlerExecution, diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/events/lifecycle/EntityLifecycleEventHandler.java b/openmetadata-service/src/main/java/org/openmetadata/service/events/lifecycle/EntityLifecycleEventHandler.java index c6c95cde662e..9cec0bf8ecad 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/events/lifecycle/EntityLifecycleEventHandler.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/events/lifecycle/EntityLifecycleEventHandler.java @@ -40,7 +40,7 @@ default boolean shouldProcess(EventType eventType, ChangeDescription changeDescr /** * Called after an entity is successfully created. */ - default void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { + default void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { // Default empty implementation } @@ -48,12 +48,14 @@ default void onEntityCreated(EntityInterface entity, SubjectContext subjectConte * Called after an entity is successfully updated. */ default void onEntityUpdated( - EntityInterface entity, ChangeDescription changeDescription, SubjectContext subjectContext) { + EntityInterface entity, + ChangeDescription changeDescription, + SubjectContext subjectContext) { // Default empty implementation } default void onEntityUpdated( - EntityInterface entity, + EntityInterface entity, ChangeDescription changeDescription, SubjectContext subjectContext, EntityUpdateContext updateContext) { @@ -65,13 +67,13 @@ default void onEntityUpdated( * the single-entity onEntityUpdated for backward compatibility. */ default void onEntitiesUpdated( - List entities, + List> entities, ChangeDescription changeDescription, SubjectContext subjectContext) { if (entities == null || entities.isEmpty()) { return; } - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { onEntityUpdated( entity, entity.getChangeDescription() != null ? entity.getChangeDescription() : changeDescription, @@ -80,7 +82,7 @@ default void onEntitiesUpdated( } default void onEntitiesUpdated( - List entities, + List> entities, ChangeDescription changeDescription, SubjectContext subjectContext, EntityUpdateContext updateContext) { @@ -98,8 +100,8 @@ default void onEntityUpdated(EntityReference entityRef, SubjectContext subjectCo * Called after multiple entities are successfully created in bulk. * Default implementation delegates to individual onEntityCreated calls. */ - default void onEntitiesCreated(List entities, SubjectContext subjectContext) { - for (EntityInterface entity : entities) { + default void onEntitiesCreated(List> entities, SubjectContext subjectContext) { + for (EntityInterface entity : entities) { onEntityCreated(entity, subjectContext); } } @@ -107,7 +109,7 @@ default void onEntitiesCreated(List entities, SubjectContext su /** * Called after an entity is successfully deleted. */ - default void onEntityDeleted(EntityInterface entity, SubjectContext subjectContext) { + default void onEntityDeleted(EntityInterface entity, SubjectContext subjectContext) { // Default empty implementation } @@ -115,7 +117,7 @@ default void onEntityDeleted(EntityInterface entity, SubjectContext subjectConte * Called after an entity is soft deleted or restored. */ default void onEntitySoftDeletedOrRestored( - EntityInterface entity, boolean isDeleted, SubjectContext subjectContext) { + EntityInterface entity, boolean isDeleted, SubjectContext subjectContext) { // Default empty implementation } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/events/lifecycle/handlers/DomainSyncHandler.java b/openmetadata-service/src/main/java/org/openmetadata/service/events/lifecycle/handlers/DomainSyncHandler.java index 6880396fdd43..183d515fd944 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/events/lifecycle/handlers/DomainSyncHandler.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/events/lifecycle/handlers/DomainSyncHandler.java @@ -50,7 +50,9 @@ public boolean shouldProcess(EventType eventType, ChangeDescription changeDescri @Override public void onEntityUpdated( - EntityInterface entity, ChangeDescription changeDescription, SubjectContext subjectContext) { + EntityInterface entity, + ChangeDescription changeDescription, + SubjectContext subjectContext) { if (entity == null || changeDescription == null) { return; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/events/lifecycle/handlers/SearchIndexHandler.java b/openmetadata-service/src/main/java/org/openmetadata/service/events/lifecycle/handlers/SearchIndexHandler.java index 7c6119398215..bb2ff5d7208c 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/events/lifecycle/handlers/SearchIndexHandler.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/events/lifecycle/handlers/SearchIndexHandler.java @@ -42,7 +42,7 @@ public SearchIndexHandler(SearchRepository searchRepository) { } @Override - public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { + public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { if (entity == null) { LOG.warn("Received null entity in onEntityCreated"); return; @@ -61,7 +61,9 @@ public void onEntityCreated(EntityInterface entity, SubjectContext subjectContex @Override public void onEntityUpdated( - EntityInterface entity, ChangeDescription changeDescription, SubjectContext subjectContext) { + EntityInterface entity, + ChangeDescription changeDescription, + SubjectContext subjectContext) { if (entity == null) { LOG.warn("Received null entity in onEntityUpdated"); return; @@ -101,7 +103,7 @@ public void onEntityUpdated(EntityReference entityRef, SubjectContext subjectCon } @Override - public void onEntityDeleted(EntityInterface entity, SubjectContext subjectContext) { + public void onEntityDeleted(EntityInterface entity, SubjectContext subjectContext) { if (entity == null) { LOG.warn("Received null entity in onEntityDeleted"); return; @@ -120,7 +122,7 @@ public void onEntityDeleted(EntityInterface entity, SubjectContext subjectContex @Override public void onEntitySoftDeletedOrRestored( - EntityInterface entity, boolean isDeleted, SubjectContext subjectContext) { + EntityInterface entity, boolean isDeleted, SubjectContext subjectContext) { if (entity == null) { LOG.warn("Received null entity in onEntitySoftDeletedOrRestored"); return; @@ -157,22 +159,22 @@ public boolean isAsync() { return false; } - public void onEntitiesCreated(List entities, SubjectContext subjectContext) { + public void onEntitiesCreated(List> entities, SubjectContext subjectContext) { if (entities == null || entities.isEmpty()) { LOG.warn("Received null entities in onEntitiesCreated"); return; } try { - Map> entitiesByType = + Map>> entitiesByType = entities.stream().collect(Collectors.groupingBy(e -> e.getEntityReference().getType())); - for (Map.Entry> entry : entitiesByType.entrySet()) { + for (Map.Entry>> entry : entitiesByType.entrySet()) { searchRepository.createEntitiesIndex(entry.getValue()); } } catch (Exception e) { LOG.error("Failed to create search indexes for {} entities", entities.size(), e); - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { onEntityCreated(entity, subjectContext); } } @@ -184,7 +186,7 @@ public void onEntitiesCreated(List entities, SubjectContext sub */ @Override public void onEntitiesUpdated( - List entities, + List> entities, ChangeDescription changeDescription, SubjectContext subjectContext) { onEntitiesUpdated(entities, changeDescription, subjectContext, EntityUpdateContext.empty()); @@ -192,7 +194,7 @@ public void onEntitiesUpdated( @Override public void onEntitiesUpdated( - List entities, + List> entities, ChangeDescription changeDescription, SubjectContext subjectContext, EntityUpdateContext updateContext) { @@ -210,7 +212,7 @@ public void onEntitiesUpdated( LOG.debug("Successfully updated search indexes for {} entities", entities.size()); } catch (Exception e) { LOG.error("Failed to bulk update search indexes for {} entities", entities.size(), e); - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { Long relationshipRevision = effectiveContext.relationshipRevisions().get(entity.getId()); if (relationshipRevision == null) { onEntityUpdated( diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/events/subscription/AlertsRuleEvaluator.java b/openmetadata-service/src/main/java/org/openmetadata/service/events/subscription/AlertsRuleEvaluator.java index 98465746ef4f..5ec7df0fb285 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/events/subscription/AlertsRuleEvaluator.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/events/subscription/AlertsRuleEvaluator.java @@ -146,7 +146,7 @@ public boolean matchAnyOwnerName(List ownerNameList) { } private boolean matchesEntityOrTestSuiteOwner( - EntityInterface entity, List ownerNameList) { + EntityInterface entity, List ownerNameList) { List ownerReferences = resolveOwners(entity); boolean matched = false; if (!nullOrEmpty(ownerReferences)) { @@ -161,11 +161,11 @@ private boolean matchesEntityOrTestSuiteOwner( return matched; } - private List resolveOwners(EntityInterface entity) { + private List resolveOwners(EntityInterface entity) { List ownerReferences = entity.getOwners(); if (nullOrEmpty(ownerReferences) && supports(changeEvent.getEntityType(), EntityRepository::isSupportsOwners)) { - EntityInterface storedEntity = readStoredEntity(entity.getId(), Entity.FIELD_OWNERS); + EntityInterface storedEntity = readStoredEntity(entity.getId(), Entity.FIELD_OWNERS); ownerReferences = storedEntity == null ? ownerReferences : storedEntity.getOwners(); } return ownerReferences; @@ -189,7 +189,7 @@ public boolean matchAnyEntityFqn(List entityFqns) { return feedSubjectMatchesFqn(entityFqns); } - EntityInterface entity = getEntity(changeEvent); + EntityInterface entity = getEntity(changeEvent); if (matchesFqnOrDescendant(entity.getFullyQualifiedName(), entityFqns)) { return true; } @@ -494,10 +494,11 @@ public boolean matchAnyDomain(List fieldChangeUpdate) { return matched; } - private boolean matchesEntityOrTestSuiteDomain(EntityInterface entity, List domainFqns) { + private boolean matchesEntityOrTestSuiteDomain( + EntityInterface entity, List domainFqns) { List domains = entity.getDomains(); if (supports(changeEvent.getEntityType(), EntityRepository::isSupportsDomains)) { - EntityInterface storedEntity = readStoredEntity(entity.getId(), Entity.FIELD_DOMAINS); + EntityInterface storedEntity = readStoredEntity(entity.getId(), Entity.FIELD_DOMAINS); domains = storedEntity == null ? domains : storedEntity.getDomains(); } boolean matched = matchesAnyDomainFqn(domains, domainFqns); @@ -531,7 +532,7 @@ private boolean matchesAnyDomainFqn(List domains, List * lookup must not abort the whole subscription then (issue #29674) and callers fall back to the * payload instead. */ - private T readStoredEntity(UUID entityId, String fields) { + private > T readStoredEntity(UUID entityId, String fields) { return Entity.getEntityOrNull( changeEvent.getEntityType(), entityId, fields, DELETED_TOLERANT_SUBJECT); } @@ -561,11 +562,11 @@ private List resolveTestSuites(TestCase testCase, String fields) { return listOrEmpty(testSuites); } - public static EntityInterface getEntity(ChangeEvent event) { - Class entityClass = + public static EntityInterface getEntity(ChangeEvent event) { + Class> entityClass = Entity.getEntityClassFromType(event.getEntityType()); if (entityClass != null) { - EntityInterface entity; + EntityInterface entity; if (event.getEntity() instanceof String str) { entity = JsonUtils.readValue(str, entityClass); } else { @@ -775,7 +776,7 @@ private boolean isFeedEvent() { } // The event's entity of entityType: the entity itself, or for a comment, the entity it is on. - private EntityInterface eventEntityOfType(String entityType) { + private EntityInterface eventEntityOfType(String entityType) { if (changeEvent == null || changeEvent.getEntity() == null) { return null; } @@ -786,7 +787,7 @@ private EntityInterface eventEntityOfType(String entityType) { }; } - private EntityInterface feedSubjectOfType(String entityType) { + private EntityInterface feedSubjectOfType(String entityType) { EntityReference subject = feedSubject(); return subject != null && entityType.equals(subject.getType()) ? Entity.getEntityOrNull(subject, "", Include.NON_DELETED) @@ -831,7 +832,7 @@ private static UUID parseUuidOrNull(String id) { } private boolean feedSubjectMatchesOwner(List ownerNameList) { - EntityInterface subject = + EntityInterface subject = readFeedSubject(Entity.FIELD_OWNERS, EntityRepository::isSupportsOwners); return subject != null && !nullOrEmpty(subject.getOwners()) @@ -839,15 +840,16 @@ private boolean feedSubjectMatchesOwner(List ownerNameList) { } private boolean feedSubjectMatchesDomain(List domainFqns) { - EntityInterface subject = + EntityInterface subject = readFeedSubject(Entity.FIELD_DOMAINS, EntityRepository::isSupportsDomains); return subject != null && matchesAnyDomainFqn(subject.getDomains(), domainFqns); } /** The feed's subject read with {@code field}, or null when its type cannot supply that field. */ - private EntityInterface readFeedSubject(String field, Predicate> capability) { + private EntityInterface readFeedSubject( + String field, Predicate> capability) { EntityReference subject = feedSubject(); - EntityInterface entity = null; + EntityInterface entity = null; if (subject != null && supports(subject.getType(), capability)) { entity = Entity.getEntityOrNull(subject, field, Include.NON_DELETED); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/formatter/decorators/MessageDecorator.java b/openmetadata-service/src/main/java/org/openmetadata/service/formatter/decorators/MessageDecorator.java index cf4f499c2e28..bfaf565a2a0f 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/formatter/decorators/MessageDecorator.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/formatter/decorators/MessageDecorator.java @@ -87,7 +87,7 @@ default String httpRemoveMarker() { T buildTestMessage(); @SneakyThrows - default String buildEntityUrl(String entityType, EntityInterface entityInterface) { + default String buildEntityUrl(String entityType, EntityInterface entityInterface) { String fqn = resolveFullyQualifiedName(entityType, entityInterface); String entityUrl = ""; switch (entityType) { @@ -131,10 +131,10 @@ default String buildEntityUrl(String entityType, EntityInterface entityInterface } // Helper function to resolve FQN if null or empty - private String resolveFullyQualifiedName(String entityType, EntityInterface entityInterface) { + private String resolveFullyQualifiedName(String entityType, EntityInterface entityInterface) { String fqn = entityInterface.getFullyQualifiedName(); if (CommonUtil.nullOrEmpty(fqn)) { - EntityInterface result = + EntityInterface result = Entity.getEntity(entityType, entityInterface.getId(), "id", Include.NON_DELETED); fqn = result.getFullyQualifiedName(); } @@ -152,7 +152,7 @@ static String getFQNForChangeEventEntity(ChangeEvent event) { ? conversation.getId().toString() : conversation.getEntityRef().getFullyQualifiedName(); } else { - EntityInterface entityInterface = getEntity(event); + EntityInterface entityInterface = getEntity(event); return entityInterface.getFullyQualifiedName(); } }); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/formatter/entity/IngestionPipelineFormatter.java b/openmetadata-service/src/main/java/org/openmetadata/service/formatter/entity/IngestionPipelineFormatter.java index d88080921085..ddde12882aed 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/formatter/entity/IngestionPipelineFormatter.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/formatter/entity/IngestionPipelineFormatter.java @@ -50,7 +50,7 @@ public String format( private String transformIngestionPipelineStatus( MessageDecorator messageFormatter, FormattedMessage thread, FieldChange fieldChange) { - EntityInterface entity = + EntityInterface entity = Entity.getEntity( thread.getEntityRef().getType(), thread.getEntityRef().getId(), "id", Include.ALL); String ingestionPipelineName = entity.getName(); @@ -75,7 +75,7 @@ private String transformIngestionPipelineStatus( } public static String getIngestionPipelineUrl( - MessageDecorator formatter, String entityType, EntityInterface entityInterface) { + MessageDecorator formatter, String entityType, EntityInterface entityInterface) { if (entityType.equals(Entity.INGESTION_PIPELINE)) { // Tags need to be redirected to Classification Page IngestionPipeline ingestionPipeline = (IngestionPipeline) entityInterface; @@ -117,7 +117,7 @@ public static String getIngestionPipelineUrl( // Provide the URL of the table the Data Contract belongs to public static String getDataContractUrl( - MessageDecorator formatter, String entityType, EntityInterface entityInterface) { + MessageDecorator formatter, String entityType, EntityInterface entityInterface) { if (entityType.equals(Entity.DATA_CONTRACT)) { DataContract contract = (DataContract) entityInterface; EntityReference tableRef = contract.getEntity(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/formatter/entity/KpiFormatter.java b/openmetadata-service/src/main/java/org/openmetadata/service/formatter/entity/KpiFormatter.java index 9c5e08ff4cb9..060f73ae659b 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/formatter/entity/KpiFormatter.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/formatter/entity/KpiFormatter.java @@ -42,7 +42,7 @@ public String format( private String transformKpiResult( MessageDecorator messageFormatter, FormattedMessage thread, FieldChange fieldChange) { - EntityInterface entity = + EntityInterface entity = Entity.getEntity( thread.getEntityRef().getType(), thread.getEntityRef().getId(), "id", Include.ALL); String kpiName = entity.getName(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/formatter/entity/PipelineFormatter.java b/openmetadata-service/src/main/java/org/openmetadata/service/formatter/entity/PipelineFormatter.java index fc35caed2a56..fa1463e3252c 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/formatter/entity/PipelineFormatter.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/formatter/entity/PipelineFormatter.java @@ -45,7 +45,7 @@ public String format( private String transformPipelineStatus( MessageDecorator messageFormatter, FormattedMessage thread, FieldChange fieldChange) { - EntityInterface entity = + EntityInterface entity = Entity.getEntity( thread.getEntityRef().getType(), thread.getEntityRef().getId(), "id", Include.ALL); String pipelineName = entity.getName(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/formatter/util/ActivityMessageFormatter.java b/openmetadata-service/src/main/java/org/openmetadata/service/formatter/util/ActivityMessageFormatter.java index 2d2b01a7762c..380c383b4a8f 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/formatter/util/ActivityMessageFormatter.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/formatter/util/ActivityMessageFormatter.java @@ -50,7 +50,7 @@ public static List format( private static List formatEntityChange( MessageDecorator messageDecorator, ChangeEvent changeEvent) { String message; - EntityInterface entity = getEntity(changeEvent); + EntityInterface entity = getEntity(changeEvent); MessageParser.EntityLink about = new MessageParser.EntityLink( changeEvent.getEntityType(), entity.getFullyQualifiedName(), null, null, null); @@ -113,7 +113,7 @@ private static void addEntityInfo( FormattedMessage formattedMessage, FormattedMessage.CardStyle cardStyle, String message, - EntityInterface entity) { + EntityInterface entity) { formattedMessage .withMessage(message) .withCardStyle(cardStyle) @@ -127,7 +127,7 @@ private static void addEntityInfo( private static FormattedMessage createMessage( MessageDecorator decorator, - EntityInterface entity, + EntityInterface entity, String linkString, String entityType, String updatedBy) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/formatter/util/FormatterUtil.java b/openmetadata-service/src/main/java/org/openmetadata/service/formatter/util/FormatterUtil.java index 6e7d52e9f2c7..e799289f1c3b 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/formatter/util/FormatterUtil.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/formatter/util/FormatterUtil.java @@ -246,7 +246,7 @@ private static ChangeEvent extractChangeEvent( } // If the response entity is an EntityInterface, then create a ChangeEvent from it - if (responseContext.getEntity() instanceof EntityInterface entityInterface) { + if (responseContext.getEntity() instanceof EntityInterface entityInterface) { return createChangeEventForEntity(updateBy, eventType, entityInterface); } @@ -268,7 +268,7 @@ private static ChangeEvent extractChangeEvent( } public static ChangeEvent createChangeEventForEntity( - String updateBy, EventType eventType, EntityInterface entityInterface) { + String updateBy, EventType eventType, EntityInterface entityInterface) { return getChangeEvent( updateBy, eventType, entityInterface.getEntityReference().getType(), entityInterface) .withPreviousVersion( @@ -297,7 +297,7 @@ private static Optional getEventTypeFromResponse( } private static ChangeEvent getChangeEvent( - String updateBy, EventType eventType, String entityType, EntityInterface entityInterface) { + String updateBy, EventType eventType, String entityType, EntityInterface entityInterface) { return new ChangeEvent() .withId(UUID.randomUUID()) .withEventType(eventType) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/EntityLifecycle.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/EntityLifecycle.java index 9f1b180d5f5f..64cd1992250e 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/EntityLifecycle.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/EntityLifecycle.java @@ -3,76 +3,76 @@ import java.util.Collections; import java.util.EnumMap; import java.util.EnumSet; +import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Set; import org.openmetadata.schema.type.EntityStatus; -/** - * The lifecycle stages an entity type uses and the moves allowed between them. Every type draws its - * stages from the shared {@link EntityStatus} vocabulary. Most use the general stages and can move - * between any of them; a type with a lifecycle of its own declares the stages it uses, including - * any that only it has, and each stage's next stages. - */ -public record EntityLifecycle(Map> transitions) { - /** - * The stages a type uses unless it declares its own lifecycle. A stage added to the vocabulary for - * one type is not among them, so it stays out of every lifecycle that does not declare it. - */ +/** A lifecycle policy using the status vocabulary generated from its entity's schema. */ +public record EntityLifecycle>( + EntityStatusAdapter adapter, Map> transitions) { public static final Set GENERAL_STAGES = - Collections.unmodifiableSet( - EnumSet.of( - EntityStatus.DRAFT, - EntityStatus.IN_REVIEW, - EntityStatus.APPROVED, - EntityStatus.ARCHIVED, - EntityStatus.DEPRECATED, - EntityStatus.REJECTED, - EntityStatus.UNPROCESSED)); + Collections.unmodifiableSet(EnumSet.allOf(EntityStatus.class)); + public static final EntityLifecycle GENERAL = anyMoveBetween(EntityStatus.class); - /** Any move between the general stages. */ - public static final EntityLifecycle GENERAL = anyMoveBetween(GENERAL_STAGES); + public EntityLifecycle(Class statusType, Map> transitions) { + this(new EntityStatusAdapter<>(statusType), transitions); + } - /** Each stage the type uses, mapped to the stages it can move to; a final stage maps to none. */ public EntityLifecycle { - Map> copy = new EnumMap<>(EntityStatus.class); - transitions.forEach((from, to) -> copy.put(from, unmodifiableStages(to))); + Map> copy = new EnumMap<>(adapter.statusType()); + transitions.forEach((from, to) -> copy.put(from, Set.copyOf(to))); requireMovesBetweenOwnStages(copy); + requireSchemaVocabulary(adapter, copy.keySet()); transitions = Collections.unmodifiableMap(copy); } - public Set stages() { + public Set stages() { return transitions.keySet(); } - public boolean includes(EntityStatus stage) { + public List stageCodes() { + return adapter.codes(); + } + + public Map> transitionCodes() { + Map> codes = new LinkedHashMap<>(); + transitions.forEach( + (from, to) -> + codes.put(adapter.code(from), to.stream().map(adapter::code).sorted().toList())); + return Collections.unmodifiableMap(codes); + } + + public boolean includes(S stage) { return transitions.containsKey(stage); } - /** Whether an entity can move between two stages; one saved without a stage can take any. */ - public boolean allows(EntityStatus from, EntityStatus to) { + public boolean includesCode(String code) { + return stageCodes().contains(code); + } + + public boolean allows(S from, S to) { return from == null ? includes(to) : transitions.getOrDefault(from, Set.of()).contains(to); } - private static EntityLifecycle anyMoveBetween(Set stages) { - Map> transitions = new EnumMap<>(EntityStatus.class); - for (EntityStatus from : stages) { - Set to = EnumSet.copyOf(stages); + public boolean allowsCodes(String from, String to) { + return includesCode(to) + && (from == null + || (includesCode(from) && allows(adapter.resolve(from), adapter.resolve(to)))); + } + + private static > EntityLifecycle anyMoveBetween(Class statusType) { + Map> transitions = new EnumMap<>(statusType); + for (S from : statusType.getEnumConstants()) { + Set to = EnumSet.allOf(statusType); to.remove(from); transitions.put(from, to); } - return new EntityLifecycle(transitions); - } - - private static Set unmodifiableStages(Set stages) { - Set copy = EnumSet.noneOf(EntityStatus.class); - copy.addAll(stages); - return Collections.unmodifiableSet(copy); + return new EntityLifecycle<>(statusType, transitions); } - // A declaration that moves to a stage it does not list is a mistake in the code declaring it, - // so it fails when the lifecycle is built rather than when an entity first takes that move. - private static void requireMovesBetweenOwnStages( - Map> transitions) { + private static > void requireMovesBetweenOwnStages(Map> transitions) { transitions.values().stream() .flatMap(Set::stream) .filter(stage -> !transitions.containsKey(stage)) @@ -80,8 +80,18 @@ private static void requireMovesBetweenOwnStages( .ifPresent( stage -> { throw new IllegalArgumentException( - "A lifecycle can only move between its own stages, but one moves to " - + stage.value()); + "A lifecycle can only move between its own stages, but one moves to " + stage); }); } + + private static > void requireSchemaVocabulary( + EntityStatusAdapter adapter, Set stages) { + if (!stages.equals(Set.copyOf(adapter.statuses()))) { + throw new IllegalArgumentException( + "Lifecycle stages must match " + + adapter.statusType().getSimpleName() + + " schema vocabulary: " + + adapter.codes()); + } + } } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/EntityStatusAdapter.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/EntityStatusAdapter.java new file mode 100644 index 000000000000..3560a9bcef21 --- /dev/null +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/EntityStatusAdapter.java @@ -0,0 +1,89 @@ +package org.openmetadata.service.governance; + +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import org.openmetadata.schema.EntityInterface; + +/** Converts a policy's generated enum to wire codes at shared lifecycle boundaries. */ +public record EntityStatusAdapter>(Class statusType) { + public EntityStatusAdapter { + Objects.requireNonNull(statusType, "A lifecycle requires its generated status enum"); + if (!statusType.isEnum()) { + throw new IllegalArgumentException("Lifecycle status must be an enum: " + statusType); + } + } + + public List statuses() { + return List.of(statusType.getEnumConstants()); + } + + public List codes() { + return statuses().stream().map(this::code).toList(); + } + + public String code(Enum status) { + return status == null ? null : statusType.cast(status).toString(); + } + + public S resolve(String code) { + String normalized = code == null ? "" : code.trim(); + return Arrays.stream(statusType.getEnumConstants()) + .filter(status -> status.toString().equalsIgnoreCase(normalized)) + .findFirst() + .orElseThrow( + () -> + new IllegalArgumentException( + "Unknown " + statusType.getSimpleName() + " value: " + code)); + } + + public String read(EntityInterface entity) { + return code(entity.getEntityStatus()); + } + + public void write(EntityInterface entity, String code) { + requireEntityType(entity.getClass()); + writeChecked(entity, code == null ? null : resolve(code)); + } + + public void requireEntityType(Class entityType) { + try { + Class declaredStatus = entityType.getMethod("getEntityStatus").getReturnType(); + if (!statusType.equals(declaredStatus)) { + throw new IllegalArgumentException( + entityType.getSimpleName() + + " declares " + + declaredStatus.getSimpleName() + + ", but its lifecycle uses " + + statusType.getSimpleName()); + } + } catch (NoSuchMethodException exception) { + throw new IllegalArgumentException( + "Entity has no lifecycle status: " + entityType, exception); + } + } + + public static EntityStatusAdapter forEntityType(Class entityType) { + try { + return forStatusType(entityType.getMethod("getEntityStatus").getReturnType()); + } catch (NoSuchMethodException exception) { + throw new IllegalArgumentException( + "Entity has no lifecycle status: " + entityType, exception); + } + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + private static EntityStatusAdapter forStatusType(Class statusType) { + if (!statusType.isEnum()) { + throw new IllegalArgumentException("Entity has no declared status enum: " + statusType); + } + return new EntityStatusAdapter((Class) statusType); + } + + // The generated getter's return type is checked before crossing the heterogeneous entity + // boundary. + @SuppressWarnings("unchecked") + private void writeChecked(EntityInterface entity, S status) { + ((EntityInterface) entity).setEntityStatus(status); + } +} diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/EntityStatusWorkflows.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/EntityStatusWorkflows.java index 794c00873389..b0f0611f3fa8 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/EntityStatusWorkflows.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/EntityStatusWorkflows.java @@ -65,7 +65,7 @@ public List owningStageOf(String entityType) { } @Override - public Optional owningStageOf(String entityType, EntityInterface entity) { + public Optional owningStageOf(String entityType, EntityInterface entity) { return ACTIVE_STAGE_WORKFLOWS.get(ACTIVE_STAGE_WORKFLOWS_KEY).stream() .filter(workflow -> appliesTo(workflow, entityType, entity)) .map(WorkflowDefinition::getName) @@ -74,7 +74,7 @@ public Optional owningStageOf(String entityType, EntityInterface entity) } /** Workflows change entities as, or impersonating, the governance bot. */ - public static boolean isWorkflowChange(EntityInterface entity) { + public static boolean isWorkflowChange(EntityInterface entity) { return GOVERNANCE_BOT.equals(entity.getUpdatedBy()) || GOVERNANCE_BOT.equals(entity.getImpersonatedBy()); } @@ -95,12 +95,13 @@ static boolean startsOn(WorkflowDefinition workflow, String entityType) { && triggerEntityTypes(trigger.getConfig()).contains(entityType); } - static boolean appliesTo(WorkflowDefinition workflow, String entityType, EntityInterface entity) { + static boolean appliesTo( + WorkflowDefinition workflow, String entityType, EntityInterface entity) { return startsOn(workflow, entityType) && !excludedByTriggerFilter(workflow, entityType, entity); } private static boolean excludedByTriggerFilter( - WorkflowDefinition workflow, String entityType, EntityInterface entity) { + WorkflowDefinition workflow, String entityType, EntityInterface entity) { Object filter = ((EventBasedEntityTriggerDefinition) workflow.getTrigger()).getConfig().getFilter(); return TriggerEntityFilter.excludes( diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/StageOwnership.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/StageOwnership.java index ed5b9d3428ef..2cb290063638 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/StageOwnership.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/StageOwnership.java @@ -10,5 +10,5 @@ public interface StageOwnership { List owningStageOf(String entityType); /** The workflow that owns this entity's stage, honouring each workflow's trigger filter. */ - Optional owningStageOf(String entityType, EntityInterface entity); + Optional owningStageOf(String entityType, EntityInterface entity); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/WorkflowVariableHandler.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/WorkflowVariableHandler.java index c0b3127d2263..4a03879004a1 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/WorkflowVariableHandler.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/WorkflowVariableHandler.java @@ -129,11 +129,11 @@ public void setGlobalVariable(String varName, Object varValue) { * its FQN does, so a stale FQN no longer breaks resolution. The FQN fallback covers in-flight * workflows started before {@code relatedEntityId} was recorded at the trigger. */ - public EntityInterface getRelatedEntity( + public EntityInterface getRelatedEntity( MessageParser.EntityLink entityLink, String fields, Include include) { Object idValue = getNamespacedVariable(GLOBAL_NAMESPACE, RELATED_ENTITY_ID_VARIABLE); String relatedEntityId = idValue != null ? idValue.toString() : null; - EntityInterface entity; + EntityInterface entity; if (nullOrEmpty(relatedEntityId)) { entity = Entity.getEntity(entityLink, fields, include); } else { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/CheckChangeDescriptionTaskImpl.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/CheckChangeDescriptionTaskImpl.java index 060592bbc18a..6ec81844a8bb 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/CheckChangeDescriptionTaskImpl.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/CheckChangeDescriptionTaskImpl.java @@ -55,7 +55,7 @@ public void execute(DelegateExecution execution) { private boolean checkChangeDescription(DelegateExecution execution, String entityLinkStr) { // Parse entity MessageParser.EntityLink entityLink = MessageParser.EntityLink.parse(entityLinkStr); - EntityInterface entity = Entity.getEntity(entityLink, "", Include.ALL); + EntityInterface entity = Entity.getEntity(entityLink, "", Include.ALL); // No changeDescription means it's a create event - return true ChangeDescription changeDescription = entity.getChangeDescription(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/CheckEntityAttributesImpl.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/CheckEntityAttributesImpl.java index 4fd0942f405c..acd2142fa832 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/CheckEntityAttributesImpl.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/CheckEntityAttributesImpl.java @@ -56,7 +56,7 @@ public void execute(DelegateExecution execution) { private Boolean checkAttributes( WorkflowVariableHandler varHandler, MessageParser.EntityLink entityLink, String rules) { - EntityInterface entity = varHandler.getRelatedEntity(entityLink, "*", Include.ALL); + EntityInterface entity = varHandler.getRelatedEntity(entityLink, "*", Include.ALL); Map entityMap = JsonUtils.getMap(entity); enrichTransientCounts(entityLink.getEntityType(), entity, entityMap); @@ -70,7 +70,7 @@ private Boolean checkAttributes( } private void enrichTransientCounts( - String entityType, EntityInterface entity, Map entityMap) { + String entityType, EntityInterface entity, Map entityMap) { if (!DATA_PRODUCT.equals(entityType)) { return; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/DataCompletenessImpl.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/DataCompletenessImpl.java index e1f28bd7a71c..95736c50d676 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/DataCompletenessImpl.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/DataCompletenessImpl.java @@ -56,7 +56,7 @@ public void execute(DelegateExecution execution) { inputNamespaces.namespaceFor(RELATED_ENTITY_VARIABLE), RELATED_ENTITY_VARIABLE)); - EntityInterface entity = Entity.getEntity(entityLink, "*", Include.ALL); + EntityInterface entity = Entity.getEntity(entityLink, "*", Include.ALL); Map entityMap = JsonUtils.getMap(entity); // Calculate completeness diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/RollbackEntityImpl.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/RollbackEntityImpl.java index f591b2770aa6..a2b438bc4f2c 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/RollbackEntityImpl.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/RollbackEntityImpl.java @@ -35,6 +35,7 @@ import org.openmetadata.schema.utils.JsonUtils; import org.openmetadata.service.Entity; import org.openmetadata.service.exception.EntityNotFoundException; +import org.openmetadata.service.governance.EntityStatusAdapter; import org.openmetadata.service.governance.workflows.WorkflowVariableHandler; import org.openmetadata.service.governance.workflows.WorkflowVariableHandler.InputNamespaces; import org.openmetadata.service.jdbi3.EntityRepository; @@ -73,7 +74,7 @@ public void execute(DelegateExecution execution) { } RejectionOutcome applyRejection( - EntityRepository repository, EntityInterface currentEntity, String updatedBy) { + EntityRepository repository, EntityInterface currentEntity, String updatedBy) { Optional approvedVersion = findMostRecentApprovedVersion(currentEntity, repository); RejectionOutcome outcome; @@ -89,11 +90,11 @@ RejectionOutcome applyRejection( } Optional findMostRecentApprovedVersion( - EntityInterface currentEntity, EntityRepository repository) { + EntityInterface currentEntity, EntityRepository repository) { List earlierVersions = earlierVersions(currentEntity, repository); Optional approvedVersion = Optional.empty(); for (Double version : earlierVersions) { - EntityInterface versionEntity = + EntityInterface versionEntity = repository.getVersion(currentEntity.getId(), version.toString()); if (isApprovedBaseline(versionEntity)) { approvedVersion = Optional.of(new ApprovedVersion(version, versionEntity)); @@ -107,7 +108,7 @@ private RollbackContext createContext(DelegateExecution execution) { WorkflowVariableHandler variableHandler = new WorkflowVariableHandler(execution); InputNamespaces namespaces = InputNamespaces.from(inputNamespaceMapExpr, execution); MessageParser.EntityLink entityLink = relatedEntityLink(variableHandler, namespaces); - EntityInterface entity = variableHandler.getRelatedEntity(entityLink, "", Include.ALL); + EntityInterface entity = variableHandler.getRelatedEntity(entityLink, "", Include.ALL); String updatedBy = updatedBy(variableHandler, namespaces); String entityType = entityLink.getEntityType(); EntityRepository repository = Entity.getEntityRepository(entityType); @@ -129,7 +130,7 @@ private String updatedBy(WorkflowVariableHandler variableHandler, InputNamespace } private List earlierVersions( - EntityInterface currentEntity, EntityRepository repository) { + EntityInterface currentEntity, EntityRepository repository) { EntityHistory history = repository.listVersions(currentEntity.getId()); List versions = new ArrayList<>(); for (Object serializedVersion : history.getVersions()) { @@ -141,14 +142,15 @@ private List earlierVersions( return versions; } - private Optional parsedVersion(Object serializedVersion, EntityInterface currentEntity) { + private Optional parsedVersion( + Object serializedVersion, EntityInterface currentEntity) { Optional version; try { String json = serializedVersion instanceof String serialized ? serialized : JsonUtils.pojoToJson(serializedVersion); - EntityInterface entity = JsonUtils.readValue(json, currentEntity.getClass()); + EntityInterface entity = JsonUtils.readValue(json, currentEntity.getClass()); version = Optional.ofNullable(entity.getVersion()); } catch (RuntimeException exception) { LOG.warn("[RollbackEntity] Ignoring an unreadable entity version", exception); @@ -157,10 +159,13 @@ private Optional parsedVersion(Object serializedVersion, EntityInterface return version; } - private boolean isApprovedBaseline(EntityInterface entity) { + private boolean isApprovedBaseline(EntityInterface entity) { // A non-reviewer edit inherits Approved until its asynchronous workflow marks it In Review. // Only an actual approval event (or reviewer-authored change) is safe to restore later. - boolean isApproved = entity.getEntityStatus() == EntityStatus.APPROVED; + boolean isApproved = + EntityStatus.APPROVED + .value() + .equals(EntityStatusAdapter.forEntityType(entity.getClass()).read(entity)); boolean hasDurableApproval = nullOrEmpty(entity.getReviewers()) || recordsApprovalTransition(entity) @@ -168,7 +173,7 @@ private boolean isApprovedBaseline(EntityInterface entity) { return isApproved && hasDurableApproval; } - private boolean recordsApprovalTransition(EntityInterface entity) { + private boolean recordsApprovalTransition(EntityInterface entity) { ChangeDescription change = entity.getIncrementalChangeDescription(); if (change == null) { change = entity.getChangeDescription(); @@ -182,7 +187,7 @@ private boolean setsApprovedStatus(FieldChange change) { && EntityStatus.APPROVED.value().equals(String.valueOf(change.getNewValue())); } - private boolean wasUpdatedByReviewer(EntityInterface entity) { + private boolean wasUpdatedByReviewer(EntityInterface entity) { List reviewers = entity.getReviewers(); String updatedBy = entity.getUpdatedBy(); boolean isReviewer = false; @@ -216,38 +221,42 @@ private boolean belongsToReviewerTeam(String user, List reviewe private void restoreToApprovedVersion( EntityRepository repository, - EntityInterface currentEntity, - EntityInterface approvedEntity, + EntityInterface currentEntity, + EntityInterface approvedEntity, String updatedBy) { - EntityInterface persistedCurrent = persistedCurrentVersion(repository, currentEntity); + EntityInterface persistedCurrent = persistedCurrentVersion(repository, currentEntity); applyPatch(repository, persistedCurrent, approvedEntity, updatedBy); } private void rejectCurrentVersion( - EntityRepository repository, EntityInterface currentEntity, String updatedBy) { - EntityInterface persistedCurrent = persistedCurrentVersion(repository, currentEntity); + EntityRepository repository, EntityInterface currentEntity, String updatedBy) { + EntityInterface persistedCurrent = persistedCurrentVersion(repository, currentEntity); String currentJson = JsonUtils.pojoToJson(persistedCurrent); - EntityInterface rejectedEntity = JsonUtils.readValue(currentJson, persistedCurrent.getClass()); + EntityInterface rejectedEntity = + JsonUtils.readValue(currentJson, persistedCurrent.getClass()); setRejectedStatus(rejectedEntity); applyPatch(repository, persistedCurrent, rejectedEntity, updatedBy); } - private EntityInterface persistedCurrentVersion( - EntityRepository repository, EntityInterface currentEntity) { + private EntityInterface persistedCurrentVersion( + EntityRepository repository, EntityInterface currentEntity) { return repository.getVersion(currentEntity.getId(), currentEntity.getVersion().toString()); } - private void setRejectedStatus(EntityInterface entity) { - entity.setEntityStatus(EntityStatus.REJECTED); - if (entity.getEntityStatus() != EntityStatus.REJECTED) { + private void setRejectedStatus(EntityInterface entity) { + EntityStatusAdapter.forEntityType(entity.getClass()) + .write(entity, EntityStatus.REJECTED.value()); + if (!EntityStatus.REJECTED + .value() + .equals(EntityStatusAdapter.forEntityType(entity.getClass()).read(entity))) { throw new IllegalStateException("Entity does not support a rejected approval status"); } } private void applyPatch( EntityRepository repository, - EntityInterface currentEntity, - EntityInterface targetEntity, + EntityInterface currentEntity, + EntityInterface targetEntity, String updatedBy) { JsonPatch patch = JsonUtils.getJsonPatch( @@ -269,7 +278,7 @@ private void setOutcomeVariables( execution.setVariable(ROLLBACK_ENTITY_TYPE_VARIABLE, context.entityType()); } - record ApprovedVersion(Double version, EntityInterface entity) {} + record ApprovedVersion(Double version, EntityInterface entity) {} record RejectionOutcome(String action, Double fromVersion, Double toVersion) { private static RejectionOutcome rolledBack(Double fromVersion, Double toVersion) { @@ -282,7 +291,7 @@ private static RejectionOutcome rejected(Double fromVersion) { } private record RollbackContext( - EntityInterface currentEntity, + EntityInterface currentEntity, EntityRepository repository, String entityType, String updatedBy) {} diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/SetEntityAttributeImpl.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/SetEntityAttributeImpl.java index a4a32c2366c8..116aa33d3917 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/SetEntityAttributeImpl.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/SetEntityAttributeImpl.java @@ -38,7 +38,7 @@ public void execute(DelegateExecution execution) { MessageParser.EntityLink entityLink = MessageParser.EntityLink.parse(relatedEntityValue); String entityType = entityLink.getEntityType(); - EntityInterface entity = varHandler.getRelatedEntity(entityLink, "*", Include.ALL); + EntityInterface entity = varHandler.getRelatedEntity(entityLink, "*", Include.ALL); String fieldName = fieldNameExpr != null ? (String) fieldNameExpr.getValue(execution) : ""; diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/SetEntityCertificationImpl.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/SetEntityCertificationImpl.java index 0bb2ec994b02..0d459bf2ddfc 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/SetEntityCertificationImpl.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/SetEntityCertificationImpl.java @@ -43,7 +43,7 @@ public void execute(DelegateExecution execution) { inputNamespaces.namespaceFor(RELATED_ENTITY_VARIABLE), RELATED_ENTITY_VARIABLE)); String entityType = entityLink.getEntityType(); - EntityInterface entity = Entity.getEntity(entityLink, "certification", Include.ALL); + EntityInterface entity = Entity.getEntity(entityLink, "certification", Include.ALL); String certification = Optional.ofNullable(certificationExpr) @@ -66,7 +66,7 @@ public void execute(DelegateExecution execution) { } private void setStatus( - EntityInterface entity, String entityType, String user, String certification) { + EntityInterface entity, String entityType, String user, String certification) { String originalJson = JsonUtils.pojoToJson(entity); Optional oCertification = Optional.ofNullable(certification); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/SinkProvider.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/SinkProvider.java index 8383d5f1779f..97250adfad58 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/SinkProvider.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/SinkProvider.java @@ -39,7 +39,7 @@ public interface SinkProvider { * @param entity the entity to write * @return the result of the write operation */ - SinkResult write(SinkContext context, EntityInterface entity); + SinkResult write(SinkContext context, EntityInterface entity); /** * Writes multiple entities to the sink destination in a batch operation. @@ -51,7 +51,7 @@ public interface SinkProvider { * @param entities the list of entities to write * @return the result of the batch write operation */ - SinkResult writeBatch(SinkContext context, List entities); + SinkResult writeBatch(SinkContext context, List> entities); /** * Releases any resources held by the sink provider. diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/SinkTaskDelegate.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/SinkTaskDelegate.java index 6070c0f62591..c8e529167042 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/SinkTaskDelegate.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/SinkTaskDelegate.java @@ -235,7 +235,7 @@ BatchAccumulator merge(SinkResult result, List fetchErrors // Fetch entities for this sub-batch List fetchErrors = new ArrayList<>(); - List entities = new ArrayList<>(); + List> entities = new ArrayList<>(); for (String entityLinkStr : subBatch) { try { var entityLink = MessageParser.EntityLink.parse(entityLinkStr); @@ -293,7 +293,7 @@ private SinkResult executeSingleEntityMode( MessageParser.EntityLink entityLink = MessageParser.EntityLink.parse(relatedEntityValue); String fields = String.join(",", ReindexingUtil.getSearchIndexFields(entityLink.getEntityType())); - EntityInterface entity = Entity.getEntity(entityLink, fields, Include.ALL); + EntityInterface entity = Entity.getEntity(entityLink, fields, Include.ALL); LOG.info( "[{}] Executing single entity sink for: {}", diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/providers/WebhookSinkProvider.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/providers/WebhookSinkProvider.java index f75100f957b5..a024f0a132c9 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/providers/WebhookSinkProvider.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/providers/WebhookSinkProvider.java @@ -69,7 +69,7 @@ public String getSinkType() { } @Override - public SinkResult write(SinkContext context, EntityInterface entity) { + public SinkResult write(SinkContext context, EntityInterface entity) { try { String payload = serializeEntity(entity, context.getOutputFormat()); return executeWithRetry( @@ -113,11 +113,11 @@ public SinkResult write(SinkContext context, EntityInterface entity) { } @Override - public SinkResult writeBatch(SinkContext context, List entities) { + public SinkResult writeBatch(SinkContext context, List> entities) { List synced = new ArrayList<>(); List errors = new ArrayList<>(); - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { try { String payload = serializeEntity(entity, context.getOutputFormat()); SinkResult result = @@ -269,7 +269,7 @@ public void close() { } } - private String serializeEntity(EntityInterface entity, String format) { + private String serializeEntity(EntityInterface entity, String format) { if ("yaml".equalsIgnoreCase(format)) { try { return YAML_MAPPER.writeValueAsString(entity); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/CreateTask.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/CreateTask.java index 9b5aa4bdcc03..a008206eee38 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/CreateTask.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/CreateTask.java @@ -137,7 +137,7 @@ public void notify(DelegateTask delegateTask) { varHandler.getNamespacedVariable( inputNamespaces.namespaceFor(RELATED_ENTITY_VARIABLE), RELATED_ENTITY_VARIABLE)); - EntityInterface entity = Entity.getEntity(entityLink, "*", Include.ALL); + EntityInterface entity = Entity.getEntity(entityLink, "*", Include.ALL); // Get approval threshold, default to 1 if not set Integer approvalThreshold = @@ -384,7 +384,7 @@ private EntityReference getEntityReferenceFromLinkString(String entityLinkString private Task createOrUpdateTask( DelegateTask delegateTask, - EntityInterface entity, + EntityInterface entity, List assignees, TaskEntityType taskType, TaskCategory taskCategory, @@ -706,7 +706,7 @@ private Task createOrUpdateTask( private void supersedePriorApprovalTask( DelegateTask delegateTask, TaskRepository taskRepository, - EntityInterface entity, + EntityInterface entity, TaskCategory taskCategory, UUID currentWorkflowDefinitionId, UUID currentWorkflowInstanceId, @@ -744,7 +744,7 @@ private void supersedePriorApprovalTask( */ static Object findPriorOpenApprovalPayload( TaskRepository taskRepository, - EntityInterface entity, + EntityInterface entity, TaskCategory taskCategory, UUID currentWorkflowDefinitionId, UUID currentWorkflowInstanceId) { @@ -1049,7 +1049,7 @@ private static DataAccessRequestPayload readDataAccessRequestPayload(Object payl * description. */ static Object applyProposedChangesIfApproval( - TaskEntityType taskType, EntityInterface entity, Object payload) { + TaskEntityType taskType, EntityInterface entity, Object payload) { if (taskType != TaskEntityType.GlossaryApproval && taskType != TaskEntityType.RequestApproval) { return payload; } @@ -1081,7 +1081,7 @@ private TaskPriority resolveTaskPriority(DelegateTask delegateTask) { return TaskPriority.fromValue(priority); } - private String buildTaskDescription(EntityInterface entity, TaskEntityType taskType) { + private String buildTaskDescription(EntityInterface entity, TaskEntityType taskType) { return String.format("Approval required for %s", entity.getName()); } @@ -1125,7 +1125,7 @@ static Object mergeManualGrantReason(Object payload, String reason) { private EntityReference resolveCreatedByReference( EntityReference requestedCreatedBy, - EntityInterface entity, + EntityInterface entity, Object payload, TaskEntityType taskType) { if (requestedCreatedBy != null && requestedCreatedBy.getId() != null) { @@ -1178,7 +1178,7 @@ private static RecognizerFeedbackTaskPayload readRecognizerFeedbackTaskPayload(O } } - private String resolveUpdatedBy(EntityInterface entity, EntityReference createdByRef) { + private String resolveUpdatedBy(EntityInterface entity, EntityReference createdByRef) { if (entity != null && entity.getUpdatedBy() != null && !entity.getUpdatedBy().isEmpty()) { return entity.getUpdatedBy(); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/impl/SetApprovalAssigneesImpl.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/impl/SetApprovalAssigneesImpl.java index ae955c4e271b..4d41dfa14968 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/impl/SetApprovalAssigneesImpl.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/impl/SetApprovalAssigneesImpl.java @@ -69,7 +69,7 @@ public void execute(DelegateExecution execution) { String relationshipFields = getRelationshipFieldsForAssigneeResolution( entityLink.getEntityType(), entitySupportsReviewers); - EntityInterface entity = Entity.getEntity(entityLink, relationshipFields, Include.ALL); + EntityInterface entity = Entity.getEntity(entityLink, relationshipFields, Include.ALL); Set assignees = new LinkedHashSet<>(); @@ -418,7 +418,7 @@ private String getRelationshipFieldsForAssigneeResolution( } private List resolveEffectiveReviewers( - String entityType, EntityInterface entity) { + String entityType, EntityInterface entity) { if (entity.getReviewers() != null && !entity.getReviewers().isEmpty()) { return entity.getReviewers(); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/triggers/impl/FilterEntityImpl.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/triggers/impl/FilterEntityImpl.java index 413ff842bc3a..98fc39643aac 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/triggers/impl/FilterEntityImpl.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/triggers/impl/FilterEntityImpl.java @@ -138,7 +138,7 @@ private boolean passesExcludedFilter( List includeFields, String filterLogic) { MessageParser.EntityLink entityLink = MessageParser.EntityLink.parse(entityLinkStr); - EntityInterface entity = Entity.getEntity(entityLink, "*", Include.ALL); + EntityInterface entity = Entity.getEntity(entityLink, "*", Include.ALL); boolean fieldBasedFilter; Optional oChangeDescription = diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/triggers/impl/TriggerEntityFilter.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/triggers/impl/TriggerEntityFilter.java index db9736b7dc69..38d77ff43e2c 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/triggers/impl/TriggerEntityFilter.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/triggers/impl/TriggerEntityFilter.java @@ -43,7 +43,7 @@ public static String forEntityType(Object filterConfig, String entityType) { // If the JsonLogic evaluates to TRUE, the entity is excluded from triggering the workflow. // Non-match (FALSE) or unparseable filter (RuleEngine returns false on any exception) means the // entity is NOT excluded, so the workflow triggers. - public static boolean excludes(String filterLogic, EntityInterface entity) { + public static boolean excludes(String filterLogic, EntityInterface entity) { boolean matches = false; if (filterLogic != null && !filterLogic.trim().isEmpty()) { matches = diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/util/ChangePreviewUtils.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/util/ChangePreviewUtils.java index 33ae8fcbec08..c410cb6a05be 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/util/ChangePreviewUtils.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/util/ChangePreviewUtils.java @@ -208,7 +208,8 @@ private static List coerceStringList(Object value) { * change description; returns a payload with the {@code proposedChanges} key removed when the * merged map is empty (e.g. all changes cancelled out across re-edits). */ - public static Object buildProposedChangesPayload(EntityInterface entity, Object existingPayload) { + public static Object buildProposedChangesPayload( + EntityInterface entity, Object existingPayload) { if (entity == null) return existingPayload; ChangeDescription changeDescription = pickIncrementalOrFull(entity); if (hasNoChanges(changeDescription)) { @@ -261,7 +262,7 @@ public static Object buildProposedChangesPayload(EntityInterface entity, Object * Incremental change description always reflects just the latest patch, which is the right * unit of work to fold into the running merge. */ - private static ChangeDescription pickIncrementalOrFull(EntityInterface entity) { + private static ChangeDescription pickIncrementalOrFull(EntityInterface entity) { ChangeDescription incremental = entity.getIncrementalChangeDescription(); if (!hasNoChanges(incremental)) { return incremental; diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/APICollectionRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/APICollectionRepository.java index 5efd6fa8b143..b6bea2ea8601 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/APICollectionRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/APICollectionRepository.java @@ -128,7 +128,7 @@ protected EntityReference getParentReference(APICollection entity) { } @Override - public EntityInterface getParentEntity(APICollection entity, String fields) { + public EntityInterface getParentEntity(APICollection entity, String fields) { if (entity.getService() == null) { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/APIEndpointRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/APIEndpointRepository.java index 753633c91295..5cfcfdd308b5 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/APIEndpointRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/APIEndpointRepository.java @@ -365,14 +365,14 @@ protected String getInheritableFields() { } @Override - protected void applyInheritance(APIEndpoint entity, Fields fields, EntityInterface parent) { + protected void applyInheritance(APIEndpoint entity, Fields fields, EntityInterface parent) { inheritOwners(entity, fields, parent); inheritDomains(entity, fields, parent); inheritTags(entity, fields, parent); } @Override - public EntityInterface getParentEntity(APIEndpoint entity, String fields) { + public EntityInterface getParentEntity(APIEndpoint entity, String fields) { return Entity.getEntity(entity.getApiCollection(), fields, Include.ALL); } @@ -525,7 +525,7 @@ public void validateTags(APIEndpoint entity) { } @Override - public List getAllTags(EntityInterface entity) { + public List getAllTags(EntityInterface entity) { List allTags = new ArrayList<>(); APIEndpoint apiEndpoint = (APIEndpoint) entity; EntityUtil.mergeTags(allTags, apiEndpoint.getTags()); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ActivityStreamRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ActivityStreamRepository.java index 3e670dc42e56..4d517f5552fd 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ActivityStreamRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ActivityStreamRepository.java @@ -126,7 +126,7 @@ public ResultList getEntityActivityByFqn( String domain, int days, int limit) { - EntityInterface entity = Entity.getEntityByName(entityType, fqn, "", null); + EntityInterface entity = Entity.getEntityByName(entityType, fqn, "", null); return getEntityActivityById(securityContext, entityType, entity.getId(), domain, days, limit); } @@ -224,7 +224,7 @@ public ActivityEvent insertForTesting( * @param entity The entity that changed (for extracting domains) * @return The created ActivityEvent */ - public ActivityEvent createFromChangeEvent(ChangeEvent changeEvent, EntityInterface entity) { + public ActivityEvent createFromChangeEvent(ChangeEvent changeEvent, EntityInterface entity) { if (changeEvent == null || entity == null) { return null; } @@ -244,7 +244,7 @@ public ActivityEvent createFromChangeEvent(ChangeEvent changeEvent, EntityInterf * @return List of created ActivityEvents (one per significant field change) */ public List createFieldEventsFromChangeEvent( - ChangeEvent changeEvent, EntityInterface entity) { + ChangeEvent changeEvent, EntityInterface entity) { List events = new ArrayList<>(); if (changeEvent == null || entity == null) { @@ -760,7 +760,7 @@ private List getEffectiveDomainsByFqn(SecurityContext securityContext, Str // ========== Private Helper Methods ========== private ActivityEvent convertChangeEventToActivityEvent( - ChangeEvent changeEvent, EntityInterface entity) { + ChangeEvent changeEvent, EntityInterface entity) { ActivityEventType eventType = mapChangeEventType(changeEvent.getEventType()); if (eventType == null) { return null; @@ -771,7 +771,7 @@ private ActivityEvent convertChangeEventToActivityEvent( private ActivityEvent buildActivityEvent( ChangeEvent changeEvent, - EntityInterface entity, + EntityInterface entity, ActivityEventType eventType, FieldChange fieldChange) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ChangeSummarizer.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ChangeSummarizer.java index 5d0dabaef73e..ff533f1f077d 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ChangeSummarizer.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ChangeSummarizer.java @@ -19,7 +19,7 @@ import org.openmetadata.service.util.FullyQualifiedName; @Slf4j -public class ChangeSummarizer { +public class ChangeSummarizer> { private final Set fields; Class clazz; diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ChartRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ChartRepository.java index 1e9aac2b7a98..98ef0363ca0d 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ChartRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ChartRepository.java @@ -206,7 +206,7 @@ protected EntityReference getParentReference(Chart entity) { } @Override - public EntityInterface getParentEntity(Chart entity, String fields) { + public EntityInterface getParentEntity(Chart entity, String fields) { if (entity.getService() == null) { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ChildFieldPageReader.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ChildFieldPageReader.java index 7fbcd977f894..cfde8258e117 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ChildFieldPageReader.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ChildFieldPageReader.java @@ -27,17 +27,17 @@ public final class ChildFieldPageReader { /** Per-type enrichment of one page: custom metrics, extensions, profiles, PII masking. */ public interface ChildPageEnricher { List enrich( - EntityInterface parent, List page, String fieldsParam); + EntityInterface parent, List page, String fieldsParam); /** For the entity types whose children need nothing beyond tags. */ ChildPageEnricher NONE = (parent, page, fieldsParam) -> page; } - private final EntityRepository repository; + private final EntityRepository> repository; private final ChildFieldResolver.ChildContainerSpec spec; public ChildFieldPageReader( - EntityRepository repository, + EntityRepository> repository, ChildFieldResolver.ChildContainerSpec spec) { this.repository = repository; this.spec = spec; @@ -55,7 +55,7 @@ public ChildFieldPageReader( * always done with an unrecognised value. */ public ResultList read( - EntityInterface parent, + EntityInterface parent, int limit, int offset, String fieldsParam, @@ -100,7 +100,7 @@ private ResultList emptyChildPage(int limit, int offset) { } private ResultList buildChildPage( - EntityInterface parent, + EntityInterface parent, List allChildren, int limit, int offset, diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ClassificationRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ClassificationRepository.java index a8ca07123e6b..b4da876ad09a 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ClassificationRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ClassificationRepository.java @@ -317,7 +317,7 @@ private List listTagsForCsv(Classification classification) { repository.listAllForCSV( repository.getFields("owners,reviewers,parent,domains"), classification.getFullyQualifiedName()); - tags.sort(Comparator.comparing(EntityInterface::getFullyQualifiedName)); + tags.sort(Comparator.comparing(EntityInterface::getFullyQualifiedName)); return tags; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ColumnRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ColumnRepository.java index 5883ccc341f9..eed93eceab79 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ColumnRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ColumnRepository.java @@ -123,7 +123,7 @@ public FieldInterface getChildByFQN( Objects.requireNonNull(columnFQN, "columnFQN cannot be null"); ChildFieldResolver.ChildContainerSpec spec = validateEntityType(entityType); String parentFQN = extractParentFQN(columnFQN, entityType); - EntityInterface parent = fetchAuthorizedParent(securityContext, spec, parentFQN, include); + EntityInterface parent = fetchAuthorizedParent(securityContext, spec, parentFQN, include); ChildFieldResolver.ensureChildFqns(parent, entityType); FieldInterface child = ChildFieldResolver.locate(parent, entityType, columnFQN) @@ -134,14 +134,15 @@ public FieldInterface getChildByFQN( : child; } - private EntityInterface fetchAuthorizedParent( + private EntityInterface fetchAuthorizedParent( SecurityContext securityContext, ChildFieldResolver.ChildContainerSpec spec, String parentFQN, Include include) { String entityType = spec.entityType(); - EntityRepository repository = Entity.getEntityRepository(entityType); - EntityInterface parent = + EntityRepository> repository = + Entity.getEntityRepository(entityType); + EntityInterface parent = repository.getByName( null, parentFQN, @@ -157,7 +158,7 @@ private EntityInterface fetchAuthorizedParent( @SuppressWarnings({"unchecked", "rawtypes"}) private ResourceContextInterface resourceContextFor( - String entityType, EntityInterface entity, EntityRepository repository) { + String entityType, EntityInterface entity, EntityRepository repository) { return new ResourceContext(entityType, entity, repository); } @@ -169,7 +170,7 @@ private ResourceContextInterface resourceContextFor( private Column enrichChild( SecurityContext securityContext, ChildFieldResolver.ChildContainerSpec spec, - EntityInterface parent, + EntityInterface parent, Column column, String fieldsParam) { return switch (spec.entityType()) { @@ -256,16 +257,17 @@ private FieldInterface updateChildByFQN( String parentFQN = extractParentFQN(columnFQN, entityType); EntityReference parentEntityRef = getParentEntityByFQN(parentFQN, entityType); String user = securityContext.getUserPrincipal().getName(); - EntityRepository repository = Entity.getEntityRepository(entityType); + EntityRepository> repository = + Entity.getEntityRepository(entityType); - EntityInterface original = + EntityInterface original = repository.get( null, parentEntityRef.getId(), repository.getFields(spec.requiredFields()), Include.NON_DELETED, false); - EntityInterface updated = deepCopy(original); + EntityInterface updated = deepCopy(original); ChildFieldResolver.ensureChildFqns(updated, entityType); FieldInterface child = @@ -279,7 +281,7 @@ private FieldInterface updateChildByFQN( // A null changeSource makes this identical to the 4-argument overload the two per-type write // paths called before consolidation (EntityRepository delegates both to the same method with // changeSource null), so an unattributed write stays byte-identical on the wire. - RestUtil.PatchResponse patchResponse = + RestUtil.PatchResponse> patchResponse = repository.patch(uriInfo, parentEntityRef.getId(), user, jsonPatch, changeSource); triggerParentChangeEvent(patchResponse.entity(), user); @@ -287,8 +289,8 @@ private FieldInterface updateChildByFQN( } @SuppressWarnings("unchecked") - private EntityInterface deepCopy(EntityInterface original) { - return JsonUtils.deepCopy(original, (Class) original.getClass()); + private EntityInterface deepCopy(EntityInterface original) { + return JsonUtils.deepCopy(original, (Class>) original.getClass()); } private void applyChildUpdates( @@ -343,13 +345,14 @@ private void authorizeAndPatch( } private EntityReference getParentEntityByFQN(String parentFQN, String entityType) { - EntityRepository repository = Entity.getEntityRepository(entityType); + EntityRepository> repository = + Entity.getEntityRepository(entityType); return repository.findByName(parentFQN, Include.NON_DELETED).getEntityReference(); } private void triggerParentChangeEvent(Object parent, String user) { ChangeEvent changeEvent = - createChangeEventForEntity(user, EventType.ENTITY_UPDATED, (EntityInterface) parent); + createChangeEventForEntity(user, EventType.ENTITY_UPDATED, (EntityInterface) parent); Object entity = changeEvent.getEntity(); changeEvent = copyChangeEvent(changeEvent); changeEvent.setEntity(JsonUtils.pojoToMaskedJson(entity)); @@ -403,14 +406,15 @@ private void searchEntitiesForColumn( String schemaName, String domainId) { - EntityRepository repository = Entity.getEntityRepository(entityType); + EntityRepository> repository = + Entity.getEntityRepository(entityType); ListFilter filter = buildSearchFilter(entityType, serviceName, databaseName, schemaName, domainId); - List parents = + List> parents = repository.listAll(repository.getFields(searchFieldsFor(entityType)), filter); - for (EntityInterface parent : parents) { + for (EntityInterface parent : parents) { ChildFieldResolver.ensureChildFqns(parent, entityType); searchColumnsInHierarchy(columnsOf(parent), columnName, entityType, parent, groupedColumns); } @@ -458,7 +462,7 @@ private String searchFieldsFor(String entityType) { * and searchColumnsInHierarchy's null guard still covers a parent that has none. */ @SuppressWarnings("unchecked") - private List columnsOf(EntityInterface parent) { + private List columnsOf(EntityInterface parent) { return (List) ChildFieldResolver.containerListFor(parent, "columns"); } @@ -629,8 +633,9 @@ private Column getColumnForPreview(String columnFQN, String entityType) { private Optional loadChildForPreview(String columnFQN, String entityType) { String parentFQN = ChildFieldResolver.parentFqnOf(columnFQN, entityType); EntityReference parentEntityRef = getParentEntityByFQN(parentFQN, entityType); - EntityRepository repository = Entity.getEntityRepository(entityType); - EntityInterface parent = + EntityRepository> repository = + Entity.getEntityRepository(entityType); + EntityInterface parent = repository.get( null, parentEntityRef.getId(), diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ContainerRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ContainerRepository.java index af75bfcc4779..be036e4e970d 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ContainerRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ContainerRepository.java @@ -584,7 +584,7 @@ protected EntityReference getParentReference(Container entity) { } @Override - public EntityInterface getParentEntity(Container entity, String fields) { + public EntityInterface getParentEntity(Container entity, String fields) { if (entity.getService() == null) { return null; } @@ -592,7 +592,7 @@ public EntityInterface getParentEntity(Container entity, String fields) { } @Override - public List getAllTags(EntityInterface entity) { + public List getAllTags(EntityInterface entity) { List allTags = new ArrayList<>(); Container container = (Container) entity; EntityUtil.mergeTags(allTags, container.getTags()); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ContextMemoryLifecycle.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ContextMemoryLifecycle.java index da0b88411384..2fbda71fffd7 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ContextMemoryLifecycle.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ContextMemoryLifecycle.java @@ -20,9 +20,9 @@ import java.util.List; import java.util.Objects; import org.openmetadata.schema.entity.context.ContextMemory; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.MemoryDispute; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.service.Entity; /** Lifecycle rules for status changes, supersession, and disputes. */ @@ -51,7 +51,7 @@ static void applyCreate(ContextMemory memory, MemoryResolver resolver) { private static void applyStatusChange(ContextMemory original, ContextMemory updated) { boolean statusChanged = original.getEntityStatus() != updated.getEntityStatus(); - if (statusChanged && original.getEntityStatus() == EntityStatus.DEPRECATED) { + if (statusChanged && isSuperseded(original.getEntityStatus())) { updated.setSupersededBy(null); } if (statusChanged && Objects.equals(original.getStatusReason(), updated.getStatusReason())) { @@ -60,15 +60,19 @@ private static void applyStatusChange(ContextMemory original, ContextMemory upda } private static void validateSupersession(ContextMemory memory) { - boolean superseded = memory.getEntityStatus() == EntityStatus.DEPRECATED; + boolean superseded = isSuperseded(memory.getEntityStatus()); if (superseded != (memory.getSupersededBy() != null)) { throw new BadRequestException( superseded - ? "A Deprecated memory requires supersededBy" - : "supersededBy is only allowed on a Deprecated memory"); + ? String.format("A %s memory requires supersededBy", memory.getEntityStatus().value()) + : "supersededBy is only allowed on a Deprecated memory or a Superseded memory"); } } + private static boolean isSuperseded(ContextMemoryStatus status) { + return status == ContextMemoryStatus.SUPERSEDED || status == ContextMemoryStatus.DEPRECATED; + } + private static void resolveReferences( ContextMemory original, ContextMemory updated, MemoryResolver resolver) { resolveSuccessor(original, updated, resolver); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ContextMemoryRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ContextMemoryRepository.java index 23636c6bf896..b72f36d4d42e 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ContextMemoryRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ContextMemoryRepository.java @@ -30,8 +30,8 @@ import org.openmetadata.schema.EntityInterface; import org.openmetadata.schema.entity.context.ContextMemory; import org.openmetadata.schema.entity.context.ContextMemorySourceType; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.Include; import org.openmetadata.schema.type.Relationship; import org.openmetadata.schema.type.change.ChangeSource; @@ -90,28 +90,53 @@ public class ContextMemoryRepository extends EntityRepository { } /** Memory-specific stages and transitions; the shared repository validates every stage change. */ - public static final EntityLifecycle LIFECYCLE = - new EntityLifecycle( + public static final EntityLifecycle LIFECYCLE = + new EntityLifecycle<>( + ContextMemoryStatus.class, Map.of( - EntityStatus.UNPROCESSED, + ContextMemoryStatus.UNPROCESSED, Set.of( - EntityStatus.APPROVED, - EntityStatus.DEPRECATED, - EntityStatus.REJECTED, - EntityStatus.ARCHIVED), - EntityStatus.DRAFT, - Set.of(EntityStatus.APPROVED, EntityStatus.ARCHIVED, EntityStatus.UNPROCESSED), - EntityStatus.APPROVED, + ContextMemoryStatus.APPROVED, + ContextMemoryStatus.DEPRECATED, + ContextMemoryStatus.REJECTED, + ContextMemoryStatus.SUPERSEDED, + ContextMemoryStatus.INVALIDATED, + ContextMemoryStatus.ARCHIVED), + ContextMemoryStatus.DRAFT, Set.of( - EntityStatus.ARCHIVED, - EntityStatus.DEPRECATED, - EntityStatus.REJECTED, - EntityStatus.UNPROCESSED), - EntityStatus.DEPRECATED, - Set.of(EntityStatus.APPROVED, EntityStatus.ARCHIVED, EntityStatus.UNPROCESSED), - EntityStatus.REJECTED, - Set.of(EntityStatus.APPROVED, EntityStatus.ARCHIVED, EntityStatus.UNPROCESSED), - EntityStatus.ARCHIVED, Set.of(EntityStatus.APPROVED, EntityStatus.UNPROCESSED))); + ContextMemoryStatus.APPROVED, + ContextMemoryStatus.ARCHIVED, + ContextMemoryStatus.UNPROCESSED), + ContextMemoryStatus.APPROVED, + Set.of( + ContextMemoryStatus.ARCHIVED, + ContextMemoryStatus.DEPRECATED, + ContextMemoryStatus.REJECTED, + ContextMemoryStatus.SUPERSEDED, + ContextMemoryStatus.INVALIDATED, + ContextMemoryStatus.UNPROCESSED), + ContextMemoryStatus.DEPRECATED, + Set.of( + ContextMemoryStatus.APPROVED, + ContextMemoryStatus.ARCHIVED, + ContextMemoryStatus.UNPROCESSED), + ContextMemoryStatus.REJECTED, + Set.of( + ContextMemoryStatus.APPROVED, + ContextMemoryStatus.ARCHIVED, + ContextMemoryStatus.UNPROCESSED), + ContextMemoryStatus.SUPERSEDED, + Set.of( + ContextMemoryStatus.APPROVED, + ContextMemoryStatus.ARCHIVED, + ContextMemoryStatus.UNPROCESSED), + ContextMemoryStatus.INVALIDATED, + Set.of( + ContextMemoryStatus.APPROVED, + ContextMemoryStatus.ARCHIVED, + ContextMemoryStatus.UNPROCESSED), + ContextMemoryStatus.ARCHIVED, + Set.of(ContextMemoryStatus.APPROVED, ContextMemoryStatus.UNPROCESSED))); public ContextMemoryRepository() { super( @@ -123,7 +148,7 @@ public ContextMemoryRepository() { UPDATE_FIELDS); supportsSearch = true; entityLifecycle = LIFECYCLE; - defaultEntityStatus = EntityStatus.UNPROCESSED; + defaultEntityStatus = ContextMemoryStatus.UNPROCESSED; } @Override @@ -564,7 +589,7 @@ && nullOrEmpty(memory.getDomains()) } private static List anchorDomains(EntityReference anchor) { - EntityInterface entity = Entity.getEntity(anchor, Entity.FIELD_DOMAINS, Include.NON_DELETED); + EntityInterface entity = Entity.getEntity(anchor, Entity.FIELD_DOMAINS, Include.NON_DELETED); return entity.getDomains(); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ConversationRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ConversationRepository.java index d2cdd6f11a7a..1e4ab3111930 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ConversationRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ConversationRepository.java @@ -1089,7 +1089,7 @@ private boolean isReaction(Reaction reaction, EntityReference user, ReactionType private Target resolveTarget(String about, Include include) { MessageParser.EntityLink link = MessageParser.EntityLink.parse(about); EntityReference reference = EntityUtil.validateEntityLink(link); - EntityInterface entity = getWithDomains(reference.getType(), reference.getId(), include); + EntityInterface entity = getWithDomains(reference.getType(), reference.getId(), include); return new Target(entity.getEntityReference(), emptyIfNull(entity.getDomains())); } @@ -1098,7 +1098,7 @@ private Target resolveTarget(String about, Include include) { * name would 400 on every conversation scoped to a domain. Drop the field where it is unsupported * instead. */ - private EntityInterface getWithDomains(String entityType, UUID id, Include include) { + private EntityInterface getWithDomains(String entityType, UUID id, Include include) { EntityRepository repository = Entity.getEntityRepository(entityType); return repository.get( null, id, repository.getOnlySupportedFields(Entity.FIELD_DOMAINS), include, false); @@ -1108,7 +1108,7 @@ private ActivityContext resolveActivityContext(UUID activityId) { ActivityEvent event = activityStreamRepository.getById(activityId); EntityReference eventTarget = event.getEntity(); try { - EntityInterface target = getWithDomains(eventTarget.getType(), eventTarget.getId(), ALL); + EntityInterface target = getWithDomains(eventTarget.getType(), eventTarget.getId(), ALL); return new ActivityContext( event, new Target(target.getEntityReference(), emptyIfNull(target.getDomains())), true); } catch (EntityNotFoundException exception) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DashboardDataModelRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DashboardDataModelRepository.java index 7098e4e26c0f..463125936297 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DashboardDataModelRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DashboardDataModelRepository.java @@ -229,7 +229,7 @@ protected EntityReference getParentReference(DashboardDataModel entity) { } @Override - public EntityInterface getParentEntity(DashboardDataModel entity, String fields) { + public EntityInterface getParentEntity(DashboardDataModel entity, String fields) { if (entity.getService() == null) { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DashboardRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DashboardRepository.java index 672894a2a2e9..da0492b0295b 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DashboardRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DashboardRepository.java @@ -445,7 +445,7 @@ protected EntityReference getParentReference(Dashboard entity) { } @Override - public EntityInterface getParentEntity(Dashboard entity, String fields) { + public EntityInterface getParentEntity(Dashboard entity, String fields) { if (entity.getService() == null) { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataAssetServiceDAOs.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataAssetServiceDAOs.java index 4007d8707e6c..cb50c5021981 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataAssetServiceDAOs.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataAssetServiceDAOs.java @@ -271,7 +271,7 @@ default List listBefore( ListFilter filter, int limit, String beforeName, String beforeId) { boolean root = Boolean.parseBoolean(filter.getQueryParam("root")); - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); // By default, root will be false. We won't filter the results then if (!root) { @@ -289,7 +289,7 @@ default List listBefore( @Override default List listAfter(ListFilter filter, int limit, String afterName, String afterId) { boolean root = Boolean.parseBoolean(filter.getQueryParam("root")); - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); if (!root) { return EntityDAO.super.listAfter(filter, limit, afterName, afterId); @@ -302,7 +302,7 @@ default List listAfter(ListFilter filter, int limit, String afterName, S @Override default int listCount(ListFilter filter) { boolean root = Boolean.parseBoolean(filter.getQueryParam("root")); - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); if (!root) { return EntityDAO.super.listCount(filter); @@ -696,7 +696,7 @@ default String getNameHashColumn() { default List listBefore( ListFilter filter, int limit, String beforeName, String beforeId) { boolean root = Boolean.parseBoolean(filter.getQueryParam("root")); - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); if (!root) { return EntityDAO.super.listBefore(filter, limit, beforeName, beforeId); } @@ -708,7 +708,7 @@ default List listBefore( @Override default List listAfter(ListFilter filter, int limit, String afterName, String afterId) { boolean root = Boolean.parseBoolean(filter.getQueryParam("root")); - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); if (!root) { return EntityDAO.super.listAfter(filter, limit, afterName, afterId); } @@ -720,7 +720,7 @@ default List listAfter(ListFilter filter, int limit, String afterName, S @Override default int listCount(ListFilter filter) { boolean root = Boolean.parseBoolean(filter.getQueryParam("root")); - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); if (!root) { return EntityDAO.super.listCount(filter); } @@ -821,7 +821,7 @@ default String getNameHashColumn() { default List listBefore( ListFilter filter, int limit, String beforeName, String beforeId) { boolean root = Boolean.parseBoolean(filter.getQueryParam("root")); - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); if (!root) { return EntityDAO.super.listBefore(filter, limit, beforeName, beforeId); } @@ -833,7 +833,7 @@ default List listBefore( @Override default List listAfter(ListFilter filter, int limit, String afterName, String afterId) { boolean root = Boolean.parseBoolean(filter.getQueryParam("root")); - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); if (!root) { return EntityDAO.super.listAfter(filter, limit, afterName, afterId); } @@ -845,7 +845,7 @@ default List listAfter(ListFilter filter, int limit, String afterName, S @Override default int listCount(ListFilter filter) { boolean root = Boolean.parseBoolean(filter.getQueryParam("root")); - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); if (!root) { return EntityDAO.super.listCount(filter); } @@ -946,7 +946,7 @@ default String getNameHashColumn() { default List listBefore( ListFilter filter, int limit, String beforeName, String beforeId) { boolean root = Boolean.parseBoolean(filter.getQueryParam("root")); - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); if (!root) { return EntityDAO.super.listBefore(filter, limit, beforeName, beforeId); } @@ -958,7 +958,7 @@ default List listBefore( @Override default List listAfter(ListFilter filter, int limit, String afterName, String afterId) { boolean root = Boolean.parseBoolean(filter.getQueryParam("root")); - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); if (!root) { return EntityDAO.super.listAfter(filter, limit, afterName, afterId); } @@ -970,7 +970,7 @@ default List listAfter(ListFilter filter, int limit, String afterName, S @Override default int listCount(ListFilter filter) { boolean root = Boolean.parseBoolean(filter.getQueryParam("root")); - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); if (!root) { return EntityDAO.super.listCount(filter); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataContractRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataContractRepository.java index 07f2a8738a96..0503562cd110 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataContractRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataContractRepository.java @@ -534,7 +534,7 @@ private static class SchemaValidationResult { private SchemaValidationResult validateFieldsAgainstEntity( DataContract dataContract, EntityReference entityRef) { ChildFieldResolver.ChildContainerSpec spec = ChildFieldResolver.specFor(entityRef.getType()); - EntityInterface parent = + EntityInterface parent = Entity.getEntity( entityRef.getType(), entityRef.getId(), spec.requiredFields(), Include.NON_DELETED); List children = ChildFieldResolver.childrenOf(parent, entityRef.getType()); @@ -1024,7 +1024,7 @@ public RestUtil.PutResponse validateContract(DataContract da * @param user The user creating the contract */ public DataContract materializeInheritedContract( - EntityInterface entity, String dataProductContractName, String user) { + EntityInterface entity, String dataProductContractName, String user) { // Name format: " - " String contractName = dataProductContractName + " - " + entity.getName(); String contractFqn = entity.getFullyQualifiedName() + ".contract"; @@ -1050,7 +1050,7 @@ public DataContract materializeInheritedContract( * @return the stored result, or empty when no contract applies to the entity */ public Optional> validateEntityContract( - EntityInterface entity, String user) { + EntityInterface entity, String user) { return Optional.ofNullable(getEffectiveDataContract(entity)) .map( effective -> @@ -1059,7 +1059,7 @@ public Optional> validateEntityContract } private DataContract contractForResults( - EntityInterface entity, DataContract effective, String user) { + EntityInterface entity, DataContract effective, String user) { DataContract direct = getEntityDataContractSafely(entity); DataContract contract = direct != null ? direct : effective; if (direct == null && Boolean.TRUE.equals(effective.getInherited())) { @@ -1228,7 +1228,7 @@ private SemanticsValidation validateSemantics(DataContract dataContract) { try { // Get the entity that the contract applies to - EntityInterface entity = + EntityInterface entity = Entity.getEntity( dataContract.getEntity().getType(), dataContract.getEntity().getId(), @@ -1616,7 +1616,7 @@ public DataContract loadEntityDataContract(EntityReference entity) { DataContract.class); } - public DataContract getEntityDataContractSafely(EntityInterface entity) { + public DataContract getEntityDataContractSafely(EntityInterface entity) { try { return loadEntityDataContract(entity.getEntityReference()); } catch (Exception e) { @@ -1625,7 +1625,7 @@ public DataContract getEntityDataContractSafely(EntityInterface entity) { } } - public DataContract getEffectiveDataContract(EntityInterface entity) { + public DataContract getEffectiveDataContract(EntityInterface entity) { DataContract entityContract = getEntityDataContractSafely(entity); List dataProducts = entity.getDataProducts(); @@ -1668,7 +1668,7 @@ public DataContract getEffectiveDataContract(EntityInterface entity) { } private DataContract inheritFromDataProductContract( - EntityInterface entity, DataContract dataProductContract) { + EntityInterface entity, DataContract dataProductContract) { DataContract inherited = JsonUtils.deepCopy(dataProductContract, DataContract.class); // Update the entity reference to point to the actual entity, not the data product diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataInsightSystemChartRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataInsightSystemChartRepository.java index 4993dd21e735..003de64047b3 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataInsightSystemChartRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataInsightSystemChartRepository.java @@ -232,8 +232,9 @@ private List listServiceAutomations(String serviceType, String || !SERVICE_TYPES_WITH_AUTOMATIONS.contains(serviceType)) { return List.of(); } - EntityInterface service = - (EntityInterface) Entity.getEntityByName(serviceType, serviceName, "", Include.NON_DELETED); + EntityInterface service = + (EntityInterface) + Entity.getEntityByName(serviceType, serviceName, "", Include.NON_DELETED); return Entity.getEntityRepository(serviceType) .findTo(service.getId(), serviceType, Relationship.CONTAINS, AI_AUTOMATION); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataProductRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataProductRepository.java index 02f31f7f064f..7db6e844cd23 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataProductRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataProductRepository.java @@ -667,9 +667,9 @@ private ResultList getPaginatedPorts( Map entitiesById = new HashMap<>(); for (Map.Entry> entry : refsByType.entrySet()) { String entityType = entry.getKey(); - List entitiesOfType = + List> entitiesOfType = Entity.getEntities(entry.getValue(), fieldsToFetch, NON_DELETED); - for (EntityInterface entity : entitiesOfType) { + for (EntityInterface entity : entitiesOfType) { entitiesById.put(entity.getId(), new EntityWithType(entity, entityType)); } } @@ -762,14 +762,14 @@ protected BulkOperationResult bulkAssetsOperation( } // Fetch all asset entities grouped by type so add-validation can still run during dryRun - Map assetEntitiesMap = new HashMap<>(); + Map> assetEntitiesMap = new HashMap<>(); if (isAdd && !assets.isEmpty()) { for (Map.Entry> entry : assetsByType.entrySet()) { - List entitiesOfType = + List> entitiesOfType = Entity.getEntities(entry.getValue(), "domains,dataProducts", ALL); // Key by each entity's own id; getEntities may reorder or drop rows relative to the // request list, so request-index zipping would validate the wrong asset. - for (EntityInterface entity : entitiesOfType) { + for (EntityInterface entity : entitiesOfType) { assetEntitiesMap.put(entity.getId(), entity); } } @@ -780,7 +780,7 @@ protected BulkOperationResult bulkAssetsOperation( try { if (isAdd) { - EntityInterface assetEntity = assetEntitiesMap.get(ref.getId()); + EntityInterface assetEntity = assetEntitiesMap.get(ref.getId()); if (assetEntity == null) { throw new IllegalStateException("Asset entity not found for ID: " + ref.getId()); } @@ -838,7 +838,7 @@ protected BulkOperationResult bulkAssetsOperation( // Create a Change Event on successful operations (skip when dryRun makes no changes) if (!dryRun && !success.isEmpty()) { - EntityInterface entityInterface = Entity.getEntity(fromEntity, entityId, "id", ALL); + EntityInterface entityInterface = Entity.getEntity(fromEntity, entityId, "id", ALL); List successfulAssets = new ArrayList<>(); for (BulkResponse response : success) { successfulAssets.add((EntityReference) response.getRequest()); @@ -865,7 +865,7 @@ protected BulkOperationResult bulkAssetsOperation( * @throws RuleValidationException if validation fails */ private void validateAssetDataProductAssignment( - EntityInterface assetEntity, EntityReference dataProductRef) { + EntityInterface assetEntity, EntityReference dataProductRef) { try { List currentDataProducts = listOrEmpty(assetEntity.getDataProducts()); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DatabaseRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DatabaseRepository.java index 3585ff92351c..1396ae01c083 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DatabaseRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DatabaseRepository.java @@ -188,7 +188,7 @@ protected EntityReference getParentReference(Database entity) { } @Override - public EntityInterface getParentEntity(Database entity, String fields) { + public EntityInterface getParentEntity(Database entity, String fields) { if (entity.getService() == null) { return null; } @@ -225,7 +225,7 @@ public String exportToCsv( schemaRepository.listAllForCSV( schemaRepository.getFields("owners,tags,domains,extension"), database.getFullyQualifiedName()); - schemas.sort(Comparator.comparing(EntityInterface::getFullyQualifiedName)); + schemas.sort(Comparator.comparing(EntityInterface::getFullyQualifiedName)); // Export schemas and all their child entities return new DatabaseCsv(database, user, recursive).exportAllCsv(schemas, recursive, callback); @@ -683,7 +683,7 @@ public String exportAllCsv( /** * Add entity to CSV file with entity type */ - public void addEntityToCSV( + public > void addEntityToCSV( CsvFile csvFile, E entity, String entityType) { List recordList = new ArrayList<>(); addField(recordList, entity.getName()); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DatabaseSchemaRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DatabaseSchemaRepository.java index 76b8b6bb4a5a..d9b7b9f997b8 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DatabaseSchemaRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DatabaseSchemaRepository.java @@ -603,7 +603,7 @@ protected String getInheritableFields() { } @Override - protected void applyInheritance(DatabaseSchema entity, Fields fields, EntityInterface parent) { + protected void applyInheritance(DatabaseSchema entity, Fields fields, EntityInterface parent) { inheritOwners(entity, fields, parent); inheritDomains(entity, fields, parent); inheritTags(entity, fields, parent); @@ -616,7 +616,7 @@ protected void applyInheritance(DatabaseSchema entity, Fields fields, EntityInte } @Override - public EntityInterface getParentEntity(DatabaseSchema entity, String fields) { + public EntityInterface getParentEntity(DatabaseSchema entity, String fields) { return Entity.getEntity(entity.getDatabase(), fields, ALL); } @@ -674,7 +674,7 @@ public String exportToCsv( schema.getFullyQualifiedName()); tables.forEach( table -> tableRepository.setFieldsInternal(table, new Fields(Set.of("columns", "tags")))); - tables.sort(Comparator.comparing(EntityInterface::getFullyQualifiedName)); + tables.sort(Comparator.comparing(EntityInterface::getFullyQualifiedName)); // Get stored procedures under this schema StoredProcedureRepository spRepository = @@ -683,7 +683,7 @@ public String exportToCsv( spRepository.listAllForCSV( spRepository.getFields("owners,tags,domains,extension,storedProcedureCode"), schema.getFullyQualifiedName()); - storedProcedures.sort(Comparator.comparing(EntityInterface::getFullyQualifiedName)); + storedProcedures.sort(Comparator.comparing(EntityInterface::getFullyQualifiedName)); // Export all entities using a single CSV return new DatabaseSchemaCsv(schema, user, recursive) @@ -880,7 +880,7 @@ public String exportAllCsv( /** * Add entity to CSV file with entity type and fully qualified name */ - public void addEntityToCSV( + public > void addEntityToCSV( CsvFile csvFile, E entity, String entityType) { List recordList = new ArrayList<>(); addField(recordList, entity.getName()); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DatabaseServiceRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DatabaseServiceRepository.java index bf27676f9d7c..26a2a73bf523 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DatabaseServiceRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DatabaseServiceRepository.java @@ -91,7 +91,7 @@ public String exportToCsv( repository.getFields("name,owners,tags,domains,extension"), databaseService.getFullyQualifiedName()); - databases.sort(Comparator.comparing(EntityInterface::getFullyQualifiedName)); + databases.sort(Comparator.comparing(EntityInterface::getFullyQualifiedName)); return new DatabaseServiceCsv(databaseService, user, recursive) .exportAllCsv(databases, recursive, callback); } @@ -195,7 +195,7 @@ public String exportAllCsv( /** * Add entity to CSV file with entity type */ - public void addEntityToCSV( + public > void addEntityToCSV( CsvFile csvFile, E entity, String entityType) { List recordList = new ArrayList<>(); addField(recordList, entity.getName()); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DomainRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DomainRepository.java index 58b276f2468a..e757ec0ad53b 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DomainRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DomainRepository.java @@ -280,7 +280,7 @@ public void fetchInheritableRelationships(List entities, Fields fields) } @Override - protected void applyInheritance(Domain entity, Fields fields, EntityInterface parent) { + protected void applyInheritance(Domain entity, Fields fields, EntityInterface parent) { inheritOwners(entity, fields, parent); inheritExperts(entity, fields, parent); } @@ -423,7 +423,7 @@ protected BulkOperationResult bulkAssetsOperation( result.withSuccessRequest(success); if (!dryRun && result.getStatus().equals(ApiStatus.SUCCESS)) { - EntityInterface entityInterface = Entity.getEntity(fromEntity, entityId, "id", ALL); + EntityInterface entityInterface = Entity.getEntity(fromEntity, entityId, "id", ALL); ChangeDescription change = addBulkAddRemoveChangeDescription( entityInterface.getVersion(), isAdd, request.getAssets(), null); @@ -802,7 +802,7 @@ private EntityReference resolveParentRef(Domain entity) { } @Override - public EntityInterface getParentEntity(Domain entity, String fields) { + public EntityInterface getParentEntity(Domain entity, String fields) { return entity.getParent() != null ? Entity.getEntity(entity.getParent(), fields, Include.NON_DELETED) : null; diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DriveServiceRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DriveServiceRepository.java index 91ba74d4c8fe..d54e281cefe1 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DriveServiceRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DriveServiceRepository.java @@ -83,7 +83,7 @@ public String exportToCsv( repository.getFields("name,owners,tags,domains,extension"), driveService.getFullyQualifiedName()); - directories.sort(Comparator.comparing(EntityInterface::getFullyQualifiedName)); + directories.sort(Comparator.comparing(EntityInterface::getFullyQualifiedName)); return new DriveServiceCsv(driveService, user, recursive) .exportAllCsv(directories, recursive, callback); } @@ -225,7 +225,7 @@ protected void createEntity(CSVPrinter printer, List csvRecords) thro } } - protected void addEntityToCSV(CsvFile csvFile, EntityInterface entity, String entityType) { + protected void addEntityToCSV(CsvFile csvFile, EntityInterface entity, String entityType) { List recordList = new ArrayList<>(); addField(recordList, entity.getName()); addField(recordList, entity.getDisplayName()); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityDAO.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityDAO.java index 9b9284292ed9..acacd3cba619 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityDAO.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityDAO.java @@ -57,7 +57,7 @@ import org.openmetadata.service.util.jdbi.BindUUID; import org.openmetadata.service.workflows.searchIndex.ReindexingUtil; -public interface EntityDAO { +public interface EntityDAO> { org.slf4j.Logger LOG = org.slf4j.LoggerFactory.getLogger(EntityDAO.class); /** @@ -927,8 +927,16 @@ List listKeysDesc( default List listKeys(ListFilter filter, int limit, boolean ascending) { return ascending - ? listKeys(getTableName(), filter.getQueryParams(), filter.getCondition(), limit) - : listKeysDesc(getTableName(), filter.getQueryParams(), filter.getCondition(), limit); + ? listKeys( + getTableName(), + filter.getQueryParams(), + filter.getConditionForEntity(getTableName()), + limit) + : listKeysDesc( + getTableName(), + filter.getQueryParams(), + filter.getConditionForEntity(getTableName()), + limit); } record ServiceTypeCount(String serviceType, int count) {} @@ -953,7 +961,8 @@ List listCountByServiceType( @Define("table") String table, @BindMap Map params, @Define("cond") String cond); default List listCountByServiceType(ListFilter filter) { - return listCountByServiceType(getTableName(), filter.getQueryParams(), filter.getCondition()); + return listCountByServiceType( + getTableName(), filter.getQueryParams(), filter.getConditionForEntity(getTableName())); } @SqlQuery("SELECT EXISTS (SELECT * FROM WHERE id = :id)") @@ -997,13 +1006,13 @@ default void analyzeTable() { } /** Default methods that interfaces with implementation. Don't override */ - default void insert(EntityInterface entity, String fqn) { + default void insert(EntityInterface entity, String fqn) { insert(getTableName(), getNameHashColumn(), fqn, JsonUtils.pojoToJson(entity)); } /** Default methods that interfaces with implementation. Don't override */ - default void insertMany(List entities) { - List fqns = entities.stream().map(EntityInterface::getFullyQualifiedName).toList(); + default void insertMany(List> entities) { + List fqns = entities.stream().map(EntityInterface::getFullyQualifiedName).toList(); insertMany( getTableName(), getNameHashColumn(), @@ -1012,9 +1021,9 @@ default void insertMany(List entities) { } /** Batch update entities. Don't override */ - default void updateMany(List entities) { - List fqns = entities.stream().map(EntityInterface::getFullyQualifiedName).toList(); - List ids = entities.stream().map(EntityInterface::getId).toList(); + default void updateMany(List> entities) { + List fqns = entities.stream().map(EntityInterface::getFullyQualifiedName).toList(); + List ids = entities.stream().map(EntityInterface::getId).toList(); updateMany( getTableName(), getNameHashColumn(), @@ -1023,7 +1032,7 @@ default void updateMany(List entities) { entities.stream().map(JsonUtils::pojoToJson).toList()); } - default void insert(String nameHash, EntityInterface entity, String fqn) { + default void insert(String nameHash, EntityInterface entity, String fqn) { insert(getTableName(), nameHash, fqn, JsonUtils.pojoToJson(entity)); } @@ -1031,7 +1040,7 @@ default void update(UUID id, String fqn, String json) { update(getTableName(), getNameHashColumn(), fqn, id.toString(), json); } - default void update(EntityInterface entity) { + default void update(EntityInterface entity) { update( getTableName(), getNameHashColumn(), @@ -1040,7 +1049,7 @@ default void update(EntityInterface entity) { JsonUtils.pojoToJson(entity)); } - default void update(String nameHashColumn, EntityInterface entity) { + default void update(String nameHashColumn, EntityInterface entity) { update( getTableName(), nameHashColumn, @@ -1049,7 +1058,7 @@ default void update(String nameHashColumn, EntityInterface entity) { JsonUtils.pojoToJson(entity)); } - default int updateIfMatches(EntityInterface entity, String expectedJson) { + default int updateIfMatches(EntityInterface entity, String expectedJson) { return updateIfMatches( getTableName(), getNameHashColumn(), @@ -1181,7 +1190,10 @@ default T jsonToEntity(String json, Object identity) { default int listCount(ListFilter filter) { return listCount( - getTableName(), getNameHashColumn(), filter.getQueryParams(), filter.getCondition()); + getTableName(), + getNameHashColumn(), + filter.getQueryParams(), + filter.getConditionForEntity(getTableName())); } default int listTotalCount() { @@ -1194,7 +1206,7 @@ default List listBefore( return listBefore( getTableName(), filter.getQueryParams(), - filter.getCondition(), + filter.getConditionForEntity(getTableName()), limit, beforeName, beforeId); @@ -1203,7 +1215,12 @@ default List listBefore( default List listAfter(ListFilter filter, int limit, String afterName, String afterId) { // Quoted name is stored in fullyQualifiedName column and not in the name column return listAfter( - getTableName(), filter.getQueryParams(), filter.getCondition(), limit, afterName, afterId); + getTableName(), + filter.getQueryParams(), + filter.getConditionForEntity(getTableName()), + limit, + afterName, + afterId); } default List listAll(String startHash, String endHash) { @@ -1213,7 +1230,12 @@ default List listAll(String startHash, String endHash) { default List listAll(String startHash, String endHash, ListFilter filter) { // Quoted name is stored in fullyQualifiedName column and not in the name column - return listAll(getTableName(), filter.getCondition(), getNameHashColumn(), startHash, endHash); + return listAll( + getTableName(), + filter.getConditionForEntity(getTableName()), + getNameHashColumn(), + startHash, + endHash); } default List listAfterWithOffset(int limit, int offset) { @@ -1227,12 +1249,20 @@ default List migrationListAfterWithOffset(int limit, String nameHashColu } default List listAfter(ListFilter filter, int limit, int offset) { - return listAfter(getTableName(), filter.getQueryParams(), filter.getCondition(), limit, offset); + return listAfter( + getTableName(), + filter.getQueryParams(), + filter.getConditionForEntity(getTableName()), + limit, + offset); } default CursorRow getCursorAtOffset(ListFilter filter, int offset) { return getCursorAtOffset( - getTableName(), filter.getQueryParams(), filter.getCondition(), offset); + getTableName(), + filter.getQueryParams(), + filter.getConditionForEntity(getTableName()), + offset); } default void exists(UUID id) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityDataDAOs.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityDataDAOs.java index 4d41c40dbf7f..ec860f04c596 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityDataDAOs.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityDataDAOs.java @@ -731,34 +731,39 @@ static String addHierarchyCondition(ListFilter filter, String condition) { @Override default int listCount(ListFilter filter) { - String condition = addHierarchyCondition(filter, filter.getCondition()); + String condition = + addHierarchyCondition(filter, filter.getConditionForEntity(getTableName())); return listCount(getTableName(), getNameHashColumn(), filter.getQueryParams(), condition); } @Override default List listBefore( ListFilter filter, int limit, String beforeName, String beforeId) { - String condition = addHierarchyCondition(filter, filter.getCondition()); + String condition = + addHierarchyCondition(filter, filter.getConditionForEntity(getTableName())); return listBefore( getTableName(), filter.getQueryParams(), condition, limit, beforeName, beforeId); } @Override default List listAfter(ListFilter filter, int limit, String afterName, String afterId) { - String condition = addHierarchyCondition(filter, filter.getCondition()); + String condition = + addHierarchyCondition(filter, filter.getConditionForEntity(getTableName())); return listAfter( getTableName(), filter.getQueryParams(), condition, limit, afterName, afterId); } @Override default List listAfter(ListFilter filter, int limit, int offset) { - String condition = addHierarchyCondition(filter, filter.getCondition()); + String condition = + addHierarchyCondition(filter, filter.getConditionForEntity(getTableName())); return listAfter(getTableName(), filter.getQueryParams(), condition, limit, offset); } @Override default CursorRow getCursorAtOffset(ListFilter filter, int offset) { - String condition = addHierarchyCondition(filter, filter.getCondition()); + String condition = + addHierarchyCondition(filter, filter.getConditionForEntity(getTableName())); return getCursorAtOffset(getTableName(), filter.getQueryParams(), condition, offset); } @@ -830,7 +835,7 @@ default String getNameHashColumn() { @Override default int listCount(ListFilter filter) { - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); String directChildrenOf = filter.getQueryParam("directChildrenOf"); if (!nullOrEmpty(directChildrenOf)) { @@ -848,7 +853,7 @@ default int listCount(ListFilter filter) { @Override default List listBefore( ListFilter filter, int limit, String beforeName, String beforeId) { - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); String directChildrenOf = filter.getQueryParam("directChildrenOf"); if (!nullOrEmpty(directChildrenOf)) { @@ -866,7 +871,7 @@ default List listBefore( @Override default List listAfter(ListFilter filter, int limit, String afterName, String afterId) { - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); String directChildrenOf = filter.getQueryParam("directChildrenOf"); if (!nullOrEmpty(directChildrenOf)) { @@ -1078,7 +1083,7 @@ int listIngestionPipelineCount( default String displayNameSortCondition(ListFilter filter) { // Unqualified: a table prefix on the pipelineType JSON expression reads as a routine call. return nullOrEmpty(filter.getQueryParam("serviceType")) - ? filter.getCondition() + ? filter.getConditionForEntity(getTableName()) : serviceTypeJoinCondition(filter); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityProfileRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityProfileRepository.java index 973dbfac0f8d..c282e7dc4c3b 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityProfileRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityProfileRepository.java @@ -56,7 +56,7 @@ public ResultList listProfileData( } public Response addProfileData( - UriInfo uriInfo, EntityInterface entity, CreateEntityProfile createEntityProfile) { + UriInfo uriInfo, EntityInterface entity, CreateEntityProfile createEntityProfile) { RestUtil.validateTimestampMilliseconds(createEntityProfile.getTimestamp()); EntityProfile entityProfile = @@ -90,7 +90,7 @@ public void deleteEntityProfile(ListFilter filter, Long timestamp) { } private void insertSystemProfile( - EntityInterface entity, String extension, EntityProfile entityProfile) { + EntityInterface entity, String extension, EntityProfile entityProfile) { // For system profile, timestamp corresponds to the operation time not the profiling time // We need to first check if there is an existing system profile at the same timestamp // If yes, we update the existing record diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java index 526f9376657a..e993ee415e7c 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java @@ -317,7 +317,7 @@ */ @Slf4j @Repository() -public abstract class EntityRepository { +public abstract class EntityRepository> { public static final String BULK_IMPORT = "bulkImport"; private static final int RELATION_DELETE_BATCH_SIZE = 500; @@ -561,7 +561,7 @@ public Integer load(String key) { * describe assets that already exist in the data infrastructure, so they start Approved; entity * types created and reviewed in OpenMetadata start in Draft instead. */ - protected EntityStatus defaultEntityStatus = EntityStatus.UNPROCESSED; + protected Enum defaultEntityStatus = EntityStatus.UNPROCESSED; /** * Whether an active governance workflow that sets this entity type's lifecycle stage is the only @@ -587,7 +587,7 @@ public Integer load(String key) { * The lifecycle stages this entity type uses and the moves between them. Most types use the * general lifecycle; a type with stages of its own declares its lifecycle here. */ - protected EntityLifecycle entityLifecycle = EntityLifecycle.GENERAL; + protected EntityLifecycle entityLifecycle = EntityLifecycle.GENERAL; protected boolean quoteFqn = false; // Entity FQNS not hierarchical such user, teams, services need to be quoted @@ -639,7 +639,8 @@ public Integer load(String key) { * Thread-local cache for parent entities during bulk prepare operations. * Set by {@link #preloadParentsForBulk(List)} and cleared after use. */ - private final ThreadLocal> parentCacheForPrepare = new ThreadLocal<>(); + private final ThreadLocal>> parentCacheForPrepare = + new ThreadLocal<>(); protected final ChangeSummarizer changeSummarizer; @@ -945,10 +946,10 @@ protected void deleteFromMany( protected void clearCommonRelationshipsForMany(List entities) { if (entities.isEmpty()) return; - List ids = entities.stream().map(EntityInterface::getId).toList(); + List ids = entities.stream().map(EntityInterface::getId).toList(); if (supportsTags) { - List fqns = entities.stream().map(EntityInterface::getFullyQualifiedName).toList(); + List fqns = entities.stream().map(EntityInterface::getFullyQualifiedName).toList(); daoCollection.tagUsageDAO().deleteTagsByTargets(fqns); } if (supportsOwners) { @@ -995,7 +996,7 @@ protected void setInheritedFields(T entity, Fields fields) { EntityReference parentRef = getParentReference(entity); String inheritableFields = parentRef == null ? getInheritableFields() : getInheritableFields(parentRef.getType()); - EntityInterface parent = resolveInheritanceParentLeniently(entity, inheritableFields); + EntityInterface parent = resolveInheritanceParentLeniently(entity, inheritableFields); if (parent != null) { // Keep single-entity inheritance path aligned with batch/recursive inheritance path. applyInheritance(entity, fields, parent); @@ -1011,8 +1012,8 @@ protected void setInheritedFields(T entity, Fields fields) { * {@link #setInheritedFields(List, Fields)} routes entities without a {@code getParentReference} * override through this per-entity path, so this is also the list path's guard. */ - private EntityInterface resolveInheritanceParentLeniently(T entity, String inheritableFields) { - EntityInterface parent; + private EntityInterface resolveInheritanceParentLeniently(T entity, String inheritableFields) { + EntityInterface parent; try { parent = getParentEntity(entity, inheritableFields); } catch (EntityNotFoundException e) { @@ -1198,7 +1199,7 @@ public final T getForInheritance(UUID id, Fields fields, Include include) { // Preserve the requested inheritance shape (e.g. retentionPeriod-only), but only for this // repository's declared inheritable fields to avoid leaking invalid fields up the chain. String parentFields = projectInheritanceFields(fields, containerRef.getType()); - EntityInterface parent = + EntityInterface parent = Entity.getEntityForInheritance( containerRef.getType(), containerRef.getId(), parentFields, ALL); applyInheritance(entity, fields, parent); @@ -1268,7 +1269,7 @@ public void setInheritedFieldsUntyped(List entities, Fields fields) { } /** Apply inherited fields from a loaded parent to the entity. Override for custom inheritance logic. */ - protected void applyInheritance(T entity, Fields fields, EntityInterface parent) { + protected void applyInheritance(T entity, Fields fields, EntityInterface parent) { inheritDomains(entity, fields, parent); inheritTags(entity, fields, parent); } @@ -1288,11 +1289,11 @@ public void preloadParentsForBulk(List entities) { } } if (uniqueRefs.isEmpty()) return; - var loaded = new HashMap(); + var loaded = new HashMap>(); var refsByType = uniqueRefs.values().stream().collect(Collectors.groupingBy(EntityReference::getType)); for (var entry : refsByType.entrySet()) { - List parents = Entity.getEntities(entry.getValue(), "", ALL); + List> parents = Entity.getEntities(entry.getValue(), "", ALL); for (var parent : parents) { loaded.put(parent.getId(), parent); } @@ -1301,7 +1302,7 @@ public void preloadParentsForBulk(List entities) { } /** Get a parent entity from the bulk-prepare cache, or load from DB if not cached. */ - protected EntityInterface getCachedParentOrLoad( + protected EntityInterface getCachedParentOrLoad( EntityReference ref, String fields, Include include) { var cache = parentCacheForPrepare.get(); if (cache != null && ref != null && ref.getId() != null) { @@ -1312,7 +1313,7 @@ protected EntityInterface getCachedParentOrLoad( } /** Store preloaded parents in the thread-local cache. */ - protected void setParentCache(Map cache) { + protected void setParentCache(Map> cache) { parentCacheForPrepare.set(cache); } @@ -1326,12 +1327,12 @@ public void clearParentCache() { * read. Returns null (skip inheritance) rather than propagating, matching {@link * #resolveInheritanceParentLeniently}. */ - protected final

P loadInheritanceParentLeniently( + protected final

> P loadInheritanceParentLeniently( EntityReference parentRef, String fields, Class

parentClass) { P result = null; if (parentRef != null && parentRef.getId() != null && !nullOrEmpty(parentRef.getType())) { try { - EntityInterface parent = + EntityInterface parent = Entity.getEntityForInheritance(parentRef.getType(), parentRef.getId(), fields, ALL); if (parentClass.isInstance(parent)) { result = parentClass.cast(parent); @@ -1388,10 +1389,10 @@ private void setInheritedFields( // One bulk load per parent type keeps list endpoints off an N+1, which is what the removed // thread-local parent cache was really buying on this path. - var parentsById = new HashMap(); + var parentsById = new HashMap>(); for (var entry : parentRefsByType.entrySet()) { String parentFields = getInheritableFields(entry.getKey()); - List parents = + List> parents = Entity.getEntitiesForInheritance(entry.getValue(), parentFields, ALL); for (var parent : parents) { parentsById.put(parent.getId(), parent); @@ -1407,7 +1408,7 @@ private void setInheritedFields( parentRef = unhydratedParentRefs.get(entity.getId()); } if (parentRef != null - && parentsById.get(parentRef.getId()) instanceof EntityInterface parent) { + && parentsById.get(parentRef.getId()) instanceof EntityInterface parent) { applyInheritance(entity, fields, parent); } else { // Parent could not be resolved via batch loading (no container, or a concurrently-deleted @@ -1462,18 +1463,20 @@ public void setFullyQualifiedName(T entity) { * from the reviewers who will approve the entity. Only consulted at creation: an update that * omits the stage keeps the stored one. */ - protected EntityStatus initialEntityStatus(T entity) { - return Objects.requireNonNullElse(entity.getEntityStatus(), defaultEntityStatus); + protected Enum initialEntityStatus(T entity) { + return entity.getEntityStatus() == null ? defaultEntityStatus : entity.getEntityStatus(); } /** Puts a new entity in the stage it starts in; every create path calls it before storing. */ void assignInitialEntityStatus(T entity) { if (supportsEntityStatus) { - requireStageInLifecycle(entity.getEntityStatus()); + requireStageInLifecycle(entityLifecycle.adapter().read(entity)); if (requestsStageOwnedByWorkflow(entity)) { entity.setEntityStatus(null); } - entity.setEntityStatus(initialEntityStatus(entity)); + entityLifecycle + .adapter() + .write(entity, entityLifecycle.adapter().code(initialEntityStatus(entity))); } } @@ -1493,13 +1496,13 @@ public List getStageWorkflows() { : List.of(); } - private void validateEntityStatusChange(T current, T change, EntityStatus from, EntityStatus to) { + private void validateEntityStatusChange(T current, T change, String from, String to) { requireMoveInLifecycle(from, to); checkEntityStatusNotOwnedByWorkflow(current, change); // A workflow's approval task already decided who may approve (reviewers, owners or named // candidates), so the reviewer rule only guards direct edits and imports. - if (from == EntityStatus.IN_REVIEW - && (to == EntityStatus.APPROVED || to == EntityStatus.REJECTED) + if (EntityStatus.IN_REVIEW.value().equals(from) + && (EntityStatus.APPROVED.value().equals(to) || EntityStatus.REJECTED.value().equals(to)) && !EntityStatusWorkflows.isWorkflowChange(change)) { checkUpdatedByReviewer(current, change.getUpdatedBy()); } @@ -1514,11 +1517,11 @@ private void validateEntityStatusChange(T current, T change, EntityStatus from, public void applyEntityStatusRulesForImport(T original, T updated, String importedBy) { if (supportsEntityStatus) { if (updated.getEntityStatus() == null) { - updated.setEntityStatus(original.getEntityStatus()); + entityLifecycle.adapter().write(updated, entityLifecycle.adapter().read(original)); } - EntityStatus from = original.getEntityStatus(); - EntityStatus to = updated.getEntityStatus(); - if (from != to) { + String from = entityLifecycle.adapter().read(original); + String to = entityLifecycle.adapter().read(updated); + if (!Objects.equals(from, to)) { updated.setUpdatedBy(importedBy); loadReviewersForStageCheck(original, from); validateEntityStatusChange(original, updated, from, to); @@ -1529,8 +1532,8 @@ public void applyEntityStatusRulesForImport(T original, T updated, String import // An import row is matched from stored JSON, which holds no relationship fields, so the reviewer // rule would see an entity without reviewers. Load them the way a PATCH does, inherited ones // included, before checking who may move the entity out of review. - private void loadReviewersForStageCheck(T original, EntityStatus from) { - if (supportsReviewers && from == EntityStatus.IN_REVIEW) { + private void loadReviewersForStageCheck(T original, String from) { + if (supportsReviewers && EntityStatus.IN_REVIEW.value().equals(from)) { T withReviewers = get(null, original.getId(), getFields(FIELD_REVIEWERS), Include.NON_DELETED, false); original.setReviewers(withReviewers.getReviewers()); @@ -1550,28 +1553,30 @@ private void checkEntityStatusNotOwnedByWorkflow(T current, T change) { } } - public EntityLifecycle getEntityLifecycle() { + public EntityLifecycle getEntityLifecycle() { + if (supportsEntityStatus) { + entityLifecycle.adapter().requireEntityType(entityClass); + } return entityLifecycle; } - private void requireStageInLifecycle(EntityStatus stage) { - if (stage != null && !entityLifecycle.includes(stage)) { - throw new BadRequestException(entityStatusNotInLifecycle(entityType, stage.value())); + private void requireStageInLifecycle(String stage) { + if (stage != null && !entityLifecycle.includesCode(stage)) { + throw new BadRequestException(entityStatusNotInLifecycle(entityType, stage)); } } // An entity saved before it had a stage can take any stage of its lifecycle - private void requireMoveInLifecycle(EntityStatus from, EntityStatus to) { + private void requireMoveInLifecycle(String from, String to) { if (from == null) { requireStageInLifecycle(to); - } else if (!entityLifecycle.allows(from, to)) { - throw new BadRequestException( - entityStatusMoveNotInLifecycle(entityType, from.value(), to.value())); + } else if (!entityLifecycle.allowsCodes(from, to)) { + throw new BadRequestException(entityStatusMoveNotInLifecycle(entityType, from, to)); } } /** When an entity has reviewers, only one of them may approve, reject or delete it in review. */ - public static void checkUpdatedByReviewer(EntityInterface entity, String updatedBy) { + public static void checkUpdatedByReviewer(EntityInterface entity, String updatedBy) { List reviewers = entity.getReviewers(); if (!nullOrEmpty(reviewers)) { boolean isReviewer = @@ -1598,7 +1603,8 @@ public static void checkUpdatedByReviewer(EntityInterface entity, String updated } private void checkInReviewEntityDeletedByReviewer(T entity, String deletedBy) { - if (onlyReviewersDeleteInReview && entity.getEntityStatus() == EntityStatus.IN_REVIEW) { + if (onlyReviewersDeleteInReview + && EntityStatus.IN_REVIEW.value().equals(entityLifecycle.adapter().read(entity))) { checkUpdatedByReviewer(entity, deletedBy); } } @@ -1615,15 +1621,18 @@ private void closeApprovalTaskOnEntityStatusChange(T original, T updated) { } static Optional approvalTaskClosingComment( - String entityType, EntityStatus from, EntityStatus to) { + String entityType, Enum fromStatus, Enum toStatus) { + String from = fromStatus == null ? null : fromStatus.toString(); + String to = toStatus == null ? null : toStatus.toString(); String entityTypeName = entityType.replaceAll("([a-z])([A-Z])", "$1 $2").toLowerCase(Locale.ROOT); Optional comment = Optional.empty(); - if (from == EntityStatus.IN_REVIEW && to == EntityStatus.APPROVED) { + if (EntityStatus.IN_REVIEW.value().equals(from) && EntityStatus.APPROVED.value().equals(to)) { comment = Optional.of("Approved the " + entityTypeName); - } else if (from == EntityStatus.IN_REVIEW && to == EntityStatus.REJECTED) { + } else if (EntityStatus.IN_REVIEW.value().equals(from) + && EntityStatus.REJECTED.value().equals(to)) { comment = Optional.of("Rejected the " + entityTypeName); - } else if (from != EntityStatus.DRAFT && to == EntityStatus.DRAFT) { + } else if (!EntityStatus.DRAFT.value().equals(from) && EntityStatus.DRAFT.value().equals(to)) { comment = Optional.of("Closed due to " + entityTypeName + " going back to DRAFT."); } return comment; @@ -2272,7 +2281,10 @@ private static boolean readPlanCoversRelations( } private static CachedReadBundle.Dto buildBundleDto( - EntityInterface entity, ReadPlan readPlan, ReadBundle bundle, boolean supportsCertification) { + EntityInterface entity, + ReadPlan readPlan, + ReadBundle bundle, + boolean supportsCertification) { CachedReadBundle.Dto dto = new CachedReadBundle.Dto(); dto.relations = new HashMap<>(); readPlan @@ -2599,7 +2611,7 @@ public List findByNames(List entityFQNs, Include include) { * create/update path. Defaults to true; override to keep specific instances out of the index. * The bulk reindex applies the same rule at the DB-query level via {@link #getReindexFilter()}. */ - public boolean isSearchIndexable(EntityInterface entity) { + public boolean isSearchIndexable(EntityInterface entity) { return true; } @@ -2609,7 +2621,7 @@ public boolean isSearchIndexable(EntityInterface entity) { * reachable through the vector path — for instance when its chunk documents cannot carry the * fields its privacy model needs the vector query to filter on. */ - public boolean isVectorEmbeddable(EntityInterface entity) { + public boolean isVectorEmbeddable(EntityInterface entity) { return isSearchIndexable(entity); } @@ -4385,7 +4397,7 @@ static boolean isCacheableEntityType(String entityType) { /** * Validates entity has required fields for caching */ - private static boolean isValidEntityForCache(EntityInterface entity) { + private static boolean isValidEntityForCache(EntityInterface entity) { return entity != null && entity.getId() != null && entity.getFullyQualifiedName() != null; } @@ -6266,7 +6278,7 @@ public static void validateEnumKeys( } } - public final void storeExtension(EntityInterface entity) { + public final void storeExtension(EntityInterface entity) { if (entity.getExtension() == null) { return; } @@ -6287,7 +6299,7 @@ public final void storeExtensions(List entities) { List entityIds = new ArrayList<>(); List fieldFQNs = new ArrayList<>(); List jsons = new ArrayList<>(); - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { JsonNode jsonNode = JsonUtils.valueToTree(entity.getExtension()); Iterator> customFields = jsonNode.fields(); while (customFields.hasNext()) { @@ -6330,7 +6342,7 @@ protected final void storeColumnExtensions(UUID entityId, List columns) } } - public final void removeExtension(EntityInterface entity) { + public final void removeExtension(EntityInterface entity) { if (entity.getExtension() == null) { return; } @@ -6362,7 +6374,7 @@ public final void removeExtensions(List entities) { } } - private void storeCustomProperty(EntityInterface entity, String fieldName, JsonNode value) { + private void storeCustomProperty(EntityInterface entity, String fieldName, JsonNode value) { String fieldFQN = TypeRegistry.getCustomPropertyFQN(entityType, fieldName); daoCollection .entityExtensionDAO() @@ -6374,7 +6386,7 @@ private void storeCustomProperties( daoCollection.entityExtensionDAO().insertMany(uuids, fieldFQNs, "customFieldSchema", values); } - private void removeCustomProperty(EntityInterface entity, String fieldName) { + private void removeCustomProperty(EntityInterface entity, String fieldName) { String fieldFQN = TypeRegistry.getCustomPropertyFQN(entityType, fieldName); daoCollection.entityExtensionDAO().delete(entity.getId(), fieldFQN); } @@ -6532,7 +6544,7 @@ protected AssetCertification getCertification(T entity) { return buildCertificationFromCertTag(certTags.get(0).toTagLabel()); } - private void fetchAndPutTagsWithCertification(EntityInterface entity, ReadBundle bundle) { + private void fetchAndPutTagsWithCertification(EntityInterface entity, ReadBundle bundle) { String fqn = entity.getFullyQualifiedName(); Map> byHash = populateTagLabel( @@ -6675,7 +6687,7 @@ protected void applyCertificationBatch(List entities) { if (certEntities.isEmpty()) return; List targetFQNs = - certEntities.stream().map(EntityInterface::getFullyQualifiedName).toList(); + certEntities.stream().map(EntityInterface::getFullyQualifiedName).toList(); daoCollection .tagUsageDAO() .deleteTagsByPrefixAndTargets( @@ -8458,7 +8470,7 @@ protected EntityReference getDataContract(T entity, Include include) { return refs.isEmpty() ? null : refs.get(0); } - public EntityInterface getParentEntity(T entity, String fields) { + public EntityInterface getParentEntity(T entity, String fields) { return null; } @@ -8505,13 +8517,13 @@ protected List getExperts(T entity, Include include) { : null); } - public final void inheritDomains(T entity, Fields fields, EntityInterface parent) { + public final void inheritDomains(T entity, Fields fields, EntityInterface parent) { if (fields.contains(FIELD_DOMAINS) && nullOrEmpty(entity.getDomains()) && parent != null) { entity.setDomains(inheritedEntityReferences(parent.getDomains())); } } - public final void inheritDataProducts(T entity, Fields fields, EntityInterface parent) { + public final void inheritDataProducts(T entity, Fields fields, EntityInterface parent) { if (fields.contains(FIELD_DATA_PRODUCTS) && nullOrEmpty(entity.getDataProducts()) && parent != null) { @@ -8519,41 +8531,41 @@ && nullOrEmpty(entity.getDataProducts()) } } - public final void inheritFollowers(T entity, Fields fields, EntityInterface parent) { + public final void inheritFollowers(T entity, Fields fields, EntityInterface parent) { if (fields.contains(FIELD_FOLLOWERS) && nullOrEmpty(entity.getFollowers()) && parent != null) { entity.setFollowers(inheritedEntityReferences(parent.getFollowers())); } } - public final void inheritOwners(T entity, Fields fields, EntityInterface parent) { + public final void inheritOwners(T entity, Fields fields, EntityInterface parent) { if (fields.contains(FIELD_OWNERS) && nullOrEmpty(entity.getOwners()) && parent != null) { entity.setOwners(getInheritedOwners(entity, fields, parent)); } } public final List getInheritedOwners( - T entity, Fields fields, EntityInterface parent) { + T entity, Fields fields, EntityInterface parent) { if (fields.contains(FIELD_OWNERS) && nullOrEmpty(entity.getOwners()) && parent != null) { return inheritedEntityReferences(parent.getOwners()); } return entity.getOwners(); } - public final void inheritExperts(T entity, Fields fields, EntityInterface parent) { + public final void inheritExperts(T entity, Fields fields, EntityInterface parent) { if (fields.contains(FIELD_EXPERTS) && nullOrEmpty(entity.getExperts()) && parent != null) { entity.setExperts(getInheritedExperts(entity, fields, parent)); } } public final List getInheritedExperts( - T entity, Fields fields, EntityInterface parent) { + T entity, Fields fields, EntityInterface parent) { if (fields.contains(FIELD_EXPERTS) && nullOrEmpty(entity.getExperts()) && parent != null) { return inheritedEntityReferences(parent.getExperts()); } return entity.getExperts(); } - public final void inheritReviewers(T entity, Fields fields, EntityInterface parent) { + public final void inheritReviewers(T entity, Fields fields, EntityInterface parent) { if (fields.contains(FIELD_REVIEWERS) && parent != null) { entity.setReviewers( mergedInheritedEntityRefs( @@ -8573,7 +8585,7 @@ public final void inheritReviewers(T entity, Fields fields, EntityInterface pare * it came from. Nothing is persisted; this is a read-time view, so turning the setting off * restores the previous answer immediately and no {@code tag_usage} rows are written. */ - public final void inheritTags(T entity, Fields fields, EntityInterface parent) { + public final void inheritTags(T entity, Fields fields, EntityInterface parent) { if (supportsTags) { applyInheritedTags(entity, fields, parent); } @@ -8583,7 +8595,8 @@ public final void inheritTags(T entity, Fields fields, EntityInterface parent) { * The propagation rules themselves, free of any repository state so they can be exercised * directly. Package-private for {@code InheritTagsTest}. */ - static void applyInheritedTags(EntityInterface entity, Fields fields, EntityInterface parent) { + static void applyInheritedTags( + EntityInterface entity, Fields fields, EntityInterface parent) { if (fields == null || !fields.contains(FIELD_TAGS) || parent == null) { return; } @@ -8870,7 +8883,7 @@ protected BulkOperationResult bulkAssetsOperation( // Create a Change Event on successful addition/removal of assets (skip when dryRun) if (!dryRun && result.getStatus().equals(ApiStatus.SUCCESS)) { - EntityInterface entityInterface = Entity.getEntity(fromEntity, entityId, "id", ALL); + EntityInterface entityInterface = Entity.getEntity(fromEntity, entityId, "id", ALL); ChangeDescription change = addBulkAddRemoveChangeDescription( entityInterface.getVersion(), isAdd, request.getAssets(), null); @@ -8898,12 +8911,12 @@ protected ChangeDescription addBulkAddRemoveChangeDescription( } protected ChangeEvent getChangeEvent( - EntityInterface updated, ChangeDescription change, String entityType, Double prevVersion) { + EntityInterface updated, ChangeDescription change, String entityType, Double prevVersion) { return getChangeEvent(updated, change, entityType, prevVersion, updated.getUpdatedBy()); } protected ChangeEvent getChangeEvent( - EntityInterface updated, + EntityInterface updated, ChangeDescription change, String entityType, Double prevVersion, @@ -9208,7 +9221,7 @@ public CsvImportResult importFromCsv( throw new IllegalArgumentException(csvNotSupported(entityType)); } - public List getAllTags(EntityInterface entity) { + public List getAllTags(EntityInterface entity) { return entity.getTags(); } @@ -10011,13 +10024,13 @@ void updateEntityStatus(boolean consolidatingChanges) { return; } keepStoredEntityStatusWhenOmitted(); - EntityStatus from = original.getEntityStatus(); - EntityStatus to = updated.getEntityStatus(); - if (from != to) { + String from = entityLifecycle.adapter().read(original); + String to = entityLifecycle.adapter().read(updated); + if (!Objects.equals(from, to)) { if (!consolidatingChanges && !isDiffFromSessionStart()) { validateEntityStatusChange(from, to); } - recordChange(FIELD_ENTITY_STATUS, from, to); + recordChange(FIELD_ENTITY_STATUS, original.getEntityStatus(), updated.getEntityStatus()); } } @@ -10032,11 +10045,11 @@ private boolean isDiffFromSessionStart() { // arrives without it and must not reset the stage the entity is in. private void keepStoredEntityStatusWhenOmitted() { if (updated.getEntityStatus() == null) { - updated.setEntityStatus(original.getEntityStatus()); + entityLifecycle.adapter().write(updated, entityLifecycle.adapter().read(original)); } } - private void validateEntityStatusChange(EntityStatus from, EntityStatus to) { + private void validateEntityStatusChange(String from, String to) { EntityRepository.this.validateEntityStatusChange(original, updated, from, to); } @@ -11703,7 +11716,7 @@ static class EntityLoaderWithName extends CacheLoader, Stri private String loadInternal(@NotNull Pair fqnPair, long startEpoch) { String entityType = fqnPair.getLeft(); String fqn = fqnPair.getRight(); - EntityRepository repository = + EntityRepository> repository = Entity.getEntityRepository(entityType); EntityDAO dao = repository.getDao(); @@ -11715,8 +11728,8 @@ private String loadInternal(@NotNull Pair fqnPair, long startEpo if (cachedJson.isPresent()) { LOG.debug("CACHE HIT: Loading entity by name from Redis cache: {} {}", entityType, fqn); try { - Class entityClass = repository.getEntityClass(); - EntityInterface entity = JsonUtils.readValue(cachedJson.get(), entityClass); + Class> entityClass = repository.getEntityClass(); + EntityInterface entity = JsonUtils.readValue(cachedJson.get(), entityClass); if (entity.getId() == null || entity.getFullyQualifiedName() == null) { LOG.error( "CACHE ERROR: Cached entity from name lookup is invalid! Evicting. Type: {}, Name: {}", @@ -11758,7 +11771,7 @@ private String loadInternal(@NotNull Pair fqnPair, long startEpo } // Validate - EntityInterface entity = JsonUtils.readValue(json, repository.getEntityClass()); + EntityInterface entity = JsonUtils.readValue(json, repository.getEntityClass()); if (!isValidEntityForCache(entity)) { LOG.error( "CRITICAL: Entity loaded from database by name is invalid! Type: {}, Name: {}, ID: {}", @@ -11794,9 +11807,9 @@ private void evictExternalCache(Pair fqnPair, String json) { } cachedEntityDao.deleteByName(fqnPair.getLeft(), fqnPair.getRight()); try { - EntityRepository repository = + EntityRepository> repository = Entity.getEntityRepository(fqnPair.getLeft()); - EntityInterface entity = JsonUtils.readValue(json, repository.getEntityClass()); + EntityInterface entity = JsonUtils.readValue(json, repository.getEntityClass()); if (entity.getId() != null) { cachedEntityDao.deleteBase(fqnPair.getLeft(), entity.getId()); } @@ -11826,7 +11839,7 @@ static class EntityLoaderWithId extends CacheLoader, String> private String loadInternal(@NotNull Pair idPair, long startEpoch) { String entityType = idPair.getLeft(); UUID id = idPair.getRight(); - EntityRepository repository = + EntityRepository> repository = Entity.getEntityRepository(entityType); EntityDAO dao = repository.getDao(); @@ -11838,8 +11851,8 @@ private String loadInternal(@NotNull Pair idPair, long startEpoch) if (cachedJson.isPresent()) { LOG.debug("CACHE HIT: Loading entity from Redis cache: {} {}", entityType, id); try { - Class entityClass = repository.getEntityClass(); - EntityInterface entity = JsonUtils.readValue(cachedJson.get(), entityClass); + Class> entityClass = repository.getEntityClass(); + EntityInterface entity = JsonUtils.readValue(cachedJson.get(), entityClass); if (entity.getId() == null) { LOG.error( "CACHE ERROR: Cached entity has null ID! Evicting. Type: {}, Expected ID: {}", @@ -11874,7 +11887,7 @@ private String loadInternal(@NotNull Pair idPair, long startEpoch) } // Validate - EntityInterface entity = JsonUtils.readValue(json, repository.getEntityClass()); + EntityInterface entity = JsonUtils.readValue(json, repository.getEntityClass()); if (!isValidEntityForCache(entity)) { if (entity.getId() == null) { LOG.error( @@ -12288,7 +12301,7 @@ private void fetchAndSetTags(List entities, Fields fields) { } List entityFQNs = - entities.stream().map(EntityInterface::getFullyQualifiedName).toList(); + entities.stream().map(EntityInterface::getFullyQualifiedName).toList(); Map> tagsMap = batchFetchTags(entityFQNs); @@ -12901,7 +12914,7 @@ private Map> batchFetchChildren(List entities) { } List entityListToStrings(List entities) { - return entities.stream().map(EntityInterface::getId).map(UUID::toString).toList(); + return entities.stream().map(EntityInterface::getId).map(UUID::toString).toList(); } private Iterator> serializeJsons( @@ -13151,7 +13164,7 @@ protected void bulkPopulateEntityFieldTags( } protected List entityListToUUID(List entities) { - return entities.stream().map(EntityInterface::getId).toList(); + return entities.stream().map(EntityInterface::getId).toList(); } private boolean isEntityNotFoundError(EntityError error) { @@ -14048,7 +14061,7 @@ private void validateScopeRequest(String scopeEntityType, String scopeFqn) { * persisted) or the scope was already removed - so the caller treats it as zero deletions. */ private boolean scopeExists(String scopeEntityType, String scopeFqn) { - EntityRepository scopeRepository = + EntityRepository> scopeRepository = Entity.getEntityRepository(resolveScopeEntityType(scopeEntityType)); return scopeRepository.findByNameOrNull(scopeFqn, Include.NON_DELETED) != null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/FeedDAOs.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/FeedDAOs.java index 4f8867ce0314..561d25ee0563 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/FeedDAOs.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/FeedDAOs.java @@ -142,7 +142,7 @@ void insertTask( @Bind("id") String id, @BindJson("json") String json, @BindFQN("fqnHash") String fqn); @Override - default void insert(org.openmetadata.schema.EntityInterface entity, String fqn) { + default void insert(org.openmetadata.schema.EntityInterface entity, String fqn) { Task task = (Task) entity; insertTask(task.getId().toString(), JsonUtils.pojoToJson(task), task.getFullyQualifiedName()); } @@ -381,7 +381,7 @@ void insertAnnouncement( @Bind("id") String id, @BindJson("json") String json, @BindFQN("fqnHash") String fqn); @Override - default void insert(org.openmetadata.schema.EntityInterface entity, String fqn) { + default void insert(org.openmetadata.schema.EntityInterface entity, String fqn) { Announcement announcement = (Announcement) entity; insertAnnouncement( announcement.getId().toString(), @@ -418,7 +418,7 @@ void insertTaskFormSchema( @Bind("id") String id, @BindJson("json") String json, @BindFQN("fqnHash") String fqn); @Override - default void insert(org.openmetadata.schema.EntityInterface entity, String fqn) { + default void insert(org.openmetadata.schema.EntityInterface entity, String fqn) { TaskFormSchema schema = (TaskFormSchema) entity; insertTaskFormSchema( schema.getId().toString(), JsonUtils.pojoToJson(schema), schema.getFullyQualifiedName()); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GlossaryRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GlossaryRepository.java index 76b0c8e782bb..6ea484e0fe84 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GlossaryRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GlossaryRepository.java @@ -251,7 +251,7 @@ public String exportToCsv( repository.getFields( "owners,reviewers,tags,relatedTerms,synonyms,extension,parent,domains"), glossary.getFullyQualifiedName()); - terms.sort(Comparator.comparing(EntityInterface::getFullyQualifiedName)); + terms.sort(Comparator.comparing(EntityInterface::getFullyQualifiedName)); return new GlossaryCsv(glossary, user).exportCsv(terms, callback); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GlossaryTermRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GlossaryTermRepository.java index b2dbdd51ef93..5268ba006da7 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GlossaryTermRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GlossaryTermRepository.java @@ -816,7 +816,7 @@ protected boolean requiresParentForInheritance(GlossaryTerm glossaryTerm, Fields @Override protected void applyInheritance( - GlossaryTerm glossaryTerm, Fields fields, EntityInterface parent) { + GlossaryTerm glossaryTerm, Fields fields, EntityInterface parent) { inheritOwners(glossaryTerm, fields, parent); inheritDomains(glossaryTerm, fields, parent); inheritReviewers(glossaryTerm, fields, parent); @@ -828,7 +828,7 @@ protected void applyInheritance( * parent chain. A root term's parent is its glossary, which declares no attributes, so its * effective set is exactly what it declares itself. */ - private void inheritAttributes(GlossaryTerm term, Fields fields, EntityInterface parent) { + private void inheritAttributes(GlossaryTerm term, Fields fields, EntityInterface parent) { if (!fields.contains(FIELD_EFFECTIVE_ATTRIBUTES)) { return; } @@ -1867,7 +1867,7 @@ public BulkOperationResult bulkAddAndValidateGlossaryToAssets( GlossaryTerm term = this.get(null, glossaryTermId, getFields("id,tags")); EntityRepository glossaryRepository = Entity.getEntityRepository(Entity.GLOSSARY); - EntityInterface glossary = + EntityInterface glossary = glossaryRepository.getByName( null, term.getGlossary().getFullyQualifiedName(), glossaryRepository.getFields("tags")); // Check if the tags are mutually exclusive for the glossary @@ -1910,7 +1910,7 @@ public BulkOperationResult bulkAddAndValidateGlossaryToAssets( } EntityRepository entityRepository = Entity.getEntityRepository(ref.getType()); - EntityInterface asset = + EntityInterface asset = entityRepository.get(null, ref.getId(), entityRepository.getFields("tags")); try { @@ -2203,7 +2203,7 @@ public BulkOperationResult bulkRemoveGlossaryToAssets( } EntityRepository entityRepository = Entity.getEntityRepository(ref.getType()); - EntityInterface asset = + EntityInterface asset = entityRepository.get(null, ref.getId(), entityRepository.getFields("id")); // Skip the destructive tag_usage delete + ES update on dryRun so the preview @@ -2322,14 +2322,14 @@ protected EntityReference getParentReference(GlossaryTerm entity) { } @Override - public EntityInterface getParentEntity(GlossaryTerm entity, String fields) { + public EntityInterface getParentEntity(GlossaryTerm entity, String fields) { return entity.getParent() != null ? Entity.getEntity(entity.getParent(), fields, Include.ALL) : Entity.getEntity(entity.getGlossary(), fields, Include.ALL); } - public List getParentEntities(List entities, String fields) { - List result = new ArrayList<>(); + public List> getParentEntities(List entities, String fields) { + List> result = new ArrayList<>(); if (CollectionUtils.isEmpty(entities)) { return result; } @@ -3558,7 +3558,7 @@ public String exportToCsv( List terms = listAllForCSV(fields, glossaryTerm.getFullyQualifiedName()); - terms.sort(Comparator.comparing(EntityInterface::getFullyQualifiedName)); + terms.sort(Comparator.comparing(EntityInterface::getFullyQualifiedName)); return new GlossaryRepository.GlossaryCsv(glossary, user).exportCsv(terms, callback); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GovernanceDAOs.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GovernanceDAOs.java index 74d3c11565e7..6d76939e1742 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GovernanceDAOs.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GovernanceDAOs.java @@ -62,7 +62,7 @@ default boolean supportsSoftDelete() { @Override default int listCount(ListFilter filter) { - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); String directChildrenOf = filter.getQueryParam("directChildrenOf"); String hierarchyFilter = filter.getQueryParam("hierarchyFilter"); @@ -87,7 +87,7 @@ default int listCount(ListFilter filter) { @Override default List listBefore( ListFilter filter, int limit, String beforeName, String beforeId) { - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); String directChildrenOf = filter.getQueryParam("directChildrenOf"); String hierarchyFilter = filter.getQueryParam("hierarchyFilter"); @@ -112,7 +112,7 @@ default List listBefore( @Override default List listAfter(ListFilter filter, int limit, String afterName, String afterId) { - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); String directChildrenOf = filter.getQueryParam("directChildrenOf"); String hierarchyFilter = filter.getQueryParam("hierarchyFilter"); String offsetParam = filter.getQueryParam("offset"); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/IngestionPipelineRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/IngestionPipelineRepository.java index 0461488e16db..46fb2148b228 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/IngestionPipelineRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/IngestionPipelineRepository.java @@ -378,7 +378,7 @@ public void setInheritedFields(IngestionPipeline ingestionPipeline, Fields field return; } try { - EntityInterface parent = Entity.getEntity(serviceRef, "owners,domains", ALL); + EntityInterface parent = Entity.getEntity(serviceRef, "owners,domains", ALL); inheritOwners(ingestionPipeline, fields, parent); inheritDomains(ingestionPipeline, fields, parent); } catch (EntityNotFoundException e) { @@ -897,7 +897,7 @@ protected EntityReference getParentReference(IngestionPipeline entity) { } @Override - public EntityInterface getParentEntity(IngestionPipeline entity, String fields) { + public EntityInterface getParentEntity(IngestionPipeline entity, String fields) { if (entity.getService() == null) { // Try to load the service if it's not set LOG.warn( @@ -920,7 +920,7 @@ public EntityInterface getParentEntity(IngestionPipeline entity, String fields) } protected ChangeEvent getChangeEvent( - EntityInterface updated, ChangeDescription change, String entityType, Double prevVersion) { + EntityInterface updated, ChangeDescription change, String entityType, Double prevVersion) { return new ChangeEvent() .withId(UUID.randomUUID()) .withEntity(updated) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/LLMModelRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/LLMModelRepository.java index 54ac2834269a..729318908c3d 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/LLMModelRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/LLMModelRepository.java @@ -178,7 +178,7 @@ protected EntityReference getParentReference(LLMModel entity) { } @Override - public EntityInterface getParentEntity(LLMModel entity, String fields) { + public EntityInterface getParentEntity(LLMModel entity, String fields) { if (entity.getService() == null) { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/LineageRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/LineageRepository.java index 5b11e132adc9..449d2a653dc8 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/LineageRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/LineageRepository.java @@ -340,9 +340,9 @@ private void buildExtendedLineage( && Entity.entityHasField(to.getType(), FIELD_DATA_PRODUCTS); String fields = getExtendedLineageFields(addService, addDomain, addDataProduct); - EntityInterface fromEntity = + EntityInterface fromEntity = Entity.getEntity(from.getType(), from.getId(), fields, Include.ALL); - EntityInterface toEntity = Entity.getEntity(to.getType(), to.getId(), fields, Include.ALL); + EntityInterface toEntity = Entity.getEntity(to.getType(), to.getId(), fields, Include.ALL); addServiceLineage(fromEntity, toEntity, lineageDetails, priorDetails, childRelationExists); addDomainLineage(fromEntity, toEntity, lineageDetails, childRelationExists); @@ -350,8 +350,8 @@ private void buildExtendedLineage( } private void addServiceLineage( - EntityInterface fromEntity, - EntityInterface toEntity, + EntityInterface fromEntity, + EntityInterface toEntity, LineageDetails entityLineageDetails, LineageDetails priorDetails, boolean childRelationExists) { @@ -474,7 +474,7 @@ private EntityReference getPipelineService(LineageDetails entityLineageDetails) if (!Entity.entityHasField(pipelineRef.getType(), FIELD_SERVICE)) { return null; } - EntityInterface pipelineEntity = + EntityInterface pipelineEntity = Entity.getEntity(pipelineRef.getType(), pipelineRef.getId(), FIELD_SERVICE, Include.ALL); return pipelineEntity.getService(); } @@ -495,8 +495,8 @@ private void insertServiceEdgeIfDistinct( } private void addDomainLineage( - EntityInterface fromEntity, - EntityInterface toEntity, + EntityInterface fromEntity, + EntityInterface toEntity, LineageDetails entityLineageDetails, boolean childRelationExists) { @@ -524,8 +524,8 @@ private void addDomainLineage( } private void addDataProductsLineage( - EntityInterface fromEntity, - EntityInterface toEntity, + EntityInterface fromEntity, + EntityInterface toEntity, LineageDetails entityLineageDetails, boolean childRelationExists) { @@ -550,21 +550,23 @@ private void addDataProductsLineage( } private boolean shouldAddDataProductLineage( - EntityInterface fromEntity, EntityInterface toEntity) { + EntityInterface fromEntity, EntityInterface toEntity) { return Entity.entityHasField(fromEntity.getEntityReference().getType(), FIELD_DATA_PRODUCTS) && Entity.entityHasField(toEntity.getEntityReference().getType(), FIELD_DATA_PRODUCTS) && !nullOrEmpty(fromEntity.getDataProducts()) && !nullOrEmpty(toEntity.getDataProducts()); } - private boolean shouldAddDomainsLineage(EntityInterface fromEntity, EntityInterface toEntity) { + private boolean shouldAddDomainsLineage( + EntityInterface fromEntity, EntityInterface toEntity) { return Entity.entityHasField(fromEntity.getEntityReference().getType(), FIELD_DOMAINS) && Entity.entityHasField(toEntity.getEntityReference().getType(), FIELD_DOMAINS) && !nullOrEmpty(fromEntity.getDomains()) && !nullOrEmpty(toEntity.getDomains()); } - private boolean shouldAddServiceLineage(EntityInterface fromEntity, EntityInterface toEntity) { + private boolean shouldAddServiceLineage( + EntityInterface fromEntity, EntityInterface toEntity) { return Entity.entityHasField(fromEntity.getEntityReference().getType(), FIELD_SERVICE) && Entity.entityHasField(toEntity.getEntityReference().getType(), FIELD_SERVICE) && fromEntity.getService() != null @@ -1191,7 +1193,7 @@ private Set getChildrenNames(EntityReference entityReference) { private Set getRegistryChildrenNames(EntityReference entityReference, String entityType) { // Only the container fields: this path reads child names, so asking for the write path's tags // and constraints would add a tag lookup per lineage edge for nothing. - EntityInterface parent = + EntityInterface parent = Entity.getEntity( entityType, entityReference.getId(), @@ -1360,19 +1362,21 @@ private void cleanUpExtendedLineage( hasField(from, FIELD_DATA_PRODUCTS) && hasField(to, FIELD_DATA_PRODUCTS); String fields = getExtendedLineageFields(addService, addDomain, addDataProduct); - EntityInterface fromEntity = + EntityInterface fromEntity = Entity.getEntity(from.getType(), from.getId(), fields, Include.ALL); - EntityInterface toEntity = Entity.getEntity(to.getType(), to.getId(), fields, Include.ALL); + EntityInterface toEntity = Entity.getEntity(to.getType(), to.getId(), fields, Include.ALL); cleanUpServiceLineage(fromEntity, toEntity, lineageDetails); - cleanupListLineage(fromEntity, toEntity, FIELD_DOMAINS, EntityInterface::getDomains); + cleanupListLineage(fromEntity, toEntity, FIELD_DOMAINS, EntityInterface::getDomains); cleanUpLineageForDataProducts( - fromEntity, toEntity, FIELD_DATA_PRODUCTS, EntityInterface::getDataProducts); + fromEntity, toEntity, FIELD_DATA_PRODUCTS, EntityInterface::getDataProducts); } /** Mirrors {@link #addServiceLineage}: releases exactly the edges that edge's insert created. */ private void cleanUpServiceLineage( - EntityInterface fromEntity, EntityInterface toEntity, LineageDetails entityLineageDetails) { + EntityInterface fromEntity, + EntityInterface toEntity, + LineageDetails entityLineageDetails) { if (!shouldAddServiceLineage(fromEntity, toEntity)) { return; } @@ -1415,10 +1419,10 @@ private boolean hasField(EntityReference entity, String field) { } private void cleanupListLineage( - EntityInterface fromEntity, - EntityInterface toEntity, + EntityInterface fromEntity, + EntityInterface toEntity, String field, - Function> getter) { + Function, List> getter) { boolean hasField = hasField(fromEntity.getEntityReference(), field) && hasField(toEntity.getEntityReference(), field); @@ -1437,10 +1441,10 @@ private void cleanupListLineage( } private void cleanUpLineageForDataProducts( - EntityInterface fromEntity, - EntityInterface toEntity, + EntityInterface fromEntity, + EntityInterface toEntity, String field, - Function> getter) { + Function, List> getter) { boolean hasField = hasField(fromEntity.getEntityReference(), field) && hasField(toEntity.getEntityReference(), field); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ListFilter.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ListFilter.java index e45bdaf0884b..f82bb17abec4 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ListFilter.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ListFilter.java @@ -16,7 +16,6 @@ import org.openmetadata.schema.entity.data.Table; import org.openmetadata.schema.type.AnnouncementStatus; import org.openmetadata.schema.type.Column; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.Include; import org.openmetadata.schema.type.RegexMode; import org.openmetadata.schema.type.Relationship; @@ -39,6 +38,7 @@ public class ListFilter extends Filter { // holding these as fields keeps the sorted and unsorted listings on a single count-cache entry. private String sortField; private String sortOrder; + private String entityTableName; private static final String TASK_STATUS_GROUP_OPEN = "open"; private static final String TASK_STATUS_GROUP_ACTIVE = "active"; @@ -66,6 +66,11 @@ public ListFilter(Include include) { this.include = include; } + public String getConditionForEntity(String tableName) { + entityTableName = tableName; + return getCondition(); + } + public String getSortField() { return sortField; } @@ -585,7 +590,16 @@ private String getEntityStatusCondition(String tableName) { } Set validStatuses = - Arrays.stream(EntityStatus.values()).map(EntityStatus::value).collect(Collectors.toSet()); + Entity.getEntityTypesWithLifecycleStage().stream() + .map(Entity::getEntityRepository) + .filter( + repository -> + repository + .getDao() + .getTableName() + .equals(entityTableName == null ? tableName : entityTableName)) + .flatMap(repository -> repository.getEntityLifecycle().stageCodes().stream()) + .collect(Collectors.toSet()); List statusValues = Arrays.stream(entityStatus.split(",")) .map(String::trim) @@ -594,7 +608,7 @@ private String getEntityStatusCondition(String tableName) { .toList(); if (statusValues.isEmpty()) { - return ""; + return "1 = 0"; } List bindParams = new ArrayList<>(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/McpServerRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/McpServerRepository.java index 4a1d3f91c38d..a1fdd17d2168 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/McpServerRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/McpServerRepository.java @@ -126,7 +126,7 @@ protected EntityReference getParentReference(McpServer entity) { } @Override - public EntityInterface getParentEntity(McpServer entity, String fields) { + public EntityInterface getParentEntity(McpServer entity, String fields) { if (entity.getService() == null) { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/MlModelRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/MlModelRepository.java index aa733770c38e..bd3d8a1ceb94 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/MlModelRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/MlModelRepository.java @@ -510,7 +510,7 @@ protected EntityReference getParentReference(MlModel entity) { } @Override - public EntityInterface getParentEntity(MlModel entity, String fields) { + public EntityInterface getParentEntity(MlModel entity, String fields) { if (entity.getService() == null) { return null; } @@ -518,7 +518,7 @@ public EntityInterface getParentEntity(MlModel entity, String fields) { } @Override - public List getAllTags(EntityInterface entity) { + public List getAllTags(EntityInterface entity) { List allTags = new ArrayList<>(); MlModel mlModel = (MlModel) entity; EntityUtil.mergeTags(allTags, mlModel.getTags()); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/PipelineRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/PipelineRepository.java index 10c20fc4c26c..f33d18969a59 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/PipelineRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/PipelineRepository.java @@ -887,7 +887,7 @@ protected EntityReference getParentReference(Pipeline entity) { } @Override - public EntityInterface getParentEntity(Pipeline entity, String fields) { + public EntityInterface getParentEntity(Pipeline entity, String fields) { if (entity.getService() == null) { return null; } @@ -971,7 +971,7 @@ public EntityRepository.EntityUpdater getUpdater( } @Override - public List getAllTags(EntityInterface entity) { + public List getAllTags(EntityInterface entity) { List allTags = new ArrayList<>(); Pipeline pipeline = (Pipeline) entity; EntityUtil.mergeTags(allTags, pipeline.getTags()); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ReadPlanner.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ReadPlanner.java index 32fff22b20df..e089bf49f64f 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ReadPlanner.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ReadPlanner.java @@ -36,7 +36,7 @@ record ReadPlannerConfig( boolean supportsVotes) {} ReadPlanBuilder newBuilder( - EntityInterface entity, + EntityInterface entity, Fields fields, RelationIncludes relationIncludes, ReadPlannerConfig config) { @@ -108,7 +108,7 @@ ReadPlanBuilder newBuilder( } ReadPlan build( - EntityInterface entity, + EntityInterface entity, Fields fields, RelationIncludes relationIncludes, ReadPlannerConfig config) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/RecognizerFeedbackRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/RecognizerFeedbackRepository.java index c0c0402247b7..b0f071a57185 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/RecognizerFeedbackRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/RecognizerFeedbackRepository.java @@ -243,7 +243,7 @@ public UUID getRecognizerIdFromTagLabel(String entityLink, String tagFQN) { return null; } - org.openmetadata.schema.EntityInterface entity = + org.openmetadata.schema.EntityInterface entity = repository.getByName(null, entityFQN, repository.getFields("tags")); List tagsToCheck = null; @@ -321,7 +321,7 @@ private void validateTagIsAutoApplied(String entityLink, String tagFQN) { throw new IllegalArgumentException("Unknown entity type: " + entityType); } - org.openmetadata.schema.EntityInterface entity = + org.openmetadata.schema.EntityInterface entity = repository.getByName(null, entityFQN, repository.getFields("tags")); List tagsToCheck = null; @@ -404,10 +404,10 @@ private void removeTagFromEntity(String entityLink, String tagFQN, String update return; } - org.openmetadata.schema.EntityInterface entity = + org.openmetadata.schema.EntityInterface entity = repository.getByName(null, entityFQN, repository.getFields("tags")); - org.openmetadata.schema.EntityInterface originalEntity = + org.openmetadata.schema.EntityInterface originalEntity = JsonUtils.readValue(JsonUtils.pojoToJson(entity), entity.getClass()); boolean entityModified = false; diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/RelationshipTypeRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/RelationshipTypeRepository.java index fade5bf35ded..b37b5d52acd8 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/RelationshipTypeRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/RelationshipTypeRepository.java @@ -186,7 +186,7 @@ private void publishOntologyEvent(final RelationshipType entity) { // System-defined relationship types ship with the ontology and are in use from the start. @Override - protected EntityStatus initialEntityStatus(RelationshipType entity) { + protected Enum initialEntityStatus(RelationshipType entity) { return Boolean.TRUE.equals(entity.getSystemDefined()) && entity.getEntityStatus() == null ? EntityStatus.APPROVED : super.initialEntityStatus(entity); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/SearchIndexRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/SearchIndexRepository.java index 9d4a70279b6c..e9dd9f0f89c7 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/SearchIndexRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/SearchIndexRepository.java @@ -370,7 +370,7 @@ protected EntityReference getParentReference(SearchIndex entity) { } @Override - public EntityInterface getParentEntity(SearchIndex entity, String fields) { + public EntityInterface getParentEntity(SearchIndex entity, String fields) { if (entity.getService() == null) { return null; } @@ -378,7 +378,7 @@ public EntityInterface getParentEntity(SearchIndex entity, String fields) { } @Override - public List getAllTags(EntityInterface entity) { + public List getAllTags(EntityInterface entity) { List allTags = new ArrayList<>(); SearchIndex searchIndex = (SearchIndex) entity; EntityUtil.mergeTags(allTags, searchIndex.getTags()); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ServiceEntityRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ServiceEntityRepository.java index 5c5bb9cf6b8c..514aa977e388 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ServiceEntityRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ServiceEntityRepository.java @@ -338,7 +338,7 @@ private boolean anotherServiceGoesByName(String name, UUID excludedServiceId) { private boolean serviceWithNameExists( String serviceEntityType, String name, UUID excludedServiceId) { try { - EntityInterface other = + EntityInterface other = Entity.getEntityByName(serviceEntityType, name, "", Include.NON_DELETED); return !other.getId().equals(excludedServiceId); } catch (EntityNotFoundException e) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ServicesOverviewRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ServicesOverviewRepository.java index dbf6661047e9..71fbabd39853 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ServicesOverviewRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ServicesOverviewRepository.java @@ -341,10 +341,11 @@ private Map> groupByType(List page) { @SuppressWarnings("unchecked") private List hydrateType( String entityType, List ids, ServicesOverviewRequest r) { - EntityRepository repository = Entity.getEntityRepository(entityType); - List entities = - (List) repository.getDao().findEntitiesByIds(ids, r.include()); - ((EntityRepository) repository) + EntityRepository> repository = + Entity.getEntityRepository(entityType); + List> entities = + (List>) repository.getDao().findEntitiesByIds(ids, r.include()); + ((EntityRepository>) repository) .setFieldsInBulk(repository.getFields(SUMMARY_FIELDS), entities); return entities.stream().map(entity -> toSummary(entity, entityType)).toList(); } @@ -356,7 +357,7 @@ private ServiceSummary withHealth( : summary; } - private ServiceSummary toSummary(EntityInterface entity, String entityType) { + private ServiceSummary toSummary(EntityInterface entity, String entityType) { return new ServiceSummary() .withId(entity.getId()) .withEntityType(entityType) @@ -376,7 +377,7 @@ private ServiceSummary toSummary(EntityInterface entity, String entityType) { * types with no shared interface, so the value is read reflectively rather than through a cast * ladder. The column is also generated from this same JSON field, so it always exists. */ - private String serviceTypeOf(EntityInterface entity) { + private String serviceTypeOf(EntityInterface entity) { String serviceType = null; try { Object value = entity.getClass().getMethod("getServiceType").invoke(entity); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/StoredProcedureRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/StoredProcedureRepository.java index 7ccc0a6f815b..b1427c3d676f 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/StoredProcedureRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/StoredProcedureRepository.java @@ -196,7 +196,7 @@ protected String getInheritableFields() { @Override protected void applyInheritance( - StoredProcedure entity, EntityUtil.Fields fields, EntityInterface parent) { + StoredProcedure entity, EntityUtil.Fields fields, EntityInterface parent) { if (!(parent instanceof DatabaseSchema schema)) { return; } @@ -259,7 +259,7 @@ protected EntityReference getParentReference(StoredProcedure entity) { } @Override - public EntityInterface getParentEntity(StoredProcedure entity, String fields) { + public EntityInterface getParentEntity(StoredProcedure entity, String fields) { return Entity.getEntity(entity.getDatabaseSchema(), fields, Include.ALL); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TableRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TableRepository.java index 7b120136f37a..a6e0b7a869b1 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TableRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TableRepository.java @@ -1830,7 +1830,7 @@ public List getSearchPropagationDescriptors() { } @Override - protected void applyInheritance(Table entity, Fields fields, EntityInterface parent) { + protected void applyInheritance(Table entity, Fields fields, EntityInterface parent) { inheritOwners(entity, fields, parent); inheritDomains(entity, fields, parent); inheritTags(entity, fields, parent); @@ -1843,7 +1843,7 @@ protected void applyInheritance(Table entity, Fields fields, EntityInterface par } @Override - public EntityInterface getParentEntity(Table entity, String fields) { + public EntityInterface getParentEntity(Table entity, String fields) { return Entity.getEntity(entity.getDatabaseSchema(), fields, ALL); } @@ -1854,7 +1854,7 @@ public void validateTags(Table entity) { } @Override - public List getAllTags(EntityInterface entity) { + public List getAllTags(EntityInterface entity) { List allTags = new ArrayList<>(); Table table = (Table) entity; EntityUtil.mergeTags(allTags, table.getTags()); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TagRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TagRepository.java index 6e318c5f14a0..7a9414f51ad6 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TagRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TagRepository.java @@ -528,7 +528,7 @@ public BulkOperationResult bulkAddAndValidateTagsToAssets( } EntityRepository entityRepository = Entity.getEntityRepository(ref.getType()); - EntityInterface asset = + EntityInterface asset = entityRepository.get(null, ref.getId(), entityRepository.getFields("tags")); try { @@ -683,7 +683,7 @@ public BulkOperationResult bulkRemoveAndValidateTagsToAssets( } EntityRepository entityRepository = Entity.getEntityRepository(ref.getType()); - EntityInterface asset = + EntityInterface asset = entityRepository.get(null, ref.getId(), entityRepository.getFields("id")); // Skip the destructive tag_usage delete + ES update on dryRun so the preview diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseRepository.java index 7eeb1ae466c9..32d0e0feac10 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseRepository.java @@ -833,7 +833,7 @@ private List filterMutuallyExclusiveConflicts( } @Override - public EntityInterface getParentEntity(TestCase entity, String fields) { + public EntityInterface getParentEntity(TestCase entity, String fields) { EntityReference testSuite = entity.getTestSuite(); if (testSuite == null) { @@ -910,11 +910,11 @@ public void prepare(TestCase test, boolean update) { */ EntityReference getOrCreateTestSuite(TestCase test) { var entityLink = EntityLink.parse(test.getEntityLink()); - EntityInterface tableEntity = Entity.getEntity(entityLink, "", ALL); + EntityInterface tableEntity = Entity.getEntity(entityLink, "", ALL); return getOrCreateTestSuite(test, tableEntity); } - private EntityReference getOrCreateTestSuite(TestCase test, EntityInterface tableEntity) { + private EntityReference getOrCreateTestSuite(TestCase test, EntityInterface tableEntity) { try { return getTestSuite(tableEntity.getId(), TEST_SUITE, TABLE, Direction.TO); } catch (EntityNotFoundException e) { @@ -2355,8 +2355,8 @@ public static class TestCaseCsv extends EntityCsv { private final TestSuite targetBundleSuite; private final List importedTestCaseIds = new ArrayList<>(); private final Map importedTestSuiteIds = new HashMap<>(); - private final EntityRepository versioningRepo = - (EntityRepository) Entity.getEntityRepository(TEST_SUITE); + private final EntityRepository> versioningRepo = + (EntityRepository>) Entity.getEntityRepository(TEST_SUITE); private final SubjectContext subjectContext; TestCaseCsv(String user, TestSuite targetBundleSuite) { @@ -2586,7 +2586,7 @@ private String resolveInDomainTargetLink(String entityFQN) { String entityLink = null; try { String candidate = convertFQNToEntityLink(entityFQN); - EntityInterface target = + EntityInterface target = Entity.getEntity(EntityLink.parse(candidate), FIELD_DOMAINS, Include.NON_DELETED); if (subjectContext.hasDomains(target.getDomains())) { entityLink = candidate; diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseResolutionStatusRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseResolutionStatusRepository.java index 2232d49172c0..9b3ae215f0e1 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseResolutionStatusRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseResolutionStatusRepository.java @@ -739,7 +739,7 @@ public void inferIncidentSeverity(TestCaseResolutionStatus incident) { "", Include.ALL); MessageParser.EntityLink entityLink = MessageParser.EntityLink.parse(testCase.getEntityLink()); - EntityInterface entity = + EntityInterface entity = Entity.getEntityByName( entityLink.getEntityType(), entityLink.getEntityFQN(), diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestSuiteRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestSuiteRepository.java index 565030f32e23..4cc151388b1d 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestSuiteRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestSuiteRepository.java @@ -339,7 +339,7 @@ protected EntityReference getParentReference(TestSuite entity) { } @Override - public EntityInterface getParentEntity(TestSuite entity, String fields) { + public EntityInterface getParentEntity(TestSuite entity, String fields) { if (entity.getBasic() && entity.getBasicEntityReference() != null) { var filteredFields = EntityUtil.getFilteredFields(TABLE, fields); return Entity.getEntity(entity.getBasicEntityReference(), filteredFields, ALL); @@ -601,7 +601,7 @@ protected void postCreate(TestSuite entity) { super.postCreate(entity); if (Boolean.TRUE.equals(entity.getBasic()) && entity.getBasicEntityReference() != null) { // Update table index with test suite field - EntityInterface entityInterface = + EntityInterface entityInterface = getEntity(entity.getBasicEntityReference(), "testSuite", ALL); IndexMapping indexMapping = searchRepository.getIndexMapping(entity.getBasicEntityReference().getType()); @@ -672,7 +672,7 @@ protected void fetchAndSetIngestionPipelines(List entities, EntityUti Map> ingestionPipelineMap = entities.stream() - .collect(Collectors.toMap(EntityInterface::getId, this::getIngestionPipelines)); + .collect(Collectors.toMap(EntityInterface::getId, this::getIngestionPipelines)); setFieldFromMap(true, entities, ingestionPipelineMap, TestSuite::setPipelines); } @@ -1056,7 +1056,7 @@ private void createTestSuiteCompletionChangeEvent(TestSuite testSuite, Double pr private class TestSuitePipelineStatusHandler implements EntityLifecycleEventHandler { @Override public void onEntityUpdated( - EntityInterface entity, + EntityInterface entity, ChangeDescription changeDescription, SubjectContext subjectContext) { if (!(entity instanceof IngestionPipeline pipeline)) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TopicRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TopicRepository.java index 3fdd79819ded..e205c8e668e9 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TopicRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TopicRepository.java @@ -401,7 +401,7 @@ protected EntityReference getParentReference(Topic entity) { } @Override - public EntityInterface getParentEntity(Topic entity, String fields) { + public EntityInterface getParentEntity(Topic entity, String fields) { if (entity.getService() == null) { return null; } @@ -417,7 +417,7 @@ public void validateTags(Topic entity) { } @Override - public List getAllTags(EntityInterface entity) { + public List getAllTags(EntityInterface entity) { List allTags = new ArrayList<>(); Topic topic = (Topic) entity; EntityUtil.mergeTags(allTags, topic.getTags()); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/UsageRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/UsageRepository.java index 64b191f42c3e..a494969ec3d6 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/UsageRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/UsageRepository.java @@ -246,7 +246,7 @@ private void insertToUsageRepository( } private ChangeEvent getChangeEvent( - EntityInterface updated, ChangeDescription change, String entityType, Double prevVersion) { + EntityInterface updated, ChangeDescription change, String entityType, Double prevVersion) { return new ChangeEvent() .withId(UUID.randomUUID()) .withEntity(updated) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/UserRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/UserRepository.java index 079bc8e76375..f4b7ce9f4dfe 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/UserRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/UserRepository.java @@ -1914,7 +1914,7 @@ private void updateTeams(User original, User updated) { Stream.concat(added.stream(), deleted.stream()) .forEach( teamRef -> { - EntityInterface team = Entity.getEntity(teamRef, "id,userCount", Include.ALL); + EntityInterface team = Entity.getEntity(teamRef, "id,userCount", Include.ALL); searchRepository.updateEntityIndex(team); }); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/WorkflowDocStoreDAOs.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/WorkflowDocStoreDAOs.java index 7b112704e87c..7a886edbb215 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/WorkflowDocStoreDAOs.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/WorkflowDocStoreDAOs.java @@ -110,7 +110,7 @@ default List listBefore( ListFilter filter, int limit, String beforeName, String beforeId) { String workflowType = filter.getQueryParam("workflowType"); String workflowStatus = filter.getQueryParam("workflowStatus"); - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); if (workflowType == null && workflowStatus == null) { return EntityDAO.super.listBefore(filter, limit, beforeName, beforeId); @@ -140,7 +140,7 @@ default List listBefore( default List listAfter(ListFilter filter, int limit, String afterName, String afterId) { String workflowType = filter.getQueryParam("workflowType"); String workflowStatus = filter.getQueryParam("workflowStatus"); - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); if (workflowType == null && workflowStatus == null) { return EntityDAO.super.listAfter(filter, limit, afterName, afterId); @@ -170,7 +170,7 @@ default List listAfter(ListFilter filter, int limit, String afterName, S default int listCount(ListFilter filter) { String workflowType = filter.getQueryParam("workflowType"); String workflowStatus = filter.getQueryParam("workflowStatus"); - String condition = filter.getCondition(); + String condition = filter.getConditionForEntity(getTableName()); if (workflowType == null && workflowStatus == null) { return EntityDAO.super.listCount(filter); @@ -279,7 +279,7 @@ default List listBefore( String fqnPrefix = filter.getQueryParam("fqnPrefix"); String excludedEntityType = filter.getQueryParam(PrivateDocumentType.EXCLUDED_ENTITY_TYPE_FILTER); - String cond = filter.getCondition(); + String cond = filter.getConditionForEntity(getTableName()); if (entityType == null && fqnPrefix == null && excludedEntityType == null) { return EntityDAO.super.listBefore(filter, limit, beforeName, beforeId); } @@ -320,7 +320,7 @@ default List listAfter(ListFilter filter, int limit, String afterName, S String fqnPrefix = filter.getQueryParam("fqnPrefix"); String excludedEntityType = filter.getQueryParam(PrivateDocumentType.EXCLUDED_ENTITY_TYPE_FILTER); - String cond = filter.getCondition(); + String cond = filter.getConditionForEntity(getTableName()); if (entityType == null && fqnPrefix == null && excludedEntityType == null) { return EntityDAO.super.listAfter(filter, limit, afterName, afterId); @@ -361,7 +361,7 @@ default int listCount(ListFilter filter) { String fqnPrefix = filter.getQueryParam("fqnPrefix"); String excludedEntityType = filter.getQueryParam(PrivateDocumentType.EXCLUDED_ENTITY_TYPE_FILTER); - String cond = filter.getCondition(); + String cond = filter.getConditionForEntity(getTableName()); if (entityType == null && fqnPrefix == null && excludedEntityType == null) { return EntityDAO.super.listCount(filter); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/lineage/LineageHydrator.java b/openmetadata-service/src/main/java/org/openmetadata/service/lineage/LineageHydrator.java index beaff023497a..f24374562a54 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/lineage/LineageHydrator.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/lineage/LineageHydrator.java @@ -107,7 +107,7 @@ public HydrateLineageResponse hydrate( Map> entitiesByType = new LinkedHashMap<>(idsByType.size()); int returnedCount = 0; for (Map.Entry> entry : idsByType.entrySet()) { - List hydrated = + List> hydrated = hydrateAndAuthorize( uriInfo, securityContext, @@ -199,13 +199,13 @@ private void authorizeLineageType( Set authorized, Map.Entry> entry) { try { - EntityRepository repository = + EntityRepository> repository = Entity.getEntityRepository(entry.getKey()); Fields fields = repository.getOnlySupportedFields(AUTHORIZATION_FIELDS); - List entities = + List> entities = hydrateAndAuthorize( null, securityContext, entry.getKey(), entry.getValue(), fields, include, repository); - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { authorized.add(new EntityKey(entry.getKey(), entity.getId())); } } catch (EntityNotFoundException exception) { @@ -213,7 +213,7 @@ private void authorizeLineageType( } } - private List hydrateAndAuthorize( + private > List hydrateAndAuthorize( UriInfo uriInfo, SecurityContext securityContext, String entityType, diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/lineage/LineagePermissionFilter.java b/openmetadata-service/src/main/java/org/openmetadata/service/lineage/LineagePermissionFilter.java index 8649a820046c..5fbc4777a49f 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/lineage/LineagePermissionFilter.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/lineage/LineagePermissionFilter.java @@ -145,7 +145,7 @@ private Set visibleIds(SecurityContext securityContext, List void addVisibleFromBucket( + private > void addVisibleFromBucket( SecurityContext securityContext, String entityType, List refs, @@ -164,14 +164,14 @@ private void addVisibleFromBucket( } } - private BulkFieldHydrator tagHydrator( + private > BulkFieldHydrator tagHydrator( EntityRepository repository, List entities) { return new BulkFieldHydrator( Map.of(Entity.FIELD_TAGS, () -> repository.batchLoadTags(new ArrayList<>(entities)))); } @SuppressWarnings("unchecked") - private EntityRepository repositoryOrNull(String entityType) { + private > EntityRepository repositoryOrNull(String entityType) { EntityRepository repository = null; try { repository = (EntityRepository) Entity.getEntityRepository(entityType); @@ -182,7 +182,7 @@ private EntityRepository repositoryOrNull(String return repository; } - private List loadForAuthorization( + private > List loadForAuthorization( EntityRepository repository, String entityType, List refs) { List entities = List.of(); List ids = refs.stream().map(EntityReference::getId).filter(Objects::nonNull).toList(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/lock/HierarchicalLockManager.java b/openmetadata-service/src/main/java/org/openmetadata/service/lock/HierarchicalLockManager.java index 99b4e3ea68bb..c374c21a215d 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/lock/HierarchicalLockManager.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/lock/HierarchicalLockManager.java @@ -41,7 +41,7 @@ public HierarchicalLockManager(DeletionLockDAO lockDAO) { */ @Transaction public DeletionLock acquireDeletionLock( - EntityInterface entity, String lockedBy, boolean cascade) { + EntityInterface entity, String lockedBy, boolean cascade) { // Check if any parent is already locked checkParentLocks(entity); @@ -96,7 +96,7 @@ public DeletionLock acquireDeletionLock( /** * Check if any parent entity has an active deletion lock */ - private void checkParentLocks(EntityInterface entity) { + private void checkParentLocks(EntityInterface entity) { String fqn = entity.getFullyQualifiedName(); List parentFqns = getParentFqns(fqn); @@ -119,7 +119,7 @@ private void checkParentLocks(EntityInterface entity) { /** * Check if entity creation/update is allowed (no parent deletion in progress) */ - public void checkModificationAllowed(EntityInterface entity) { + public void checkModificationAllowed(EntityInterface entity) { String fqn = entity.getFullyQualifiedName(); // Fast path: check cache first @@ -133,7 +133,7 @@ public void checkModificationAllowed(EntityInterface entity) { * Batch check if entities creation/update is allowed (no parent deletion in progress) * More efficient than calling checkModificationAllowed for each entity */ - public void checkModificationsAllowed(List entities) { + public void checkModificationsAllowed(List> entities) { if (entities == null || entities.isEmpty()) { return; } @@ -141,7 +141,7 @@ public void checkModificationsAllowed(List entities) // Collect all FQNs Set allFqns = entities.stream() - .map(EntityInterface::getFullyQualifiedName) + .map(EntityInterface::getFullyQualifiedName) .filter(Objects::nonNull) .collect(java.util.stream.Collectors.toSet()); @@ -155,7 +155,7 @@ public void checkModificationsAllowed(List entities) } // Slow path: for potentially locked FQNs, check database - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { String fqn = entity.getFullyQualifiedName(); if (fqn != null && potentiallyLocked.contains(fqn)) { checkParentLocks(entity); @@ -325,7 +325,7 @@ private void invalidateFqnCache(String fqn) { /** * Estimate completion time based on entity type and cascade scope */ - private Instant estimateCompletionTime(EntityInterface entity, boolean cascade) { + private Instant estimateCompletionTime(EntityInterface entity, boolean cascade) { // Simple estimation - can be made more sophisticated based on entity counts int estimatedMinutes = cascade ? 30 : 5; diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/mapper/EntityMapper.java b/openmetadata-service/src/main/java/org/openmetadata/service/mapper/EntityMapper.java index 2f0f0d9a9eee..4221ec4faa54 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/mapper/EntityMapper.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/mapper/EntityMapper.java @@ -14,7 +14,7 @@ import org.openmetadata.service.Entity; import org.openmetadata.service.rules.RuleEngine; -public interface EntityMapper { +public interface EntityMapper, C extends CreateEntity> { T createToEntity(C create, String user); default T copy(T entity, CreateEntity request, String updatedBy) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/mapper/EntityUpdateMapper.java b/openmetadata-service/src/main/java/org/openmetadata/service/mapper/EntityUpdateMapper.java index 1478953cdf72..5a6e55ded0d1 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/mapper/EntityUpdateMapper.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/mapper/EntityUpdateMapper.java @@ -2,7 +2,7 @@ import org.openmetadata.schema.EntityInterface; -public interface EntityUpdateMapper { +public interface EntityUpdateMapper, U> { String getFqn(U update); void applyEntitySpecificUpdates(T original, U update); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v110/MigrationUtil.java b/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v110/MigrationUtil.java index 5802199c48b9..943d62e29401 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v110/MigrationUtil.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v110/MigrationUtil.java @@ -97,14 +97,14 @@ private MigrationUtil() { "UPDATE field_relationship SET fromFQNHash = :fromFQNHash, toFQNHash = :toFQNHash where fromFQN= :fromFQN and toFQN = :toFQN"; @SneakyThrows - public static void updateFQNHashForEntity( + public static > void updateFQNHashForEntity( Handle handle, Class clazz, EntityDAO dao, int limitParam) { String nameHashColumn = dao.getNameHashColumn(); updateFQNHashForEntity(handle, clazz, dao, limitParam, nameHashColumn); } @SneakyThrows - public static void updateFQNHashForEntity( + public static > void updateFQNHashForEntity( Handle handle, Class clazz, EntityDAO dao, int limitParam, String nameHashColumn) { if (Boolean.TRUE.equals(DatasourceConfig.getInstance().isMySQL())) { handle.execute(String.format(COLUMN_CHECK, dao.getTableName())); @@ -129,14 +129,14 @@ public static void updateFQNHashForEntity( } @SneakyThrows - public static void updateFQNHashForEntityWithName( + public static > void updateFQNHashForEntityWithName( Handle handle, Class clazz, EntityDAO dao, int limitParam) { String nameHashColumn = dao.getNameHashColumn(); updateFQNHashForEntityWithName(handle, clazz, dao, limitParam, nameHashColumn); } @SneakyThrows - public static void updateFQNHashForEntityWithName( + public static > void updateFQNHashForEntityWithName( Handle handle, Class clazz, EntityDAO dao, int limitParam, String nameHashColumn) { if (Boolean.TRUE.equals(DatasourceConfig.getInstance().isMySQL())) { readAndProcessEntity( @@ -159,7 +159,7 @@ public static void updateFQNHashForEntityWithName( } } - public static void readAndProcessEntity( + public static > void readAndProcessEntity( Handle handle, String updateSql, Class clazz, diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v11212/MigrationUtil.java b/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v11212/MigrationUtil.java index 1d0696632504..923a2dc3bfd5 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v11212/MigrationUtil.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v11212/MigrationUtil.java @@ -105,7 +105,7 @@ private static void addStaleLinkIfMoved( return; } try { - EntityInterface term = + EntityInterface term = Entity.getEntity(GLOSSARY_TERM_TYPE, UUID.fromString(entityId), "", Include.NON_DELETED); String newLink = new EntityLink(GLOSSARY_TERM_TYPE, term.getFullyQualifiedName()).getLinkString(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v1126/MigrationUtil.java b/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v1126/MigrationUtil.java index dd76995f83fe..07cadf7a7ebd 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v1126/MigrationUtil.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v1126/MigrationUtil.java @@ -101,13 +101,13 @@ private static void collectPipelineServiceEdges( return; } - EntityInterface fromEntity = + EntityInterface fromEntity = Entity.getEntity( record.getFromEntity(), UUID.fromString(record.getFromId()), "service", Include.ALL); - EntityInterface toEntity = + EntityInterface toEntity = Entity.getEntity( record.getToEntity(), UUID.fromString(record.getToId()), "service", Include.ALL); - EntityInterface pipelineEntity = + EntityInterface pipelineEntity = Entity.getEntity(pipelineRef.getType(), pipelineRef.getId(), "service", Include.ALL); EntityReference fromService = fromEntity.getService(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v1129/MigrationUtil.java b/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v1129/MigrationUtil.java index 84a65fbfd569..b2eb04b324f4 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v1129/MigrationUtil.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v1129/MigrationUtil.java @@ -247,7 +247,7 @@ private List fetchDomainIds(MessageParser.EntityLink entityLink) { if (ref == null || ref.getId() == null) return Collections.emptyList(); Object entity = repo.get(null, ref.getId(), repo.getFields(Entity.FIELD_DOMAINS)); - if (!(entity instanceof EntityInterface ei)) { + if (!(entity instanceof EntityInterface ei)) { return Collections.emptyList(); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v1131/MigrationUtil.java b/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v1131/MigrationUtil.java index 647c35a334d6..58d3db73d62a 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v1131/MigrationUtil.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v1131/MigrationUtil.java @@ -217,7 +217,7 @@ public static List repairChildFqns(CollectionDAO collectionDAO) { return summaries; } - private static RepairSummary repairEntityType( + private static > RepairSummary repairEntityType( EntityRepair repair) { List failedEntityIds = new ArrayList<>(); int scanned = 0; @@ -244,7 +244,7 @@ private static RepairSummary repairEntityType( return summary; } - private static RowRepair repairRow( + private static > RowRepair repairRow( EntityRepair repair, String json, List failedEntityIds) { int childCount = 0; boolean failed = false; @@ -421,7 +421,7 @@ private record FqnAccessor( BiConsumer setFqn, Function> children) {} - private record EntityRepair( + private record EntityRepair>( String entityType, EntityDAO entityDAO, Class entityClass, @@ -570,19 +570,19 @@ private static void collectPipelineServiceEdges( return; } - EntityInterface fromEntity = + EntityInterface fromEntity = Entity.getEntity( record.getFromEntity(), UUID.fromString(record.getFromId()), Entity.FIELD_SERVICE, Include.ALL); - EntityInterface toEntity = + EntityInterface toEntity = Entity.getEntity( record.getToEntity(), UUID.fromString(record.getToId()), Entity.FIELD_SERVICE, Include.ALL); - EntityInterface pipelineEntity = + EntityInterface pipelineEntity = Entity.getEntity( pipelineRef.getType(), pipelineRef.getId(), Entity.FIELD_SERVICE, Include.ALL); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v170/MigrationUtil.java b/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v170/MigrationUtil.java index 90be77a309df..656e8ebfdc78 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v170/MigrationUtil.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v170/MigrationUtil.java @@ -487,7 +487,7 @@ private static List getAllServicesForLineageExcludingDri serviceTypes.remove(ServiceType.MCP); // Exclude MCP as it doesn't exist until v1.13.0 for (ServiceType serviceType : serviceTypes) { - EntityRepository repository = + EntityRepository> repository = Entity.getServiceEntityRepository(serviceType); ListFilter filter = new ListFilter(Include.ALL); List services = diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v200/MigrationUtil.java b/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v200/MigrationUtil.java index 9f61b87b8b2e..87fe22b4c9fa 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v200/MigrationUtil.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v200/MigrationUtil.java @@ -1038,7 +1038,7 @@ private static String lookupEntityIdByFqn(String entityType, String entityFQN) { EntityRepository repo = Entity.getEntityRepository(entityType); Object entity = repo.getByName(null, entityFQN, repo.getFields(""), Include.NON_DELETED, true); - if (entity instanceof EntityInterface ei && ei.getId() != null) { + if (entity instanceof EntityInterface ei && ei.getId() != null) { resolvedId = ei.getId().toString(); } } catch (Exception e) { @@ -1779,7 +1779,7 @@ private static List resolveDomainsViaRepository( } Object entity = repo.get(null, UUID.fromString(entityId), repo.getFields(Entity.FIELD_DOMAINS)); - if (!(entity instanceof EntityInterface ei)) { + if (!(entity instanceof EntityInterface ei)) { DOMAIN_CACHE.put(cacheKey, Collections.emptyList()); return Collections.emptyList(); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v203/ServiceLineagePipelineRoutingMigration.java b/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v203/ServiceLineagePipelineRoutingMigration.java index 5b91414213cd..e7ee529b6d3e 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v203/ServiceLineagePipelineRoutingMigration.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v203/ServiceLineagePipelineRoutingMigration.java @@ -277,7 +277,7 @@ private static EntityReference serviceOf( .get( entityId, id -> { - EntityInterface entity = + EntityInterface entity = Entity.getEntity(entityType, UUID.fromString(id), SERVICE_FIELD, Include.ALL); return Optional.ofNullable(entity.getService()); }) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v210/DottedServiceFqnMigration.java b/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v210/DottedServiceFqnMigration.java index a85c12105739..4da37c6731d2 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v210/DottedServiceFqnMigration.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v210/DottedServiceFqnMigration.java @@ -163,7 +163,7 @@ private static void repairServiceChildren( RepairTally tally) { try { // Include.ALL so a soft-deleted service still has its (also soft-deleted) children repaired. - EntityInterface service = + EntityInterface service = hierarchy.serviceDao().apply(collectionDAO).findEntityById(serviceId, Include.ALL); String serviceFqn = service == null ? null : service.getFullyQualifiedName(); // Only a quoted service FQN could have produced the unquoted-dotted corruption. @@ -197,8 +197,8 @@ private static void repairChildBatch( RepairTally tally) { // Include.ALL so soft-deleted children (still linked to the service) are repaired too; a later // restore would otherwise keep the invalid FQN/hash and duplicate on re-ingestion. - List children = childDao.findEntitiesByIds(childIds, Include.ALL); - for (EntityInterface child : children) { + List> children = childDao.findEntitiesByIds(childIds, Include.ALL); + for (EntityInterface child : children) { recordOutcome(tally, child.getId(), repairChild(childDao, childType, serviceFqn, child)); } } @@ -212,7 +212,7 @@ private static void recordOutcome(RepairTally tally, UUID childId, RepairOutcome } private static RepairOutcome repairChild( - EntityDAO childDao, String childType, String serviceFqn, EntityInterface child) { + EntityDAO childDao, String childType, String serviceFqn, EntityInterface child) { try { String expectedFqn = FullyQualifiedName.add(serviceFqn, child.getName()); if (expectedFqn.equals(child.getFullyQualifiedName())) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/downstream/impl/DataContractLineageResolver.java b/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/downstream/impl/DataContractLineageResolver.java index f8fadb2864c0..56faa09c353f 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/downstream/impl/DataContractLineageResolver.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/downstream/impl/DataContractLineageResolver.java @@ -67,7 +67,7 @@ public Set resolveTraversalEntities(UUID entityId, String entit DataContract dataContract = null; try { - EntityInterface contractEntity = + EntityInterface contractEntity = Entity.getEntity(Entity.DATA_CONTRACT, entityId, "", Include.NON_DELETED); if (contractEntity instanceof DataContract dc) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/downstream/impl/TestCaseLineageResolver.java b/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/downstream/impl/TestCaseLineageResolver.java index 8b9ef959e322..07ca00b62128 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/downstream/impl/TestCaseLineageResolver.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/downstream/impl/TestCaseLineageResolver.java @@ -58,7 +58,7 @@ public Set resolveTraversalEntities(UUID entityId, String entit TestCase testCase = null; try { - EntityInterface entity = + EntityInterface entity = Entity.getEntity(Entity.TEST_CASE, entityId, "owners", Include.NON_DELETED); if (entity instanceof TestCase tc) { @@ -81,7 +81,7 @@ private Set extractParentFromTestCase(TestCase testCase, UUID e try { MessageParser.EntityLink parentLink = MessageParser.EntityLink.parse(testCase.getEntityLink()); - EntityInterface parentEntity = Entity.getEntity(parentLink, "owners", Include.NON_DELETED); + EntityInterface parentEntity = Entity.getEntity(parentLink, "owners", Include.NON_DELETED); if (parentEntity != null) { parents.add( diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/downstream/impl/TestSuiteLineageResolver.java b/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/downstream/impl/TestSuiteLineageResolver.java index 7ff81df7159a..d2b0146d196d 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/downstream/impl/TestSuiteLineageResolver.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/downstream/impl/TestSuiteLineageResolver.java @@ -148,7 +148,7 @@ private Set extractParentFromTestCaseResult(ResultSummary resul } // Fetch the parent entity - EntityInterface parentEntity = Entity.getEntity(parsedLink, "", Include.NON_DELETED); + EntityInterface parentEntity = Entity.getEntity(parsedLink, "", Include.NON_DELETED); if (parentEntity != null) { EntityReference parentEntityRef = diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/strategy/impl/FollowerRecipientResolver.java b/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/strategy/impl/FollowerRecipientResolver.java index b3338a8d8c8c..89d217641ca3 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/strategy/impl/FollowerRecipientResolver.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/strategy/impl/FollowerRecipientResolver.java @@ -80,11 +80,11 @@ private Recipients ofConversation( stored(subject.getType(), subject.getId()), entity -> of(entity, destination)); } - private Recipients of(EntityInterface entity, SubscriptionDestination destination) { + private Recipients of(EntityInterface entity, SubscriptionDestination destination) { return Principals.of(entity.getFollowers(), users, teams, destination); } - private static Lookup stored(String entityType, UUID entityId) { + private static Lookup> stored(String entityType, UUID entityId) { return Lookup.of( entityType + " " + entityId, () -> Entity.getEntity(entityType, entityId, "followers", Include.NON_DELETED)); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/strategy/impl/OwnerRecipientResolver.java b/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/strategy/impl/OwnerRecipientResolver.java index f7cf39f55225..38672ec78e8a 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/strategy/impl/OwnerRecipientResolver.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/notifications/recipients/strategy/impl/OwnerRecipientResolver.java @@ -91,11 +91,11 @@ private Recipients ofSubject(Conversation conversation, SubscriptionDestination stored(subject.getType(), subject.getId()), entity -> of(entity, destination)); } - private Recipients of(EntityInterface entity, SubscriptionDestination destination) { + private Recipients of(EntityInterface entity, SubscriptionDestination destination) { return Principals.of(entity.getOwners(), users, teams, destination); } - private static Lookup stored(String entityType, UUID entityId) { + private static Lookup> stored(String entityType, UUID entityId) { return Lookup.of( entityType + " " + entityId, () -> Entity.getEntity(entityType, entityId, "owners", Include.NON_DELETED)); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyChangeEventPublisher.java b/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyChangeEventPublisher.java index 63bd8b9d4dbb..892c98c7ba0f 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyChangeEventPublisher.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyChangeEventPublisher.java @@ -40,7 +40,7 @@ public OntologyChangeEventPublisher() { } public void publish( - final EventType eventType, final EntityInterface entity, final String userName) { + final EventType eventType, final EntityInterface entity, final String userName) { final String entityType = entityType(eventType); final ChangeEvent event = event(eventType, entityType, entity, userName); try { @@ -58,7 +58,7 @@ public void publish( private ChangeEvent event( final EventType eventType, final String entityType, - final EntityInterface entity, + final EntityInterface entity, final String userName) { return new ChangeEvent() .withId(UUID.randomUUID()) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyChangeOperationExecutor.java b/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyChangeOperationExecutor.java index 52b87481d523..ae0f5641b28e 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyChangeOperationExecutor.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyChangeOperationExecutor.java @@ -283,7 +283,7 @@ private OperationOutcome deleteAxiom(final String user, final OntologyChangeOper return outcome(deleted); } - private static OperationOutcome outcome(final EntityInterface entity) { + private static OperationOutcome outcome(final EntityInterface entity) { return new OperationOutcome(entity.getEntityReference(), entity.getVersion()); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyChangePreflight.java b/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyChangePreflight.java index 6ae1aaa0caaf..fb64b861abfd 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyChangePreflight.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyChangePreflight.java @@ -26,11 +26,11 @@ import java.util.stream.Collectors; import org.openmetadata.schema.EntityInterface; import org.openmetadata.schema.entity.context.ContextMemory; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.data.GlossaryTerm; import org.openmetadata.schema.entity.data.OntologyAxiom; import org.openmetadata.schema.entity.data.OntologyChangeSet; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.OntologyChangeOperation; import org.openmetadata.schema.type.OntologyChangeOperationType; import org.openmetadata.schema.type.OntologyRelationship; @@ -80,7 +80,7 @@ private boolean isActiveSource(final UUID memoryId) { (ContextMemory) entityLoader.load(Entity.CONTEXT_MEMORY, memoryId); active = !Boolean.TRUE.equals(memory.getDeleted()) - && memory.getEntityStatus() == EntityStatus.APPROVED; + && memory.getEntityStatus() == ContextMemoryStatus.APPROVED; } catch (EntityNotFoundException e) { active = false; } @@ -203,7 +203,7 @@ private void validateStoredTarget( private VersionGuard loadVersionGuard( final OntologyChangeOperation operation, final OperationTarget target) { - final EntityInterface entity = entityLoader.load(target.entityType(), target.id()); + final EntityInterface entity = entityLoader.load(target.entityType(), target.id()); requireVersion(operation, operation.getBaseVersion(), entity.getVersion()); return new VersionGuard(target, operation.getBaseVersion()); } @@ -255,6 +255,6 @@ public record OperationTarget(String entityType, UUID id) {} @FunctionalInterface public interface EntityLoader { - EntityInterface load(String entityType, UUID id); + EntityInterface load(String entityType, UUID id); } } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyMemoryDerivationQueue.java b/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyMemoryDerivationQueue.java index de35b8587858..3099f052b44f 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyMemoryDerivationQueue.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyMemoryDerivationQueue.java @@ -7,9 +7,9 @@ import java.util.function.LongSupplier; import lombok.extern.slf4j.Slf4j; import org.openmetadata.schema.entity.context.ContextMemory; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.MemoryVisibility; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.utils.JsonUtils; import org.openmetadata.service.jobs.JobDAO; @@ -74,7 +74,7 @@ public static boolean hasNewPublishedContent(ContextMemory previous, ContextMemo public static boolean isPublished(ContextMemory memory) { if (memory == null - || memory.getEntityStatus() != EntityStatus.APPROVED + || memory.getEntityStatus() != ContextMemoryStatus.APPROVED || memory.getShareConfig() == null || memory.getQuestion() == null || memory.getQuestion().isBlank() diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyMemoryDerivationService.java b/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyMemoryDerivationService.java index 96eafea780ac..38472cd9456e 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyMemoryDerivationService.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/ontology/OntologyMemoryDerivationService.java @@ -31,10 +31,10 @@ import lombok.extern.slf4j.Slf4j; import org.openmetadata.schema.api.data.CreateOntologyChangeSet; import org.openmetadata.schema.entity.context.ContextMemory; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.MemoryVisibility; import org.openmetadata.schema.entity.data.Glossary; import org.openmetadata.schema.entity.data.OntologyChangeSet; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.Include; import org.openmetadata.service.Entity; import org.openmetadata.service.exception.EntityNotFoundException; @@ -313,7 +313,7 @@ private enum Ineligibility { INACTIVE( "Memory is not active", Response.Status.BAD_REQUEST, - (memory, user) -> memory.getEntityStatus() != EntityStatus.APPROVED), + (memory, user) -> memory.getEntityStatus() != ContextMemoryStatus.APPROVED), RESTRICTED( "Restricted memory requires an owner-initiated job", Response.Status.BAD_REQUEST, diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/openlineage/OpenLineageEntityCreator.java b/openmetadata-service/src/main/java/org/openmetadata/service/openlineage/OpenLineageEntityCreator.java index 79cadd59fac6..27dedee09d8f 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/openlineage/OpenLineageEntityCreator.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/openlineage/OpenLineageEntityCreator.java @@ -79,7 +79,7 @@ public class OpenLineageEntityCreator { */ @FunctionalInterface public interface CreateAuthorization { - void authorize(String entityType, EntityInterface entity); + void authorize(String entityType, EntityInterface entity); } /** Without a caller there is nobody to authorize a create against, so nothing is created. */ @@ -222,7 +222,7 @@ private Table findOrCreateTable(CreationRun run, DatabaseSchema schema, TableDra * A soft-deleted entity still owns its name, so creating a new one would collide with it. Asking * for a restore is the only way the lineage can land on it. */ - private static T requireNotDeleted(String entityType, T entity) { + private static > T requireNotDeleted(String entityType, T entity) { if (entity != null && Boolean.TRUE.equals(entity.getDeleted())) { throw new IllegalArgumentException( String.format( @@ -248,7 +248,7 @@ String createdBy() { return createdBy; } - T findOrCreate( + > T findOrCreate( String entityType, String fqn, Supplier newEntity) { EntityRepository repository = repository(entityType); T existing = requireNotDeleted(entityType, repository.findByNameOrNull(fqn, Include.ALL)); @@ -260,7 +260,7 @@ T findOrCreate( * on the unique name, and the winner's row is the one both events should use; it is not this * run's to take back. */ - private T create( + private > T create( EntityRepository repository, String fqn, T entity) { createAuthorization.authorize(repository.getEntityType(), entity); T result; @@ -330,7 +330,7 @@ private static User findUser(String name) { } @SuppressWarnings("unchecked") - private static EntityRepository repository(String entityType) { + private static > EntityRepository repository(String entityType) { return (EntityRepository) Entity.getEntityRepository(entityType); } } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfEntityDiffService.java b/openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfEntityDiffService.java index 5e05018d3e6d..a6d5d22d7ea2 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfEntityDiffService.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfEntityDiffService.java @@ -104,7 +104,7 @@ private static RdfEntityDiff buildDiff( } private Model versionModel(final String entityType, final UUID entityId, final Double version) { - final EntityInterface entity = versionReader.read(entityType, entityId, version); + final EntityInterface entity = versionReader.read(entityType, entityId, version); final Model source = translator.toRdf(entity); try { return parseCanonical(canonicalizer.canonicalize(source)); @@ -182,19 +182,19 @@ private static void requireVersion(final String parameterName, final Double vers } } - private static EntityInterface readVersion( + private static EntityInterface readVersion( final String entityType, final UUID entityId, final Double version) { return Entity.getEntityRepository(entityType).getVersion(entityId, version.toString()); } @FunctionalInterface interface EntityVersionReader { - EntityInterface read(String entityType, UUID entityId, Double version); + EntityInterface read(String entityType, UUID entityId, Double version); } @FunctionalInterface interface EntityRdfTranslator { - Model toRdf(EntityInterface entity); + Model toRdf(EntityInterface entity); } private record DiffRequest( diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfLiveWrite.java b/openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfLiveWrite.java index 2e498266cca6..d64d9a29402b 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfLiveWrite.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfLiveWrite.java @@ -33,7 +33,7 @@ public sealed interface RdfLiveWrite { void apply(RdfRepository repository); record EntityUpdate(String entityType, UUID entityId) implements RdfLiveWrite { - public static EntityUpdate capture(final EntityInterface entity) { + public static EntityUpdate capture(final EntityInterface entity) { return new EntityUpdate(Entity.getEntityTypeFromObject(entity), entity.getId()); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfRepository.java index 1425ff7876fe..f418448e1873 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfRepository.java @@ -164,7 +164,7 @@ public class RdfRepository { private final RdfStorageInterface materializationStorageService; private final JsonLdTranslator translator; private final Supplier relationshipTypeResolverSupplier; - private final BiFunction projectionEntityLoader; + private final BiFunction> projectionEntityLoader; private final Cache entityGraphCache = Caffeine.newBuilder() .maximumSize(GRAPH_CACHE_MAX_SIZE) @@ -255,7 +255,7 @@ private RdfRepository(RdfConfiguration config) { final RdfStorageInterface storageService, final JsonLdTranslator translator, final Supplier relationshipTypeResolverSupplier, - final BiFunction projectionEntityLoader) { + final BiFunction> projectionEntityLoader) { this.config = config; this.datasetNames = RdfDatasetNames.from(config); this.datasetManager = null; @@ -491,7 +491,7 @@ public void ensureStorageReady() { } public void refreshEntity(final String entityType, final UUID entityId) { - final EntityInterface entity; + final EntityInterface entity; try { entity = projectionEntityLoader.apply(entityType, entityId); } catch (EntityNotFoundException exception) { @@ -503,7 +503,7 @@ public void refreshEntity(final String entityType, final UUID entityId) { createOrUpdate(entity); } - private static EntityInterface loadProjectionEntity( + private static EntityInterface loadProjectionEntity( final String entityType, final UUID entityId) { return Entity.getEntity( entityType, @@ -513,7 +513,7 @@ private static EntityInterface loadProjectionEntity( false); } - public void createOrUpdate(EntityInterface entity) { + public void createOrUpdate(EntityInterface entity) { if (!isEnabled()) { return; } @@ -562,11 +562,12 @@ public void createOrUpdate(EntityInterface entity) { * The per-entity fallback in {@code RdfBatchProcessor.processEntities} keeps * row-level failure attribution when a chunk fails. */ - public void bulkCreateOrUpdate(List entities) { + public void bulkCreateOrUpdate(List> entities) { bulkCreateOrUpdate(entities, RdfWriteMode.RECONCILE); } - public void bulkCreateOrUpdate(List entities, RdfWriteMode writeMode) { + public void bulkCreateOrUpdate( + List> entities, RdfWriteMode writeMode) { if (!isEnabled() || entities == null || entities.isEmpty()) { return; } @@ -587,10 +588,10 @@ public void bulkCreateOrUpdate(List entities, RdfWrit * thread turns translate time into overlap instead of writer-lock idle time. */ public List translateEntities( - List entities) { + List> entities) { List requests = new ArrayList<>(entities.size()); if (isEnabled()) { - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { // Per-entity isolation: mapEntityToRdf propagates mapping failures, and the sink // translates a whole batch in one task, so an unguarded throw here would record // every entity in the batch as failed instead of the one that is actually bad. @@ -1554,7 +1555,7 @@ public String getEntityAsJsonLd(String entityType, UUID entityId) throws IOExcep try { // Get entity to convert to JSON-LD directly - EntityInterface entity = Entity.getEntity(entityType, entityId, "*", null); + EntityInterface entity = Entity.getEntity(entityType, entityId, "*", null); // Convert directly to JSON-LD without going through RDF model return translator.toJsonLdString(entity, true); @@ -1574,7 +1575,7 @@ public String getEntityAsRdf(String entityType, UUID entityId, String format) { try { // Get the entity and convert to RDF - EntityInterface entity = Entity.getEntity(entityType, entityId, "*", null); + EntityInterface entity = Entity.getEntity(entityType, entityId, "*", null); Model rdfModel = translator.toRdf(entity); // Convert model to requested format @@ -3046,11 +3047,11 @@ private String extractEntityIdFromUri(String entityUri) { */ private void enhanceNodesWithEntityDetails( Map nodeMap) { - Map entitiesById = fetchEntitiesForNodes(nodeMap.values()); + Map> entitiesById = fetchEntitiesForNodes(nodeMap.values()); for (com.fasterxml.jackson.databind.node.ObjectNode node : nodeMap.values()) { String entityId = node.get("entityId").asText(); String entityType = node.get("type").asText(); - EntityInterface entity = entitiesById.get(entityId); + EntityInterface entity = entitiesById.get(entityId); if (entity != null) { populateNodeFromEntity(node, entity); } else { @@ -3059,7 +3060,7 @@ private void enhanceNodesWithEntityDetails( } } - private Map fetchEntitiesForNodes( + private Map> fetchEntitiesForNodes( Collection nodes) { Map> refsByType = new HashMap<>(); for (com.fasterxml.jackson.databind.node.ObjectNode node : nodes) { @@ -3070,7 +3071,7 @@ private Map fetchEntitiesForNodes( } } - Map entitiesById = new HashMap<>(); + Map> entitiesById = new HashMap<>(); refsByType.forEach((entityType, refs) -> fetchEntityBatch(entityType, refs, entitiesById)); return entitiesById; } @@ -3086,12 +3087,12 @@ private EntityReference toEntityReference(String entityType, String entityId) { } private void fetchEntityBatch( - String entityType, List refs, Map target) { + String entityType, List refs, Map> target) { String fields = ""; try { fields = graphNodeFields(entityType); - List entities = Entity.getEntities(refs, fields, Include.ALL); - for (EntityInterface entity : entities) { + List> entities = Entity.getEntities(refs, fields, Include.ALL); + for (EntityInterface entity : entities) { target.put(entity.getId().toString(), entity); } } catch (RuntimeException e) { @@ -3112,11 +3113,11 @@ private void fetchEntityBatch( private void fetchEntitiesIndividually( String entityType, List refs, - Map target, + Map> target, String fields) { for (EntityReference ref : refs) { try { - EntityInterface entity = Entity.getEntity(entityType, ref.getId(), fields, Include.ALL); + EntityInterface entity = Entity.getEntity(entityType, ref.getId(), fields, Include.ALL); target.put(entity.getId().toString(), entity); } catch (RuntimeException e) { LOG.warn( @@ -3133,7 +3134,7 @@ private String graphNodeFields(String entityType) { } private void populateNodeFromEntity( - com.fasterxml.jackson.databind.node.ObjectNode node, EntityInterface entity) { + com.fasterxml.jackson.databind.node.ObjectNode node, EntityInterface entity) { String displayLabel = entity.getDisplayName() != null ? entity.getDisplayName() : entity.getName(); node.put("label", displayLabel); @@ -3146,7 +3147,7 @@ private void populateNodeFromEntity( } private void applyNodeTags( - com.fasterxml.jackson.databind.node.ObjectNode node, EntityInterface entity) { + com.fasterxml.jackson.databind.node.ObjectNode node, EntityInterface entity) { if (!nullOrEmpty(entity.getTags())) { com.fasterxml.jackson.databind.node.ArrayNode tagsArray = JsonUtils.getObjectMapper().createArrayNode(); @@ -3963,7 +3964,7 @@ public RdfStatistics getStatistics() { config.getStorageType().toString()); } - public void bulkSyncEntities(String entityType, List entities) { + public void bulkSyncEntities(String entityType, List> entities) { if (!isEnabled()) { return; } @@ -3972,7 +3973,7 @@ public void bulkSyncEntities(String entityType, List LOG.info( "Starting bulk sync for entity type: {} with {} entities", entityType, entities.size()); - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { try { createOrUpdate(entity); } catch (Exception e) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfUpdater.java b/openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfUpdater.java index 82e29e914f1e..57cbf45fceb1 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfUpdater.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfUpdater.java @@ -78,7 +78,7 @@ public static synchronized void stop() { } } - public static void updateEntity(final EntityInterface entity) { + public static void updateEntity(final EntityInterface entity) { if (isEnabled() && !RdfExcludedEntities.isExcluded(Entity.getEntityTypeFromObject(entity))) { submit(RdfLiveWrite.EntityUpdate.capture(entity)); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/rdf/semantic/SemanticSearchEngine.java b/openmetadata-service/src/main/java/org/openmetadata/service/rdf/semantic/SemanticSearchEngine.java index 7de24797fb7f..e46b4ef16f89 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/rdf/semantic/SemanticSearchEngine.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/rdf/semantic/SemanticSearchEngine.java @@ -94,7 +94,7 @@ private List executeOpenSearchSemanticQuery( public List findSimilarEntities(String entityId, String entityType, int limit) { try { - EntityInterface entity = Entity.getEntity(entityType, UUID.fromString(entityId), "", null); + EntityInterface entity = Entity.getEntity(entityType, UUID.fromString(entityId), "", null); float[] entityEmbedding = getOrGenerateEmbedding(entity); List similar = findSimilarByEmbedding(entityEmbedding, entityType, limit * 2); similar = @@ -146,7 +146,8 @@ private List findSimilarByEmbedding( for (String entityId : entityIds) { try { - EntityInterface entity = Entity.getEntity(entityType, UUID.fromString(entityId), "", null); + EntityInterface entity = + Entity.getEntity(entityType, UUID.fromString(entityId), "", null); float[] entityEmbedding = getOrGenerateEmbedding(entity); double similarity = cosineSimilarity(embedding, entityEmbedding); @@ -302,7 +303,7 @@ private List reRankResults(List results, int limit) .collect(Collectors.toList()); } - private float[] getOrGenerateEmbedding(EntityInterface entity) { + private float[] getOrGenerateEmbedding(EntityInterface entity) { String cacheKey = entity.getId().toString(); return embeddingCache.computeIfAbsent( @@ -390,7 +391,7 @@ private EntityReference getEntityFromUri(String uri) { String type = parts[parts.length - 2]; String id = parts[parts.length - 1]; - EntityInterface entity = Entity.getEntity(type, UUID.fromString(id), "", null); + EntityInterface entity = Entity.getEntity(type, UUID.fromString(id), "", null); return entity.getEntityReference(); } catch (Exception e) { return null; @@ -398,7 +399,7 @@ private EntityReference getEntityFromUri(String uri) { } private List enhanceWithRelationships( - EntityInterface source, List similar, int limit) { + EntityInterface source, List similar, int limit) { // Query for common relationships patterns for (SearchResult result : similar) { try { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/rdf/translator/JsonLdTranslator.java b/openmetadata-service/src/main/java/org/openmetadata/service/rdf/translator/JsonLdTranslator.java index 2bfaad684be9..578afc045654 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/rdf/translator/JsonLdTranslator.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/rdf/translator/JsonLdTranslator.java @@ -53,7 +53,7 @@ public class JsonLdTranslator { // zero cross-entity hits, i.e. one DB round trip per tag FQN per entity // during reindexing. private final RdfPropertyMapper propertyMapper; - private final Function entityTypeResolver; + private final Function, String> entityTypeResolver; public JsonLdTranslator(ObjectMapper objectMapper, String baseUri) { this(objectMapper, baseUri, entity -> entity.getEntityReference().getType()); @@ -62,7 +62,7 @@ public JsonLdTranslator(ObjectMapper objectMapper, String baseUri) { JsonLdTranslator( ObjectMapper objectMapper, String baseUri, - Function entityTypeResolver) { + Function, String> entityTypeResolver) { this.objectMapper = Objects.requireNonNull(objectMapper, "objectMapper"); this.contextCache = new HashMap<>(); this.baseUri = Objects.requireNonNull(baseUri, "baseUri"); @@ -109,7 +109,7 @@ private JsonNode readContext(String filename) { } } - public ObjectNode toJsonLd(EntityInterface entity) { + public ObjectNode toJsonLd(EntityInterface entity) { String entityType = resolveEntityType(entity); ObjectNode entityJson = createEntityDocument(entity, entityType); Object context = selectContext(entityType); @@ -122,7 +122,7 @@ public ObjectNode toJsonLd(EntityInterface entity) { } } - private ObjectNode createEntityDocument(EntityInterface entity, String entityType) { + private ObjectNode createEntityDocument(EntityInterface entity, String entityType) { ObjectNode entityJson = objectMapper.valueToTree(entity); addJsonLdPropertiesToReferences(entityJson); assignColumnIds(entityJson); @@ -194,7 +194,7 @@ private void assignColumnId(JsonNode columnNode) { } } - public Model toRdf(EntityInterface entity) { + public Model toRdf(EntityInterface entity) { Model model = ModelFactory.createDefaultModel(); model.setNsPrefix("om", "https://open-metadata.org/ontology/"); @@ -253,7 +253,7 @@ public Model toRdf(EntityInterface entity) { return model; } - public String toJsonLdString(EntityInterface entity, boolean prettyPrint) throws IOException { + public String toJsonLdString(EntityInterface entity, boolean prettyPrint) throws IOException { ObjectNode jsonLd = toJsonLd(entity); return prettyPrint ? objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonLd) @@ -264,8 +264,8 @@ private Object selectContext(String entityType) { return contextCache.get(RdfContextRegistry.contextNameFor(entityType)); } - private String resolveEntityType(EntityInterface entity) { - EntityInterface requiredEntity = Objects.requireNonNull(entity, "entity"); + private String resolveEntityType(EntityInterface entity) { + EntityInterface requiredEntity = Objects.requireNonNull(entity, "entity"); String entityType = entityTypeResolver.apply(requiredEntity); if (nullOrEmpty(entityType)) { throw new IllegalArgumentException( diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/rdf/translator/RdfPropertyMapper.java b/openmetadata-service/src/main/java/org/openmetadata/service/rdf/translator/RdfPropertyMapper.java index c41009579c65..cb0558a542b9 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/rdf/translator/RdfPropertyMapper.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/rdf/translator/RdfPropertyMapper.java @@ -193,8 +193,8 @@ public static boolean isIndexableEntityField(String fieldName) { /** * Convert all entity properties to RDF triples based on context mappings */ - public void mapEntityToRdf(EntityInterface entity, Resource entityResource, Model model) { - EntityInterface requiredEntity = Objects.requireNonNull(entity, "entity"); + public void mapEntityToRdf(EntityInterface entity, Resource entityResource, Model model) { + EntityInterface requiredEntity = Objects.requireNonNull(entity, "entity"); Resource requiredResource = Objects.requireNonNull(entityResource, "entityResource"); Model requiredModel = Objects.requireNonNull(model, "model"); JsonNode entityJson = objectMapper.valueToTree(requiredEntity); @@ -218,7 +218,7 @@ public void mapEntityToRdf(EntityInterface entity, Resource entityResource, Mode } private void emitStructuredProperties( - EntityInterface entity, JsonNode entityJson, Resource entityResource, Model model) { + EntityInterface entity, JsonNode entityJson, Resource entityResource, Model model) { RdfJsonNode.array(entityJson, "tableConstraints") .ifPresent( constraints -> @@ -639,8 +639,9 @@ private Optional findTagEntityId(String fqn, JsonNode tagLabel, String ent private Optional findEntityId(String entityType, String fqn) { try { - EntityInterface entity = Entity.findEntityByNameOrNull(entityType, fqn, Include.NON_DELETED); - return Optional.ofNullable(entity).map(EntityInterface::getId); + EntityInterface entity = + Entity.findEntityByNameOrNull(entityType, fqn, Include.NON_DELETED); + return Optional.ofNullable(entity).map(EntityInterface::getId); } catch (RuntimeException exception) { LOG.debug("Could not resolve {} id for FQN {}", entityType, fqn, exception); return Optional.empty(); @@ -1513,7 +1514,7 @@ private void addNumericProperty( } } - private void addStandardProperties(EntityInterface entity, Resource resource, Model model) { + private void addStandardProperties(EntityInterface entity, Resource resource, Model model) { // Add timestamps. updatedAt is epoch millis on the entity; convert to an // ISO-8601 instant before tagging it as xsd:dateTime so the lexical form is // valid (a long literal would be a malformed xsd:dateTime). diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/ChangeSummaryResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/ChangeSummaryResource.java index 3b0f7b0e2d57..6c6a46492ab1 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/ChangeSummaryResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/ChangeSummaryResource.java @@ -113,8 +113,8 @@ public Response getChangeSummaryById( authorizer.authorize(securityContext, operationContext, resourceContext); EntityRepository repository = Entity.getEntityRepository(entityType); - EntityInterface entity = - (EntityInterface) repository.get(uriInfo, id, repository.getFields("changeDescription")); + EntityInterface entity = + (EntityInterface) repository.get(uriInfo, id, repository.getFields("changeDescription")); return buildResponse(entity, fieldPrefix, limit, offset); } @@ -171,15 +171,15 @@ public Response getChangeSummaryByFqn( authorizer.authorize(securityContext, operationContext, resourceContext); EntityRepository repository = Entity.getEntityRepository(entityType); - EntityInterface entity = - (EntityInterface) + EntityInterface entity = + (EntityInterface) repository.getByName(uriInfo, fqn, repository.getFields("changeDescription")); return buildResponse(entity, fieldPrefix, limit, offset); } private Response buildResponse( - EntityInterface entity, String fieldPrefix, int limit, int offset) { + EntityInterface entity, String fieldPrefix, int limit, int offset) { ChangeDescription changeDescription = entity.getChangeDescription(); ChangeSummaryMap changeSummaryMap = changeDescription != null ? changeDescription.getChangeSummary() : null; diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/EntityResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/EntityResource.java index 18497e7eb6d5..af1b684dae1a 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/EntityResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/EntityResource.java @@ -125,7 +125,7 @@ @Slf4j @LatencyPhase -public abstract class EntityResource> { +public abstract class EntityResource, K extends EntityRepository> { private static final String INCLUDE_PERMISSIONS_PARAM = "includePermissions"; protected final Class entityClass; protected final String entityType; @@ -440,7 +440,8 @@ public T getInternal( @SuppressWarnings("unchecked") private T reuseAuthorizedEntity( UriInfo uriInfo, ResourceContextInterface resourceContext, Fields fields) { - EntityInterface resolved = resourceContext == null ? null : resourceContext.getResolvedEntity(); + EntityInterface resolved = + resourceContext == null ? null : resourceContext.getResolvedEntity(); boolean coversProjection = resolved != null && resourceContext.getLoadedFields().containsAll(fields.getFieldList()); T result = null; @@ -1284,8 +1285,8 @@ protected CsvImportResult importCsvInternal( if (result.getStatus() != ApiStatus.ABORTED && result.getNumberOfRowsProcessed() > 1 && !dryRun) { - EntityRepository versioningRepo = - (EntityRepository) + EntityRepository> versioningRepo = + (EntityRepository>) Entity.getEntityRepository(effectiveVersioningEntityType); if (versioningRepo.supportsBulkImportVersioning()) { @@ -1296,7 +1297,7 @@ protected CsvImportResult importCsvInternal( } protected void processChangeEventForBulkImport( - EntityRepository versioningRepo, + EntityRepository> versioningRepo, UriInfo uriInfo, SecurityContext securityContext, String name, @@ -1377,7 +1378,7 @@ protected ResultList getChildFieldPage( new OperationContext(entityType, VIEW_BASIC), getResourceContextByName(fqn, include)); ChildFieldResolver.ChildContainerSpec spec = ChildFieldResolver.specFor(entityType); - EntityInterface parent = + EntityInterface parent = repository.getByName( null, fqn, repository.getFields(spec.requiredFields()), include, false); return new ChildFieldPageReader(repository, spec) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/AIGovernanceWorkflowService.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/AIGovernanceWorkflowService.java index 1d82e12f2d2f..9324bbe035d2 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/AIGovernanceWorkflowService.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/AIGovernanceWorkflowService.java @@ -44,6 +44,7 @@ import org.openmetadata.service.security.policyevaluator.OperationContext; import org.openmetadata.service.security.policyevaluator.ResourceContext; import org.openmetadata.service.security.policyevaluator.ResourceContextInterface; +import org.openmetadata.service.util.EntityFieldUtils; @Slf4j final class AIGovernanceWorkflowService { @@ -66,18 +67,18 @@ IntakeChecksResponse getIntakeChecksByFqn( return IntakeChecks.compute(loadEntityByFqn(entityType, fqn)); } - EntityInterface submitForReview( + EntityInterface submitForReview( SecurityContext securityContext, String entityType, String id, String user) { return transitionRegistration( securityContext, entityType, id, STATUS_PENDING_APPROVAL, user, null); } - EntityInterface approve( + EntityInterface approve( SecurityContext securityContext, String entityType, String id, String user, String comment) { return transitionRegistration(securityContext, entityType, id, STATUS_APPROVED, user, comment); } - EntityInterface reject( + EntityInterface reject( SecurityContext securityContext, String entityType, String id, String user, String comment) { return transitionRegistration(securityContext, entityType, id, STATUS_REJECTED, user, comment); } @@ -151,15 +152,17 @@ AIGovernanceBulkTriageResponse bulkTriage( return new AIGovernanceBulkTriageResponse().withResults(results); } - private EntityInterface loadEntityByFqn(String entityType, String fqn) { + private EntityInterface loadEntityByFqn(String entityType, String fqn) { assertSupported(entityType); - EntityRepository repository = Entity.getEntityRepository(entityType); + EntityRepository> repository = + Entity.getEntityRepository(entityType); return repository.getByName(null, fqn, repository.getFields("owners,tags,domains,extension")); } - private EntityInterface loadEntity(String entityType, String id) { + private EntityInterface loadEntity(String entityType, String id) { assertSupported(entityType); - EntityRepository repository = Entity.getEntityRepository(entityType); + EntityRepository> repository = + Entity.getEntityRepository(entityType); return repository.get( null, UUID.fromString(id), repository.getFields("owners,tags,domains,extension")); } @@ -174,21 +177,22 @@ private void assertSupported(String entityType) { } } - private EntityInterface transitionRegistration( + private EntityInterface transitionRegistration( SecurityContext securityContext, String entityType, String id, String newStatus, String user, String comment) { - EntityInterface entity = loadEntity(entityType, id); + EntityInterface entity = loadEntity(entityType, id); String originalJson = JsonUtils.pojoToJson(entity); applyStatusTransition(entity, newStatus, user, comment); String updatedJson = JsonUtils.pojoToJson(entity); JsonPatch patch = JsonUtils.getJsonPatch(originalJson, updatedJson); authorizePatch(securityContext, entityType, entity.getId(), patch); - EntityRepository repository = Entity.getEntityRepository(entityType); + EntityRepository> repository = + Entity.getEntityRepository(entityType); return repository.patch(null, entity.getId(), user, patch).entity(); } @@ -232,8 +236,8 @@ private void authorizePatch( } private void applyStatusTransition( - EntityInterface entity, String newStatus, String user, String comment) { - entity.setEntityStatus(mapToEntityStatus(newStatus)); + EntityInterface entity, String newStatus, String user, String comment) { + EntityFieldUtils.setEntityStatus(entity, mapToEntityStatus(newStatus).value()); if (entity instanceof LLMModel llm) { llm.setGovernanceStatus(mapToGovernanceStatus(newStatus)); } else if (entity instanceof AIApplication app) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/AuditPackGenerator.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/AuditPackGenerator.java index 5f1a5e268aeb..99414a12820a 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/AuditPackGenerator.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/AuditPackGenerator.java @@ -403,9 +403,9 @@ private static void collectAssets( String entityType, AuditReportScope scope, AuditReport report, List out) { try { ListFilter filter = new ListFilter(Include.NON_DELETED); - List entities = + List> entities = listAssets(entityType, filter, fieldsForScope(entityType, scope)); - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { if (scope == AuditReportScope.Asset && report.getScopeTarget() != null) { if (!report.getScopeTarget().getId().equals(entity.getId())) { continue; @@ -431,13 +431,13 @@ private static void collectAssets( } } - private static List listAssets( + private static List> listAssets( String entityType, ListFilter filter, EntityUtil.Fields fields) { - List result = new ArrayList<>(); - EntityRepository repo = Entity.getEntityRepository(entityType); + List> result = new ArrayList<>(); + EntityRepository> repo = Entity.getEntityRepository(entityType); String after = null; do { - ResultList page = + ResultList> page = repo.listAfter(null, fields, filter, PAGE_SIZE, after); result.addAll(page.getData()); after = page.getPaging() == null ? null : page.getPaging().getAfter(); @@ -460,7 +460,7 @@ private static EntityUtil.Fields fieldsForScope(String entityType, AuditReportSc return result; } - private static Object governanceMetadata(EntityInterface entity) { + private static Object governanceMetadata(EntityInterface entity) { Object result = null; if (entity instanceof AIApplication app) { result = app.getGovernanceMetadata(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/DashboardRollup.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/DashboardRollup.java index 6a263e495c5a..217a02808180 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/DashboardRollup.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/DashboardRollup.java @@ -85,15 +85,15 @@ static AIGovernanceDashboardResponse compute() { private static void collectAssets(String entityType, String fields, List out) { try { - EntityRepository repository = + EntityRepository> repository = Entity.getEntityRepository(entityType); Fields parsedFields = repository.getFields(fields); ListFilter filter = new ListFilter(); String after = null; do { - ResultList page = + ResultList> page = repository.listAfter(null, parsedFields, filter, PAGE_SIZE, after); - for (EntityInterface entity : page.getData()) { + for (EntityInterface entity : page.getData()) { out.add(RolledAsset.from(entityType, entity)); } after = page.getPaging() == null ? null : page.getPaging().getAfter(); @@ -194,14 +194,14 @@ private static List buildReadinessEntries( private static Map enabledFrameworkDeadlines() { Map result = new LinkedHashMap<>(); try { - EntityRepository repository = + EntityRepository> repository = Entity.getEntityRepository(Entity.AI_GOVERNANCE_FRAMEWORK); ListFilter filter = new ListFilter(); String after = null; do { - ResultList page = + ResultList> page = repository.listAfter(null, Fields.EMPTY_FIELDS, filter, PAGE_SIZE, after); - for (EntityInterface entity : page.getData()) { + for (EntityInterface entity : page.getData()) { collectEnabledFramework(entity, result); } after = page.getPaging() == null ? null : page.getPaging().getAfter(); @@ -212,7 +212,7 @@ private static Map enabledFrameworkDeadlines() { return result; } - private static void collectEnabledFramework(EntityInterface entity, Map out) { + private static void collectEnabledFramework(EntityInterface entity, Map out) { if (entity instanceof AIGovernanceFramework framework && Boolean.TRUE.equals(framework.getEnabled()) && framework.getName() != null) { @@ -440,7 +440,7 @@ AIGovernanceTopEntity toTopEntity() { .withEntityType(entityType); } - static RolledAsset from(String entityType, EntityInterface entity) { + static RolledAsset from(String entityType, EntityInterface entity) { GovernanceSnapshot governance = governance(entity); List frameworks = new ArrayList<>(); String euRisk = extractCompliance(governance.aiCompliance(), frameworks); @@ -537,7 +537,7 @@ private static String mapLlmStatus(LLMModel.GovernanceStatus status) { return result; } - private static GovernanceSnapshot governance(EntityInterface entity) { + private static GovernanceSnapshot governance(EntityInterface entity) { GovernanceSnapshot result = GovernanceSnapshot.EMPTY; if (entity instanceof AIApplication app) { result = governance(app.getGovernanceMetadata()); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/FrameworkCoverageComputer.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/FrameworkCoverageComputer.java index 8bb5f4d6ccca..371555e5aac8 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/FrameworkCoverageComputer.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/FrameworkCoverageComputer.java @@ -76,7 +76,7 @@ public static FrameworkCoverageResponse compute( static FrameworkCoverageResponse compute( AIGovernanceFramework framework, List controls, - List assets) { + List> assets) { FrameworkCoverageResponse response = new FrameworkCoverageResponse(); response.setFrameworkId(framework.getId()); response.setFrameworkName(framework.getName()); @@ -170,7 +170,7 @@ private static int deriveAffectedAssetCount(int nonCompliant, int partial) { return nonCompliant + partial; } - private static AssetCompliance assetCompliance(EntityInterface asset, String frameworkName) { + private static AssetCompliance assetCompliance(EntityInterface asset, String frameworkName) { GovernanceSnapshot governance = governance(asset); return new AssetCompliance( findComplianceRecord(governance.aiCompliance(), frameworkName), @@ -178,7 +178,7 @@ private static AssetCompliance assetCompliance(EntityInterface asset, String fra } private static ComplianceRecordSnapshot findComplianceRecord( - EntityInterface asset, String frameworkName) { + EntityInterface asset, String frameworkName) { return findComplianceRecord(governance(asset).aiCompliance(), frameworkName); } @@ -228,13 +228,13 @@ private static boolean frameworkMatches( return recordFramework != null && recordFramework.value().equalsIgnoreCase(frameworkName); } - private static List collectInScopeAssets(AIGovernanceFramework framework) { + private static List> collectInScopeAssets(AIGovernanceFramework framework) { FrameworkAutoApplyRules rules = framework.getAutoApply(); String frameworkName = framework.getName(); - List result = new ArrayList<>(); + List> result = new ArrayList<>(); List assetTypes = autoApplyAssetTypes(rules); for (String entityType : assetTypes) { - for (EntityInterface entity : listEntities(entityType)) { + for (EntityInterface entity : listEntities(entityType)) { // In-scope when the asset matches the auto-apply rules OR already carries // a compliance record for this framework (an explicit assessment always // counts, even if the asset hasn't declared the matching region/stage). @@ -266,13 +266,13 @@ private static List autoApplyAssetTypes(FrameworkAutoApplyRules rules) { return result; } - private static List listEntities(String entityType) { - List result = new ArrayList<>(); + private static List> listEntities(String entityType) { + List> result = new ArrayList<>(); try { ListFilter filter = new ListFilter(Include.NON_DELETED); String after = null; do { - ResultList page = listEntityPage(entityType, filter, after); + ResultList> page = listEntityPage(entityType, filter, after); result.addAll(page.getData()); after = page.getPaging() == null ? null : page.getPaging().getAfter(); } while (after != null); @@ -283,7 +283,7 @@ private static List listEntities(String entityType) { return result; } - private static ResultList listEntityPage( + private static ResultList> listEntityPage( String entityType, ListFilter filter, String after) { if (Entity.AI_APPLICATION.equals(entityType)) { AIApplicationRepository repo = @@ -301,7 +301,7 @@ private static ResultList listEntityPage( return new ResultList<>(List.of(), null, null, 0); } - private static boolean matchesScope(EntityInterface entity, FrameworkAutoApplyRules rules) { + private static boolean matchesScope(EntityInterface entity, FrameworkAutoApplyRules rules) { boolean result; if (rules == null) { result = true; @@ -389,7 +389,7 @@ private static List extractRiskClasses(GovernanceSnapshot governance) { return result; } - private static GovernanceSnapshot governance(EntityInterface asset) { + private static GovernanceSnapshot governance(EntityInterface asset) { GovernanceSnapshot result = GovernanceSnapshot.EMPTY; if (asset instanceof AIApplication app) { result = governance(app.getGovernanceMetadata(), enumValue(app.getDevelopmentStage())); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/GovernanceActivity.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/GovernanceActivity.java index 768ff650bdac..10f07f75ed4a 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/GovernanceActivity.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/GovernanceActivity.java @@ -54,10 +54,10 @@ final class GovernanceActivity { private GovernanceActivity() {} static AIGovernanceActivityResponse compute(String entityType, String entityId, int limit) { - List assets = new ArrayList<>(); + List> assets = new ArrayList<>(); boolean singleEntity = entityType != null && entityId != null; if (singleEntity) { - EntityInterface single = loadSingle(entityType, entityId); + EntityInterface single = loadSingle(entityType, entityId); if (single != null) { assets.add(single); } @@ -70,7 +70,7 @@ static AIGovernanceActivityResponse compute(String entityType, String entityId, } List events = new ArrayList<>(); - for (EntityInterface entity : assets) { + for (EntityInterface entity : assets) { events.addAll(eventsFor(entity, singleEntity)); } events.sort(Comparator.comparing(AIGovernanceActivityEvent::getAt).reversed()); @@ -79,11 +79,12 @@ static AIGovernanceActivityResponse compute(String entityType, String entityId, return new AIGovernanceActivityResponse().withEvents(events.subList(0, effective)); } - private static EntityInterface loadSingle(String entityType, String entityId) { - EntityInterface result = null; + private static EntityInterface loadSingle(String entityType, String entityId) { + EntityInterface result = null; if (SUPPORTED_TYPES.contains(entityType)) { try { - EntityRepository repo = Entity.getEntityRepository(entityType); + EntityRepository> repo = + Entity.getEntityRepository(entityType); result = repo.get(null, UUID.fromString(entityId), repo.getFields(fieldList(entityType))); } catch (Exception error) { LOG.warn("Activity feed: failed to load {}:{}", entityType, entityId, error); @@ -92,14 +93,14 @@ private static EntityInterface loadSingle(String entityType, String entityId) { return result; } - private static void collect(String entityType, List out) { + private static void collect(String entityType, List> out) { try { - EntityRepository repo = Entity.getEntityRepository(entityType); + EntityRepository> repo = Entity.getEntityRepository(entityType); Fields fields = repo.getFields(fieldList(entityType)); ListFilter filter = new ListFilter(); String after = null; do { - ResultList page = + ResultList> page = repo.listAfter(null, fields, filter, PAGE_SIZE, after); out.addAll(page.getData()); after = page.getPaging() == null ? null : page.getPaging().getAfter(); @@ -115,7 +116,7 @@ private static String fieldList(String entityType) { : "owners,governanceMetadata"; } - static List eventsFor(EntityInterface entity) { + static List eventsFor(EntityInterface entity) { return eventsFor(entity, true); } @@ -126,7 +127,7 @@ static List eventsFor(EntityInterface entity) { * true so both submission and approval events are shown. */ static List eventsFor( - EntityInterface entity, boolean reconstructHistory) { + EntityInterface entity, boolean reconstructHistory) { List events = new ArrayList<>(); String entityType = entity.getEntityReference() == null ? null : entity.getEntityReference().getType(); @@ -207,7 +208,7 @@ static List eventsFor( } private static AIGovernanceActivityEvent event( - EntityInterface entity, String entityType, String type, String text, long at, Object who) { + EntityInterface entity, String entityType, String type, String text, long at, Object who) { AIGovernanceActivityEvent event = new AIGovernanceActivityEvent() .withEntityType(entityType) @@ -231,7 +232,7 @@ private static AIGovernanceActivityEvent event( * {@code scheduledAt} carries the future date the event refers to. */ private static AIGovernanceActivityEvent scheduledEvent( - EntityInterface entity, + EntityInterface entity, String entityType, String type, String text, @@ -243,7 +244,7 @@ private static AIGovernanceActivityEvent scheduledEvent( return event; } - private static long reviewFallback(ActivityGovernance governance, EntityInterface entity) { + private static long reviewFallback(ActivityGovernance governance, EntityInterface entity) { Long registeredAt = governance.registeredAt(); long result; if (registeredAt != null) { @@ -256,7 +257,8 @@ private static long reviewFallback(ActivityGovernance governance, EntityInterfac return result; } - private static ActivityGovernance governance(EntityInterface entity, boolean reconstructHistory) { + private static ActivityGovernance governance( + EntityInterface entity, boolean reconstructHistory) { ActivityGovernance result = ActivityGovernance.EMPTY; if (entity instanceof AIApplication app) { result = governance(app.getGovernanceMetadata()); @@ -321,7 +323,7 @@ private static LlmSubmission llmSubmissionFromHistory(LLMModel llm) { return result; } try { - EntityRepository repository = + EntityRepository> repository = Entity.getEntityRepository(Entity.LLM_MODEL); List versions = repository.listVersions(llm.getId()).getVersions(); if (versions == null) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/IntakeChecks.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/IntakeChecks.java index 649488772d31..13c769a8ae89 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/IntakeChecks.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/IntakeChecks.java @@ -42,7 +42,7 @@ final class IntakeChecks { private IntakeChecks() {} - static IntakeChecksResponse compute(EntityInterface entity) { + static IntakeChecksResponse compute(EntityInterface entity) { List checks = new ArrayList<>(); checks.add(intakeCheck(OWNER_ASSIGNED, hasOwner(entity), null)); checks.add(intakeCheck(RISK_CLASSIFIED, hasRisk(entity), null)); @@ -57,11 +57,11 @@ private static IntakeCheck intakeCheck(String name, boolean passing, String evid return new IntakeCheck().withName(name).withPassing(passing).withEvidenceRef(evidenceRef); } - private static boolean hasOwner(EntityInterface entity) { + private static boolean hasOwner(EntityInterface entity) { return !nullOrEmpty(entity.getOwners()); } - private static boolean hasRisk(EntityInterface entity) { + private static boolean hasRisk(EntityInterface entity) { boolean result = riskAssessmentDeclared(entity) || euRiskClassificationPresent(aiCompliance(entity)); if (!result && entity instanceof LLMModel llm) { @@ -70,7 +70,7 @@ private static boolean hasRisk(EntityInterface entity) { return result; } - private static boolean hasFairnessEvidence(EntityInterface entity) { + private static boolean hasFairnessEvidence(EntityInterface entity) { boolean result = false; if (entity instanceof AIApplication app && app.getBiasMetrics() != null @@ -84,12 +84,12 @@ private static boolean hasFairnessEvidence(EntityInterface entity) { return result; } - private static boolean hasDpia(EntityInterface entity) { + private static boolean hasDpia(EntityInterface entity) { AIEvidence evidence = evidence(entity); return evidence != null && !nullOrEmpty(evidence.getDpiaUrl()); } - private static boolean hasTransparency(EntityInterface entity) { + private static boolean hasTransparency(EntityInterface entity) { AICompliance aiCompliance = aiCompliance(entity); boolean result = false; if (aiCompliance != null && aiCompliance.getComplianceRecords() != null) { @@ -106,7 +106,7 @@ private static boolean hasTransparency(EntityInterface entity) { return result; } - private static boolean riskAssessmentDeclared(EntityInterface entity) { + private static boolean riskAssessmentDeclared(EntityInterface entity) { boolean result = false; if (entity instanceof AIApplication app && app.getGovernanceMetadata() != null) { GovernanceMetadata governance = app.getGovernanceMetadata(); @@ -135,7 +135,7 @@ private static boolean euRiskClassificationPresent(AICompliance aiCompliance) { return result; } - private static AICompliance aiCompliance(EntityInterface entity) { + private static AICompliance aiCompliance(EntityInterface entity) { AICompliance result = null; if (entity instanceof AIApplication app && app.getGovernanceMetadata() != null) { result = app.getGovernanceMetadata().getAiCompliance(); @@ -145,7 +145,7 @@ private static AICompliance aiCompliance(EntityInterface entity) { return result; } - private static AIEvidence evidence(EntityInterface entity) { + private static AIEvidence evidence(EntityInterface entity) { AIEvidence result = null; if (entity instanceof AIApplication app && app.getGovernanceMetadata() != null) { result = app.getGovernanceMetadata().getEvidence(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/PolicyEvaluator.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/PolicyEvaluator.java index 7c0a3790dcc8..c832231900a8 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/PolicyEvaluator.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/PolicyEvaluator.java @@ -61,7 +61,7 @@ enum Status { NOT_APPLICABLE } - static List evaluate(EntityInterface entity, String entityType) { + static List evaluate(EntityInterface entity, String entityType) { List rules = new ArrayList<>(); rules.add(piiAccessRequiresDpia(entity)); rules.add(subgroupFairnessQuarterly(entity)); @@ -72,7 +72,7 @@ static List evaluate(EntityInterface entity, Strin return rules; } - private static AIGovernancePolicyRuleResult piiAccessRequiresDpia(EntityInterface entity) { + private static AIGovernancePolicyRuleResult piiAccessRequiresDpia(EntityInterface entity) { GovernanceSnapshot governance = governance(entity); boolean accessesPii = governance.dataClassification() != null @@ -98,7 +98,7 @@ private static AIGovernancePolicyRuleResult piiAccessRequiresDpia(EntityInterfac dpiaUrl == null ? (accessesPii ? "No DPIA on file" : "N/A") : dpiaUrl); } - private static AIGovernancePolicyRuleResult subgroupFairnessQuarterly(EntityInterface entity) { + private static AIGovernancePolicyRuleResult subgroupFairnessQuarterly(EntityInterface entity) { GovernanceSnapshot governance = governance(entity); String euRisk = euRiskClassification(governance.aiCompliance()); boolean highRisk = "High".equals(euRisk) || "Unacceptable".equals(euRisk); @@ -129,7 +129,7 @@ private static AIGovernancePolicyRuleResult subgroupFairnessQuarterly(EntityInte value); } - private static AIGovernancePolicyRuleResult humanOversight(EntityInterface entity) { + private static AIGovernancePolicyRuleResult humanOversight(EntityInterface entity) { GovernanceSnapshot governance = governance(entity); Boolean oversight = humanOversightFromGovernance(governance.aiCompliance()); Status status; @@ -152,7 +152,7 @@ private static AIGovernancePolicyRuleResult humanOversight(EntityInterface entit value); } - private static AIGovernancePolicyRuleResult auditLogRetention(EntityInterface entity) { + private static AIGovernancePolicyRuleResult auditLogRetention(EntityInterface entity) { GovernanceSnapshot governance = governance(entity); DataClassificationSnapshot classification = governance.dataClassification(); String value = @@ -197,7 +197,7 @@ private static AIGovernancePolicyRuleResult rule( .withValue(value); } - private static GovernanceSnapshot governance(EntityInterface entity) { + private static GovernanceSnapshot governance(EntityInterface entity) { GovernanceSnapshot result = GovernanceSnapshot.EMPTY; if (entity instanceof AIApplication app && app.getGovernanceMetadata() != null) { result = governance(app.getGovernanceMetadata()); @@ -276,7 +276,7 @@ private static Boolean humanOversightFromGovernance(AICompliance aiCompliance) { return result; } - private static Long lastBiasEval(EntityInterface entity) { + private static Long lastBiasEval(EntityInterface entity) { Long result = null; if (entity instanceof AIApplication app && app.getBiasMetrics() != null) { result = app.getBiasMetrics().getLastEvaluatedAt(); @@ -318,8 +318,8 @@ private static void scanAssets( long sinceMs, int limit, List rows) { - List entities = listEntities(entityType, limit); - for (EntityInterface entity : entities) { + List> entities = listEntities(entityType, limit); + for (EntityInterface entity : entities) { if (rows.size() >= limit) { return; } @@ -354,15 +354,15 @@ private static void scanAssets( } } - private static List listEntities(String entityType, int limit) { - List result = new ArrayList<>(); + private static List> listEntities(String entityType, int limit) { + List> result = new ArrayList<>(); try { ListFilter filter = new ListFilter(Include.NON_DELETED); - EntityRepository repo = Entity.getEntityRepository(entityType); + EntityRepository> repo = Entity.getEntityRepository(entityType); String after = null; do { int pageSize = Math.min(PAGE_SIZE, Math.max(1, limit - result.size())); - ResultList page = + ResultList> page = repo.listAfter(null, EntityUtil.Fields.EMPTY_FIELDS, filter, pageSize, after); result.addAll(page.getData()); after = page.getPaging() == null ? null : page.getPaging().getAfter(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/audit/AuditLogResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/audit/AuditLogResource.java index 4e6aa48c978f..60b5e87a6969 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/audit/AuditLogResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/audit/AuditLogResource.java @@ -449,7 +449,7 @@ public List getTags() { } @Override - public EntityInterface getEntity() { + public EntityInterface getEntity() { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/automations/WorkflowResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/automations/WorkflowResource.java index 16954a1cbf71..9c063cf074f3 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/automations/WorkflowResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/automations/WorkflowResource.java @@ -682,7 +682,7 @@ private Workflow buildFromOriginalServiceConnection(Workflow workflow) { } if (originalWorkflow.getRequest() instanceof TestServiceConnectionRequest testServiceConnection) { - EntityRepository serviceRepository = + EntityRepository> serviceRepository = Entity.getServiceEntityRepository(testServiceConnection.getServiceType()); ServiceEntityInterface originalService = (ServiceEntityInterface) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/bots/BotMapper.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/bots/BotMapper.java index 170dbbcc7ec1..748d81380af6 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/bots/BotMapper.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/bots/BotMapper.java @@ -71,7 +71,7 @@ private List retrieveBotRelationshipsFor } private User retrieveUser(Bot bot) { - EntityRepository userRepository = + EntityRepository> userRepository = Entity.getEntityRepository(Entity.USER); return (User) userRepository.findByNameOrNull( diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/context/ContextMemoryAnchorAccess.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/context/ContextMemoryAnchorAccess.java index 50a0053e5a96..6dff897a193e 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/context/ContextMemoryAnchorAccess.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/context/ContextMemoryAnchorAccess.java @@ -48,7 +48,7 @@ static boolean canView(String userName, EntityReference anchor) { private static boolean isAllowed(String userName, EntityReference anchor) { boolean allowed; try { - ResourceContext resource = + ResourceContext> resource = new ResourceContext<>(anchor.getType(), anchor.getId(), anchor.getFullyQualifiedName()); DefaultAuthorizer.authorizeUser( userName, @@ -67,8 +67,8 @@ private static boolean isAllowed(String userName, EntityReference anchor) { } private static boolean isSourceVisible( - String userName, ResourceContext resource) { - EntityInterface entity = resource.getEntity(); + String userName, ResourceContext> resource) { + EntityInterface entity = resource.getEntity(); return entity != null && (!(entity instanceof ContextFile file) || ContextFileVisibility.isVisibleToUser(file, userName, false)); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/context/ContextMemoryResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/context/ContextMemoryResource.java index 32f0915fac71..3f58e37bb3b0 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/context/ContextMemoryResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/context/ContextMemoryResource.java @@ -54,9 +54,9 @@ import org.openmetadata.schema.api.context.CreateContextMemory; import org.openmetadata.schema.api.data.RestoreEntity; import org.openmetadata.schema.entity.context.ContextMemory; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.teams.User; import org.openmetadata.schema.type.EntityHistory; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.Include; import org.openmetadata.schema.type.MetadataOperation; import org.openmetadata.schema.utils.JsonUtils; @@ -260,7 +260,7 @@ private ResultList listMemoriesFromSearch( UUID sourceFileId, UUID sourceEntityId, UUID primaryEntityId, - List statuses) + List statuses) throws IOException { validateSearchBackedListParams(before, after, sourceFileId, sourceEntityId, primaryEntityId); SearchListFilter searchListFilter = @@ -291,18 +291,18 @@ private ResultList listMemoriesFromSearch( getAuthRequestsForListOps()); } - private static List parseStatuses(String statuses) { - Set parsed = new LinkedHashSet<>(); + private static List parseStatuses(String statuses) { + Set parsed = new LinkedHashSet<>(); for (String value : statuses.split(",", -1)) { parsed.add(parseMemoryStatus(value.trim())); } return List.copyOf(parsed); } - private static EntityStatus parseMemoryStatus(String value) { - EntityStatus status = null; + private static ContextMemoryStatus parseMemoryStatus(String value) { + ContextMemoryStatus status = null; try { - status = EntityStatus.fromValue(value); + status = ContextMemoryStatus.fromValue(value); } catch (IllegalArgumentException ex) { LOG.debug("Unknown memory status '{}'", value, ex); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/context/ContextMemoryVisibility.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/context/ContextMemoryVisibility.java index 8436627d0722..fe29db186ec7 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/context/ContextMemoryVisibility.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/context/ContextMemoryVisibility.java @@ -119,7 +119,7 @@ public static void enforceVisibility(ContextMemory memory, SecurityContext secur * rule when {@code entity} is a memory and does nothing for every other entity type, so a caller * needs no per-type knowledge to be safe. */ - public static void enforceVisibility(EntityInterface entity, SecurityContext securityContext) { + public static void enforceVisibility(EntityInterface entity, SecurityContext securityContext) { if (entity instanceof ContextMemory memory) { enforceVisibility(memory, securityContext); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/data/DataContractResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/data/DataContractResource.java index b4cbb19dbfd7..a339779483e8 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/data/DataContractResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/data/DataContractResource.java @@ -420,7 +420,7 @@ public DataContract getByEntityId( Entity.getEntityRepository(entityType) .getAllowedFields() .contains(Entity.FIELD_DATA_PRODUCTS); - EntityInterface entity = + EntityInterface entity = Entity.getEntity( entityType, entityId, supportsDataProducts ? "dataProducts" : "", Include.NON_DELETED); DataContract dataContract = repository.getEffectiveDataContract(entity); @@ -1003,7 +1003,7 @@ public Response validateContract( authorizer.authorize(securityContext, operationContext, resourceContext); // Get the effective contract (with inherited properties from data products) for validation - EntityInterface entity = + EntityInterface entity = Entity.getEntity( dataContract.getEntity().getType(), dataContract.getEntity().getId(), @@ -1052,7 +1052,7 @@ public Response validateContractByEntityId( new OperationContext(entityType, MetadataOperation.EDIT_ALL), getResourceContextById(entityId)); - EntityInterface entity = Entity.getEntity(entityType, entityId, "*", Include.NON_DELETED); + EntityInterface entity = Entity.getEntity(entityType, entityId, "*", Include.NON_DELETED); return repository .validateEntityContract(entity, securityContext.getUserPrincipal().getName()) .orElseThrow( diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResolutionStatusResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResolutionStatusResource.java index fe4f6e0b8d91..659d9c46e29c 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResolutionStatusResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResolutionStatusResource.java @@ -1044,7 +1044,7 @@ protected static ResourceContextInterface buildEntityResourceContext( MessageParser.EntityLink.parse(testCase.getEntityLink()); return TestCaseResourceContext.builder().entityLink(entityLink).build(); } else if (originEntityFQN != null) { - EntityInterface entityInterface = + EntityInterface entityInterface = Entity.getEntityByName(Entity.TABLE, originEntityFQN, "", Include.ALL); String entityLinkStr = EntityUtil.buildEntityLink(Entity.TABLE, entityInterface.getFullyQualifiedName()); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResource.java index 507f076fab5d..858d44d999b0 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResource.java @@ -1532,7 +1532,7 @@ private static String resolveUserOrTeamIds(String userOrTeamName, boolean includ } } catch (Exception e) { // If not a user, try to resolve as a team - EntityInterface entity = Entity.getEntityByName(Entity.TEAM, userOrTeamName, "", ALL); + EntityInterface entity = Entity.getEntityByName(Entity.TEAM, userOrTeamName, "", ALL); ids.append(entity.getId().toString()); } @@ -1785,7 +1785,7 @@ private SearchListFilter buildBulkSearchListFilter(Filter filter) { @Override protected void processChangeEventForBulkImport( - EntityRepository versioningRepo, + EntityRepository> versioningRepo, UriInfo uriInfo, SecurityContext securityContext, String name, diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestSuiteResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestSuiteResource.java index 8418d0fbfa5d..8ff4842e11b9 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestSuiteResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestSuiteResource.java @@ -296,7 +296,7 @@ public ResultList listFromSearch( searchListFilter.addQueryParam("excludeFields", SEARCH_FIELDS_EXCLUDE); searchListFilter.addQueryParam("domains", domain); if (!nullOrEmpty(owner)) { - EntityInterface entity; + EntityInterface entity; try { entity = Entity.getEntityByName(Entity.USER, owner, "", ALL); } catch (Exception e) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/entityProfiles/EntityProfileResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/entityProfiles/EntityProfileResource.java index 6f7d7c91bec9..94a7425436a7 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/entityProfiles/EntityProfileResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/entityProfiles/EntityProfileResource.java @@ -134,7 +134,7 @@ public ResultList listProfileData( ResourceContext resourceContext = new ResourceContext<>(entityType, null, entityFQN); authorizer.authorize(securityContext, operationContext, resourceContext); - EntityInterface entity = Entity.getEntityByName(entityType, entityFQN, "owners", ALL); + EntityInterface entity = Entity.getEntityByName(entityType, entityFQN, "owners", ALL); Boolean authorizePII = authorizer.authorizePII(securityContext, entity.getOwners()); return repository.listProfileData(filter, startTs, endTs, authorizePII); } @@ -170,7 +170,7 @@ public Response addProfileDataById( new OperationContext(entityType, MetadataOperation.EDIT_DATA_PROFILE); ResourceContext

resourceContext = new ResourceContext<>(entityType, id, null); authorizer.authorize(securityContext, operationContext, resourceContext); - EntityInterface entity = Entity.getEntity(entityType, id, "", ALL); + EntityInterface entity = Entity.getEntity(entityType, id, "", ALL); return repository.addProfileData(uriInfo, entity, create); } @@ -205,7 +205,7 @@ public Response addProfileDataByName( new OperationContext(entityType, MetadataOperation.EDIT_DATA_PROFILE); ResourceContext
resourceContext = new ResourceContext<>(entityType, null, fqn); authorizer.authorize(securityContext, operationContext, resourceContext); - EntityInterface entity = Entity.getEntityByName(entityType, fqn, "", ALL); + EntityInterface entity = Entity.getEntityByName(entityType, fqn, "", ALL); return repository.addProfileData(uriInfo, entity, create); } @@ -313,7 +313,7 @@ public Response deleteEntityProfileDataById( new OperationContext(entityType, MetadataOperation.EDIT_DATA_PROFILE); ResourceContext
resourceContext = new ResourceContext<>(entityType, id, null); authorizer.authorize(securityContext, operationContext, resourceContext); - EntityInterface entity = Entity.getEntity(entityType, id, "", ALL); + EntityInterface entity = Entity.getEntity(entityType, id, "", ALL); ListFilter filter = new ListFilter(null); filter.addQueryParam("entityProfileColumnName", columnName); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/filters/ETagResponseFilter.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/filters/ETagResponseFilter.java index 1b152111d37a..c91d9f686d6b 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/filters/ETagResponseFilter.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/filters/ETagResponseFilter.java @@ -71,7 +71,7 @@ public void filter( private static boolean shouldEmitETag( ContainerRequestContext requestContext, ContainerResponseContext responseContext) { boolean result = false; - if (responseContext.getEntity() instanceof EntityInterface) { + if (responseContext.getEntity() instanceof EntityInterface) { String method = requestContext.getMethod(); int status = responseContext.getStatus(); boolean successfulRead = GET.equals(method) && status == Response.Status.OK.getStatusCode(); @@ -86,7 +86,7 @@ private static boolean shouldEmitETag( private static void applyETag( ContainerRequestContext requestContext, ContainerResponseContext responseContext) { - String etag = EntityETag.generateETag((EntityInterface) responseContext.getEntity()); + String etag = EntityETag.generateETag((EntityInterface) responseContext.getEntity()); if (etag != null) { responseContext.getHeaders().putSingle(HttpHeaders.ETAG, etag); responseContext.getHeaders().putSingle(HttpHeaders.CACHE_CONTROL, CACHE_CONTROL_VALUE); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/lineage/LineageResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/lineage/LineageResource.java index 1d86883b2c89..628691d37ad4 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/lineage/LineageResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/lineage/LineageResource.java @@ -1417,7 +1417,7 @@ public List getTags() { } @Override - public EntityInterface getEntity() { + public EntityInterface getEntity() { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/lineage/OpenLineageResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/lineage/OpenLineageResource.java index 61c3f5168483..22965b7e3d61 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/lineage/OpenLineageResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/lineage/OpenLineageResource.java @@ -116,9 +116,9 @@ private OpenLineageMapper createMapper(SecurityContext securityContext) { * entity's persisted parent. */ private void authorizeCreate( - SecurityContext securityContext, String entityType, EntityInterface entity) { + SecurityContext securityContext, String entityType, EntityInterface entity) { OperationContext operationContext = new OperationContext(entityType, MetadataOperation.CREATE); - CreateResourceContext resourceContext = + CreateResourceContext> resourceContext = new CreateResourceContext<>(entityType, entity); limits.enforceLimits(securityContext, resourceContext, operationContext); authorizer.authorize(securityContext, operationContext, resourceContext); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/rdf/RdfQueryResourceContext.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/rdf/RdfQueryResourceContext.java index 03130a0622b5..012f8b2f5a83 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/rdf/RdfQueryResourceContext.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/rdf/RdfQueryResourceContext.java @@ -43,7 +43,7 @@ public List getTags() { } @Override - public EntityInterface getEntity() { + public EntityInterface getEntity() { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/scim/ScimResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/scim/ScimResource.java index d80a30500f81..34e5fbc963f4 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/scim/ScimResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/scim/ScimResource.java @@ -375,7 +375,7 @@ public List getTags() { } @Override - public EntityInterface getEntity() { + public EntityInterface getEntity() { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/search/SearchResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/search/SearchResource.java index 86a0bd21c699..860d8c7d58f6 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/search/SearchResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/search/SearchResource.java @@ -1055,7 +1055,7 @@ public Response reindexEntities( String fields = String.join(",", ReindexingUtil.getSearchIndexFields(entityType)); - EntityInterface entity = Entity.getEntity(ref, fields, Include.ALL); + EntityInterface entity = Entity.getEntity(ref, fields, Include.ALL); String indexName = indexMapping.getIndexName(searchRepository.getClusterAlias()); @@ -1074,7 +1074,7 @@ public Response reindexEntities( docSizeBytes, maxContentLength); - EntityInterface reducedEntity = + EntityInterface reducedEntity = Entity.getEntity( ref, "id,name,fullyQualifiedName,displayName,description,owners,tags,deleted", diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/EntityPipelineRunner.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/EntityPipelineRunner.java index 24d3811beeb1..0189fe7e430d 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/EntityPipelineRunner.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/EntityPipelineRunner.java @@ -80,7 +80,7 @@ public PipelineServiceClientResponse run( EntityLink entityLink = EntityLink.parse(request.getEntityLink()); PipelineType pipelineType = request.getPipelineType(); RunnablePipelineResolver resolver = resolverFor(entityLink, pipelineType); - EntityInterface target = + EntityInterface target = Entity.getEntity(entityLink, resolver.entityFields(), Include.NON_DELETED); authorizeView(securityContext, entityLink.getEntityType(), target); IngestionPipeline pipeline = @@ -127,7 +127,7 @@ private static RunnablePipelineResolver resolverFor( } private static NotFoundException noRunnablePipeline( - EntityInterface target, PipelineType pipelineType) { + EntityInterface target, PipelineType pipelineType) { return new NotFoundException( String.format( "'%s' has no enabled, deployed %s ingestion pipeline to run.", @@ -137,7 +137,7 @@ private static NotFoundException noRunnablePipeline( // The run aims a pipeline at the entity the caller named, so a caller who may not see that entity // may not aim a pipeline at it either. The Trigger check covers the pipeline, not its target. private void authorizeView( - SecurityContext securityContext, String entityType, EntityInterface target) { + SecurityContext securityContext, String entityType, EntityInterface target) { authorizer.authorize( securityContext, new OperationContext(entityType, MetadataOperation.VIEW_BASIC), diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/MetadataScoper.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/MetadataScoper.java index 9dddd6ac5154..daf347ad2705 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/MetadataScoper.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/MetadataScoper.java @@ -53,7 +53,7 @@ public void checkScopable(IngestionPipeline pipeline) { } @Override - public Map sourceConfigOverride(EntityInterface table) { + public Map sourceConfigOverride(EntityInterface table) { Map override = new HashMap<>(tableFilterScoper.sourceConfigOverride(table)); override.put("markDeletedTables", false); override.put("markDeletedSchemas", false); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/RunnablePipelineResolver.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/RunnablePipelineResolver.java index 98176db8d022..28b4d206df35 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/RunnablePipelineResolver.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/RunnablePipelineResolver.java @@ -34,7 +34,7 @@ public interface RunnablePipelineResolver { String entityFields(); /** The pipelines of {@code pipelineType} that own {@code target}, whether runnable or not. */ - List pipelinesOwning(EntityInterface target, PipelineType pipelineType); + List pipelinesOwning(EntityInterface target, PipelineType pipelineType); static List pipelinesOfType( List pipelines, PipelineType pipelineType) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/SourceConfigScoper.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/SourceConfigScoper.java index ecef35bc8d13..16c8e41c4207 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/SourceConfigScoper.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/SourceConfigScoper.java @@ -32,5 +32,5 @@ public interface SourceConfigScoper { default void checkScopable(IngestionPipeline pipeline) {} /** The source config keys that narrow the run to {@code target}; see RunOptions. */ - Map sourceConfigOverride(EntityInterface target); + Map sourceConfigOverride(EntityInterface target); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/TableFilterScoper.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/TableFilterScoper.java index 0e41121e606a..2bcf5d6351ac 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/TableFilterScoper.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/TableFilterScoper.java @@ -33,7 +33,7 @@ public class TableFilterScoper implements SourceConfigScoper { private static final Pattern REGEX_METACHARACTER = Pattern.compile("[\\\\.^$|?*+()\\[\\]{}]"); @Override - public Map sourceConfigOverride(EntityInterface target) { + public Map sourceConfigOverride(EntityInterface target) { Table table = (Table) target; // Matching on FQNs rather than names keeps a table apart from a same-named one in another // schema; views are included so a view can be scoped too, the patterns still match only it. diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/TablePipelineResolver.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/TablePipelineResolver.java index dbf968285e69..5c2e374ff683 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/TablePipelineResolver.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/TablePipelineResolver.java @@ -40,7 +40,8 @@ public String entityFields() { } @Override - public List pipelinesOwning(EntityInterface table, PipelineType pipelineType) { + public List pipelinesOwning( + EntityInterface table, PipelineType pipelineType) { DatabaseService service = Entity.getEntity(((Table) table).getService(), "pipelines", Include.NON_DELETED); return RunnablePipelineResolver.pipelinesOfType(service.getPipelines(), pipelineType); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/TestCasePipelineResolver.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/TestCasePipelineResolver.java index fab4068044fc..2be69b2f4dc5 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/TestCasePipelineResolver.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/TestCasePipelineResolver.java @@ -42,7 +42,7 @@ public String entityFields() { @Override public List pipelinesOwning( - EntityInterface testCase, PipelineType pipelineType) { + EntityInterface testCase, PipelineType pipelineType) { TestSuite testSuite = Entity.getEntity(((TestCase) testCase).getTestSuite(), "pipelines", Include.NON_DELETED); return RunnablePipelineResolver.pipelinesOfType(testSuite.getPipelines(), pipelineType); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/TestCaseScoper.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/TestCaseScoper.java index 3f2a84f6b357..f205c7f01330 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/TestCaseScoper.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/run/TestCaseScoper.java @@ -25,7 +25,7 @@ public class TestCaseScoper implements SourceConfigScoper { // The test suite source filters on the test case name, not its FQN - an FQN would run nothing. // Names are unique within the test case's table suite, which is the suite this scope runs. @Override - public Map sourceConfigOverride(EntityInterface testCase) { + public Map sourceConfigOverride(EntityInterface testCase) { return Map.of(TEST_CASES, List.of(testCase.getName())); } } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/system/SystemResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/system/SystemResource.java index 0b999504be44..6a86c146b600 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/system/SystemResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/system/SystemResource.java @@ -1795,7 +1795,7 @@ public Response invalidateCacheForEntity( if (id == null && normalizedFqn != null) { try { EntityRepository repository = Entity.getEntityRepository(type); - EntityInterface resolved = repository.findByName(normalizedFqn, Include.ALL, false); + EntityInterface resolved = repository.findByName(normalizedFqn, Include.ALL, false); if (resolved != null) { id = resolved.getId(); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/teams/UserResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/teams/UserResource.java index e9516f6f7702..486f4e3b2d57 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/teams/UserResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/teams/UserResource.java @@ -2125,7 +2125,7 @@ private Response createOrUpdateBotUser( User user, CreateUser create, UriInfo uriInfo, SecurityContext securityContext) { User original = retrieveBotUser(user, uriInfo); String botName = create.getBotName(); - EntityInterface bot = retrieveBot(botName); + EntityInterface bot = retrieveBot(botName); // check if the bot user exists if (original != null && (original.getIsBot() == null || Boolean.FALSE.equals(original.getIsBot()))) { @@ -2168,7 +2168,7 @@ && userHasRelationshipWithAnyBot(original, bot)) { return response.toResponse(); } - private EntityInterface retrieveBot(String botName) { + private EntityInterface retrieveBot(String botName) { try { return Entity.getEntityRepository(Entity.BOT).getByName(null, botName, Fields.EMPTY_FIELDS); } catch (Exception e) { @@ -2176,7 +2176,7 @@ private EntityInterface retrieveBot(String botName) { } } - private boolean userHasRelationshipWithAnyBot(User user, EntityInterface botUser) { + private boolean userHasRelationshipWithAnyBot(User user, EntityInterface botUser) { List userBotRelationship = retrieveBotRelationshipsFor(user); return !userBotRelationship.isEmpty() @@ -2189,7 +2189,7 @@ private List retrieveBotRelationshipsFor return repository.findFromRecords(user.getId(), Entity.USER, Relationship.CONTAINS, Entity.BOT); } - private boolean botHasRelationshipWithUser(EntityInterface bot, User user) { + private boolean botHasRelationshipWithUser(EntityInterface bot, User user) { if (bot == null || user == null) { return false; } @@ -2200,7 +2200,7 @@ private boolean botHasRelationshipWithUser(EntityInterface bot, User user) { } private List retrieveBotRelationshipsFor( - EntityInterface bot) { + EntityInterface bot) { return repository.findToRecords(bot.getId(), Entity.BOT, Relationship.CONTAINS, Entity.USER); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/types/TypeResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/types/TypeResource.java index 8b2763b554f7..9ed14d3d6e11 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/types/TypeResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/types/TypeResource.java @@ -14,6 +14,7 @@ package org.openmetadata.service.resources.types; import static org.openmetadata.common.utils.CommonUtil.listOrEmpty; +import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty; import static org.openmetadata.service.Entity.ADMIN_USER_NAME; import io.swagger.v3.oas.annotations.ExternalDocumentation; @@ -58,7 +59,6 @@ import org.openmetadata.schema.entity.type.Category; import org.openmetadata.schema.entity.type.CustomProperty; import org.openmetadata.schema.type.EntityHistory; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.Include; import org.openmetadata.schema.type.MetadataOperation; import org.openmetadata.schema.utils.JsonUtils; @@ -186,22 +186,32 @@ public WorkflowTriggerFieldsRegistry.WorkflowTriggerFieldsConfig getWorkflowTrig mediaType = "application/json", schema = @Schema(implementation = EntityLifecycleStages.class))) }) - public EntityLifecycleStages getEntityLifecycleStages() { + public EntityLifecycleStages getEntityLifecycleStages(@QueryParam("index") String index) { + List scopedTypes = + nullOrEmpty(index) ? null : Entity.getSearchRepository().getEntityTypesForIndex(index); List entityTypes = - Entity.getEntityTypesWithLifecycleStage().stream().map(TypeResource::lifecycleOf).toList(); + Entity.getEntityTypesWithLifecycleStage().stream() + .filter(type -> scopedTypes == null || scopedTypes.contains(type)) + .map(TypeResource::lifecycleOf) + .toList(); return new EntityLifecycleStages() - .withStages(List.of(EntityStatus.values())) + .withStages( + entityTypes.stream() + .flatMap(type -> type.getStages().stream()) + .distinct() + .sorted() + .toList()) .withEntityTypes(entityTypes); } private static EntityTypeLifecycle lifecycleOf(String entityType) { EntityRepository repository = Entity.getEntityRepository(entityType); - EntityLifecycle lifecycle = repository.getEntityLifecycle(); + EntityLifecycle lifecycle = repository.getEntityLifecycle(); return new EntityTypeLifecycle() .withEntityType(entityType) - .withStages(List.copyOf(lifecycle.stages())) + .withStages(lifecycle.stageCodes()) .withTransitions( - lifecycle.transitions().entrySet().stream() + lifecycle.transitionCodes().entrySet().stream() .map( move -> new StageTransition() diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/rules/RuleEngine.java b/openmetadata-service/src/main/java/org/openmetadata/service/rules/RuleEngine.java index 8bcc7dcd6d6f..f93b42baedca 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/rules/RuleEngine.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/rules/RuleEngine.java @@ -52,15 +52,15 @@ public Object apply(String rule, Map context) { /** * Evaluates the default platform entity semantics rules against the provided entity */ - public void evaluate(EntityInterface facts) { + public void evaluate(EntityInterface facts) { evaluate(facts, null, true, false); } - public void evaluate(EntityInterface facts, boolean enforcePlatform, boolean enforceContract) { + public void evaluate(EntityInterface facts, boolean enforcePlatform, boolean enforceContract) { evaluate(facts, null, enforcePlatform, enforceContract); } - public void evaluateUpdate(EntityInterface original, EntityInterface updated) { + public void evaluateUpdate(EntityInterface original, EntityInterface updated) { List originalErrors = evaluateAndReturn(original, null, true, false); List updatedErrors = evaluateAndReturn(updated, null, true, false); @@ -71,7 +71,7 @@ public void evaluateUpdate(EntityInterface original, EntityInterface updated) { } public void evaluate( - EntityInterface facts, + EntityInterface facts, List rules, boolean enforcePlatform, boolean enforceContract) { @@ -91,7 +91,7 @@ private void raiseErroredRules(List erroredRules) { } public List evaluateAndReturn( - EntityInterface facts, + EntityInterface facts, List rules, boolean enforcePlatform, boolean enforceContract) { @@ -113,7 +113,7 @@ public List evaluateAndReturn( } private List getRulesToEvaluate( - EntityInterface facts, + EntityInterface facts, List rules, boolean enforcePlatform, boolean enforceContract) { @@ -139,7 +139,7 @@ private List getRulesToEvaluate( return rulesToEvaluate; } - public Boolean shouldApplyRule(EntityInterface facts, SemanticsRule rule) { + public Boolean shouldApplyRule(EntityInterface facts, SemanticsRule rule) { if (!rule.getEnabled()) { return false; // If the rule is not enabled, skip it } @@ -153,7 +153,7 @@ public Boolean shouldApplyRule(EntityInterface facts, SemanticsRule rule) { } // Finally, check if the rule is not ignored for the entity type if (!nullOrEmpty(rule.getIgnoredEntities())) { - List> ignoredEntities = + List>> ignoredEntities = rule.getIgnoredEntities().stream() .map(Entity::getEntityRepository) .map(EntityRepository::getEntityClass) @@ -197,7 +197,7 @@ private void validateRule(Object facts, SemanticsRule rule) throws RuleValidatio } } - private DataContract getEntityDataContractSafely(EntityInterface entity) { + private DataContract getEntityDataContractSafely(EntityInterface entity) { try { return ((DataContractRepository) Entity.getEntityRepository(Entity.DATA_CONTRACT)) .getEffectiveDataContract(entity); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchIndexRetryQueue.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchIndexRetryQueue.java index 8669f090feea..4be63e33fa81 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchIndexRetryQueue.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchIndexRetryQueue.java @@ -30,7 +30,7 @@ public final class SearchIndexRetryQueue { private SearchIndexRetryQueue() {} - public static void enqueue(EntityInterface entity, String operation, Throwable failure) { + public static void enqueue(EntityInterface entity, String operation, Throwable failure) { if (entity == null) { return; } @@ -44,7 +44,7 @@ public static void enqueue(EntityInterface entity, String operation, Throwable f } public static void enqueueWithPropagation( - EntityInterface entity, + EntityInterface entity, ChangeDescription propagationChangeDescription, String failureReason) { if (entity == null) { @@ -60,7 +60,7 @@ public static void enqueueWithPropagation( } public static void enqueueWithPropagation( - EntityInterface entity, + EntityInterface entity, ChangeDescription propagationChangeDescription, String operation, Throwable failure) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchIndexRetryWorker.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchIndexRetryWorker.java index 480e9f6021f0..e120b85d9ade 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchIndexRetryWorker.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchIndexRetryWorker.java @@ -180,7 +180,7 @@ private void processRecord(SearchIndexRetryRecord record) { try { EntityReference root = resolveEntityReference(record); if (root != null) { - EntityInterface rootEntity = reindexEntityCascade(root); + EntityInterface rootEntity = reindexEntityCascade(root); propagateAfterRetry(rootEntity, record.getFailureReason()); completeClaim(record); return; @@ -415,14 +415,14 @@ private List candidateEntityTypes() { // Reindexing // --------------------------------------------------------------------------- - EntityInterface reindexEntityCascade(EntityReference root) throws Exception { + EntityInterface reindexEntityCascade(EntityReference root) throws Exception { ArrayDeque queue = new ArrayDeque<>(); Set visited = new HashSet<>(); - List entitiesToIndex = new ArrayList<>(); + List> entitiesToIndex = new ArrayList<>(); Map relationshipRevisions = new HashMap<>(); queue.add(root); int processed = 0; - EntityInterface rootEntity = null; + EntityInterface rootEntity = null; while (!queue.isEmpty() && processed < MAX_CASCADE_REINDEX) { EntityReference current = queue.poll(); @@ -449,7 +449,7 @@ EntityInterface reindexEntityCascade(EntityReference root) throws Exception { throw ex; } - EntityInterface entity = snapshot.entity(); + EntityInterface entity = snapshot.entity(); if (entity == null) { throw new IllegalStateException( "Loaded an empty entity while processing search retry for " + current.getId()); @@ -499,7 +499,7 @@ EntityInterface reindexEntityCascade(EntityReference root) throws Exception { return rootEntity; } - void propagateAfterRetry(EntityInterface rootEntity, String failureReason) throws IOException { + void propagateAfterRetry(EntityInterface rootEntity, String failureReason) throws IOException { ChangeDescription propagationChangeDescription = SearchIndexRetryQueue.getPropagationContext(failureReason); if (rootEntity != null && propagationChangeDescription != null) { @@ -519,7 +519,7 @@ private StableEntitySnapshot loadStableEntitySnapshot(EntityReference reference) if (cachedReadBundle != null) { cachedReadBundle.invalidate(reference.getType(), reference.getId()); } - EntityInterface entity = Entity.getEntity(reference, fields, Include.ALL); + EntityInterface entity = Entity.getEntity(reference, fields, Include.ALL); if (entity instanceof TestSuite testSuite && !Boolean.FALSE.equals(testSuite.getBasic())) { return new StableEntitySnapshot(entity, null); } @@ -545,15 +545,15 @@ private long getRelationshipRevision(EntityReference reference) { } private void upsertEntitiesInBulk( - List entitiesToIndex, Map relationshipRevisions) + List> entitiesToIndex, Map relationshipRevisions) throws Exception { if (entitiesToIndex.size() == 1 && relationshipRevisions.isEmpty()) { upsertEntityDirect(entitiesToIndex.getFirst()); return; } - Map> entitiesByType = new HashMap<>(); - for (EntityInterface entity : entitiesToIndex) { + Map>> entitiesByType = new HashMap<>(); + for (EntityInterface entity : entitiesToIndex) { if (entity == null || entity.getEntityReference() == null) { continue; } @@ -582,7 +582,7 @@ private void upsertEntitiesInBulk( }); try { - for (Map.Entry> entry : entitiesByType.entrySet()) { + for (Map.Entry>> entry : entitiesByType.entrySet()) { Map context = new HashMap<>(); context.put(ReindexingUtil.ENTITY_TYPE_KEY, entry.getKey()); Map typeRelationshipRevisions = @@ -595,8 +595,8 @@ private void upsertEntitiesInBulk( } if (!relationshipRevisions.isEmpty()) { - for (Map.Entry> entry : entitiesByType.entrySet()) { - List relationshipEntities = + for (Map.Entry>> entry : entitiesByType.entrySet()) { + List> relationshipEntities = entry.getValue().stream() .filter(entity -> relationshipRevisions.containsKey(entity.getId())) .toList(); @@ -639,9 +639,9 @@ private void upsertEntitiesInBulk( } private Map relationshipRevisionsFor( - List entities, Map relationshipRevisions) { + List> entities, Map relationshipRevisions) { Map revisions = new HashMap<>(); - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { Long revision = relationshipRevisions.get(entity.getId()); if (revision != null) { revisions.put(entity.getId(), revision); @@ -650,7 +650,7 @@ private Map relationshipRevisionsFor( return revisions; } - private void upsertEntityDirect(EntityInterface entity) throws Exception { + private void upsertEntityDirect(EntityInterface entity) throws Exception { if (entity == null || entity.getEntityReference() == null || entity.getId() == null) { return; } @@ -716,7 +716,7 @@ void removeStaleEntityById(String entityId, String entityTypeHint) throws Except } } - private record StableEntitySnapshot(EntityInterface entity, Long relationshipRevision) {} + private record StableEntitySnapshot(EntityInterface entity, Long relationshipRevision) {} // --------------------------------------------------------------------------- // Resilience: client availability, backoff, and error classification diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchIndexUtils.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchIndexUtils.java index eceaa39b70d6..e13046276725 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchIndexUtils.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchIndexUtils.java @@ -721,7 +721,7 @@ private static String resolveTagSource(TagLabel tag, TagLabel.LabelType labelTyp } private static void processEntityTagSources( - EntityInterface entity, TagAndTierSources tagAndTierSources) { + EntityInterface entity, TagAndTierSources tagAndTierSources) { processTagAndTierSources(entity.getTags(), tagAndTierSources); } @@ -732,7 +732,7 @@ private static void processColumnTagSources( } } - public static TagAndTierSources processTagAndTierSources(EntityInterface entity) { + public static TagAndTierSources processTagAndTierSources(EntityInterface entity) { TagAndTierSources tagAndTierSources = new TagAndTierSources(); processEntityTagSources(entity, tagAndTierSources); if (SearchIndexUtils.hasColumns(entity)) { @@ -742,7 +742,7 @@ public static TagAndTierSources processTagAndTierSources(EntityInterface entity) } public static void processDescriptionSource( - EntityInterface entity, + EntityInterface entity, Map changeSummaryMap, Map descriptionSources) { Optional.ofNullable( @@ -768,12 +768,12 @@ public static void processColumnDescriptionSources( } } - public static boolean hasColumns(EntityInterface entity) { + public static boolean hasColumns(EntityInterface entity) { return List.of(entity.getClass().getInterfaces()).contains(ColumnsEntityInterface.class); } public static Map processDescriptionSources( - EntityInterface entity, Map changeSummaryMap) { + EntityInterface entity, Map changeSummaryMap) { Map descriptionSources = new HashMap<>(); processDescriptionSource(entity, changeSummaryMap, descriptionSources); if (hasColumns(entity)) { @@ -783,7 +783,7 @@ public static Map processDescriptionSources( return descriptionSources; } - public static Map getChangeSummaryMap(EntityInterface entity) { + public static Map getChangeSummaryMap(EntityInterface entity) { return Optional.ofNullable(entity.getChangeDescription()) .map(ChangeDescription::getChangeSummary) .map(ChangeSummaryMap::getAdditionalProperties) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchListFilter.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchListFilter.java index 58b68866e51c..47d2f5416f8b 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchListFilter.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchListFilter.java @@ -7,7 +7,7 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -import org.openmetadata.schema.type.EntityStatus; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.type.Include; import org.openmetadata.service.Entity; import org.openmetadata.service.jdbi3.DataQualityDimensionRepository; @@ -16,7 +16,8 @@ import org.openmetadata.service.search.security.ContextMemorySearchVisibility; public class SearchListFilter extends Filter { - private List memoryStatuses = ContextMemorySearchVisibility.SEARCHABLE_STATUSES; + private List memoryStatuses = + ContextMemorySearchVisibility.SEARCHABLE_STATUSES; public SearchListFilter() { this(Include.NON_DELETED); @@ -30,12 +31,12 @@ public SearchListFilter(Include include) { * Context memory stages the listing admits. Applied with memory visibility rather than as a * condition, since ordinary search already admits Approved memories only. */ - public SearchListFilter withMemoryStatuses(List statuses) { + public SearchListFilter withMemoryStatuses(List statuses) { memoryStatuses = List.copyOf(statuses); return this; } - public List getMemoryStatuses() { + public List getMemoryStatuses() { return memoryStatuses; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchManagementClient.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchManagementClient.java index 9cdfb1d26122..50d08c3f99ae 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchManagementClient.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchManagementClient.java @@ -4,8 +4,8 @@ import java.io.IOException; import java.util.List; import org.openmetadata.schema.api.search.SearchSettings; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.search.SearchRequest; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.service.search.security.ContextMemorySearchVisibility; import org.openmetadata.service.security.policyevaluator.SubjectContext; @@ -173,7 +173,7 @@ SearchResultListMapper listWithOffset( String q, String queryString, SubjectContext subjectContext, - List memoryStatuses) + List memoryStatuses) throws IOException; /** diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java index a34c2af5b25d..ac6a121f7819 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java @@ -328,7 +328,7 @@ private static RelationshipRevisionSpec relationshipRevisionSpec( relationshipField, revisionField, replacementScript, documentUpdateScript); } - private static RelationshipRevisionSpec relationshipRevisionSpec(EntityInterface entity) { + private static RelationshipRevisionSpec relationshipRevisionSpec(EntityInterface entity) { if (entity == null || entity.getEntityReference() == null) { return null; } @@ -345,7 +345,7 @@ private static RelationshipRevisionSpec relationshipRevisionSpec(EntityInterface } public static void applyRelationshipRevision( - EntityInterface entity, Map document, Long relationshipRevision) { + EntityInterface entity, Map document, Long relationshipRevision) { if (relationshipRevision == null) { return; } @@ -1361,7 +1361,7 @@ private String getHardenedResourceMapping(IndexMapping indexMapping) { * Create search index for an entity only (no lifecycle events). * This method is used by SearchIndexHandler. */ - public void createEntityIndex(EntityInterface entity) { + public void createEntityIndex(EntityInterface entity) { if (entity == null) { LOG.warn("Entity is null, cannot create index."); return; @@ -1524,7 +1524,7 @@ private void deleteTableColumns(Table table) { * {@code service.id} / {@code database.id} / {@code databaseSchema.id}, so delete by whichever * ancestor the deleted entity is. */ - private void deleteDescendantColumns(EntityInterface entity, String entityType) { + private void deleteDescendantColumns(EntityInterface entity, String entityType) { String columnParentField = switch (entityType) { case Entity.DATABASE_SERVICE -> SERVICE_ID; @@ -1679,10 +1679,10 @@ private List> buildEntityRefListWithDisplayName( * Create search indexes for multiple entities only (no lifecycle events). * This method is used by SearchIndexHandler. */ - public void createEntitiesIndex(List entities) throws IOException { + public void createEntitiesIndex(List> entities) throws IOException { if (!nullOrEmpty(entities)) { String entityType = null; - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { try { EntityReference entityReference = entity != null ? entity.getEntityReference() : null; if (entityReference != null) { @@ -1701,7 +1701,7 @@ public void createEntitiesIndex(List entities) throws IOExcepti Timer.Sample searchSample = RequestLatencyContext.startSearchOperation(); try { if (!getSearchClient().isClientAvailable()) { - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { try { if (Entity.isSearchIndexable(entity)) { SearchIndexRetryQueue.enqueue( @@ -1722,7 +1722,7 @@ public void createEntitiesIndex(List entities) throws IOExcepti } IndexMapping indexMapping = entityIndexMap.get(entityType); List> docs = new ArrayList<>(); - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { try { if (!Entity.isSearchIndexable(entity)) { continue; @@ -1756,7 +1756,7 @@ public void createEntitiesIndex(List entities) throws IOExcepti private static final int COLUMN_BATCH_SIZE = 500; - private void indexColumnsForTables(List entities) { + private void indexColumnsForTables(List> entities) { IndexMapping columnIndexMapping = columnIndexMappingIfEnabled(); if (columnIndexMapping == null) { return; @@ -1765,7 +1765,7 @@ private void indexColumnsForTables(List entities) { String indexName = getWriteIndexName(columnIndexMapping); List> allColumnDocs = new ArrayList<>(); - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { Table table = (Table) entity; if (table.getColumns() == null || table.getColumns().isEmpty()) { continue; @@ -1806,7 +1806,7 @@ private void indexColumnsForTables(List entities) { * Create search indexes for multiple entities and dispatch lifecycle events. * This method maintains backward compatibility. */ - public void createEntities(List entities) throws IOException { + public void createEntities(List> entities) throws IOException { // For backward compatibility, just call the index-only method // EntityRepository now handles lifecycle event dispatching createEntitiesIndex(entities); @@ -1885,7 +1885,7 @@ public void updateTimeSeriesEntity(EntityTimeSeriesInterface entityTimeSeries) { * entity to the durable retry outbox. Returns {@code false} (run inline) for every non-flush * caller — the post-commit search-index handler, reindex apps, lineage jobs. */ - private boolean deferEntityIndex(EntityInterface entity, Long relationshipRevision) { + private boolean deferEntityIndex(EntityInterface entity, Long relationshipRevision) { EntityReference ref = entity.getEntityReference(); return deferSearchWrite( new DeferredSearchWrite( @@ -1900,11 +1900,11 @@ private boolean deferEntityIndex(EntityInterface entity, Long relationshipRevisi * Update search index for an entity only (no lifecycle events). * This method is used by SearchIndexHandler. */ - public void updateEntityIndex(EntityInterface entity) { + public void updateEntityIndex(EntityInterface entity) { updateEntityIndex(entity, null); } - public void updateEntityIndex(EntityInterface entity, Long relationshipRevision) { + public void updateEntityIndex(EntityInterface entity, Long relationshipRevision) { if (entity == null) { LOG.warn("Entity is null, cannot update index."); return; @@ -2102,7 +2102,7 @@ public void updateEntity(EntityReference entityReference) { // consistent and bounded. String fields = String.join(",", searchIndexFactory.getReindexFieldsFor(entityReference.getType())); - EntityInterface entity = + EntityInterface entity = entityRepository.get( null, entityReference.getId(), entityRepository.getOnlySupportedFields(fields)); entity.setChangeDescription(null); @@ -2132,7 +2132,7 @@ public void updateEntityAndPropagateInheritedDomainsToChildren(EntityReference e EntityRepository entityRepository = Entity.getEntityRepository(entityReference.getType()); String fields = String.join(",", searchIndexFactory.getReindexFieldsFor(entityReference.getType())); - EntityInterface entity = + EntityInterface entity = entityRepository.get( null, entityReference.getId(), entityRepository.getOnlySupportedFields(fields)); entity.setChangeDescription(null); @@ -2181,7 +2181,7 @@ public void updateEntitiesByReference(List references) { final List chunk = List.copyOf( ids.subList(start, Math.min(start + REFERENCE_REINDEX_BATCH_SIZE, ids.size()))); - final List entities = + final List> entities = entityRepository.get(null, chunk, fields, Include.NON_DELETED); entities.forEach(entity -> entity.setChangeDescription(null)); if (!entities.isEmpty()) { @@ -2201,17 +2201,17 @@ public void updateEntitiesByReference(List references) { * * @param entities List of entities to update in the search index */ - public void updateEntitiesIndex(List entities) { + public void updateEntitiesIndex(List> entities) { updateEntitiesIndexInternal(entities, Map.of()); } public void updateEntitiesIndex( - List entities, Map relationshipRevisions) { + List> entities, Map relationshipRevisions) { updateEntitiesIndexInternal(entities, relationshipRevisions); } private void updateEntitiesIndexInternal( - List entities, Map suppliedRelationshipRevisions) { + List> entities, Map suppliedRelationshipRevisions) { if (entities == null || entities.isEmpty()) { return; } @@ -2223,8 +2223,8 @@ private void updateEntitiesIndexInternal( // Keep only the latest state per (entityType, entityId) within the same bulk call. // This avoids repeated writes/propagation for duplicates in a single request. - Map dedupedEntities = new LinkedHashMap<>(); - for (EntityInterface entity : entities) { + Map> dedupedEntities = new LinkedHashMap<>(); + for (EntityInterface entity : entities) { if (entity == null || entity.getId() == null || entity.getEntityReference() == null) { continue; } @@ -2241,8 +2241,8 @@ private void updateEntitiesIndexInternal( } // Group entities by their actual type to ensure each goes to the correct index - Map> entitiesByType = new HashMap<>(); - for (EntityInterface entity : dedupedEntities.values()) { + Map>> entitiesByType = new HashMap<>(); + for (EntityInterface entity : dedupedEntities.values()) { if (entity == null || entity.getEntityReference() == null || !checkIfIndexingIsSupported(entity.getEntityReference().getType())) { @@ -2256,13 +2256,13 @@ private void updateEntitiesIndexInternal( int batchSize = 100; int maxConcurrentRequests = 5; long maxPayloadSizeBytes = SearchClusterMetrics.DEFAULT_BULK_PAYLOAD_SIZE_BYTES; - List propagationCandidates = new ArrayList<>(); + List> propagationCandidates = new ArrayList<>(); // Process each entity type separately to ensure correct index routing - for (Map.Entry> entry : entitiesByType.entrySet()) { + for (Map.Entry>> entry : entitiesByType.entrySet()) { String entityType = entry.getKey(); - List typeEntities = new ArrayList<>(); - for (EntityInterface entity : entry.getValue()) { + List> typeEntities = new ArrayList<>(); + for (EntityInterface entity : entry.getValue()) { if (Entity.isSearchIndexable(entity)) { typeEntities.add(entity); } else { @@ -2274,22 +2274,22 @@ private void updateEntitiesIndexInternal( if (typeEntities.isEmpty()) { continue; } - Map typeEntitiesById = + Map> typeEntitiesById = typeEntities.stream() .collect( Collectors.toUnmodifiableMap( entity -> entity.getId().toString(), Function.identity())); - Map typeEntitiesByFqn = + Map> typeEntitiesByFqn = typeEntities.stream() .filter(entity -> !nullOrEmpty(entity.getFullyQualifiedName())) .collect( Collectors.toUnmodifiableMap( - EntityInterface::getFullyQualifiedName, + EntityInterface::getFullyQualifiedName, Function.identity(), (first, ignored) -> first)); if (!getSearchClient().isClientAvailable()) { - for (EntityInterface entity : typeEntities) { + for (EntityInterface entity : typeEntities) { enqueueEntityRetry(entity, "updateEntitiesBulk: Search client unavailable"); } continue; @@ -2312,7 +2312,7 @@ private void updateEntitiesIndexInternal( if (!nullOrEmpty(failedEntityFqn)) { failedEntityFqns.add(failedEntityFqn); } - EntityInterface failedEntity = + EntityInterface failedEntity = !nullOrEmpty(failedEntityId) ? typeEntitiesById.get(failedEntityId) : null; if (failedEntity == null && !nullOrEmpty(failedEntityFqn)) { failedEntity = typeEntitiesByFqn.get(failedEntityFqn); @@ -2355,7 +2355,7 @@ private void updateEntitiesIndexInternal( bulkSink = null; } if (!bulkWriteAttempted) { - for (EntityInterface entity : typeEntities) { + for (EntityInterface entity : typeEntities) { try { Long relationshipRevision = relationshipRevisions.get(entity.getId()); if (relationshipRevision == null) { @@ -2380,7 +2380,7 @@ private void updateEntitiesIndexInternal( propagationCandidates, confirmedEntityIds); } - for (EntityInterface entity : typeEntities) { + for (EntityInterface entity : typeEntities) { String entityId = entity.getId().toString(); String entityFqn = entity.getFullyQualifiedName(); if (confirmedEntityIds.contains(entityId) @@ -2415,12 +2415,12 @@ private boolean closeBulkSinkAndCheckQuiescent(BulkSink bulkSink) { } private void addConfirmedPropagationCandidates( - List entities, + List> entities, StepStats sinkStats, int recordedFailures, Set failedEntityIds, Set failedEntityFqns, - List propagationCandidates, + List> propagationCandidates, Set confirmedEntityIds) { int failedRecords = Optional.ofNullable(sinkStats.getFailedRecords()).orElse(0); if (failedRecords == 0 && recordedFailures == 0) { @@ -2435,7 +2435,7 @@ private void addConfirmedPropagationCandidates( failedRecords); return; } - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { if (!failedEntityIds.contains(entity.getId().toString()) && (entity.getFullyQualifiedName() == null || !failedEntityFqns.contains(entity.getFullyQualifiedName()))) { @@ -2445,12 +2445,12 @@ private void addConfirmedPropagationCandidates( } } - private void propagateEntitiesAfterBulkFlush(Iterable entities) { + private void propagateEntitiesAfterBulkFlush(Iterable> entities) { int candidates = 0; int propagated = 0; long startTime = System.currentTimeMillis(); - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { if (entity == null || entity.getId() == null || entity.getEntityReference() == null) { continue; } @@ -2493,7 +2493,8 @@ private void propagateEntitiesAfterBulkFlush(Iterable entities) } void propagateEntityAfterRetry( - EntityInterface entity, ChangeDescription propagationChangeDescription) throws IOException { + EntityInterface entity, ChangeDescription propagationChangeDescription) + throws IOException { if (entity == null || entity.getId() == null || entity.getEntityReference() == null) { return; } @@ -2507,7 +2508,7 @@ void propagateEntityAfterRetry( } private void propagateEntitySearchChanges( - EntityInterface entity, + EntityInterface entity, String entityType, ChangeDescription changeDescription, IndexMapping indexMapping) @@ -2520,7 +2521,7 @@ private void propagateEntitySearchChanges( propagateToRelatedEntities(entityType, changeDescription, indexMapping, entity); } - private void enqueueEntityRetry(EntityInterface entity, String failureReason) { + private void enqueueEntityRetry(EntityInterface entity, String failureReason) { if (entity == null) { return; } @@ -2538,7 +2539,7 @@ private void enqueueEntityRetry(EntityInterface entity, String failureReason) { failureReason); } - private void enqueueEntityRetry(EntityInterface entity, String operation, Throwable failure) { + private void enqueueEntityRetry(EntityInterface entity, String operation, Throwable failure) { if (entity == null) { return; } @@ -2550,7 +2551,7 @@ private void enqueueEntityRetry(EntityInterface entity, String operation, Throwa SearchIndexRetryQueue.enqueue(entity, operation, failure); } - public void updateEntitiesBulk(List entities) { + public void updateEntitiesBulk(List> entities) { updateEntitiesIndex(entities); } @@ -2718,10 +2719,11 @@ public void updateEntityFieldInSearch( * Only propagate when fields that actually affect children have been modified. */ private boolean requiresPropagation( - ChangeDescription changeDescription, String entityType, EntityInterface entity) { + ChangeDescription changeDescription, String entityType, EntityInterface entity) { if (changeDescription == null) return false; - EntityRepository repository = Entity.getEntityRepository(entityType); + EntityRepository> repository = + Entity.getEntityRepository(entityType); Set propagatedFields = repository.getSearchPropagationDescriptors().stream() .map(PropagationDescriptor::fieldName) @@ -2740,7 +2742,7 @@ public void propagateInheritedFieldsToChildren( String entityId, ChangeDescription changeDescription, IndexMapping indexMapping, - EntityInterface entity) + EntityInterface entity) throws IOException { if (changeDescription != null && !nullOrEmpty(indexMapping.getChildAliases())) { Pair> updates = @@ -2939,7 +2941,7 @@ public void propagateGlossaryTags( private static final String CERTIFICATION_TAG_FQN_FIELD = "certification.tagLabel.tagFQN"; public void propagateCertificationTags( - String entityType, EntityInterface entity, ChangeDescription changeDescription) { + String entityType, EntityInterface entity, ChangeDescription changeDescription) { if (changeDescription == null) { return; } @@ -2994,7 +2996,8 @@ private String getCertificationClassificationFromSettings() { .getAllowedClassification(); } - private void handleEntityCertificationUpdate(EntityInterface entity, ChangeDescription change) { + private void handleEntityCertificationUpdate( + EntityInterface entity, ChangeDescription change) { if (!isCertificationUpdated(change)) { return; } @@ -3005,7 +3008,7 @@ private void handleEntityCertificationUpdate(EntityInterface entity, ChangeDescr } private void propagateServiceStyle( - String entityType, EntityInterface entity, ChangeDescription change) { + String entityType, EntityInterface entity, ChangeDescription change) { if (!SERVICE_ENTITY_SET.contains(entityType) || !Entity.entityHasField(entityType, FIELD_STYLE) || !isStyleUpdated(change)) { @@ -3014,7 +3017,7 @@ private void propagateServiceStyle( cascadeServiceStyleToChildren(entity, entity.getStyle()); } - private void cascadeServiceStyleToChildren(EntityInterface service, Style style) { + private void cascadeServiceStyleToChildren(EntityInterface service, Style style) { String type = service.getEntityReference().getType(); IndexMapping indexMapping = entityIndexMap.get(type); if (indexMapping == null) { @@ -3049,7 +3052,7 @@ private void cascadeServiceStyleToChildren(EntityInterface service, Style style) // reindex. RAW_REPLACE in PropagationDescriptor can't be used because it // restores the old value on delete; we drive a dedicated script instead. private void cascadeCertificationToChildren( - EntityInterface entity, AssetCertification certification) { + EntityInterface entity, AssetCertification certification) { String type = entity.getEntityReference().getType(); if (!Entity.TABLE.equalsIgnoreCase(type)) { // Scope: Table only. Dashboard/ApiCollection children also have cert in @@ -3098,12 +3101,12 @@ private boolean hasFieldChange(ChangeDescription change, String fieldName) { .anyMatch(fieldChange -> fieldName.equals(fieldChange.getName())); } - private AssetCertification getCertificationFromEntity(EntityInterface entity) { + private AssetCertification getCertificationFromEntity(EntityInterface entity) { return (AssetCertification) EntityUtil.getEntityField(entity, CERTIFICATION_FIELD); } private void updateEntityCertificationInSearch( - EntityInterface entity, AssetCertification certification) { + EntityInterface entity, AssetCertification certification) { IndexMapping indexMapping = entityIndexMap.get(entity.getEntityReference().getType()); String indexName = getWriteIndexName(indexMapping); Map paramMap = new HashMap<>(); @@ -3128,7 +3131,7 @@ public void propagateToRelatedEntities( String entityType, ChangeDescription changeDescription, IndexMapping indexMapping, - EntityInterface entity) { + EntityInterface entity) { reindexQueriesForDomainChange(entityType, changeDescription, entity); @@ -3217,7 +3220,7 @@ public void propagateToRelatedEntities( } private void reindexQueriesForDomainChange( - String entityType, ChangeDescription changeDescription, EntityInterface entity) { + String entityType, ChangeDescription changeDescription, EntityInterface entity) { if (hasFieldChange(changeDescription, FIELD_DOMAINS)) { reindexQueriesForDomainSource(entityType, entity.getId(), entity.getFullyQualifiedName()); } @@ -3239,7 +3242,7 @@ private void reindexQueriesForDomainSource(String entityType, UUID entityId, Str } private Pair> getInheritedFieldChanges( - ChangeDescription changeDescription, EntityInterface entity, String entityType) { + ChangeDescription changeDescription, EntityInterface entity, String entityType) { StringBuilder scriptTxt = new StringBuilder(); Map fieldData = new HashMap<>(); @@ -3269,7 +3272,7 @@ private void appendAddScript( Map data, FieldChange field, PropagationDescriptor desc, - EntityInterface entity) { + EntityInterface entity) { switch (desc.propagationType()) { case ENTITY_REFERENCE_LIST -> { if (field.getName().equals(FIELD_FOLLOWERS)) { @@ -3330,7 +3333,7 @@ private void appendDeleteScript( Map data, FieldChange field, PropagationDescriptor desc, - EntityInterface entity) { + EntityInterface entity) { switch (desc.propagationType()) { case ENTITY_REFERENCE_LIST -> { if (field.getName().equals(FIELD_FOLLOWERS)) { @@ -3385,7 +3388,7 @@ private void appendUpdateScript( Map data, FieldChange field, PropagationDescriptor desc, - EntityInterface entity) { + EntityInterface entity) { switch (desc.propagationType()) { case ENTITY_REFERENCE_LIST -> { if (field.getName().equals(FIELD_FOLLOWERS)) { @@ -3449,7 +3452,7 @@ private void appendUpdateScript( } private List resolveEntityReferenceList( - String fieldName, EntityInterface entity) { + String fieldName, EntityInterface entity) { return switch (fieldName) { case "owners" -> entity.getOwners() != null ? JsonUtils.deepCopyList(entity.getOwners(), EntityReference.class) @@ -3599,7 +3602,7 @@ public void deleteByScript(String entityType, String scriptTxt, Map entity) { if (entity == null) { LOG.debug("Entity or EntityReference is null, cannot perform delete."); return; @@ -3642,7 +3645,7 @@ public void deleteEntityIndex(EntityInterface entity) { } } - public void deleteEntityByFQNPrefix(EntityInterface entity) { + public void deleteEntityByFQNPrefix(EntityInterface entity) { if (entity != null) { String entityType = entity.getEntityReference().getType(); String fqn = entity.getFullyQualifiedName(); @@ -3704,7 +3707,7 @@ public void deleteTimeSeriesEntityById(EntityTimeSeriesInterface entity) { * Soft delete or restore search index for an entity only (no lifecycle events). * This method is used by SearchIndexHandler. */ - public void softDeleteOrRestoreEntityIndex(EntityInterface entity, boolean delete) { + public void softDeleteOrRestoreEntityIndex(EntityInterface entity, boolean delete) { if (entity == null) { LOG.debug("Entity or EntityReference is null, cannot perform soft delete or restore."); return; @@ -3773,7 +3776,7 @@ private void softDeleteOrRestoreTableColumns(Table table, boolean delete) { } } - public void deleteOrUpdateChildren(EntityInterface entity, IndexMapping indexMapping) + public void deleteOrUpdateChildren(EntityInterface entity, IndexMapping indexMapping) throws IOException { String docId = entity.getId().toString(); String entityType = entity.getEntityReference().getType(); @@ -3871,7 +3874,7 @@ public void softDeleteOrRestoredChildren( } public String getScriptWithParams( - EntityInterface entity, + EntityInterface entity, Map fieldAddParams, ChangeDescription changeDescription) { List fieldsAdded = changeDescription.getFieldsAdded(); @@ -3964,12 +3967,12 @@ public String getScriptWithParams( return scriptTxt.toString(); } - public ScriptedPartialUpdate buildBulkScriptedPartialUpdate(EntityInterface entity) { + public ScriptedPartialUpdate buildBulkScriptedPartialUpdate(EntityInterface entity) { return buildBulkScriptedPartialUpdate(entity, null); } public ScriptedPartialUpdate buildRelationshipDocumentUpdate( - EntityInterface entity, Map document) { + EntityInterface entity, Map document) { RelationshipRevisionSpec revisionSpec = relationshipRevisionSpec(entity); if (revisionSpec == null || document == null) { return null; @@ -3979,7 +3982,7 @@ public ScriptedPartialUpdate buildRelationshipDocumentUpdate( } public ScriptedPartialUpdate buildBulkScriptedPartialUpdate( - EntityInterface entity, Long relationshipRevision) { + EntityInterface entity, Long relationshipRevision) { RelationshipRevisionSpec revisionSpec = relationshipRevisionSpec(entity); if (revisionSpec == null || relationshipRevision == null) { return null; @@ -4007,7 +4010,9 @@ public ScriptedPartialUpdate buildBulkScriptedPartialUpdate( } private ScriptedPartialUpdate buildScriptedPartialUpdate( - EntityInterface entity, ChangeDescription changeDescription, boolean isNonVersionedUpdate) { + EntityInterface entity, + ChangeDescription changeDescription, + boolean isNonVersionedUpdate) { if (!isNonVersionedUpdate || !canUseScriptedPartialUpdate(changeDescription)) { return null; } @@ -4016,7 +4021,7 @@ private ScriptedPartialUpdate buildScriptedPartialUpdate( return new ScriptedPartialUpdate(script, parameters); } - private ChangeDescription getEffectiveChangeDescription(EntityInterface entity) { + private ChangeDescription getEffectiveChangeDescription(EntityInterface entity) { ChangeDescription incrementalChangeDescription = entity.getIncrementalChangeDescription(); return !isNullOrEmptyChangeDescription(incrementalChangeDescription) ? incrementalChangeDescription diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchClient.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchClient.java index fc5de4de0937..d46b688c9f35 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchClient.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchClient.java @@ -63,6 +63,7 @@ import org.openmetadata.schema.dataInsight.DataInsightChartResult; import org.openmetadata.schema.dataInsight.custom.DataInsightCustomChart; import org.openmetadata.schema.dataInsight.custom.DataInsightCustomChartResultList; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.data.PageHierarchy; import org.openmetadata.schema.entity.data.QueryCostSearchResult; import org.openmetadata.schema.search.AggregationRequest; @@ -70,7 +71,6 @@ import org.openmetadata.schema.service.configuration.elasticsearch.ElasticSearchConfiguration; import org.openmetadata.schema.tests.DataQualityReport; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.LayerPaging; import org.openmetadata.schema.utils.JsonUtils; import org.openmetadata.schema.utils.ResultList; @@ -408,7 +408,7 @@ public SearchResultListMapper listWithOffset( String q, String queryString, SubjectContext subjectContext, - List memoryStatuses) + List memoryStatuses) throws IOException { return searchManager.listWithOffset( filter, diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchEntitiesProcessor.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchEntitiesProcessor.java index 1849febea37f..91c2e2c9f4ad 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchEntitiesProcessor.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchEntitiesProcessor.java @@ -23,7 +23,7 @@ @Slf4j public class ElasticSearchEntitiesProcessor - implements Processor, ResultList> { + implements Processor, ResultList>> { private final StepStats stats = new StepStats(); public ElasticSearchEntitiesProcessor(int total) { @@ -32,7 +32,7 @@ public ElasticSearchEntitiesProcessor(int total) { @Override public List process( - ResultList input, Map contextData) + ResultList> input, Map contextData) throws SearchIndexException { String entityType = (String) contextData.get(ENTITY_TYPE_KEY); if (CommonUtil.nullOrEmpty(entityType)) { @@ -71,16 +71,16 @@ public List process( } private static List buildBulkOperations( - String entityType, List entities) { + String entityType, List> entities) { List operations = new ArrayList<>(); - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { BulkOperation operation = getUpdateOperation(entityType, entity); operations.add(operation); } return operations; } - public static BulkOperation getUpdateOperation(String entityType, EntityInterface entity) { + public static BulkOperation getUpdateOperation(String entityType, EntityInterface entity) { IndexMapping indexMapping = Entity.getSearchRepository().getIndexMapping(entityType); String indexName = indexMapping.getIndexName(Entity.getSearchRepository().getClusterAlias()); String doc = diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchEntityManager.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchEntityManager.java index 395c9f374c3e..3844116a2b65 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchEntityManager.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchEntityManager.java @@ -1450,7 +1450,7 @@ public void reindexEntities(List entities) throws IOException { List operations = new ArrayList<>(); for (EntityReference entityRef : entities) { - EntityInterface entity = Entity.getEntity(entityRef, "*", Include.ALL); + EntityInterface entity = Entity.getEntity(entityRef, "*", Include.ALL); IndexMapping indexMapping = Entity.getSearchRepository().getIndexMapping(entityRef.getType()); String indexName = indexMapping.getIndexName(Entity.getSearchRepository().getClusterAlias()); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchSearchManager.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchSearchManager.java index b2ae4b9a0149..bc3961e8ac0a 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchSearchManager.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchSearchManager.java @@ -64,10 +64,10 @@ import org.openmetadata.schema.api.lineage.EsLineageData; import org.openmetadata.schema.api.search.AssetTypeConfiguration; import org.openmetadata.schema.api.search.SearchSettings; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.data.EntityHierarchy; import org.openmetadata.schema.entity.data.Table; import org.openmetadata.schema.settings.SettingsType; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.Include; import org.openmetadata.schema.utils.JsonUtils; import org.openmetadata.sdk.exception.SearchException; @@ -405,7 +405,7 @@ public SearchResultListMapper listWithOffset( String q, String queryString, SubjectContext subjectContext, - List statuses) + List statuses) throws IOException { if (!isClientAvailable) { throw new IOException("Elasticsearch client is not available"); @@ -638,7 +638,7 @@ private void applyRbacCondition( private void applyRbacCondition( SubjectContext subjectContext, ElasticSearchRequestBuilder requestBuilder, - List statuses) { + List statuses) { if (shouldApplyRbacConditions(subjectContext, rbacConditionEvaluator)) { OMQueryBuilder rbacQueryBuilder = rbacConditionEvaluator.evaluateConditions(subjectContext); if (rbacQueryBuilder != null) { @@ -692,7 +692,7 @@ private void applyContextMemoryVisibility( private void applyContextMemoryVisibility( SubjectContext subjectContext, ElasticSearchRequestBuilder requestBuilder, - List statuses) { + List statuses) { OMQueryBuilder visibilityBuilder = contextMemoryVisibility.buildVisibilityFilter(subjectContext, statuses); if (visibilityBuilder != null) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/AIContextIndex.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/AIContextIndex.java index c1b0747da40f..c34d5df16bfb 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/AIContextIndex.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/AIContextIndex.java @@ -28,7 +28,7 @@ public interface AIContextIndex extends SearchIndex { default void applyAIContextFields(Map doc) { - if (getEntity() instanceof EntityInterface entity) { + if (getEntity() instanceof EntityInterface entity) { AIContextBuilder.applySearchFields(doc, entity); } } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/ColumnIndex.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/ColumnIndex.java index ec74fa64eb00..d4f8ace3d46a 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/ColumnIndex.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/ColumnIndex.java @@ -85,7 +85,7 @@ private String addFlattenColumn( return columnName; } - default String getColumnDescriptionStatus(EntityInterface entity) { + default String getColumnDescriptionStatus(EntityInterface entity) { String status = "COMPLETE"; List> interfaces = Arrays.asList(entity.getClass().getInterfaces()); if (interfaces.contains(ColumnsEntityInterface.class) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/LineageIndex.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/LineageIndex.java index a514da9d06b8..c5cebfd96cbe 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/LineageIndex.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/LineageIndex.java @@ -27,7 +27,7 @@ default void applyLineageFields(Map doc) { */ default void applyLineageFields(Map doc, DocBuildContext ctx) { Object entity = getEntity(); - if (entity instanceof EntityInterface ei) { + if (entity instanceof EntityInterface ei) { List prefetched = ctx.prefetchedUpstreamLineage(); if (prefetched != null) { doc.put("upstreamLineage", prefetched); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/SearchIndex.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/SearchIndex.java index 48d643a71ddc..b5aee3098add 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/SearchIndex.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/SearchIndex.java @@ -94,7 +94,7 @@ default Map buildSearchIndexDoc(DocBuildContext ctx) { Map esDoc = JsonUtils.getMap(entity); // Phase 1: Common entity fields (owners, domains, displayName, etc.) - if (entity instanceof EntityInterface ei) { + if (entity instanceof EntityInterface ei) { populateCommonFields(esDoc, ei, getEntityTypeName()); } @@ -173,7 +173,7 @@ default Set getRequiredReindexFields() { * NOT call this — it is handled by the framework. */ default void populateCommonFields( - Map doc, EntityInterface entity, String entityType) { + Map doc, EntityInterface entity, String entityType) { doc.put( "displayName", entity.getDisplayName() != null && !entity.getDisplayName().isBlank() @@ -197,7 +197,7 @@ default void populateCommonFields( doc.put( "entityStatus", entity.getEntityStatus() != null - ? entity.getEntityStatus().value() + ? entity.getEntityStatus().toString() : org.openmetadata.schema.type.EntityStatus.UNPROCESSED.value()); if (entity.getVotes() != null) { int upVotes = entity.getVotes().getUpVotes() != null ? entity.getVotes().getUpVotes() : 0; @@ -271,7 +271,7 @@ default EntityReference getEntityWithDisplayName(EntityReference entity) { return cloneEntity; } - default String getDescriptionStatus(EntityInterface entity) { + default String getDescriptionStatus(EntityInterface entity) { return nullOrEmpty(entity.getDescription()) ? "INCOMPLETE" : "COMPLETE"; } @@ -301,7 +301,7 @@ static List getLineageData(EntityReference entity) { * falls back to per-entity DB lookups via {@link #getLineageData(EntityReference)}. */ static Map> prefetchLineageIfSupported( - String entityType, List entities) { + String entityType, List> entities) { Map> result = null; if (!nullOrEmpty(entities) && supportsLineagePrefetch(entityType)) { Map> prefetched = prefetchUpstreamLineage(entities); @@ -313,7 +313,7 @@ static Map> prefetchLineageIfSupported( } static Map> prefetchServiceStylesIfSupported( - String entityType, List entities) { + String entityType, List> entities) { Map> result = null; if (!nullOrEmpty(entities) && supportsServiceStylePrefetch(entityType)) { Map> prefetched = prefetchServiceStyles(entities); @@ -408,7 +408,7 @@ private static Boolean probeServiceStylePrefetchSupport(String entityType) { * so doc-build falls back to per-entity DB lookups. */ static Map> prefetchUpstreamLineage( - List entities) { + List> entities) { Map> result = new HashMap<>(); if (!nullOrEmpty(entities)) { populatePrefetchedUpstreamLineage(entities, result); @@ -417,7 +417,7 @@ static Map> prefetchUpstreamLineage( } static Map> prefetchServiceStyles( - List entities) { + List> entities) { Map> result = new HashMap<>(); if (!nullOrEmpty(entities)) { populatePrefetchedServiceStyles(entities, result); @@ -434,10 +434,10 @@ static boolean serviceReferenceSupportsStyle(EntityReference service) { } private static void populatePrefetchedServiceStyles( - List entities, Map> result) { + List> entities, Map> result) { Map serviceIdByEntityId = new HashMap<>(); Map> serviceIdsByType = new HashMap<>(); - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { UUID entityId = entity.getId(); if (entityId == null) { continue; @@ -490,13 +490,13 @@ private static Map> fetchServiceStyles( } private static void populatePrefetchedUpstreamLineage( - List entities, Map> result) { + List> entities, Map> result) { Map toRefByEntityId = new HashMap<>(entities.size()); List toIds = new ArrayList<>(entities.size()); // Seed every input id with the shared immutable empty-list sentinel. Reindex batches are // typically sparse in upstream lineage (most entities have none), so deferring the // ArrayList allocation to the first edge keeps the no-lineage path GC-free. - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { UUID entityId = entity.getId(); if (entityId == null) { continue; @@ -741,7 +741,7 @@ private static void processUpstreamConstraints( } private static Map buildUpstreamRelationshipMap( - EntityInterface entity, + EntityInterface entity, Table relatedEntity, TableConstraint tableConstraint, String referredColumn, @@ -806,7 +806,7 @@ private static Map buildUpstreamRelationshipMap( } private static Map buildUpstreamColumnMap( - EntityInterface entity, + EntityInterface entity, TableConstraint tableConstraint, String referredColumn, int columnIndex) { @@ -848,7 +848,7 @@ static Map checkUpstreamRelationship( } private static void updateExistingUpstreamRelationship( - EntityInterface entity, + EntityInterface entity, TableConstraint tableConstraint, Map existingRelationship, String referredColumn, diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/ServiceBackedIndex.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/ServiceBackedIndex.java index 1b90c12a2028..c4a58cfb12f3 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/ServiceBackedIndex.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/ServiceBackedIndex.java @@ -40,7 +40,7 @@ default void applyServiceFields(Map doc) { default void applyServiceFields(Map doc, DocBuildContext ctx) { Object entity = getEntity(); - if (entity instanceof EntityInterface ei) { + if (entity instanceof EntityInterface ei) { EntityReference service = ei.getService(); if (service != null) { // Always a Map so the field has one shape regardless of style. diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/TaggableIndex.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/TaggableIndex.java index 7639db3f7a26..e7099c861b17 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/TaggableIndex.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/TaggableIndex.java @@ -41,7 +41,7 @@ public interface TaggableIndex extends SearchIndex { */ default void applyTagFields(Map doc) { Object entity = getEntity(); - if (!(entity instanceof EntityInterface ei)) { + if (!(entity instanceof EntityInterface ei)) { return; } ParseTags parseTags = new ParseTags(Entity.getEntityTags(getEntityTypeName(), ei)); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/TestCaseIndex.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/TestCaseIndex.java index 4d24aeb4f2c9..e944a595df83 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/TestCaseIndex.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/TestCaseIndex.java @@ -129,7 +129,7 @@ private void setParentRelationships(Map doc, TestCase testCase) // Denormalize parent relationships and inherit domains/certification from the linked table. // addTestSuiteParentEntityRelations already fetches the Table with these fields, // so we reuse it to avoid an extra DB query per test case. - EntityInterface linkedTable = denormalizeTestSuiteParents(doc, testCase); + EntityInterface linkedTable = denormalizeTestSuiteParents(doc, testCase); if (nullOrEmpty(testCase.getDomains()) && linkedTable != null @@ -151,7 +151,8 @@ private void setParentRelationships(Map doc, TestCase testCase) } } - private EntityInterface denormalizeTestSuiteParents(Map doc, TestCase testCase) { + private EntityInterface denormalizeTestSuiteParents( + Map doc, TestCase testCase) { EntityReference testSuiteRef = testCase.getTestSuite(); if (testSuiteRef == null) { return null; diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchClient.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchClient.java index b4af73bc94d8..a0ee74ce983d 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchClient.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchClient.java @@ -45,6 +45,7 @@ import org.openmetadata.schema.dataInsight.DataInsightChartResult; import org.openmetadata.schema.dataInsight.custom.DataInsightCustomChart; import org.openmetadata.schema.dataInsight.custom.DataInsightCustomChartResultList; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.data.PageHierarchy; import org.openmetadata.schema.entity.data.QueryCostSearchResult; import org.openmetadata.schema.search.AggregationRequest; @@ -53,7 +54,6 @@ import org.openmetadata.schema.service.configuration.elasticsearch.ElasticSearchConfiguration; import org.openmetadata.schema.tests.DataQualityReport; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.LayerPaging; import org.openmetadata.schema.utils.ResultList; import org.openmetadata.search.IndexMapping; @@ -392,7 +392,7 @@ public SearchResultListMapper listWithOffset( String q, String queryString, SubjectContext subjectContext, - List memoryStatuses) + List memoryStatuses) throws IOException { return searchManager.listWithOffset( filter, diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchEntitiesProcessor.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchEntitiesProcessor.java index 54fcdfd4ff86..f05dcda11c6a 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchEntitiesProcessor.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchEntitiesProcessor.java @@ -23,7 +23,7 @@ @Slf4j public class OpenSearchEntitiesProcessor - implements Processor, ResultList> { + implements Processor, ResultList>> { private final StepStats stats = new StepStats(); public OpenSearchEntitiesProcessor(int total) { @@ -32,7 +32,7 @@ public OpenSearchEntitiesProcessor(int total) { @Override public List process( - ResultList input, Map contextData) + ResultList> input, Map contextData) throws SearchIndexException { String entityType = (String) contextData.get(ENTITY_TYPE_KEY); if (CommonUtil.nullOrEmpty(entityType)) { @@ -71,16 +71,16 @@ public List process( } private static List buildBulkOperations( - String entityType, List entities) { + String entityType, List> entities) { List operations = new ArrayList<>(); - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { BulkOperation operation = getUpdateOperation(entityType, entity); operations.add(operation); } return operations; } - public static BulkOperation getUpdateOperation(String entityType, EntityInterface entity) { + public static BulkOperation getUpdateOperation(String entityType, EntityInterface entity) { IndexMapping indexMapping = Entity.getSearchRepository().getIndexMapping(entityType); String indexName = indexMapping.getIndexName(Entity.getSearchRepository().getClusterAlias()); String doc = diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchEntityManager.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchEntityManager.java index fa140846787b..3177876423c1 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchEntityManager.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchEntityManager.java @@ -1543,7 +1543,7 @@ public void reindexEntities(List entities) throws IOException { List operations = new ArrayList<>(); for (EntityReference entityRef : entities) { - EntityInterface entity = Entity.getEntity(entityRef, "*", Include.ALL); + EntityInterface entity = Entity.getEntity(entityRef, "*", Include.ALL); IndexMapping indexMapping = Entity.getSearchRepository().getIndexMapping(entityRef.getType()); String indexName = indexMapping.getIndexName(Entity.getSearchRepository().getClusterAlias()); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchSearchManager.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchSearchManager.java index 82f976492d30..9d92d2b34ca7 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchSearchManager.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchSearchManager.java @@ -49,11 +49,11 @@ import org.openmetadata.schema.api.lineage.EsLineageData; import org.openmetadata.schema.api.search.AssetTypeConfiguration; import org.openmetadata.schema.api.search.SearchSettings; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.data.EntityHierarchy; import org.openmetadata.schema.entity.data.Table; import org.openmetadata.schema.settings.SettingsType; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.Include; import org.openmetadata.schema.utils.JsonUtils; import org.openmetadata.sdk.exception.SearchException; @@ -514,7 +514,7 @@ public SearchResultListMapper listWithOffset( String q, String queryString, SubjectContext subjectContext, - List statuses) + List statuses) throws IOException { if (!isClientAvailable) { throw new IOException("OpenSearch client is not available"); @@ -1157,7 +1157,7 @@ private void applyContextMemoryVisibility( private void applyContextMemoryVisibility( SubjectContext subjectContext, OpenSearchRequestBuilder requestBuilder, - List statuses) { + List statuses) { OMQueryBuilder visibilityBuilder = contextMemoryVisibility.buildVisibilityFilter(subjectContext, statuses); if (visibilityBuilder != null) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/security/ContextMemorySearchVisibility.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/security/ContextMemorySearchVisibility.java index 72ce5fab6bf6..a7e12b99780a 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/security/ContextMemorySearchVisibility.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/security/ContextMemorySearchVisibility.java @@ -18,10 +18,10 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.MemoryVisibility; import org.openmetadata.schema.entity.teams.User; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.service.Entity; import org.openmetadata.service.search.indexes.ContextMemoryIndex; import org.openmetadata.service.search.queries.OMQueryBuilder; @@ -70,7 +70,8 @@ public class ContextMemorySearchVisibility { public static final String FIELD_SHARED_WITH_IDS = "sharedWithIds"; /** Memory stages ordinary search admits; the Context Center listing may ask for others. */ - public static final List SEARCHABLE_STATUSES = List.of(EntityStatus.APPROVED); + public static final List SEARCHABLE_STATUSES = + List.of(ContextMemoryStatus.APPROVED); private final QueryBuilderFactory queryBuilderFactory; @@ -89,7 +90,7 @@ public OMQueryBuilder buildVisibilityFilter(SubjectContext subjectContext) { /** As above, admitting memories in any of {@code statuses} instead of Approved only. */ public OMQueryBuilder buildVisibilityFilter( - SubjectContext subjectContext, List statuses) { + SubjectContext subjectContext, List statuses) { OMQueryBuilder filter = null; if (isVisibilityEnforced(subjectContext)) { User user = subjectContext.user(); @@ -129,7 +130,7 @@ public static boolean isOrgWideReadable(Map document) { readable = (MemoryVisibility.ENTITY.value().equals(visibility) || MemoryVisibility.PUBLIC.value().equals(visibility)) - && EntityStatus.APPROVED + && ContextMemoryStatus.APPROVED .value() .equals(document.get(ContextMemoryIndex.FIELD_STATUS)) && ContextMemoryIndex.UNANCHORED.equals( @@ -188,7 +189,8 @@ private OMQueryBuilder scopeGovernedTypes( } /** Applies the selected status constraint and optional visibility clause only to memories. */ - private OMQueryBuilder scopeMemoriesTo(OMQueryBuilder memoryClause, List statuses) { + private OMQueryBuilder scopeMemoriesTo( + OMQueryBuilder memoryClause, List statuses) { OMQueryBuilder nonMemory = queryBuilderFactory .boolQuery() @@ -200,7 +202,7 @@ private OMQueryBuilder scopeMemoriesTo(OMQueryBuilder memoryClause, List statuses) { + OMQueryBuilder memoryClause, List statuses) { List clauses = new ArrayList<>(); if (memoryClause != null) { clauses.add(memoryClause); @@ -211,7 +213,7 @@ private OMQueryBuilder statusMemoryClause( ContextMemoryIndex.FIELD_STATUS, statuses.getFirst().value()) : queryBuilderFactory.termsQuery( ContextMemoryIndex.FIELD_STATUS, - statuses.stream().map(EntityStatus::value).toList())); + statuses.stream().map(ContextMemoryStatus::value).toList())); return queryBuilderFactory.boolQuery().must(clauses); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/ContextMemoryBodyTextContributor.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/ContextMemoryBodyTextContributor.java index 214bc2a22bb3..b3df53b6370f 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/ContextMemoryBodyTextContributor.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/ContextMemoryBodyTextContributor.java @@ -43,7 +43,7 @@ public BodyTextExtractor extractor() { return ContextMemoryBodyTextContributor::extractBodyText; } - static String extractBodyText(EntityInterface entity) { + static String extractBodyText(EntityInterface entity) { if (!(entity instanceof ContextMemory memory)) { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/ElasticSearchVectorService.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/ElasticSearchVectorService.java index f2183c0e7c4e..e9aee7ef3a0d 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/ElasticSearchVectorService.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/ElasticSearchVectorService.java @@ -281,12 +281,12 @@ private static String readEntityBody(org.apache.hc.core5.http.HttpEntity entity) } @Override - public Map generateEmbeddingFields(EntityInterface entity) { + public Map generateEmbeddingFields(EntityInterface entity) { return VectorDocBuilder.buildEmbeddingFields(entity, embeddingClient); } @Override - public void updateEntityEmbedding(EntityInterface entity, String entityIndexName) { + public void updateEntityEmbedding(EntityInterface entity, String entityIndexName) { try { String entityId = entity.getId().toString(); String existingFingerprint = getExistingFingerprint(entityIndexName, entityId); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/OpenSearchVectorService.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/OpenSearchVectorService.java index 05abc3f5ace4..342c21986b6f 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/OpenSearchVectorService.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/OpenSearchVectorService.java @@ -194,12 +194,12 @@ public Optional checkHybridSearchPipeline() { } @Override - public Map generateEmbeddingFields(EntityInterface entity) { + public Map generateEmbeddingFields(EntityInterface entity) { return VectorDocBuilder.buildEmbeddingFields(entity, embeddingClient); } @Override - public void updateEntityEmbedding(EntityInterface entity, String entityIndexName) { + public void updateEntityEmbedding(EntityInterface entity, String entityIndexName) { if (!embeddingClient.isAvailable()) { LOG.debug("Embedding provider unavailable; skipping entity {}", entity.getId()); return; @@ -244,7 +244,7 @@ public String getChunkIndexName() { } @Override - public void updateEntityEmbeddingChunks(EntityInterface entity) { + public void updateEntityEmbeddingChunks(EntityInterface entity) { requireChunkIndexForWrite(); updateEntityEmbeddingChunks(entity, getChunkIndexName()); } @@ -256,7 +256,7 @@ public void updateEntityEmbeddingChunks(EntityInterface entity) { * comes from the sink's own ReindexContext, so writers of normal (non-recreate) runs never * consult generation discovery and can never land in a crashed run's orphan. */ - public void backfillEntityChunks(EntityInterface entity, String stagedChunkTarget) { + public void backfillEntityChunks(EntityInterface entity, String stagedChunkTarget) { if (stagedChunkTarget == null) { updateEntityEmbeddingChunks(entity); } else { @@ -271,7 +271,7 @@ public void backfillEntityChunks(EntityInterface entity, String stagedChunkTarge * re-embed the whole catalog. Nothing is skipped — the staged generation starts empty, so every * entity passes through exactly once ({@code stagedHeader} short-circuits retries). */ - private void backfillChunksToStagedGeneration(EntityInterface entity, String staged) { + private void backfillChunksToStagedGeneration(EntityInterface entity, String staged) { try { String parentId = entity.getId().toString(); String fingerprint = VectorDocBuilder.computeFingerprintForEntity(entity); @@ -306,7 +306,7 @@ private void backfillChunksToStagedGeneration(EntityInterface entity, String sta * fingerprint-based staleness check. */ @Override - public void updateEntityEmbeddings(EntityInterface entity, String entityIndexName) { + public void updateEntityEmbeddings(EntityInterface entity, String entityIndexName) { if (!embeddingClient.isAvailable()) { LOG.debug("Embedding provider unavailable; skipping entity {}", entity.getId()); return; @@ -1113,7 +1113,7 @@ private ObjectNode columnsMapping() { * bulk-deleting the trailing stale ids in the same request — no delete-by-query and no forced * refresh on this hot path; visibility follows the index refresh interval. */ - public void updateEntityEmbeddingChunks(EntityInterface entity, String chunkIndexName) { + public void updateEntityEmbeddingChunks(EntityInterface entity, String chunkIndexName) { try { String parentId = entity.getId().toString(); ChunkHeader header = getChunkHeader(chunkIndexName, parentId); @@ -1143,7 +1143,7 @@ public void updateEntityEmbeddingChunks(EntityInterface entity, String chunkInde * chunk set) or the re-chunk disagrees with the cached count. */ private List> rebuildChunksReusingEmbeddings( - EntityInterface entity, String chunkIndexName, String parentId, ChunkHeader header) { + EntityInterface entity, String chunkIndexName, String parentId, ChunkHeader header) { Map vectors = fetchExistingChunkVectors(chunkIndexName, parentId, header.chunkCount()); if (vectors.size() != header.chunkCount()) { @@ -1235,7 +1235,8 @@ enum ChunkRefresh { REEMBED } - static ChunkRefresh chunkRefresh(EntityInterface entity, String fingerprint, ChunkHeader header) { + static ChunkRefresh chunkRefresh( + EntityInterface entity, String fingerprint, ChunkHeader header) { ChunkRefresh refresh = ChunkRefresh.NONE; if (header == null || !fingerprint.equals(header.fingerprint())) { refresh = ChunkRefresh.REEMBED; @@ -1247,7 +1248,7 @@ static ChunkRefresh chunkRefresh(EntityInterface entity, String fingerprint, Chu // Status and anchor gate memory visibility but are not embedded text, so the fingerprint // cannot see them change. - private static boolean memoryFilterChanged(EntityInterface entity, ChunkHeader header) { + private static boolean memoryFilterChanged(EntityInterface entity, ChunkHeader header) { return entity instanceof ContextMemory memory && (!Objects.equals(ContextMemoryIndex.statusValue(memory), header.status()) || !ContextMemoryIndex.anchorId(memory).equals(header.anchorId())); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/PageBodyTextContributor.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/PageBodyTextContributor.java index f89f431fbaca..90f815580088 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/PageBodyTextContributor.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/PageBodyTextContributor.java @@ -46,7 +46,7 @@ public BodyTextExtractor extractor() { return PageBodyTextContributor::extractBodyText; } - static String extractBodyText(EntityInterface entity) { + static String extractBodyText(EntityInterface entity) { if (!(entity instanceof Page page)) { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/QueryBodyTextContributor.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/QueryBodyTextContributor.java index a35c7636d8ae..f9b1e6f7ee6a 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/QueryBodyTextContributor.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/QueryBodyTextContributor.java @@ -51,7 +51,7 @@ public BodyTextExtractor extractor() { return QueryBodyTextContributor::extractBodyText; } - static String extractBodyText(EntityInterface entity) { + static String extractBodyText(EntityInterface entity) { if (!(entity instanceof Query query)) { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/TestCaseBodyTextContributor.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/TestCaseBodyTextContributor.java index 73baf2ed4702..aea18d6f9971 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/TestCaseBodyTextContributor.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/TestCaseBodyTextContributor.java @@ -47,7 +47,7 @@ public BodyTextExtractor extractor() { return TestCaseBodyTextContributor::extractBodyText; } - static String extractBodyText(EntityInterface entity) { + static String extractBodyText(EntityInterface entity) { if (!(entity instanceof TestCase testCase)) { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/TestSuiteBodyTextContributor.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/TestSuiteBodyTextContributor.java index eaeb9539ccc9..55be2beaf8b5 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/TestSuiteBodyTextContributor.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/TestSuiteBodyTextContributor.java @@ -43,7 +43,7 @@ public BodyTextExtractor extractor() { return TestSuiteBodyTextContributor::extractBodyText; } - static String extractBodyText(EntityInterface entity) { + static String extractBodyText(EntityInterface entity) { if (!(entity instanceof TestSuite testSuite)) { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/VectorDocBuilder.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/VectorDocBuilder.java index 3f2b506d413f..e164c03cf02c 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/VectorDocBuilder.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/VectorDocBuilder.java @@ -100,7 +100,7 @@ public interface BodyTextExtractor { * behavior. Implementations should be fast and side-effect free; they run on the hot path of * every create/update and every reembed iteration. */ - String extract(EntityInterface entity); + String extract(EntityInterface entity); } private static final Map BODY_TEXT_EXTRACTORS = @@ -116,7 +116,7 @@ public interface BodyTextExtractor { * an entry keyed by {@link Entity#DATABASE} is only consulted for {@link Database} entities. */ private record SemanticChildrenSpec( - Function> childGetter, String phrasePrefix) {} + Function, List> childGetter, String phrasePrefix) {} private static final Map SEMANTIC_CHILDREN_SPECS = Map.of( @@ -138,11 +138,12 @@ private record SemanticChildrenSpec( * shared subject/type phrase. Table-driven so new type enrichers are one map entry rather than * another {@code instanceof} branch. */ - private static final Map, EntityInterface>> SEMANTIC_ENRICHERS = - Map.of( - Entity.GLOSSARY_TERM, - (phrases, e) -> appendGlossaryTermPhrases(phrases, (GlossaryTerm) e), - Entity.METRIC, (phrases, e) -> appendMetricPhrases(phrases, (Metric) e)); + private static final Map, EntityInterface>> + SEMANTIC_ENRICHERS = + Map.of( + Entity.GLOSSARY_TERM, + (phrases, e) -> appendGlossaryTermPhrases(phrases, (GlossaryTerm) e), + Entity.METRIC, (phrases, e) -> appendMetricPhrases(phrases, (Metric) e)); /** * Register a custom {@link BodyTextExtractor} for an entity type. The registry is consulted by @@ -166,7 +167,7 @@ public static void registerBodyTextExtractor(String entityType, BodyTextExtracto * {@code _}. */ public static List> fromEntity( - EntityInterface entity, EmbeddingClient embeddingClient) { + EntityInterface entity, EmbeddingClient embeddingClient) { if (embeddingClient == null || !embeddingClient.isAvailable()) { // Signal the outage explicitly rather than returning an empty list, which callers cannot // distinguish from "entity has no chunks" and would treat as a delete of existing vectors. @@ -184,7 +185,7 @@ public static List> fromEntity( * so the service layer can fall back to a full re-embed. */ public static List> fromEntityReusingEmbeddings( - EntityInterface entity, Map reuseEmbeddings) { + EntityInterface entity, Map reuseEmbeddings) { return fromEntity( entity, (index, textToEmbed) -> { @@ -198,7 +199,7 @@ public static List> fromEntityReusingEmbeddings( } private static List> fromEntity( - EntityInterface entity, ChunkEmbeddingSource embeddingSource) { + EntityInterface entity, ChunkEmbeddingSource embeddingSource) { List> docs = buildChunkFields(entity, embeddingSource); if (entity instanceof GlossaryTerm term) { List> relatedTermDocs = buildRelatedTermRefs(term); @@ -232,7 +233,7 @@ private static List> buildRelatedTermRefs(GlossaryTerm term) } private record ChunkContext( - EntityInterface entity, + EntityInterface entity, String entityType, String parentId, String fingerprint, @@ -244,12 +245,12 @@ private record ChunkContext( /** One embedding-field map per body chunk. See {@link #fromEntity} for the doc shape. */ public static List> buildChunkFields( - EntityInterface entity, EmbeddingClient embeddingClient) { + EntityInterface entity, EmbeddingClient embeddingClient) { return buildChunkFields(entity, (index, textToEmbed) -> embeddingClient.embed(textToEmbed)); } private static List> buildChunkFields( - EntityInterface entity, ChunkEmbeddingSource embeddingSource) { + EntityInterface entity, ChunkEmbeddingSource embeddingSource) { EntityReference reference = entity.getEntityReference(); String entityType = reference == null ? null : reference.getType(); ChunkContext ctx = @@ -324,7 +325,7 @@ private static Map buildChunkDoc( * rather than describe, so the chunk header records them for the restamp check instead. */ private static Map buildDenormalizedFields( - EntityInterface entity, String entityType) { + EntityInterface entity, String entityType) { Map fields = new HashMap<>(); fields.put("entityType", entityType); fields.put("deleted", Boolean.TRUE.equals(entity.getDeleted())); @@ -464,7 +465,7 @@ private static Set fqnParts(String fqn) { * matches an owner on nested {@code owners.id}, the same field the entity indices carry; name * alone would make an owner unable to find their own restricted memory. */ - private static List> ownerNameObjects(EntityInterface entity) { + private static List> ownerNameObjects(EntityInterface entity) { List> owners = new ArrayList<>(); List ownerRefs = entity.getOwners() != null ? entity.getOwners() : Collections.emptyList(); @@ -488,7 +489,7 @@ private static List> ownerNameObjects(EntityInterface entity * have it; absence is a no-op. */ private static void addReferenceField( - Map fields, EntityInterface entity, String key, String getter) { + Map fields, EntityInterface entity, String key, String getter) { try { Method method = entity.getClass().getMethod(getter); Object result = method.invoke(entity); @@ -514,7 +515,7 @@ private static void putIfPresent(Map fields, String key, String } } - private static List> tagFqnObjects(EntityInterface entity) { + private static List> tagFqnObjects(EntityInterface entity) { List> tags = new ArrayList<>(); List tagLabels = entity.getTags() != null ? entity.getTags() : Collections.emptyList(); @@ -526,7 +527,7 @@ private static List> tagFqnObjects(EntityInterface entity) { return tags; } - private static List> domainNameObjects(EntityInterface entity) { + private static List> domainNameObjects(EntityInterface entity) { List> domains = new ArrayList<>(); List domainRefs = entity.getDomains() != null ? entity.getDomains() : Collections.emptyList(); @@ -548,7 +549,7 @@ private static List> domainNameObjects(EntityInterface entit * model. */ public static Map buildEmbeddingFields( - EntityInterface entity, EmbeddingClient embeddingClient) { + EntityInterface entity, EmbeddingClient embeddingClient) { String parentId = entity.getId().toString(); String entityType = entity.getEntityReference().getType(); @@ -582,7 +583,7 @@ public static Map buildEmbeddingFields( return fields; } - public static String computeFingerprintForEntity(EntityInterface entity) { + public static String computeFingerprintForEntity(EntityInterface entity) { String entityType = entity.getEntityReference().getType(); String metaLight = buildMetaLightText(entity, entityType); String body = buildBodyText(entity, entityType); @@ -594,7 +595,7 @@ public static String computeFingerprintForEntity(EntityInterface entity) { * Status and anchor are filter metadata; tracking them separately avoids paid re-embedding. */ @SuppressWarnings("unchecked") - private static String shareConfigPart(EntityInterface entity) { + private static String shareConfigPart(EntityInterface entity) { String part = ""; if (entity instanceof ContextMemory memory) { Map shareConfig = ContextMemoryIndex.shareConfigFields(memory); @@ -605,7 +606,7 @@ private static String shareConfigPart(EntityInterface entity) { return part; } - static String buildMetaLightText(EntityInterface entity, String entityType) { + static String buildMetaLightText(EntityInterface entity, String entityType) { boolean isGlossary = entity instanceof Glossary; boolean isGlossaryTerm = entity instanceof GlossaryTerm; boolean isMetric = entity instanceof Metric; @@ -723,7 +724,7 @@ static String buildMetaLightText(EntityInterface entity, String entityType) { return String.join("; ", parts) + " | "; } - static String buildBodyText(EntityInterface entity, String entityType) { + static String buildBodyText(EntityInterface entity, String entityType) { if (entityType != null) { BodyTextExtractor customExtractor = BODY_TEXT_EXTRACTORS.get(entityType); if (customExtractor != null) { @@ -755,14 +756,14 @@ static String buildBodyText(EntityInterface entity, String entityType) { * (FQN, entityType, serviceType, owners, customProperties, chunk marker) so the pooled vector * isn't dominated by structural tokens that appear in every document. */ - static String buildSemanticMetaLightText(EntityInterface entity, String entityType) { + static String buildSemanticMetaLightText(EntityInterface entity, String entityType) { boolean isGlossary = entity instanceof Glossary; boolean isGlossaryTerm = entity instanceof GlossaryTerm; List phrases = new ArrayList<>(); appendSubjectPhrase(phrases, entity, entityType); - BiConsumer, EntityInterface> enricher = + BiConsumer, EntityInterface> enricher = entityType == null ? null : SEMANTIC_ENRICHERS.get(entityType); if (enricher != null) { enricher.accept(phrases, entity); @@ -779,7 +780,7 @@ static String buildSemanticMetaLightText(EntityInterface entity, String entityTy } private static void appendSubjectPhrase( - List phrases, EntityInterface entity, String entityType) { + List phrases, EntityInterface entity, String entityType) { String name = entity.getName(); String displayName = entity.getDisplayName(); String subject = null; @@ -799,7 +800,7 @@ private static void appendSubjectPhrase( } private static void appendTierAndCertificationPhrases( - List phrases, EntityInterface entity) { + List phrases, EntityInterface entity) { String tier = extractTierLabel(entity); if (tier != null) { phrases.add(tier.replace('.', ' ')); @@ -849,7 +850,7 @@ private static void appendMetricPhrases(List phrases, Metric metric) { } private static void appendTagPhrases( - List phrases, EntityInterface entity, boolean isGlossary, boolean isGlossaryTerm) { + List phrases, EntityInterface entity, boolean isGlossary, boolean isGlossaryTerm) { List tagsPojo = entity.getTags() != null ? entity.getTags() : Collections.emptyList(); List classificationTagNames = tagsPojo.stream() @@ -872,7 +873,7 @@ private static void appendTagPhrases( } } - private static void appendDomainPhrase(List phrases, EntityInterface entity) { + private static void appendDomainPhrase(List phrases, EntityInterface entity) { List domainsPojo = entity.getDomains() != null ? entity.getDomains() : Collections.emptyList(); List domainNames = @@ -895,7 +896,7 @@ private static String joinSemanticParts(String metaLight, String body) { return metaLight + ". " + body; } - static String buildSemanticBodyText(EntityInterface entity, String entityType) { + static String buildSemanticBodyText(EntityInterface entity, String entityType) { if (entityType != null) { BodyTextExtractor customExtractor = BODY_TEXT_EXTRACTORS.get(entityType); if (customExtractor != null) { @@ -952,7 +953,7 @@ static String humanizeEntityType(String entityType) { * compile-time checked. Returns null when the entity is not a known container or when the * child list is empty. */ - static String buildChildContextPhrase(EntityInterface entity, String entityType) { + static String buildChildContextPhrase(EntityInterface entity, String entityType) { if (entityType == null) { return null; } @@ -986,7 +987,7 @@ private static List readChildNames(List refs) { return names; } - static String extractServiceType(EntityInterface entity) { + static String extractServiceType(EntityInterface entity) { try { Method method = entity.getClass().getMethod("getServiceType"); Object result = method.invoke(entity); @@ -996,7 +997,7 @@ static String extractServiceType(EntityInterface entity) { } } - static String extractTierLabel(EntityInterface entity) { + static String extractTierLabel(EntityInterface entity) { if (entity.getTags() == null) return null; for (TagLabel tag : entity.getTags()) { if (tag.getTagFQN() != null && tag.getTagFQN().startsWith("Tier.")) { @@ -1006,7 +1007,7 @@ static String extractTierLabel(EntityInterface entity) { return null; } - static String extractCertificationLabel(EntityInterface entity) { + static String extractCertificationLabel(EntityInterface entity) { AssetCertification cert = entity.getCertification(); if (cert != null && cert.getTagLabel() != null) { return cert.getTagLabel().getTagFQN(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/VectorEmbeddingHandler.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/VectorEmbeddingHandler.java index 02fa7c33804b..2c766068b7e7 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/VectorEmbeddingHandler.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/VectorEmbeddingHandler.java @@ -29,13 +29,15 @@ public int getPriority() { } @Override - public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { + public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { updateEmbedding(entity); } @Override public void onEntityUpdated( - EntityInterface entity, ChangeDescription changeDescription, SubjectContext subjectContext) { + EntityInterface entity, + ChangeDescription changeDescription, + SubjectContext subjectContext) { if (entity == null) { LOG.warn("Received null entity in onEntityUpdated"); return; @@ -52,7 +54,7 @@ public void onEntityUpdated( } @Override - public void onEntityDeleted(EntityInterface entity, SubjectContext subjectContext) { + public void onEntityDeleted(EntityInterface entity, SubjectContext subjectContext) { // Entity search doc is deleted by SearchIndexHandler; chunk docs live in the dedicated // chunk index and must be cleaned here or the deleted entity keeps matching KNN queries. deleteChunks(entity); @@ -60,7 +62,7 @@ public void onEntityDeleted(EntityInterface entity, SubjectContext subjectContex @Override public void onEntitySoftDeletedOrRestored( - EntityInterface entity, boolean isDeleted, SubjectContext subjectContext) { + EntityInterface entity, boolean isDeleted, SubjectContext subjectContext) { // Chunk docs carry their own deleted flag, so mirror the transition: drop chunks on soft // delete, re-embed on restore. The entity search doc itself is handled by SearchIndexHandler. if (isDeleted) { @@ -74,7 +76,7 @@ public void onEntitySoftDeletedOrRestored( * Entity-doc embedding writes are partial merges, so an entity that stops being embeddable keeps * its stale {@code embedding} — and stays kNN-matchable — unless the field is removed explicitly. */ - private void clearEntityEmbedding(EntityInterface entity) { + private void clearEntityEmbedding(EntityInterface entity) { if (entity != null && entity.getId() != null && isSupported(entity)) { try { String entityIndexName = resolveEntityIndexName(extractEntityType(entity)); @@ -87,7 +89,7 @@ private void clearEntityEmbedding(EntityInterface entity) { } } - private void deleteChunks(EntityInterface entity) { + private void deleteChunks(EntityInterface entity) { if (entity != null && entity.getId() != null && isSupported(entity)) { try { vectorService.deleteEntityChunks(entity.getId().toString()); @@ -97,12 +99,12 @@ private void deleteChunks(EntityInterface entity) { } } - private boolean isSupported(EntityInterface entity) { + private boolean isSupported(EntityInterface entity) { String entityType = extractEntityType(entity); return entityType != null && isSupportedEntityType(entityType); } - private void updateEmbedding(EntityInterface entity) { + private void updateEmbedding(EntityInterface entity) { if (entity == null) { LOG.warn("Received null entity in updateEmbedding"); return; @@ -142,7 +144,7 @@ private String resolveEntityIndexName(String entityType) { } } - private String extractEntityType(EntityInterface entity) { + private String extractEntityType(EntityInterface entity) { try { return entity.getEntityReference().getType(); } catch (Exception e) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/VectorIndexService.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/VectorIndexService.java index 00b57ab3c11c..97d3cf64e1df 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/VectorIndexService.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/VectorIndexService.java @@ -11,16 +11,16 @@ public interface VectorIndexService { String VECTOR_EMBEDDING_ALIAS = "dataAssetEmbeddings"; - Map generateEmbeddingFields(EntityInterface entity); + Map generateEmbeddingFields(EntityInterface entity); - void updateEntityEmbedding(EntityInterface entity, String entityIndexName); + void updateEntityEmbedding(EntityInterface entity, String entityIndexName); /** * Multi-chunk write path (issue #4789): index one document per body chunk into the dedicated * chunk index so long articles are fully retrievable. Default is a no-op for backends without * chunk support. */ - default void updateEntityEmbeddingChunks(EntityInterface entity) {} + default void updateEntityEmbeddingChunks(EntityInterface entity) {} /** Remove all chunk documents for the given parent entity (hard/soft delete cleanup). */ default void deleteEntityChunks(String parentId) {} @@ -38,7 +38,7 @@ default void clearEntityEmbedding(String entityIndexName, String entityId) {} * chunk documents (read by the semantic vector path). Implementations should embed each chunk * once and reuse chunk 0 for the entity doc; this default simply chains the two writes. */ - default void updateEntityEmbeddings(EntityInterface entity, String entityIndexName) { + default void updateEntityEmbeddings(EntityInterface entity, String entityIndexName) { updateEntityEmbedding(entity, entityIndexName); updateEntityEmbeddingChunks(entity); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/VectorSearchUtils.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/VectorSearchUtils.java index 47c1adde136c..05eebfea9cc6 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/VectorSearchUtils.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/vector/VectorSearchUtils.java @@ -10,13 +10,13 @@ public final class VectorSearchUtils { private VectorSearchUtils() {} - public static void updateVectorEmbeddingsForOpenSearch(EntityInterface entity) { + public static void updateVectorEmbeddingsForOpenSearch(EntityInterface entity) { String entityType = entity.getEntityReference().getType(); updateVectorEmbeddingsForOpenSearch(entity, entityType); } public static void updateVectorEmbeddingsForOpenSearch( - EntityInterface entity, String entityType) { + EntityInterface entity, String entityType) { if (!Entity.getSearchRepository().isVectorEmbeddingEnabled()) { return; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/secrets/SecretsManagerUpdateService.java b/openmetadata-service/src/main/java/org/openmetadata/service/secrets/SecretsManagerUpdateService.java index 41050f14afe5..fa71abbe393c 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/secrets/SecretsManagerUpdateService.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/secrets/SecretsManagerUpdateService.java @@ -224,7 +224,7 @@ private List retrieveServices( private Optional> retrieveServiceRepository(String entityType) { try { - EntityRepository repository = + EntityRepository> repository = Entity.getEntityRepository(entityType); if (ServiceEntityRepository.class.isAssignableFrom(repository.getClass())) { return Optional.of(((ServiceEntityRepository) repository)); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/PagePermissionsResolver.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/PagePermissionsResolver.java index fec3e1d3fd54..733b63447454 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/PagePermissionsResolver.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/PagePermissionsResolver.java @@ -34,7 +34,7 @@ public final class PagePermissionsResolver { private PagePermissionsResolver() {} - public static Map resolve( + public static > Map resolve( Authorizer authorizer, SecurityContext securityContext, String entityType, @@ -56,18 +56,22 @@ public static Map resolv return permissions; } - private static List idsOf(List page) { + private static > List idsOf(List page) { if (page == null) { return List.of(); } - return page.stream().map(EntityInterface::getId).filter(Objects::nonNull).distinct().toList(); + return page.stream() + .map(EntityInterface::getId) + .filter(Objects::nonNull) + .distinct() + .toList(); } /** * Include.ALL: a soft-deleted row still needs its policy evaluated rather than resolving to * nothing and leaving every conditional rule reading an absent attribute. */ - private static Map loadForAuthorization( + private static > Map loadForAuthorization( EntityRepository repository, List ids) { List entities = repository.get(null, ids, ResourceContext.authorizationFields(repository), Include.ALL); @@ -76,16 +80,17 @@ private static Map loadForAuthorization( } return entities.stream() .collect( - Collectors.toMap(EntityInterface::getId, entity -> entity, (first, second) -> first)); + Collectors.toMap( + EntityInterface::getId, entity -> entity, (first, second) -> first)); } - private static BulkFieldHydrator tagHydrator( + private static > BulkFieldHydrator tagHydrator( EntityRepository repository, Collection entities) { return new BulkFieldHydrator( Map.of(Entity.FIELD_TAGS, () -> repository.batchLoadTags(new ArrayList<>(entities)))); } - private static ResourceContext contextFor( + private static > ResourceContext contextFor( String entityType, EntityRepository repository, T resolved, diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/AgentExecutionContext.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/AgentExecutionContext.java index 147a547ab3e7..e481f078a5bc 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/AgentExecutionContext.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/AgentExecutionContext.java @@ -25,7 +25,7 @@ public List getTags() { } @Override - public EntityInterface getEntity() { + public EntityInterface getEntity() { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ConversationReplyResourceContext.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ConversationReplyResourceContext.java index 916a72bc31df..3868572a6293 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ConversationReplyResourceContext.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ConversationReplyResourceContext.java @@ -43,7 +43,7 @@ public List getTags() { } @Override - public EntityInterface getEntity() { + public EntityInterface getEntity() { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ConversationResourceContext.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ConversationResourceContext.java index 161ce3220b08..e9eed3190b38 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ConversationResourceContext.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ConversationResourceContext.java @@ -42,7 +42,7 @@ public List getTags() { } @Override - public EntityInterface getEntity() { + public EntityInterface getEntity() { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/CreateResourceContext.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/CreateResourceContext.java index c1ad7a20d631..c6192a15fca9 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/CreateResourceContext.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/CreateResourceContext.java @@ -30,14 +30,15 @@ *

As multiple threads don't access this, the class is not thread-safe by design. */ @Slf4j -public class CreateResourceContext implements ResourceContextInterface { +public class CreateResourceContext> + implements ResourceContextInterface { @NonNull @Getter private final String resource; private final EntityRepository entityRepository; private final T entity; // Entity being created - private List parentEntities; + private List> parentEntities; // Resolved on first use by a service condition; the flag is separate because "no service" is a // valid null result. - private EntityInterface serviceEntity; + private EntityInterface serviceEntity; private boolean serviceEntityLoaded; public CreateResourceContext(@NonNull String resource, @NotNull T entity) { @@ -53,7 +54,7 @@ public List getOwners() { return null; } List owners = new ArrayList<>(); - for (EntityInterface parent : parentEntities) { + for (EntityInterface parent : parentEntities) { if (parent.getOwners() != null) { owners = mergedInheritedEntityRefs(owners, parent.getOwners()); } @@ -67,7 +68,7 @@ public List getTags() { return Collections.emptyList(); } List tags = new ArrayList<>(); - for (EntityInterface parent : parentEntities) { + for (EntityInterface parent : parentEntities) { if (parent.getTags() != null) { tags.addAll(Entity.getEntityTags(parent.getEntityReference().getType(), parent)); } @@ -77,7 +78,7 @@ public List getTags() { } @Override - public EntityInterface getEntity() { + public EntityInterface getEntity() { return entity; } @@ -92,7 +93,7 @@ public List getDomains() { // Add inherited domains from parent entities if (!nullOrEmpty(parentEntities)) { - for (EntityInterface parent : parentEntities) { + for (EntityInterface parent : parentEntities) { if (parent.getDomains() != null) { domains = mergedInheritedEntityRefs(domains, parent.getDomains()); } @@ -118,7 +119,7 @@ public EntityReference getServiceReference() { return null; } List serviceEntityTypes = Entity.getServiceEntityTypes(); - for (EntityInterface parent : parentEntities) { + for (EntityInterface parent : parentEntities) { EntityReference parentReference = parent.getEntityReference(); if (parentReference != null && serviceEntityTypes.contains(parentReference.getType())) { return parentReference; // the parent is the service itself @@ -137,7 +138,7 @@ public EntityReference getServiceReference() { */ @Override public List getServiceTags() { - EntityInterface service = getServiceEntity(); + EntityInterface service = getServiceEntity(); if (service == null) { return Collections.emptyList(); } @@ -159,7 +160,7 @@ public String getServiceEnvironment() { * getEntityOrNull} rather than {@code getEntity} so a service deleted between the parent load and * this read does not raise from inside the authorization decision. */ - private EntityInterface getServiceEntity() { + private EntityInterface getServiceEntity() { if (!serviceEntityLoaded) { serviceEntity = Entity.getEntityOrNull(getServiceReference(), Entity.FIELD_TAGS, Include.ALL); serviceEntityLoaded = true; @@ -183,7 +184,7 @@ private void setParents(T entity) { } try { // First, check direct parent, which are always singular - EntityInterface directParent = entityRepository.getParentEntity(entity, fields.toString()); + EntityInterface directParent = entityRepository.getParentEntity(entity, fields.toString()); if (directParent != null) { parentEntities = List.of(directParent); } else { @@ -195,7 +196,7 @@ private void setParents(T entity) { } } - private List resolveRootParentEntities(T entity, Fields fields) { + private List> resolveRootParentEntities(T entity, Fields fields) { try { List rootReferences = switch (entityRepository.getEntityType()) { @@ -207,7 +208,7 @@ private List resolveRootParentEntities(T entity, Fields fields) }; if (nullOrEmpty(rootReferences)) return null; - List parentEntities = new ArrayList<>(); + List> parentEntities = new ArrayList<>(); for (EntityReference rootReference : rootReferences) { if (rootReference == null || rootReference.getId() == null) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/DomainAccessFilter.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/DomainAccessFilter.java index 28f64653eb25..7a5ba0597c70 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/DomainAccessFilter.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/DomainAccessFilter.java @@ -59,7 +59,7 @@ public static boolean isAccessible(SubjectContext subjectContext, List List retainAccessible( + public static > List retainAccessible( List entities, SubjectContext subjectContext) { List candidates = listOrEmpty(entities); return shouldApply(subjectContext) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/McpExecutionContext.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/McpExecutionContext.java index 24478dbd4572..6b0051a55eed 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/McpExecutionContext.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/McpExecutionContext.java @@ -38,7 +38,7 @@ public List getTags() { } @Override - public EntityInterface getEntity() { + public EntityInterface getEntity() { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/PermissionDebugService.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/PermissionDebugService.java index f4a06b1f0fab..3932f1c65b78 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/PermissionDebugService.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/PermissionDebugService.java @@ -320,7 +320,7 @@ public PermissionEvaluationDebugInfo debugPermissionEvaluation( debugInfo.setOperation(operation); // Get the resource if resourceIdOrFqn is provided - EntityInterface resource = null; + EntityInterface resource = null; if (resourceIdOrFqn != null) { try { EntityRepository repository = Entity.getEntityRepository(resourceType); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ReportDataContext.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ReportDataContext.java index 764dba592303..afa92d5de708 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ReportDataContext.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ReportDataContext.java @@ -25,7 +25,7 @@ public List getTags() { } @Override - public EntityInterface getEntity() { + public EntityInterface getEntity() { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ResourceContext.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ResourceContext.java index 7ecfd425e28b..8517843cb868 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ResourceContext.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ResourceContext.java @@ -33,7 +33,7 @@ *

As multiple threads don't access this, the class is not thread-safe by design. */ @Slf4j -public class ResourceContext implements ResourceContextInterface { +public class ResourceContext> implements ResourceContextInterface { @NonNull @Getter private final String resource; private final EntityRepository entityRepository; private final UUID id; @@ -49,7 +49,7 @@ public class ResourceContext implements ResourceConte private BulkFieldHydrator bulkFieldHydrator; // Service attributes are read only when a condition asks for them, then memoized for this // context. The loaded flags are needed separately because "no service" is a valid null result. - private EntityInterface serviceEntity; + private EntityInterface serviceEntity; private boolean serviceEntityLoaded; private List serviceTags; private boolean serviceTagsLoaded; @@ -150,9 +150,9 @@ public List getOwners() { // Check for parents owners' List owners = nullOrEmpty(entity.getOwners()) ? null : new ArrayList<>(entity.getOwners()); - List parentEntities = resolveParentEntities(entity); + List> parentEntities = resolveParentEntities(entity); if (!nullOrEmpty(parentEntities)) { - for (EntityInterface parentEntity : parentEntities) { + for (EntityInterface parentEntity : parentEntities) { if (parentEntity.getOwners() != null) { if (owners == null) owners = new ArrayList<>(); owners.addAll(parentEntity.getOwners()); @@ -163,7 +163,7 @@ public List getOwners() { return owners; } - private List resolveParentEntities(T entity) { + private List> resolveParentEntities(T entity) { Fields fields = new Fields(new HashSet<>(Collections.singleton(FIELD_OWNERS))); try { List parentReferences = @@ -175,7 +175,7 @@ private List resolveParentEntities(T entity) { }; if (nullOrEmpty(parentReferences)) return null; - List parentEntities = new ArrayList<>(); + List> parentEntities = new ArrayList<>(); for (EntityReference parentReference : parentReferences) { if (parentReference == null || parentReference.getId() == null) { @@ -315,7 +315,7 @@ public String getServiceEnvironment() { * Carries the service's {@code tags}; every other service field is stored inline, so callers * needing {@code serviceType} or {@code name} can read them off the same instance. */ - private EntityInterface getServiceEntity() { + private EntityInterface getServiceEntity() { if (!serviceEntityLoaded) { serviceEntity = loadServiceEntity(); serviceEntityLoaded = true; @@ -329,7 +329,7 @@ private List loadServiceTags() { // on-demand tag load, so resolving a separate service entity would be a redundant read. return getTags(); } - EntityInterface service = getServiceEntity(); + EntityInterface service = getServiceEntity(); if (service == null) { return Collections.emptyList(); } @@ -341,7 +341,7 @@ private List loadServiceTags() { * otherwise raise {@link EntityNotFoundException} from inside the authorization decision and * surface as a 500 on a read that should simply not match the condition. */ - private EntityInterface loadServiceEntity() { + private EntityInterface loadServiceEntity() { if (isServiceResource()) { resolveEntity(); return entity; @@ -362,7 +362,7 @@ private boolean isServiceResource() { } @Override - public EntityInterface getResolvedEntity() { + public EntityInterface getResolvedEntity() { return entity; } @@ -372,7 +372,7 @@ public Set getLoadedFields() { } @Override - public EntityInterface getEntity() { + public EntityInterface getEntity() { return resolveEntity(); } @@ -387,7 +387,7 @@ public List getDomains() { return entity.getDomains(); } - private EntityInterface resolveEntity() { + private EntityInterface resolveEntity() { if (entity == null) { Fields fieldList; RelationIncludes relationIncludesToUse = relationIncludes; diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ResourceContextInterface.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ResourceContextInterface.java index 94f63f1bb188..f16e4b61781c 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ResourceContextInterface.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ResourceContextInterface.java @@ -24,14 +24,14 @@ enum Operation { // return null List getTags(); - EntityInterface getEntity(); + EntityInterface getEntity(); /** * The entity already resolved while evaluating policy, or null if evaluation never needed it. * Unlike {@link #getEntity()} this never triggers a load, so callers can reuse what the decision * fetched without forcing work on requests that were authorized without inspecting the resource. */ - default EntityInterface getResolvedEntity() { + default EntityInterface getResolvedEntity() { return null; } @@ -55,7 +55,7 @@ default Set getLoadedFields() { * always null. */ default EntityReference getServiceReference() { - EntityInterface entity = getEntity(); + EntityInterface entity = getEntity(); return entity == null ? null : entity.getService(); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/RuleEvaluator.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/RuleEvaluator.java index e9e3f2a182d9..432d59ff7875 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/RuleEvaluator.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/RuleEvaluator.java @@ -148,7 +148,7 @@ public boolean isTaskReviewer() { private Task currentTask() { Task task = null; if (!expressionValidation && subjectContext != null && resourceContext != null) { - EntityInterface entity = resourceContext.getEntity(); + EntityInterface entity = resourceContext.getEntity(); if (entity instanceof Task t) { task = t; } @@ -467,7 +467,7 @@ public boolean matchAnyCertification(String... tagFQNs) { return false; } - EntityInterface entity = resourceContext.getEntity(); + EntityInterface entity = resourceContext.getEntity(); if (entity == null) { return false; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ServiceAttributeCache.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ServiceAttributeCache.java index 2d60885fc5fc..26119d93bf2a 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ServiceAttributeCache.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ServiceAttributeCache.java @@ -89,7 +89,7 @@ static ServiceAttributes resolve(EntityReference serviceReference) { * authorization decision; it simply stops matching the condition. */ private static ServiceAttributes load(EntityReference serviceReference) { - EntityInterface service = + EntityInterface service = Entity.getEntityOrNull(serviceReference, Entity.FIELD_TAGS, Include.ALL); if (service == null) { return NONE; diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ServiceAttributeResolver.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ServiceAttributeResolver.java index 2cbe915c8629..b58d413e1e42 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ServiceAttributeResolver.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ServiceAttributeResolver.java @@ -279,11 +279,11 @@ private static void indexServices( Map> serviceIdsByName, Map> serviceIdsByEnvironment, Map> serviceIdsByType) { - EntityRepository repository = + EntityRepository> repository = Entity.getEntityRepository(serviceEntityType); - List services = + List> services = repository.listAll(repository.getFields(Entity.FIELD_TAGS), new ListFilter(Include.ALL)); - for (EntityInterface service : services) { + for (EntityInterface service : services) { String serviceId = service.getId().toString(); serviceIdsByName.computeIfAbsent(service.getName(), name -> new HashSet<>()).add(serviceId); for (TagLabel tag : Entity.getEntityTags(serviceEntityType, service)) { @@ -297,7 +297,7 @@ private static void indexServices( } private static void indexServiceType( - EntityInterface service, String serviceId, Map> serviceIdsByType) { + EntityInterface service, String serviceId, Map> serviceIdsByType) { String serviceType = ServiceAttributeUtil.serviceTypeOf(service); if (serviceType == null) { return; @@ -312,7 +312,9 @@ private static void indexServiceType( * so it arrives with the listing and needs no extra field projection. */ private static void indexEnvironment( - EntityInterface service, String serviceId, Map> serviceIdsByEnvironment) { + EntityInterface service, + String serviceId, + Map> serviceIdsByEnvironment) { if (!(service instanceof ServiceEntityInterface typedService)) { return; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ServiceAttributeUtil.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ServiceAttributeUtil.java index 655e1e1d8a2e..921d9208bc97 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ServiceAttributeUtil.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/ServiceAttributeUtil.java @@ -35,7 +35,7 @@ final class ServiceAttributeUtil { private ServiceAttributeUtil() {} /** Connector type ({@code Snowflake}, {@code Postgres}), or null if unknown. */ - static String serviceTypeOf(EntityInterface service) { + static String serviceTypeOf(EntityInterface service) { if (service instanceof ServiceEntityInterface typedService && typedService.getServiceType() != null) { return typedService.getServiceType().value(); @@ -44,7 +44,7 @@ static String serviceTypeOf(EntityInterface service) { } /** Declared environment, or null when unset — the attributes block is optional. */ - static String environmentOf(EntityInterface service) { + static String environmentOf(EntityInterface service) { if (!(service instanceof ServiceEntityInterface typedService)) { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/TaskResourceContext.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/TaskResourceContext.java index 1a29ba3ccaaa..f4bb83b807aa 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/TaskResourceContext.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/TaskResourceContext.java @@ -69,7 +69,7 @@ public List getTags() { } @Override - public EntityInterface getEntity() { + public EntityInterface getEntity() { return task; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/TestCaseResourceContext.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/TestCaseResourceContext.java index 3b363dd531ce..7ea3345fd688 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/TestCaseResourceContext.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/TestCaseResourceContext.java @@ -42,7 +42,7 @@ public class TestCaseResourceContext implements ResourceContextInterface { private final String entityType; private final UUID id; private final String name; - private EntityInterface + private EntityInterface entity; // Will be lazily initialized to the entity that has this test case @Override @@ -63,7 +63,7 @@ public List getTags() { } @Override - public EntityInterface getEntity() { + public EntityInterface getEntity() { return resolveEntity(); } @@ -73,7 +73,7 @@ public List getDomains() { return entity == null ? null : entity.getDomains(); } - private EntityInterface resolveEntity() { + private EntityInterface resolveEntity() { if (entity == null) { if (entityLink != null) { entity = resolveEntityByEntityLink(entityLink); @@ -90,13 +90,13 @@ private EntityInterface resolveEntity() { return entity; } - private static EntityInterface resolveTestSuiteById(UUID id) { + private static EntityInterface resolveTestSuiteById(UUID id) { TestSuiteRepository dao = (TestSuiteRepository) Entity.getEntityRepository(Entity.TEST_SUITE); return dao.get(null, id, dao.getFields("owners,tags,domains"), Include.ALL, true); } - private static EntityInterface resolveEntityByEntityLink(EntityLink entityLink) { - EntityRepository entityRepository = + private static EntityInterface resolveEntityByEntityLink(EntityLink entityLink) { + EntityRepository> entityRepository = Entity.getEntityRepository(entityLink.getEntityType()); String fields = ""; if (entityRepository.isSupportsOwners()) { @@ -112,21 +112,21 @@ private static EntityInterface resolveEntityByEntityLink(EntityLink entityLink) null, entityLink.getEntityFQN(), entityRepository.getFields(fields)); } - private static EntityInterface resolveEntityById(UUID id) { + private static EntityInterface resolveEntityById(UUID id) { TestCaseRepository dao = (TestCaseRepository) Entity.getEntityRepository(Entity.TEST_CASE); TestCase testCase = dao.get(null, id, dao.getFields("entityLink"), Include.ALL, true); return resolveEntityByEntityLink(EntityLink.parse(testCase.getEntityLink())); } - private static EntityInterface resolveEntityByName(String fqn) { + private static EntityInterface resolveEntityByName(String fqn) { if (fqn == null) return null; TestCaseRepository dao = (TestCaseRepository) Entity.getEntityRepository(Entity.TEST_CASE); TestCase testCase = dao.getByName(null, fqn, dao.getFields("entityLink"), Include.ALL, true); return resolveEntityByEntityLink(EntityLink.parse(testCase.getEntityLink())); } - private static EntityInterface resolveEntityFQN(String entityFQN, String entityType) { - EntityRepository dao = Entity.getEntityRepository(entityType); + private static EntityInterface resolveEntityFQN(String entityFQN, String entityType) { + EntityRepository> dao = Entity.getEntityRepository(entityType); return dao.getByName(null, entityFQN, dao.getFields("owners,tags,domains")); } } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/tasks/SuggestionHandler.java b/openmetadata-service/src/main/java/org/openmetadata/service/tasks/SuggestionHandler.java index 6cd3eb9bf855..90d67b825ba1 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/tasks/SuggestionHandler.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/tasks/SuggestionHandler.java @@ -77,7 +77,7 @@ public void applySuggestion(Task suggestionTask, String resolvedBy) { } EntityRepository repository = Entity.getEntityRepository(about.getType()); - EntityInterface entity = repository.get(null, about.getId(), repository.getFields("*")); + EntityInterface entity = repository.get(null, about.getId(), repository.getFields("*")); String origJson = JsonUtils.pojoToJson(entity); JsonPatch patch = generatePatch(entity, suggestionPayload); @@ -136,7 +136,7 @@ private String getSuggestedValue(Task task) { /** * Generate JSON Patch based on suggestion type and field path. */ - private JsonPatch generatePatch(EntityInterface entity, SuggestionPayload payload) { + private JsonPatch generatePatch(EntityInterface entity, SuggestionPayload payload) { String fieldPath = payload.getFieldPath(); SuggestionPayload.SuggestionType suggestionType = payload.getSuggestionType(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/tasks/TaskWorkflowHandler.java b/openmetadata-service/src/main/java/org/openmetadata/service/tasks/TaskWorkflowHandler.java index 0fbe633293b0..3d748409f375 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/tasks/TaskWorkflowHandler.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/tasks/TaskWorkflowHandler.java @@ -574,7 +574,7 @@ private void applyEntityChanges( } try { - EntityInterface entity = Entity.getEntity(aboutRef, "*", Include.ALL); + EntityInterface entity = Entity.getEntity(aboutRef, "*", Include.ALL); EntityRepository repository = Entity.getEntityRepository(aboutRef.getType()); List actions = @@ -599,7 +599,7 @@ private void applyEntityChanges( private void executeConfiguredActions( List actions, Task task, - EntityInterface entity, + EntityInterface entity, EntityRepository repository, String user, Object payload, @@ -624,7 +624,7 @@ private void executeConfiguredActions( private void applyDescriptionAction( Task task, - EntityInterface entity, + EntityInterface entity, EntityRepository repository, String user, String newValue, @@ -682,7 +682,7 @@ private void applyDescriptionAction( private void applyMergeTagsAction( Task task, - EntityInterface entity, + EntityInterface entity, EntityRepository repository, String user, String newValue, @@ -742,7 +742,7 @@ private boolean isEntityLevelTagPath(String fieldPath) { } private void patchEntityTags( - EntityInterface entity, + EntityInterface entity, EntityRepository repository, String user, List tagsToAdd, @@ -751,7 +751,7 @@ private void patchEntityTags( } private void patchEntityTags( - EntityInterface entity, + EntityInterface entity, EntityRepository repository, String user, List updatedTags) { @@ -766,7 +766,7 @@ private void patchEntityTags( @SuppressWarnings("unchecked") private boolean patchFieldTags( - EntityInterface entity, + EntityInterface entity, EntityRepository repository, String user, String fieldPath, @@ -813,7 +813,7 @@ private void recordChangeEvent(PatchResponse response, String user) { return; } Object patchedEntity = response.entity(); - if (!(patchedEntity instanceof EntityInterface entityInterface)) { + if (!(patchedEntity instanceof EntityInterface entityInterface)) { return; } try { @@ -851,7 +851,7 @@ private List mergeTags( return merged; } - private String resolveTagTargetFqn(EntityInterface entity, String fieldPath) { + private String resolveTagTargetFqn(EntityInterface entity, String fieldPath) { if (fieldPath == null || fieldPath.isEmpty() || "tags".equals(fieldPath)) { return entity.getFullyQualifiedName(); } @@ -944,7 +944,7 @@ private List readTagLabels( private void applyReplaceOwnersAction( Task task, - EntityInterface entity, + EntityInterface entity, EntityRepository repository, String user, Object payload, @@ -981,7 +981,7 @@ private void applyReplaceOwnersAction( private void applyApplyTierAction( Task task, - EntityInterface entity, + EntityInterface entity, EntityRepository repository, String user, Object payload, @@ -1012,7 +1012,7 @@ private void applyApplyTierAction( private void applyReplaceDomainsAction( Task task, - EntityInterface entity, + EntityInterface entity, EntityRepository repository, String user, Object payload, @@ -1048,7 +1048,11 @@ private void applyReplaceDomainsAction( } private void applyPatchEntityFieldAction( - Task task, EntityInterface entity, String user, Object payload, TaskExecutionAction action) { + Task task, + EntityInterface entity, + String user, + Object payload, + TaskExecutionAction action) { if (action.entityField() == null) { LOG.warn( "[TaskWorkflowHandler] Missing entity field binding for patchEntityField action on task '{}'", @@ -1099,7 +1103,7 @@ private boolean isAgentAuthored(Task task, JsonNode payloadNode, String appliedV private void applySuggestion( Task task, Object payload, - EntityInterface entity, + EntityInterface entity, EntityRepository repository, String user) { if (payload == null) return; @@ -1169,7 +1173,7 @@ private void applySuggestion( } private void applyEntityLevelTags( - EntityInterface entity, EntityRepository repository, String user, List tags) { + EntityInterface entity, EntityRepository repository, String user, List tags) { String originalJson = JsonUtils.pojoToJson(entity); List mergedTags = org.openmetadata.service.resources.tags.TagLabelUtil.mergeTagsWithIncomingPrecedence( diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/util/ChildFieldResolver.java b/openmetadata-service/src/main/java/org/openmetadata/service/util/ChildFieldResolver.java index 51e609803d8c..1adfb0469aa9 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/util/ChildFieldResolver.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/util/ChildFieldResolver.java @@ -184,7 +184,7 @@ public static ChildContainerSpec specFor(String entityType) { } @SuppressWarnings("unchecked") - public static List childrenOf(EntityInterface parent, String entityType) { + public static List childrenOf(EntityInterface parent, String entityType) { ChildContainerSpec spec = specFor(entityType); List children = new ArrayList<>(); for (String path : spec.containerPaths()) { @@ -197,11 +197,11 @@ public static List childrenOf(EntityInterface parent, String ent } public static Optional locate( - EntityInterface parent, String entityType, String childFqn) { + EntityInterface parent, String entityType, String childFqn) { return findByFqn(childrenOf(parent, entityType), childFqn); } - public static void ensureChildFqns(EntityInterface parent, String entityType) { + public static void ensureChildFqns(EntityInterface parent, String entityType) { assignFqns(parent.getFullyQualifiedName(), childrenOf(parent, entityType)); } @@ -210,7 +210,7 @@ public static void ensureChildFqns(EntityInterface parent, String entityType) { * Returns null when the entity's type is not registered or the segment does not name one of its * declared container paths, which lets callers fall back to their own resolution. */ - public static List containerListFor(EntityInterface entity, String containerName) { + public static List containerListFor(EntityInterface entity, String containerName) { String entityType = registryTypeOf(entity); List result = null; if (supports(entityType)) { @@ -234,13 +234,13 @@ public static List containerListFor(EntityInterface entity, String containerN * registration). The registry's own keys already are the canonical entity-type names, so deriving * the lookup from them keeps this resolvable everywhere and independent of registration order. */ - private static String registryTypeOf(EntityInterface entity) { + private static String registryTypeOf(EntityInterface entity) { return TYPE_BY_SIMPLE_CLASS_NAME.get( entity.getClass().getSimpleName().toLowerCase(Locale.ROOT)); } private static List listForDeclaredPath( - EntityInterface entity, ChildContainerSpec spec, String containerName) { + EntityInterface entity, ChildContainerSpec spec, String containerName) { List result = null; for (String path : spec.containerPaths()) { boolean matches = path.equals(containerName) || path.startsWith(containerName + "."); @@ -301,11 +301,12 @@ private static String fixedDepthParent(String childFqn, int depth) { } private static String longestPrefixParent(String childFqn, String entityType) { - EntityRepository repository = Entity.getEntityRepository(entityType); + EntityRepository> repository = + Entity.getEntityRepository(entityType); String[] parts = FullyQualifiedName.split(childFqn); String result = null; for (int end = parts.length - 1; end >= MIN_PARENT_PARTS && result == null; end--) { - EntityInterface parent = + EntityInterface parent = repository.findByNameOrNull( FullyQualifiedName.build(Arrays.copyOf(parts, end)), Include.ALL); result = parent == null ? null : parent.getFullyQualifiedName(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/util/EntityETag.java b/openmetadata-service/src/main/java/org/openmetadata/service/util/EntityETag.java index ecaccb67c058..41ed1744f36f 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/util/EntityETag.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/util/EntityETag.java @@ -54,7 +54,7 @@ public class EntityETag { * @param entity The entity to generate ETag for * @return quoted strong ETag, or {@code null} if entity is null */ - public static String generateETag(EntityInterface entity) { + public static String generateETag(EntityInterface entity) { String etag = null; if (entity != null) { etag = ETAG_PREFIX + generateHash(fingerprint(entity)) + ETAG_SUFFIX; @@ -74,7 +74,7 @@ public static String generateETag(EntityInterface entity) { * never a stale or incorrect body. OpenMetadata map fields (e.g. {@code extension}) deserialize * into order-preserving structures, so this stays stable in practice. */ - private static String fingerprint(EntityInterface entity) { + private static String fingerprint(EntityInterface entity) { String result; try { result = JsonUtils.pojoToJson(entity); @@ -100,7 +100,7 @@ private static String fingerprint(EntityInterface entity) { * @param entity The entity to generate weak ETag for * @return Weak ETag string in format W/"version" */ - public static String generateWeakETag(EntityInterface entity) { + public static String generateWeakETag(EntityInterface entity) { if (entity == null) { return null; } @@ -127,7 +127,7 @@ public static String generateWeakETag(EntityInterface entity) { * @throws PreconditionFailedException if ETags don't match and enforcement is enabled */ public static void validateETag( - String ifMatchHeader, EntityInterface entity, boolean enforceETag) { + String ifMatchHeader, EntityInterface entity, boolean enforceETag) { LOG.debug( "validateETag called - ifMatchHeader: {}, enforceETag: {}, entity: {}", ifMatchHeader, @@ -181,7 +181,7 @@ public static void validateETag( * @return The response builder with ETag header added */ public static Response.ResponseBuilder addETagHeader( - Response.ResponseBuilder responseBuilder, EntityInterface entity) { + Response.ResponseBuilder responseBuilder, EntityInterface entity) { String etag = generateETag(entity); if (etag != null) { responseBuilder.header(ETAG_HEADER, etag); @@ -196,7 +196,7 @@ public static Response.ResponseBuilder addETagHeader( * @param entity The entity to match against * @return true if weak match, false otherwise */ - private static boolean isWeakMatch(String providedETag, EntityInterface entity) { + private static boolean isWeakMatch(String providedETag, EntityInterface entity) { if (providedETag.startsWith(WEAK_PREFIX)) { String weakETag = generateWeakETag(entity); return weakETag.equals(providedETag); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/util/EntityFieldUtils.java b/openmetadata-service/src/main/java/org/openmetadata/service/util/EntityFieldUtils.java index e8e1a553ddb6..3424e2371ef2 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/util/EntityFieldUtils.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/util/EntityFieldUtils.java @@ -16,6 +16,7 @@ import jakarta.json.JsonPatch; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.UUID; import lombok.extern.slf4j.Slf4j; @@ -33,6 +34,7 @@ import org.openmetadata.schema.type.TagLabel; import org.openmetadata.schema.utils.JsonUtils; import org.openmetadata.service.Entity; +import org.openmetadata.service.governance.EntityStatusAdapter; import org.openmetadata.service.jdbi3.EntityRepository; import org.openmetadata.service.resources.tags.TagLabelUtil; @@ -51,7 +53,7 @@ public class EntityFieldUtils { * @param applyPatch Whether to apply the patch immediately (true for workflows, false for manual patching) */ public static void setEntityField( - EntityInterface entity, + EntityInterface entity, String entityType, String user, String fieldName, @@ -61,7 +63,7 @@ public static void setEntityField( } public static void setEntityField( - EntityInterface entity, + EntityInterface entity, String entityType, String user, String fieldName, @@ -130,7 +132,7 @@ public static void setEntityField( } public static void setSimpleStringField( - EntityInterface entity, String fieldName, String fieldValue) { + EntityInterface entity, String fieldName, String fieldValue) { try { // Try setter method first String setterName = "set" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1); @@ -159,7 +161,7 @@ public static void setSimpleStringField( * Appends tags to the entity by fetching actual Tag entities. * If new tags are mutually exclusive with existing tags, replaces the conflicting tags. */ - public static void appendTags(EntityInterface entity, String tagFQNs) { + public static void appendTags(EntityInterface entity, String tagFQNs) { if (tagFQNs == null || tagFQNs.isEmpty()) { return; } @@ -250,7 +252,7 @@ public static void appendTags(EntityInterface entity, String tagFQNs) { * Appends glossary terms to the entity by fetching actual GlossaryTerm entities. * If new glossary terms are mutually exclusive with existing tags/terms, replaces the conflicting ones. */ - public static void appendGlossaryTerms(EntityInterface entity, String termFQNs) { + public static void appendGlossaryTerms(EntityInterface entity, String termFQNs) { if (termFQNs == null || termFQNs.isEmpty()) { return; } @@ -334,7 +336,7 @@ public static void appendGlossaryTerms(EntityInterface entity, String termFQNs) /** * Sets certification on the entity (replaces existing). */ - public static void setCertification(EntityInterface entity, String certificationFQN) { + public static void setCertification(EntityInterface entity, String certificationFQN) { if (certificationFQN == null || certificationFQN.isEmpty()) { entity.setCertification(null); return; @@ -360,7 +362,7 @@ public static void setCertification(EntityInterface entity, String certification /** * Sets tier on the entity by managing Tier.* tags (replaces existing tier). */ - public static void setTier(EntityInterface entity, String tierFQN) { + public static void setTier(EntityInterface entity, String tierFQN) { if (tierFQN == null || tierFQN.isEmpty()) { return; } @@ -391,7 +393,7 @@ public static void setTier(EntityInterface entity, String tierFQN) { * Sets owners on the entity by fetching User/Team entities. * Format: "user:userName" or "team:teamName" */ - public static void setOwners(EntityInterface entity, String ownerNames) { + public static void setOwners(EntityInterface entity, String ownerNames) { if (ownerNames == null || ownerNames.isEmpty()) { entity.setOwners(null); return; @@ -442,7 +444,7 @@ public static void setOwners(EntityInterface entity, String ownerNames) { * Sets reviewers on the entity by fetching User entities. * Format: "user:userName" or "team:teamName" */ - public static void setReviewers(EntityInterface entity, String reviewerNames) { + public static void setReviewers(EntityInterface entity, String reviewerNames) { if (reviewerNames == null || reviewerNames.isEmpty()) { entity.setReviewers(null); return; @@ -512,47 +514,27 @@ public static EntityStatus parseEntityStatus(String value) { * Sets the status field on various entity types using appropriate enum values. * Handles both legacy 'status' field and new 'entityStatus' field. */ - public static void setEntityStatus(EntityInterface entity, String statusValue) { + public static void setEntityStatus(EntityInterface entity, String statusValue) { + EntityStatusAdapter adapter; try { - try { - EntityStatus status = parseEntityStatus(statusValue); - entity.setEntityStatus(status); - LOG.debug( - "Successfully set entityStatus to '{}' on entity type: {}", - statusValue, - entity.getClass().getSimpleName()); - return; - } catch (IllegalArgumentException e) { - // Not a valid EntityStatus enum value - LOG.warn( - "Invalid EntityStatus value '{}' for entity type: {}", - statusValue, - entity.getClass().getSimpleName()); - } catch (UnsupportedOperationException e) { - // Entity doesn't support entityStatus - LOG.debug( - "Entity type {} doesn't support entityStatus field, trying legacy status field", - entity.getClass().getSimpleName()); - } - try { - setSimpleStringField(entity, "status", statusValue); - LOG.debug( - "Successfully set legacy status field to '{}' on entity type: {}", - statusValue, - entity.getClass().getSimpleName()); - } catch (Exception e) { - LOG.debug( - "Entity type {} doesn't have a legacy status field either", - entity.getClass().getSimpleName()); - } + adapter = EntityStatusAdapter.forEntityType(entity.getClass()); + } catch (IllegalArgumentException exception) { + setLegacyStatus(entity, statusValue, exception); + return; + } + try { + adapter.write(entity, statusValue); + } catch (UnsupportedOperationException exception) { + setLegacyStatus(entity, statusValue, exception); + } + } - } catch (Exception e) { - LOG.error( - "Failed to set status field to '{}' on entity type: {}", - statusValue, - entity.getClass().getSimpleName(), - e); - throw new RuntimeException("Failed to set status field", e); + private static void setLegacyStatus( + EntityInterface entity, String statusValue, RuntimeException exception) { + if (Arrays.stream(entity.getClass().getMethods()) + .noneMatch(method -> method.getName().equals("getStatus"))) { + throw exception; } + setSimpleStringField(entity, "status", statusValue); } } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/util/EntityUtil.java b/openmetadata-service/src/main/java/org/openmetadata/service/util/EntityUtil.java index f7e286f8d635..cde57c9ddb0b 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/util/EntityUtil.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/util/EntityUtil.java @@ -457,7 +457,7 @@ public static List getJsonDataResources(String path) throws IOException return CommonUtil.getResources(Pattern.compile(path)); } - public static List toFQNs(List entities) { + public static > List toFQNs(List entities) { if (entities == null) { return Collections.emptyList(); } @@ -877,7 +877,7 @@ public static String getFqn(EntityReference ref) { return ref == null ? null : ref.getFullyQualifiedName(); } - public static String getFqn(EntityInterface entity) { + public static String getFqn(EntityInterface entity) { return entity == null ? null : entity.getFullyQualifiedName(); } @@ -892,7 +892,7 @@ public static List getFqns(List refs) { return fqns; } - public static EntityReference getEntityReference(EntityInterface entity) { + public static EntityReference getEntityReference(EntityInterface entity) { return entity == null ? null : entity.getEntityReference(); } @@ -937,9 +937,9 @@ public static Column getColumn(Table table, String columnName) { .orElse(null); } - public static void sortByFQN(List entities) { + public static void sortByFQN(List> entities) { // Sort entities by fullyQualifiedName - entities.sort(Comparator.comparing(EntityInterface::getFullyQualifiedName)); + entities.sort(Comparator.comparing(EntityInterface::getFullyQualifiedName)); } /** @@ -1217,7 +1217,7 @@ public static String encodeEntityFqnSafe(String fqn) { * This method checks if the entity supports the given field and returns its value. * If the field is not supported, returns null. */ - public static Object getEntityField(EntityInterface entity, String fieldName) { + public static Object getEntityField(EntityInterface entity, String fieldName) { if (entity == null || fieldName == null || fieldName.isEmpty()) { return null; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/util/EntityWithType.java b/openmetadata-service/src/main/java/org/openmetadata/service/util/EntityWithType.java index 2972649250a7..f1b0a449c1b8 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/util/EntityWithType.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/util/EntityWithType.java @@ -27,16 +27,16 @@ */ @NoArgsConstructor public class EntityWithType { - @Getter @Setter @JsonUnwrapped private EntityInterface entity; + @Getter @Setter @JsonUnwrapped private EntityInterface entity; @Getter @Setter private String entityType; - public EntityWithType(EntityInterface entity, String entityType) { + public EntityWithType(EntityInterface entity, String entityType) { this.entity = entity; this.entityType = entityType; } - public static EntityWithType from(EntityInterface entity) { + public static EntityWithType from(EntityInterface entity) { return new EntityWithType(entity, entity.getEntityReference().getType()); } } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/util/FieldPathUtils.java b/openmetadata-service/src/main/java/org/openmetadata/service/util/FieldPathUtils.java index 207410da6bb3..070be365e74f 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/util/FieldPathUtils.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/util/FieldPathUtils.java @@ -53,7 +53,7 @@ private FieldPathUtils() {} * @return true if update was successful */ public static boolean updateFieldDescription( - EntityInterface entity, + EntityInterface entity, EntityRepository repository, String user, String fieldPath, @@ -70,7 +70,7 @@ public static boolean updateFieldDescription( * @param changeSource provenance of the new text, or null to leave it defaulted */ public static boolean updateFieldDescription( - EntityInterface entity, + EntityInterface entity, EntityRepository repository, String user, String fieldPath, @@ -108,7 +108,7 @@ public static boolean updateFieldDescription( * Returns empty when the path cannot be resolved. Callers can then read/mutate the POJO via * its own getters/setters and generate a JSON patch against the parent entity. */ - public static Optional findField(EntityInterface entity, String fieldPath) { + public static Optional findField(EntityInterface entity, String fieldPath) { FieldPathComponents components = parseFieldPath(fieldPath); if (components == null) { return Optional.empty(); @@ -123,7 +123,7 @@ public static Optional findField(EntityInterface entity, String fieldPat * @param fieldPath The field path (e.g., "columns::customer_id::description") * @return the current description if the field path could be resolved */ - public static Optional getFieldDescription(EntityInterface entity, String fieldPath) { + public static Optional getFieldDescription(EntityInterface entity, String fieldPath) { if (fieldPath == null || fieldPath.isEmpty() || fieldPath.equals("description") @@ -145,7 +145,7 @@ public static Optional getFieldDescription(EntityInterface entity, Strin * Modifies the entity in memory. */ private static boolean setFieldDescription( - EntityInterface entity, String fieldPath, String description) { + EntityInterface entity, String fieldPath, String description) { // Handle entity-level description if (fieldPath == null @@ -243,7 +243,7 @@ public static FieldPathComponents parseFieldPath(String fieldPath) { /** Navigate entity structure and set description on target field. */ private static boolean navigateAndSetDescription( - EntityInterface entity, FieldPathComponents components, String description) { + EntityInterface entity, FieldPathComponents components, String description) { List fieldList = resolveContainerList(entity, components.containerName()); if (fieldList == null) { LOG.warn("[FieldPathUtils] Unknown container type: {}", components.containerName()); @@ -254,7 +254,7 @@ private static boolean navigateAndSetDescription( /** Navigate entity structure and get the description on the target field. */ private static Optional navigateAndGetDescription( - EntityInterface entity, FieldPathComponents components) { + EntityInterface entity, FieldPathComponents components) { List fieldList = resolveContainerList(entity, components.containerName()); if (fieldList == null) { LOG.warn("[FieldPathUtils] Unknown container type: {}", components.containerName()); @@ -271,7 +271,7 @@ private static Optional navigateAndGetDescription( * a registry type always means what the registry says it means. Falling back to the getter only * serves entity types the registry does not cover, for example a dashboard's charts. */ - private static List resolveContainerList(EntityInterface entity, String container) { + private static List resolveContainerList(EntityInterface entity, String container) { List fromRegistry = ChildFieldResolver.containerListFor(entity, container); return fromRegistry != null ? fromRegistry : getFieldList(entity, container); } @@ -369,7 +369,7 @@ private static Optional getDescriptionFromList(List fieldList, String /** Navigate the parsed components to the target field POJO. */ private static Optional locateField( - EntityInterface entity, FieldPathComponents components) { + EntityInterface entity, FieldPathComponents components) { String container = components.containerName(); String fieldName = components.fieldName(); @@ -509,7 +509,7 @@ private static Optional getDescription(Object field) { } /** Get a field list from entity by name (columns, fields, schemaFields, etc.). */ - private static List getFieldList(EntityInterface entity, String listName) { + private static List getFieldList(EntityInterface entity, String listName) { Object result = ChildFieldResolver.invokeGetter(entity, ChildFieldResolver.getterName(listName)); return result instanceof List ? (List) result : null; diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/util/IntakeFormValidator.java b/openmetadata-service/src/main/java/org/openmetadata/service/util/IntakeFormValidator.java index 065209a30811..977d3a52bd4e 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/util/IntakeFormValidator.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/util/IntakeFormValidator.java @@ -54,7 +54,7 @@ private IntakeFormValidator() {} * * @throws IllegalArgumentException if any intake-form required field is unset. */ - public static void validate(EntityInterface entity, String entityType) { + public static void validate(EntityInterface entity, String entityType) { IntakeForm form = loadIntakeForm(entityType); if (form == null) return; @@ -69,7 +69,7 @@ public static void validate(EntityInterface entity, String entityType) { } private static List checkIntakeFormRequiredFields( - EntityInterface entity, IntakeForm form) { + EntityInterface entity, IntakeForm form) { List missing = new ArrayList<>(); for (IntakeFormField field : IntakeFormUtil.getEffectiveFormFields(form)) { if (!Boolean.TRUE.equals(field.getRequired())) continue; @@ -96,7 +96,7 @@ private static String describe(IntakeFormField field) { return described; } - private static boolean isFieldSet(EntityInterface entity, IntakeFormField field) { + private static boolean isFieldSet(EntityInterface entity, IntakeFormField field) { boolean isCustomProperty = IntakeFormField.FieldKind.CUSTOM_PROPERTY.equals(field.getFieldKind()) || field.getFieldPath().startsWith(EXTENSION_PREFIX); @@ -106,7 +106,7 @@ private static boolean isFieldSet(EntityInterface entity, IntakeFormField field) return isNativeFieldSet(entity, field.getFieldPath()); } - private static boolean isNativeFieldSet(EntityInterface entity, String fieldName) { + private static boolean isNativeFieldSet(EntityInterface entity, String fieldName) { try { JsonNode node = MAPPER.valueToTree(entity); return hasMeaningfulValue(node.get(fieldName)); @@ -116,7 +116,7 @@ private static boolean isNativeFieldSet(EntityInterface entity, String fieldName } } - private static boolean isExtensionFieldSet(EntityInterface entity, String path) { + private static boolean isExtensionFieldSet(EntityInterface entity, String path) { String propertyName = path.startsWith(EXTENSION_PREFIX) ? path.substring(EXTENSION_PREFIX.length()) : path; Object ext = entity.getExtension(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/util/JsonPatchUtils.java b/openmetadata-service/src/main/java/org/openmetadata/service/util/JsonPatchUtils.java index 80720eb10771..2b1083e53a31 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/util/JsonPatchUtils.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/util/JsonPatchUtils.java @@ -44,7 +44,7 @@ private JsonPatchUtils() {} public static Set getMetadataOperations( ResourceContextInterface resourceContextInterface, JsonPatch jsonPatch) { Set uniqueOperations = new HashSet<>(); - EntityInterface originalEntity = resourceContextInterface.getEntity(); + EntityInterface originalEntity = resourceContextInterface.getEntity(); String resourceType = resourceContextInterface.getResource(); boolean tagsAffected = false; diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/util/OpenMetadataOperations.java b/openmetadata-service/src/main/java/org/openmetadata/service/util/OpenMetadataOperations.java index 72a39a8c82d9..126787142684 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/util/OpenMetadataOperations.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/util/OpenMetadataOperations.java @@ -1813,7 +1813,7 @@ public Integer reembed( producerExecutor.submit( () -> { try { - org.openmetadata.schema.utils.ResultList batch = + org.openmetadata.schema.utils.ResultList> batch = source.readWithCursor(RestUtil.encodeCursor(String.valueOf(offset))); if (batch != null && batch.getData() != null && !batch.getData().isEmpty()) { taskQueue.put(new ReembedTask(entityType, batch)); @@ -1872,7 +1872,7 @@ public Integer reembed( private record ReembedTask( String entityType, - org.openmetadata.schema.utils.ResultList batch) {} + org.openmetadata.schema.utils.ResultList> batch) {} private java.util.concurrent.CountDownLatch startReembedConsumers( int consumerThreads, @@ -1922,7 +1922,7 @@ private void runReembedConsumer( LOG.warn("No index mapping found for entity type: {}, skipping batch", entityType); continue; } - for (EntityInterface entity : task.batch().getData()) { + for (EntityInterface entity : task.batch().getData()) { try { vecService.updateEntityEmbeddings(entity, entityIndexName); processedCounts @@ -3106,7 +3106,8 @@ public Integer cleanupFlowableHistory( private void analyzeEntityTable(String entity) { try { - EntityRepository repository = Entity.getEntityRepository(entity); + EntityRepository> repository = + Entity.getEntityRepository(entity); LOG.info("Analyzing table for [{}] Entity", entity); repository.getDao().analyzeTable(); } catch (EntityNotFoundException e) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/util/RequestEntityCache.java b/openmetadata-service/src/main/java/org/openmetadata/service/util/RequestEntityCache.java index faf688f889e0..6b17d92863ae 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/util/RequestEntityCache.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/util/RequestEntityCache.java @@ -90,7 +90,7 @@ public static void invalidate(String entityType, UUID id, String name) { } } - public static T getById( + public static > T getById( String entityType, UUID id, Fields fields, @@ -103,7 +103,7 @@ entityType, id, fieldsKey(fields), relationIncludesKey(relationIncludes), fromCa entityClass); } - public static T getByName( + public static > T getByName( String entityType, String name, Fields fields, @@ -116,7 +116,7 @@ entityType, name, fieldsKey(fields), relationIncludesKey(relationIncludes), from entityClass); } - public static void putById( + public static > void putById( String entityType, UUID id, Fields fields, @@ -130,7 +130,7 @@ entityType, id, fieldsKey(fields), relationIncludesKey(relationIncludes), fromCa entity); } - public static void putByName( + public static > void putByName( String entityType, String name, Fields fields, @@ -144,7 +144,7 @@ entityType, name, fieldsKey(fields), relationIncludesKey(relationIncludes), from entity); } - private static T get(EntityCacheKey key, Class entityClass) { + private static > T get(EntityCacheKey key, Class entityClass) { String cachedJson; try (Phase ignored = phase("requestCacheGet")) { cachedJson = entries().get(key); @@ -157,7 +157,7 @@ private static T get(EntityCacheKey key, Class en } } - private static void put(EntityCacheKey key, T entity) { + private static > void put(EntityCacheKey key, T entity) { if (entity == null) { return; } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/util/RestUtil.java b/openmetadata-service/src/main/java/org/openmetadata/service/util/RestUtil.java index a3430b81fc2a..1af63473d9e5 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/util/RestUtil.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/util/RestUtil.java @@ -166,8 +166,9 @@ public Response toResponse() { Response.status(status).header(CHANGE_CUSTOM_HEADER, changeType.value()).entity(entity); // Add ETag header if entity implements EntityInterface - if (entity != null && entity instanceof org.openmetadata.schema.EntityInterface) { - EntityETag.addETagHeader(responseBuilder, (org.openmetadata.schema.EntityInterface) entity); + if (entity != null && entity instanceof org.openmetadata.schema.EntityInterface) { + EntityETag.addETagHeader( + responseBuilder, (org.openmetadata.schema.EntityInterface) entity); } return responseBuilder.build(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/util/WebsocketNotificationHandler.java b/openmetadata-service/src/main/java/org/openmetadata/service/util/WebsocketNotificationHandler.java index 3c2b694f5dd3..f92e92a3fad4 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/util/WebsocketNotificationHandler.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/util/WebsocketNotificationHandler.java @@ -357,7 +357,7 @@ public static void sendQueryRunnerProgressNotification( } public static void sendDeleteOperationCompleteNotification( - String jobId, SecurityContext securityContext, EntityInterface entity) { + String jobId, SecurityContext securityContext, EntityInterface entity) { DeleteEntityMessage message = new DeleteEntityMessage(jobId, "COMPLETED", entity.getName(), null); String jsonMessage = JsonUtils.pojoToJson(message); @@ -374,7 +374,7 @@ public static void sendDeleteOperationCompleteNotification( } public static void sendDeleteOperationFailedNotification( - String jobId, SecurityContext securityContext, EntityInterface entity, String error) { + String jobId, SecurityContext securityContext, EntityInterface entity, String error) { DeleteEntityMessage message = new DeleteEntityMessage(jobId, "FAILED", entity.getName(), error); String jsonMessage = JsonUtils.pojoToJson(message); @@ -392,7 +392,7 @@ public static void sendDeleteOperationFailedNotification( } public static void sendRestoreOperationCompleteNotification( - String jobId, UUID userId, EntityInterface entity) { + String jobId, UUID userId, EntityInterface entity) { RestoreEntityMessage message = new RestoreEntityMessage(jobId, "COMPLETED", entity.getName(), null); String jsonMessage = JsonUtils.pojoToJson(message); @@ -434,7 +434,7 @@ public static UUID resolveUserId(SecurityContext securityContext) { } public static void sendMoveOperationCompleteNotification( - String jobId, SecurityContext securityContext, EntityInterface entity) { + String jobId, SecurityContext securityContext, EntityInterface entity) { MoveGlossaryTermMessage message = new MoveGlossaryTermMessage( jobId, "COMPLETED", entity.getName(), entity.getFullyQualifiedName(), null); @@ -452,7 +452,7 @@ public static void sendMoveOperationCompleteNotification( } public static void sendMoveOperationFailedNotification( - String jobId, SecurityContext securityContext, EntityInterface entity, String error) { + String jobId, SecurityContext securityContext, EntityInterface entity, String error) { MoveGlossaryTermMessage message = new MoveGlossaryTermMessage( jobId, "FAILED", entity.getName(), entity.getFullyQualifiedName(), error); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/util/incidentSeverityClassifier/IncidentSeverityClassifierInterface.java b/openmetadata-service/src/main/java/org/openmetadata/service/util/incidentSeverityClassifier/IncidentSeverityClassifierInterface.java index ca9f5c0328f8..01eab25d0d06 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/util/incidentSeverityClassifier/IncidentSeverityClassifierInterface.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/util/incidentSeverityClassifier/IncidentSeverityClassifierInterface.java @@ -23,5 +23,5 @@ private static IncidentSeverityClassifierInterface getClassifierClass() { return new LogisticRegressionIncidentSeverityClassifier(); } - public abstract Severity classifyIncidentSeverity(EntityInterface entity); + public abstract Severity classifyIncidentSeverity(EntityInterface entity); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/util/incidentSeverityClassifier/LogisticRegressionIncidentSeverityClassifier.java b/openmetadata-service/src/main/java/org/openmetadata/service/util/incidentSeverityClassifier/LogisticRegressionIncidentSeverityClassifier.java index 9264876b137a..1be9a57284e9 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/util/incidentSeverityClassifier/LogisticRegressionIncidentSeverityClassifier.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/util/incidentSeverityClassifier/LogisticRegressionIncidentSeverityClassifier.java @@ -27,7 +27,7 @@ public class LogisticRegressionIncidentSeverityClassifier }; @Override - public Severity classifyIncidentSeverity(EntityInterface entity) { + public Severity classifyIncidentSeverity(EntityInterface entity) { double[] vectorX = getVectorX(entity); if (vectorX.length == 0) { return null; @@ -92,7 +92,7 @@ private int argmax(double[] softmaxVector) { return maxIndex; } - private double[] getVectorX(EntityInterface entity) { + private double[] getVectorX(EntityInterface entity) { // get the input vector for the logistic regression model double hasOwner = !nullOrEmpty(entity.getOwners()) ? 1 : 0; double followers = entity.getFollowers() != null ? entity.getFollowers().size() : 0; diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/workflows/searchIndex/PaginatedEntitiesSource.java b/openmetadata-service/src/main/java/org/openmetadata/service/workflows/searchIndex/PaginatedEntitiesSource.java index 19ef36c1cad4..93a1baec276e 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/workflows/searchIndex/PaginatedEntitiesSource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/workflows/searchIndex/PaginatedEntitiesSource.java @@ -39,7 +39,7 @@ @Slf4j @Getter -public class PaginatedEntitiesSource implements Source> { +public class PaginatedEntitiesSource implements Source>> { private String name = "PaginatedEntitiesSource"; private final int batchSize; private final String entityType; @@ -56,7 +56,7 @@ public PaginatedEntitiesSource(String entityType, int batchSize, List fi this.entityType = entityType; this.batchSize = batchSize; this.fields = fields; - EntityRepository entityRepository = + EntityRepository> entityRepository = Entity.getEntityRepository(entityType); this.filter = entityRepository.getReindexFilter(); this.cachedTotalCount = entityRepository.getDao().listCount(this.filter); @@ -115,9 +115,9 @@ public PaginatedEntitiesSource withName(String name) { } @Override - public ResultList readNext(Map contextData) + public ResultList> readNext(Map contextData) throws SearchIndexException { - ResultList data = null; + ResultList> data = null; if (Boolean.FALSE.equals(isDone.get())) { data = read(cursor.get()); cursor.set(data.getPaging().getAfter()); @@ -128,10 +128,10 @@ public ResultList readNext(Map contex return data; } - private ResultList read(String cursor) throws SearchIndexException { + private ResultList> read(String cursor) throws SearchIndexException { LOG.debug("[PaginatedEntitiesSource] Fetching a Batch of Size: {} ", batchSize); EntityRepository entityRepository = Entity.getEntityRepository(entityType); - ResultList result; + ResultList> result; try { EntityDAO entityDAO = entityRepository.getDao(); result = @@ -228,11 +228,11 @@ private ResultList read(String cursor) throws SearchI return result; } - public ResultList readWithCursor(String currentCursor) + public ResultList> readWithCursor(String currentCursor) throws SearchIndexException { LOG.debug("[PaginatedEntitiesSource] Fetching a Batch of Size: {} ", batchSize); EntityRepository entityRepository = Entity.getEntityRepository(entityType); - ResultList result; + ResultList> result; try { EntityDAO entityDAO = entityRepository.getDao(); result = @@ -291,11 +291,11 @@ public ResultList readWithCursor(String currentCursor return result; } - public ResultList readNextKeyset(String keysetCursor) + public ResultList> readNextKeyset(String keysetCursor) throws SearchIndexException { LOG.debug("[PaginatedEntitiesSource] Fetching keyset batch of size: {}", batchSize); EntityRepository entityRepository = Entity.getEntityRepository(entityType); - ResultList result; + ResultList> result; try { result = entityRepository.listAfterKeyset( diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/workflows/searchIndex/ReindexingUtil.java b/openmetadata-service/src/main/java/org/openmetadata/service/workflows/searchIndex/ReindexingUtil.java index d6ef94773d77..4bda7640d1c3 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/workflows/searchIndex/ReindexingUtil.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/workflows/searchIndex/ReindexingUtil.java @@ -76,7 +76,7 @@ private ReindexingUtil() { public static void populateDocBuildContext( Map contextData, String entityType, - List entities) { + List> entities) { Map> prefetchedLineage = null; Map> prefetchedServiceStyles = null; Map prefetchedRelationshipRevisions = null; @@ -91,7 +91,7 @@ public static void populateDocBuildContext( Entity.TEST_CASE.equals(entityType) || entity instanceof TestSuite testSuite && Boolean.FALSE.equals(testSuite.getBasic())) - .map(EntityInterface::getId) + .map(EntityInterface::getId) .filter(Objects::nonNull) .toList(); @SuppressWarnings("unchecked") @@ -134,7 +134,7 @@ public static void populateDocBuildContext( prefetchedServiceStyles != null ? prefetchedServiceStyles.size() : 0), prefetchedRelationshipRevisions != null ? prefetchedRelationshipRevisions.size() : 0); Map docBuildContexts = new HashMap<>(contextSize); - for (EntityInterface entity : entities) { + for (EntityInterface entity : entities) { UUID entityId = entity.getId(); if (entityId == null) { continue; diff --git a/openmetadata-service/src/test/java/org/openmetadata/csv/EntityCsvTest.java b/openmetadata-service/src/test/java/org/openmetadata/csv/EntityCsvTest.java index 7801fb496bc1..69d46e1eaf02 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/csv/EntityCsvTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/csv/EntityCsvTest.java @@ -653,7 +653,7 @@ void test_exportCsvWritesRecordsAndReportsBatchProgress() throws IOException { HEADER_STRING + "orders,service.db.schema.orders,Orders table" + LINE_SEPARATOR, testCsv.exportCsv(singleEntity)); - List entities = new ArrayList<>(); + List> entities = new ArrayList<>(); for (int i = 0; i < EntityCsv.DEFAULT_BATCH_SIZE + 1; i++) { entities.add(tableEntity("table" + i, "service.db.schema.table" + i, "description-" + i)); } @@ -1047,7 +1047,7 @@ void test_createEntityAndFlushPendingEntityOperationsBatchesCreatesAndUpdates() .withFullyQualifiedName("service.db.schema.updated_table"); @SuppressWarnings("unchecked") - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); RuleEngine ruleEngine = mock(RuleEngine.class); ChangeEvent createdChangeEvent = @@ -1083,7 +1083,8 @@ void test_createEntityAndFlushPendingEntityOperationsBatchesCreatesAndUpdates() .thenReturn(updatedChangeEvent); Mockito.when(repository.findMatchForImport(createdEntity)).thenReturn(null); - Mockito.when(repository.findMatchForImport(updatedEntity)).thenReturn(originalEntity); + Mockito.>when(repository.findMatchForImport(updatedEntity)) + .thenReturn(originalEntity); Mockito.when(repository.createManyEntitiesForImport(List.of(createdEntity), "admin")) .thenReturn(List.of(createdEntity)); Mockito.when( @@ -1123,7 +1124,7 @@ void test_flushPendingEntityOperationsFallsBackToIndividualWritesOnBatchFailure( .withFullyQualifiedName("service.db.schema.failed_table"); @SuppressWarnings("unchecked") - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); RuleEngine ruleEngine = mock(RuleEngine.class); try (MockedStatic entity = Mockito.mockStatic(Entity.class); @@ -1176,7 +1177,7 @@ void test_createEntityDryRunTracksCreateAndUpdateStatuses() throws Exception { CSVRecord updateRecord = singleRecord(testCsv, updatedEntity.getFullyQualifiedName(), "", ""); @SuppressWarnings("unchecked") - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); RuleEngine ruleEngine = mock(RuleEngine.class); try (MockedStatic entity = Mockito.mockStatic(Entity.class); @@ -1187,7 +1188,8 @@ void test_createEntityDryRunTracksCreateAndUpdateStatuses() throws Exception { validatorUtil.when(() -> ValidatorUtil.validate(createdEntity)).thenReturn(null); validatorUtil.when(() -> ValidatorUtil.validate(updatedEntity)).thenReturn(null); Mockito.when(repository.findMatchForImport(createdEntity)).thenReturn(null); - Mockito.when(repository.findMatchForImport(updatedEntity)).thenReturn(originalEntity); + Mockito.>when(repository.findMatchForImport(updatedEntity)) + .thenReturn(originalEntity); testCsv.queueEntity(createRecord, createdEntity); testCsv.queueEntity(updateRecord, updatedEntity); @@ -1220,7 +1222,7 @@ void test_createEntityFlushesPendingOperationsWhenPrepareInternalNeedsDependenci singleRecord(testCsv, dependentEntity.getFullyQualifiedName(), "", ""); @SuppressWarnings("unchecked") - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); RuleEngine ruleEngine = mock(RuleEngine.class); ChangeEvent createdChangeEvent = new ChangeEvent() @@ -1279,7 +1281,7 @@ void test_createEntityValidationAndUnexpectedFailuresRecordImportErrors() throws singleRecord(validationCsv, invalidEntity.getFullyQualifiedName(), "", ""); @SuppressWarnings("unchecked") - EntityRepository validationRepository = mock(EntityRepository.class); + EntityRepository> validationRepository = mock(EntityRepository.class); try (MockedStatic entity = Mockito.mockStatic(Entity.class); MockedStatic validatorUtil = Mockito.mockStatic(ValidatorUtil.class)) { @@ -1303,7 +1305,7 @@ void test_createEntityValidationAndUnexpectedFailuresRecordImportErrors() throws singleRecord(failingCsv, failingEntity.getFullyQualifiedName(), "", ""); @SuppressWarnings("unchecked") - EntityRepository failingRepository = mock(EntityRepository.class); + EntityRepository> failingRepository = mock(EntityRepository.class); try (MockedStatic entity = Mockito.mockStatic(Entity.class); MockedStatic validatorUtil = Mockito.mockStatic(ValidatorUtil.class)) { @@ -1339,7 +1341,7 @@ void test_createEntityWithTypeDryRunTracksCreateAndUpdateStatuses() throws Excep CSVRecord updateRecord = singleRecord(testCsv, updatedEntity.getFullyQualifiedName(), "", ""); @SuppressWarnings("unchecked") - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); RuleEngine ruleEngine = mock(RuleEngine.class); try (MockedStatic entity = Mockito.mockStatic(Entity.class); @@ -1350,7 +1352,8 @@ void test_createEntityWithTypeDryRunTracksCreateAndUpdateStatuses() throws Excep validatorUtil.when(() -> ValidatorUtil.validate(createdEntity)).thenReturn(null); validatorUtil.when(() -> ValidatorUtil.validate(updatedEntity)).thenReturn(null); Mockito.when(repository.findMatchForImport(createdEntity)).thenReturn(null); - Mockito.when(repository.findMatchForImport(updatedEntity)).thenReturn(originalEntity); + Mockito.>when(repository.findMatchForImport(updatedEntity)) + .thenReturn(originalEntity); testCsv.queueEntityWithType(createRecord, createdEntity, Entity.TABLE); testCsv.queueEntityWithType(updateRecord, updatedEntity, Entity.TABLE); @@ -1383,7 +1386,7 @@ void test_createEntityWithTypeFlushesPendingOperationsWhenPrepareInternalNeedsDe singleRecord(testCsv, dependentEntity.getFullyQualifiedName(), "", ""); @SuppressWarnings("unchecked") - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); RuleEngine ruleEngine = mock(RuleEngine.class); ChangeEvent createdChangeEvent = new ChangeEvent() @@ -1443,7 +1446,7 @@ void test_createEntityWithTypeValidationAndUnexpectedFailuresRecordImportErrors( singleRecord(validationCsv, invalidEntity.getFullyQualifiedName(), "", ""); @SuppressWarnings("unchecked") - EntityRepository validationRepository = mock(EntityRepository.class); + EntityRepository> validationRepository = mock(EntityRepository.class); try (MockedStatic entity = Mockito.mockStatic(Entity.class); MockedStatic validatorUtil = Mockito.mockStatic(ValidatorUtil.class)) { @@ -1467,7 +1470,7 @@ void test_createEntityWithTypeValidationAndUnexpectedFailuresRecordImportErrors( singleRecord(failingCsv, failingEntity.getFullyQualifiedName(), "", ""); @SuppressWarnings("unchecked") - EntityRepository failingRepository = mock(EntityRepository.class); + EntityRepository> failingRepository = mock(EntityRepository.class); try (MockedStatic entity = Mockito.mockStatic(Entity.class); MockedStatic validatorUtil = Mockito.mockStatic(ValidatorUtil.class)) { @@ -1490,9 +1493,9 @@ void test_createEntityWithTypeValidationAndUnexpectedFailuresRecordImportErrors( void test_changeEventHelpersHandleNoChangeAndQueueEvents() throws Exception { TestCsv testCsv = new TestCsv(); Table entity = tableEntity("orders", "service.db.schema.orders", "Orders"); - PutResponse updatedResponse = + PutResponse> updatedResponse = new PutResponse<>(Response.Status.OK, entity, EventType.ENTITY_UPDATED); - PutResponse noChangeResponse = + PutResponse> noChangeResponse = new PutResponse<>(Response.Status.OK, entity, EventType.ENTITY_NO_CHANGE); ChangeEvent changeEvent = new ChangeEvent() @@ -1656,7 +1659,7 @@ void test_getEntityWithDependencyResolutionFlushesPendingEntitiesAndRetriesLooku .withFullyQualifiedName("service.db.schema.pending_table"); @SuppressWarnings("unchecked") - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); RuleEngine ruleEngine = mock(RuleEngine.class); ChangeEvent createdChangeEvent = new ChangeEvent() @@ -1695,7 +1698,7 @@ void test_getEntityWithDependencyResolutionFlushesPendingEntitiesAndRetriesLooku testCsv.queueEntity(record, pendingEntity); - EntityInterface resolved = + EntityInterface resolved = testCsv.getEntityWithDependencyResolution( Entity.TABLE, "service.db.schema.pending_table", @@ -2292,7 +2295,7 @@ void test_flushPendingSearchIndexUpdatesClearsQueueOnSuccessAndFailure() { SearchRepository searchRepository = mock(SearchRepository.class); Table successEntity = tableEntity("orders", "service.db.schema.orders", "Orders"); Table failedEntity = tableEntity("payments", "service.db.schema.payments", "Payments"); - List> capturedBatches = new ArrayList<>(); + List>> capturedBatches = new ArrayList<>(); TestCsv successfulCsv = new TestCsv(); successfulCsv.pendingSearchIndexUpdates.add(successEntity); @@ -2432,7 +2435,7 @@ void test_createUserEntityNonDryRunQueuesChangeEventWithoutAuthMechanism() throw UserRepository repository = mock(UserRepository.class); ChangeEvent changeEvent = new ChangeEvent().withEntityType(Entity.USER).withEventType(EventType.ENTITY_CREATED); - EntityInterface[] eventEntity = new EntityInterface[1]; + EntityInterface[] eventEntity = new EntityInterface[1]; try (MockedStatic entity = Mockito.mockStatic(Entity.class); MockedStatic validatorUtil = Mockito.mockStatic(ValidatorUtil.class); @@ -2606,14 +2609,14 @@ void test_rowEntityTypeOverridesEntityTypeInExtensionValidation() throws IOExcep } } - private static class TestCsv extends EntityCsv { - private final Map entitiesByTypeAndName = new HashMap<>(); + private static class TestCsv extends EntityCsv> { + private final Map> entitiesByTypeAndName = new HashMap<>(); protected TestCsv() { super(Entity.TABLE, CSV_HEADERS, "admin"); } - private void addEntity(String entityType, String fqn, EntityInterface entity) { + private void addEntity(String entityType, String fqn, EntityInterface entity) { entitiesByTypeAndName.put(entityType + ":" + fqn, entity); } @@ -2638,11 +2641,11 @@ private void setDryRun(boolean dryRun) { importResult.withDryRun(dryRun); } - private void queueEntity(CSVRecord csvRecord, EntityInterface entity) throws IOException { + private void queueEntity(CSVRecord csvRecord, EntityInterface entity) throws IOException { createEntity(mock(CSVPrinter.class), csvRecord, entity); } - private void queueEntityWithType(CSVRecord csvRecord, EntityInterface entity, String type) + private void queueEntityWithType(CSVRecord csvRecord, EntityInterface entity, String type) throws IOException { createEntity(mock(CSVPrinter.class), csvRecord, entity, type); } @@ -2710,14 +2713,14 @@ private String parseFormattedDateTime( } @Override - protected EntityInterface getEntityByName(String entityType, String fqn) { - EntityInterface entity = entitiesByTypeAndName.get(entityType + ":" + fqn); + protected EntityInterface getEntityByName(String entityType, String fqn) { + EntityInterface entity = entitiesByTypeAndName.get(entityType + ":" + fqn); return entity != null ? entity : super.getEntityByName(entityType, fqn); } @Override protected EntityReference getEntityReferenceByName(String entityType, String fqn) { - EntityInterface entity = entitiesByTypeAndName.get(entityType + ":" + fqn); + EntityInterface entity = entitiesByTypeAndName.get(entityType + ":" + fqn); return entity != null ? entity.getEntityReference() : super.getEntityReferenceByName(entityType, fqn); @@ -2734,7 +2737,7 @@ protected void createEntity(CSVPrinter resultsPrinter, List records) } @Override - protected void addRecord(CsvFile csvFile, EntityInterface entity) { + protected void addRecord(CsvFile csvFile, EntityInterface entity) { addRecord( csvFile, List.of( @@ -2759,7 +2762,7 @@ private void updateColumns(Table table, CSVRecord csvRecord) throws Exception { } private void invokeCreateChangeEventAndUpdateInES( - PutResponse response, String importedBy) throws Exception { + PutResponse> response, String importedBy) throws Exception { Method method = EntityCsv.class.getDeclaredMethod( "createChangeEventAndUpdateInES", PutResponse.class, String.class); @@ -2775,7 +2778,7 @@ private void invokeCreateChangeEventAndUpdateInES( } private void invokeCreateChangeEventForBatchedEntity( - EntityInterface entity, EventType eventType) throws Exception { + EntityInterface entity, EventType eventType) throws Exception { Method method = EntityCsv.class.getDeclaredMethod( "createChangeEventForBatchedEntity", EntityInterface.class, EventType.class); @@ -3050,7 +3053,7 @@ void test_bulkEditInheritedDomainWithMismatchedDataProductFailsRule() throws IOE private record DataProductImportScenario( TestCsv testCsv, CSVRecord csvRecord, - EntityRepository repository, + EntityRepository> repository, Table updatedEntity) {} /** @@ -3091,7 +3094,7 @@ private DataProductImportScenario importTableUpdateWithInheritedDomain( testCsv.setDryRun(true); CSVRecord csvRecord = singleRecord(testCsv, updatedEntity.getFullyQualifiedName(), "", ""); - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); EntityRulesSettings rulesSettings = new EntityRulesSettings().withEntitySemantics(List.of(dataProductDomainValidationRule())); @@ -3100,7 +3103,7 @@ private DataProductImportScenario importTableUpdateWithInheritedDomain( MockedStatic validatorUtil = Mockito.mockStatic(ValidatorUtil.class)) { entityStatic.when(() -> Entity.getEntityRepository(Entity.TABLE)).thenReturn(repository); for (String ignoredType : List.of(Entity.USER, Entity.TEAM, Entity.PERSONA, Entity.BOT)) { - EntityRepository ignoredRepo = mock(EntityRepository.class); + EntityRepository> ignoredRepo = mock(EntityRepository.class); Mockito.doReturn(User.class).when(ignoredRepo).getEntityClass(); entityStatic.when(() -> Entity.getEntityRepository(ignoredType)).thenReturn(ignoredRepo); } @@ -3125,7 +3128,8 @@ private DataProductImportScenario importTableUpdateWithInheritedDomain( .thenReturn(rulesSettings); validatorUtil.when(() -> ValidatorUtil.validate(Mockito.any())).thenReturn(null); - Mockito.when(repository.findMatchForImport(Mockito.any())).thenReturn(originalEntity); + Mockito.>when(repository.findMatchForImport(Mockito.any())) + .thenReturn(originalEntity); testCsv.queueEntity(csvRecord, updatedEntity); } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/aicontext/AIContextBuilderTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/aicontext/AIContextBuilderTest.java index 88fd99174926..83988cc1d73f 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/aicontext/AIContextBuilderTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/aicontext/AIContextBuilderTest.java @@ -33,6 +33,7 @@ import org.openmetadata.schema.api.data.MetricExpression; import org.openmetadata.schema.api.services.CreateDatabaseService; import org.openmetadata.schema.entity.context.ContextMemory; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.data.Metric; import org.openmetadata.schema.entity.data.Table; import org.openmetadata.schema.tests.type.TestSummary; @@ -48,7 +49,6 @@ import org.openmetadata.schema.type.Edge; import org.openmetadata.schema.type.EntityLineage; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.JoinedWith; import org.openmetadata.schema.type.LineageDetails; import org.openmetadata.schema.type.MetadataOperation; @@ -280,15 +280,19 @@ void applyKnowledgeBudget_omitsContentWhenBudgetExhausted() { @Test void isActivePill_admitsOnlyApprovedMemories() { assertTrue( - AIContextBuilder.isActivePill(new ContextMemory().withEntityStatus(EntityStatus.APPROVED))); + AIContextBuilder.isActivePill( + new ContextMemory().withEntityStatus(ContextMemoryStatus.APPROVED))); assertFalse( - AIContextBuilder.isActivePill(new ContextMemory().withEntityStatus(EntityStatus.DRAFT)), + AIContextBuilder.isActivePill( + new ContextMemory().withEntityStatus(ContextMemoryStatus.DRAFT)), "Draft memories are not settled knowledge"); assertFalse( - AIContextBuilder.isActivePill(new ContextMemory().withEntityStatus(EntityStatus.ARCHIVED)), + AIContextBuilder.isActivePill( + new ContextMemory().withEntityStatus(ContextMemoryStatus.ARCHIVED)), "Archived memories must not reach agents as current context"); assertFalse( - AIContextBuilder.isActivePill(new ContextMemory().withEntityStatus(EntityStatus.REJECTED)), + AIContextBuilder.isActivePill( + new ContextMemory().withEntityStatus(ContextMemoryStatus.REJECTED)), "Rejected memories were found to be wrong"); } @@ -296,10 +300,10 @@ void isActivePill_admitsOnlyApprovedMemories() { void pillsForContext_dropsRetiredAndHiddenPillsBeforeTheCap() { List attached = new ArrayList<>(); for (int i = 0; i < 20; i++) { - attached.add(pill("retired-" + i, EntityStatus.REJECTED)); + attached.add(pill("retired-" + i, ContextMemoryStatus.REJECTED)); } - ContextMemory hidden = pill("hidden", EntityStatus.APPROVED); - ContextMemory usable = pill("usable", EntityStatus.APPROVED); + ContextMemory hidden = pill("hidden", ContextMemoryStatus.APPROVED); + ContextMemory usable = pill("usable", ContextMemoryStatus.APPROVED); attached.add(hidden); attached.add(usable); @@ -314,13 +318,13 @@ void pillsForContext_dropsRetiredAndHiddenPillsBeforeTheCap() { void pillsForContext_capsTheUsablePills() { List attached = new ArrayList<>(); for (int i = 0; i < 25; i++) { - attached.add(pill("approved-" + i, EntityStatus.APPROVED)); + attached.add(pill("approved-" + i, ContextMemoryStatus.APPROVED)); } assertEquals(20, AIContextBuilder.pillsForContext(attached, pills -> pills).size()); } - private static ContextMemory pill(String name, EntityStatus status) { + private static ContextMemory pill(String name, ContextMemoryStatus status) { return new ContextMemory().withId(UUID.randomUUID()).withName(name).withEntityStatus(status); } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataInsightsExtensionsTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataInsightsExtensionsTest.java index 7236b587f5ce..2d88962c6a5d 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataInsightsExtensionsTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataInsightsExtensionsTest.java @@ -26,7 +26,7 @@ void batchPreparationPrecedesEnrichmentAndCancellationStopsCompletion() { new Session() { @Override public void beforeBatch( - List entities) { + List> entities) { calls.add("batch"); } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/DataInsightsEntityEnricherProcessorTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/DataInsightsEntityEnricherProcessorTest.java index aa6d168e86d3..dff93102ab1b 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/DataInsightsEntityEnricherProcessorTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/DataInsightsEntityEnricherProcessorTest.java @@ -41,6 +41,7 @@ import org.openmetadata.schema.type.Column; import org.openmetadata.schema.type.ColumnDataType; import org.openmetadata.schema.type.EntityReference; +import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.utils.JsonUtils; import org.openmetadata.service.Entity; import org.openmetadata.service.apps.bundles.insights.workflows.dataAssets.processors.enricher.ColumnCoverage; @@ -335,7 +336,7 @@ void testStripNestedColumnChildrenNoOpWhenColumnsKeyAbsent() throws Exception { * so each step's contract is exercised without pulling in their real implementations, and * stubs {@link Entity#getEntityTypeFromObject(Object)} for the per-step team/tier log lines. */ - private Map enrichEntity(EntityInterface entity, String entityType) { + private Map enrichEntity(EntityInterface entity, String entityType) { try (MockedStatic searchIndexUtilsMock = Mockito.mockStatic(SearchIndexUtils.class); MockedStatic entityMock = Mockito.mockStatic(Entity.class)) { @@ -351,7 +352,7 @@ private Map enrichEntity(EntityInterface entity, String entityTy .when(() -> SearchIndexUtils.hasColumns(any())) .thenAnswer( invocation -> { - EntityInterface e = invocation.getArgument(0); + EntityInterface e = invocation.getArgument(0); return List.of(e.getClass().getInterfaces()).contains(ColumnsEntityInterface.class); }); @@ -401,7 +402,7 @@ private Column createColumn(String name, String description) { return column; } - static class MockColumnsEntity implements EntityInterface, ColumnsEntityInterface { + static class MockColumnsEntity implements EntityInterface, ColumnsEntityInterface { private final UUID id = UUID.randomUUID(); private final String fqn = "test.table." + id; private final List columns; @@ -506,12 +507,12 @@ public void setUpdatedAt(Long updatedAt) {} public void setHref(URI href) {} @Override - public T withHref(URI href) { + public > T withHref(URI href) { return (T) this; } } - static class MockEntity implements EntityInterface { + static class MockEntity implements EntityInterface { private final UUID id = UUID.randomUUID(); private final String fqn = "test.entity." + id; private final String description; @@ -609,7 +610,7 @@ public void setUpdatedAt(Long updatedAt) {} public void setHref(URI href) {} @Override - public T withHref(URI href) { + public > T withHref(URI href) { return (T) this; } } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/EnrichmentPipelineTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/EnrichmentPipelineTest.java index 8ccf8d600c89..0d7d2fcf324f 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/EnrichmentPipelineTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/EnrichmentPipelineTest.java @@ -312,7 +312,7 @@ private static EnrichmentTarget newTarget() { } private static EnrichmentTarget newTargetWithFqn(String fqn) { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); when(entity.getFullyQualifiedName()).thenReturn(fqn); return new EnrichmentTarget( entity, diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/SnapshotMaterializerTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/SnapshotMaterializerTest.java index 55e95438e18b..7549a5d982c3 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/SnapshotMaterializerTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/SnapshotMaterializerTest.java @@ -138,7 +138,7 @@ void timestampKey_isStartOfDay_notRawPointer() { assertTrue(((Long) snap.get(TIMESTAMP_KEY)) <= now, "@timestamp <= now"); } - private EntityInterface stubEntity() { + private EntityInterface stubEntity() { return mock(EntityInterface.class); } } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/VersionResolverTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/VersionResolverTest.java index ed8990b0aa8d..1ebce34c6475 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/VersionResolverTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/VersionResolverTest.java @@ -45,7 +45,8 @@ void entityUnchangedBeforeWindow_returnsOneWindowCoveringFullRange() { long windowEnd = TimestampUtils.getEndOfDayTimestamp(today); long windowStart = TimestampUtils.subtractDays(today, 29); - EntityInterface entity = stubEntity(windowStart - 5 * ONE_DAY); // updated 5 days BEFORE window + EntityInterface entity = + stubEntity(windowStart - 5 * ONE_DAY); // updated 5 days BEFORE window EnrichmentContext context = new EnrichmentContext( "table", List.of("id", "name", "fullyQualifiedName"), windowStart, windowEnd); @@ -73,7 +74,7 @@ void entityUpdatedExactlyOnWindowStart_doesNotShortCircuit() { long windowEnd = TimestampUtils.getEndOfDayTimestamp(today); long windowStart = TimestampUtils.subtractDays(today, 29); - EntityInterface entity = stubEntity(windowStart + 1); // 1ms after window start + EntityInterface entity = stubEntity(windowStart + 1); // 1ms after window start EnrichmentContext context = new EnrichmentContext("table", List.of("id"), windowStart, windowEnd); @@ -116,7 +117,7 @@ void entityWithNullUpdatedAt_skipsShortCircuit() { long windowEnd = TimestampUtils.getEndOfDayTimestamp(now); long windowStart = TimestampUtils.subtractDays(now, 7); - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); when(entity.getUpdatedAt()).thenReturn(null); EnrichmentContext context = @@ -130,8 +131,8 @@ void entityWithNullUpdatedAt_skipsShortCircuit() { } } - private static EntityInterface stubEntity(long updatedAt) { - EntityInterface entity = mock(EntityInterface.class); + private static EntityInterface stubEntity(long updatedAt) { + EntityInterface entity = mock(EntityInterface.class); when(entity.getUpdatedAt()).thenReturn(updatedAt); return entity; } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/EntityStatusStepTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/EntityStatusStepTest.java index 58901b38fe59..ffd9a3b6fe7e 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/EntityStatusStepTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/EntityStatusStepTest.java @@ -51,7 +51,7 @@ void nullStatus_defaultsToUnprocessed() { assertEquals("Unprocessed", snapshot.get("entityStatus")); } - private Map run(EntityInterface entity) { + private Map run(EntityInterface entity) { Map entityMap = new HashMap<>(); EnrichmentTarget target = new EnrichmentTarget( @@ -66,8 +66,8 @@ private Map run(EntityInterface entity) { return entityMap; } - private static EntityInterface entityWithStatus(EntityStatus status) { - EntityInterface entity = mock(EntityInterface.class); + private static EntityInterface entityWithStatus(EntityStatus status) { + EntityInterface entity = mock(EntityInterface.class); when(entity.getEntityStatus()).thenReturn(status); return entity; } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/TagAndTierSourcesStepTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/TagAndTierSourcesStepTest.java index 0135063ed9d2..c120832a2d79 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/TagAndTierSourcesStepTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/TagAndTierSourcesStepTest.java @@ -47,7 +47,7 @@ class TagAndTierSourcesStepTest { @Test void classificationTagsOnly_populateClassificationBucketOnly() { - EntityInterface entity = + EntityInterface entity = entityWithTags( List.of(classificationTag("PII.Sensitive"), classificationTag("Tier.Tier1"))); @@ -59,7 +59,7 @@ void classificationTagsOnly_populateClassificationBucketOnly() { @Test void glossaryTagsOnly_populateGlossaryBucketOnly() { - EntityInterface entity = + EntityInterface entity = entityWithTags(List.of(glossaryTag("Business.Customer"), glossaryTag("Business.Revenue"))); Map snapshot = run(entity); @@ -70,7 +70,7 @@ void glossaryTagsOnly_populateGlossaryBucketOnly() { @Test void mixedTags_splitBySource() { - EntityInterface entity = + EntityInterface entity = entityWithTags( List.of( classificationTag("PII.Sensitive"), @@ -86,7 +86,7 @@ void mixedTags_splitBySource() { @Test void emptyTags_emitEmptyLists() { - EntityInterface entity = entityWithTags(List.of()); + EntityInterface entity = entityWithTags(List.of()); Map snapshot = run(entity); @@ -96,7 +96,7 @@ void emptyTags_emitEmptyLists() { @Test void nullTags_emitEmptyLists_andDoesNotThrow() { - EntityInterface entity = entityWithTags(null); + EntityInterface entity = entityWithTags(null); Map snapshot = run(entity); @@ -106,7 +106,7 @@ void nullTags_emitEmptyLists_andDoesNotThrow() { @Test void existingTagAndTierSourceCounts_areStillEmitted() { - EntityInterface entity = + EntityInterface entity = entityWithTags( List.of(classificationTag("PII.Sensitive"), classificationTag("Tier.Tier1"))); @@ -118,7 +118,7 @@ void existingTagAndTierSourceCounts_areStillEmitted() { assertTrue(((Map) snapshot.get(TIER_SOURCES)).containsKey("Manual")); } - private Map run(EntityInterface entity) { + private Map run(EntityInterface entity) { Map entityMap = new HashMap<>(); EnrichmentTarget target = new EnrichmentTarget( @@ -139,8 +139,8 @@ private Map run(EntityInterface entity) { return entityMap; } - private static EntityInterface entityWithTags(List tags) { - EntityInterface entity = mock(EntityInterface.class); + private static EntityInterface entityWithTags(List tags) { + EntityInterface entity = mock(EntityInterface.class); when(entity.getTags()).thenReturn(tags); return entity; } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/TierStepTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/TierStepTest.java index 8b4bfcfc5b07..500778d8be70 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/TierStepTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/processors/enricher/steps/TierStepTest.java @@ -40,21 +40,21 @@ class TierStepTest { @Test void tierEligibleEntity_noTierTag_emitsNoTierDefault() { - EntityInterface entity = entityWithTags(List.of()); + EntityInterface entity = entityWithTags(List.of()); Map snapshot = run(entity, "table"); assertEquals("NoTier", snapshot.get("tier")); } @Test void tierEligibleEntity_withTierTag_emitsTagFqn() { - EntityInterface entity = entityWithTags(List.of(tag("Tier.Tier2"))); + EntityInterface entity = entityWithTags(List.of(tag("Tier.Tier2"))); Map snapshot = run(entity, "table"); assertEquals("Tier.Tier2", snapshot.get("tier")); } @Test void tierEligibleEntity_firstTierTagWins() { - EntityInterface entity = + EntityInterface entity = entityWithTags(List.of(tag("PII.Sensitive"), tag("Tier.Tier3"), tag("Tier.Tier1"))); Map snapshot = run(entity, "table"); assertEquals("Tier.Tier3", snapshot.get("tier")); @@ -62,7 +62,7 @@ void tierEligibleEntity_firstTierTagWins() { @Test void nonTierEntity_noTierTag_emitsNothing() { - EntityInterface entity = entityWithTags(List.of(tag("Domain.Sales"))); + EntityInterface entity = entityWithTags(List.of(tag("Domain.Sales"))); Map snapshot = run(entity, "tag"); assertFalse(snapshot.containsKey("tier")); } @@ -71,14 +71,14 @@ void nonTierEntity_noTierTag_emitsNothing() { void nonTierEntity_withTierTag_emitsTagFqn() { // Even a NON_TIER_ENTITIES type, if explicitly tagged with Tier.*, still gets the tier // emitted. - EntityInterface entity = entityWithTags(List.of(tag("Tier.Tier4"))); + EntityInterface entity = entityWithTags(List.of(tag("Tier.Tier4"))); Map snapshot = run(entity, "glossaryTerm"); assertEquals("Tier.Tier4", snapshot.get("tier")); } @Test void tierEligibleEntity_nullTagsList_emitsNoTierDefault() { - EntityInterface entity = entityWithTags(null); + EntityInterface entity = entityWithTags(null); Map snapshot = run(entity, "table"); assertEquals("NoTier", snapshot.get("tier")); } @@ -90,21 +90,21 @@ void tierEligibleEntity_tagsWithNullEntries_skipsThemGracefully() { tags.add(null); tags.add(tag("Tier.Tier2")); tags.add(null); - EntityInterface entity = entityWithTags(tags); + EntityInterface entity = entityWithTags(tags); Map snapshot = run(entity, "table"); assertEquals("Tier.Tier2", snapshot.get("tier")); } @Test void tagWithNullFqn_doesNotMatchTierPrefix() { - EntityInterface entity = entityWithTags(List.of(new TagLabel())); // tagFQN null + EntityInterface entity = entityWithTags(List.of(new TagLabel())); // tagFQN null Map snapshot = run(entity, "table"); assertEquals("NoTier", snapshot.get("tier")); } // ─────────────── helpers ─────────────── - private Map run(EntityInterface entity, String entityType) { + private Map run(EntityInterface entity, String entityType) { try (MockedStatic entityMock = mockStatic(Entity.class)) { entityMock.when(() -> Entity.getEntityTypeFromObject(any())).thenReturn(entityType); @@ -123,8 +123,8 @@ private Map run(EntityInterface entity, String entityType) { } } - private static EntityInterface entityWithTags(List tags) { - EntityInterface entity = org.mockito.Mockito.mock(EntityInterface.class); + private static EntityInterface entityWithTags(List tags) { + EntityInterface entity = org.mockito.Mockito.mock(EntityInterface.class); when(entity.getTags()).thenReturn(tags); return entity; } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/rdf/RdfBatchProcessorTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/rdf/RdfBatchProcessorTest.java index 21f41ebf9c9c..79d860457aec 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/rdf/RdfBatchProcessorTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/rdf/RdfBatchProcessorTest.java @@ -103,7 +103,7 @@ void setUp() { @Test void preTranslatedAttemptConsumesTheOriginalBudget() { final AtomicLong now = new AtomicLong(); - final List entities = + final List> entities = List.of(new Table().withId(UUID.randomUUID()), new Table().withId(UUID.randomUUID())); final var requests = entities.stream() @@ -133,7 +133,7 @@ void preTranslatedAttemptConsumesTheOriginalBudget() { @Test void successfulLeftHalfCannotStartARightHalfAfterTheDeadline() { final AtomicLong now = new AtomicLong(); - final List entities = + final List> entities = List.of(new Table().withId(UUID.randomUUID()), new Table().withId(UUID.randomUUID())); when(rdfRepository.batchWriteBudgetMs()).thenReturn(1L); doThrow(new IllegalArgumentException("split")) @@ -160,7 +160,7 @@ void successfulLeftHalfCannotStartARightHalfAfterTheDeadline() { @Test void uncertainWriteOutcomeStopsBisection() { - final List entities = + final List> entities = List.of(new Table().withId(UUID.randomUUID()), new Table().withId(UUID.randomUUID())); doThrow( new RdfWriteOutcomeUnknownException( @@ -175,8 +175,8 @@ void uncertainWriteOutcomeStopsBisection() { verify(rdfRepository, times(1)).bulkCreateOrUpdate(anyList(), any()); } - private EntityInterface mockEntity() { - EntityInterface e = mock(EntityInterface.class); + private EntityInterface mockEntity() { + EntityInterface e = mock(EntityInterface.class); lenient().when(e.getId()).thenReturn(UUID.randomUUID()); return e; } @@ -184,7 +184,7 @@ private EntityInterface mockEntity() { @Test @DisplayName("happy path: bulk write succeeds; all entities counted as success, no fallback") void bulkSuccessReportsAllSuccess() { - List entities = List.of(mockEntity(), mockEntity(), mockEntity()); + List> entities = List.of(mockEntity(), mockEntity(), mockEntity()); RdfBatchProcessor.BatchProcessingResult result = processor.processEntities("table", entities, null); @@ -199,8 +199,8 @@ void bulkSuccessReportsAllSuccess() { @Test @DisplayName("pre-translation failures remain visible when the writable entities succeed") void preTranslationFailureIsNotOverwrittenByWriteSuccess() { - EntityInterface translated = mockEntity(); - EntityInterface untranslated = mockEntity(); + EntityInterface translated = mockEntity(); + EntityInterface untranslated = mockEntity(); RdfStorageInterface.EntityWriteRequest request = new RdfStorageInterface.EntityWriteRequest("table", translated.getId(), null); @@ -217,10 +217,10 @@ void preTranslationFailureIsNotOverwrittenByWriteSuccess() { @Test @DisplayName("bulk failure (non-breaker): bisect isolates the bad row, others succeed") void bulkFailureBisectIsolatesBadRow() { - EntityInterface a = mockEntity(); - EntityInterface b = mockEntity(); - EntityInterface c = mockEntity(); - List entities = List.of(a, b, c); + EntityInterface a = mockEntity(); + EntityInterface b = mockEntity(); + EntityInterface c = mockEntity(); + List> entities = List.of(a, b, c); // Any sub-batch containing the poison entity b fails (a real payload-shape // failure, NOT the circuit breaker); sub-batches without b succeed. Bisect @@ -228,7 +228,7 @@ void bulkFailureBisectIsolatesBadRow() { doThrow(new RuntimeException("payload broken on b")) .when(rdfRepository) .bulkCreateOrUpdate( - argThat((List list) -> list != null && list.contains(b)), + argThat((List> list) -> list != null && list.contains(b)), eq(RdfWriteMode.RECONCILE)); RdfBatchProcessor.BatchProcessingResult result = @@ -258,7 +258,7 @@ void perSourceIsolationStopsAfterFailureLimit() { collectionDAO, rdfRepository, new RdfIndexingRunContext(RdfWriteMode.RECONCILE, Set.of(), null, null, 2)); - List entities = + List> entities = List.of(mockEntity(), mockEntity(), mockEntity(), mockEntity(), mockEntity()); // The bulk relationship write fails, and so does every per-source retry: the @@ -284,7 +284,7 @@ void perSourceIsolationNotPenalisedBySuccess() { collectionDAO, rdfRepository, new RdfIndexingRunContext(RdfWriteMode.RECONCILE, Set.of(), null, null, 2)); - List entities = + List> entities = List.of(mockEntity(), mockEntity(), mockEntity(), mockEntity(), mockEntity()); // Only the initial bulk write fails; every per-source retry succeeds, so the @@ -315,11 +315,11 @@ void relationshipIsolationMaxFailuresComesFromAppConfiguration() { @Test @DisplayName("breaker opening mid-bisect stops all further attempts, remainder marked failed") void breakerOpeningMidBisectStopsFurtherAttempts() { - EntityInterface a = mockEntity(); - EntityInterface b = mockEntity(); - EntityInterface c = mockEntity(); - EntityInterface d = mockEntity(); - List entities = List.of(a, b, c, d); + EntityInterface a = mockEntity(); + EntityInterface b = mockEntity(); + EntityInterface c = mockEntity(); + EntityInterface d = mockEntity(); + List> entities = List.of(a, b, c, d); doThrow(new RuntimeException("bad model")) .when(rdfRepository) @@ -341,7 +341,7 @@ void breakerOpeningMidBisectStopsFurtherAttempts() { @Test @DisplayName("write budget exhaustion stops bisecting; remainder marked failed after one attempt") void writeBudgetExhaustionStopsBisecting() { - List entities = List.of(mockEntity(), mockEntity(), mockEntity()); + List> entities = List.of(mockEntity(), mockEntity(), mockEntity()); when(rdfRepository.batchWriteBudgetMs()).thenReturn(1L); // Burn past the 1 ms budget inside the first (and only) bulk attempt so @@ -372,7 +372,7 @@ void writeBudgetExhaustionStopsBisecting() { @Test @DisplayName("bulk failure + circuit breaker open: fallback SKIPPED, batch marked failed once") void bulkFailureWithBreakerOpenSkipsFallback() { - List entities = List.of(mockEntity(), mockEntity(), mockEntity()); + List> entities = List.of(mockEntity(), mockEntity(), mockEntity()); // The storage layer fast-fails with the typed breaker exception. The // bulk-fallback path MUST detect this and not retry per-entity (every @@ -396,7 +396,7 @@ void bulkFailureWithBreakerOpenSkipsFallback() { @Test @DisplayName("breaker exception wrapped in RuntimeException is still detected via cause chain") void wrappedBreakerExceptionDetectedViaCauseChain() { - List entities = List.of(mockEntity(), mockEntity()); + List> entities = List.of(mockEntity(), mockEntity()); // RdfRepository.bulkCreateOrUpdate catches and re-throws as a generic // RuntimeException("Failed to bulk create/update entities in RDF", e) @@ -418,7 +418,7 @@ void wrappedBreakerExceptionDetectedViaCauseChain() { @Test @DisplayName("stop signal raised BEFORE the bulk call skips writing entirely") void preBatchStopSignalSkipsBulkWrite() { - List entities = List.of(mockEntity(), mockEntity()); + List> entities = List.of(mockEntity(), mockEntity()); // Stop signal is hot before the loop checks it. RdfBatchProcessor.BatchProcessingResult result = @@ -443,10 +443,10 @@ void emptyEntityListShortCircuits() { @DisplayName( "bulk failure + stop signal raised mid-fallback: remaining per-entity attempts skipped") void stopSignalMidFallbackHonored() { - EntityInterface a = mockEntity(); - EntityInterface b = mockEntity(); - EntityInterface c = mockEntity(); - List entities = List.of(a, b, c); + EntityInterface a = mockEntity(); + EntityInterface b = mockEntity(); + EntityInterface c = mockEntity(); + List> entities = List.of(a, b, c); doThrow(new RuntimeException("bad model")) .when(rdfRepository) @@ -478,7 +478,7 @@ void stopSignalMidFallbackHonored() { @Test @DisplayName("relationships whose endpoint is an excluded entity type (aiChart) are filtered out") void relationshipsToExcludedEntityTypesAreSkipped() { - EntityInterface dashboard = mockEntity(); + EntityInterface dashboard = mockEntity(); EntityRelationshipObject aiChartEdge = EntityRelationshipObject.builder() @@ -519,7 +519,7 @@ void insertOnlyContextIsPropagated() { collectionDAO, rdfRepository, new RdfIndexingRunContext(RdfWriteMode.INSERT_ONLY, Set.of("table"))); - List entities = List.of(mockEntity()); + List> entities = List.of(mockEntity()); processor.processEntities("table", entities, null); @@ -535,9 +535,9 @@ void insertOnlyModeIsPreservedByBisectedWrites() { collectionDAO, rdfRepository, new RdfIndexingRunContext(RdfWriteMode.INSERT_ONLY, Set.of("table"))); - EntityInterface a = mockEntity(); - EntityInterface b = mockEntity(); - List entities = List.of(a, b); + EntityInterface a = mockEntity(); + EntityInterface b = mockEntity(); + List> entities = List.of(a, b); doThrow(new RuntimeException("bulk payload rejected")) .when(rdfRepository) .bulkCreateOrUpdate(entities, RdfWriteMode.INSERT_ONLY); @@ -564,8 +564,8 @@ void incomingLineageIsDeduplicatedForIndexedSourceType() { new RdfIndexingRunContext(RdfWriteMode.INSERT_ONLY, Set.of("table"))); UUID fromId = UUID.randomUUID(); UUID toId = UUID.randomUUID(); - EntityInterface from = mock(EntityInterface.class); - EntityInterface to = mock(EntityInterface.class); + EntityInterface from = mock(EntityInterface.class); + EntityInterface to = mock(EntityInterface.class); when(from.getId()).thenReturn(fromId); when(to.getId()).thenReturn(toId); EntityRelationshipObject lineage = lineage(fromId, toId); @@ -590,7 +590,7 @@ void incomingLineageIsDeduplicatedForIndexedSourceType() { void legacyContextProcessesIncomingLineage() { UUID fromId = UUID.randomUUID(); UUID toId = UUID.randomUUID(); - EntityInterface to = mock(EntityInterface.class); + EntityInterface to = mock(EntityInterface.class); when(to.getId()).thenReturn(toId); when(relationshipDAO.findToBatchWithRelations(anyList(), anyString(), anyList())) .thenReturn(List.of()); @@ -612,7 +612,7 @@ void lineageFallbackIsolatesBadEdge() { UUID fromId = UUID.randomUUID(); UUID goodTargetId = UUID.randomUUID(); UUID badTargetId = UUID.randomUUID(); - EntityInterface source = mock(EntityInterface.class); + EntityInterface source = mock(EntityInterface.class); when(source.getId()).thenReturn(fromId); when(relationshipDAO.findToBatchWithRelations(anyList(), anyString(), anyList())) .thenReturn(List.of(lineage(fromId, goodTargetId), lineage(fromId, badTargetId))); @@ -644,7 +644,7 @@ void lineageFallbackStopsWhenCircuitBreakerOpens() { UUID fromId = UUID.randomUUID(); UUID firstTargetId = UUID.randomUUID(); UUID secondTargetId = UUID.randomUUID(); - EntityInterface source = mock(EntityInterface.class); + EntityInterface source = mock(EntityInterface.class); when(source.getId()).thenReturn(fromId); when(relationshipDAO.findToBatchWithRelations(anyList(), anyString(), anyList())) .thenReturn(List.of(lineage(fromId, firstTargetId), lineage(fromId, secondTargetId))); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/rdf/RdfIndexAppTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/rdf/RdfIndexAppTest.java index f37f940576ae..289ee23c03e8 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/rdf/RdfIndexAppTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/rdf/RdfIndexAppTest.java @@ -874,9 +874,9 @@ void testExecuteClearsRdfDataWhenRecreateIndexEnabled() throws Exception { jobDataField.set(testApp, jobConfig); @SuppressWarnings("unchecked") - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); @SuppressWarnings("unchecked") - EntityDAO entityDAO = mock(EntityDAO.class); + EntityDAO> entityDAO = mock(EntityDAO.class); when(repository.getDao()).thenReturn(entityDAO); when(entityDAO.listTotalCount()).thenReturn(0); @@ -960,9 +960,9 @@ private EventPublisherJob executeInPlaceRebuild() throws Exception { jobDataField.set(testApp, jobConfig); @SuppressWarnings("unchecked") - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); @SuppressWarnings("unchecked") - EntityDAO entityDAO = mock(EntityDAO.class); + EntityDAO> entityDAO = mock(EntityDAO.class); lenient().when(repository.getDao()).thenReturn(entityDAO); lenient().when(entityDAO.listTotalCount()).thenReturn(0); @@ -996,9 +996,9 @@ void testCompactStorageStillFiresOnIncrementalIndex() throws Exception { jobDataField.set(testApp, jobConfig); @SuppressWarnings("unchecked") - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); @SuppressWarnings("unchecked") - EntityDAO entityDAO = mock(EntityDAO.class); + EntityDAO> entityDAO = mock(EntityDAO.class); lenient().when(repository.getDao()).thenReturn(entityDAO); lenient().when(entityDAO.listTotalCount()).thenReturn(0); @@ -1037,9 +1037,9 @@ void testInitializeJobClearsGlossaryRelationsWhenIncremental() throws Exception jobDataField.set(testApp, jobConfig); @SuppressWarnings("unchecked") - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); @SuppressWarnings("unchecked") - EntityDAO entityDAO = mock(EntityDAO.class); + EntityDAO> entityDAO = mock(EntityDAO.class); lenient().when(repository.getDao()).thenReturn(entityDAO); lenient().when(entityDAO.listTotalCount()).thenReturn(0); @@ -1081,9 +1081,9 @@ void testInitializeJobSkipsGlossaryClearWhenNoGlossaryEntity() throws Exception jobDataField.set(testApp, jobConfig); @SuppressWarnings("unchecked") - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); @SuppressWarnings("unchecked") - EntityDAO entityDAO = mock(EntityDAO.class); + EntityDAO> entityDAO = mock(EntityDAO.class); lenient().when(repository.getDao()).thenReturn(entityDAO); lenient().when(entityDAO.listTotalCount()).thenReturn(0); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/rdf/RdfReindexerTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/rdf/RdfReindexerTest.java index a37bb9cfd394..337f5c52c108 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/rdf/RdfReindexerTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/rdf/RdfReindexerTest.java @@ -203,8 +203,8 @@ public List readPage(final KeysetCursor after, final int limit) { } @Override - public ResultList load(final List page) { - final List entities = new ArrayList<>(); + public ResultList> load(final List page) { + final List> entities = new ArrayList<>(); final List errors = new ArrayList<>(); for (final String row : page) { if (unreadable.contains(row)) { @@ -242,8 +242,8 @@ private static final class RecordingWriter implements RdfReindexer.BatchWriter { @Override public CompletableFuture submit( - final String entityType, final List entities) { - final List names = entities.stream().map(EntityInterface::getName).toList(); + final String entityType, final List> entities) { + final List names = entities.stream().map(EntityInterface::getName).toList(); return CompletableFuture.supplyAsync( () -> { if (rejectContaining != null && names.contains(rejectContaining)) { diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/rdf/sink/RdfBulkSinkTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/rdf/sink/RdfBulkSinkTest.java index 3c511b6096d4..3f3bad9a6a93 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/rdf/sink/RdfBulkSinkTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/rdf/sink/RdfBulkSinkTest.java @@ -70,11 +70,11 @@ void tearDown() { sink.close(); } - private List batchOf(int size) { + private List> batchOf(int size) { return java.util.stream.IntStream.range(0, size) - .mapToObj( + .>mapToObj( i -> { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); lenient().when(entity.getId()).thenReturn(UUID.randomUUID()); return entity; }) @@ -243,7 +243,8 @@ void translationTimeIsReportedAsProcessTime() throws Exception { .thenReturn(new RdfBatchProcessor.BatchProcessingResult(1, 0)); RdfBatchProcessor.BatchProcessingResult result = - sink.submit("table", List.of(mock(EntityInterface.class))).get(30, TimeUnit.SECONDS); + sink.submit("table", List.>of(mock(EntityInterface.class))) + .get(30, TimeUnit.SECONDS); // Previously always 0: the run record showed no translation cost at all. assertTrue( diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchBulkSinkBehaviorTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchBulkSinkBehaviorTest.java index 6ebe0bc3d0e7..a06bf04a5a4b 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchBulkSinkBehaviorTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchBulkSinkBehaviorTest.java @@ -115,7 +115,7 @@ void writeSkipsWhenIndexMappingMissingAndExtractsTrackersSafely() throws Excepti @Test void addEntityRecordsSuccessAndProcessStats() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); StageStatsTracker tracker = mock(StageStatsTracker.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); @@ -168,7 +168,7 @@ void addEntityRecordsSuccessAndProcessStats() throws Exception { @Test void relationshipPartialUpdateUsesFullDocumentUpsertWithoutRewritingOtherFields() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); when(entity.getEntityReference()) @@ -336,7 +336,7 @@ void oversizedScriptedUpdateIsSentDirectlyInsteadOfPoisoningTheBulkBatch() throw @Test void fullTestCaseDocumentUsesRelationshipPreservingUpdate() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); SearchRepository.ScriptedPartialUpdate documentUpdate = @@ -403,7 +403,7 @@ void fullTestCaseDocumentUsesRelationshipPreservingUpdate() throws Exception { @Test void addEntityRecordsEntityNotFoundWarningsWithoutCallback() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); StageStatsTracker tracker = mock(StageStatsTracker.class); BulkSink.FailureCallback failureCallback = mock(BulkSink.FailureCallback.class); UUID entityId = UUID.randomUUID(); @@ -609,7 +609,7 @@ void settersUpdateConfigurationAndForwardFailureCallbacks() { @Test void addEntityLooksUpEntityContextFromMap() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); List edges = List.of(new EsLineageData()); @@ -658,7 +658,7 @@ void addEntityLooksUpEntityContextFromMap() throws Exception { @Test void addEntityFallsBackToEmptyContextWhenEntityNotInMap() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); when(entity.getId()).thenReturn(UUID.randomUUID()); try (MockedConstruction ignored = @@ -705,7 +705,7 @@ void enrichWithEmbeddingReusesCachedFieldsWhenServiceReportsMatch() throws Excep // P1 guard: on an incremental reindex the doc is re-indexed via a full index op, so a // state-matched entity must carry its cached embedding spliced back in — never embedding-less // (which would wipe the stored vector). Mirrors the OpenSearch sink test. - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); // A real entity always resolves a reference; the bulk sink consults it via @@ -751,7 +751,7 @@ void enrichWithEmbeddingReusesCachedFieldsWhenServiceReportsMatch() throws Excep @Test void enrichWithEmbeddingRecomputesWhenNoCachedEntryAvailable() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); when(entity.getId()).thenReturn(UUID.randomUUID()); // A real entity always resolves a reference; the bulk sink consults it via // Entity.isVectorEmbeddable to keep restricted ContextMemory out of the vector index. @@ -789,7 +789,7 @@ void enrichWithEmbeddingRecomputesWhenNoCachedEntryAvailable() throws Exception @Test void enrichWithEmbeddingRecomputesWhenCachedDimensionMismatchesClient() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); // A real entity always resolves a reference; the bulk sink consults it via diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchBulkSinkColumnBackpressureTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchBulkSinkColumnBackpressureTest.java index 397e30ed073d..84221c531b97 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchBulkSinkColumnBackpressureTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchBulkSinkColumnBackpressureTest.java @@ -62,7 +62,7 @@ void columnIndexingAppliesBackpressureAtTheInFlightCap() throws Exception { new ElasticSearchBulkSink(searchRepository, 10, 2, 1_000L) { @Override protected void indexTableColumns( - EntityInterface entity, ReindexContext reindexContext) { + EntityInterface entity, ReindexContext reindexContext) { started.incrementAndGet(); try { gate.await(30, TimeUnit.SECONDS); @@ -124,8 +124,8 @@ private Thread newProducer( "column-submit-producer"); } - private EntityInterface tableEntity(int index) { - EntityInterface entity = mock(EntityInterface.class); + private EntityInterface tableEntity(int index) { + EntityInterface entity = mock(EntityInterface.class); when(entity.getId()).thenReturn(UUID.randomUUID()); when(entity.getName()).thenReturn("table-" + index); return entity; diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchIndexSinkTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchIndexSinkTest.java index ed96f4ed93ef..8ee570fbe0eb 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchIndexSinkTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchIndexSinkTest.java @@ -61,7 +61,7 @@ void setUp() { @Test void writeDoesNotSendEmptyOverflowBatchAndCountsEntitySuccessOnce() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); @@ -110,8 +110,8 @@ void writeHandlesTimeSeriesEntitiesWithoutDoubleCounting() throws Exception { @Test void writeTracksBulkItemFailuresWithoutDoubleCountingStats() { - EntityInterface firstEntity = mock(EntityInterface.class); - EntityInterface secondEntity = mock(EntityInterface.class); + EntityInterface firstEntity = mock(EntityInterface.class); + EntityInterface secondEntity = mock(EntityInterface.class); when(firstEntity.getId()).thenReturn(UUID.randomUUID()); when(secondEntity.getId()).thenReturn(UUID.randomUUID()); @@ -144,7 +144,7 @@ void writeTracksBulkItemFailuresWithoutDoubleCountingStats() { @Test void writeTracksConversionFailuresWithoutDoubleCountingBulkResults() { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); when(entity.getId()).thenReturn(UUID.randomUUID()); try (MockedConstruction asyncConstruction = @@ -173,7 +173,7 @@ void writeTracksConversionFailuresWithoutDoubleCountingBulkResults() { @Test void writeThrowsWhenInterruptedWhileWaitingForPendingBulkResponses() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); when(entity.getId()).thenReturn(UUID.randomUUID()); try (MockedConstruction asyncConstruction = diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchBulkSinkBehaviorTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchBulkSinkBehaviorTest.java index 52a8e5915044..e2a241408c84 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchBulkSinkBehaviorTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchBulkSinkBehaviorTest.java @@ -118,7 +118,7 @@ void writeSkipsWhenIndexMappingMissingAndExtractsTrackersSafely() throws Excepti @Test void addEntityRecordsSuccessAndProcessStats() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); StageStatsTracker tracker = mock(StageStatsTracker.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); @@ -169,7 +169,7 @@ void addEntityRecordsSuccessAndProcessStats() throws Exception { @Test void relationshipPartialUpdateUsesVectorEnrichedFullUpsertWithoutRewritingOtherFields() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); when(entity.getEntityReference()) @@ -351,7 +351,7 @@ void oversizedScriptedUpdateIsSentDirectlyInsteadOfPoisoningTheBulkBatch() throw @Test void fullTestCaseDocumentUsesRelationshipPreservingUpdate() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); SearchRepository.ScriptedPartialUpdate documentUpdate = @@ -414,7 +414,7 @@ void fullTestCaseDocumentUsesRelationshipPreservingUpdate() throws Exception { @Test void addEntityRecordsEntityNotFoundWarningsWithoutCallback() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); StageStatsTracker tracker = mock(StageStatsTracker.class); BulkSink.FailureCallback failureCallback = mock(BulkSink.FailureCallback.class); UUID entityId = UUID.randomUUID(); @@ -597,7 +597,7 @@ void settersUpdateConfigurationAndForwardCallbacks() { @Test void addEntityLooksUpEntityContextFromMap() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); List edges = List.of(new EsLineageData()); @@ -646,7 +646,7 @@ void addEntityLooksUpEntityContextFromMap() throws Exception { void enrichWithEmbeddingReusesCachedFieldsWhenServiceReportsMatch() throws Exception { // The service-layer two-step fetch already pre-filters to fingerprint matches; if an entry is // present in the map, the splice path is taken without any further fingerprint check. - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); // A real entity always resolves a reference; the bulk sink consults it via @@ -704,7 +704,7 @@ void enrichWithEmbeddingReusesCachedFieldsWhenServiceReportsMatch() throws Excep @Test void addEntityFallsBackToEmptyContextWhenEntityNotInMap() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); when(entity.getId()).thenReturn(UUID.randomUUID()); try (MockedConstruction ignored = @@ -753,7 +753,7 @@ void addEntityFallsBackToEmptyContextWhenEntityNotInMap() throws Exception { private static List> stubRecompute( MockedStatic docBuilderMock, MockedStatic vectorServiceMock, - EntityInterface entity, + EntityInterface entity, String fingerprint, List embedding, String textToEmbed) { @@ -785,7 +785,7 @@ private static EmbeddingClient availableClient() { void enrichWithEmbeddingRecomputesWhenNoCachedEntryAvailable() throws Exception { // When the service-layer fetch returns nothing for this entity (cache miss or fingerprint // mismatch filtered upstream), the call site must regenerate embeddings. - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); // A real entity always resolves a reference; the bulk sink consults it via @@ -843,7 +843,7 @@ void enrichWithEmbeddingRecomputesWhenNoCachedEntryAvailable() throws Exception void enrichWithEmbeddingRecomputesWhenCachedEntryHasNoEmbedding() throws Exception { // Defensive: even if the service layer ever admits an entry without an embedding (e.g. a doc // indexed before embeddings were enabled), the splice site must not blindly trust it. - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); // A real entity always resolves a reference; the bulk sink consults it via @@ -896,7 +896,7 @@ void enrichWithEmbeddingRecomputesWhenCachedEntryHasNoEmbedding() throws Excepti void enrichWithEmbeddingRecomputesWhenCachedNodeIsNotAnObject() throws Exception { // Defensive: a malformed _source (array or scalar instead of object) must not crash the splice // path; we fall through to regeneration. - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); // A real entity always resolves a reference; the bulk sink consults it via @@ -952,7 +952,7 @@ void enrichWithEmbeddingRecomputesWhenCachedDimensionMismatchesClient() throws E // active client's dimension must be regenerated — otherwise an old-dimension vector would be // spliced into a staged index built for the new dimension and silently rejected by the knn // field. This is the recreate-after-model-change dimension mismatch. - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); // A real entity always resolves a reference; the bulk sink consults it via @@ -1019,7 +1019,7 @@ void enrichWithEmbeddingSkipsGenerationWhenProviderUnavailable() throws Exceptio // Circuit open (provider unavailable): index the entity without embeddings and count it a // success, never calling the provider or writing chunks — a transient outage must not fail // every entity in the reindex. The embedding self-heals on the next run. - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); // A real entity always resolves a reference; the bulk sink consults it via diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchBulkSinkColumnBackpressureTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchBulkSinkColumnBackpressureTest.java index 1e9c54ca7867..7e8dfb26c17e 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchBulkSinkColumnBackpressureTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchBulkSinkColumnBackpressureTest.java @@ -65,7 +65,7 @@ void columnIndexingAppliesBackpressureAtTheInFlightCap() throws Exception { new OpenSearchBulkSink(searchRepository, 10, 2, 1_000L) { @Override protected void indexTableColumns( - EntityInterface entity, ReindexContext reindexContext) { + EntityInterface entity, ReindexContext reindexContext) { started.incrementAndGet(); try { gate.await(30, TimeUnit.SECONDS); @@ -130,8 +130,8 @@ private Thread newProducer( "column-submit-producer"); } - private EntityInterface tableEntity(int index) { - EntityInterface entity = mock(EntityInterface.class); + private EntityInterface tableEntity(int index) { + EntityInterface entity = mock(EntityInterface.class); when(entity.getId()).thenReturn(UUID.randomUUID()); when(entity.getName()).thenReturn("table-" + index); return entity; diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchIndexSinkTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchIndexSinkTest.java index 6873c5b5a7fd..b7f3a06fe176 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchIndexSinkTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchIndexSinkTest.java @@ -62,7 +62,7 @@ void setUp() { @Test void writeDoesNotSendEmptyOverflowBatchAndCountsEntitySuccessOnce() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); @@ -111,8 +111,8 @@ void writeHandlesTimeSeriesEntitiesWithoutDoubleCounting() throws Exception { @Test void writeTracksBulkItemFailuresWithoutDoubleCountingStats() throws Exception { - EntityInterface firstEntity = mock(EntityInterface.class); - EntityInterface secondEntity = mock(EntityInterface.class); + EntityInterface firstEntity = mock(EntityInterface.class); + EntityInterface secondEntity = mock(EntityInterface.class); UUID firstId = UUID.randomUUID(); UUID secondId = UUID.randomUUID(); when(firstEntity.getId()).thenReturn(firstId); @@ -147,7 +147,7 @@ void writeTracksBulkItemFailuresWithoutDoubleCountingStats() throws Exception { @Test void writeTracksConversionFailuresWithoutDoubleCountingBulkResults() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); @@ -177,7 +177,7 @@ void writeTracksConversionFailuresWithoutDoubleCountingBulkResults() throws Exce @Test void writeWrapsAsyncClientIoFailures() throws Exception { - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); UUID entityId = UUID.randomUUID(); when(entity.getId()).thenReturn(entityId); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/DistributedSearchIndexCoordinatorTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/DistributedSearchIndexCoordinatorTest.java index 832c1395e73c..b979ecf35139 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/DistributedSearchIndexCoordinatorTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/DistributedSearchIndexCoordinatorTest.java @@ -119,9 +119,9 @@ void tearDown() { @Test void precomputedPartitionCursorsUseRepositoryReindexFilter() throws Exception { @SuppressWarnings("unchecked") - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); @SuppressWarnings("unchecked") - EntityDAO dao = mock(EntityDAO.class); + EntityDAO> dao = mock(EntityDAO.class); ListFilter reindexFilter = mock(ListFilter.class); when(repository.getReindexFilter()).thenReturn(reindexFilter); when(repository.getDao()).thenReturn(dao); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/PartitionWorkerTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/PartitionWorkerTest.java index 702c9edc78da..e9ee8aaa4c74 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/PartitionWorkerTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/PartitionWorkerTest.java @@ -288,7 +288,7 @@ void testPartitionResultEquality() { @Test void initializeKeysetCursorHandlesRegularAndTimeSeriesEntities() throws Exception { @SuppressWarnings("unchecked") - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); ListFilter reindexFilter = mock(ListFilter.class); UUID jobId = UUID.randomUUID(); @@ -365,7 +365,7 @@ void initializeKeysetCursorHandlesRegularAndTimeSeriesEntities() throws Exceptio @Test void initializeKeysetCursorHitsPrecomputedCacheAndSkipsOffsetFallback() throws Exception { @SuppressWarnings("unchecked") - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); UUID jobId = UUID.randomUUID(); SearchIndexPartition partition = @@ -453,10 +453,10 @@ void processBatchWritesEntitiesAndRecordsReaderFailures() throws Exception { PartitionWorker batchWorker = new PartitionWorker(coordinator, bulkSink, BATCH_SIZE, stagedIndexContext, failureRecorder); - EntityInterface entityOne = mock(EntityInterface.class); - EntityInterface entityTwo = mock(EntityInterface.class); + EntityInterface entityOne = mock(EntityInterface.class); + EntityInterface entityTwo = mock(EntityInterface.class); UUID errorEntityId = UUID.randomUUID(); - ResultList resultList = new ResultList<>(); + ResultList> resultList = new ResultList<>(); resultList.setData(List.of(entityOne, entityTwo)); resultList.setErrors( List.of(new EntityError().withEntity(errorEntityId).withMessage("reader failure"))); @@ -501,11 +501,11 @@ void processBatchExtractsIdFromEntityInterfaceForReaderFailure() throws Exceptio new PartitionWorker(coordinator, bulkSink, BATCH_SIZE, stagedIndexContext, failureRecorder); UUID errorEntityId = UUID.randomUUID(); - EntityInterface failingEntity = mock(EntityInterface.class); + EntityInterface failingEntity = mock(EntityInterface.class); when(failingEntity.getId()).thenReturn(errorEntityId); - EntityInterface successEntity = mock(EntityInterface.class); + EntityInterface successEntity = mock(EntityInterface.class); - ResultList resultList = new ResultList<>(); + ResultList> resultList = new ResultList<>(); resultList.setData(List.of(successEntity)); resultList.setErrors( List.of(new EntityError().withEntity(failingEntity).withMessage("reader failure"))); @@ -531,11 +531,11 @@ void processBatchSkipsReaderFailureWhenEntityInterfaceHasNullId() throws Excepti PartitionWorker batchWorker = new PartitionWorker(coordinator, bulkSink, BATCH_SIZE, stagedIndexContext, failureRecorder); - EntityInterface failingEntity = mock(EntityInterface.class); + EntityInterface failingEntity = mock(EntityInterface.class); when(failingEntity.getId()).thenReturn(null); - EntityInterface successEntity = mock(EntityInterface.class); + EntityInterface successEntity = mock(EntityInterface.class); - ResultList resultList = new ResultList<>(); + ResultList> resultList = new ResultList<>(); resultList.setData(List.of(successEntity)); resultList.setErrors( List.of(new EntityError().withEntity(failingEntity).withMessage("reader failure"))); @@ -557,7 +557,7 @@ void processBatchSkipsReaderFailureWhenEntityInterfaceHasNullId() throws Excepti void processBatchWrapsSinkFailuresAsSearchIndexException() throws Exception { PartitionWorker batchWorker = new PartitionWorker(coordinator, bulkSink, BATCH_SIZE, stagedIndexContext); - ResultList resultList = new ResultList<>(); + ResultList> resultList = new ResultList<>(); resultList.setData(List.of(mock(EntityInterface.class))); try (MockedConstruction ignored = @@ -590,7 +590,7 @@ void readEntitiesKeysetPassesSelectiveFieldsNotWildcard() throws Exception { // single-server path. We stub the helper here so the test stays focused on the // PartitionWorker invocation contract; ReindexingUtilTest covers the helper's own // filter/fallback logic. - ResultList resultList = new ResultList<>(); + ResultList> resultList = new ResultList<>(); resultList.setData(List.of(mock(EntityInterface.class))); AtomicReference> constructorArgs = new AtomicReference<>(); List selectiveFields = List.of("owners", "domains", "tags", "dataModel"); @@ -756,7 +756,7 @@ void processPartitionKeepsProgressStatusProcessingAndCompletesSuccessfully() { new PartitionWorker(coordinator, bulkSink, BATCH_SIZE, stagedIndexContext); SearchIndexPartition partition = buildPartition("table", 0, 2); - ResultList resultList = new ResultList<>(); + ResultList> resultList = new ResultList<>(); resultList.setData(List.of(mock(EntityInterface.class), mock(EntityInterface.class))); when(coordinator.getCollectionDAO()).thenReturn(collectionDAO); @@ -838,7 +838,7 @@ void processPartitionStopsAfterReadWhenStopRequestedMidLoop() { new PartitionWorker(coordinator, bulkSink, BATCH_SIZE, stagedIndexContext); SearchIndexPartition partition = buildPartition("table", 0, 2); - ResultList resultList = new ResultList<>(); + ResultList> resultList = new ResultList<>(); resultList.setData(List.of(mock(EntityInterface.class))); when(coordinator.getCollectionDAO()).thenReturn(collectionDAO); @@ -882,11 +882,11 @@ void processPartitionRecordsSinkFailuresAndStopsWhenCursorCannotBeRebuilt() thro new PartitionWorker(coordinator, bulkSink, 2, stagedIndexContext, failureRecorder); SearchIndexPartition partition = buildPartition("table", 0, 4); - ResultList resultList = new ResultList<>(); + ResultList> resultList = new ResultList<>(); resultList.setData(List.of(mock(EntityInterface.class))); @SuppressWarnings("unchecked") - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); when(coordinator.getCollectionDAO()).thenReturn(collectionDAO); when(collectionDAO.searchIndexServerStatsDAO()).thenReturn(searchIndexServerStatsDAO); @@ -933,7 +933,7 @@ void processPartitionAdjustsSuccessCountsForProcessFailures() { new PartitionWorker(coordinator, bulkSink, 2, stagedIndexContext); SearchIndexPartition partition = buildPartition("table", 0, 2); - ResultList resultList = new ResultList<>(); + ResultList> resultList = new ResultList<>(); resultList.setData(List.of(mock(EntityInterface.class), mock(EntityInterface.class))); StageCounter processCounter = new StageCounter(); processCounter.getCumulativeFailed().set(1); @@ -980,7 +980,7 @@ void processPartitionFailsPartitionWhenCompletionThrows() { new PartitionWorker(coordinator, bulkSink, 2, stagedIndexContext); SearchIndexPartition partition = buildPartition("table", 0, 1); - ResultList resultList = new ResultList<>(); + ResultList> resultList = new ResultList<>(); resultList.setData(List.of(mock(EntityInterface.class))); when(coordinator.getCollectionDAO()).thenReturn(collectionDAO); @@ -1014,7 +1014,7 @@ void processPartitionFailsPartitionWhenCompletionThrows() { @Test void processBatchReturnsEmptyResultWhenNoEntitiesAreRead() throws Exception { - ResultList emptyResult = new ResultList<>(); + ResultList> emptyResult = new ResultList<>(); emptyResult.setData(List.of()); try (MockedConstruction ignored = @@ -1033,7 +1033,7 @@ void processBatchReturnsEmptyResultWhenNoEntitiesAreRead() throws Exception { @Test void initializeKeysetCursorReturnsNullWhenRepositoryCursorMissing() throws Exception { @SuppressWarnings("unchecked") - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); SearchIndexPartition partition = SearchIndexPartition.builder() diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/context/center/ContextMemoryExtractorTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/context/center/ContextMemoryExtractorTest.java index b2f460b7be32..43c4e6a67dac 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/context/center/ContextMemoryExtractorTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/context/center/ContextMemoryExtractorTest.java @@ -17,9 +17,9 @@ import org.openmetadata.schema.entity.context.ContextMemory; import org.openmetadata.schema.entity.context.ContextMemoryScope; import org.openmetadata.schema.entity.context.ContextMemorySourceType; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.MemoryVisibility; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.service.Entity; import org.openmetadata.service.llm.LLMCompletionClient; import org.openmetadata.service.llm.LLMCompletionException; @@ -59,7 +59,7 @@ void createsOneMemoryPerExtractedPill() { assertEquals(source.getId(), first.getPrimaryEntity().getId()); assertEquals(ContextMemoryScope.ENTITY_SCOPED, first.getMemoryScope()); assertEquals(MemoryVisibility.ENTITY, first.getShareConfig().getVisibility()); - assertEquals(EntityStatus.APPROVED, first.getEntityStatus()); + assertEquals(ContextMemoryStatus.APPROVED, first.getEntityStatus()); assertEquals("Q1", first.getQuestion()); } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/context/center/ContextMemoryReconcilerTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/context/center/ContextMemoryReconcilerTest.java index ec1a98dc4b72..65bb78750134 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/context/center/ContextMemoryReconcilerTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/context/center/ContextMemoryReconcilerTest.java @@ -21,10 +21,10 @@ import org.openmetadata.schema.entity.context.ContextMemory; import org.openmetadata.schema.entity.context.ContextMemoryScope; import org.openmetadata.schema.entity.context.ContextMemorySourceType; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.MemoryShareConfig; import org.openmetadata.schema.entity.context.MemoryVisibility; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.service.Entity; import org.openmetadata.service.jdbi3.ContextMemoryRepository; @@ -37,7 +37,7 @@ class ContextMemoryReconcilerTest { new EntityReference().withId(UUID.randomUUID()).withName("page").withType(Entity.PAGE); private ContextMemory pill( - String question, String answer, ContextMemorySourceType type, EntityStatus status) { + String question, String answer, ContextMemorySourceType type, ContextMemoryStatus status) { return new ContextMemory() .withId(UUID.randomUUID()) .withName(question) @@ -51,7 +51,8 @@ private ContextMemory pill( } private ContextMemory derived(String question, String answer) { - return pill(question, answer, ContextMemorySourceType.PAGE_EXTRACTION, EntityStatus.APPROVED); + return pill( + question, answer, ContextMemorySourceType.PAGE_EXTRACTION, ContextMemoryStatus.APPROVED); } private void existing(ContextMemory... pills) { @@ -73,7 +74,7 @@ void rephrasedQuestionKeepsThePillInsteadOfChurningIt() { "The Payments Platform team owns the checkout on-call rotation and escalates to the" + " Commerce Director after 30 minutes without acknowledgement.", ContextMemorySourceType.PAGE_EXTRACTION, - EntityStatus.APPROVED); + ContextMemoryStatus.APPROVED); stored.setUsageCount(42); existing(stored); @@ -105,7 +106,7 @@ void unrelatedFactDoesNotClaimAnExistingPill() { "How are incidents announced to the business?", "Paging happens through Opsgenie, never through Slack alone.", ContextMemorySourceType.PAGE_EXTRACTION, - EntityStatus.APPROVED); + ContextMemoryStatus.APPROVED); existing(stored); ContextMemoryReconciler.ReconcileResult result = @@ -133,7 +134,8 @@ void createsAllWhenNoExistingPills() { @Test void keepsUnchangedPillWithoutUpdateOrReembed() { - existing(pill("Q1", "A1", ContextMemorySourceType.PAGE_EXTRACTION, EntityStatus.APPROVED)); + existing( + pill("Q1", "A1", ContextMemorySourceType.PAGE_EXTRACTION, ContextMemoryStatus.APPROVED)); ContextMemoryReconciler.ReconcileResult result = reconcile(List.of(derived("Q1", "A1"))); @@ -145,9 +147,9 @@ void keepsUnchangedPillWithoutUpdateOrReembed() { @ParameterizedTest @EnumSource( - value = EntityStatus.class, + value = ContextMemoryStatus.class, names = {"DRAFT", "ARCHIVED", "DEPRECATED", "REJECTED"}) - void reExtractionLeavesAPillOutsideApprovedAsIs(EntityStatus retired) { + void reExtractionLeavesAPillOutsideApprovedAsIs(ContextMemoryStatus retired) { existing( pill("Q1", "A1", ContextMemorySourceType.PAGE_EXTRACTION, retired), pill("Q2", "A2", ContextMemorySourceType.PAGE_EXTRACTION, retired)); @@ -163,7 +165,7 @@ void reExtractionLeavesAPillOutsideApprovedAsIs(EntityStatus retired) { @Test void updatesPillInPlaceWhenAnswerChanges() { ContextMemory original = - pill("Q1", "old", ContextMemorySourceType.PAGE_EXTRACTION, EntityStatus.APPROVED); + pill("Q1", "old", ContextMemorySourceType.PAGE_EXTRACTION, ContextMemoryStatus.APPROVED); existing(original); ContextMemoryReconciler.ReconcileResult result = reconcile(List.of(derived("Q1", "new"))); @@ -179,7 +181,7 @@ void updatesPillInPlaceWhenAnswerChanges() { @Test void deletesPillNoLongerDerived() { ContextMemory gone = - pill("gone", "A", ContextMemorySourceType.PAGE_EXTRACTION, EntityStatus.APPROVED); + pill("gone", "A", ContextMemorySourceType.PAGE_EXTRACTION, ContextMemoryStatus.APPROVED); existing(gone); ContextMemoryReconciler.ReconcileResult result = reconcile(List.of(derived("fresh", "A"))); @@ -192,7 +194,7 @@ void deletesPillNoLongerDerived() { @Test void neverTouchesManuallyEditedPillAndDoesNotDuplicateIt() { - existing(pill("Q1", "human", ContextMemorySourceType.MANUAL, EntityStatus.APPROVED)); + existing(pill("Q1", "human", ContextMemorySourceType.MANUAL, ContextMemoryStatus.APPROVED)); ContextMemoryReconciler.ReconcileResult result = reconcile(List.of(derived("Q1", "llm answer"), derived("Q2", "A2"))); @@ -213,7 +215,7 @@ void keepsPillIdentityWhenTheQuestionIsRephrased() { "How should billing totals handle refunds?", "Filter to amount > 0 to exclude refunds from totals.", ContextMemorySourceType.PAGE_EXTRACTION, - EntityStatus.APPROVED); + ContextMemoryStatus.APPROVED); existing(original); ContextMemoryReconciler.ReconcileResult result = @@ -264,7 +266,7 @@ void reusesEquivalentMemoryForAnotherFile() { "What is the retention window?", "Events are retained for 90 days.", ContextMemorySourceType.FILE_EXTRACTION, - EntityStatus.APPROVED); + ContextMemoryStatus.APPROVED); ContextMemoryReconciler reconciler = new ContextMemoryReconciler(memoryRepository, ignored -> equivalent); @@ -287,7 +289,7 @@ void changedSharedFactLeavesOtherSourceMemoryIntact() { "How long are events retained?", "Events are retained for 90 days.", ContextMemorySourceType.PAGE_EXTRACTION, - EntityStatus.APPROVED); + ContextMemoryStatus.APPROVED); existing(shared); when(memoryRepository.hasOtherSources(shared.getId(), source)).thenReturn(true); @@ -317,7 +319,7 @@ void identicalSourceLinksAllExistingMemories() { "What is the retention window?", "Events are retained for 90 days.", ContextMemorySourceType.FILE_EXTRACTION, - EntityStatus.APPROVED); + ContextMemoryStatus.APPROVED); when(memoryRepository.listExtractedMemories(original.getId(), Entity.CONTEXT_FILE)) .thenReturn(List.of(memory)); @@ -332,7 +334,7 @@ void identicalSourceLinksAllExistingMemories() { @Test void rederivationRepairsLegacyPillVisibilityAndScope() { ContextMemory legacy = - pill("Q", "A", ContextMemorySourceType.PAGE_EXTRACTION, EntityStatus.APPROVED); + pill("Q", "A", ContextMemorySourceType.PAGE_EXTRACTION, ContextMemoryStatus.APPROVED); legacy.setMemoryScope(null); legacy.setPrimaryEntity(null); legacy.setShareConfig(new MemoryShareConfig().withVisibility(MemoryVisibility.SHARED)); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/context/center/SemanticMemoryDuplicateFinderTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/context/center/SemanticMemoryDuplicateFinderTest.java index 701b541fa66b..fa65298b4423 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/context/center/SemanticMemoryDuplicateFinderTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/context/center/SemanticMemoryDuplicateFinderTest.java @@ -25,10 +25,10 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.openmetadata.schema.entity.context.ContextMemory; import org.openmetadata.schema.entity.context.ContextMemorySourceType; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.MemoryShareConfig; import org.openmetadata.schema.entity.context.MemoryVisibility; import org.openmetadata.schema.search.SearchRequest; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.Include; import org.openmetadata.service.jdbi3.ContextMemoryRepository; import org.openmetadata.service.llm.LLMCompletionClient; @@ -54,7 +54,7 @@ private ContextMemory memory(UUID id, String question, String answer) { .withQuestion(question) .withAnswer(answer) .withSourceType(ContextMemorySourceType.FILE_EXTRACTION) - .withEntityStatus(EntityStatus.APPROVED) + .withEntityStatus(ContextMemoryStatus.APPROVED) .withShareConfig(new MemoryShareConfig().withVisibility(MemoryVisibility.ENTITY)); } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/events/lifecycle/EntityLifecycleEventDispatcherTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/events/lifecycle/EntityLifecycleEventDispatcherTest.java index 599ee503ffc5..afbdfbff1361 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/events/lifecycle/EntityLifecycleEventDispatcherTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/events/lifecycle/EntityLifecycleEventDispatcherTest.java @@ -42,7 +42,7 @@ @ExtendWith(MockitoExtension.class) class EntityLifecycleEventDispatcherTest { - @Mock private EntityInterface mockEntity; + @Mock private EntityInterface mockEntity; @Mock private EntityReference mockEntityRef; @Mock private ChangeDescription mockChangeDescription; @Mock private SubjectContext mockSubjectContext; @@ -221,7 +221,7 @@ void testHandlerPriorityOrdering() throws InterruptedException { TestHandler orderedAsyncHandler = new TestHandler("AsyncHandler", 200, true, Set.of()) { @Override - public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { + public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { super.onEntityCreated(entity, subjectContext); asyncLatch.countDown(); } @@ -270,7 +270,7 @@ void testAsyncHandlerExecution() throws InterruptedException { TestHandler asyncHandlerWithLatch = new TestHandler("AsyncWithLatch", 100, true, Set.of()) { @Override - public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { + public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { super.onEntityCreated(entity, subjectContext); latch.countDown(); } @@ -289,7 +289,7 @@ void testSyncHandlerException() { TestHandler faultyHandler = new TestHandler("FaultyHandler", 100, false, Set.of()) { @Override - public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { + public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { super.onEntityCreated(entity, subjectContext); throw new RuntimeException("Test exception"); } @@ -312,7 +312,7 @@ void testAsyncHandlerException() throws InterruptedException { TestHandler faultyAsyncHandler = new TestHandler("FaultyAsyncHandler", 100, true, Set.of()) { @Override - public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { + public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { super.onEntityCreated(entity, subjectContext); faultyLatch.countDown(); throw new RuntimeException("Async test exception"); @@ -322,7 +322,7 @@ public void onEntityCreated(EntityInterface entity, SubjectContext subjectContex TestHandler goodAsyncHandler = new TestHandler("GoodAsyncHandler", 200, true, Set.of()) { @Override - public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { + public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { super.onEntityCreated(entity, subjectContext); goodLatch.countDown(); } @@ -338,7 +338,7 @@ public void onEntityCreated(EntityInterface entity, SubjectContext subjectContex assertTrue(goodLatch.await(10, TimeUnit.SECONDS)); } - private EntityInterface createAsyncSafeEntity() { + private EntityInterface createAsyncSafeEntity() { Table entity = new Table(); UUID entityId = UUID.randomUUID(); entity.setId(entityId); @@ -395,7 +395,7 @@ void testOnEntitiesUpdatedUsesEntitySpecificChangeDescriptions() { TestHandler allEntitiesHandler = new TestHandler("AllEntitiesHandler", 100, false, Set.of()); dispatcher.registerHandler(allEntitiesHandler); - EntityInterface dashboardEntity = mock(EntityInterface.class); + EntityInterface dashboardEntity = mock(EntityInterface.class); ChangeDescription dashboardChangeDescription = mock(ChangeDescription.class); when(dashboardEntity.getChangeDescription()).thenReturn(dashboardChangeDescription); @@ -413,7 +413,7 @@ void testOnEntitiesUpdatedForwardsUpdateContextToSynchronousHandler() { new TestHandler("ContextHandler", 100, false, Set.of()) { @Override public void onEntitiesUpdated( - List entities, + List> entities, ChangeDescription changeDescription, SubjectContext subjectContext, EntityUpdateContext updateContext) { @@ -430,14 +430,14 @@ public void onEntitiesUpdated( @Test void testAsyncBulkCreateIsSlicedPerEntityForOwnLaneOrdering() throws InterruptedException { - List entities = + List> entities = List.of(asyncSafeEntity("a"), asyncSafeEntity("b"), asyncSafeEntity("c")); - List ids = entities.stream().map(EntityInterface::getId).toList(); + List ids = entities.stream().map(EntityInterface::getId).toList(); CountDownLatch allCreated = new CountDownLatch(entities.size()); TestHandler bulkAsyncHandler = new TestHandler("BulkAsyncHandler", 100, true, Set.of()) { @Override - public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { + public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { super.onEntityCreated(entity, subjectContext); allCreated.countDown(); } @@ -478,7 +478,7 @@ void asyncHandlersShareOneSnapshotPerEntity() throws InterruptedException { TestHandler asyncOne = new TestHandler("AsyncOne", 100, true, Set.of()) { @Override - public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { + public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { super.onEntityCreated(entity, subjectContext); bothRan.countDown(); } @@ -486,7 +486,7 @@ public void onEntityCreated(EntityInterface entity, SubjectContext subjectContex TestHandler asyncTwo = new TestHandler("AsyncTwo", 200, true, Set.of()) { @Override - public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { + public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { super.onEntityCreated(entity, subjectContext); bothRan.countDown(); } @@ -494,7 +494,7 @@ public void onEntityCreated(EntityInterface entity, SubjectContext subjectContex dispatcher.registerHandler(asyncOne); dispatcher.registerHandler(asyncTwo); - EntityInterface original = createAsyncSafeEntity(); + EntityInterface original = createAsyncSafeEntity(); dispatcher.onEntityCreated(original, mockSubjectContext); assertTrue(bothRan.await(10, TimeUnit.SECONDS), "Both async handlers should run"); @@ -561,13 +561,13 @@ public boolean shouldProcess(EventType eventType, ChangeDescription changeDescri @Test void asyncBulkCreateSharesOneSnapshotPerEntityAcrossHandlers() throws InterruptedException { - EntityInterface entityA = asyncSafeEntity("a"); - EntityInterface entityB = asyncSafeEntity("b"); + EntityInterface entityA = asyncSafeEntity("a"); + EntityInterface entityB = asyncSafeEntity("b"); CountDownLatch allRan = new CountDownLatch(4); TestHandler asyncOne = new TestHandler("BulkAsyncOne", 100, true, Set.of()) { @Override - public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { + public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { super.onEntityCreated(entity, subjectContext); allRan.countDown(); } @@ -575,7 +575,7 @@ public void onEntityCreated(EntityInterface entity, SubjectContext subjectContex TestHandler asyncTwo = new TestHandler("BulkAsyncTwo", 200, true, Set.of()) { @Override - public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { + public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { super.onEntityCreated(entity, subjectContext); allRan.countDown(); } @@ -622,14 +622,14 @@ void snapshotFailureRoutesToOutboxInsteadOfFailingTheCommittedRequest() { "Async handler is skipped on snapshot failure; the entity is routed to the retry outbox"); } - private static EntityInterface snapshotFor(TestHandler handler, UUID id) { + private static EntityInterface snapshotFor(TestHandler handler, UUID id) { return handler.receivedCreatedEntities.stream() .filter(entity -> entity != null && id.equals(entity.getId())) .findFirst() .orElseThrow(); } - private EntityInterface asyncSafeEntity(String suffix) { + private EntityInterface asyncSafeEntity(String suffix) { Table entity = new Table(); entity.setId(UUID.randomUUID()); entity.setName("test_table_" + suffix); @@ -698,14 +698,14 @@ private static class TestHandler implements EntityLifecycleEventHandler { int updatedCallCount = 0; final AtomicInteger createdCallCount = new AtomicInteger(0); - EntityInterface lastCreatedEntity; - EntityInterface lastUpdatedEntity; - EntityInterface lastDeletedEntity; + EntityInterface lastCreatedEntity; + EntityInterface lastUpdatedEntity; + EntityInterface lastDeletedEntity; ChangeDescription lastChangeDescription; boolean lastIsDeleted; List receivedChangeDescriptions = new ArrayList<>(); List perEntityCreatedIds = java.util.Collections.synchronizedList(new ArrayList<>()); - List receivedCreatedEntities = + List> receivedCreatedEntities = java.util.Collections.synchronizedList(new ArrayList<>()); TestHandler(String name, int priority, boolean async, Set supportedEntityTypes) { @@ -716,7 +716,7 @@ private static class TestHandler implements EntityLifecycleEventHandler { } @Override - public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { + public void onEntityCreated(EntityInterface entity, SubjectContext subjectContext) { createdCalled = true; createdCallCount.incrementAndGet(); lastCreatedEntity = entity; @@ -727,13 +727,14 @@ public void onEntityCreated(EntityInterface entity, SubjectContext subjectContex } @Override - public void onEntitiesCreated(List entities, SubjectContext subjectContext) { + public void onEntitiesCreated( + List> entities, SubjectContext subjectContext) { bulkCreatedCalled = true; } @Override public void onEntityUpdated( - EntityInterface entity, + EntityInterface entity, ChangeDescription changeDescription, SubjectContext subjectContext) { updatedCalled = true; @@ -744,14 +745,14 @@ public void onEntityUpdated( } @Override - public void onEntityDeleted(EntityInterface entity, SubjectContext subjectContext) { + public void onEntityDeleted(EntityInterface entity, SubjectContext subjectContext) { deletedCalled = true; lastDeletedEntity = entity; } @Override public void onEntitySoftDeletedOrRestored( - EntityInterface entity, boolean isDeleted, SubjectContext subjectContext) { + EntityInterface entity, boolean isDeleted, SubjectContext subjectContext) { softDeletedOrRestoredCalled = true; lastIsDeleted = isDeleted; } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/events/lifecycle/EntityLifecyclePostCommitTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/events/lifecycle/EntityLifecyclePostCommitTest.java index 690dd2652d9d..24e494f4302a 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/events/lifecycle/EntityLifecyclePostCommitTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/events/lifecycle/EntityLifecyclePostCommitTest.java @@ -48,7 +48,7 @@ void cleanup() { @Test void synchronousLifecycleHandlerRunsOnlyAfterCommit() { - final EntityInterface entity = mock(EntityInterface.class); + final EntityInterface entity = mock(EntityInterface.class); final EntityReference reference = new EntityReference().withId(UUID.randomUUID()).withType(Entity.GLOSSARY_TERM); when(entity.getId()).thenReturn(reference.getId()); @@ -66,7 +66,8 @@ private static final class RecordingHandler implements EntityLifecycleEventHandl private boolean created; @Override - public void onEntityCreated(final EntityInterface entity, final SubjectContext subjectContext) { + public void onEntityCreated( + final EntityInterface entity, final SubjectContext subjectContext) { created = true; } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/events/lifecycle/handlers/SearchIndexHandlerTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/events/lifecycle/handlers/SearchIndexHandlerTest.java index 237ac82dc0f3..b4b8ad2f2940 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/events/lifecycle/handlers/SearchIndexHandlerTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/events/lifecycle/handlers/SearchIndexHandlerTest.java @@ -37,8 +37,8 @@ class SearchIndexHandlerTest { @Mock private SearchRepository mockSearchRepository; - @Mock private EntityInterface mockEntity; - @Mock private EntityInterface mockEntity2; + @Mock private EntityInterface mockEntity; + @Mock private EntityInterface mockEntity2; @Mock private EntityReference mockEntityRef; @Mock private EntityReference mockEntityRef2; @Mock private ChangeDescription mockChangeDescription; @@ -128,7 +128,7 @@ void testOnEntityUpdatedWithEntityReference() { @Test void testOnEntitiesUpdatedUsesBulkApi() { - List entities = List.of(mockEntity, mockEntity2); + List> entities = List.of(mockEntity, mockEntity2); searchIndexHandler.onEntitiesUpdated(entities, mockChangeDescription, mockSubjectContext); @@ -138,7 +138,7 @@ void testOnEntitiesUpdatedUsesBulkApi() { @Test void testOnEntitiesUpdatedFallsBackToIndividualUpdates() { - List entities = List.of(mockEntity, mockEntity2); + List> entities = List.of(mockEntity, mockEntity2); doThrow(new RuntimeException("Bulk update failed")) .when(mockSearchRepository) .updateEntitiesIndex(entities, Map.of()); @@ -153,7 +153,7 @@ void testOnEntitiesUpdatedFallsBackToIndividualUpdates() { @Test void testOnEntitiesUpdatedForwardsRelationshipRevisions() { - List entities = List.of(mockEntity, mockEntity2); + List> entities = List.of(mockEntity, mockEntity2); Map revisions = Map.of(mockEntity.getId(), 11L, mockEntity2.getId(), 12L); searchIndexHandler.onEntitiesUpdated( @@ -165,7 +165,7 @@ void testOnEntitiesUpdatedForwardsRelationshipRevisions() { @Test void testOnEntitiesUpdatedRetainsRelationshipRevisionsInFallback() { - List entities = List.of(mockEntity, mockEntity2); + List> entities = List.of(mockEntity, mockEntity2); Map revisions = Map.of(mockEntity.getId(), 11L, mockEntity2.getId(), 12L); doThrow(new RuntimeException("Bulk update failed")) .when(mockSearchRepository) @@ -252,7 +252,7 @@ void testOnEntitiesCreatedEmpty() { @Test void testOnEntitiesCreatedSameType() throws IOException { - List entities = List.of(mockEntity, mockEntity2); + List> entities = List.of(mockEntity, mockEntity2); searchIndexHandler.onEntitiesCreated(entities, mockSubjectContext); @@ -265,7 +265,7 @@ void testOnEntitiesCreatedMixedTypes() throws IOException { // Setup different entity types when(mockEntityRef2.getType()).thenReturn(Entity.DASHBOARD); - List entities = List.of(mockEntity, mockEntity2); + List> entities = List.of(mockEntity, mockEntity2); searchIndexHandler.onEntitiesCreated(entities, mockSubjectContext); @@ -277,7 +277,7 @@ void testOnEntitiesCreatedMixedTypes() throws IOException { @Test void testOnEntitiesCreatedWithFallback() throws IOException { - List entities = List.of(mockEntity, mockEntity2); + List> entities = List.of(mockEntity, mockEntity2); // Make bulk operation fail doThrow(new RuntimeException("Bulk indexing failed")) diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/events/subscription/AlertUtilFilterIsolationTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/events/subscription/AlertUtilFilterIsolationTest.java index cd3e68758a1e..33b83842dcdf 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/events/subscription/AlertUtilFilterIsolationTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/events/subscription/AlertUtilFilterIsolationTest.java @@ -141,7 +141,7 @@ void getFilteredEvents_withoutAHandler_stillIsolatesTheFailure() { /** The deliverable event resolves its domain; the poison one fails the way a matcher bug does. */ private static void stubStore(MockedStatic entityMock) { - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); when(repository.isSupportsDomains()).thenReturn(true); entityMock.when(() -> Entity.getEntityClassFromType(Entity.TABLE)).thenReturn(Table.class); entityMock.when(() -> Entity.getEntityClassFromType(Entity.DOMAIN)).thenReturn(Domain.class); @@ -195,7 +195,7 @@ private static Map> batchOf(ChangeEvent... events) { return batch; } - private static ChangeEvent event(String entityType, UUID entityId, EntityInterface entity) { + private static ChangeEvent event(String entityType, UUID entityId, EntityInterface entity) { return new ChangeEvent() .withId(UUID.randomUUID()) .withEventType(EventType.ENTITY_UPDATED) diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/events/subscription/AlertsRuleEvaluatorTestSuiteDomainTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/events/subscription/AlertsRuleEvaluatorTestSuiteDomainTest.java index 74c7e0f055db..05215696025a 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/events/subscription/AlertsRuleEvaluatorTestSuiteDomainTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/events/subscription/AlertsRuleEvaluatorTestSuiteDomainTest.java @@ -79,15 +79,15 @@ private ChangeEvent testCaseEvent(TestCase payload) { } /** testCase declares domains; without this the #31331 guard skips the read under a static mock. */ - private static EntityRepository repositoryDeclaringDomains() { - EntityRepository repository = mock(EntityRepository.class); + private static EntityRepository> repositoryDeclaringDomains() { + EntityRepository> repository = mock(EntityRepository.class); when(repository.isSupportsDomains()).thenReturn(true); return repository; } @Test void matchesDomainCarriedOnlyByTheStoredTestSuite() { - EntityRepository repository = repositoryDeclaringDomains(); + EntityRepository> repository = repositoryDeclaringDomains(); try (MockedStatic entityMock = mockStatic(Entity.class, CALLS_REAL_METHODS)) { entityMock .when(() -> Entity.getEntityClassFromType(Entity.TEST_CASE)) @@ -123,7 +123,7 @@ void matchesDomainCarriedOnlyByTheStoredTestSuite() { @Test void doesNotMatchWhenNeitherTestCaseNorSuiteCarriesTheDomain() { - EntityRepository repository = repositoryDeclaringDomains(); + EntityRepository> repository = repositoryDeclaringDomains(); try (MockedStatic entityMock = mockStatic(Entity.class, CALLS_REAL_METHODS)) { entityMock .when(() -> Entity.getEntityClassFromType(Entity.TEST_CASE)) diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/events/subscription/AlertsRuleEvaluatorUndeclaredFieldTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/events/subscription/AlertsRuleEvaluatorUndeclaredFieldTest.java index 49bfb8307d6d..8a1abfdb02d7 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/events/subscription/AlertsRuleEvaluatorUndeclaredFieldTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/events/subscription/AlertsRuleEvaluatorUndeclaredFieldTest.java @@ -52,7 +52,7 @@ class AlertsRuleEvaluatorUndeclaredFieldTest { @Test void matchAnyDomain_entityTypeWithoutDomains_returnsFalseInsteadOfThrowing() { - EntityRepository repository = repositoryDeclaring(true, false); + EntityRepository> repository = repositoryDeclaring(true, false); try (MockedStatic entityMock = mockStatic(Entity.class, CALLS_REAL_METHODS)) { entityMock.when(() -> Entity.getEntityClassFromType(Entity.DOMAIN)).thenReturn(Domain.class); entityMock.when(() -> Entity.getEntityRepository(Entity.DOMAIN)).thenReturn(repository); @@ -67,7 +67,7 @@ void matchAnyDomain_entityTypeWithoutDomains_returnsFalseInsteadOfThrowing() { @Test void matchAnyOwnerName_entityTypeWithoutOwners_returnsFalseInsteadOfThrowing() { - EntityRepository repository = repositoryDeclaring(false, true); + EntityRepository> repository = repositoryDeclaring(false, true); try (MockedStatic entityMock = mockStatic(Entity.class, CALLS_REAL_METHODS)) { entityMock.when(() -> Entity.getEntityClassFromType(Entity.USER)).thenReturn(User.class); entityMock.when(() -> Entity.getEntityRepository(Entity.USER)).thenReturn(repository); @@ -82,7 +82,7 @@ void matchAnyOwnerName_entityTypeWithoutOwners_returnsFalseInsteadOfThrowing() { @Test void matchAnyDomain_entityTypeDeclaringDomains_stillResolvesThemFromTheStore() { - EntityRepository repository = repositoryDeclaring(true, true); + EntityRepository> repository = repositoryDeclaring(true, true); try (MockedStatic entityMock = mockStatic(Entity.class, CALLS_REAL_METHODS)) { entityMock.when(() -> Entity.getEntityClassFromType(Entity.TABLE)).thenReturn(Table.class); entityMock.when(() -> Entity.getEntityRepository(Entity.TABLE)).thenReturn(repository); @@ -125,15 +125,15 @@ private static void rejectUndeclaredRead( .thenThrow(new IllegalArgumentException("Invalid field name " + field)); } - private static EntityRepository repositoryDeclaring( + private static EntityRepository> repositoryDeclaring( boolean owners, boolean domains) { - EntityRepository repository = mock(EntityRepository.class); + EntityRepository> repository = mock(EntityRepository.class); when(repository.isSupportsOwners()).thenReturn(owners); when(repository.isSupportsDomains()).thenReturn(domains); return repository; } - private static ChangeEvent event(String entityType, EntityInterface entity) { + private static ChangeEvent event(String entityType, EntityInterface entity) { return new ChangeEvent() .withId(UUID.randomUUID()) .withEventType(EventType.ENTITY_UPDATED) diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/formatter/util/FormatterUtilTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/formatter/util/FormatterUtilTest.java index 6e4d8fc0004e..ab8290743437 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/formatter/util/FormatterUtilTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/formatter/util/FormatterUtilTest.java @@ -194,7 +194,7 @@ void getChangeEventFromResponseContextBuildsEntityEvents() { .withId(entityId) .withType(Entity.TABLE) .withFullyQualifiedName("service.sales.orders"); - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); when(entity.getId()).thenReturn(entityId); when(entity.getEntityReference()).thenReturn(entityRef); when(entity.getDomains()).thenReturn(List.of(new EntityReference().withId(UUID.randomUUID()))); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/governance/EntityLifecycleTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/governance/EntityLifecycleTest.java index 4c1701c903ba..0ff1cac21d3f 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/governance/EntityLifecycleTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/governance/EntityLifecycleTest.java @@ -5,19 +5,38 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +import java.util.EnumSet; +import java.util.HashMap; import java.util.Map; import java.util.Set; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.type.EntityStatus; class EntityLifecycleTest { - /** A lifecycle where a draft is reviewed before it is approved, and approval is final. */ - private static final EntityLifecycle REVIEWED = - new EntityLifecycle( + private enum ReviewedStatus { + DRAFT, + IN_REVIEW, + APPROVED + } + + private static final EntityLifecycle REVIEWED = + new EntityLifecycle<>( + ReviewedStatus.class, Map.of( - EntityStatus.DRAFT, Set.of(EntityStatus.IN_REVIEW), - EntityStatus.IN_REVIEW, Set.of(EntityStatus.APPROVED, EntityStatus.DRAFT), - EntityStatus.APPROVED, Set.of())); + ReviewedStatus.DRAFT, Set.of(ReviewedStatus.IN_REVIEW), + ReviewedStatus.IN_REVIEW, Set.of(ReviewedStatus.APPROVED, ReviewedStatus.DRAFT), + ReviewedStatus.APPROVED, Set.of())); + + @ParameterizedTest + @ValueSource(strings = {"Superseded", "Invalidated"}) + void memoryRetirementStagesAreNotGeneralStages(String value) { + assertEquals(value, ContextMemoryStatus.fromValue(value).value()); + assertFalse(EntityLifecycle.GENERAL.includesCode(value)); + assertFalse(EntityLifecycle.GENERAL.allowsCodes(EntityStatus.APPROVED.value(), value)); + } @Test void generalLifecycleMovesBetweenAnyOfTheGeneralStages() { @@ -25,32 +44,64 @@ void generalLifecycleMovesBetweenAnyOfTheGeneralStages() { for (EntityStatus from : EntityLifecycle.GENERAL_STAGES) { for (EntityStatus to : EntityLifecycle.GENERAL_STAGES) { assertEquals(from != to, EntityLifecycle.GENERAL.allows(from, to), from + " to " + to); + assertEquals(from != to, EntityLifecycle.GENERAL.allowsCodes(from.value(), to.value())); } } } @Test void declaredLifecycleAllowsOnlyTheMovesItDeclares() { - assertTrue(REVIEWED.allows(EntityStatus.DRAFT, EntityStatus.IN_REVIEW)); - assertTrue(REVIEWED.allows(EntityStatus.IN_REVIEW, EntityStatus.DRAFT)); - assertFalse(REVIEWED.allows(EntityStatus.DRAFT, EntityStatus.APPROVED)); - assertFalse(REVIEWED.allows(EntityStatus.APPROVED, EntityStatus.DRAFT)); - assertFalse(REVIEWED.includes(EntityStatus.DEPRECATED)); + assertTrue(REVIEWED.allows(ReviewedStatus.DRAFT, ReviewedStatus.IN_REVIEW)); + assertTrue(REVIEWED.allows(ReviewedStatus.IN_REVIEW, ReviewedStatus.DRAFT)); + assertFalse(REVIEWED.allows(ReviewedStatus.DRAFT, ReviewedStatus.APPROVED)); + assertFalse(REVIEWED.allows(ReviewedStatus.APPROVED, ReviewedStatus.DRAFT)); + assertFalse(REVIEWED.includesCode(EntityStatus.DEPRECATED.value())); + assertFalse( + REVIEWED.allowsCodes(EntityStatus.DEPRECATED.value(), ReviewedStatus.DRAFT.toString())); } @Test void entitySavedWithoutAStageCanTakeAnyStageOfItsLifecycle() { - assertTrue(REVIEWED.allows(null, EntityStatus.APPROVED)); - assertFalse(REVIEWED.allows(null, EntityStatus.DEPRECATED)); + assertTrue(REVIEWED.allows(null, ReviewedStatus.APPROVED)); + assertTrue(REVIEWED.allowsCodes(null, ReviewedStatus.APPROVED.toString())); + assertFalse(REVIEWED.allowsCodes(null, EntityStatus.DEPRECATED.value())); } @Test void lifecycleThatMovesToAStageItDoesNotListIsRejected() { - Map> movesOutside = - Map.of(EntityStatus.DRAFT, Set.of(EntityStatus.APPROVED)); + var mistake = + assertThrows( + IllegalArgumentException.class, + () -> + new EntityLifecycle<>( + ReviewedStatus.class, + Map.of(ReviewedStatus.DRAFT, Set.of(ReviewedStatus.APPROVED)))); + assertTrue(mistake.getMessage().contains(ReviewedStatus.APPROVED.toString())); + } - IllegalArgumentException mistake = - assertThrows(IllegalArgumentException.class, () -> new EntityLifecycle(movesOutside)); - assertTrue(mistake.getMessage().contains(EntityStatus.APPROVED.value())); + @Test + void lifecycleMustDeclareEveryStageInItsGeneratedSchemaEnum() { + var mistake = + assertThrows( + IllegalArgumentException.class, + () -> + new EntityLifecycle<>( + ContextMemoryStatus.class, Map.of(ContextMemoryStatus.DRAFT, Set.of()))); + assertTrue(mistake.getMessage().contains("ContextMemoryStatus schema vocabulary")); + } + + @Test + void lifecycleDefensivelyCopiesItsTransitionGraph() { + Set draftMoves = EnumSet.of(ReviewedStatus.IN_REVIEW); + Map> graph = new HashMap<>(REVIEWED.transitions()); + graph.put(ReviewedStatus.DRAFT, draftMoves); + EntityLifecycle policy = new EntityLifecycle<>(ReviewedStatus.class, graph); + draftMoves.clear(); + graph.clear(); + assertTrue(policy.allows(ReviewedStatus.DRAFT, ReviewedStatus.IN_REVIEW)); + assertThrows(UnsupportedOperationException.class, () -> policy.transitions().clear()); + assertThrows( + UnsupportedOperationException.class, + () -> policy.transitions().get(ReviewedStatus.DRAFT).clear()); } } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/governance/EntityStatusAdapterTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/governance/EntityStatusAdapterTest.java new file mode 100644 index 000000000000..8ae5e1603e1e --- /dev/null +++ b/openmetadata-service/src/test/java/org/openmetadata/service/governance/EntityStatusAdapterTest.java @@ -0,0 +1,65 @@ +package org.openmetadata.service.governance; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.util.List; +import org.junit.jupiter.api.Test; +import org.openmetadata.schema.EntityInterface; +import org.openmetadata.schema.entity.context.ContextMemory; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.type.EntityStatus; + +class EntityStatusAdapterTest { + private static final EntityStatusAdapter MEMORY = + new EntityStatusAdapter<>(ContextMemoryStatus.class); + private static final EntityStatusAdapter GENERAL = + new EntityStatusAdapter<>(EntityStatus.class); + + @Test + void statusWritesResolveAgainstTheEntityVocabulary() { + ContextMemory memory = new ContextMemory(); + EntityStatusAdapter.forEntityType(ContextMemory.class).write(memory, " superseded "); + assertEquals(ContextMemoryStatus.SUPERSEDED, memory.getEntityStatus()); + assertEquals("Superseded", MEMORY.read(memory)); + assertThrows(IllegalArgumentException.class, () -> MEMORY.write(memory, "In Review")); + assertEquals(ContextMemoryStatus.SUPERSEDED, memory.getEntityStatus()); + assertThrows(IllegalArgumentException.class, () -> GENERAL.write(new Table(), "Superseded")); + } + + @Test + void adapterCannotWriteADifferentEntityStatusEnum() { + ContextMemory memory = new ContextMemory().withEntityStatus(ContextMemoryStatus.DRAFT); + assertThrows(IllegalArgumentException.class, () -> GENERAL.write(memory, "Approved")); + assertThrows(ClassCastException.class, () -> GENERAL.read(memory)); + assertEquals(ContextMemoryStatus.DRAFT, memory.getEntityStatus()); + } + + @Test + void adapterPreservesUnsetAndLegacyStatuses() { + ContextMemory memory = new ContextMemory(); + assertNull(MEMORY.read(memory)); + MEMORY.write(memory, "Deprecated"); + assertEquals(ContextMemoryStatus.DEPRECATED, memory.getEntityStatus()); + MEMORY.write(memory, "Rejected"); + assertEquals(ContextMemoryStatus.REJECTED, memory.getEntityStatus()); + MEMORY.write(memory, null); + assertNull(memory.getEntityStatus()); + } + + @Test + void adapterExposesTheCompleteGeneratedVocabulary() { + assertEquals(List.of(ContextMemoryStatus.values()), MEMORY.statuses()); + assertEquals( + MEMORY.statuses().stream().map(ContextMemoryStatus::value).toList(), MEMORY.codes()); + assertThrows(IllegalArgumentException.class, () -> MEMORY.resolve(null)); + assertThrows( + IllegalArgumentException.class, () -> EntityStatusAdapter.forEntityType(String.class)); + assertThrows(IllegalArgumentException.class, () -> GENERAL.requireEntityType(String.class)); + assertThrows( + IllegalArgumentException.class, + () -> EntityStatusAdapter.forEntityType(EntityInterface.class)); + } +} diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/SinkTaskDelegateTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/SinkTaskDelegateTest.java index f7123c3307b1..194e595bbec8 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/SinkTaskDelegateTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/SinkTaskDelegateTest.java @@ -113,7 +113,7 @@ void testBatchMode_IgnoresLegacyBatchProcessedFlag() { List entityList = List.of("<#E::table::test.fqn>"); setupVariableAccess(entityList, true); - EntityInterface batchEntity = mock(EntityInterface.class); + EntityInterface batchEntity = mock(EntityInterface.class); when(batchEntity.getFullyQualifiedName()).thenReturn("test.fqn"); try (MockedStatic entityMock = mockStatic(Entity.class)) { @@ -146,7 +146,7 @@ void testBatchMode_ProcessesFirstIteration() { List entityList = List.of("<#E::table::test.fqn>"); setupVariableAccess(entityList, false); - EntityInterface batchEntity = mock(EntityInterface.class); + EntityInterface batchEntity = mock(EntityInterface.class); when(batchEntity.getFullyQualifiedName()).thenReturn("test.fqn"); try (MockedStatic entityMock = mockStatic(Entity.class)) { @@ -291,12 +291,12 @@ void testTestSinkProvider_WriteBatch() { .build(); // Create mock entities - EntityInterface entity1 = mock(EntityInterface.class); - EntityInterface entity2 = mock(EntityInterface.class); + EntityInterface entity1 = mock(EntityInterface.class); + EntityInterface entity2 = mock(EntityInterface.class); when(entity1.getFullyQualifiedName()).thenReturn("test.entity1"); when(entity2.getFullyQualifiedName()).thenReturn("test.entity2"); - List entities = List.of(entity1, entity2); + List> entities = List.of(entity1, entity2); SinkResult result = provider.writeBatch(context, entities); @@ -320,7 +320,7 @@ void testTestSinkProvider_Write() { .workflowName("TestWorkflow") .build(); - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); when(entity.getFullyQualifiedName()).thenReturn("test.entity"); SinkResult result = provider.write(context, entity); @@ -343,7 +343,7 @@ void testTestSinkProvider_FailureMode() { .batchMode(false) .build(); - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); when(entity.getFullyQualifiedName()).thenReturn("test.entity"); assertThrows(RuntimeException.class, () -> provider.write(context, entity)); @@ -375,8 +375,8 @@ private void injectExpression(Object target, String fieldName, Expression value) } static class TestSinkProvider implements SinkProvider { - private final List writtenEntities = new ArrayList<>(); - private final List> batchWrites = new ArrayList<>(); + private final List> writtenEntities = new ArrayList<>(); + private final List>> batchWrites = new ArrayList<>(); private boolean shouldFail = false; @Override @@ -385,7 +385,7 @@ public String getSinkType() { } @Override - public SinkResult write(SinkContext context, EntityInterface entity) { + public SinkResult write(SinkContext context, EntityInterface entity) { if (shouldFail) { throw new RuntimeException("Simulated failure"); } @@ -398,12 +398,12 @@ public SinkResult write(SinkContext context, EntityInterface entity) { } @Override - public SinkResult writeBatch(SinkContext context, List entities) { + public SinkResult writeBatch(SinkContext context, List> entities) { if (shouldFail) { throw new RuntimeException("Simulated failure"); } batchWrites.add(new ArrayList<>(entities)); - List fqns = entities.stream().map(EntityInterface::getFullyQualifiedName).toList(); + List fqns = entities.stream().map(EntityInterface::getFullyQualifiedName).toList(); return SinkResult.builder() .success(true) .syncedCount(entities.size()) @@ -427,11 +427,11 @@ public int getBatchWriteCallCount() { return batchWrites.size(); } - public List getWrittenEntities() { + public List> getWrittenEntities() { return writtenEntities; } - public List getLastBatchEntities() { + public List> getLastBatchEntities() { return batchWrites.isEmpty() ? List.of() : batchWrites.get(batchWrites.size() - 1); } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/WebhookSinkProviderTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/WebhookSinkProviderTest.java index 4ec39842eadc..82106036ae0b 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/WebhookSinkProviderTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/sink/WebhookSinkProviderTest.java @@ -36,6 +36,7 @@ import org.openmetadata.schema.EntityInterface; import org.openmetadata.schema.type.ChangeDescription; import org.openmetadata.schema.type.EntityReference; +import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.service.governance.workflows.elements.nodes.automatedTask.sink.providers.WebhookSinkProvider; class WebhookSinkProviderTest { @@ -279,7 +280,7 @@ private void captureRequest( } } - private static class TestEntity implements EntityInterface { + private static class TestEntity implements EntityInterface { private final UUID id = UUID.randomUUID(); private final String name; @@ -382,7 +383,7 @@ public void setHref(URI href) {} @Override @SuppressWarnings("unchecked") - public T withHref(URI href) { + public > T withHref(URI href) { return (T) this; } } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/impl/SetApprovalAssigneesImplTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/impl/SetApprovalAssigneesImplTest.java index 56ede002ec3c..c62128b0c050 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/impl/SetApprovalAssigneesImplTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/impl/SetApprovalAssigneesImplTest.java @@ -65,7 +65,7 @@ class SetApprovalAssigneesImplTest { @Mock private Expression assigneesExpr; @Mock private Expression assigneesVarNameExpr; @Mock private Expression inputNamespaceMapExpr; - @Mock private EntityInterface mockEntity; + @Mock private EntityInterface mockEntity; @SuppressWarnings("rawtypes") @Mock diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/util/ChangePreviewUtilsTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/util/ChangePreviewUtilsTest.java index 0db8d92cf589..e187ed3d8647 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/util/ChangePreviewUtilsTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/util/ChangePreviewUtilsTest.java @@ -447,7 +447,7 @@ void extractProposedChanges_jsonRoundTripMissingRemovedKey_defaultsToEmpty() { @Test void buildProposedChangesPayload_entityWithoutChanges_returnsInput() { - EntityInterface entity = new GlossaryTerm().withName("t"); + EntityInterface entity = new GlossaryTerm().withName("t"); Map existing = Map.of("k", "v"); assertEquals(existing, ChangePreviewUtils.buildProposedChangesPayload(entity, existing)); } @@ -458,7 +458,7 @@ void buildProposedChangesPayload_prefersIncrementalOverCumulative() { // removal that the prior task payload already cancelled, while the latest hop only // touches a different field. Without incremental preference, the cumulative removal // double-counts and re-introduces the cancelled tag on the removed side. - EntityInterface entity = + EntityInterface entity = new GlossaryTerm() .withName("t") .withChangeDescription( @@ -489,7 +489,7 @@ void buildProposedChangesPayload_prefersIncrementalOverCumulative() { @Test void buildProposedChangesPayload_freshChanges_writesKey() { - EntityInterface entity = + EntityInterface entity = new GlossaryTerm() .withName("t") .withChangeDescription( @@ -515,7 +515,7 @@ void buildProposedChangesPayload_mergesWithExistingProposedChanges() { "proposedChanges", Map.of("tags", Map.of("added", List.of("PII.Sensitive"), "removed", List.of("PII.None")))); - EntityInterface entity = + EntityInterface entity = new GlossaryTerm() .withName("t") .withChangeDescription( @@ -543,7 +543,7 @@ void buildProposedChangesPayload_cancelsToEmpty_removesKey() { "proposedChanges", Map.of("tags", Map.of("added", List.of("PII.Sensitive"), "removed", List.of()))); - EntityInterface entity = + EntityInterface entity = new GlossaryTerm() .withName("t") .withChangeDescription( diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/ActivityStreamRepositoryTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/ActivityStreamRepositoryTest.java index 671c5be0c825..62e88bfe65eb 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/ActivityStreamRepositoryTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/ActivityStreamRepositoryTest.java @@ -73,7 +73,7 @@ void buildActorReferenceCountsSystemEventWhenUserNameMissing() { ActivityStreamRepository repository = new ActivityStreamRepository(dao); ChangeEvent changeEvent = changeEventWith(/* userName */ null); - EntityInterface entity = tableEntity(); + EntityInterface entity = tableEntity(); repository.createFromChangeEvent(changeEvent, entity); @@ -91,7 +91,7 @@ void buildActorReferenceCountsHardDeletedWhenUserNotFound() { ActivityStreamRepository repository = new ActivityStreamRepository(dao); ChangeEvent changeEvent = changeEventWith("ghost-user"); - EntityInterface entity = tableEntity(); + EntityInterface entity = tableEntity(); try (MockedStatic entityMock = mockStatic(Entity.class)) { entityMock @@ -169,7 +169,7 @@ private static ChangeEvent changeEventWith(String userName) { .withUserName(userName); } - private static EntityInterface tableEntity() { + private static EntityInterface tableEntity() { return new Table().withId(UUID.randomUUID()).withFullyQualifiedName("svc.db.schema.table"); } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/ContextMemoryLifecycleTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/ContextMemoryLifecycleTest.java index 18fd81decb0b..7d908d20382e 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/ContextMemoryLifecycleTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/ContextMemoryLifecycleTest.java @@ -23,10 +23,12 @@ import java.util.List; import java.util.UUID; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; import org.openmetadata.schema.entity.context.ContextMemory; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.MemoryDispute; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.utils.JsonUtils; import org.openmetadata.service.Entity; @@ -44,13 +46,14 @@ class ContextMemoryLifecycleTest { throw new AssertionError(field + " must not be looked up"); }; - @Test - void leavingDeprecatedDropsTheSuccessorAndStaleReason() { + @ParameterizedTest + @EnumSource( + value = ContextMemoryStatus.class, + names = {"DEPRECATED", "SUPERSEDED"}) + void leavingSupersededDropsTheSuccessorAndStaleReason(ContextMemoryStatus status) { ContextMemory original = - memory(EntityStatus.DEPRECATED) - .withSupersededBy(memoryRef()) - .withStatusReason("Duplicate of the keeper"); - ContextMemory updated = copyOf(original).withEntityStatus(EntityStatus.APPROVED); + memory(status).withSupersededBy(memoryRef()).withStatusReason("Duplicate of the keeper"); + ContextMemory updated = copyOf(original).withEntityStatus(ContextMemoryStatus.APPROVED); ContextMemoryLifecycle.applyUpdate(original, updated, NO_LOOKUP); @@ -58,34 +61,41 @@ void leavingDeprecatedDropsTheSuccessorAndStaleReason() { assertNull(updated.getStatusReason()); } - @Test - void aStatusChangeKeepsItsNewReason() { - ContextMemory original = memory(EntityStatus.APPROVED); + @ParameterizedTest + @EnumSource( + value = ContextMemoryStatus.class, + names = {"REJECTED", "INVALIDATED"}) + void aStatusChangeKeepsItsNewReason(ContextMemoryStatus status) { + ContextMemory original = memory(ContextMemoryStatus.APPROVED); ContextMemory updated = - copyOf(original) - .withEntityStatus(EntityStatus.REJECTED) - .withStatusReason("Anchor table was deleted"); + copyOf(original).withEntityStatus(status).withStatusReason("Anchor table was deleted"); ContextMemoryLifecycle.applyUpdate(original, updated, NO_LOOKUP); assertEquals("Anchor table was deleted", updated.getStatusReason()); } - @Test - void supersedingResolvesTheNewSuccessor() { - ContextMemory original = memory(EntityStatus.APPROVED); + @ParameterizedTest + @EnumSource( + value = ContextMemoryStatus.class, + names = {"DEPRECATED", "SUPERSEDED"}) + void supersedingResolvesTheNewSuccessor(ContextMemoryStatus status) { + ContextMemory original = memory(ContextMemoryStatus.APPROVED); EntityReference keeper = memoryRef(); - ContextMemory updated = supersededBy(original, keeper); + ContextMemory updated = supersededBy(original, keeper, status); ContextMemoryLifecycle.applyUpdate(original, updated, RESOLVE); assertEquals("memory-" + keeper.getId(), updated.getSupersededBy().getName()); } - @Test - void anUnchangedSuccessorKeepsTheStoredReference() { + @ParameterizedTest + @EnumSource( + value = ContextMemoryStatus.class, + names = {"DEPRECATED", "SUPERSEDED"}) + void anUnchangedSuccessorKeepsTheStoredReference(ContextMemoryStatus status) { EntityReference stored = memoryRef().withName("keeper"); - ContextMemory original = memory(EntityStatus.DEPRECATED).withSupersededBy(stored); + ContextMemory original = memory(status).withSupersededBy(stored); ContextMemory updated = copyOf(original) .withSupersededBy( @@ -96,16 +106,19 @@ void anUnchangedSuccessorKeepsTheStoredReference() { assertSame(stored, updated.getSupersededBy()); } - @Test - void supersededNeedsASuccessorAndOnlyDeprecatedMayHaveOne() { - ContextMemory active = memory(EntityStatus.APPROVED); + @ParameterizedTest + @EnumSource( + value = ContextMemoryStatus.class, + names = {"DEPRECATED", "SUPERSEDED"}) + void supersededNeedsASuccessorAndOtherStagesCannotHaveOne(ContextMemoryStatus status) { + ContextMemory active = memory(ContextMemoryStatus.APPROVED); BadRequestException missing = assertThrows( BadRequestException.class, () -> ContextMemoryLifecycle.applyUpdate( - active, copyOf(active).withEntityStatus(EntityStatus.DEPRECATED), RESOLVE)); + active, copyOf(active).withEntityStatus(status), RESOLVE)); BadRequestException stray = assertThrows( BadRequestException.class, @@ -117,26 +130,33 @@ void supersededNeedsASuccessorAndOnlyDeprecatedMayHaveOne() { assertTrue(stray.getMessage().contains("only allowed on a Deprecated memory")); } - @Test - void aSuccessorMustBeAnotherContextMemory() { - ContextMemory active = memory(EntityStatus.APPROVED); + @ParameterizedTest + @EnumSource( + value = ContextMemoryStatus.class, + names = {"DEPRECATED", "SUPERSEDED"}) + void aSuccessorMustBeAnotherContextMemory(ContextMemoryStatus status) { + ContextMemory active = memory(ContextMemoryStatus.APPROVED); EntityReference table = new EntityReference().withId(UUID.randomUUID()).withType(Entity.TABLE); EntityReference self = new EntityReference().withId(active.getId()).withType(Entity.CONTEXT_MEMORY); assertThrows( BadRequestException.class, - () -> ContextMemoryLifecycle.applyUpdate(active, supersededBy(active, table), RESOLVE)); + () -> + ContextMemoryLifecycle.applyUpdate( + active, supersededBy(active, table, status), RESOLVE)); assertThrows( BadRequestException.class, - () -> ContextMemoryLifecycle.applyUpdate(active, supersededBy(active, self), RESOLVE)); + () -> + ContextMemoryLifecycle.applyUpdate( + active, supersededBy(active, self, status), RESOLVE)); } @Test void onlyNewDisputesAreResolved() { MemoryDispute existing = new MemoryDispute().withMemory(memoryRef()).withReason("Says Q3"); MemoryDispute added = new MemoryDispute().withMemory(memoryRef()).withReason("Says Q4"); - ContextMemory original = memory(EntityStatus.APPROVED).withDisputes(List.of(existing)); + ContextMemory original = memory(ContextMemoryStatus.APPROVED).withDisputes(List.of(existing)); ContextMemory updated = copyOf(original) .withDisputes(List.of(JsonUtils.deepCopy(existing, MemoryDispute.class), added)); @@ -154,7 +174,7 @@ void onlyNewDisputesAreResolved() { @Test void disputesNeedAnOtherMemoryAndANonBlankReason() { - ContextMemory active = memory(EntityStatus.APPROVED); + ContextMemory active = memory(ContextMemoryStatus.APPROVED); MemoryDispute blankReason = new MemoryDispute().withMemory(memoryRef()).withReason(" "); MemoryDispute noMemory = new MemoryDispute().withReason("Contradicts glossary"); MemoryDispute self = @@ -171,22 +191,26 @@ void disputesNeedAnOtherMemoryAndANonBlankReason() { } } - @Test - void createCannotBeDeprecatedWithoutASuccessor() { + @ParameterizedTest + @EnumSource( + value = ContextMemoryStatus.class, + names = {"DEPRECATED", "SUPERSEDED"}) + void createCannotBeSupersededWithoutASuccessor(ContextMemoryStatus status) { assertThrows( BadRequestException.class, - () -> ContextMemoryLifecycle.applyCreate(memory(EntityStatus.DEPRECATED), RESOLVE)); + () -> ContextMemoryLifecycle.applyCreate(memory(status), RESOLVE)); } - private static ContextMemory memory(EntityStatus status) { + private static ContextMemory memory(ContextMemoryStatus status) { return new ContextMemory() .withId(UUID.randomUUID()) .withName("memory") .withEntityStatus(status); } - private static ContextMemory supersededBy(ContextMemory original, EntityReference successor) { - return copyOf(original).withEntityStatus(EntityStatus.DEPRECATED).withSupersededBy(successor); + private static ContextMemory supersededBy( + ContextMemory original, EntityReference successor, ContextMemoryStatus status) { + return copyOf(original).withEntityStatus(status).withSupersededBy(successor); } private static EntityReference memoryRef() { diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/ContextMemoryRepositoryTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/ContextMemoryRepositoryTest.java index 6123a30aac3e..b3796a59289f 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/ContextMemoryRepositoryTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/ContextMemoryRepositoryTest.java @@ -118,7 +118,7 @@ void entityFacade_isSearchIndexable_defaultsTrueForTypeWithoutRepository() { // A type with no registered repository (index-only / time-series sub-entities such as // pipelineStatus) must default to indexable instead of throwing EntityNotFoundException, so the // live index paths keep working for it. - EntityInterface repoLess = mock(EntityInterface.class); + EntityInterface repoLess = mock(EntityInterface.class); when(repoLess.getEntityReference()) .thenReturn(new EntityReference().withType("typeWithoutRepository")); @@ -143,7 +143,7 @@ void entityFacade_isSearchIndexable_defaultsTrueWhenOnlyTimeSeriesRepositoryExis repositories.put(entityType, mock(EntityTimeSeriesRepository.class)); try { - EntityInterface timeSeriesEntity = mock(EntityInterface.class); + EntityInterface timeSeriesEntity = mock(EntityInterface.class); when(timeSeriesEntity.getEntityReference()) .thenReturn(new EntityReference().withType(entityType)); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/EntityRepositoryEntityStatusTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/EntityRepositoryEntityStatusTest.java index 01ad8a1a49e3..59389b377136 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/EntityRepositoryEntityStatusTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/EntityRepositoryEntityStatusTest.java @@ -21,16 +21,21 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.openmetadata.schema.EntityInterface; import org.openmetadata.schema.entity.context.ContextMemory; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.data.Metric; import org.openmetadata.schema.entity.teams.Team; import org.openmetadata.schema.entity.teams.User; +import org.openmetadata.schema.exception.JsonParsingException; import org.openmetadata.schema.type.ChangeDescription; import org.openmetadata.schema.type.EntityReference; import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.FieldChange; import org.openmetadata.schema.type.Include; +import org.openmetadata.schema.utils.JsonUtils; import org.openmetadata.service.Entity; import org.openmetadata.service.exception.BadRequestException; import org.openmetadata.service.governance.EntityLifecycle; @@ -76,11 +81,16 @@ private static class ReviewedMetricRepo extends TestMetricRepo { super(dao); defaultEntityStatus = EntityStatus.DRAFT; entityLifecycle = - new EntityLifecycle( + new EntityLifecycle<>( + EntityStatus.class, Map.of( EntityStatus.DRAFT, Set.of(EntityStatus.APPROVED), EntityStatus.APPROVED, Set.of(EntityStatus.DEPRECATED), - EntityStatus.DEPRECATED, Set.of())); + EntityStatus.DEPRECATED, Set.of(), + EntityStatus.IN_REVIEW, Set.of(), + EntityStatus.REJECTED, Set.of(), + EntityStatus.ARCHIVED, Set.of(), + EntityStatus.UNPROCESSED, Set.of())); } } @@ -108,7 +118,7 @@ public List owningStageOf(String entityType) { } @Override - public Optional owningStageOf(String entityType, EntityInterface entity) { + public Optional owningStageOf(String entityType, EntityInterface entity) { return EXCLUDED_METRIC.equals(entity.getName()) ? Optional.empty() : Optional.of(STAGE_WORKFLOW); @@ -140,6 +150,14 @@ void newEntityStartsInTheStageItsRequestAskedFor() { assertEquals(EntityStatus.IN_REVIEW, metric.getEntityStatus()); } + @ParameterizedTest + @ValueSource(strings = {"Superseded", "Invalidated"}) + void generalEntitiesCannotDeserializeMemoryRetirementStages(String value) { + assertThrows( + JsonParsingException.class, + () -> JsonUtils.readValue("{\"entityStatus\":\"" + value + "\"}", Metric.class)); + } + @Test void newEntityWithoutAStageStartsInItsTypesDefaultStage() { Metric ingested = metric(); @@ -153,12 +171,10 @@ void newEntityWithoutAStageStartsInItsTypesDefaultStage() { } @Test - void newEntityInAStageItsTypeDoesNotUseIsRejected() { + void newEntityCanStartInAnyStageItsSchemaDeclares() { Metric inReview = metric().withEntityStatus(EntityStatus.IN_REVIEW); - assertThrows( - BadRequestException.class, - () -> new ReviewedMetricRepo(metricDAO).assignInitialEntityStatus(inReview)); + assertDoesNotThrow(() -> new ReviewedMetricRepo(metricDAO).assignInitialEntityStatus(inReview)); } @Test @@ -227,12 +243,11 @@ void entityTypeCanRejectAStageTransition() { } @Test - void entitySavedWithoutAStageCanTakeOnlyAStageOfItsTypesLifecycle() { + void entitySavedWithoutAStageCanTakeAnyStageOfItsTypesVocabulary() { TestMetricRepo repo = new ReviewedMetricRepo(metricDAO); Metric unstaged = metric().withEntityStatus(null); - assertThrows( - BadRequestException.class, + assertDoesNotThrow( () -> newUpdater(repo, unstaged, movedBy(unstaged, EntityStatus.IN_REVIEW, REVIEWER)) .updateEntityStatus(false)); @@ -245,16 +260,16 @@ void entitySavedWithoutAStageCanTakeOnlyAStageOfItsTypesLifecycle() { @Test void memoryStageChangesFollowTheMemoryLifecycle() { ContextMemoryRepository repo = new ContextMemoryRepository(); - ContextMemory archived = memory(EntityStatus.ARCHIVED); + ContextMemory archived = memory(ContextMemoryStatus.ARCHIVED); assertThrows( BadRequestException.class, () -> - newUpdater(repo, archived, memoryMovedTo(archived, EntityStatus.DRAFT)) + newUpdater(repo, archived, memoryMovedTo(archived, ContextMemoryStatus.DRAFT)) .updateEntityStatus(false)); assertDoesNotThrow( () -> - newUpdater(repo, archived, memoryMovedTo(archived, EntityStatus.APPROVED)) + newUpdater(repo, archived, memoryMovedTo(archived, ContextMemoryStatus.APPROVED)) .updateEntityStatus(false)); } @@ -493,7 +508,7 @@ private static Metric movedBy(Metric current, EntityStatus stage, String userNam .withReviewers(current.getReviewers()); } - private static ContextMemory memory(EntityStatus stage) { + private static ContextMemory memory(ContextMemoryStatus stage) { return new ContextMemory() .withId(UUID.randomUUID()) .withName("orders_are_net_of_refunds") @@ -502,7 +517,7 @@ private static ContextMemory memory(EntityStatus stage) { .withUpdatedBy(Entity.ADMIN_USER_NAME); } - private static ContextMemory memoryMovedTo(ContextMemory current, EntityStatus stage) { + private static ContextMemory memoryMovedTo(ContextMemory current, ContextMemoryStatus stage) { return memory(stage).withId(current.getId()); } @@ -522,7 +537,7 @@ private static EntityReference reference(String type, String name) { .withFullyQualifiedName(name); } - private static EntityRepository.EntityUpdater newUpdater( + private static > EntityRepository.EntityUpdater newUpdater( EntityRepository repo, E original, E updated) { EntityRepository.EntityUpdater updater = repo.new EntityUpdater(original, updated, EntityRepository.Operation.PUT); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/EntityRepositoryHistoryPageTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/EntityRepositoryHistoryPageTest.java index 0e54e011ff88..e322b93354d7 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/EntityRepositoryHistoryPageTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/EntityRepositoryHistoryPageTest.java @@ -244,7 +244,7 @@ private static Database databaseVersion(long updatedAt) { .withVersion(0.1); } - private void stubVersionRows(long startTs, List rows) { + private void stubVersionRows(long startTs, List> rows) { List jsons = rows.stream().map(JsonUtils::pojoToJson).toList(); when(extensionDAO.getEntityHistoryByTimestampRange( anyString(), diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/EntityRepositoryInheritanceParentTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/EntityRepositoryInheritanceParentTest.java index 3c1d83eca480..66ad5256633d 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/EntityRepositoryInheritanceParentTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/EntityRepositoryInheritanceParentTest.java @@ -73,7 +73,7 @@ public EntityReference getParentReference(Pipeline entity) { * instance would let a memoized reference appear up to date and hide staleness. */ @Override - public EntityInterface getParentEntity(Pipeline entity, String fields) { + public EntityInterface getParentEntity(Pipeline entity, String fields) { parentLoads++; return new Pipeline() .withId(parent.getId()) diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/GlossaryTermRepositoryInitialStageTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/GlossaryTermRepositoryInitialStageTest.java index 153e473711de..8b7c8499eed4 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/GlossaryTermRepositoryInitialStageTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/GlossaryTermRepositoryInitialStageTest.java @@ -110,7 +110,7 @@ private static EntityReference storedParentTerm(List reviewers) } @SuppressWarnings("unchecked") - private static EntityReference stored( + private static > EntityReference stored( String entityType, Class entityClass, E entity) { EntityRepository store = mock(EntityRepository.class); when(store.get(any(), eq(entity.getId()), any(), any(Include.class), anyBoolean())) diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/LineageChildrenNamesTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/LineageChildrenNamesTest.java index 6b0ca806a011..c86ad70f7d60 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/LineageChildrenNamesTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/LineageChildrenNamesTest.java @@ -289,7 +289,7 @@ void mlmodel_featureNames() throws Exception { @Test void parity_registryChildrenMatchOldSwitch_tableTopicMlmodel() throws Exception { - record Case(String type, EntityInterface entity) {} + record Case(String type, EntityInterface entity) {} List cases = List.of( new Case(Entity.TABLE, tableFixture()), diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/LineageRepositoryTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/LineageRepositoryTest.java index 9a265632bc97..68baef219cf3 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/LineageRepositoryTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/LineageRepositoryTest.java @@ -667,11 +667,11 @@ void testServiceEdge_WithNonNullEntityPipeline_NewEdgeHasNoPipeline() throws Exc LineageDetails entityDetails = new LineageDetails().withPipeline(pipelineRef).withCreatedBy("testUser"); - EntityInterface fromEntityMock = mock(EntityInterface.class); + EntityInterface fromEntityMock = mock(EntityInterface.class); when(fromEntityMock.getService()).thenReturn(fromServiceRef); when(fromEntityMock.getEntityReference()).thenReturn(fromRef); - EntityInterface toEntityMock = mock(EntityInterface.class); + EntityInterface toEntityMock = mock(EntityInterface.class); when(toEntityMock.getService()).thenReturn(toServiceRef); when(toEntityMock.getEntityReference()).thenReturn(toRef); @@ -747,11 +747,11 @@ void testServiceEdge_WithNonNullEntityPipeline_ExistingEdgeHasNoPipeline() throw mock(CollectionDAO.EntityRelationshipObject.class); when(existingRecord.getJson()).thenReturn(JsonUtils.pojoToJson(existingServiceDetails)); - EntityInterface fromEntityMock = mock(EntityInterface.class); + EntityInterface fromEntityMock = mock(EntityInterface.class); when(fromEntityMock.getService()).thenReturn(fromServiceRef); when(fromEntityMock.getEntityReference()).thenReturn(fromRef); - EntityInterface toEntityMock = mock(EntityInterface.class); + EntityInterface toEntityMock = mock(EntityInterface.class); when(toEntityMock.getService()).thenReturn(toServiceRef); when(toEntityMock.getEntityReference()).thenReturn(toRef); @@ -829,15 +829,15 @@ void testPipelineServiceEdges_WithDistinctPipelineService_RoutesThroughPipelineO LineageDetails entityDetails = new LineageDetails().withPipeline(pipelineRef).withCreatedBy("testUser"); - EntityInterface fromEntityMock = mock(EntityInterface.class); + EntityInterface fromEntityMock = mock(EntityInterface.class); when(fromEntityMock.getService()).thenReturn(fromServiceRef); when(fromEntityMock.getEntityReference()).thenReturn(fromRef); - EntityInterface toEntityMock = mock(EntityInterface.class); + EntityInterface toEntityMock = mock(EntityInterface.class); when(toEntityMock.getService()).thenReturn(toServiceRef); when(toEntityMock.getEntityReference()).thenReturn(toRef); - EntityInterface pipelineEntityMock = mock(EntityInterface.class); + EntityInterface pipelineEntityMock = mock(EntityInterface.class); when(pipelineEntityMock.getService()).thenReturn(pipelineServiceRef); CollectionDAO freshDao = mock(CollectionDAO.class); @@ -913,11 +913,11 @@ void testPipelineServiceEdges_WithNoPipeline_OnlyDirectServiceEdgeCreated() thro LineageDetails entityDetails = new LineageDetails().withPipeline(null).withCreatedBy("testUser"); - EntityInterface fromEntityMock = mock(EntityInterface.class); + EntityInterface fromEntityMock = mock(EntityInterface.class); when(fromEntityMock.getService()).thenReturn(fromServiceRef); when(fromEntityMock.getEntityReference()).thenReturn(fromRef); - EntityInterface toEntityMock = mock(EntityInterface.class); + EntityInterface toEntityMock = mock(EntityInterface.class); when(toEntityMock.getService()).thenReturn(toServiceRef); when(toEntityMock.getEntityReference()).thenReturn(toRef); @@ -1023,10 +1023,10 @@ private CollectionDAO.EntityRelationshipDAO rollUpChildEdge( EntityReference fromRef = new EntityReference().withId(UUID.randomUUID()).withType(entityType); EntityReference toRef = new EntityReference().withId(UUID.randomUUID()).withType(entityType); - EntityInterface fromEntityMock = mock(EntityInterface.class); + EntityInterface fromEntityMock = mock(EntityInterface.class); when(fromEntityMock.getService()).thenReturn(fromService); when(fromEntityMock.getEntityReference()).thenReturn(fromRef); - EntityInterface toEntityMock = mock(EntityInterface.class); + EntityInterface toEntityMock = mock(EntityInterface.class); when(toEntityMock.getService()).thenReturn(toService); when(toEntityMock.getEntityReference()).thenReturn(toRef); @@ -1050,7 +1050,7 @@ private CollectionDAO.EntityRelationshipDAO rollUpChildEdge( .when(() -> Entity.getEntity(eq(entityType), eq(toRef.getId()), any(), any())) .thenReturn(toEntityMock); if (childEdge.getPipeline() != null) { - EntityInterface pipelineEntityMock = mock(EntityInterface.class); + EntityInterface pipelineEntityMock = mock(EntityInterface.class); when(pipelineEntityMock.getService()).thenReturn(serviceRef("pipelineService")); mockedEntity.when(() -> Entity.entityHasField("pipeline", "service")).thenReturn(true); mockedEntity diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/migration/utils/v210/DottedServiceFqnMigrationTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/migration/utils/v210/DottedServiceFqnMigrationTest.java index 19d1f1120bf7..a55a025d64c2 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/migration/utils/v210/DottedServiceFqnMigrationTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/migration/utils/v210/DottedServiceFqnMigrationTest.java @@ -315,7 +315,8 @@ void leavesRowUnhealedWhenCanonicalDuplicateAlreadyExists() { assertEquals("dash.service.sales", dashboard.getFullyQualifiedName()); } - private static void stubService(EntityDAO dao, UUID id, T entity) { + private static > void stubService( + EntityDAO dao, UUID id, T entity) { // The migration loads services with Include.ALL so soft-deleted services are covered too. when(dao.findEntityById(eq(id), eq(Include.ALL))).thenReturn(entity); } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/ontology/OntologyChangePreflightTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/ontology/OntologyChangePreflightTest.java index fca472c28445..20bc938d70e4 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/ontology/OntologyChangePreflightTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/ontology/OntologyChangePreflightTest.java @@ -22,11 +22,11 @@ import java.util.UUID; import org.junit.jupiter.api.Test; import org.openmetadata.schema.entity.context.ContextMemory; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.data.Glossary; import org.openmetadata.schema.entity.data.GlossaryTerm; import org.openmetadata.schema.entity.data.OntologyChangeSet; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.OntologyChangeOperation; import org.openmetadata.schema.type.OntologyChangeOperationType; import org.openmetadata.schema.type.OntologyRelationship; @@ -40,7 +40,8 @@ void rejectsAProposalWhoseSourceMemoryWasRetired() { final OntologyChangeOperation proposal = createOperation(storedTerm(glossaryId, null)).withSourceMemoryIds(Set.of(memoryId)); - for (final EntityStatus status : List.of(EntityStatus.DEPRECATED, EntityStatus.REJECTED)) { + for (final ContextMemoryStatus status : + List.of(ContextMemoryStatus.DEPRECATED, ContextMemoryStatus.REJECTED)) { final OntologyChangePreflight preflight = new OntologyChangePreflight( (entityType, id) -> new ContextMemory().withId(id).withEntityStatus(status)); @@ -65,7 +66,9 @@ void acceptsAnOperationThatAnotherApprovedSourceStillGrounds() { new ContextMemory() .withId(id) .withEntityStatus( - id.equals(retired) ? EntityStatus.REJECTED : EntityStatus.APPROVED)); + id.equals(retired) + ? ContextMemoryStatus.REJECTED + : ContextMemoryStatus.APPROVED)); assertDoesNotThrow(() -> preflight.validate(changeSet(glossaryId), List.of(proposal))); } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/ontology/OntologyMemoryDerivationQueueTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/ontology/OntologyMemoryDerivationQueueTest.java index 31cc56f4a9b0..d5f94f2fe20c 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/ontology/OntologyMemoryDerivationQueueTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/ontology/OntologyMemoryDerivationQueueTest.java @@ -15,10 +15,10 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.openmetadata.schema.entity.context.ContextMemory; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.MemoryShareConfig; import org.openmetadata.schema.entity.context.MemoryVisibility; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.utils.JsonUtils; import org.openmetadata.service.jobs.JobDAO; @@ -115,7 +115,7 @@ void skipsUnchangedContentAndQueuesWhenMemoryBecomesPublished() { private static ContextMemory memory(UUID id, MemoryVisibility visibility) { return new ContextMemory() .withId(id) - .withEntityStatus(EntityStatus.APPROVED) + .withEntityStatus(ContextMemoryStatus.APPROVED) .withQuestion("What is revenue churn?") .withAnswer("Revenue lost from existing customers over a period.") .withShareConfig(new MemoryShareConfig().withVisibility(visibility)); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/ontology/OntologyMemoryDerivationServiceTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/ontology/OntologyMemoryDerivationServiceTest.java index 5ac2a02a2639..c38216292c38 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/ontology/OntologyMemoryDerivationServiceTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/ontology/OntologyMemoryDerivationServiceTest.java @@ -38,13 +38,13 @@ import org.mockito.ArgumentCaptor; import org.openmetadata.schema.api.data.CreateOntologyChangeSet; import org.openmetadata.schema.entity.context.ContextMemory; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.MemoryShareConfig; import org.openmetadata.schema.entity.context.MemoryVisibility; import org.openmetadata.schema.entity.data.Glossary; import org.openmetadata.schema.entity.data.OntologyChangeSet; import org.openmetadata.schema.search.SearchRequest; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.Include; import org.openmetadata.schema.type.OntologyChangeOperation; import org.openmetadata.schema.utils.ResultList; @@ -102,7 +102,7 @@ void resumedJobReusesItsDraftWithoutCallingTheModel() { void batchSkipsMemoriesThatStoppedBeingEligibleAndDerivesFromTheRest() throws IOException { final ContextMemory drafted = stored(memory(MemoryVisibility.ENTITY)); final ContextMemory archived = stored(memory(MemoryVisibility.ENTITY)); - archived.setEntityStatus(EntityStatus.ARCHIVED); + archived.setEntityStatus(ContextMemoryStatus.ARCHIVED); final ContextMemory eligible = stored(memory(MemoryVisibility.ENTITY)); final UUID deletedId = UUID.randomUUID(); when(memories.get(isNull(), eq(deletedId), isNull(), eq(Include.NON_DELETED), eq(false))) @@ -163,7 +163,7 @@ void requireEligibleAcceptsPublishedMemoriesAndOwnRestrictedOnes() { void requireEligibleRejectsRestrictedInactiveAndDerivedMemories() { final ContextMemory restricted = memory(MemoryVisibility.PRIVATE); final ContextMemory archived = memory(MemoryVisibility.ENTITY); - archived.setEntityStatus(EntityStatus.ARCHIVED); + archived.setEntityStatus(ContextMemoryStatus.ARCHIVED); final ContextMemory derived = memory(MemoryVisibility.PUBLIC); derived.setDerivedEntities( List.of(new EntityReference().withId(UUID.randomUUID()).withType(Entity.GLOSSARY_TERM))); @@ -171,8 +171,11 @@ void requireEligibleRejectsRestrictedInactiveAndDerivedMemories() { assertThrows( BadRequestException.class, () -> OntologyMemoryDerivationService.requireEligible(List.of(restricted), "bob")); - for (EntityStatus status : - List.of(EntityStatus.ARCHIVED, EntityStatus.DEPRECATED, EntityStatus.REJECTED)) { + for (ContextMemoryStatus status : + List.of( + ContextMemoryStatus.ARCHIVED, + ContextMemoryStatus.DEPRECATED, + ContextMemoryStatus.REJECTED)) { archived.setEntityStatus(status); assertThrows( BadRequestException.class, @@ -251,7 +254,7 @@ private static ContextMemory memory(final MemoryVisibility visibility) { .withQuestion("What is a churned customer?") .withAnswer("A customer who cancelled every subscription.") .withOwners(List.of(new EntityReference().withType("user").withName("alice"))) - .withEntityStatus(EntityStatus.APPROVED) + .withEntityStatus(ContextMemoryStatus.APPROVED) .withShareConfig(new MemoryShareConfig().withVisibility(visibility)); } } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/rdf/RdfEntityDiffServiceTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/rdf/RdfEntityDiffServiceTest.java index b8613c8f3371..f4b0b48e2eef 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/rdf/RdfEntityDiffServiceTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/rdf/RdfEntityDiffServiceTest.java @@ -36,8 +36,8 @@ class RdfEntityDiffServiceTest { private static final Double FROM_VERSION = 0.1; private static final Double TO_VERSION = 0.2; private final UUID entityId = UUID.randomUUID(); - private final EntityInterface fromEntity = entity(); - private final EntityInterface toEntity = entity(); + private final EntityInterface fromEntity = entity(); + private final EntityInterface toEntity = entity(); @Test void returnsTypedAddedAndRemovedStatementsInStableOrder() { @@ -111,7 +111,7 @@ private static Model model(final String turtle) { return model; } - private static EntityInterface entity() { + private static EntityInterface entity() { return mock(EntityInterface.class); } } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/rdf/RdfPropertyMapperTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/rdf/RdfPropertyMapperTest.java index 1c623409e153..b7dc33247f1f 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/rdf/RdfPropertyMapperTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/rdf/RdfPropertyMapperTest.java @@ -33,6 +33,7 @@ import org.openmetadata.schema.EntityInterface; import org.openmetadata.schema.entity.data.Table; import org.openmetadata.schema.type.ChangeDescription; +import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.service.rdf.translator.RdfPropertyMapper; /** @@ -1629,7 +1630,7 @@ private ObjectNode entityReferenceNode( return entityReference; } - private static class TestRdfEntity implements EntityInterface { + private static class TestRdfEntity implements EntityInterface { private UUID id; private String description; private String displayName; @@ -1784,7 +1785,7 @@ public void setHref(URI href) { @Override @SuppressWarnings("unchecked") - public T withHref(URI href) { + public > T withHref(URI href) { this.href = href; return (T) this; } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/rdf/RdfRepositoryBulkChunkingTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/rdf/RdfRepositoryBulkChunkingTest.java index 8f02ece0d851..b8edf5202b06 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/rdf/RdfRepositoryBulkChunkingTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/rdf/RdfRepositoryBulkChunkingTest.java @@ -348,8 +348,8 @@ void untranslatableEntityIsIsolatedFromItsBatch() { JsonLdTranslator translator = mock(JsonLdTranslator.class); RdfRepository repository = new RdfRepository(config(), storage, translator); - EntityInterface good = entityWithId(UUID.randomUUID()); - EntityInterface bad = entityWithId(UUID.randomUUID()); + EntityInterface good = entityWithId(UUID.randomUUID()); + EntityInterface bad = entityWithId(UUID.randomUUID()); when(translator.toRdf(good)).thenReturn(ModelFactory.createDefaultModel()); when(translator.toRdf(bad)).thenThrow(new IllegalStateException("tagLabel missing tagFQN")); @@ -362,8 +362,8 @@ void untranslatableEntityIsIsolatedFromItsBatch() { assertEquals(good.getId(), requests.getFirst().entityId()); } - private static EntityInterface entityWithId(UUID id) { - EntityInterface entity = mock(EntityInterface.class); + private static EntityInterface entityWithId(UUID id) { + EntityInterface entity = mock(EntityInterface.class); lenient().when(entity.getId()).thenReturn(id); lenient() .when(entity.getEntityReference()) diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/rdf/RdfWritePathScaleHarness.java b/openmetadata-service/src/test/java/org/openmetadata/service/rdf/RdfWritePathScaleHarness.java index 33f7155411a6..187fc136c54c 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/rdf/RdfWritePathScaleHarness.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/rdf/RdfWritePathScaleHarness.java @@ -88,7 +88,7 @@ public static void main(String[] args) throws Exception { RdfRepository repository = new RdfRepository(config, storage, translator); long before = triples(endpoint); - List batch = new ArrayList<>(); + List> batch = new ArrayList<>(); long translateNanos = 0; long writeNanos = 0; long triplesWritten = 0; diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/resources/ai/FrameworkCoverageComputerTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/resources/ai/FrameworkCoverageComputerTest.java index 736492a9167d..d257d63d2c56 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/resources/ai/FrameworkCoverageComputerTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/resources/ai/FrameworkCoverageComputerTest.java @@ -37,7 +37,7 @@ class FrameworkCoverageComputerTest { void computeReportsPerControlStatusFromMatchingRemediationActions() { AIGovernanceFramework framework = new AIGovernanceFramework().withName("EU_AI_Act"); List controls = List.of(control("art-10"), control("art-14")); - List assets = + List> assets = List.of( compliantApplication("claimsCopilot", remediation("art-10", RemediationStatus.Open)), compliantApplication("financeCopilot")); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/resources/context/ContextMemorySchemaTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/resources/context/ContextMemorySchemaTest.java index ae9462c4c7d0..7f7e45ebf6f7 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/resources/context/ContextMemorySchemaTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/resources/context/ContextMemorySchemaTest.java @@ -14,12 +14,18 @@ package org.openmetadata.service.resources.context; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.List; import java.util.UUID; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.junit.jupiter.params.provider.ValueSource; +import org.openmetadata.schema.api.context.CreateContextMemory; import org.openmetadata.schema.entity.context.ContextMemory; import org.openmetadata.schema.entity.context.ContextMemorySourceType; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.ContextMemoryType; import org.openmetadata.schema.entity.context.MemoryDispute; import org.openmetadata.schema.type.EntityReference; @@ -30,18 +36,42 @@ /** Pins lifecycle wire values shared with ai-platform and Collate. */ class ContextMemorySchemaTest { + @ParameterizedTest + @ValueSource(strings = {"Superseded", "Invalidated"}) + void memoryRetirementStagesAreNotShared(String value) { + assertThrows(IllegalArgumentException.class, () -> EntityStatus.fromValue(value)); + } + + @Test + void memoryAndCreateRequestUseTheirOwnStatusEnum() throws NoSuchMethodException { + Class memoryStatus = ContextMemory.class.getMethod("getEntityStatus").getReturnType(); + assertEquals( + "org.openmetadata.schema.entity.context.ContextMemoryStatus", memoryStatus.getName()); + assertEquals( + memoryStatus, CreateContextMemory.class.getMethod("getEntityStatus").getReturnType()); + } + + @Test + void memoryRetirementStagesHaveDistinctWireValues() { + assertEquals("Superseded", ContextMemoryStatus.fromValue("Superseded").value()); + assertEquals("Invalidated", ContextMemoryStatus.fromValue("Invalidated").value()); + } + @Test void lifecycleEnumsCarryTheirWireValues() { assertEquals(ContextMemoryType.LEARNING, ContextMemoryType.fromValue("Learning")); assertEquals( ContextMemorySourceType.CONVERSATION_EXTRACTION, ContextMemorySourceType.fromValue("ConversationExtraction")); - assertEquals(EntityStatus.DEPRECATED, EntityStatus.fromValue("Deprecated")); - assertEquals(EntityStatus.REJECTED, EntityStatus.fromValue("Rejected")); + assertEquals(ContextMemoryStatus.DEPRECATED, ContextMemoryStatus.fromValue("Deprecated")); + assertEquals(ContextMemoryStatus.REJECTED, ContextMemoryStatus.fromValue("Rejected")); } - @Test - void lifecycleFieldsSurviveAJsonRoundTrip() { + @ParameterizedTest + @EnumSource( + value = ContextMemoryStatus.class, + names = {"DEPRECATED", "SUPERSEDED"}) + void lifecycleFieldsSurviveAJsonRoundTrip(ContextMemoryStatus status) { EntityReference keeper = new EntityReference().withId(UUID.randomUUID()).withType(Entity.CONTEXT_MEMORY); MemoryDispute dispute = @@ -53,13 +83,14 @@ void lifecycleFieldsSurviveAJsonRoundTrip() { new ContextMemory() .withId(UUID.randomUUID()) .withName("superseded-memory") - .withEntityStatus(EntityStatus.DEPRECATED) + .withEntityStatus(status) .withSupersededBy(keeper) .withStatusReason("Duplicate of the keeper") .withDisputes(List.of(dispute)); ContextMemory copy = JsonUtils.readValue(JsonUtils.pojoToJson(memory), ContextMemory.class); + assertEquals(status, copy.getEntityStatus()); assertEquals(keeper, copy.getSupersededBy()); assertEquals("Duplicate of the keeper", copy.getStatusReason()); assertEquals(List.of(dispute), copy.getDisputes()); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/resources/context/ContextMemoryStatusTransitionTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/resources/context/ContextMemoryStatusTransitionTest.java index 09039bc28886..6a6f9d718a5c 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/resources/context/ContextMemoryStatusTransitionTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/resources/context/ContextMemoryStatusTransitionTest.java @@ -6,66 +6,95 @@ import java.util.Set; import org.junit.jupiter.api.Test; -import org.openmetadata.schema.type.EntityStatus; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.service.governance.EntityLifecycle; import org.openmetadata.service.jdbi3.ContextMemoryRepository; class ContextMemoryStatusTransitionTest { + @ParameterizedTest + @ValueSource(strings = {"Superseded", "Invalidated"}) + void explicitRetirementStagesResolvePendingAndApprovedMemories(String value) { + ContextMemoryStatus retired = ContextMemoryStatus.fromValue(value); + + assertTrue(MEMORY.allows(ContextMemoryStatus.UNPROCESSED, retired)); + assertTrue(MEMORY.allows(ContextMemoryStatus.APPROVED, retired)); + assertTrue(MEMORY.allows(retired, ContextMemoryStatus.APPROVED)); + assertTrue(MEMORY.allows(retired, ContextMemoryStatus.UNPROCESSED)); + assertTrue(MEMORY.allows(retired, ContextMemoryStatus.ARCHIVED)); + assertFalse(MEMORY.allows(ContextMemoryStatus.DRAFT, retired)); + assertFalse(MEMORY.allows(retired, ContextMemoryStatus.DRAFT)); + for (ContextMemoryStatus other : + Set.of( + ContextMemoryStatus.SUPERSEDED, + ContextMemoryStatus.INVALIDATED, + ContextMemoryStatus.DEPRECATED, + ContextMemoryStatus.REJECTED)) { + if (other != retired) { + assertFalse(MEMORY.allows(retired, other)); + } + } + } + @Test void unprocessedMemoriesCanBeResolvedAndReviewedMemoriesCanBeExplicitlyRequeued() { - assertTrue(MEMORY.allows(EntityStatus.UNPROCESSED, EntityStatus.APPROVED)); - assertTrue(MEMORY.allows(EntityStatus.UNPROCESSED, EntityStatus.REJECTED)); - assertTrue(MEMORY.allows(EntityStatus.UNPROCESSED, EntityStatus.DEPRECATED)); - assertTrue(MEMORY.allows(EntityStatus.APPROVED, EntityStatus.UNPROCESSED)); - assertTrue(MEMORY.allows(EntityStatus.REJECTED, EntityStatus.UNPROCESSED)); + assertTrue(MEMORY.allows(ContextMemoryStatus.UNPROCESSED, ContextMemoryStatus.APPROVED)); + assertTrue(MEMORY.allows(ContextMemoryStatus.UNPROCESSED, ContextMemoryStatus.REJECTED)); + assertTrue(MEMORY.allows(ContextMemoryStatus.UNPROCESSED, ContextMemoryStatus.DEPRECATED)); + assertTrue(MEMORY.allows(ContextMemoryStatus.APPROVED, ContextMemoryStatus.UNPROCESSED)); + assertTrue(MEMORY.allows(ContextMemoryStatus.REJECTED, ContextMemoryStatus.UNPROCESSED)); } - private static final EntityLifecycle MEMORY = ContextMemoryRepository.LIFECYCLE; + private static final EntityLifecycle MEMORY = + ContextMemoryRepository.LIFECYCLE; @Test void memoryStagesIncludePendingAndResolvedStates() { assertEquals( Set.of( - EntityStatus.UNPROCESSED, - EntityStatus.DRAFT, - EntityStatus.APPROVED, - EntityStatus.DEPRECATED, - EntityStatus.REJECTED, - EntityStatus.ARCHIVED), + ContextMemoryStatus.UNPROCESSED, + ContextMemoryStatus.DRAFT, + ContextMemoryStatus.APPROVED, + ContextMemoryStatus.DEPRECATED, + ContextMemoryStatus.REJECTED, + ContextMemoryStatus.SUPERSEDED, + ContextMemoryStatus.INVALIDATED, + ContextMemoryStatus.ARCHIVED), MEMORY.stages()); } @Test void memoryMovesForwardAndCanBeRestoredFromTheArchive() { - assertTrue(MEMORY.allows(EntityStatus.DRAFT, EntityStatus.APPROVED)); - assertTrue(MEMORY.allows(EntityStatus.DRAFT, EntityStatus.ARCHIVED)); - assertTrue(MEMORY.allows(EntityStatus.APPROVED, EntityStatus.ARCHIVED)); - assertTrue(MEMORY.allows(EntityStatus.APPROVED, EntityStatus.DEPRECATED)); - assertTrue(MEMORY.allows(EntityStatus.APPROVED, EntityStatus.REJECTED)); - assertTrue(MEMORY.allows(EntityStatus.ARCHIVED, EntityStatus.APPROVED)); - assertTrue(MEMORY.allows(EntityStatus.DEPRECATED, EntityStatus.APPROVED)); - assertTrue(MEMORY.allows(EntityStatus.REJECTED, EntityStatus.APPROVED)); + assertTrue(MEMORY.allows(ContextMemoryStatus.DRAFT, ContextMemoryStatus.APPROVED)); + assertTrue(MEMORY.allows(ContextMemoryStatus.DRAFT, ContextMemoryStatus.ARCHIVED)); + assertTrue(MEMORY.allows(ContextMemoryStatus.APPROVED, ContextMemoryStatus.ARCHIVED)); + assertTrue(MEMORY.allows(ContextMemoryStatus.APPROVED, ContextMemoryStatus.DEPRECATED)); + assertTrue(MEMORY.allows(ContextMemoryStatus.APPROVED, ContextMemoryStatus.REJECTED)); + assertTrue(MEMORY.allows(ContextMemoryStatus.ARCHIVED, ContextMemoryStatus.APPROVED)); + assertTrue(MEMORY.allows(ContextMemoryStatus.DEPRECATED, ContextMemoryStatus.APPROVED)); + assertTrue(MEMORY.allows(ContextMemoryStatus.REJECTED, ContextMemoryStatus.APPROVED)); } @Test void memoryNeverGoesBackToDraft() { - assertFalse(MEMORY.allows(EntityStatus.APPROVED, EntityStatus.DRAFT)); - assertFalse(MEMORY.allows(EntityStatus.ARCHIVED, EntityStatus.DRAFT)); + assertFalse(MEMORY.allows(ContextMemoryStatus.APPROVED, ContextMemoryStatus.DRAFT)); + assertFalse(MEMORY.allows(ContextMemoryStatus.ARCHIVED, ContextMemoryStatus.DRAFT)); } @Test void memorySavedWithoutAStageMayTakeAnyMemoryStage() { - assertTrue(MEMORY.allows(null, EntityStatus.DRAFT)); - assertTrue(MEMORY.allows(null, EntityStatus.ARCHIVED)); - assertFalse(MEMORY.allows(null, EntityStatus.IN_REVIEW)); + assertTrue(MEMORY.allows(null, ContextMemoryStatus.DRAFT)); + assertTrue(MEMORY.allows(null, ContextMemoryStatus.ARCHIVED)); + assertFalse(MEMORY.includesCode("In Review")); } @Test void retiredMemoriesCannotSkipBetweenRetiredStagesOrReturnToDraft() { - assertFalse(MEMORY.allows(EntityStatus.DEPRECATED, EntityStatus.REJECTED)); - assertFalse(MEMORY.allows(EntityStatus.REJECTED, EntityStatus.DEPRECATED)); - assertFalse(MEMORY.allows(EntityStatus.DEPRECATED, EntityStatus.DRAFT)); - assertFalse(MEMORY.allows(EntityStatus.REJECTED, EntityStatus.DRAFT)); + assertFalse(MEMORY.allows(ContextMemoryStatus.DEPRECATED, ContextMemoryStatus.REJECTED)); + assertFalse(MEMORY.allows(ContextMemoryStatus.REJECTED, ContextMemoryStatus.DEPRECATED)); + assertFalse(MEMORY.allows(ContextMemoryStatus.DEPRECATED, ContextMemoryStatus.DRAFT)); + assertFalse(MEMORY.allows(ContextMemoryStatus.REJECTED, ContextMemoryStatus.DRAFT)); } } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/resources/context/ContextMemoryVisibilityTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/resources/context/ContextMemoryVisibilityTest.java index 1e9216864b53..2417076dba00 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/resources/context/ContextMemoryVisibilityTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/resources/context/ContextMemoryVisibilityTest.java @@ -284,7 +284,7 @@ void testIsOwnedBy_returnsFalseWhenNoOwners() { */ @Test void testEnforceVisibility_onEntityInterface_deniesAnotherUsersPrivateMemory() { - EntityInterface privateOwnedByAlice = memoryOwnedBy(ALICE, MemoryVisibility.PRIVATE); + EntityInterface privateOwnedByAlice = memoryOwnedBy(ALICE, MemoryVisibility.PRIVATE); SecurityContext bob = securityContextFor(BOB); withSubject( @@ -298,7 +298,7 @@ void testEnforceVisibility_onEntityInterface_deniesAnotherUsersPrivateMemory() { @Test void testEnforceVisibility_onEntityInterface_allowsTheOwnersOwnPrivateMemory() { - EntityInterface privateOwnedByAlice = memoryOwnedBy(ALICE, MemoryVisibility.PRIVATE); + EntityInterface privateOwnedByAlice = memoryOwnedBy(ALICE, MemoryVisibility.PRIVATE); SecurityContext alice = securityContextFor(ALICE); withSubject( @@ -311,7 +311,7 @@ void testEnforceVisibility_onEntityInterface_allowsTheOwnersOwnPrivateMemory() { @Test void testEnforceVisibility_onEntityInterface_ignoresTypesWithoutVisibilityRules() { - EntityInterface table = new Table().withName("orders").withFullyQualifiedName("s.d.orders"); + EntityInterface table = new Table().withName("orders").withFullyQualifiedName("s.d.orders"); assertDoesNotThrow( () -> ContextMemoryVisibility.enforceVisibility(table, securityContextFor(BOB))); @@ -319,7 +319,7 @@ void testEnforceVisibility_onEntityInterface_ignoresTypesWithoutVisibilityRules( @Test void testEnforceVisibility_onEntityInterface_letsAnAdminReadEveryMemory() { - EntityInterface privateOwnedByAlice = memoryOwnedBy(ALICE, MemoryVisibility.PRIVATE); + EntityInterface privateOwnedByAlice = memoryOwnedBy(ALICE, MemoryVisibility.PRIVATE); SecurityContext admin = securityContextFor(BOB); try (MockedStatic authorizer = Mockito.mockStatic(DefaultAuthorizer.class)) { diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/resources/filters/ETagResponseFilterTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/resources/filters/ETagResponseFilterTest.java index 13c418852b67..18cd6d573a9c 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/resources/filters/ETagResponseFilterTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/resources/filters/ETagResponseFilterTest.java @@ -32,7 +32,7 @@ class ETagResponseFilterTest { @Test void getResponseGetsETagAndCacheControl() { - EntityInterface entity = entity(1.2, 111L); + EntityInterface entity = entity(1.2, 111L); ContainerResponseContext res = response(OK, entity); filter.filter(request("GET", null), res); @@ -43,7 +43,7 @@ void getResponseGetsETagAndCacheControl() { @Test void mutationResponsesGetETag() { - EntityInterface entity = entity(2.0, 222L); + EntityInterface entity = entity(2.0, 222L); ContainerResponseContext patch = response(OK, entity); filter.filter(request("PATCH", null), patch); @@ -60,7 +60,7 @@ void mutationResponsesGetETag() { @Test void getWithMatchingIfNoneMatchBecomes304() { - EntityInterface entity = entity(3.1, 333L); + EntityInterface entity = entity(3.1, 333L); String etag = EntityETag.generateETag(entity); ContainerResponseContext res = response(OK, entity); @@ -78,7 +78,7 @@ void staleIfNoneMatchIsNotShortCircuitedAfterVoteChangesBody() { // (stale body). Before the content-based ETag fix this returned 304 and the header stuck. UUID id = UUID.randomUUID(); String staleEtag = EntityETag.generateETag(table(id, 1.0, 100L, 0)); - EntityInterface afterVote = table(id, 1.0, 100L, 1); + EntityInterface afterVote = table(id, 1.0, 100L, 1); ContainerResponseContext res = response(OK, afterVote); filter.filter(request("GET", staleEtag), res); @@ -90,7 +90,7 @@ void staleIfNoneMatchIsNotShortCircuitedAfterVoteChangesBody() { @Test void mutationWithMatchingIfNoneMatchIsNotShortCircuited() { - EntityInterface entity = entity(3.1, 333L); + EntityInterface entity = entity(3.1, 333L); String etag = EntityETag.generateETag(entity); ContainerResponseContext res = response(OK, entity); @@ -111,7 +111,7 @@ void nonEntityResponseGetsNoETag() { @Test void nonSuccessResponseGetsNoETag() { - EntityInterface entity = entity(1.0, 1L); + EntityInterface entity = entity(1.0, 1L); ContainerResponseContext res = response(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), entity); @@ -136,7 +136,7 @@ private static ContainerResponseContext response(int status, Object entity) { return res; } - private static EntityInterface entity(double version, long updatedAt) { + private static EntityInterface entity(double version, long updatedAt) { return new Table() .withId(UUID.randomUUID()) .withName("etag_table") @@ -144,7 +144,7 @@ private static EntityInterface entity(double version, long updatedAt) { .withUpdatedAt(updatedAt); } - private static EntityInterface table(UUID id, double version, long updatedAt, int upVotes) { + private static EntityInterface table(UUID id, double version, long updatedAt, int upVotes) { return new Table() .withId(id) .withName("etag_table") diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/search/SearchIndexRetryWorkerTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/search/SearchIndexRetryWorkerTest.java index 72c98997e005..934a4bbc9fb7 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/search/SearchIndexRetryWorkerTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/search/SearchIndexRetryWorkerTest.java @@ -212,7 +212,7 @@ void testCaseRetryPreservesThenFencesRelationshipFields() throws Exception { SearchIndexRetryWorker retryWorker = new SearchIndexRetryWorker(mock(CollectionDAO.class), searchRepository); UUID testCaseId = UUID.randomUUID(); - EntityInterface testCase = mock(EntityInterface.class); + EntityInterface testCase = mock(EntityInterface.class); when(testCase.getId()).thenReturn(testCaseId); when(testCase.getEntityReference()) .thenReturn( @@ -293,7 +293,7 @@ void successfulRetryReplaysDurablePropagationContext() throws Exception { SearchRepository searchRepository = mock(SearchRepository.class); SearchIndexRetryWorker retryWorker = new SearchIndexRetryWorker(mock(CollectionDAO.class), searchRepository); - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); ChangeDescription changeDescription = new ChangeDescription() .withPreviousVersion(1.0) diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/search/SearchRepositoryBehaviorTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/search/SearchRepositoryBehaviorTest.java index 7aa336907dd3..55411dbc5384 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/search/SearchRepositoryBehaviorTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/search/SearchRepositoryBehaviorTest.java @@ -50,6 +50,7 @@ import org.mockito.InOrder; import org.mockito.MockedConstruction; import org.mockito.MockedStatic; +import org.mockito.Mockito; import org.openmetadata.schema.EntityInterface; import org.openmetadata.schema.EntityTimeSeriesInterface; import org.openmetadata.schema.api.entityRelationship.SearchEntityRelationshipRequest; @@ -64,6 +65,7 @@ import org.openmetadata.schema.configuration.LLMEmbeddingsConfig.Provider; import org.openmetadata.schema.dataInsight.DataInsightChartResult; import org.openmetadata.schema.entity.classification.Tag; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.data.Pipeline; import org.openmetadata.schema.entity.data.PipelineStatus; import org.openmetadata.schema.entity.data.QueryCostSearchResult; @@ -82,7 +84,6 @@ import org.openmetadata.schema.type.Column; import org.openmetadata.schema.type.ColumnDataType; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.FieldChange; import org.openmetadata.schema.type.TagLabel; import org.openmetadata.schema.type.UsageDetails; @@ -601,7 +602,7 @@ void deleteIndexDeletesConcreteIndexWhenItExists() { @Test void createEntityIndexBuildsAndWritesSearchDocument() throws IOException { UUID entityId = UUID.randomUUID(); - EntityInterface entity = mockEntity(Entity.TABLE, entityId, "orders"); + EntityInterface entity = mockEntity(Entity.TABLE, entityId, "orders"); when(searchIndexFactory.buildIndex(Entity.TABLE, entity)) .thenReturn(new MapBackedSearchIndex(entity, Map.of("name", "orders"))); @@ -647,7 +648,7 @@ void createEntityIndexDeletesStaleDocumentForNonIndexableEntity() throws IOExcep @Test void createEntityIndexPreservesEntityTypeWhenSearchIsUnavailable() throws IOException { UUID entityId = UUID.randomUUID(); - EntityInterface entity = mockEntity(Entity.TABLE, entityId, "orders"); + EntityInterface entity = mockEntity(Entity.TABLE, entityId, "orders"); when(searchClient.isClientAvailable()).thenReturn(false); try (MockedStatic retryQueue = mockStatic(SearchIndexRetryQueue.class)) { @@ -667,8 +668,8 @@ void createEntityIndexPreservesEntityTypeWhenSearchIsUnavailable() throws IOExce @Test void createEntitiesIndexBulkWritesDocumentsOfTheSameType() throws IOException { - EntityInterface first = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); - EntityInterface second = mockEntity(Entity.TABLE, UUID.randomUUID(), "customers"); + EntityInterface first = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface second = mockEntity(Entity.TABLE, UUID.randomUUID(), "customers"); when(searchIndexFactory.buildIndex(Entity.TABLE, first)) .thenReturn(new MapBackedSearchIndex(first, Map.of("name", "orders"))); when(searchIndexFactory.buildIndex(Entity.TABLE, second)) @@ -685,8 +686,8 @@ void createEntitiesIndexBulkWritesDocumentsOfTheSameType() throws IOException { @Test void createEntitiesIndexDoesNotRetryNonIndexableEntitiesWhenSearchIsUnavailable() throws IOException { - EntityInterface hidden = mockEntity(Entity.TABLE, UUID.randomUUID(), "private-memory"); - EntityInterface visible = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface hidden = mockEntity(Entity.TABLE, UUID.randomUUID(), "private-memory"); + EntityInterface visible = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); EntityRepository tableRepository = Entity.getEntityRepository(Entity.TABLE); doReturn(false).when(tableRepository).isSearchIndexable(hidden); when(searchClient.isClientAvailable()).thenReturn(false); @@ -714,8 +715,8 @@ void createEntitiesIndexDoesNotRetryNonIndexableEntitiesWhenSearchIsUnavailable( @Test void createEntitiesIndexSkipsFailedDocumentsAndContinuesBulkCreate() throws IOException { - EntityInterface broken = mockEntity(Entity.TABLE, UUID.randomUUID(), "broken"); - EntityInterface valid = mockEntity(Entity.TABLE, UUID.randomUUID(), "customers"); + EntityInterface broken = mockEntity(Entity.TABLE, UUID.randomUUID(), "broken"); + EntityInterface valid = mockEntity(Entity.TABLE, UUID.randomUUID(), "customers"); when(searchIndexFactory.buildIndex(Entity.TABLE, broken)) .thenThrow(new IllegalStateException("cannot index broken entity")); when(searchIndexFactory.buildIndex(Entity.TABLE, valid)) @@ -733,8 +734,8 @@ void createEntitiesIndexSkipsFailedDocumentsAndContinuesBulkCreate() throws IOEx @Test void createEntitiesIndexSkipsEntityWhenIndexabilityCheckFails() throws IOException { - EntityInterface broken = mockEntity(Entity.TABLE, UUID.randomUUID(), "broken"); - EntityInterface valid = mockEntity(Entity.TABLE, UUID.randomUUID(), "customers"); + EntityInterface broken = mockEntity(Entity.TABLE, UUID.randomUUID(), "broken"); + EntityInterface valid = mockEntity(Entity.TABLE, UUID.randomUUID(), "customers"); when(broken.getEntityReference()) .thenThrow(new IllegalStateException("cannot resolve entity reference")); when(searchIndexFactory.buildIndex(Entity.TABLE, valid)) @@ -752,8 +753,8 @@ void createEntitiesIndexSkipsEntityWhenIndexabilityCheckFails() throws IOExcepti @Test void createEntitiesIndexSkipsBulkCreateWhenNoDocumentCanBeBuilt() throws IOException { - EntityInterface first = mockEntity(Entity.TABLE, UUID.randomUUID(), "broken_1"); - EntityInterface second = mockEntity(Entity.TABLE, UUID.randomUUID(), "broken_2"); + EntityInterface first = mockEntity(Entity.TABLE, UUID.randomUUID(), "broken_1"); + EntityInterface second = mockEntity(Entity.TABLE, UUID.randomUUID(), "broken_2"); when(searchIndexFactory.buildIndex(Entity.TABLE, first)) .thenThrow(new IllegalStateException("cannot index first")); when(searchIndexFactory.buildIndex(Entity.TABLE, second)) @@ -951,7 +952,8 @@ void deleteByScriptUsesTheMappedEntityIndex() throws IOException { @Test void propagateInheritedFieldsToChildrenUsesServiceParentFieldForServiceDisplayNameChanges() throws IOException { - EntityInterface serviceEntity = mockEntity(Entity.DATABASE_SERVICE, UUID.randomUUID(), "svc"); + EntityInterface serviceEntity = + mockEntity(Entity.DATABASE_SERVICE, UUID.randomUUID(), "svc"); ChangeDescription changeDescription = changeDescription( List.of(), @@ -985,7 +987,7 @@ void propagateInheritedFieldsToChildrenUsesServiceParentFieldForServiceDisplayNa @Test void propagateInheritedFieldsToChildrenUpdatesDomainChildrenAndDataProductsSeparately() throws IOException { - EntityInterface domainEntity = mockEntity(Entity.DOMAIN, UUID.randomUUID(), "finance"); + EntityInterface domainEntity = mockEntity(Entity.DOMAIN, UUID.randomUUID(), "finance"); ChangeDescription changeDescription = changeDescription( List.of(), @@ -1016,7 +1018,7 @@ void propagateInheritedFieldsToChildrenSkipsAllChangesForTimeSeriesChildren() th .childAliases(List.of(Entity.TEST_CASE_RESOLUTION_STATUS, Entity.TEST_CASE_RESULT)) .indexMappingFile("/elasticsearch/%s/test_case_index_mapping.json") .build(); - EntityInterface testCase = mockEntity(Entity.TEST_CASE, UUID.randomUUID(), "test_case"); + EntityInterface testCase = mockEntity(Entity.TEST_CASE, UUID.randomUUID(), "test_case"); when(testCase.getOwners()) .thenReturn(List.of(new EntityReference().withId(UUID.randomUUID()).withType(Entity.USER))); when(testCase.getDomains()) @@ -1046,7 +1048,7 @@ void propagateInheritedFieldsToChildrenSkipsAllChangesForTimeSeriesChildren() th @Test void propagateInheritedFieldsToChildrenOnlyTargetsNonTimeSeriesChildren() throws IOException { - EntityInterface testCase = mockEntity(Entity.TEST_CASE, UUID.randomUUID(), "test_case"); + EntityInterface testCase = mockEntity(Entity.TEST_CASE, UUID.randomUUID(), "test_case"); when(testCase.getOwners()) .thenReturn(List.of(new EntityReference().withId(UUID.randomUUID()).withType(Entity.USER))); when(testCase.getDomains()) @@ -1095,7 +1097,7 @@ void propagateInheritedFieldsToChildrenIncludesUnregisteredChildAliases() throws .childAliases(List.of("unregisteredChild", Entity.TABLE_COLUMN)) .indexMappingFile("/elasticsearch/%s/test_case_index_mapping.json") .build(); - EntityInterface testCase = mockEntity(Entity.TEST_CASE, UUID.randomUUID(), "test_case"); + EntityInterface testCase = mockEntity(Entity.TEST_CASE, UUID.randomUUID(), "test_case"); ChangeDescription changeDescription = changeDescription( List.of(), @@ -1123,7 +1125,7 @@ void propagateInheritedFieldsToChildrenIncludesUnregisteredChildAliases() throws @Test void deleteEntityByFqnPrefixUsesEntityIndex() throws IOException { - EntityInterface entity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface entity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); repository.deleteEntityByFQNPrefix(entity); @@ -1434,7 +1436,7 @@ void propagateCertificationTagsUsesQuotedOldNameWhenTagHasNoParentFqn() { @Test void deleteAndSoftDeleteOperationsSkipUnsupportedTypesButHandleMappedEntities() throws IOException { - EntityInterface entity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface entity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); SearchRepository spyRepository = spy(repository); doNothing().when(spyRepository).deleteOrUpdateChildren(any(), any()); doNothing().when(spyRepository).softDeleteOrRestoredChildren(any(), any(), anyBoolean()); @@ -1454,7 +1456,7 @@ void deleteAndSoftDeleteOperationsSkipUnsupportedTypesButHandleMappedEntities() verify(queryRepository) .forEachQueryBatchForDomainSource(eq(Entity.TABLE), eq(entityId), eq(entityFqn), any()); - EntityInterface unsupported = mockEntity("unsupported", UUID.randomUUID(), "skip-me"); + EntityInterface unsupported = mockEntity("unsupported", UUID.randomUUID(), "skip-me"); spyRepository.deleteEntityIndex(unsupported); verify(searchClient, never()) .deleteEntity("cluster_unsupported_search_index", unsupported.getId().toString()); @@ -1462,7 +1464,7 @@ void deleteAndSoftDeleteOperationsSkipUnsupportedTypesButHandleMappedEntities() @Test void deleteEntityIndexRemovesTagReferencesFromChildren() { - EntityInterface tag = mockEntity(Entity.TAG, UUID.randomUUID(), "revenue"); + EntityInterface tag = mockEntity(Entity.TAG, UUID.randomUUID(), "revenue"); when(tag.getFullyQualifiedName()).thenReturn("Glossary.Revenue"); repository.deleteEntityIndex(tag); @@ -1477,7 +1479,8 @@ void deleteEntityIndexRemovesTagReferencesFromChildren() { @Test void deleteEntityIndexDeletesServiceChildrenByServiceId() throws Exception { - EntityInterface service = mockEntity(Entity.DATABASE_SERVICE, UUID.randomUUID(), "warehouse"); + EntityInterface service = + mockEntity(Entity.DATABASE_SERVICE, UUID.randomUUID(), "warehouse"); repository.deleteEntityIndex(service); @@ -1491,7 +1494,7 @@ void deleteEntityIndexDeletesServiceChildrenByServiceId() throws Exception { @Test void deleteEntityIndexDeletesGenericChildrenByEntityTypeId() throws Exception { - EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); repository.deleteEntityIndex(table); @@ -1521,9 +1524,9 @@ void deleteEntityIndexRemovesDescendantColumnsForDatabaseSubtreeAncestors() thro Entity.DATABASE_SCHEMA, DATABASE_SCHEMA_MAPPING, Entity.TABLE_COLUMN, COLUMN_MAPPING), "cluster"); - EntityInterface service = mockEntity(Entity.DATABASE_SERVICE, UUID.randomUUID(), "svc"); - EntityInterface database = mockEntity(Entity.DATABASE, UUID.randomUUID(), "db"); - EntityInterface schema = mockEntity(Entity.DATABASE_SCHEMA, UUID.randomUUID(), "schema"); + EntityInterface service = mockEntity(Entity.DATABASE_SERVICE, UUID.randomUUID(), "svc"); + EntityInterface database = mockEntity(Entity.DATABASE, UUID.randomUUID(), "db"); + EntityInterface schema = mockEntity(Entity.DATABASE_SCHEMA, UUID.randomUUID(), "schema"); repo.deleteEntityIndex(service); repo.deleteEntityIndex(database); @@ -1589,7 +1592,7 @@ void tableChildUpdatesSkipTheColumnAliasWhileColumnIndexingIsOff() throws Except newRepository( Map.of(Entity.TABLE, tableWithChildren, Entity.TABLE_COLUMN, COLUMN_MAPPING), "cluster"); - EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); try (MockedStatic settingsCache = columnIndexing(false)) { repo.deleteEntityIndex(table); @@ -1758,7 +1761,8 @@ private static Table tableWithOneColumn() { @Test void inheritedFieldChangesMarkAddedOwnersDomainsFollowersAndNestedDisplayName() throws Exception { - EntityInterface serviceEntity = mockEntity(Entity.DATABASE_SERVICE, UUID.randomUUID(), "svc"); + EntityInterface serviceEntity = + mockEntity(Entity.DATABASE_SERVICE, UUID.randomUUID(), "svc"); when(serviceEntity.getOwners()) .thenReturn(List.of(new EntityReference().withId(UUID.randomUUID()).withType(Entity.USER))); when(serviceEntity.getDomains()) @@ -1804,7 +1808,7 @@ void inheritedFieldChangesMarkAddedOwnersDomainsFollowersAndNestedDisplayName() @Test void inheritedFieldChangesHandleUpdatedTestSuitesAndDeletedInheritedReferences() throws Exception { - EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); when(tableEntity.getOwners()) .thenReturn(List.of(new EntityReference().withId(UUID.randomUUID()).withType(Entity.USER))); when(tableEntity.getDomains()) @@ -1843,7 +1847,7 @@ void inheritedFieldChangesHandleUpdatedTestSuitesAndDeletedInheritedReferences() @Test void inheritedFieldChangesSimpleValueBindsValueAsParamAndTerminatesStatements() throws Exception { - EntityInterface tagEntity = mockEntity(Entity.TAG, UUID.randomUUID(), "PII.Sensitive"); + EntityInterface tagEntity = mockEntity(Entity.TAG, UUID.randomUUID(), "PII.Sensitive"); String renamedTag = "O'Brien's Tag"; String certification = "Gold's"; @@ -1876,7 +1880,7 @@ void inheritedFieldChangesSimpleValueBindsValueAsParamAndTerminatesStatements() @Test @SuppressWarnings("unchecked") void inheritedFieldChangesAddTagsMarksThemAsDerived() throws Exception { - EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); TagLabel tag1 = new TagLabel() @@ -1915,7 +1919,7 @@ void inheritedFieldChangesAddTagsMarksThemAsDerived() throws Exception { @Test @SuppressWarnings("unchecked") void inheritedFieldChangesDeleteTagsMarksThemAsDerived() throws Exception { - EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); TagLabel tag = new TagLabel() @@ -1948,7 +1952,7 @@ void inheritedFieldChangesDeleteTagsMarksThemAsDerived() throws Exception { @Test @SuppressWarnings("unchecked") void inheritedFieldChangesUpdateTagsPopulatesBothAddedAndDeleted() throws Exception { - EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); TagLabel oldTag = new TagLabel() @@ -1992,7 +1996,7 @@ void inheritedFieldChangesUpdateTagsPopulatesBothAddedAndDeleted() throws Except @Test void inheritedFieldChangesIgnoreTagsForEntityWithoutTagDescriptor() throws Exception { - EntityInterface domainEntity = mockEntity(Entity.DOMAIN, UUID.randomUUID(), "engineering"); + EntityInterface domainEntity = mockEntity(Entity.DOMAIN, UUID.randomUUID(), "engineering"); TagLabel tag = new TagLabel() @@ -2016,7 +2020,7 @@ void inheritedFieldChangesIgnoreTagsForEntityWithoutTagDescriptor() throws Excep @Test void inheritedFieldChangesTagAddScriptContainsDedupAndSortLogic() throws Exception { - EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); TagLabel tag = new TagLabel() @@ -2041,7 +2045,7 @@ void inheritedFieldChangesTagAddScriptContainsDedupAndSortLogic() throws Excepti @Test void inheritedFieldChangesTagDeleteScriptRemovesByFqn() throws Exception { - EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); TagLabel tag = new TagLabel() @@ -2069,7 +2073,7 @@ void inheritedFieldChangesTagDeleteScriptRemovesByFqn() throws Exception { @Test @SuppressWarnings("unchecked") void inheritedFieldChangesTagAddWithEmptyListProducesEmptyData() throws Exception { - EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); String emptyTagsJson = JsonUtils.pojoToJson(List.of()); @@ -2090,7 +2094,7 @@ void inheritedFieldChangesTagAddWithEmptyListProducesEmptyData() throws Exceptio @Test @SuppressWarnings("unchecked") void inheritedFieldChangesAddDataProductsOnTableMarksInherited() throws Exception { - EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); UUID dpId = UUID.randomUUID(); when(tableEntity.getDataProducts()) .thenReturn( @@ -2120,7 +2124,7 @@ void inheritedFieldChangesAddDataProductsOnTableMarksInherited() throws Exceptio @Test @SuppressWarnings("unchecked") void inheritedFieldChangesDeleteDataProductsOnTable() throws Exception { - EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); UUID dpId = UUID.randomUUID(); when(tableEntity.getDataProducts()) .thenReturn( @@ -2149,7 +2153,7 @@ void inheritedFieldChangesDeleteDataProductsOnTable() throws Exception { @Test @SuppressWarnings("unchecked") void inheritedFieldChangesUpdateDataProductsOnTable() throws Exception { - EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); UUID dpId = UUID.randomUUID(); when(tableEntity.getDataProducts()) .thenReturn( @@ -2177,7 +2181,7 @@ void inheritedFieldChangesUpdateDataProductsOnTable() throws Exception { @Test void inheritedFieldChangesAddRawReplaceTestSuites() throws Exception { - EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); ChangeDescription changeDescription = changeDescription( @@ -2197,7 +2201,7 @@ void inheritedFieldChangesAddRawReplaceTestSuites() throws Exception { @Test void inheritedFieldChangesDeleteRawReplaceTestSuites() throws Exception { - EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); ChangeDescription changeDescription = changeDescription( @@ -2217,7 +2221,8 @@ void inheritedFieldChangesDeleteRawReplaceTestSuites() throws Exception { @Test void inheritedFieldChangesDeleteNestedFieldDisplayName() throws Exception { - EntityInterface serviceEntity = mockEntity(Entity.DATABASE_SERVICE, UUID.randomUUID(), "svc"); + EntityInterface serviceEntity = + mockEntity(Entity.DATABASE_SERVICE, UUID.randomUUID(), "svc"); ChangeDescription changeDescription = changeDescription( @@ -2236,7 +2241,7 @@ void inheritedFieldChangesDeleteNestedFieldDisplayName() throws Exception { @Test void inheritedFieldChangesEntityReferenceListUpdateMarksInherited() throws Exception { - EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); UUID ownerId = UUID.randomUUID(); when(tableEntity.getOwners()) .thenReturn( @@ -2261,7 +2266,7 @@ void inheritedFieldChangesEntityReferenceListUpdateMarksInherited() throws Excep @Test void inheritedFieldChangesUnknownFieldReturnsEmptyRefList() throws Exception { - EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface tableEntity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); when(tableEntity.getDataProducts()).thenReturn(null); ChangeDescription changeDescription = @@ -2283,7 +2288,7 @@ void inheritedFieldChangesUnknownFieldReturnsEmptyRefList() throws Exception { @Test void getScriptWithParamsBuildsFollowerDescriptionAndReducedQueryDomainUpdates() { - EntityInterface queryEntity = mockEntity(Entity.QUERY, UUID.randomUUID(), "daily_query"); + EntityInterface queryEntity = mockEntity(Entity.QUERY, UUID.randomUUID(), "daily_query"); EntityReference queryDomain = new EntityReference() .withId(UUID.randomUUID()) @@ -2348,9 +2353,10 @@ void getScriptWithParamsBuildsFollowerDescriptionAndReducedQueryDomainUpdates() @Test void requiresPropagationRecognizesGlossaryTagCertificationPageAndRelationshipChanges() throws Exception { - EntityInterface glossaryTerm = mockEntity(Entity.GLOSSARY_TERM, UUID.randomUUID(), "Revenue"); - EntityInterface page = mockEntity(Entity.PAGE, UUID.randomUUID(), "docs"); - EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface glossaryTerm = + mockEntity(Entity.GLOSSARY_TERM, UUID.randomUUID(), "Revenue"); + EntityInterface page = mockEntity(Entity.PAGE, UUID.randomUUID(), "docs"); + EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); Tag certificationTag = mock(Tag.class); EntityReference tagReference = new EntityReference().withId(UUID.randomUUID()).withType(Entity.TAG).withName("Gold"); @@ -2405,7 +2411,7 @@ void requiresPropagationRecognizesGlossaryTagCertificationPageAndRelationshipCha @Test void requiresPropagationReturnsTrueForInheritableFieldAdded() throws Exception { - EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); assertTrue( invokeRequiresPropagation( changeDescription( @@ -2418,7 +2424,7 @@ void requiresPropagationReturnsTrueForInheritableFieldAdded() throws Exception { @Test void requiresPropagationReturnsTrueForInheritableFieldUpdated() throws Exception { - EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); assertTrue( invokeRequiresPropagation( changeDescription( @@ -2432,7 +2438,7 @@ void requiresPropagationReturnsTrueForInheritableFieldUpdated() throws Exception @Test void requiresPropagationReturnsTrueForInheritableFieldDeleted() throws Exception { - EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); assertTrue( invokeRequiresPropagation( changeDescription( @@ -2445,7 +2451,7 @@ void requiresPropagationReturnsTrueForInheritableFieldDeleted() throws Exception @Test void requiresPropagationReturnsFalseForNonInheritableField() throws Exception { - EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); assertFalse( invokeRequiresPropagation( changeDescription( @@ -2462,7 +2468,8 @@ void requiresPropagationReturnsFalseForNonInheritableField() throws Exception { @Test void requiresPropagationReturnsFalseForGlossaryTermNameChangeNotInDescriptors() throws Exception { - EntityInterface glossaryTerm = mockEntity(Entity.GLOSSARY_TERM, UUID.randomUUID(), "Revenue"); + EntityInterface glossaryTerm = + mockEntity(Entity.GLOSSARY_TERM, UUID.randomUUID(), "Revenue"); assertFalse( invokeRequiresPropagation( changeDescription( @@ -2479,7 +2486,8 @@ void requiresPropagationReturnsFalseForGlossaryTermNameChangeNotInDescriptors() @Test void requiresPropagationReturnsTrueForGlossaryTermTagDeleted() throws Exception { - EntityInterface glossaryTerm = mockEntity(Entity.GLOSSARY_TERM, UUID.randomUUID(), "Revenue"); + EntityInterface glossaryTerm = + mockEntity(Entity.GLOSSARY_TERM, UUID.randomUUID(), "Revenue"); assertTrue( invokeRequiresPropagation( changeDescription( @@ -2545,7 +2553,7 @@ void requiresPropagationReturnsTrueForTableCertificationUpdate() throws Exceptio // Regression for issue #28229: a cert-only PATCH on a Table must open the propagation gate // so cascadeCertificationToChildren can push the new cert onto every denormalized child doc // (test_case, test_case_result, test_case_resolution_status, test_suite, column). - EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); assertTrue( invokeRequiresPropagation( changeDescription( @@ -2562,7 +2570,7 @@ void requiresPropagationReturnsTrueForTableCertificationUpdate() throws Exceptio @Test void requiresPropagationReturnsTrueForTableCertificationAdded() throws Exception { - EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); assertTrue( invokeRequiresPropagation( changeDescription( @@ -2575,7 +2583,7 @@ void requiresPropagationReturnsTrueForTableCertificationAdded() throws Exception @Test void requiresPropagationReturnsTrueForTableCertificationRemoved() throws Exception { - EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); assertTrue( invokeRequiresPropagation( changeDescription( @@ -2589,7 +2597,7 @@ void requiresPropagationReturnsTrueForTableCertificationRemoved() throws Excepti @Test void requiresPropagationReturnsFalseForUpstreamEntityRelationshipNotInDescriptors() throws Exception { - EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface table = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); assertFalse( invokeRequiresPropagation( changeDescription( @@ -2630,7 +2638,7 @@ void requiresPropagationReturnsFalseForTagEntityWithTagFieldChangeNotInDescripto @Test void requiresPropagationReturnsFalseForPageParentNotInDescriptors() throws Exception { - EntityInterface page = mockEntity(Entity.PAGE, UUID.randomUUID(), "docs"); + EntityInterface page = mockEntity(Entity.PAGE, UUID.randomUUID(), "docs"); assertFalse( invokeRequiresPropagation( changeDescription( @@ -2643,7 +2651,7 @@ void requiresPropagationReturnsFalseForPageParentNotInDescriptors() throws Excep @Test void propagateToRelatedEntitiesUsesClusteredPageIndexForParentChanges() { - EntityInterface page = mockEntity(Entity.PAGE, UUID.randomUUID(), "child"); + EntityInterface page = mockEntity(Entity.PAGE, UUID.randomUUID(), "child"); when(page.getFullyQualifiedName()).thenReturn("docs.parent.child"); ChangeDescription changeDescription = @@ -2692,7 +2700,8 @@ void propagateToRelatedEntitiesUsesClusteredPageIndexForParentChanges() { @Test void propagateToRelatedEntitiesUpdatesGlossaryTagFqnsAndDisplayNames() { - EntityInterface glossaryTerm = mockEntity(Entity.GLOSSARY_TERM, UUID.randomUUID(), "Revenue"); + EntityInterface glossaryTerm = + mockEntity(Entity.GLOSSARY_TERM, UUID.randomUUID(), "Revenue"); when(glossaryTerm.getFullyQualifiedName()).thenReturn("BusinessGlossary.Income"); ChangeDescription changeDescription = @@ -2765,16 +2774,17 @@ void updateEntityLoadsEntityFromRepositoryAndUpdatesIndex() { EntityReference entityReference = new EntityReference().withId(UUID.randomUUID()).withType(Entity.TABLE); @SuppressWarnings("unchecked") - org.openmetadata.service.jdbi3.EntityRepository entityRepository = + org.openmetadata.service.jdbi3.EntityRepository> entityRepository = mock(org.openmetadata.service.jdbi3.EntityRepository.class); - EntityInterface entity = mockEntity(Entity.TABLE, entityReference.getId(), "orders"); + EntityInterface entity = mockEntity(Entity.TABLE, entityReference.getId(), "orders"); doNothing().when(spyRepository).updateEntityIndex(entity); try (var entityMock = mockStatic(Entity.class)) { entityMock.when(() -> Entity.getEntityRepository(Entity.TABLE)).thenReturn(entityRepository); when(entityRepository.getFields("*")).thenReturn(null); - when(entityRepository.get(null, entityReference.getId(), null)).thenReturn(entity); + Mockito.>when(entityRepository.get(null, entityReference.getId(), null)) + .thenReturn(entity); spyRepository.updateEntity(entityReference); } @@ -2846,7 +2856,7 @@ void createIndexesFinalizesEachRecreatedEntityAndContinuesOnFailure() { @Test void deleteEntityIndexRemovesDomainReferencesAndChildren() throws Exception { - EntityInterface domain = mockEntity(Entity.DOMAIN, UUID.randomUUID(), "finance"); + EntityInterface domain = mockEntity(Entity.DOMAIN, UUID.randomUUID(), "finance"); repository.deleteEntityIndex(domain); @@ -2869,7 +2879,7 @@ void deleteEntityIndexRemovesDomainReferencesAndChildren() throws Exception { @Test void deleteEntityIndexRemovesDataProductReferences() throws Exception { - EntityInterface dataProduct = mockEntity(Entity.DATA_PRODUCT, UUID.randomUUID(), "revenue"); + EntityInterface dataProduct = mockEntity(Entity.DATA_PRODUCT, UUID.randomUUID(), "revenue"); repository.deleteEntityIndex(dataProduct); @@ -2938,7 +2948,7 @@ void deleteEntityIndexHandlesNonBasicTestSuitesByUpdatingChildren() throws Excep @Test void softDeleteOrRestoreEntityIndexPropagatesServiceDeletionToChildren() throws Exception { - EntityInterface service = mockEntity(Entity.DATABASE_SERVICE, UUID.randomUUID(), "service"); + EntityInterface service = mockEntity(Entity.DATABASE_SERVICE, UUID.randomUUID(), "service"); String scriptTxt = new org.openmetadata.service.search.scripts.SoftDeleteScript(true).painless(); @@ -3026,7 +3036,7 @@ void softDeleteOrRestoredChildrenIsNoOpWhenEveryChildIsTimeSeries() throws IOExc @Test void getScriptWithParamsBuildsExtensionAndDescriptionUpdates() { - EntityInterface entity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface entity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); when(entity.getUpdatedAt()).thenReturn(99L); when(entity.getDescription()).thenReturn("new description"); when(entity.getExtension()).thenReturn(Map.of("reviewer", "alice")); @@ -3054,7 +3064,7 @@ void getScriptWithParamsBuildsExtensionAndDescriptionUpdates() { @Test void getScriptWithParamsRemovesFollowersAndDescriptions() { - EntityInterface entity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); + EntityInterface entity = mockEntity(Entity.TABLE, UUID.randomUUID(), "orders"); EntityReference removedFollower = new EntityReference().withId(UUID.randomUUID()); Map params = new HashMap<>(); ChangeDescription changeDescription = @@ -3409,7 +3419,7 @@ void listAndPaginationWrappersUseMappedIndices() throws IOException { SubjectContext subjectContext = mock(SubjectContext.class); when(filter.getCondition(Entity.TABLE)).thenReturn("status = 'Active'"); - when(filter.getMemoryStatuses()).thenReturn(List.of(EntityStatus.DEPRECATED)); + when(filter.getMemoryStatuses()).thenReturn(List.of(ContextMemoryStatus.DEPRECATED)); when(searchClient.listWithOffset( "status = 'Active'", 25, 10, "cluster_table_search_index", sortFilter, "orders", null)) .thenReturn(listMapper); @@ -3422,7 +3432,7 @@ void listAndPaginationWrappersUseMappedIndices() throws IOException { "orders", "query", subjectContext, - List.of(EntityStatus.DEPRECATED))) + List.of(ContextMemoryStatus.DEPRECATED))) .thenReturn(listMapper); when(searchClient.listWithDeepPagination( "cluster_table_search_index", @@ -3519,7 +3529,7 @@ void createBulkSinkUsesSearchTypeSpecificImplementation() { void bulkTimeoutCompletedDuringClosePropagatesWithoutReplayOrRetry() throws Exception { when(searchClient.getSearchType()) .thenReturn(ElasticSearchConfiguration.SearchType.ELASTICSEARCH); - EntityInterface service = + EntityInterface service = mockEntity(Entity.DATABASE_SERVICE, UUID.randomUUID(), "database-service"); String serviceId = service.getId().toString(); when(service.getChangeDescription()) @@ -3559,7 +3569,7 @@ void bulkTimeoutCompletedDuringClosePropagatesWithoutReplayOrRetry() throws Exce void bulkFailureDoesNotPropagateAnUnconfirmedRoot() throws Exception { when(searchClient.getSearchType()) .thenReturn(ElasticSearchConfiguration.SearchType.ELASTICSEARCH); - EntityInterface service = + EntityInterface service = mockEntity(Entity.DATABASE_SERVICE, UUID.randomUUID(), "database-service"); ChangeDescription displayNameChange = changeDescription( @@ -3601,7 +3611,7 @@ void bulkFailureDoesNotPropagateAnUnconfirmedRoot() throws Exception { void nonQuiescentBulkDefersPropagationUntilRetryCompletes() throws Exception { when(searchClient.getSearchType()) .thenReturn(ElasticSearchConfiguration.SearchType.ELASTICSEARCH); - EntityInterface service = + EntityInterface service = mockEntity(Entity.DATABASE_SERVICE, UUID.randomUUID(), "database-service"); ChangeDescription displayNameChange = changeDescription( @@ -3643,9 +3653,9 @@ void nonQuiescentBulkDefersPropagationUntilRetryCompletes() throws Exception { void partiallyFailedBulkPropagatesOnlyConfirmedRoots() throws Exception { when(searchClient.getSearchType()) .thenReturn(ElasticSearchConfiguration.SearchType.ELASTICSEARCH); - EntityInterface failedService = + EntityInterface failedService = mockEntity(Entity.DATABASE_SERVICE, UUID.randomUUID(), "failed-service"); - EntityInterface successfulService = + EntityInterface successfulService = mockEntity(Entity.DATABASE_SERVICE, UUID.randomUUID(), "successful-service"); ChangeDescription displayNameChange = changeDescription( @@ -3865,8 +3875,8 @@ private SearchRepository newRepository( } } - private EntityInterface mockEntity(String entityType, UUID id, String name) { - EntityInterface entity = mock(EntityInterface.class); + private EntityInterface mockEntity(String entityType, UUID id, String name) { + EntityInterface entity = mock(EntityInterface.class); EntityReference entityReference = new EntityReference().withId(id).withType(entityType).withName(name); when(entity.getEntityReference()).thenReturn(entityReference); @@ -3898,7 +3908,7 @@ private ChangeDescription changeDescription( @SuppressWarnings("unchecked") private Pair> invokeGetInheritedFieldChanges( - ChangeDescription changeDescription, EntityInterface entity) throws Exception { + ChangeDescription changeDescription, EntityInterface entity) throws Exception { Method method = SearchRepository.class.getDeclaredMethod( "getInheritedFieldChanges", @@ -3911,7 +3921,7 @@ private Pair> invokeGetInheritedFieldChanges( } private boolean invokeRequiresPropagation( - ChangeDescription changeDescription, String entityType, EntityInterface entity) + ChangeDescription changeDescription, String entityType, EntityInterface entity) throws Exception { return (Boolean) invokePrivateMethod( diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/search/SearchRepositoryTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/search/SearchRepositoryTest.java index 70f1c09f9abc..87afe0bff264 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/search/SearchRepositoryTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/search/SearchRepositoryTest.java @@ -51,6 +51,7 @@ import org.openmetadata.schema.tests.TestSuite; import org.openmetadata.schema.type.ChangeDescription; import org.openmetadata.schema.type.EntityReference; +import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.FieldChange; import org.openmetadata.service.Entity; import org.openmetadata.service.apps.bundles.searchIndex.BulkSink; @@ -173,7 +174,7 @@ void updateEntitiesByReference_skipsConcurrentlyDeletedRefAndIndexesSurvivors() EntityRepository tableRepository = mock(EntityRepository.class); Fields fields = mock(Fields.class); doReturn(fields).when(tableRepository).getOnlySupportedFields(anyString()); - EntityInterface survivor = mock(EntityInterface.class); + EntityInterface survivor = mock(EntityInterface.class); doReturn(List.of(survivor)) .when(tableRepository) .get(isNull(), eq(List.of(deletedId, survivorId)), eq(fields), eq(NON_DELETED)); @@ -186,7 +187,7 @@ void updateEntitiesByReference_skipsConcurrentlyDeletedRefAndIndexesSurvivors() verify(tableRepository) .get(isNull(), eq(List.of(deletedId, survivorId)), eq(fields), eq(NON_DELETED)); @SuppressWarnings("unchecked") - ArgumentCaptor> indexed = ArgumentCaptor.forClass(List.class); + ArgumentCaptor>> indexed = ArgumentCaptor.forClass(List.class); verify(searchRepository).updateEntitiesIndex(indexed.capture()); assertEquals( List.of(survivor), @@ -220,7 +221,7 @@ void updateEntitiesByReference_dedupesRepeatedRefsAndResolvesEachOnce() { EntityRepository tableRepository = mock(EntityRepository.class); Fields fields = mock(Fields.class); doReturn(fields).when(tableRepository).getOnlySupportedFields(anyString()); - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); doReturn(List.of(entity)) .when(tableRepository) .get(isNull(), eq(List.of(id)), eq(fields), eq(NON_DELETED)); @@ -232,7 +233,7 @@ void updateEntitiesByReference_dedupesRepeatedRefsAndResolvesEachOnce() { verify(tableRepository, times(1)).get(isNull(), eq(List.of(id)), eq(fields), eq(NON_DELETED)); @SuppressWarnings("unchecked") - ArgumentCaptor> indexed = ArgumentCaptor.forClass(List.class); + ArgumentCaptor>> indexed = ArgumentCaptor.forClass(List.class); verify(searchRepository).updateEntitiesIndex(indexed.capture()); assertEquals( List.of(entity), @@ -320,7 +321,7 @@ void testUpdateEntitiesBulkWithMixedTypes() throws Exception { doCallRealMethod().when(realSearchRepository).updateEntitiesIndex(any()); // Create mixed entity types - List mixedEntities = new ArrayList<>(); + List> mixedEntities = new ArrayList<>(); mixedEntities.add(new MockEntityWithType("table", "table1")); mixedEntities.add(new MockEntityWithType("table", "table2")); mixedEntities.add(new MockEntityWithType("databaseSchema", "schema1")); @@ -331,14 +332,14 @@ void testUpdateEntitiesBulkWithMixedTypes() throws Exception { realSearchRepository.updateEntitiesBulk(mixedEntities); // Capture the arguments passed to BulkSink.write - ArgumentCaptor> entitiesCaptor = ArgumentCaptor.forClass(List.class); + ArgumentCaptor>> entitiesCaptor = ArgumentCaptor.forClass(List.class); ArgumentCaptor> contextCaptor = ArgumentCaptor.forClass(Map.class); // Verify write was called 3 times (once for each entity type) verify(mockBulkSink, times(3)).write(entitiesCaptor.capture(), contextCaptor.capture()); // Get all captured values - List> capturedEntities = entitiesCaptor.getAllValues(); + List>> capturedEntities = entitiesCaptor.getAllValues(); List> capturedContexts = contextCaptor.getAllValues(); // Verify each call had the correct entityType and entity count @@ -352,7 +353,7 @@ void testUpdateEntitiesBulkWithMixedTypes() throws Exception { // Verify the entityType in context matches the actual entities for (Object entity : capturedEntities.get(i)) { - EntityInterface e = (EntityInterface) entity; + EntityInterface e = (EntityInterface) entity; assertEquals( entityType, e.getEntityReference().getType(), @@ -398,7 +399,7 @@ void testUpdateEntitiesBulkWithSingleType() throws Exception { doCallRealMethod().when(realSearchRepository).updateEntitiesIndex(any()); // Create entities of single type - List entities = new ArrayList<>(); + List> entities = new ArrayList<>(); entities.add(new MockEntityWithType("table", "table1")); entities.add(new MockEntityWithType("table", "table2")); entities.add(new MockEntityWithType("table", "table3")); @@ -406,7 +407,7 @@ void testUpdateEntitiesBulkWithSingleType() throws Exception { realSearchRepository.updateEntitiesBulk(entities); // Capture the arguments - ArgumentCaptor> entitiesCaptor = ArgumentCaptor.forClass(List.class); + ArgumentCaptor>> entitiesCaptor = ArgumentCaptor.forClass(List.class); ArgumentCaptor> contextCaptor = ArgumentCaptor.forClass(Map.class); // Verify write was called only once @@ -626,7 +627,7 @@ void testUpdateEntitiesBulkQueuesRetryWhenBulkWriteOutcomeIsUnknown() throws Exc doThrow(bulkFailure).when(mockBulkSink).write(any(), any()); doNothing().when(mockBulkSink).close(); - List entities = List.of(new MockEntityWithType("table", "table1")); + List> entities = List.of(new MockEntityWithType("table", "table1")); try (MockedStatic retryQueue = mockStatic(SearchIndexRetryQueue.class)) { realSearchRepository.updateEntitiesBulk(entities); @@ -653,7 +654,7 @@ void testUpdateEntitiesBulkFallsBackBeforeAnyBulkWriteIsAttempted() { when(realSearchRepository.checkIfIndexingIsSupported(any())).thenReturn(true); doNothing().when(realSearchRepository).updateEntityIndex(any()); - EntityInterface entity = new MockEntityWithType("table", "table1"); + EntityInterface entity = new MockEntityWithType("table", "table1"); realSearchRepository.updateEntitiesIndex(List.of(entity)); verify(realSearchRepository).updateEntityIndex(entity); @@ -669,7 +670,7 @@ void testRelationshipUpdateRetainsRevisionInPreWriteFallback() { when(realSearchRepository.checkIfIndexingIsSupported(any())).thenReturn(true); doNothing().when(realSearchRepository).updateEntityIndex(any(), anyLong()); - EntityInterface entity = new MockEntityWithType(Entity.TEST_CASE, "testCase1"); + EntityInterface entity = new MockEntityWithType(Entity.TEST_CASE, "testCase1"); realSearchRepository.updateEntitiesIndex(List.of(entity), Map.of(entity.getId(), 17L)); verify(realSearchRepository).updateEntityIndex(entity, 17L); @@ -688,7 +689,7 @@ void testUpdateEntitiesBulkDoesNotReplayWritesThatCompleteDuringClose() throws E when(mockBulkSink.flushAndAwait(anyInt())).thenReturn(false); when(mockBulkSink.getActiveBulkRequestCount()).thenReturn(0); - EntityInterface entity = new MockEntityWithType("table", "table1"); + EntityInterface entity = new MockEntityWithType("table", "table1"); realSearchRepository.updateEntitiesIndex(List.of(entity)); verify(mockBulkSink).close(); @@ -707,7 +708,7 @@ void testUpdateEntitiesBulkDoesNotReplayPartiallyFailedBulk() throws Exception { when(mockBulkSink.flushAndAwait(anyInt())).thenReturn(true); when(mockBulkSink.getStats()).thenReturn(new StepStats().withFailedRecords(1)); - EntityInterface entity = new MockEntityWithType("table", "table1"); + EntityInterface entity = new MockEntityWithType("table", "table1"); realSearchRepository.updateEntitiesIndex(List.of(entity)); verify(mockBulkSink).close(); @@ -715,7 +716,7 @@ void testUpdateEntitiesBulkDoesNotReplayPartiallyFailedBulk() throws Exception { } /** Mock entity that allows setting a specific entity type for testing */ - static class MockEntityWithType implements EntityInterface { + static class MockEntityWithType implements EntityInterface { private final UUID id = UUID.randomUUID(); private final String entityType; private final String name; @@ -834,7 +835,7 @@ public void setHref(URI href) {} @Override @SuppressWarnings("unchecked") - public T withHref(URI href) { + public > T withHref(URI href) { return (T) this; } } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/search/elasticsearch/ElasticSearchEntitiesProcessorTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/search/elasticsearch/ElasticSearchEntitiesProcessorTest.java index fbce39e9989b..9c9f1e5e1d9d 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/search/elasticsearch/ElasticSearchEntitiesProcessorTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/search/elasticsearch/ElasticSearchEntitiesProcessorTest.java @@ -25,6 +25,7 @@ import org.openmetadata.schema.EntityInterface; import org.openmetadata.schema.system.StepStats; import org.openmetadata.schema.type.ChangeDescription; +import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.utils.ResultList; import org.openmetadata.search.IndexMapping; import org.openmetadata.service.Entity; @@ -146,7 +147,7 @@ private ResultList createMockResultList(int count) { return resultList; } - static class MockEntity implements EntityInterface { + static class MockEntity implements EntityInterface { private final UUID id = UUID.randomUUID(); private final String fqn = "test.entity." + id; @@ -239,7 +240,7 @@ public void setUpdatedAt(Long updatedAt) {} public void setHref(URI href) {} @Override - public T withHref(URI href) { + public > T withHref(URI href) { return (T) this; } } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/search/indexes/ContextMemoryIndexTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/search/indexes/ContextMemoryIndexTest.java index 9e165bb4b502..d94f4249db25 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/search/indexes/ContextMemoryIndexTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/search/indexes/ContextMemoryIndexTest.java @@ -33,12 +33,12 @@ import org.openmetadata.schema.entity.context.ContextMemory; import org.openmetadata.schema.entity.context.ContextMemoryScope; import org.openmetadata.schema.entity.context.ContextMemorySourceType; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.ContextMemoryType; import org.openmetadata.schema.entity.context.MemoryShareConfig; import org.openmetadata.schema.entity.context.MemorySharedPrincipal; import org.openmetadata.schema.entity.context.MemoryVisibility; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.service.Entity; import org.openmetadata.service.search.SearchRepository; @@ -67,7 +67,7 @@ void buildSearchIndexDoc_populatesMemorySpecificFields() { .withSummary("Quick guide on Certification filtering") .withMemoryType(ContextMemoryType.FAQ) .withMemoryScope(ContextMemoryScope.USER_GLOBAL) - .withEntityStatus(EntityStatus.APPROVED) + .withEntityStatus(ContextMemoryStatus.APPROVED) .withPinned(true) .withSourceType(ContextMemorySourceType.CHAT_PROMOTION) .withUsageCount(7) diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/search/indexes/SearchIndexPrefetchTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/search/indexes/SearchIndexPrefetchTest.java index cbd08a92d3ed..4479cb894806 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/search/indexes/SearchIndexPrefetchTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/search/indexes/SearchIndexPrefetchTest.java @@ -253,7 +253,7 @@ void prefetchWorksForMetricEntitiesAndBuildsLineageEdges() { @Test void prefetchSkipsInputEntitiesWithNullId() { Table withId = table("svc.db.s.t1"); - org.openmetadata.schema.EntityInterface nullIdEntity = + org.openmetadata.schema.EntityInterface nullIdEntity = org.mockito.Mockito.mock(org.openmetadata.schema.EntityInterface.class); when(relDao.findFromBatch(any(), anyInt(), any(Include.class))) .thenReturn(Collections.emptyList()); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/search/opensearch/OpenSearchEntitiesProcessorTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/search/opensearch/OpenSearchEntitiesProcessorTest.java index e95ea0d9b796..b6df67165529 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/search/opensearch/OpenSearchEntitiesProcessorTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/search/opensearch/OpenSearchEntitiesProcessorTest.java @@ -24,6 +24,7 @@ import org.openmetadata.schema.EntityInterface; import org.openmetadata.schema.system.StepStats; import org.openmetadata.schema.type.ChangeDescription; +import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.utils.ResultList; import org.openmetadata.search.IndexMapping; import org.openmetadata.service.Entity; @@ -146,7 +147,7 @@ private ResultList createMockResultList(int count) { return resultList; } - static class MockEntity implements EntityInterface { + static class MockEntity implements EntityInterface { private final UUID id = UUID.randomUUID(); private final String fqn = "test.entity." + id; @@ -239,7 +240,7 @@ public void setUpdatedAt(Long updatedAt) {} public void setHref(URI href) {} @Override - public T withHref(URI href) { + public > T withHref(URI href) { return (T) this; } } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/search/security/ContextMemorySearchVisibilityTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/search/security/ContextMemorySearchVisibilityTest.java index 89f41e55fbc6..9001d344ae0b 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/search/security/ContextMemorySearchVisibilityTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/search/security/ContextMemorySearchVisibilityTest.java @@ -31,10 +31,10 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.parallel.Execution; import org.junit.jupiter.api.parallel.ExecutionMode; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.MemoryVisibility; import org.openmetadata.schema.entity.teams.User; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.service.Entity; import org.openmetadata.service.search.elasticsearch.queries.ElasticQueryBuilder; import org.openmetadata.service.search.elasticsearch.queries.ElasticQueryBuilderFactory; @@ -183,7 +183,8 @@ void statusAwareListingRetainsVisibilityAndLimitsStatuses() { OMQueryBuilder filter = new ContextMemorySearchVisibility(new ElasticQueryBuilderFactory()) .buildVisibilityFilter( - nonAdminSubject(), List.of(EntityStatus.APPROVED, EntityStatus.REJECTED)); + nonAdminSubject(), + List.of(ContextMemoryStatus.APPROVED, ContextMemoryStatus.REJECTED)); DocumentContext json = JsonPath.parse(serializeElasticQuery(((ElasticQueryBuilder) filter).build())); @@ -384,7 +385,7 @@ void isOrgWideReadableRejectsRestrictedMemories() { "anchorId", ContextMemoryIndex.UNANCHORED, "entityStatus", - EntityStatus.DEPRECATED.value())), + ContextMemoryStatus.DEPRECATED.value())), "retired memories do not appear in anonymous search reads"); } @@ -418,7 +419,7 @@ private Map memoryDocument(MemoryVisibility visibility) { "anchorId", ContextMemoryIndex.UNANCHORED, "entityStatus", - EntityStatus.APPROVED.value()); + ContextMemoryStatus.APPROVED.value()); } private String orgWideOnlyJson() { diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/search/vector/OpenSearchVectorServiceTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/search/vector/OpenSearchVectorServiceTest.java index ff25e3ddc44c..39c05c1dec06 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/search/vector/OpenSearchVectorServiceTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/search/vector/OpenSearchVectorServiceTest.java @@ -23,9 +23,9 @@ import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.openmetadata.schema.entity.context.ContextMemory; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.data.Table; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.service.search.indexes.ContextMemoryIndex; import org.openmetadata.service.search.vector.client.EmbeddingClient; import org.openmetadata.service.search.vector.utils.DTOs; @@ -84,7 +84,7 @@ void liveUpdateDuringARecreateAlsoRewritesTheStagedGeneration() throws Exception mockOpenSearchResponse("{\"found\":false,\"hits\":{\"hits\":[]},\"errors\":false}"); vectorService.updateEntityEmbeddings( - refreshableMemory().withEntityStatus(EntityStatus.REJECTED), "entityIndex"); + refreshableMemory().withEntityStatus(ContextMemoryStatus.REJECTED), "entityIndex"); ArgumentCaptor captor = ArgumentCaptor.forClass(os.org.opensearch.client.opensearch.generic.Request.class); @@ -108,11 +108,12 @@ private static ContextMemory refreshableMemory() { .withTitle("SQL preference") .withQuestion("Should keywords be upper case?") .withAnswer("Yes, use upper case keywords.") - .withEntityStatus(EntityStatus.APPROVED); + .withEntityStatus(ContextMemoryStatus.APPROVED); } private static OpenSearchVectorService.ChunkRefresh refresh( - org.openmetadata.schema.EntityInterface entity, OpenSearchVectorService.ChunkHeader header) { + org.openmetadata.schema.EntityInterface entity, + OpenSearchVectorService.ChunkHeader header) { return OpenSearchVectorService.chunkRefresh( entity, VectorDocBuilder.computeFingerprintForEntity(entity), header); } @@ -144,7 +145,7 @@ void chunkHeaderRequestsTheMemoryStatusFieldUsedByChunkDocuments() throws IOExce .withTitle("SQL preference") .withQuestion("Should keywords be upper case?") .withAnswer("Yes, use upper case keywords.") - .withEntityStatus(EntityStatus.APPROVED); + .withEntityStatus(ContextMemoryStatus.APPROVED); String fingerprint = VectorDocBuilder.computeFingerprintForEntity(memory); mockOpenSearchResponse( "{\"found\":true,\"_source\":{\"fingerprint\":\"" diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/search/vector/VectorDocBuilderChunkTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/search/vector/VectorDocBuilderChunkTest.java index 1e2743628244..0fc50c16a0d9 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/search/vector/VectorDocBuilderChunkTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/search/vector/VectorDocBuilderChunkTest.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test; import org.openmetadata.schema.api.data.MetricExpression; import org.openmetadata.schema.entity.context.ContextMemory; +import org.openmetadata.schema.entity.context.ContextMemoryStatus; import org.openmetadata.schema.entity.context.MemoryShareConfig; import org.openmetadata.schema.entity.context.MemorySharedPrincipal; import org.openmetadata.schema.entity.context.MemoryVisibility; @@ -35,7 +36,6 @@ import org.openmetadata.schema.type.Column; import org.openmetadata.schema.type.ColumnDataType; import org.openmetadata.schema.type.EntityReference; -import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.MetricExpressionLanguage; import org.openmetadata.schema.type.MetricGranularity; import org.openmetadata.schema.type.MetricType; @@ -393,14 +393,14 @@ void contentFingerprint_tracksShareConfigButNotSharedWithOrdering() { @Test void chunkDocs_carryTheMemoryStatusOnEveryChunk() { ContextMemory memory = - memory(MemoryVisibility.ENTITY).withEntityStatus(EntityStatus.DEPRECATED); + memory(MemoryVisibility.ENTITY).withEntityStatus(ContextMemoryStatus.DEPRECATED); memory.withDescription("revenue ".repeat(900)); List> docs = VectorDocBuilder.fromEntity(memory, new MockEmbeddingClient()); assertTrue(docs.size() > 1); for (Map doc : docs) { - assertEquals(EntityStatus.DEPRECATED.value(), doc.get("entityStatus")); + assertEquals(ContextMemoryStatus.DEPRECATED.value(), doc.get("entityStatus")); } } @@ -418,7 +418,7 @@ void contentFingerprint_ignoresLifecycleAndAnchorFilters() { + "|"); assertEquals(preLifecycle, VectorDocBuilder.computeFingerprintForEntity(memory)); - memory.setEntityStatus(EntityStatus.DEPRECATED); + memory.setEntityStatus(ContextMemoryStatus.DEPRECATED); memory.setPrimaryEntity(new EntityReference().withId(UUID.randomUUID()).withType("table")); assertEquals(preLifecycle, VectorDocBuilder.computeFingerprintForEntity(memory)); } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/search/vector/VectorEmbeddingHandlerTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/search/vector/VectorEmbeddingHandlerTest.java index 7c7bd5ac202f..0801525369a1 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/search/vector/VectorEmbeddingHandlerTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/search/vector/VectorEmbeddingHandlerTest.java @@ -48,7 +48,7 @@ void testIsAsync() { @Test void testOnEntityCreatedForSupportedType() { - EntityInterface entity = createMockEntity("table"); + EntityInterface entity = createMockEntity("table"); try (MockedStatic entityMock = mockStatic(Entity.class)) { SearchRepository searchRepository = mock(SearchRepository.class); @@ -67,7 +67,7 @@ void testOnEntityCreatedForSupportedType() { @Test void testOnEntityCreatedForUnsupportedType() { - EntityInterface entity = createMockEntity("unsupportedType"); + EntityInterface entity = createMockEntity("unsupportedType"); handler.onEntityCreated(entity, subjectContext); @@ -76,7 +76,7 @@ void testOnEntityCreatedForUnsupportedType() { @Test void testOnEntityUpdatedCallsUpdate() { - EntityInterface entity = createMockEntity("table"); + EntityInterface entity = createMockEntity("table"); when(entity.getDeleted()).thenReturn(false); try (MockedStatic entityMock = mockStatic(Entity.class)) { @@ -96,7 +96,7 @@ void testOnEntityUpdatedCallsUpdate() { @Test void testOnEntityUpdatedDropsChunksAndEmbeddingForNonEmbeddableEntity() { - EntityInterface entity = createMockEntity("contextMemory"); + EntityInterface entity = createMockEntity("contextMemory"); SearchRepository searchRepository = mock(SearchRepository.class); IndexMapping indexMapping = mock(IndexMapping.class); @@ -120,7 +120,7 @@ void testOnEntityUpdatedDropsChunksAndEmbeddingForNonEmbeddableEntity() { @Test void testOnEntityUpdatedSkipsDeleted() { - EntityInterface entity = createMockEntity("table"); + EntityInterface entity = createMockEntity("table"); when(entity.getDeleted()).thenReturn(true); handler.onEntityUpdated(entity, null, subjectContext); @@ -137,7 +137,7 @@ void testOnEntityUpdatedHandlesNull() { @Test void testOnEntityDeletedIsNoOp() { - EntityInterface entity = createMockEntity("table"); + EntityInterface entity = createMockEntity("table"); handler.onEntityDeleted(entity, subjectContext); @@ -146,7 +146,7 @@ void testOnEntityDeletedIsNoOp() { @Test void testOnEntitySoftDeletedIsNoOp() { - EntityInterface entity = createMockEntity("table"); + EntityInterface entity = createMockEntity("table"); handler.onEntitySoftDeletedOrRestored(entity, true, subjectContext); @@ -155,7 +155,7 @@ void testOnEntitySoftDeletedIsNoOp() { @Test void testOnEntityRestoredIsNoOp() { - EntityInterface entity = createMockEntity("table"); + EntityInterface entity = createMockEntity("table"); handler.onEntitySoftDeletedOrRestored(entity, false, subjectContext); @@ -169,8 +169,8 @@ void testOnEntitySoftDeletedOrRestoredHandlesNull() { verify(vectorIndexService, never()).updateEntityEmbeddings(any(), anyString()); } - private EntityInterface createMockEntity(String entityType) { - EntityInterface entity = mock(EntityInterface.class); + private EntityInterface createMockEntity(String entityType) { + EntityInterface entity = mock(EntityInterface.class); UUID id = UUID.randomUUID(); EntityReference ref = new EntityReference(); ref.setType(entityType); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/security/DefaultAuthorizerTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/security/DefaultAuthorizerTest.java index c2d7cbac210e..6cc119608a12 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/security/DefaultAuthorizerTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/security/DefaultAuthorizerTest.java @@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.mockito.MockedStatic; +import org.mockito.Mockito; import org.openmetadata.schema.EntityInterface; import org.openmetadata.schema.entity.teams.User; import org.openmetadata.schema.type.EntityReference; @@ -164,10 +165,10 @@ void adminCanReadAnotherUsersPermissions() { void authorizeSkipsPolicyEvaluationForReviewers() { SecurityContext securityContext = securityContext("reviewer"); SubjectContext reviewerContext = subjectContext("reviewer", false, false, null); - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); when(entity.getReviewers()).thenReturn(List.of(entityReference(Entity.USER, "reviewer"))); ResourceContextInterface resourceContext = mock(ResourceContextInterface.class); - when(resourceContext.getEntity()).thenReturn(entity); + Mockito.>when(resourceContext.getEntity()).thenReturn(entity); OperationContext operationContext = new OperationContext(Entity.TABLE, MetadataOperation.EDIT_ALL); @@ -188,10 +189,10 @@ void authorizeSkipsPolicyEvaluationForReviewers() { void authorizeDoesNotTreatSelfAssignedReviewerAsReviewerOnCreate() { SecurityContext securityContext = securityContext("attacker"); SubjectContext attackerContext = subjectContext("attacker", false, false, null); - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); when(entity.getReviewers()).thenReturn(List.of(entityReference(Entity.USER, "attacker"))); CreateResourceContext createResourceContext = mock(CreateResourceContext.class); - when(createResourceContext.getEntity()).thenReturn(entity); + Mockito.>when(createResourceContext.getEntity()).thenReturn(entity); OperationContext operationContext = new OperationContext(Entity.DATA_PRODUCT, MetadataOperation.CREATE); @@ -214,10 +215,10 @@ void authorizeDoesNotTreatSelfAssignedReviewerAsReviewerOnCreate() { void authorizeDelegatesPolicyEvaluationForRegularUsers() { SecurityContext securityContext = securityContext("analyst"); SubjectContext analystContext = subjectContext("analyst", false, false, null); - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); when(entity.getReviewers()).thenReturn(null); ResourceContextInterface resourceContext = mock(ResourceContextInterface.class); - when(resourceContext.getEntity()).thenReturn(entity); + Mockito.>when(resourceContext.getEntity()).thenReturn(entity); OperationContext operationContext = new OperationContext(Entity.TABLE, MetadataOperation.VIEW_ALL); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/CachedPermissionEvaluationTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/CachedPermissionEvaluationTest.java index 6c3b537bcd66..adc0a147694a 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/CachedPermissionEvaluationTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/CachedPermissionEvaluationTest.java @@ -312,7 +312,7 @@ private static List createRules(String prefix) { return rules; } - private static List toEntityReferences( + private static > List toEntityReferences( List entities) { List references = new ArrayList<>(); for (T entity : entities) { diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/DomainAccessTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/DomainAccessTest.java index 918193fbf3ce..dd643733dc12 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/DomainAccessTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/DomainAccessTest.java @@ -13,6 +13,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.mockito.Mockito; import org.openmetadata.schema.EntityInterface; import org.openmetadata.schema.entity.teams.User; import org.openmetadata.schema.type.EntityReference; @@ -27,7 +28,7 @@ public class DomainAccessTest { private SubjectContext subjectContext; private ResourceContextInterface resourceContext; private User user; - private EntityInterface entity; + private EntityInterface entity; @BeforeEach void setUp() { @@ -41,7 +42,7 @@ void setUp() { // Set up entity with ID (to indicate it's not a list operation) when(entity.getId()).thenReturn(UUID.randomUUID()); when(entity.getFullyQualifiedName()).thenReturn("test.entity"); - when(resourceContext.getEntity()).thenReturn(entity); + Mockito.>when(resourceContext.getEntity()).thenReturn(entity); // Create RuleEvaluator with mocked contexts ruleEvaluator = new RuleEvaluator(null, subjectContext, resourceContext); @@ -197,9 +198,9 @@ void testListOperations() { assertTrue(hasAccess, "List operations should return true for post-filtering"); - EntityInterface entityWithoutId = mock(EntityInterface.class); + EntityInterface entityWithoutId = mock(EntityInterface.class); when(entityWithoutId.getId()).thenReturn(null); - when(resourceContext.getEntity()).thenReturn(entityWithoutId); + Mockito.>when(resourceContext.getEntity()).thenReturn(entityWithoutId); hasAccess = ruleEvaluator.hasDomain(); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/PermissionDebugServiceTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/PermissionDebugServiceTest.java index 438a94432a0f..2b237a4f3408 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/PermissionDebugServiceTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/PermissionDebugServiceTest.java @@ -16,6 +16,7 @@ import java.util.UUID; import org.junit.jupiter.api.Test; import org.mockito.MockedStatic; +import org.mockito.Mockito; import org.openmetadata.schema.EntityInterface; import org.openmetadata.schema.api.teams.CreateTeam.TeamType; import org.openmetadata.schema.entity.data.Table; @@ -209,7 +210,7 @@ void debugShowsWildcardAllowDoesNotGrantSparql() { TeamRepository teamRepository = mock(TeamRepository.class); RoleRepository roleRepository = mock(RoleRepository.class); PolicyRepository policyRepository = mock(PolicyRepository.class); - EntityRepository rdfRepository = mock(EntityRepository.class); + EntityRepository> rdfRepository = mock(EntityRepository.class); stubFields(userRepository, teamRepository, roleRepository, policyRepository); User user = new User().withId(UUID.randomUUID()).withName("alice"); @@ -318,7 +319,7 @@ void debugPermissionEvaluationPrefersDenyRulesOverAllows() { TeamRepository teamRepository = mock(TeamRepository.class); RoleRepository roleRepository = mock(RoleRepository.class); PolicyRepository policyRepository = mock(PolicyRepository.class); - EntityRepository resourceRepository = mock(EntityRepository.class); + EntityRepository> resourceRepository = mock(EntityRepository.class); stubFields( userRepository, teamRepository, roleRepository, policyRepository, resourceRepository); @@ -336,7 +337,8 @@ void debugPermissionEvaluationPrefersDenyRulesOverAllows() { when(userRepository.getByName(isNull(), eq("alice"), eq(EntityUtil.Fields.EMPTY_FIELDS))) .thenReturn(user); - when(resourceRepository.get(isNull(), eq(table.getId()), eq(EntityUtil.Fields.EMPTY_FIELDS))) + Mockito.>when( + resourceRepository.get(isNull(), eq(table.getId()), eq(EntityUtil.Fields.EMPTY_FIELDS))) .thenReturn(table); SubjectContext.PolicyContext allowContext = @@ -417,7 +419,7 @@ void debugPermissionEvaluationUsesFqnLookupAndEvaluatesOwnerConditions() { TeamRepository teamRepository = mock(TeamRepository.class); RoleRepository roleRepository = mock(RoleRepository.class); PolicyRepository policyRepository = mock(PolicyRepository.class); - EntityRepository resourceRepository = mock(EntityRepository.class); + EntityRepository> resourceRepository = mock(EntityRepository.class); stubFields( userRepository, teamRepository, roleRepository, policyRepository, resourceRepository); @@ -435,8 +437,9 @@ void debugPermissionEvaluationUsesFqnLookupAndEvaluatesOwnerConditions() { when(userRepository.getByName(isNull(), eq("alice"), eq(EntityUtil.Fields.EMPTY_FIELDS))) .thenReturn(user); - when(resourceRepository.getByName( - isNull(), eq(table.getFullyQualifiedName()), eq(EntityUtil.Fields.EMPTY_FIELDS))) + Mockito.>when( + resourceRepository.getByName( + isNull(), eq(table.getFullyQualifiedName()), eq(EntityUtil.Fields.EMPTY_FIELDS))) .thenReturn(table); SubjectContext.PolicyContext policyContext = @@ -581,7 +584,7 @@ private static void stubRepositories( TeamRepository teamRepository, RoleRepository roleRepository, PolicyRepository policyRepository, - EntityRepository resourceRepository) { + EntityRepository> resourceRepository) { stubRepositories(entityMock, userRepository, teamRepository, roleRepository, policyRepository); entityMock.when(() -> Entity.getEntityRepository(Entity.TABLE)).thenReturn(resourceRepository); } @@ -592,7 +595,7 @@ private static void stubFields(EntityRepository... repositories) { } } - private static void stubById( + private static > void stubById( EntityRepository repository, Map entities) { when(repository.get( isNull(), diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/SubjectCacheTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/SubjectCacheTest.java index 3d6c1b3176bc..272cbc861d8c 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/SubjectCacheTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/SubjectCacheTest.java @@ -509,7 +509,7 @@ private static List getRules(String prefix) { return rules; } - private static List toEntityReferences( + private static > List toEntityReferences( List entities) { List references = new ArrayList<>(); for (T entity : entities) { diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/SubjectContextTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/SubjectContextTest.java index cc610446c54b..e285018e4824 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/SubjectContextTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/SubjectContextTest.java @@ -420,7 +420,7 @@ private static List getRules(String prefix) { return rules; } - private static List toEntityReferences( + private static > List toEntityReferences( List entities) { List references = new ArrayList<>(); for (T entity : entities) { diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/TeamGraphFixture.java b/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/TeamGraphFixture.java index 841347a6fdce..2c8961269388 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/TeamGraphFixture.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/TeamGraphFixture.java @@ -103,7 +103,7 @@ public static void registerTeam( } /** Answers {@code Entity.getEntityReferencesByIds} from the graph registered here. */ - public static void stubReferences( + public static > void stubReferences( final EntityRepository repository, final String entityType) { when(repository.getReferences(anyList(), any(Include.class))) .thenAnswer( diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/util/EntityETagTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/util/EntityETagTest.java index 909c9f712ff6..cd1c85df895e 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/util/EntityETagTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/util/EntityETagTest.java @@ -27,7 +27,7 @@ class EntityETagTest { @Test void generateETagReturnsQuotedHashAndWeakVariant() { - EntityInterface entity = entity(1.2, 123456L); + EntityInterface entity = entity(1.2, 123456L); String strong = EntityETag.generateETag(entity); String weak = EntityETag.generateWeakETag(entity); @@ -42,7 +42,7 @@ void generateETagReturnsQuotedHashAndWeakVariant() { @Test void etagIsStableForUnchangedEntity() { - EntityInterface entity = entity(1.2, 123456L); + EntityInterface entity = entity(1.2, 123456L); assertEquals(EntityETag.generateETag(entity), EntityETag.generateETag(entity)); } @@ -54,8 +54,8 @@ void etagChangesWhenVotesChangeWithoutVersionBump() { // the post-vote conditional GET was answered 304 and the header rendered stale counts. // The ETag must move when the votes block moves, even though version/updatedAt are identical. UUID id = UUID.randomUUID(); - EntityInterface before = table(id, 1.2, 123456L, 0); - EntityInterface after = table(id, 1.2, 123456L, 1); + EntityInterface before = table(id, 1.2, 123456L, 0); + EntityInterface after = table(id, 1.2, 123456L, 1); assertEquals(before.getVersion(), after.getVersion()); assertEquals(before.getUpdatedAt(), after.getUpdatedAt()); @@ -65,8 +65,8 @@ void etagChangesWhenVotesChangeWithoutVersionBump() { @Test void etagChangesWhenVersionChanges() { UUID id = UUID.randomUUID(); - EntityInterface v1 = table(id, 1.0, 100L, 0); - EntityInterface v2 = table(id, 1.1, 200L, 0); + EntityInterface v1 = table(id, 1.0, 100L, 0); + EntityInterface v2 = table(id, 1.1, 200L, 0); assertNotEquals(EntityETag.generateETag(v1), EntityETag.generateETag(v2)); } @@ -79,9 +79,9 @@ void etagReflectsRequestedFieldsForPartialFetches() { // never hand back an owners-bearing body. The same selection with unchanged data stays stable // so the conditional GET still short-circuits to 304. UUID id = UUID.randomUUID(); - EntityInterface tagsOnly = + EntityInterface tagsOnly = partialTable(id).withTags(List.of(new TagLabel().withTagFQN("PII.Sensitive"))); - EntityInterface ownersOnly = + EntityInterface ownersOnly = partialTable(id) .withOwners( List.of( @@ -89,7 +89,7 @@ void etagReflectsRequestedFieldsForPartialFetches() { .withId(UUID.randomUUID()) .withType("user") .withName("u1"))); - EntityInterface tagsOnlyUnchanged = + EntityInterface tagsOnlyUnchanged = partialTable(id).withTags(List.of(new TagLabel().withTagFQN("PII.Sensitive"))); assertNotEquals(EntityETag.generateETag(tagsOnly), EntityETag.generateETag(ownersOnly)); @@ -104,7 +104,7 @@ void etagReflectsRelationshipOnlyMutations() { // updatedAt and differs only in the named field — exactly the shape a version-only ETag missed. UUID t = UUID.randomUUID(); UUID u = UUID.randomUUID(); - record Case(String field, EntityInterface before, EntityInterface after) {} + record Case(String field, EntityInterface before, EntityInterface after) {} List cases = List.of( new Case( @@ -149,7 +149,7 @@ record Case(String field, EntityInterface before, EntityInterface after) {} @Test void validateETagSupportsExactWildcardWeakAndMultipleMatches() { - EntityInterface entity = entity(2.5, 98765L); + EntityInterface entity = entity(2.5, 98765L); String etag = EntityETag.generateETag(entity); String weak = EntityETag.generateWeakETag(entity); @@ -192,8 +192,8 @@ void weakETagValidatesAcrossProjectionsWhereStrongETagCannot() { // validator survives the round trip. Same entity, same version, two projections: UUID id = UUID.randomUUID(); TagLabel tag = new TagLabel().withTagFQN("PII.Sensitive"); - EntityInterface asPublishedByRead = partialTable(id).withTags(List.of(tag)); - EntityInterface asLoadedForPatch = + EntityInterface asPublishedByRead = partialTable(id).withTags(List.of(tag)); + EntityInterface asLoadedForPatch = partialTable(id) .withTags(List.of(tag)) .withTableConstraints(List.of(new TableConstraint().withColumns(List.of("id")))); @@ -213,7 +213,7 @@ void weakETagValidatesAcrossProjectionsWhereStrongETagCannot() { @Test void validateETagRejectsMismatchedHeaders() { - EntityInterface entity = entity(3.1, 24680L); + EntityInterface entity = entity(3.1, 24680L); assertThrows( PreconditionFailedException.class, @@ -222,7 +222,7 @@ void validateETagRejectsMismatchedHeaders() { @Test void addETagHeaderAndEnforcementFlagBehaveAsExpected() { - EntityInterface entity = entity(4.0, 13579L); + EntityInterface entity = entity(4.0, 13579L); Response response = EntityETag.addETagHeader(Response.ok(), entity).build(); @@ -230,7 +230,7 @@ void addETagHeaderAndEnforcementFlagBehaveAsExpected() { assertFalse(EntityETag.isETagEnforcementEnabled()); } - private static EntityInterface entity(double version, long updatedAt) { + private static EntityInterface entity(double version, long updatedAt) { return new Table() .withId(UUID.randomUUID()) .withName("etag_table") @@ -238,7 +238,7 @@ private static EntityInterface entity(double version, long updatedAt) { .withUpdatedAt(updatedAt); } - private static EntityInterface table(UUID id, double version, long updatedAt, int upVotes) { + private static EntityInterface table(UUID id, double version, long updatedAt, int upVotes) { return new Table() .withId(id) .withName("etag_table") diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/util/EntityFieldUtilsTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/util/EntityFieldUtilsTest.java index d3cfe4683d3a..b5b5b56d0140 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/util/EntityFieldUtilsTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/util/EntityFieldUtilsTest.java @@ -456,11 +456,13 @@ void setEntityStatusSupportsEnumAndLegacyFallbacks() { String approvedValue = EntityStatus.APPROVED.value(); EntityFieldUtils.setEntityStatus(entity, approvedValue); - EntityFieldUtils.setEntityStatus(entity, "legacy-state"); + assertThrows( + IllegalArgumentException.class, + () -> EntityFieldUtils.setEntityStatus(entity, "Superseded")); EntityFieldUtils.setEntityStatus(legacyEntity, approvedValue); assertEquals(EntityStatus.APPROVED, entity.getEntityStatus()); - assertEquals("legacy-state", entity.getStatus()); + assertNull(entity.getStatus()); assertEquals(approvedValue, legacyEntity.getStatus()); } @@ -513,7 +515,7 @@ public void setEntityStatus(EntityStatus approvalStatus) { } } - private static class TestEntity implements EntityInterface { + private static class TestEntity implements EntityInterface { private UUID id; private String description; private String displayName; diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/util/EntityUtilTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/util/EntityUtilTest.java index 8d847686a617..433666bd5673 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/util/EntityUtilTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/util/EntityUtilTest.java @@ -19,6 +19,8 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.openmetadata.schema.EntityInterface; import org.openmetadata.schema.api.data.TermReference; import org.openmetadata.schema.entity.classification.Tag; import org.openmetadata.schema.entity.data.APIEndpoint; @@ -366,7 +368,7 @@ void testTagLabelChangeDescriptionAndOperationHelpers() { assertEquals("after", change.getFieldsUpdated().get(0).getNewValue()); when(createContext.getEntity()).thenReturn(null); - when(updateContext.getEntity()).thenReturn(new Table()); + Mockito.>when(updateContext.getEntity()).thenReturn(new Table()); assertEquals(MetadataOperation.CREATE, EntityUtil.createOrUpdateOperation(createContext)); assertEquals(MetadataOperation.EDIT_ALL, EntityUtil.createOrUpdateOperation(updateContext)); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/util/JsonPatchUtilsTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/util/JsonPatchUtilsTest.java index e892e6e86623..e275f26064e1 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/util/JsonPatchUtilsTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/util/JsonPatchUtilsTest.java @@ -2,7 +2,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.Mockito.when; import static org.openmetadata.common.utils.CommonUtil.listOf; import jakarta.json.Json; @@ -17,9 +16,11 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +import org.openmetadata.schema.EntityInterface; import org.openmetadata.schema.entity.data.Table; import org.openmetadata.schema.type.Column; import org.openmetadata.schema.type.EntityReference; @@ -66,7 +67,7 @@ public void setup() { originalTable.setColumns(listOf(column)); - when(resourceContextMock.getEntity()).thenReturn(originalTable); + Mockito.>when(resourceContextMock.getEntity()).thenReturn(originalTable); } @Test diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/workflows/searchIndex/ReindexingUtilDocBuildContextTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/workflows/searchIndex/ReindexingUtilDocBuildContextTest.java index a205f26da87d..c3bb131bb6f8 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/workflows/searchIndex/ReindexingUtilDocBuildContextTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/workflows/searchIndex/ReindexingUtilDocBuildContextTest.java @@ -55,7 +55,7 @@ static void closeEntityMock() { @Test void populateDocBuildContextDoesNothingWhenAllPrefetchesReturnNull() { Map contextData = new HashMap<>(); - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); try (MockedStatic indexMock = mockStatic(SearchIndex.class)) { indexMock @@ -74,7 +74,7 @@ void populateDocBuildContextDoesNothingWhenAllPrefetchesReturnNull() { @Test void populateDocBuildContextSwallowsThrowableAndLeavesContextUntouched() { Map contextData = new HashMap<>(); - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); try (MockedStatic indexMock = mockStatic(SearchIndex.class)) { indexMock @@ -92,8 +92,8 @@ void populateDocBuildContextWrapsEachEntityLineageInDocBuildContext() { Map contextData = new HashMap<>(); UUID id1 = UUID.randomUUID(); UUID id2 = UUID.randomUUID(); - EntityInterface e1 = mock(EntityInterface.class); - EntityInterface e2 = mock(EntityInterface.class); + EntityInterface e1 = mock(EntityInterface.class); + EntityInterface e2 = mock(EntityInterface.class); when(e1.getId()).thenReturn(id1); when(e2.getId()).thenReturn(id2); List edgesForFirst = List.of(new EsLineageData()); @@ -123,7 +123,7 @@ void populateDocBuildContextWrapsEachEntityLineageInDocBuildContext() { void populateDocBuildContextPrefetchesTestSuiteRelationshipRevision() { Map contextData = new HashMap<>(); UUID id = UUID.randomUUID(); - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); when(entity.getId()).thenReturn(id); try (MockedStatic indexMock = mockStatic(SearchIndex.class); @@ -152,7 +152,7 @@ void populateDocBuildContextUsesSuppliedRelationshipRevisionWithoutRereadingIt() UUID id = UUID.randomUUID(); Map contextData = new HashMap<>(Map.of(BulkSink.RELATIONSHIP_REVISIONS_CONTEXT_KEY, Map.of(id, 23L))); - EntityInterface entity = mock(EntityInterface.class); + EntityInterface entity = mock(EntityInterface.class); when(entity.getId()).thenReturn(id); try (MockedStatic indexMock = mockStatic(SearchIndex.class); @@ -211,8 +211,8 @@ void populateDocBuildContextWrapsEachEntityServiceStyleInDocBuildContext() { Map contextData = new HashMap<>(); UUID id1 = UUID.randomUUID(); UUID id2 = UUID.randomUUID(); - EntityInterface e1 = mock(EntityInterface.class); - EntityInterface e2 = mock(EntityInterface.class); + EntityInterface e1 = mock(EntityInterface.class); + EntityInterface e2 = mock(EntityInterface.class); Style style = new Style().withColor("#123456"); when(e1.getId()).thenReturn(id1); when(e2.getId()).thenReturn(id2); diff --git a/openmetadata-spec/src/main/java/org/openmetadata/schema/EntityInterface.java b/openmetadata-spec/src/main/java/org/openmetadata/schema/EntityInterface.java index 1635c21d309c..333b266d1537 100644 --- a/openmetadata-spec/src/main/java/org/openmetadata/schema/EntityInterface.java +++ b/openmetadata-spec/src/main/java/org/openmetadata/schema/EntityInterface.java @@ -22,15 +22,22 @@ import java.util.UUID; import org.openmetadata.common.utils.CommonUtil; import org.openmetadata.schema.entity.type.Style; -import org.openmetadata.schema.type.*; +import org.openmetadata.schema.type.AssetCertification; +import org.openmetadata.schema.type.ChangeDescription; +import org.openmetadata.schema.type.EntityReference; +import org.openmetadata.schema.type.LifeCycle; +import org.openmetadata.schema.type.ProviderType; +import org.openmetadata.schema.type.TagLabel; +import org.openmetadata.schema.type.UsageDetails; +import org.openmetadata.schema.type.Votes; import org.openmetadata.schema.utils.EntityInterfaceUtil; /** Interface to be implemented by all entities to provide a way to access all the common fields. */ @SuppressWarnings("unused") -public interface EntityInterface { +public interface EntityInterface> { // Lower case entity name to canonical entity name map Map CANONICAL_ENTITY_NAME_MAP = new HashMap<>(); - Map> ENTITY_TYPE_TO_CLASS_MAP = new HashMap<>(); + Map>> ENTITY_TYPE_TO_CLASS_MAP = new HashMap<>(); UUID getId(); @@ -72,7 +79,7 @@ default List getTags() { return null; } - default EntityStatus getEntityStatus() { + default S getEntityStatus() { return null; } @@ -177,7 +184,7 @@ default void setTags(List tags) { /* no-op implementation to be overridden */ } - default void setEntityStatus(EntityStatus approvalStatus) { + default void setEntityStatus(S status) { /* no-op implementation to be overridden */ } @@ -233,7 +240,7 @@ default void setCertification(AssetCertification certification) { /* no-op implementation to be overridden */ } - T withHref(URI href); + > T withHref(URI href); @JsonIgnore default EntityReference getEntityReference() { diff --git a/openmetadata-spec/src/main/java/org/openmetadata/schema/NamedEntityInterface.java b/openmetadata-spec/src/main/java/org/openmetadata/schema/NamedEntityInterface.java index ddce7fa1ea5d..4b6ae62a4af8 100644 --- a/openmetadata-spec/src/main/java/org/openmetadata/schema/NamedEntityInterface.java +++ b/openmetadata-spec/src/main/java/org/openmetadata/schema/NamedEntityInterface.java @@ -18,6 +18,7 @@ import org.openmetadata.schema.type.AssetCertification; import org.openmetadata.schema.type.ChangeDescription; import org.openmetadata.schema.type.EntityReference; +import org.openmetadata.schema.type.EntityStatus; import org.openmetadata.schema.type.LifeCycle; import org.openmetadata.schema.type.TagLabel; import org.openmetadata.schema.type.Votes; @@ -31,7 +32,7 @@ * null/no-op defaults for features that don't apply to lightweight entities. */ @SuppressWarnings("unused") -public interface NamedEntityInterface extends EntityInterface { +public interface NamedEntityInterface extends EntityInterface { @Override default List getOwners() { diff --git a/openmetadata-spec/src/main/java/org/openmetadata/schema/ServiceEntityInterface.java b/openmetadata-spec/src/main/java/org/openmetadata/schema/ServiceEntityInterface.java index b3922c6330bf..b66633a5e377 100644 --- a/openmetadata-spec/src/main/java/org/openmetadata/schema/ServiceEntityInterface.java +++ b/openmetadata-spec/src/main/java/org/openmetadata/schema/ServiceEntityInterface.java @@ -17,12 +17,13 @@ import org.openmetadata.schema.entity.services.ServiceAttributes; import org.openmetadata.schema.entity.services.connections.TestConnectionResult; import org.openmetadata.schema.type.EntityReference; +import org.openmetadata.schema.type.EntityStatus; /** * Interface to be implemented by all services entities to provide a way to access all the common * fields. */ -public interface ServiceEntityInterface extends EntityInterface { +public interface ServiceEntityInterface extends EntityInterface { ServiceConnectionEntityInterface getConnection(); diff --git a/openmetadata-spec/src/main/java/org/openmetadata/schema/utils/JsonUtils.java b/openmetadata-spec/src/main/java/org/openmetadata/schema/utils/JsonUtils.java index 4fa0d8be3348..e6b0708d6e85 100644 --- a/openmetadata-spec/src/main/java/org/openmetadata/schema/utils/JsonUtils.java +++ b/openmetadata-spec/src/main/java/org/openmetadata/schema/utils/JsonUtils.java @@ -618,7 +618,7 @@ private static JsonNode applyJsonPatch(JsonPatch patch, JsonNode targetNode) return jacksonPatch.apply(targetNode); } - public static T applyJsonPatch( + public static > T applyJsonPatch( T original, JsonPatch patch, Class clz) { try { // Convert original entity to JsonNode diff --git a/openmetadata-spec/src/main/resources/json/schema/analytics/webAnalyticEvent.json b/openmetadata-spec/src/main/resources/json/schema/analytics/webAnalyticEvent.json index 017e7bccaade..eb5036008ad5 100644 --- a/openmetadata-spec/src/main/resources/json/schema/analytics/webAnalyticEvent.json +++ b/openmetadata-spec/src/main/resources/json/schema/analytics/webAnalyticEvent.json @@ -5,7 +5,7 @@ "description": "Web Analytic Event", "type": "object", "javaType": "org.openmetadata.schema.analytics.WebAnalyticEvent", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "properties": { "id": { "description": "Unique identifier of the report.", diff --git a/openmetadata-spec/src/main/resources/json/schema/api/context/createContextMemory.json b/openmetadata-spec/src/main/resources/json/schema/api/context/createContextMemory.json index c64e44acd81f..31352f58c5d6 100644 --- a/openmetadata-spec/src/main/resources/json/schema/api/context/createContextMemory.json +++ b/openmetadata-spec/src/main/resources/json/schema/api/context/createContextMemory.json @@ -42,8 +42,8 @@ "$ref": "../../entity/context/contextMemory.json#/definitions/memoryScope" }, "entityStatus": { - "description": "Lifecycle stage the memory starts in. When omitted, the memory starts Unprocessed and is excluded from grounding until Approved. A Deprecated memory requires supersededBy.", - "$ref": "../../type/status.json" + "description": "Lifecycle stage the memory starts in. When omitted, the memory starts Unprocessed and is excluded from grounding until Approved. Superseded and legacy Deprecated memories require supersededBy.", + "$ref": "../../entity/context/contextMemoryStatus.json" }, "shareConfig": { "$ref": "../../entity/context/contextMemory.json#/definitions/shareConfig" diff --git a/openmetadata-spec/src/main/resources/json/schema/api/governance/entityLifecycleStages.json b/openmetadata-spec/src/main/resources/json/schema/api/governance/entityLifecycleStages.json index ba0fa3d3fc1c..da26c89fbe64 100644 --- a/openmetadata-spec/src/main/resources/json/schema/api/governance/entityLifecycleStages.json +++ b/openmetadata-spec/src/main/resources/json/schema/api/governance/entityLifecycleStages.json @@ -13,13 +13,13 @@ "properties": { "from": { "description": "Stage the entity is in.", - "$ref": "../../type/status.json" + "type": "string" }, "to": { "description": "Stages the entity can move to from it.", "type": "array", "items": { - "$ref": "../../type/status.json" + "type": "string" } } }, @@ -39,7 +39,7 @@ "description": "Stages an entity of this type can be in. Most types use the general stages; a type with a lifecycle of its own uses the stages it declares, which can include stages no other type has.", "type": "array", "items": { - "$ref": "../../type/status.json" + "type": "string" } }, "transitions": { @@ -66,7 +66,7 @@ "description": "Every lifecycle stage an entity can be in. Each entity type uses the stages its own entry lists.", "type": "array", "items": { - "$ref": "../../type/status.json" + "type": "string" } }, "entityTypes": { diff --git a/openmetadata-spec/src/main/resources/json/schema/dataInsight/custom/dataInsightCustomChart.json b/openmetadata-spec/src/main/resources/json/schema/dataInsight/custom/dataInsightCustomChart.json index d57451acc887..9bc3de065cf3 100644 --- a/openmetadata-spec/src/main/resources/json/schema/dataInsight/custom/dataInsightCustomChart.json +++ b/openmetadata-spec/src/main/resources/json/schema/dataInsight/custom/dataInsightCustomChart.json @@ -6,7 +6,7 @@ "type": "object", "javaType": "org.openmetadata.schema.dataInsight.custom.DataInsightCustomChart", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface" + "org.openmetadata.schema.EntityInterface" ], "properties": { "id": { diff --git a/openmetadata-spec/src/main/resources/json/schema/dataInsight/dataInsightChart.json b/openmetadata-spec/src/main/resources/json/schema/dataInsight/dataInsightChart.json index c5b7567a84c0..627f29c5245d 100644 --- a/openmetadata-spec/src/main/resources/json/schema/dataInsight/dataInsightChart.json +++ b/openmetadata-spec/src/main/resources/json/schema/dataInsight/dataInsightChart.json @@ -5,7 +5,7 @@ "description": "DataInsightChart represents the definition of a chart with its parameters", "type": "object", "javaType": "org.openmetadata.schema.dataInsight.DataInsightChart", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "chartParameterValues": { "type": "object", diff --git a/openmetadata-spec/src/main/resources/json/schema/dataInsight/kpi/kpi.json b/openmetadata-spec/src/main/resources/json/schema/dataInsight/kpi/kpi.json index 1e360c4198a3..e60b4a37e2e3 100644 --- a/openmetadata-spec/src/main/resources/json/schema/dataInsight/kpi/kpi.json +++ b/openmetadata-spec/src/main/resources/json/schema/dataInsight/kpi/kpi.json @@ -5,7 +5,7 @@ "description": "A `KIP` entity defines a metric and a target.", "type": "object", "javaType": "org.openmetadata.schema.dataInsight.kpi.Kpi", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "properties": { "id": { "description": "Unique identifier of this KPI Definition instance.", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/ai/aiApplication.json b/openmetadata-spec/src/main/resources/json/schema/entity/ai/aiApplication.json index 5261a59853eb..0fc65c399548 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/ai/aiApplication.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/ai/aiApplication.json @@ -6,7 +6,7 @@ "description": "AI Application entity representing AI systems including chatbots, agents, copilots, and other AI-powered applications. Applications can use multiple LLM models and integrate with various tools and data sources.", "type": "object", "javaType": "org.openmetadata.schema.entity.ai.AIApplication", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "applicationType": { "javaType": "org.openmetadata.schema.entity.ai.ApplicationType", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/ai/aiFrameworkControl.json b/openmetadata-spec/src/main/resources/json/schema/entity/ai/aiFrameworkControl.json index ccbfcfc855cb..f1c83c2b92eb 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/ai/aiFrameworkControl.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/ai/aiFrameworkControl.json @@ -6,7 +6,7 @@ "description": "A single control within an AI Governance Framework (e.g. EU AI Act Article 10). Controls drive per-asset compliance assessments.", "type": "object", "javaType": "org.openmetadata.schema.entity.ai.AIFrameworkControl", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "controlCategory": { "type": "string", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/ai/aiGovernanceFramework.json b/openmetadata-spec/src/main/resources/json/schema/entity/ai/aiGovernanceFramework.json index b48e46db881a..6bac4e91f527 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/ai/aiGovernanceFramework.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/ai/aiGovernanceFramework.json @@ -6,7 +6,7 @@ "description": "Workspace-level AI governance framework configuration. A framework is a library of controls that drives compliance assessments. Enabling a framework auto-applies it to in-scope AI assets via the autoApply rules.", "type": "object", "javaType": "org.openmetadata.schema.entity.ai.AIGovernanceFramework", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "frameworkSource": { "type": "string", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/ai/aiGovernancePolicy.json b/openmetadata-spec/src/main/resources/json/schema/entity/ai/aiGovernancePolicy.json index 478a47b0780e..a98c839dbd49 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/ai/aiGovernancePolicy.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/ai/aiGovernancePolicy.json @@ -6,7 +6,7 @@ "description": "AI Governance Policy entity representing organizational policies and rules for AI/LLM usage, compliance, and risk management. Enforces standards for model approval, data access, bias thresholds, and regulatory compliance.", "type": "object", "javaType": "org.openmetadata.schema.entity.ai.AIGovernancePolicy", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "policyType": { "type": "string", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/ai/auditReport.json b/openmetadata-spec/src/main/resources/json/schema/entity/ai/auditReport.json index 741c36380184..6f55690fde0a 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/ai/auditReport.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/ai/auditReport.json @@ -6,7 +6,7 @@ "description": "An asynchronously-generated evidence pack scoped to a framework, domain, or single AI asset. Bundles compliance records, control coverage, workflow history, remediation snapshot, and per-asset documents into machine-readable JSON (and optionally PDF) for auditors and regulators.", "type": "object", "javaType": "org.openmetadata.schema.entity.ai.AuditReport", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "reportScope": { "type": "string", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/ai/llmModel.json b/openmetadata-spec/src/main/resources/json/schema/entity/ai/llmModel.json index 0992b998641c..9e1f89559c11 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/ai/llmModel.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/ai/llmModel.json @@ -6,7 +6,7 @@ "description": "LLM Model entity representing a registered Large Language Model deployment, fine-tune, or base model. Models are independent entities that can be referenced by multiple AI agents.", "type": "object", "javaType": "org.openmetadata.schema.entity.ai.LLMModel", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "modelType": { "javaType": "org.openmetadata.schema.entity.ai.ModelType", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/ai/mcpServer.json b/openmetadata-spec/src/main/resources/json/schema/entity/ai/mcpServer.json index c942321419eb..a6a504e5d2d7 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/ai/mcpServer.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/ai/mcpServer.json @@ -6,7 +6,7 @@ "description": "MCP (Model Context Protocol) Server entity representing an MCP server deployment for AI governance. MCP servers expose tools, resources, and prompts that can be used by AI applications. This entity enables comprehensive governance including risk assessment, compliance, shadow AI detection, and data access tracking.", "type": "object", "javaType": "org.openmetadata.schema.entity.ai.McpServer", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "serverType": { "javaType": "org.openmetadata.schema.entity.ai.McpServerType", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/ai/promptTemplate.json b/openmetadata-spec/src/main/resources/json/schema/entity/ai/promptTemplate.json index 92075ab0bf87..79a5fa693f1f 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/ai/promptTemplate.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/ai/promptTemplate.json @@ -6,7 +6,7 @@ "description": "Prompt Template entity representing a reusable prompt template for AI agents. Templates can include variables, system prompts, and examples for consistent AI behavior.", "type": "object", "javaType": "org.openmetadata.schema.entity.ai.PromptTemplate", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "templateVariable": { "type": "object", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/applications/app.json b/openmetadata-spec/src/main/resources/json/schema/entity/applications/app.json index fc7f1b146344..e7586a1252cd 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/applications/app.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/applications/app.json @@ -4,7 +4,7 @@ "title": "App", "javaType": "org.openmetadata.schema.entity.app.App", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface" + "org.openmetadata.schema.EntityInterface" ], "description": "This schema defines the applications for Open-Metadata.", "type": "object", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/applications/marketplace/appMarketPlaceDefinition.json b/openmetadata-spec/src/main/resources/json/schema/entity/applications/marketplace/appMarketPlaceDefinition.json index a15086341889..5736ebdbf932 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/applications/marketplace/appMarketPlaceDefinition.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/applications/marketplace/appMarketPlaceDefinition.json @@ -3,7 +3,7 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "AppMarketPlaceDefinition", "javaType": "org.openmetadata.schema.entity.app.AppMarketPlaceDefinition", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "description": "This schema defines the applications for Open-Metadata.", "type": "object", "properties": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/automations/workflow.json b/openmetadata-spec/src/main/resources/json/schema/entity/automations/workflow.json index c02e8172d212..3be26b6f21b6 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/automations/workflow.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/automations/workflow.json @@ -6,7 +6,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.automations.Workflow", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface" + "org.openmetadata.schema.EntityInterface" ], "definitions": { "workflowType": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/bot.json b/openmetadata-spec/src/main/resources/json/schema/entity/bot.json index b78424a5d062..d896c5f25e92 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/bot.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/bot.json @@ -5,7 +5,7 @@ "description": "This schema defines a Bot entity. A bot automates tasks, such as adding description, identifying the importance of data. It performs this task as a special user in the system.", "type": "object", "javaType": "org.openmetadata.schema.entity.Bot", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "properties": { "id": { "description": "Unique identifier of a bot instance.", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/classification/classification.json b/openmetadata-spec/src/main/resources/json/schema/entity/classification/classification.json index 562c4e0298a4..2f7120b6c1b0 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/classification/classification.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/classification/classification.json @@ -6,7 +6,7 @@ "description": "A `Classification` entity contains hierarchical terms called tags used for categorizing and classifying data assets and other entities.", "type": "object", "javaType": "org.openmetadata.schema.entity.classification.Classification", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "properties": { "id": { "description": "Unique identifier of this entity instance.", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/classification/tag.json b/openmetadata-spec/src/main/resources/json/schema/entity/classification/tag.json index 2f74f543ff1c..924995a25062 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/classification/tag.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/classification/tag.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.classification.Tag", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface" + "org.openmetadata.schema.EntityInterface" ], "definitions": {}, "properties": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/context/contextMemory.json b/openmetadata-spec/src/main/resources/json/schema/entity/context/contextMemory.json index 9edfe472340f..7017d1c2ad48 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/context/contextMemory.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/context/contextMemory.json @@ -6,7 +6,7 @@ "description": "Reusable context memory for Context Center and AI-assisted retrieval.", "type": "object", "javaType": "org.openmetadata.schema.entity.context.ContextMemory", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "memoryType": { "javaType": "org.openmetadata.schema.entity.context.ContextMemoryType", @@ -251,15 +251,15 @@ "$ref": "#/definitions/memoryScope" }, "entityStatus": { - "description": "Lifecycle stage of the memory: Unprocessed (awaiting reconciliation), Draft, Approved (in use), Deprecated (replaced), Rejected (invalidated) or Archived. A Deprecated memory requires supersededBy. When omitted at creation, the memory starts Unprocessed. Only Approved memories ground new memories and agent responses.", - "$ref": "../../type/status.json" + "description": "Lifecycle stage of the memory: Unprocessed (awaiting reconciliation), Draft, Approved (in use), Superseded (replaced), Invalidated (found incorrect) or Archived. Deprecated and Rejected remain supported legacy retirement stages. Superseded and Deprecated memories require supersededBy. When omitted at creation, the memory starts Unprocessed. Only Approved memories ground new memories and agent responses.", + "$ref": "./contextMemoryStatus.json" }, "statusReason": { "description": "Why the memory reached its current status, e.g. the reconciliation verdict or the missing anchor. Cleared by a status change that brings no reason of its own.", "type": "string" }, "supersededBy": { - "description": "The memory that replaced this one. Set if and only if entityStatus is Deprecated.", + "description": "The memory that replaced this one. Set if and only if entityStatus is Superseded or the legacy Deprecated stage.", "$ref": "../../type/entityReference.json" }, "disputes": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/context/contextMemoryStatus.json b/openmetadata-spec/src/main/resources/json/schema/entity/context/contextMemoryStatus.json new file mode 100644 index 000000000000..bb2acc91efda --- /dev/null +++ b/openmetadata-spec/src/main/resources/json/schema/entity/context/contextMemoryStatus.json @@ -0,0 +1,18 @@ +{ + "$id": "https://open-metadata.org/schema/entity/context/contextMemoryStatus.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "ContextMemoryStatus", + "description": "Lifecycle stage of a context memory. Unprocessed awaits reconciliation; only Approved memories ground new memories and agent responses. Deprecated and Rejected remain readable legacy retirement stages.", + "type": "string", + "javaType": "org.openmetadata.schema.entity.context.ContextMemoryStatus", + "enum": [ + "Draft", + "Approved", + "Archived", + "Superseded", + "Invalidated", + "Unprocessed", + "Deprecated", + "Rejected" + ] +} diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/apiCollection.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/apiCollection.json index cac58121450f..12f3ef34a660 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/apiCollection.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/apiCollection.json @@ -6,7 +6,7 @@ "description": "This schema defines the APICollection entity. API Collection allows user to group multiple APIs together. In OpenAPI specification its marked as a Tag.", "type": "object", "javaType": "org.openmetadata.schema.entity.data.APICollection", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "properties": { "id": { "description": "Unique identifier that identifies a API Collection instance.", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/apiEndpoint.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/apiEndpoint.json index d3e9365dd10c..91520da4749c 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/apiEndpoint.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/apiEndpoint.json @@ -6,7 +6,7 @@ "description": "This schema defines the APIEndpoint entity. An APIEndpoint is a specific endpoint of an API that is part of an API Collection.", "type": "object", "javaType": "org.openmetadata.schema.entity.data.APIEndpoint", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "apiRequestMethod": { "javaType": "org.openmetadata.schema.type.APIRequestMethod", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/chart.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/chart.json index afb1fa694b95..19231a2191a5 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/chart.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/chart.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.data.Chart", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.CreationAudited" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/container.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/container.json index ec48304e473d..620e3f6aa036 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/container.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/container.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.data.Container", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.CreationAudited" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/contextFile.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/contextFile.json index a4b73feb53f8..be02e39cc2e5 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/contextFile.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/contextFile.json @@ -6,7 +6,7 @@ "description": "An uploaded file (PDF, spreadsheet, document) stored in the Context Center Drive.", "type": "object", "javaType": "org.openmetadata.schema.entity.data.ContextFile", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "fileType": { "javaType": "org.openmetadata.schema.entity.data.ContextFileType", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/contextFileContent.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/contextFileContent.json index 20eb6c5b59e6..751eeba6efb4 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/contextFileContent.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/contextFileContent.json @@ -6,7 +6,7 @@ "description": "A stored content snapshot for a ContextFile.", "type": "object", "javaType": "org.openmetadata.schema.entity.data.ContextFileContent", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "properties": { "id": { "description": "Unique identifier of the content snapshot.", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/dashboard.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/dashboard.json index e3bff61ae0cf..7b276c2f2805 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/dashboard.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/dashboard.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.data.Dashboard", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.CreationAudited" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/dashboardDataModel.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/dashboardDataModel.json index 1b94a5019b61..1fd8faadc960 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/dashboardDataModel.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/dashboardDataModel.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.data.DashboardDataModel", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.ColumnsEntityInterface", "org.openmetadata.schema.CreationAudited" ], diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/dataContract.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/dataContract.json index c45356a0b3f5..d8999712422e 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/dataContract.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/dataContract.json @@ -6,7 +6,7 @@ "description": "A `DataContract` entity defines the schema and quality guarantees for a data asset.", "type": "object", "javaType": "org.openmetadata.schema.entity.data.DataContract", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "contractStatus": { "javaType": "org.openmetadata.schema.type.ContractStatus", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/database.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/database.json index 3dcc6763cf62..dfef99b83d35 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/database.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/database.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.data.Database", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.CreationAudited" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/databaseSchema.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/databaseSchema.json index 41a3676de032..7bb281112229 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/databaseSchema.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/databaseSchema.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.data.DatabaseSchema", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.CreationAudited" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/directory.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/directory.json index e8b06f8c777a..865ec3b5f9d4 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/directory.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/directory.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.data.Directory", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface" + "org.openmetadata.schema.EntityInterface" ], "definitions": { "directoryType": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/file.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/file.json index af8a3bb58889..5b92def6f1dc 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/file.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/file.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.data.File", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface" + "org.openmetadata.schema.EntityInterface" ], "definitions": { "fileType": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/folder.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/folder.json index 03e80c2c4f6b..cc19eddef5fa 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/folder.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/folder.json @@ -6,7 +6,7 @@ "description": "A directory container for organizing files in the Context Center Drive. Folders can nest other folders. Access is determined by owners.", "type": "object", "javaType": "org.openmetadata.schema.entity.data.Folder", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "properties": { "id": { "description": "Unique identifier of the folder.", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/glossary.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/glossary.json index 16da9d703ea6..bb45085d788c 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/glossary.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/glossary.json @@ -6,7 +6,7 @@ "$comment": "@om-entity-type", "type": "object", "javaType": "org.openmetadata.schema.entity.data.Glossary", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "properties": { "id": { "description": "Unique identifier of a glossary instance.", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/glossaryTerm.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/glossaryTerm.json index d5540cd72a5b..d809db109f50 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/glossaryTerm.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/glossaryTerm.json @@ -6,7 +6,7 @@ "$comment": "@om-entity-type", "type": "object", "javaType": "org.openmetadata.schema.entity.data.GlossaryTerm", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "termReference": { "type": "object", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/metric.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/metric.json index b2414ad292c7..baa85c095d3f 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/metric.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/metric.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.data.Metric", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.CreationAudited" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/metricGroup.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/metricGroup.json index f37eee9e0211..ce0bdd567055 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/metricGroup.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/metricGroup.json @@ -6,7 +6,7 @@ "$comment": "@om-entity-type", "type": "object", "javaType": "org.openmetadata.schema.entity.data.MetricGroup", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "properties": { "id": { "description": "Unique identifier that identifies this Metric Group instance.", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/mlmodel.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/mlmodel.json index 6aeea79e18d4..81abb61ac9ed 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/mlmodel.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/mlmodel.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.data.MlModel", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.CreationAudited" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/ontologyAxiom.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/ontologyAxiom.json index 3072f7a1d631..ad3bbbe8d7ec 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/ontologyAxiom.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/ontologyAxiom.json @@ -6,7 +6,7 @@ "$comment": "@om-entity-type", "type": "object", "javaType": "org.openmetadata.schema.entity.data.OntologyAxiom", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "axiomType": { "javaType": "org.openmetadata.schema.type.OntologyAxiomType", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/ontologyChangeSet.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/ontologyChangeSet.json index 28baaede68da..de45d79e46c2 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/ontologyChangeSet.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/ontologyChangeSet.json @@ -6,7 +6,7 @@ "$comment": "@om-entity-type", "type": "object", "javaType": "org.openmetadata.schema.entity.data.OntologyChangeSet", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "state": { "javaType": "org.openmetadata.schema.type.OntologyChangeSetState", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/page.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/page.json index c1d13822b74a..cb6b21d578f5 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/page.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/page.json @@ -6,7 +6,7 @@ "description": "This schema defines the type of Page.", "type": "object", "javaType": "org.openmetadata.schema.entity.data.Page", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "pageType": { "javaType": "org.openmetadata.schema.entity.data.PageType", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/pipeline.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/pipeline.json index 6813370d4f13..b34c54651d3d 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/pipeline.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/pipeline.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.data.Pipeline", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.CreationAudited" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/query.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/query.json index 43e95442b275..82d3ce4122c7 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/query.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/query.json @@ -6,7 +6,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.data.Query", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.CreationAudited" ], "properties": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/relationshipType.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/relationshipType.json index 0b296fe2ab0c..9e674e6b51fd 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/relationshipType.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/relationshipType.json @@ -6,7 +6,7 @@ "$comment": "@om-entity-type", "type": "object", "javaType": "org.openmetadata.schema.entity.data.RelationshipType", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "category": { "javaType": "org.openmetadata.schema.type.RelationshipTypeCategory", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/report.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/report.json index 9a767ae1c684..537e53f15337 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/report.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/report.json @@ -5,7 +5,7 @@ "description": "This schema defines the Report entity. `Reports` are static information computed from data periodically that includes data in text, table, and visual form.", "type": "object", "javaType": "org.openmetadata.schema.entity.data.Report", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "properties": { "id": { "description": "Unique identifier that identifies this report.", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/searchIndex.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/searchIndex.json index e86cf8c0a50b..88d7d6bf0c28 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/searchIndex.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/searchIndex.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.data.SearchIndex", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface" + "org.openmetadata.schema.EntityInterface" ], "definitions": { "searchIndexSettings": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/spreadsheet.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/spreadsheet.json index e18f57e179b6..2c6bf52798f9 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/spreadsheet.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/spreadsheet.json @@ -6,7 +6,7 @@ "description": "This schema defines the Spreadsheet entity. A Spreadsheet is a file containing multiple worksheets/tabs, such as Google Sheets or Excel files.", "type": "object", "javaType": "org.openmetadata.schema.entity.data.Spreadsheet", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "spreadsheetMimeType": { "description": "MIME type for spreadsheet files", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/storedProcedure.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/storedProcedure.json index bdfbaeade38b..88b9fb75c37a 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/storedProcedure.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/storedProcedure.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.data.StoredProcedure", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface" + "org.openmetadata.schema.EntityInterface" ], "definitions": { "storedProcedureType": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/table.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/table.json index 9d2f0e52f2ad..558b7b3a954c 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/table.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/table.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.data.Table", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.ColumnsEntityInterface", "org.openmetadata.schema.CreationAudited" ], diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/topic.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/topic.json index 09adca16f0e7..91e95f887c05 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/topic.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/topic.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.data.Topic", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.CreationAudited" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/worksheet.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/worksheet.json index 5bb504382786..a121a4901007 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/worksheet.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/worksheet.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.data.Worksheet", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface" + "org.openmetadata.schema.EntityInterface" ], "properties": { "id": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/docStore/document.json b/openmetadata-spec/src/main/resources/json/schema/entity/docStore/document.json index 3fc8342799f5..10aefa88b8e8 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/docStore/document.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/docStore/document.json @@ -5,7 +5,7 @@ "description": "This schema defines Document. A Generic entity to capture any kind of Json Payload.", "type": "object", "javaType": "org.openmetadata.schema.entities.docStore.Document", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.DocStoreEntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.DocStoreEntityInterface"], "definitions": { "data": { "javaType": "org.openmetadata.schema.entities.docStore.Data", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/domains/dataProduct.json b/openmetadata-spec/src/main/resources/json/schema/entity/domains/dataProduct.json index 99131f2689ec..9b7ca2b27dc5 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/domains/dataProduct.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/domains/dataProduct.json @@ -6,7 +6,7 @@ "$comment": "@om-entity-type", "type": "object", "javaType": "org.openmetadata.schema.entity.domains.DataProduct", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "lifecycleStage": { "description": "Lifecycle stage of the data product", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/domains/domain.json b/openmetadata-spec/src/main/resources/json/schema/entity/domains/domain.json index c0ec0dcf9322..18b809e481b9 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/domains/domain.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/domains/domain.json @@ -6,7 +6,7 @@ "$comment": "@om-entity-type", "type": "object", "javaType": "org.openmetadata.schema.entity.domains.Domain", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "domainType" : { "description" : "Type of a domain", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/events/notificationTemplate.json b/openmetadata-spec/src/main/resources/json/schema/entity/events/notificationTemplate.json index 7c8f50cdf0b3..93b39aaf9063 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/events/notificationTemplate.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/events/notificationTemplate.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.events.NotificationTemplate", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface" + "org.openmetadata.schema.EntityInterface" ], "properties": { "id": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/learning/learningResource.json b/openmetadata-spec/src/main/resources/json/schema/entity/learning/learningResource.json index c201bc8a7aae..e0cb01cb6821 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/learning/learningResource.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/learning/learningResource.json @@ -6,7 +6,7 @@ "$comment": "@om-entity-type", "type": "object", "javaType": "org.openmetadata.schema.entity.learning.LearningResource", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "resourceType": { "description": "Kind of learning asset represented. A Link opens its URL in a new browser tab; a PDF is displayed in the resource player.", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/policies/policy.json b/openmetadata-spec/src/main/resources/json/schema/entity/policies/policy.json index d17ceaba94a2..c33fc2f2f3a3 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/policies/policy.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/policies/policy.json @@ -5,7 +5,7 @@ "description": "A `Policy` defines control that needs to be applied across different Data Entities.", "type": "object", "javaType": "org.openmetadata.schema.entity.policies.Policy", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "rules": { "description": "A set of rules associated with the Policy.", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/services/apiService.json b/openmetadata-spec/src/main/resources/json/schema/entity/services/apiService.json index b23fed3b2737..5d87cd451c85 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/services/apiService.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/services/apiService.json @@ -6,7 +6,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.services.ApiService", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.ServiceEntityInterface" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/services/connections/testConnectionDefinition.json b/openmetadata-spec/src/main/resources/json/schema/entity/services/connections/testConnectionDefinition.json index 64d9aa96de3e..3d7d6d4fe2f8 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/services/connections/testConnectionDefinition.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/services/connections/testConnectionDefinition.json @@ -5,7 +5,7 @@ "description": "TestConnection is the definition that will encapsulate the steps required to test a connection to a specific service.", "type": "object", "javaType": "org.openmetadata.schema.entity.services.connections.TestConnectionDefinition", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "testConnectionStep": { "description": "Function that tests one specific element of the service. E.g., listing schemas, lineage, or tags.", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/services/dashboardService.json b/openmetadata-spec/src/main/resources/json/schema/entity/services/dashboardService.json index 204bd233aaa4..ea7b46f4dedd 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/services/dashboardService.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/services/dashboardService.json @@ -6,7 +6,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.services.DashboardService", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.ServiceEntityInterface" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/services/databaseService.json b/openmetadata-spec/src/main/resources/json/schema/entity/services/databaseService.json index 096e32182f1b..f8417c5b7e86 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/services/databaseService.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/services/databaseService.json @@ -6,7 +6,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.services.DatabaseService", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.ServiceEntityInterface" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/services/driveService.json b/openmetadata-spec/src/main/resources/json/schema/entity/services/driveService.json index 46b86f4bce8a..a0ee2b17971c 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/services/driveService.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/services/driveService.json @@ -6,7 +6,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.services.DriveService", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.ServiceEntityInterface" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/services/ingestionPipelines/ingestionPipeline.json b/openmetadata-spec/src/main/resources/json/schema/entity/services/ingestionPipelines/ingestionPipeline.json index 4c3154051196..56358c0b4fb2 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/services/ingestionPipelines/ingestionPipeline.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/services/ingestionPipelines/ingestionPipeline.json @@ -5,7 +5,7 @@ "description": "Ingestion Pipeline Config is used to set up a DAG and deploy. This entity is used to setup metadata/quality pipelines on Apache Airflow.", "type": "object", "javaType": "org.openmetadata.schema.entity.services.ingestionPipelines.IngestionPipeline", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "pipelineType": { "description": "Type of Pipeline - metadata, usage", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/services/llmService.json b/openmetadata-spec/src/main/resources/json/schema/entity/services/llmService.json index 022ab70f84d7..d001e0ce9888 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/services/llmService.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/services/llmService.json @@ -6,7 +6,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.services.LLMService", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.ServiceEntityInterface" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/services/mcpService.json b/openmetadata-spec/src/main/resources/json/schema/entity/services/mcpService.json index 757ebf5b83b6..6e5f44a702fe 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/services/mcpService.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/services/mcpService.json @@ -6,7 +6,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.services.McpService", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.ServiceEntityInterface" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/services/messagingService.json b/openmetadata-spec/src/main/resources/json/schema/entity/services/messagingService.json index a49794c0e63e..a6f42ae0cb59 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/services/messagingService.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/services/messagingService.json @@ -6,7 +6,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.services.MessagingService", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.ServiceEntityInterface" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/services/metadataService.json b/openmetadata-spec/src/main/resources/json/schema/entity/services/metadataService.json index 447cfc7351f0..b2546e8bb346 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/services/metadataService.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/services/metadataService.json @@ -5,7 +5,7 @@ "description": "This schema defines the Metadata Service entity, such as Amundsen, Atlas etc.", "javaType": "org.openmetadata.schema.entity.services.MetadataService", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.ServiceEntityInterface" ], "type": "object", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/services/mlmodelService.json b/openmetadata-spec/src/main/resources/json/schema/entity/services/mlmodelService.json index 769906cfe6d4..4344a98fc76c 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/services/mlmodelService.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/services/mlmodelService.json @@ -6,7 +6,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.services.MlModelService", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.ServiceEntityInterface" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/services/pipelineService.json b/openmetadata-spec/src/main/resources/json/schema/entity/services/pipelineService.json index 3f7156418dfa..ffdc220e9395 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/services/pipelineService.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/services/pipelineService.json @@ -6,7 +6,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.services.PipelineService", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.ServiceEntityInterface" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/services/searchService.json b/openmetadata-spec/src/main/resources/json/schema/entity/services/searchService.json index 66e80bd53613..3481f1d133cb 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/services/searchService.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/services/searchService.json @@ -6,7 +6,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.services.SearchService", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.ServiceEntityInterface" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/services/securityService.json b/openmetadata-spec/src/main/resources/json/schema/entity/services/securityService.json index 6d6bfa745e68..5c7c349b4183 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/services/securityService.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/services/securityService.json @@ -6,7 +6,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.services.SecurityService", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.ServiceEntityInterface" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/services/storageService.json b/openmetadata-spec/src/main/resources/json/schema/entity/services/storageService.json index b4007ed82dd5..40d4f2767fd2 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/services/storageService.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/services/storageService.json @@ -6,7 +6,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.services.StorageService", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.ServiceEntityInterface" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/teams/persona.json b/openmetadata-spec/src/main/resources/json/schema/entity/teams/persona.json index 8b6d4a742c39..827028afd7c5 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/teams/persona.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/teams/persona.json @@ -5,7 +5,7 @@ "description": "This schema defines the Persona entity. A `Persona` is a job function associated with a user. An Example, Data Engineer or Data Consumer is a Persona of a user in Metadata world.", "type": "object", "javaType": "org.openmetadata.schema.entity.teams.Persona", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "properties": { "id": { "$ref": "../../type/basic.json#/definitions/uuid" diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/teams/role.json b/openmetadata-spec/src/main/resources/json/schema/entity/teams/role.json index 2df486cba5d1..9970537317ca 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/teams/role.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/teams/role.json @@ -5,7 +5,7 @@ "description": "A `Role` is a collection of `Policies` that provides access control. A user or a team can be assigned one or multiple roles that provide privileges to a user and members of a team to perform the job function.", "javaType": "org.openmetadata.schema.entity.teams.Role", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.CreationAudited" ], "type": "object", diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/teams/team.json b/openmetadata-spec/src/main/resources/json/schema/entity/teams/team.json index b518eb2fa408..6c8aa3b28ada 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/teams/team.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/teams/team.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.teams.Team", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.CreationAudited" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/teams/user.json b/openmetadata-spec/src/main/resources/json/schema/entity/teams/user.json index fcbf185c3a1b..423135f19a37 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/teams/user.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/teams/user.json @@ -7,7 +7,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.teams.User", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface", + "org.openmetadata.schema.EntityInterface", "org.openmetadata.schema.CreationAudited" ], "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/type.json b/openmetadata-spec/src/main/resources/json/schema/entity/type.json index 3a15ed722058..3f6c3504fc80 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/type.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/type.json @@ -5,7 +5,7 @@ "description": "This schema defines a type as an entity. Types includes property types and entity types. Custom types can also be defined by the users to extend the metadata system.", "type": "object", "javaType": "org.openmetadata.schema.entity.Type", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "entityName": { "description": "Name of the property or entity types. Note a property name must be unique for an entity. Property name must follow camelCase naming adopted by openMetadata - must start with lower case with no space, underscore, or dots.", diff --git a/openmetadata-spec/src/main/resources/json/schema/events/eventSubscription.json b/openmetadata-spec/src/main/resources/json/schema/events/eventSubscription.json index b08efd3de302..3a3c21d38bfa 100644 --- a/openmetadata-spec/src/main/resources/json/schema/events/eventSubscription.json +++ b/openmetadata-spec/src/main/resources/json/schema/events/eventSubscription.json @@ -5,7 +5,7 @@ "description": "This schema defines the EventSubscription entity. An Event Subscription has trigger, filters and Subscription", "type": "object", "javaType": "org.openmetadata.schema.entity.events.EventSubscription", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "argumentsInput": { "description": "Observability Filters for Event Subscription.", diff --git a/openmetadata-spec/src/main/resources/json/schema/governance/intakeForm.json b/openmetadata-spec/src/main/resources/json/schema/governance/intakeForm.json index 36f491e8f175..53da083e4a1e 100644 --- a/openmetadata-spec/src/main/resources/json/schema/governance/intakeForm.json +++ b/openmetadata-spec/src/main/resources/json/schema/governance/intakeForm.json @@ -6,7 +6,7 @@ "$comment": "@om-entity-type", "type": "object", "javaType": "org.openmetadata.schema.entity.governance.IntakeForm", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "targetEntityType": { "description": "Entity types supported by IntakeForm today.", diff --git a/openmetadata-spec/src/main/resources/json/schema/governance/workflows/workflowDefinition.json b/openmetadata-spec/src/main/resources/json/schema/governance/workflows/workflowDefinition.json index 48abf7582ac2..d969d97d32b9 100644 --- a/openmetadata-spec/src/main/resources/json/schema/governance/workflows/workflowDefinition.json +++ b/openmetadata-spec/src/main/resources/json/schema/governance/workflows/workflowDefinition.json @@ -3,7 +3,7 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "WorkflowDefinition", "description": "Defines a workflow, having all the different pieces and attributes.", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "javaType": "org.openmetadata.schema.governance.workflows.WorkflowDefinition", "type": "object", "definitions": { diff --git a/openmetadata-spec/src/main/resources/json/schema/tests/dataQualityDimension.json b/openmetadata-spec/src/main/resources/json/schema/tests/dataQualityDimension.json index 5e2f7e6e9b01..fde599a4868a 100644 --- a/openmetadata-spec/src/main/resources/json/schema/tests/dataQualityDimension.json +++ b/openmetadata-spec/src/main/resources/json/schema/tests/dataQualityDimension.json @@ -5,7 +5,7 @@ "description": "A Data Quality Dimension classifies what a test is checking, such as Completeness or Accuracy. Test definitions and test cases reference a dimension by relationship, so renaming or recolouring one updates it everywhere. OpenMetadata ships a set of system dimensions that cannot be edited or deleted; users with the right permission can create their own on top of them.", "type": "object", "javaType": "org.openmetadata.schema.tests.DataQualityDimension", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "properties": { "id": { "description": "Unique identifier of this data quality dimension instance.", diff --git a/openmetadata-spec/src/main/resources/json/schema/tests/testCase.json b/openmetadata-spec/src/main/resources/json/schema/tests/testCase.json index 822e91a8158d..191c33d82b0d 100644 --- a/openmetadata-spec/src/main/resources/json/schema/tests/testCase.json +++ b/openmetadata-spec/src/main/resources/json/schema/tests/testCase.json @@ -5,7 +5,7 @@ "description": "Test case is a test definition to capture data quality tests against tables, columns, and other data assets.", "type": "object", "javaType": "org.openmetadata.schema.tests.TestCase", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "testCaseParameterValue": { "type": "object", diff --git a/openmetadata-spec/src/main/resources/json/schema/tests/testDefinition.json b/openmetadata-spec/src/main/resources/json/schema/tests/testDefinition.json index 562e9c55eea2..626ad5507e0c 100644 --- a/openmetadata-spec/src/main/resources/json/schema/tests/testDefinition.json +++ b/openmetadata-spec/src/main/resources/json/schema/tests/testDefinition.json @@ -5,7 +5,7 @@ "description": "Test Definition is a type of test using which test cases are created to capture data quality tests against data entities.", "type": "object", "javaType": "org.openmetadata.schema.tests.TestDefinition", - "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], + "javaInterfaces": ["org.openmetadata.schema.EntityInterface"], "definitions": { "testPlatform": { "javaType": "org.openmetadata.schema.tests.TestPlatform", diff --git a/openmetadata-spec/src/main/resources/json/schema/type/status.json b/openmetadata-spec/src/main/resources/json/schema/type/status.json index 0a086d248bfe..e86700d81489 100644 --- a/openmetadata-spec/src/main/resources/json/schema/type/status.json +++ b/openmetadata-spec/src/main/resources/json/schema/type/status.json @@ -2,7 +2,7 @@ "$id": "https://open-metadata.org/schema/type/status.json", "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "EntityStatus", - "description": "Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` property. Entity types without that property have no lifecycle. When a create request omits the stage, the server assigns the entity type's initial stage.", + "description": "General lifecycle stage for entities that reference this vocabulary. Specialized entities can declare their own status schema and lifecycle policy. Entity types without an entityStatus property have no lifecycle. When a create request omits the stage, the server assigns the entity type's initial stage.", "type": "string", "javaType": "org.openmetadata.schema.type.EntityStatus", "enum": [ diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/ContextCenterMemoryLifecycle.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/ContextCenterMemoryLifecycle.spec.ts index 0f5758150196..c9dd5a1645ad 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/ContextCenterMemoryLifecycle.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/ContextCenterMemoryLifecycle.spec.ts @@ -62,7 +62,7 @@ test.describe( invalidated = await createMemory('invalidated', 'Approved'); await patchMemory(apiContext, superseded.id, [ - { op: 'replace', path: '/entityStatus', value: 'Deprecated' }, + { op: 'replace', path: '/entityStatus', value: 'Superseded' }, { op: 'add', path: '/supersededBy', @@ -71,7 +71,7 @@ test.describe( { op: 'add', path: '/statusReason', value: supersededReason }, ]); await patchMemory(apiContext, invalidated.id, [ - { op: 'replace', path: '/entityStatus', value: 'Rejected' }, + { op: 'replace', path: '/entityStatus', value: 'Invalidated' }, { op: 'add', path: '/statusReason', value: invalidatedReason }, ]); } finally { @@ -116,7 +116,7 @@ test.describe( ).not.toBeVisible(); await page.getByTestId('memory-status-filter').click(); - await page.getByRole('menuitemcheckbox', { name: 'Deprecated' }).click(); + await page.getByRole('menuitemcheckbox', { name: 'Superseded' }).click(); await page.keyboard.press('Escape'); await expect(page.getByTestId('memory-status-filter')).toContainText( '3 Statuses' @@ -175,7 +175,7 @@ test.describe( test.slow(); await navigateToMemories(page); await page.getByTestId('memory-status-filter').click(); - await page.getByRole('menuitemcheckbox', { name: 'Deprecated' }).click(); + await page.getByRole('menuitemcheckbox', { name: 'Superseded' }).click(); await page.keyboard.press('Escape'); const supersededRow = await searchAndGetMemoryRow( @@ -185,7 +185,7 @@ test.describe( ); await expect( supersededRow.getByTestId(`memory-status-${superseded.id}`) - ).toContainText('Deprecated'); + ).toContainText('Superseded'); await expect( supersededRow.getByTestId(`memory-status-reason-${superseded.id}`) ).toContainText(supersededReason); @@ -193,7 +193,7 @@ test.describe( const dialog = page.getByRole('dialog'); await expect(dialog.getByTestId('memory-lifecycle-status')).toContainText( - 'Deprecated' + 'Superseded' ); await expect(dialog.getByTestId('memory-lifecycle-reason')).toContainText( supersededReason @@ -201,6 +201,10 @@ test.describe( await expect( dialog.getByRole('button', { name: /propose term/i }) ).not.toBeVisible(); + await page.screenshot({ + path: test.info().outputPath('superseded-memory.png'), + animations: 'disabled', + }); await dialog.getByTestId('memory-lifecycle-successor').click(); await expect(page).toHaveURL(new RegExp(`memory=${successor.name}`)); await expect( @@ -210,11 +214,15 @@ test.describe( await page.goto(`${MEMORIES_URL}?memory=${invalidated.name}`); await waitForAllLoadersToDisappear(page); await expect(dialog.getByTestId('memory-lifecycle-status')).toContainText( - 'Rejected' + 'Invalidated' ); await expect(dialog.getByTestId('memory-lifecycle-reason')).toContainText( invalidatedReason ); + await page.screenshot({ + path: test.info().outputPath('invalidated-memory.png'), + animations: 'disabled', + }); await expect( dialog.getByRole('button', { name: /propose term/i }) ).not.toBeVisible(); @@ -226,7 +234,7 @@ test.describe( await page.goto(`${MEMORIES_URL}?memory=${superseded.name}`); const dialog = page.getByRole('dialog'); await expect(dialog.getByTestId('memory-lifecycle-status')).toContainText( - 'Deprecated' + 'Superseded' ); await dialog.getByTestId('memory-lifecycle-successor').click(); await expect( diff --git a/openmetadata-ui/src/main/resources/ui/public/jsons/connectionSchemas/connections/testConnectionDefinition.json b/openmetadata-ui/src/main/resources/ui/public/jsons/connectionSchemas/connections/testConnectionDefinition.json index 06a160af3b91..9797161a1016 100644 --- a/openmetadata-ui/src/main/resources/ui/public/jsons/connectionSchemas/connections/testConnectionDefinition.json +++ b/openmetadata-ui/src/main/resources/ui/public/jsons/connectionSchemas/connections/testConnectionDefinition.json @@ -4,7 +4,7 @@ "type": "object", "javaType": "org.openmetadata.schema.entity.services.connections.TestConnectionDefinition", "javaInterfaces": [ - "org.openmetadata.schema.EntityInterface" + "org.openmetadata.schema.EntityInterface" ], "definitions": { "testConnectionStep": { diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/CreateMemoryModal/CreateMemoryModal.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/CreateMemoryModal/CreateMemoryModal.component.tsx index f206329b12cc..4b2669bd1bda 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/CreateMemoryModal/CreateMemoryModal.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/CreateMemoryModal/CreateMemoryModal.component.tsx @@ -80,8 +80,8 @@ import { ResourceEntity } from '../../../enums/permissions.enum'; import { SearchIndex } from '../../../enums/search.enum'; import { ContextMemory, + ContextMemoryStatus, EntityReference, - EntityStatus, MemoryType, ShareVisibility, TagLabel, @@ -645,12 +645,18 @@ const MemoryTagsRow: FC<{ ); const getEntityStatusColor = ( - status: EntityStatus + status: ContextMemoryStatus ): 'error' | 'warning' | 'gray' => { - if (status === EntityStatus.Rejected) { + if ( + status === ContextMemoryStatus.Rejected || + status === ContextMemoryStatus.Invalidated + ) { return 'error'; } - if (status === EntityStatus.Deprecated) { + if ( + status === ContextMemoryStatus.Deprecated || + status === ContextMemoryStatus.Superseded + ) { return 'warning'; } @@ -708,7 +714,9 @@ const MemoryLifecycleRows: FC<{ data-testid="memory-lifecycle-status" size="sm" type="color"> - {t(MEMORY_STATUS_LABEL_KEYS[memoryToEdit.entityStatus])} + {MEMORY_STATUS_LABEL_KEYS[memoryToEdit.entityStatus] + ? t(MEMORY_STATUS_LABEL_KEYS[memoryToEdit.entityStatus]) + : memoryToEdit.entityStatus} )} @@ -727,7 +735,8 @@ const MemoryLifecycleRows: FC<{ )} - {memoryToEdit?.entityStatus === EntityStatus.Deprecated && + {(memoryToEdit?.entityStatus === ContextMemoryStatus.Deprecated || + memoryToEdit?.entityStatus === ContextMemoryStatus.Superseded) && memoryToEdit.supersededBy && (
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/CreateMemoryModal/CreateMemoryModal.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/CreateMemoryModal/CreateMemoryModal.test.tsx index 9839861c4dd0..23c5b1116d0c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/CreateMemoryModal/CreateMemoryModal.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/CreateMemoryModal/CreateMemoryModal.test.tsx @@ -29,7 +29,7 @@ import { import { MemoryRouter } from 'react-router-dom'; import { ContextMemory, - EntityStatus, + ContextMemoryStatus, } from '../../../generated/entity/context/contextMemory'; import { getMemoryOntologyProposalStatus, @@ -444,7 +444,7 @@ describe('CreateMemoryModal', () => { const memory = { id: 'memory-id', name: 'inactive-customer', - entityStatus: EntityStatus.Approved, + entityStatus: ContextMemoryStatus.Approved, owners: [{ id: 'admin-id', type: 'user', name: 'admin' }], shareConfig: { visibility: 'Shared' }, derivedEntities: [], @@ -566,10 +566,12 @@ describe('CreateMemoryModal', () => { }); it.each([ - EntityStatus.Draft, - EntityStatus.Archived, - EntityStatus.Deprecated, - EntityStatus.Rejected, + ContextMemoryStatus.Draft, + ContextMemoryStatus.Archived, + ContextMemoryStatus.Deprecated, + ContextMemoryStatus.Rejected, + ContextMemoryStatus.Superseded, + ContextMemoryStatus.Invalidated, ])('hides proposal action for status %s', async (status) => { const memory = { id: 'memory-id', @@ -741,36 +743,42 @@ describe('CreateMemoryModal', () => { ).not.toBeInTheDocument(); }); - it('shows why a memory was superseded and links to its successor', () => { - render( - - - - ); + it.each<[ContextMemoryStatus, string]>([ + [ContextMemoryStatus.Deprecated, 'label.deprecated'], + [ContextMemoryStatus.Superseded, 'label.superseded'], + ])( + 'shows why a %s memory was replaced and links to its successor', + (status, label) => { + render( + + + + ); - expect(screen.getByText('label.deprecated')).toBeInTheDocument(); - expect( - screen.getByText('The replacement has the corrected definition.') - ).toBeInTheDocument(); - expect(screen.getByText('new-memory')).toHaveAttribute( - 'href', - '/context-center/memories?memory=new-memory' - ); - }); + expect(screen.getByText(label)).toBeInTheDocument(); + expect( + screen.getByText('The replacement has the corrected definition.') + ).toBeInTheDocument(); + expect(screen.getByText('new-memory')).toHaveAttribute( + 'href', + '/context-center/memories?memory=new-memory' + ); + } + ); it('keeps the other Context Center parameters when opening the successor', () => { render( @@ -782,7 +790,7 @@ describe('CreateMemoryModal', () => { memoryToEdit={{ id: 'old-memory', name: 'old-memory', - entityStatus: EntityStatus.Deprecated, + entityStatus: ContextMemoryStatus.Deprecated, supersededBy: { id: 'new-memory', type: 'contextMemory', @@ -808,7 +816,7 @@ describe('CreateMemoryModal', () => { memoryToEdit={{ id: 'old-memory', name: 'old-memory', - entityStatus: EntityStatus.Deprecated, + entityStatus: ContextMemoryStatus.Deprecated, supersededBy: { id: 'new-memory', type: 'contextMemory', diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/MemoriesView/MemoriesView.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/MemoriesView/MemoriesView.component.tsx index 179837aedc6c..649b1e4037b1 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/MemoriesView/MemoriesView.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/MemoriesView/MemoriesView.component.tsx @@ -36,8 +36,8 @@ import { ENTITY_ICON_MAPPER } from '../../../constants/Assets.constants'; import { MEMORY_STATUS_LABEL_KEYS } from '../../../constants/ContextCenter.constants'; import { ContextMemory, + ContextMemoryStatus, EntityReference, - EntityStatus, } from '../../../generated/entity/context/contextMemory'; import { getShortRelativeTime } from '../../../utils/date-time/DateTimeUtils'; import { getEntityName } from '../../../utils/EntityNameUtils'; @@ -285,14 +285,20 @@ const EntityStatusBadge: FC<{ memory: ContextMemory }> = ({ memory }) => { const { t } = useTranslation(); const status = memory.entityStatus; - if (!status || status === EntityStatus.Approved) { + if (!status || status === ContextMemoryStatus.Approved) { return null; } let color: 'error' | 'warning' | 'gray' = 'gray'; - if (status === EntityStatus.Rejected) { + if ( + status === ContextMemoryStatus.Rejected || + status === ContextMemoryStatus.Invalidated + ) { color = 'error'; - } else if (status === EntityStatus.Deprecated) { + } else if ( + status === ContextMemoryStatus.Deprecated || + status === ContextMemoryStatus.Superseded + ) { color = 'warning'; } @@ -302,7 +308,9 @@ const EntityStatusBadge: FC<{ memory: ContextMemory }> = ({ memory }) => { data-testid={`memory-status-${memory.id}`} size="sm" type="color"> - {t(MEMORY_STATUS_LABEL_KEYS[status])} + {MEMORY_STATUS_LABEL_KEYS[status] + ? t(MEMORY_STATUS_LABEL_KEYS[status]) + : status} ); }; @@ -310,7 +318,10 @@ const EntityStatusBadge: FC<{ memory: ContextMemory }> = ({ memory }) => { const EntityStatusReason: FC<{ memory: ContextMemory }> = ({ memory }) => { const { t } = useTranslation(); - if (!memory.statusReason || memory.entityStatus === EntityStatus.Approved) { + if ( + !memory.statusReason || + memory.entityStatus === ContextMemoryStatus.Approved + ) { return null; } diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/MemoriesView/MemoriesView.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/MemoriesView/MemoriesView.test.tsx index fd0341dceb3d..b1681a82cf7d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/MemoriesView/MemoriesView.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/MemoriesView/MemoriesView.test.tsx @@ -13,7 +13,7 @@ import { render, screen } from '@testing-library/react'; import { ContextMemory, - EntityStatus, + ContextMemoryStatus, } from '../../../generated/entity/context/contextMemory'; import MemoriesView from './MemoriesView.component'; @@ -140,13 +140,18 @@ describe('MemoriesView', () => { ).toBeInTheDocument(); }); - it('shows a retired memory status and its reason', () => { + it.each<[ContextMemoryStatus, string]>([ + [ContextMemoryStatus.Deprecated, 'label.deprecated'], + [ContextMemoryStatus.Rejected, 'label.rejected'], + [ContextMemoryStatus.Superseded, 'label.superseded'], + [ContextMemoryStatus.Invalidated, 'label.invalidated'], + ])('shows the %s memory status and its reason', (status, label) => { render( { /> ); - expect(screen.getByText('label.deprecated')).toBeInTheDocument(); + expect(screen.getByText(label)).toBeInTheDocument(); expect( screen.getByText(/The replacement has the corrected definition/) ).toBeInTheDocument(); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.test.tsx index 6282a76f718f..5ae6eedaee9c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.test.tsx @@ -1199,14 +1199,19 @@ describe('Test GlossaryTermTab component', () => { expect(getStatusCheckbox(EntityStatus.Draft)).toBeChecked(); }); - it('should select every status when "all" is checked', async () => { + it('should select every general status when "all" is checked', async () => { await openStatusFilter(); + expect(screen.queryByText('Superseded')).not.toBeInTheDocument(); + expect(screen.queryByText('Invalidated')).not.toBeInTheDocument(); + fireEvent.click(getStatusCheckbox('all')); - Object.values(EntityStatus).forEach((status) => { - expect(getStatusCheckbox(status)).toBeChecked(); - }); + Object.values(EntityStatus) + .filter((status) => !['Superseded', 'Invalidated'].includes(status)) + .forEach((status) => { + expect(getStatusCheckbox(status)).toBeChecked(); + }); }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/WorkflowDefinitions/WorkflowBuilder/forms/SetActionForm.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/WorkflowDefinitions/WorkflowBuilder/forms/SetActionForm.test.tsx new file mode 100644 index 000000000000..c61bf8162185 --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/components/WorkflowDefinitions/WorkflowBuilder/forms/SetActionForm.test.tsx @@ -0,0 +1,165 @@ +/* + * Copyright 2026 Collate. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { + act, + fireEvent, + render, + screen, + waitFor, + within, +} from '@testing-library/react'; +import { MemoryRouter } from 'react-router-dom'; +import { Node } from 'reactflow'; +import { WorkflowModeProvider } from '../../../../contexts/WorkflowModeContext'; +import { EntityLifecycleStages } from '../../../../generated/api/governance/entityLifecycleStages'; +import { getEntityLifecycleStages } from '../../../../rest/metadataTypeAPI'; +import { showErrorToast } from '../../../../utils/ToastUtils'; +import { SetActionForm } from './SetActionForm'; + +jest.mock('../../../../rest/metadataTypeAPI'); +jest.mock('../../../../utils/ToastUtils'); + +const lifecycle: EntityLifecycleStages = { + stages: ['Approved', 'In Review', 'Superseded', 'Invalidated'], + entityTypes: [ + { + entityType: 'table', + stages: ['Approved', 'In Review'], + transitions: [], + stageWorkflows: [], + }, + { + entityType: 'contextMemory', + stages: ['Approved', 'Superseded', 'Invalidated'], + transitions: [], + stageWorkflows: [], + }, + ], +}; + +const node: Node = { + id: 'set-status', + position: { x: 0, y: 0 }, + data: { + displayName: 'Set status', + config: { fieldName: 'status', fieldValue: 'Superseded' }, + }, +}; + +const form = (entityTypes: string[], onSave = jest.fn()) => ( + + + + + +); + +const renderForm = (entityTypes: string[], onSave = jest.fn()) => + render(form(entityTypes, onSave)); + +describe('workflow lifecycle status options', () => { + beforeEach(() => { + ( + getEntityLifecycleStages as jest.MockedFunction< + typeof getEntityLifecycleStages + > + ) + .mockReset() + .mockResolvedValue(lifecycle); + }); + + it('loads the memory vocabulary and saves its own status code', async () => { + const onSave = jest.fn(); + renderForm(['contextMemory'], onSave); + const save = screen.getByTestId('save-node-configuration-button'); + + expect(save).toBeDisabled(); + + await waitFor(() => expect(save).toBeEnabled()); + fireEvent.click(save); + + expect(onSave).toHaveBeenCalledWith( + 'set-status', + expect.objectContaining({ + config: expect.objectContaining({ + fieldName: 'status', + fieldValue: 'Superseded', + }), + }) + ); + }); + + it('keeps a memory-only status from being saved for a mixed target workflow', async () => { + renderForm(['table', 'contextMemory']); + const select = screen.getByTestId('field-value-select'); + await waitFor(() => + expect(within(select).getByRole('button')).toBeEnabled() + ); + fireEvent.click(within(select).getByRole('button')); + await screen.findByRole('option', { name: 'Approved' }); + + expect( + screen.queryByRole('option', { name: 'Superseded' }) + ).not.toBeInTheDocument(); + expect( + screen.queryByRole('option', { name: 'In Review' }) + ).not.toBeInTheDocument(); + expect(screen.getByTestId('save-node-configuration-button')).toBeDisabled(); + }); + + it('keeps current target choices when an older discovery request finishes last', async () => { + let resolveOlder!: (value: EntityLifecycleStages) => void; + const older = new Promise((resolve) => { + resolveOlder = resolve; + }); + ( + getEntityLifecycleStages as jest.MockedFunction< + typeof getEntityLifecycleStages + > + ).mockReturnValueOnce(older); + const view = renderForm(['contextMemory']); + view.rerender(form(['table'])); + const select = screen.getByTestId('field-value-select'); + await waitFor(() => + expect(within(select).getByRole('button')).toBeEnabled() + ); + await act(async () => { + resolveOlder(lifecycle); + }); + fireEvent.click(within(select).getByRole('button')); + await screen.findByRole('option', { name: 'In Review' }); + + expect( + screen.queryByRole('option', { name: 'Superseded' }) + ).not.toBeInTheDocument(); + expect(screen.getByTestId('save-node-configuration-button')).toBeDisabled(); + }); + + it('keeps status writes disabled when discovery fails', async () => { + const error = new Error('Discovery unavailable'); + ( + getEntityLifecycleStages as jest.MockedFunction< + typeof getEntityLifecycleStages + > + ).mockRejectedValue(error); + renderForm(['contextMemory']); + await waitFor(() => expect(showErrorToast).toHaveBeenCalledWith(error)); + + expect(screen.getByTestId('save-node-configuration-button')).toBeDisabled(); + }); +}); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/WorkflowDefinitions/WorkflowBuilder/forms/SetActionForm.tsx b/openmetadata-ui/src/main/resources/ui/src/components/WorkflowDefinitions/WorkflowBuilder/forms/SetActionForm.tsx index 704103f239d0..26640ee75c13 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/WorkflowDefinitions/WorkflowBuilder/forms/SetActionForm.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/WorkflowDefinitions/WorkflowBuilder/forms/SetActionForm.tsx @@ -25,15 +25,14 @@ import { FIELD_OPTIONS_DROPDOWN, } from '../../../../constants/WorkflowBuilder.constants'; import { useWorkflowModeContext } from '../../../../contexts/WorkflowModeContext'; -import { EntityType } from '../../../../enums/entity.enum'; import { TagSource } from '../../../../generated/api/domains/createDataProduct'; -import { EntityStatus } from '../../../../generated/entity/data/glossaryTerm'; import { LabelType, State, TagLabel, } from '../../../../generated/type/tagLabel'; import { getTags } from '../../../../rest/tagAPI'; +import { fetchLifecycleStatuses } from '../../../../utils/governance/lifecycle/LifecycleStatus.utils'; import { showErrorToast } from '../../../../utils/ToastUtils'; import { createNodeConfig, @@ -50,7 +49,7 @@ interface SetActionFormProps { onSave: (nodeId: string, config: Record) => void; onClose: () => void; onDelete?: (nodeId: string) => void; - entityTypes?: EntityType[]; + entityTypes?: readonly string[]; } export const SetActionForm: React.FC = ({ @@ -58,6 +57,7 @@ export const SetActionForm: React.FC = ({ onSave, onClose, onDelete, + entityTypes, }) => { const { t } = useTranslation(); const { isFormDisabled } = useWorkflowModeContext(); @@ -71,9 +71,42 @@ export const SetActionForm: React.FC = ({ const [fieldOptions, setFieldOptions] = useState>({ certification: [], tier: [], - status: Object.values(EntityStatus), + status: [], }); const [isLoadingOptions, setIsLoadingOptions] = useState(false); + const entityTypesKey = entityTypes?.join(',') ?? ''; + + useEffect(() => { + if (formData.fieldName !== FieldOptions.STATUS) { + return; + } + let active = true; + setIsLoadingOptions(true); + setFieldOptions((previous) => ({ ...previous, status: [] })); + fetchLifecycleStatuses( + entityTypesKey.split(',').filter(Boolean), + 'intersection' + ) + .then((status) => { + if (active) { + setFieldOptions((previous) => ({ ...previous, status })); + } + }) + .catch((error: AxiosError) => { + if (active) { + showErrorToast(error); + } + }) + .finally(() => { + if (active) { + setIsLoadingOptions(false); + } + }); + + return () => { + active = false; + }; + }, [formData.fieldName, entityTypesKey]); const updateFormData = useCallback( (field: keyof typeof formData, value: string) => { @@ -298,7 +331,12 @@ export const SetActionForm: React.FC = ({ ({ id: 'memory-id', name: 'memory', - entityStatus: EntityStatus.Approved, + entityStatus: ContextMemoryStatus.Approved, shareConfig: { visibility }, derivedEntities: [], } as unknown as ContextMemory); @@ -81,10 +81,10 @@ describe('canProposeFromMemory', () => { it('blocks proposals from memories outside Approved', () => { for (const status of [ - EntityStatus.Draft, - EntityStatus.Archived, - EntityStatus.Deprecated, - EntityStatus.Rejected, + ContextMemoryStatus.Draft, + ContextMemoryStatus.Archived, + ContextMemoryStatus.Deprecated, + ContextMemoryStatus.Rejected, ]) { const retired = { ...memory(ShareVisibility.Public), diff --git a/openmetadata-ui/src/main/resources/ui/src/components/discovery/context-center/MemoryDerivedOntology/MemoryDerivedOntology.utils.ts b/openmetadata-ui/src/main/resources/ui/src/components/discovery/context-center/MemoryDerivedOntology/MemoryDerivedOntology.utils.ts index ac8ca6a3ab54..cb55961f2898 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/discovery/context-center/MemoryDerivedOntology/MemoryDerivedOntology.utils.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/discovery/context-center/MemoryDerivedOntology/MemoryDerivedOntology.utils.ts @@ -20,8 +20,8 @@ import { } from '../../../../generated/api/data/ontologyMemoryProposalStatus'; import { ContextMemory, + ContextMemoryStatus, EntityReference, - EntityStatus, ShareVisibility, } from '../../../../generated/entity/context/contextMemory'; import { getEntityName } from '../../../../utils/EntityNameUtils'; @@ -47,7 +47,8 @@ const hasOpenWork = (status: OntologyMemoryProposalStatus): boolean => const isProposable = (memory: ContextMemory): boolean => getDerivedTerms(memory).length === 0 && - (!memory.entityStatus || memory.entityStatus === EntityStatus.Approved); + (!memory.entityStatus || + memory.entityStatus === ContextMemoryStatus.Approved); const isIdle = (status: OntologyMemoryProposalStatus | undefined): boolean => status !== undefined && status.enabled && !hasOpenWork(status); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/platform/ai-shell/Sidebar/useContextCenterBadges.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/platform/ai-shell/Sidebar/useContextCenterBadges.test.tsx index b748ac8b2f45..1999b3f84c8d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/platform/ai-shell/Sidebar/useContextCenterBadges.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/platform/ai-shell/Sidebar/useContextCenterBadges.test.tsx @@ -14,7 +14,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { renderHook, waitFor } from '@testing-library/react'; import { ReactNode } from 'react'; -import { EntityStatus } from '../../../../generated/entity/context/contextMemory'; +import { ContextMemoryStatus } from '../../../../generated/entity/context/contextMemory'; import { getListContextMemories } from '../../../../rest/contextMemoryAPI'; import { useContextCenterBadges } from './useContextCenterBadges'; @@ -53,7 +53,10 @@ describe('useContextCenterBadges', () => { expect(getListContextMemories).toHaveBeenCalledWith({ limit: 0, - statuses: [EntityStatus.Approved, EntityStatus.Unprocessed].join(','), + statuses: [ + ContextMemoryStatus.Approved, + ContextMemoryStatus.Unprocessed, + ].join(','), }); }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/constants/ContextCenter.constants.ts b/openmetadata-ui/src/main/resources/ui/src/constants/ContextCenter.constants.ts index a2f5c45c0ee4..133c104f645c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/constants/ContextCenter.constants.ts +++ b/openmetadata-ui/src/main/resources/ui/src/constants/ContextCenter.constants.ts @@ -14,7 +14,7 @@ import { EntityFields } from '../enums/AdvancedSearch.enum'; import { - EntityStatus, + ContextMemoryStatus, MemoryType, ShareVisibility, } from '../generated/entity/context/contextMemory'; @@ -138,17 +138,19 @@ export const MEMORY_FIELDS = 'owners,tags,domains,primaryEntity,relatedEntities,derivedEntities,sourceEntity'; export const DEFAULT_MEMORY_STATUSES = [ - EntityStatus.Approved, - EntityStatus.Unprocessed, + ContextMemoryStatus.Approved, + ContextMemoryStatus.Unprocessed, ]; export const MEMORY_STATUS_LABEL_KEYS: Record = { - [EntityStatus.Unprocessed]: 'label.unprocessed', - [EntityStatus.Approved]: 'label.approved', - [EntityStatus.Archived]: 'label.archived', - [EntityStatus.Draft]: 'label.draft', - [EntityStatus.Deprecated]: 'label.deprecated', - [EntityStatus.Rejected]: 'label.rejected', + [ContextMemoryStatus.Unprocessed]: 'label.unprocessed', + [ContextMemoryStatus.Approved]: 'label.approved', + [ContextMemoryStatus.Archived]: 'label.archived', + [ContextMemoryStatus.Draft]: 'label.draft', + [ContextMemoryStatus.Deprecated]: 'label.deprecated', + [ContextMemoryStatus.Rejected]: 'label.rejected', + [ContextMemoryStatus.Superseded]: 'label.superseded', + [ContextMemoryStatus.Invalidated]: 'label.invalidated', }; export const FILTER_TABS = [ diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/context/createContextMemory.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/context/createContextMemory.ts index f6569c140c55..2edbe14ed6bb 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/context/createContextMemory.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/context/createContextMemory.ts @@ -32,9 +32,10 @@ export interface CreateContextMemory { domains?: string[]; /** * Lifecycle stage the memory starts in. When omitted, the memory starts Unprocessed and is - * excluded from grounding until Approved. A Deprecated memory requires supersededBy. + * excluded from grounding until Approved. Superseded and legacy Deprecated memories require + * supersededBy. */ - entityStatus?: EntityStatus; + entityStatus?: ContextMemoryStatus; machineRepresentation?: MachineRepresentation; memoryScope?: MemoryScope; memoryType?: MemoryType; @@ -83,19 +84,21 @@ export interface CreateContextMemory { /** * Lifecycle stage the memory starts in. When omitted, the memory starts Unprocessed and is - * excluded from grounding until Approved. A Deprecated memory requires supersededBy. + * excluded from grounding until Approved. Superseded and legacy Deprecated memories require + * supersededBy. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * Lifecycle stage of a context memory. Unprocessed awaits reconciliation; only Approved + * memories ground new memories and agent responses. Deprecated and Rejected remain readable + * legacy retirement stages. */ -export enum EntityStatus { +export enum ContextMemoryStatus { Approved = "Approved", Archived = "Archived", Deprecated = "Deprecated", Draft = "Draft", - InReview = "In Review", + Invalidated = "Invalidated", Rejected = "Rejected", + Superseded = "Superseded", Unprocessed = "Unprocessed", } diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createDataContract.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createDataContract.ts index 270c5b8b9be5..2cb8de7f4674 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createDataContract.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createDataContract.ts @@ -149,9 +149,10 @@ export interface EntityReference { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createOntologyAxiom.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createOntologyAxiom.ts index 807b56062983..921b130156b8 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createOntologyAxiom.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createOntologyAxiom.ts @@ -46,9 +46,10 @@ export enum AxiomType { /** * Lifecycle stage of the axiom. When omitted, the axiom starts in Draft. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createOntologyChangeSet.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createOntologyChangeSet.ts index 46daa0e33b9d..5401f6071705 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createOntologyChangeSet.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createOntologyChangeSet.ts @@ -307,9 +307,10 @@ export interface FieldChange { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. * * Status of the Glossary. * diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createPage.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createPage.ts index 104c42b4fe54..d078a3f54894 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createPage.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createPage.ts @@ -67,9 +67,10 @@ export interface CreatePage { /** * Lifecycle stage of this Knowledge Page. When omitted, the page starts in Draft. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createRelationshipType.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createRelationshipType.ts index c377c21edd93..6ad2014d95ae 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createRelationshipType.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/createRelationshipType.ts @@ -133,9 +133,10 @@ export interface EntityReference { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/glossaryTermRelationGraph.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/glossaryTermRelationGraph.ts index ed917280367b..18551f00f85e 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/glossaryTermRelationGraph.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/glossaryTermRelationGraph.ts @@ -132,9 +132,10 @@ export interface EntityReference { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/glossaryTermRelationGraphEdge.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/glossaryTermRelationGraphEdge.ts index 828137f0468b..12442245d222 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/glossaryTermRelationGraphEdge.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/glossaryTermRelationGraphEdge.ts @@ -102,9 +102,10 @@ export interface EntityReference { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/metricHierarchyContext.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/metricHierarchyContext.ts index 31ddfc2fc742..dd31e010ac4d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/metricHierarchyContext.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/metricHierarchyContext.ts @@ -616,9 +616,10 @@ export enum Type { /** * Status of the Metric. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. * * Status of the Metric Group. */ diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/metricHierarchyItem.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/metricHierarchyItem.ts index e3d795d88c7a..cc007ab3ad17 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/metricHierarchyItem.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/metricHierarchyItem.ts @@ -484,9 +484,10 @@ export interface EntityReference { /** * Status of the Metric Group. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. * * Status of the Metric. */ diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyDataGraph.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyDataGraph.ts index 585823f7363e..1c9a868b73dd 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyDataGraph.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyDataGraph.ts @@ -175,9 +175,10 @@ export enum Provenance { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyDomainDraftResult.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyDomainDraftResult.ts index 6c1f033a7711..127b44572a75 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyDomainDraftResult.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyDomainDraftResult.ts @@ -316,9 +316,10 @@ export interface FieldChange { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. * * Status of the Glossary. * diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyImpactReport.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyImpactReport.ts index c17b58e499e7..e7b955f57fe8 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyImpactReport.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyImpactReport.ts @@ -215,9 +215,10 @@ export enum Provenance { /** * Approval status of this relation edge. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyMappingSuggestion.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyMappingSuggestion.ts index 49a649b1c9bf..202bde4de7d7 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyMappingSuggestion.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyMappingSuggestion.ts @@ -300,9 +300,10 @@ export interface FieldChange { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. * * Status of the Glossary. * diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyMappingSuggestionList.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyMappingSuggestionList.ts index e98b2e520960..7dc029d36c25 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyMappingSuggestionList.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyMappingSuggestionList.ts @@ -309,9 +309,10 @@ export interface FieldChange { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. * * Status of the Glossary. * diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyPatternInstantiationResult.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyPatternInstantiationResult.ts index bb14eee73e72..985f6c1442e9 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyPatternInstantiationResult.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyPatternInstantiationResult.ts @@ -103,9 +103,10 @@ export enum Provenance { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyRelationshipSuggestion.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyRelationshipSuggestion.ts index e389ccdcb048..0123e2bc4a4d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyRelationshipSuggestion.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyRelationshipSuggestion.ts @@ -299,9 +299,10 @@ export interface FieldChange { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. * * Status of the Glossary. * diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyRelationshipSuggestionList.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyRelationshipSuggestionList.ts index 4c9bf0859108..95c56d23e33b 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyRelationshipSuggestionList.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyRelationshipSuggestionList.ts @@ -308,9 +308,10 @@ export interface FieldChange { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. * * Status of the Glossary. * diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyStructuralDiff.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyStructuralDiff.ts index 29ac8caf5f48..20cf80b884f1 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyStructuralDiff.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyStructuralDiff.ts @@ -198,9 +198,10 @@ export enum ConceptMappingType { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyStructuralMergeResult.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyStructuralMergeResult.ts index 0725918c4bc7..c97cdd5df483 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyStructuralMergeResult.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologyStructuralMergeResult.ts @@ -119,9 +119,10 @@ export enum Provenance { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologySubsetResult.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologySubsetResult.ts index 945e71061554..a1b0c6e21783 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologySubsetResult.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/ontologySubsetResult.ts @@ -102,9 +102,10 @@ export enum Provenance { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/updateOntologyChangeSet.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/updateOntologyChangeSet.ts index be1f0e3d97b2..f0b48b0fc99c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/data/updateOntologyChangeSet.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/data/updateOntologyChangeSet.ts @@ -306,9 +306,10 @@ export interface FieldChange { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. * * Status of the Glossary. * diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/governance/entityLifecycleStages.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/governance/entityLifecycleStages.ts index a9c65a5cc939..79d97f591b2f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/governance/entityLifecycleStages.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/governance/entityLifecycleStages.ts @@ -25,7 +25,7 @@ export interface EntityLifecycleStages { * Every lifecycle stage an entity can be in. Each entity type uses the stages its own entry * lists. */ - stages: EntityStatus[]; + stages: string[]; } /** @@ -41,7 +41,7 @@ export interface EntityTypeLifecycle { * lifecycle of its own uses the stages it declares, which can include stages no other type * has. */ - stages: EntityStatus[]; + stages: string[]; /** * Active governance workflows that own this entity type's lifecycle stage. While one of * them applies to an entity, its stage changes only through that workflow and a direct @@ -54,23 +54,6 @@ export interface EntityTypeLifecycle { transitions: StageTransition[]; } -/** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. - * - * Stage the entity is in. - */ -export enum EntityStatus { - Approved = "Approved", - Archived = "Archived", - Deprecated = "Deprecated", - Draft = "Draft", - InReview = "In Review", - Rejected = "Rejected", - Unprocessed = "Unprocessed", -} - /** * The stages an entity can move to from one stage. */ @@ -78,9 +61,9 @@ export interface StageTransition { /** * Stage the entity is in. */ - from: EntityStatus; + from: string; /** * Stages the entity can move to from it. */ - to: EntityStatus[]; + to: string[]; } diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/ai/aiApplication.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/ai/aiApplication.ts index 7d641bbe86e7..b22d8857b2b5 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/ai/aiApplication.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/ai/aiApplication.ts @@ -622,9 +622,10 @@ export enum DevelopmentStage { /** * Governance approval status of the AI Application. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/ai/llmModel.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/ai/llmModel.ts index 69829979ccd8..180f79453ce1 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/ai/llmModel.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/ai/llmModel.ts @@ -660,9 +660,10 @@ export enum Source { /** * Governance approval status of the LLM Model. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/ai/mcpServer.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/ai/mcpServer.ts index 331c5153ca2a..689d0745eeef 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/ai/mcpServer.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/ai/mcpServer.ts @@ -649,9 +649,10 @@ export enum DevelopmentStage { /** * Governance approval status of the MCP Server. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/classification/classification.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/classification/classification.ts index 6bf8d2d4a84a..bc120409081a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/classification/classification.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/classification/classification.ts @@ -267,9 +267,10 @@ export interface EntityReference { /** * Status of the tag. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/classification/tag.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/classification/tag.ts index 6e3dc5b50e90..d7598c68b9f2 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/classification/tag.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/classification/tag.ts @@ -276,9 +276,10 @@ export interface EntityReference { /** * Status of the tag. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/context/contextMemory.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/context/contextMemory.ts index b08dd890c262..bd648de2fd83 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/context/contextMemory.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/context/contextMemory.ts @@ -49,11 +49,12 @@ export interface ContextMemory { domains?: EntityReference[]; /** * Lifecycle stage of the memory: Unprocessed (awaiting reconciliation), Draft, Approved (in - * use), Deprecated (replaced), Rejected (invalidated) or Archived. A Deprecated memory - * requires supersededBy. When omitted at creation, the memory starts Unprocessed. Only + * use), Superseded (replaced), Invalidated (found incorrect) or Archived. Deprecated and + * Rejected remain supported legacy retirement stages. Superseded and Deprecated memories + * require supersededBy. When omitted at creation, the memory starts Unprocessed. Only * Approved memories ground new memories and agent responses. */ - entityStatus?: EntityStatus; + entityStatus?: ContextMemoryStatus; /** * Fully qualified name of the memory. */ @@ -151,7 +152,8 @@ export interface ContextMemory { */ summary?: string; /** - * The memory that replaced this one. Set if and only if entityStatus is Deprecated. + * The memory that replaced this one. Set if and only if entityStatus is Superseded or the + * legacy Deprecated stage. */ supersededBy?: EntityReference; /** @@ -275,7 +277,8 @@ export interface FieldChange { * * Deprecated: use sourceEntity. The Context Center file this memory was extracted from. * - * The memory that replaced this one. Set if and only if entityStatus is Deprecated. + * The memory that replaced this one. Set if and only if entityStatus is Superseded or the + * legacy Deprecated stage. */ export interface EntityReference { /** @@ -340,21 +343,23 @@ export interface MemoryDispute { /** * Lifecycle stage of the memory: Unprocessed (awaiting reconciliation), Draft, Approved (in - * use), Deprecated (replaced), Rejected (invalidated) or Archived. A Deprecated memory - * requires supersededBy. When omitted at creation, the memory starts Unprocessed. Only + * use), Superseded (replaced), Invalidated (found incorrect) or Archived. Deprecated and + * Rejected remain supported legacy retirement stages. Superseded and Deprecated memories + * require supersededBy. When omitted at creation, the memory starts Unprocessed. Only * Approved memories ground new memories and agent responses. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * Lifecycle stage of a context memory. Unprocessed awaits reconciliation; only Approved + * memories ground new memories and agent responses. Deprecated and Rejected remain readable + * legacy retirement stages. */ -export enum EntityStatus { +export enum ContextMemoryStatus { Approved = "Approved", Archived = "Archived", Deprecated = "Deprecated", Draft = "Draft", - InReview = "In Review", + Invalidated = "Invalidated", Rejected = "Rejected", + Superseded = "Superseded", Unprocessed = "Unprocessed", } diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/context/contextMemoryStatus.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/context/contextMemoryStatus.ts new file mode 100644 index 000000000000..5b36db25819b --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/context/contextMemoryStatus.ts @@ -0,0 +1,27 @@ +/* + * Copyright 2026 Collate. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Lifecycle stage of a context memory. Unprocessed awaits reconciliation; only Approved + * memories ground new memories and agent responses. Deprecated and Rejected remain readable + * legacy retirement stages. + */ +export enum ContextMemoryStatus { + Approved = "Approved", + Archived = "Archived", + Deprecated = "Deprecated", + Draft = "Draft", + Invalidated = "Invalidated", + Rejected = "Rejected", + Superseded = "Superseded", + Unprocessed = "Unprocessed", +} diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/apiCollection.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/apiCollection.ts index 1a1602d3166b..e6a8c5510f78 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/apiCollection.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/apiCollection.ts @@ -475,9 +475,10 @@ export interface FieldChange { /** * Status of the API Collection. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/apiEndpoint.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/apiEndpoint.ts index 3db28904538b..155763866ada 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/apiEndpoint.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/apiEndpoint.ts @@ -492,9 +492,10 @@ export interface FieldChange { /** * Status of the APIEndpoint. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/chart.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/chart.ts index 127e5b0d348a..ce0f9b5343ce 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/chart.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/chart.ts @@ -513,9 +513,10 @@ export interface EntityReference { /** * Status of the Chart. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/container.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/container.ts index 75537b07da1c..cde6350b44cc 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/container.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/container.ts @@ -947,9 +947,10 @@ export interface HistogramClass { /** * Status of the Container. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/dashboard.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/dashboard.ts index c560d52ee682..9585edfbc4c8 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/dashboard.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/dashboard.ts @@ -509,9 +509,10 @@ export enum DashboardType { /** * Status of the Dashboard. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/dashboardDataModel.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/dashboardDataModel.ts index aa5a34a00121..6103f909ee0e 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/dashboardDataModel.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/dashboardDataModel.ts @@ -924,9 +924,10 @@ export enum DataModelType { /** * Status of the DashboardDataModel. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/dataContract.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/dataContract.ts index 6f98ac5ac3a7..fd522535d575 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/dataContract.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/dataContract.ts @@ -315,9 +315,10 @@ export interface EntityReference { /** * Approval status of the data contract. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/database.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/database.ts index 6f1a9cdab750..ab7322c696e4 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/database.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/database.ts @@ -687,9 +687,10 @@ export interface AwsCredentials { /** * Status of the Database. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/databaseSchema.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/databaseSchema.ts index 8e62798150be..24138177b091 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/databaseSchema.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/databaseSchema.ts @@ -683,9 +683,10 @@ export interface AwsCredentials { /** * Status of the DatabaseSchema. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/directory.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/directory.ts index 867b100d6bf9..b8df93b35fd7 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/directory.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/directory.ts @@ -520,9 +520,10 @@ export enum DirectoryType { /** * Status of the Directory. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/file.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/file.ts index fb295ee88aec..0a9532c209ba 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/file.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/file.ts @@ -942,9 +942,10 @@ export interface HistogramClass { /** * Status of the File. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/glossary.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/glossary.ts index f79b97dc3f60..a4f8ad5d998f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/glossary.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/glossary.ts @@ -260,9 +260,10 @@ export interface EntityReference { /** * Status of the Glossary. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/glossaryTerm.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/glossaryTerm.ts index 30bdbe9a126c..e73ad57de72a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/glossaryTerm.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/glossaryTerm.ts @@ -445,9 +445,10 @@ export enum OntologyConceptType { /** * Approval status of the glossary term. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. * * Approval status of this relation edge. */ diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/metric.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/metric.ts index 57b3f4b17313..513ac018c95c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/metric.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/metric.ts @@ -580,9 +580,10 @@ export enum Type { /** * Status of the Metric. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/metricGroup.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/metricGroup.ts index 0575cc6e96ba..2dec6d15ad32 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/metricGroup.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/metricGroup.ts @@ -455,9 +455,10 @@ export interface EntityReference { /** * Status of the Metric Group. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/mlmodel.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/mlmodel.ts index 45e106fdc6ed..f28eda3ef0ce 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/mlmodel.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/mlmodel.ts @@ -519,9 +519,10 @@ export interface EntityReference { /** * Status of the MlModel. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/ontologyAxiom.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/ontologyAxiom.ts index 8beba041fead..2a62c9a0c059 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/ontologyAxiom.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/ontologyAxiom.ts @@ -121,9 +121,10 @@ export interface FieldChange { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/ontologyChangeSet.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/ontologyChangeSet.ts index aaa31f047e0c..9be7d507ba1c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/ontologyChangeSet.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/ontologyChangeSet.ts @@ -356,9 +356,10 @@ export enum AxiomType { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. * * Status of the Glossary. * diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/page.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/page.ts index b0d7e1a3d066..bf5ce9279360 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/page.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/page.ts @@ -617,9 +617,10 @@ export interface EntityReference { /** * Lifecycle stage of the page. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/pipeline.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/pipeline.ts index 28553447618b..f04b67a142b7 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/pipeline.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/pipeline.ts @@ -522,9 +522,10 @@ export interface EntityReference { /** * Status of the Pipeline. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/query.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/query.ts index 7ce8f624dd66..657a7bf45695 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/query.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/query.ts @@ -276,9 +276,10 @@ export interface EntityReference { /** * Status of the Query. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/relationshipType.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/relationshipType.ts index 1615a4b6c1d6..b28b84acf53e 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/relationshipType.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/relationshipType.ts @@ -233,9 +233,10 @@ export interface SemanticReference { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/report.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/report.ts index 444c9188c675..f815a70b3652 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/report.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/report.ts @@ -223,9 +223,10 @@ export interface EntityReference { /** * Status of the Report. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/searchIndex.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/searchIndex.ts index 231f3b8ed25a..68aefb626bb0 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/searchIndex.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/searchIndex.ts @@ -486,9 +486,10 @@ export interface EntityReference { /** * Status of the SearchIndex. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/spreadsheet.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/spreadsheet.ts index fc75123a9d88..0fc19c3be127 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/spreadsheet.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/spreadsheet.ts @@ -522,9 +522,10 @@ export interface EntityReference { /** * Status of the Spreadsheet. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/storedProcedure.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/storedProcedure.ts index b4750a63c70a..b12aae9a0d49 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/storedProcedure.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/storedProcedure.ts @@ -501,9 +501,10 @@ export interface EntityReference { /** * Status of the StoredProcedure. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/table.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/table.ts index 1e26c8181ecd..3e7ef0ba6735 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/table.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/table.ts @@ -1095,9 +1095,10 @@ export enum ModelType { /** * Status of the Table. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/topic.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/topic.ts index 0a431c12030e..9ead32a90b02 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/topic.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/topic.ts @@ -530,9 +530,10 @@ export interface EntityReference { /** * Status of the Topic. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/worksheet.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/worksheet.ts index f7d5e6b02800..c250661dd242 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/worksheet.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/data/worksheet.ts @@ -911,9 +911,10 @@ export interface HistogramClass { /** * Status of the Worksheet. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/domains/dataProduct.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/domains/dataProduct.ts index 2ed6477bb1f0..d7c714f4d726 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/domains/dataProduct.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/domains/dataProduct.ts @@ -499,9 +499,10 @@ export enum DataProductType { /** * Status of the Data Product. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/domains/domain.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/domains/domain.ts index 0bf741e820a9..66c46ab8f9d2 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/domains/domain.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/domains/domain.ts @@ -468,9 +468,10 @@ export enum DomainType { /** * Status of the entity. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/apiService.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/apiService.ts index f36a41cbc28a..45e1f39a251a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/apiService.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/apiService.ts @@ -434,9 +434,10 @@ export interface EntityReference { /** * Status of the entity. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/dashboardService.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/dashboardService.ts index df81a8d5631e..28f09d8357af 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/dashboardService.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/dashboardService.ts @@ -1639,9 +1639,10 @@ export interface EntityReference { /** * Status of the entity. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/databaseService.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/databaseService.ts index f43e1df09614..ee1c428a3876 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/databaseService.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/databaseService.ts @@ -2705,9 +2705,10 @@ export interface EntityReference { /** * Status of the entity. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/messagingService.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/messagingService.ts index 8b7eac80fd33..66415cd8506d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/messagingService.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/messagingService.ts @@ -699,9 +699,10 @@ export interface EntityReference { /** * Status of the entity. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/metadataService.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/metadataService.ts index 2f2ad72029ac..4a4cdcc9c40a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/metadataService.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/metadataService.ts @@ -1193,9 +1193,10 @@ export interface EntityReference { /** * Status of the entity. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/mlmodelService.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/mlmodelService.ts index 9e72df279751..9145ec4374c9 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/mlmodelService.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/mlmodelService.ts @@ -512,9 +512,10 @@ export interface EntityReference { /** * Status of the entity. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/pipelineService.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/pipelineService.ts index 53c0b9d042d0..46aef5761cb3 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/pipelineService.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/pipelineService.ts @@ -1894,9 +1894,10 @@ export interface EntityReference { /** * Status of the entity. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/searchService.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/searchService.ts index c588666abdc7..21a237d78402 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/searchService.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/searchService.ts @@ -471,9 +471,10 @@ export interface EntityReference { /** * Status of the entity. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/storageService.ts b/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/storageService.ts index bbc5db797f21..eb7a9faf570a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/storageService.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/entity/services/storageService.ts @@ -544,9 +544,10 @@ export interface EntityReference { /** * Status of the entity. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/governance/workflows/elements/nodes/automatedTask/setGlossaryTermStatusTask.ts b/openmetadata-ui/src/main/resources/ui/src/generated/governance/workflows/elements/nodes/automatedTask/setGlossaryTermStatusTask.ts index 8de429f2cb7c..3c8c73d09257 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/governance/workflows/elements/nodes/automatedTask/setGlossaryTermStatusTask.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/governance/workflows/elements/nodes/automatedTask/setGlossaryTermStatusTask.ts @@ -44,9 +44,10 @@ export interface NodeConfiguration { /** * Choose which Status to apply to the Glossary Term * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/tests/testCase.ts b/openmetadata-ui/src/main/resources/ui/src/generated/tests/testCase.ts index 5a1ce9644f84..c9b4e008e79c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/tests/testCase.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/tests/testCase.ts @@ -330,9 +330,10 @@ export interface EntityReference { /** * Current status of the test case. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/type/ontologyChangeOperation.ts b/openmetadata-ui/src/main/resources/ui/src/generated/type/ontologyChangeOperation.ts index 3fde5968042f..16fbcd8a6556 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/type/ontologyChangeOperation.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/type/ontologyChangeOperation.ts @@ -289,9 +289,10 @@ export interface FieldChange { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. * * Status of the Glossary. * diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/type/ontologyRelationship.ts b/openmetadata-ui/src/main/resources/ui/src/generated/type/ontologyRelationship.ts index 2799883faf2b..a5cd9123566f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/type/ontologyRelationship.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/type/ontologyRelationship.ts @@ -87,9 +87,10 @@ export enum Provenance { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/type/ontologySourceProvenance.ts b/openmetadata-ui/src/main/resources/ui/src/generated/type/ontologySourceProvenance.ts index dd146e291feb..f94bf1f6cd49 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/type/ontologySourceProvenance.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/type/ontologySourceProvenance.ts @@ -200,9 +200,10 @@ export enum ConceptMappingType { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/type/ontologyTermStructure.ts b/openmetadata-ui/src/main/resources/ui/src/generated/type/ontologyTermStructure.ts index 403cadb85ef1..36f0cb353269 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/type/ontologyTermStructure.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/type/ontologyTermStructure.ts @@ -173,9 +173,10 @@ export enum ConceptMappingType { } /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/type/status.ts b/openmetadata-ui/src/main/resources/ui/src/generated/type/status.ts index 73af7cf86a62..4257189e96fa 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/type/status.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/type/status.ts @@ -11,9 +11,10 @@ * limitations under the License. */ /** - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum Status { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/type/termRelation.ts b/openmetadata-ui/src/main/resources/ui/src/generated/type/termRelation.ts index fd8fb6397c1b..46c2542dae49 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/type/termRelation.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/type/termRelation.ts @@ -118,9 +118,10 @@ export interface EntityReference { /** * Approval status of this relation edge. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/type/termRelationMetadata.ts b/openmetadata-ui/src/main/resources/ui/src/generated/type/termRelationMetadata.ts index f1790f792a27..233767e614c6 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/type/termRelationMetadata.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/type/termRelationMetadata.ts @@ -61,9 +61,10 @@ export enum Provenance { /** * Approval status of this relation edge. * - * Lifecycle stage of an entity, shared by every entity type that declares an `entityStatus` - * property. Entity types without that property have no lifecycle. When a create request - * omits the stage, the server assigns the entity type's initial stage. + * General lifecycle stage for entities that reference this vocabulary. Specialized entities + * can declare their own status schema and lifecycle policy. Entity types without an + * entityStatus property have no lifecycle. When a create request omits the stage, the + * server assigns the entity type's initial stage. */ export enum EntityStatus { Approved = "Approved", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/ar-sa.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/ar-sa.json index d64c32a13553..a4a09b925b49 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/ar-sa.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/ar-sa.json @@ -1577,6 +1577,7 @@ "invalid-condition": "شرط غير صالح", "invalid-name": "اسم غير صالح", "invalid-url": "رابط غير صالح", + "invalidated": "تم إبطاله", "inverse": "عكسي", "inverse-functional": "وظيفي عكسي", "inverse-relation": "علاقة عكسية", @@ -3110,6 +3111,7 @@ "sum": "المجموع", "summary": "ملخص", "sunday": "الأحد", + "superseded": "تم استبداله", "superseded-by": "استُبدلت بـ", "support": "دعم", "support-url": "رابط الدعم", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/de-de.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/de-de.json index 7f0e48e15970..2a586b0f102d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/de-de.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/de-de.json @@ -1577,6 +1577,7 @@ "invalid-condition": "Ungültige Bedingung", "invalid-name": "Ungültiger Name", "invalid-url": "Ungültige URL", + "invalidated": "Für ungültig erklärt", "inverse": "Umgekehrt", "inverse-functional": "Invers funktional", "inverse-relation": "Umgekehrte Beziehung", @@ -3110,6 +3111,7 @@ "sum": "Summe", "summary": "Zusammenfassung", "sunday": "Sonntag", + "superseded": "Ersetzt", "superseded-by": "Ersetzt durch", "support": "Unterstützung", "support-url": "Support-URL", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json index 3010c9a3d1f6..2af8b4369f73 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json @@ -1577,6 +1577,7 @@ "invalid-condition": "Invalid condition", "invalid-name": "Invalid Name", "invalid-url": "Invalid URL", + "invalidated": "Invalidated", "inverse": "Inverse", "inverse-functional": "Inverse Functional", "inverse-relation": "Inverse Relation", @@ -3110,6 +3111,7 @@ "sum": "Sum", "summary": "Summary", "sunday": "Sunday", + "superseded": "Superseded", "superseded-by": "Superseded by", "support": "Support", "support-url": "Support URL", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/es-es.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/es-es.json index 770f078acd39..56943d04c860 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/es-es.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/es-es.json @@ -1577,6 +1577,7 @@ "invalid-condition": "Condición inválida", "invalid-name": "Nombre inválido", "invalid-url": "URL inválida", + "invalidated": "Invalidado", "inverse": "Inverso", "inverse-functional": "Funcional inversa", "inverse-relation": "Relación inversa", @@ -3110,6 +3111,7 @@ "sum": "Suma", "summary": "Resumen", "sunday": "Domingo", + "superseded": "Sustituido", "superseded-by": "Sustituida por", "support": "Soporte", "support-url": "URL de soporte", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json index db004e07d057..a69510713d47 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json @@ -1577,6 +1577,7 @@ "invalid-condition": "Condition Invalide", "invalid-name": "Nom Invalide", "invalid-url": "URL invalide", + "invalidated": "Invalidé", "inverse": "Inverse", "inverse-functional": "Fonctionnelle inverse", "inverse-relation": "Relation inverse", @@ -3110,6 +3111,7 @@ "sum": "Somme", "summary": "Résumé", "sunday": "Dimanche", + "superseded": "Remplacé", "superseded-by": "Remplacée par", "support": "Soutien", "support-url": "URL de Support", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/gl-es.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/gl-es.json index 15886843b5b0..d6b926eac773 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/gl-es.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/gl-es.json @@ -1577,6 +1577,7 @@ "invalid-condition": "Condición non válida", "invalid-name": "Nome non válido", "invalid-url": "URL non válida", + "invalidated": "Invalidado", "inverse": "Inverso", "inverse-functional": "Funcional inversa", "inverse-relation": "Relación inversa", @@ -3110,6 +3111,7 @@ "sum": "Suma", "summary": "Resumo", "sunday": "Domingo", + "superseded": "Substituído", "superseded-by": "Substituída por", "support": "Soporte", "support-url": "URL de soporte", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/he-he.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/he-he.json index d172bc099dc8..af9728290f08 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/he-he.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/he-he.json @@ -1577,6 +1577,7 @@ "invalid-condition": "תנאי לא תקין", "invalid-name": "שם לא תקין", "invalid-url": "כתובת URL לא תקינה", + "invalidated": "נפסל", "inverse": "הפוך", "inverse-functional": "פונקציונלי הפוך", "inverse-relation": "יחס הפוך", @@ -3110,6 +3111,7 @@ "sum": "סכום", "summary": "סיכום", "sunday": "ראשון", + "superseded": "הוחלף", "superseded-by": "הוחלף על ידי", "support": "תמיכה", "support-url": "כתובת תמיכה", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json index 2344c90833ec..945ab7f3ed61 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json @@ -1577,6 +1577,7 @@ "invalid-condition": "無効な条件", "invalid-name": "無効な名前", "invalid-url": "無効なURL", + "invalidated": "無効化済み", "inverse": "逆", "inverse-functional": "逆関数的", "inverse-relation": "逆関係", @@ -3110,6 +3111,7 @@ "sum": "合計", "summary": "サマリー", "sunday": "日曜日", + "superseded": "置き換え済み", "superseded-by": "置き換え先", "support": "サポート", "support-url": "サポート URL", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/ko-kr.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/ko-kr.json index 9d0873892862..32fe1858ca99 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/ko-kr.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/ko-kr.json @@ -1577,6 +1577,7 @@ "invalid-condition": "유효하지 않은 조건", "invalid-name": "유효하지 않은 이름", "invalid-url": "유효하지 않은 URL", + "invalidated": "무효화됨", "inverse": "역", "inverse-functional": "역함수형", "inverse-relation": "역관계", @@ -3110,6 +3111,7 @@ "sum": "합계", "summary": "요약", "sunday": "일요일", + "superseded": "대체됨", "superseded-by": "대체한 메모", "support": "지원", "support-url": "지원 URL", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/mr-in.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/mr-in.json index a2e6cb53a05b..50dc06dda7a3 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/mr-in.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/mr-in.json @@ -1577,6 +1577,7 @@ "invalid-condition": "अवैध अट", "invalid-name": "अवैध नाव", "invalid-url": "अवैध URL", + "invalidated": "अवैध ठरवलेले", "inverse": "उलट", "inverse-functional": "व्यस्त फलनीय", "inverse-relation": "उलट संबंध", @@ -3110,6 +3111,7 @@ "sum": "बेरीज", "summary": "सारांश", "sunday": "रविवार", + "superseded": "नवीनाने बदललेले", "superseded-by": "याने बदललेली", "support": "समर्थन", "support-url": "समर्थन URL", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/nl-nl.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/nl-nl.json index 588ca4385804..9153eac128ae 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/nl-nl.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/nl-nl.json @@ -1577,6 +1577,7 @@ "invalid-condition": "Ongeldige voorwaarde", "invalid-name": "Ongeldige naam", "invalid-url": "Ongeldige URL", + "invalidated": "Ongeldig verklaard", "inverse": "Invers", "inverse-functional": "Invers functioneel", "inverse-relation": "Inverse relatie", @@ -3110,6 +3111,7 @@ "sum": "Som", "summary": "Samenvatting", "sunday": "zondag", + "superseded": "Vervangen", "superseded-by": "Vervangen door", "support": "Ondersteuning", "support-url": "Ondersteunings-URL", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/pr-pr.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/pr-pr.json index c477c7f9b9f7..a9e3c9b38e0c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/pr-pr.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/pr-pr.json @@ -1577,6 +1577,7 @@ "invalid-condition": "شرط نامعتبر", "invalid-name": "نام نامعتبر", "invalid-url": "آدرس نامعتبر", + "invalidated": "نامعتبرشده", "inverse": "معکوس", "inverse-functional": "تابعی معکوس", "inverse-relation": "رابطه معکوس", @@ -3110,6 +3111,7 @@ "sum": "مجموع", "summary": "خلاصه", "sunday": "یکشنبه", + "superseded": "جایگزین‌شده", "superseded-by": "جایگزین‌شده با", "support": "پشتیبانی", "support-url": "آدرس پشتیبانی", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-br.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-br.json index 9606e1c57a53..d645aadce3bc 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-br.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-br.json @@ -1577,6 +1577,7 @@ "invalid-condition": "Condição Inválida", "invalid-name": "Nome Inválido", "invalid-url": "URL inválida", + "invalidated": "Invalidado", "inverse": "Inverso", "inverse-functional": "Funcional inversa", "inverse-relation": "Relação inversa", @@ -3110,6 +3111,7 @@ "sum": "Soma", "summary": "Resumo", "sunday": "Domingo", + "superseded": "Substituído", "superseded-by": "Substituída por", "support": "Suporte", "support-url": "URL de Suporte", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-pt.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-pt.json index 693d726ad829..80a1f00e820d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-pt.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-pt.json @@ -1577,6 +1577,7 @@ "invalid-condition": "Condição Inválida", "invalid-name": "Nome Inválido", "invalid-url": "URL inválido", + "invalidated": "Invalidado", "inverse": "Inverso", "inverse-functional": "Funcional inversa", "inverse-relation": "Relação inversa", @@ -3110,6 +3111,7 @@ "sum": "Soma", "summary": "Resumo", "sunday": "Domingo", + "superseded": "Substituído", "superseded-by": "Substituída por", "support": "Suporte", "support-url": "URL de Suporte", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/ru-ru.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/ru-ru.json index 84a5d799115a..3e4a7fec9054 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/ru-ru.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/ru-ru.json @@ -1577,6 +1577,7 @@ "invalid-condition": "Недопустимое условие", "invalid-name": "Неверное имя", "invalid-url": "Недействительный URL", + "invalidated": "Признано недействительным", "inverse": "Обратный", "inverse-functional": "Обратно-функциональное", "inverse-relation": "Обратная связь", @@ -3110,6 +3111,7 @@ "sum": "Сумма", "summary": "Сводка", "sunday": "Воскресенье", + "superseded": "Заменено", "superseded-by": "Заменена на", "support": "Поддержка", "support-url": "URL поддержки", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/sv-se.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/sv-se.json index af28762dae57..9a43e2b34bac 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/sv-se.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/sv-se.json @@ -1577,6 +1577,7 @@ "invalid-condition": "Ogiltigt villkor", "invalid-name": "Ogiltigt namn", "invalid-url": "Ogiltig URL", + "invalidated": "Ogiltigförklarad", "inverse": "Invers", "inverse-functional": "Invers funktionell", "inverse-relation": "Invers relation", @@ -3110,6 +3111,7 @@ "sum": "Summa", "summary": "Sammanfattning", "sunday": "Söndag", + "superseded": "Ersatt", "superseded-by": "Ersatt av", "support": "Support", "support-url": "Support-URL", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/th-th.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/th-th.json index 2cde43296ba0..6e2f5c5855df 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/th-th.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/th-th.json @@ -1577,6 +1577,7 @@ "invalid-condition": "เงื่อนไขไม่ถูกต้อง", "invalid-name": "ชื่อไม่ถูกต้อง", "invalid-url": "URL ไม่ถูกต้อง", + "invalidated": "ถูกระบุว่าไม่ถูกต้อง", "inverse": "ผกผัน", "inverse-functional": "ฟังก์ชันผกผัน", "inverse-relation": "ความสัมพันธ์ผกผัน", @@ -3110,6 +3111,7 @@ "sum": "ผลรวม", "summary": "สรุป", "sunday": "วันอาทิตย์", + "superseded": "ถูกแทนที่", "superseded-by": "ถูกแทนที่ด้วย", "support": "สนับสนุน", "support-url": "URL การสนับสนุน", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/tr-tr.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/tr-tr.json index f645f5807269..47a89def88d2 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/tr-tr.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/tr-tr.json @@ -1577,6 +1577,7 @@ "invalid-condition": "Geçersiz koşul", "invalid-name": "Geçersiz Ad", "invalid-url": "Geçersiz URL", + "invalidated": "Geçersiz kılındı", "inverse": "Ters", "inverse-functional": "Ters fonksiyonel", "inverse-relation": "Ters İlişki", @@ -3110,6 +3111,7 @@ "sum": "Toplam", "summary": "Özet", "sunday": "Pazar", + "superseded": "Yerine yenisi getirildi", "superseded-by": "Yerine geçen", "support": "Destek", "support-url": "Destek URL'si", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json index 90447b981a6e..844896c86856 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json @@ -1577,6 +1577,7 @@ "invalid-condition": "无效条件", "invalid-name": "无效名称", "invalid-url": "无效的URL", + "invalidated": "已失效", "inverse": "逆向", "inverse-functional": "逆函数型", "inverse-relation": "逆向关系", @@ -3110,6 +3111,7 @@ "sum": "总和", "summary": "概要", "sunday": "星期天", + "superseded": "已取代", "superseded-by": "取代它的记忆", "support": "支持", "support-url": "支持 URL", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-tw.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-tw.json index 87e828bfe958..bd267b6fe444 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-tw.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-tw.json @@ -1577,6 +1577,7 @@ "invalid-condition": "無效條件", "invalid-name": "無效名稱", "invalid-url": "無效的URL", + "invalidated": "已失效", "inverse": "逆向", "inverse-functional": "逆函數型", "inverse-relation": "逆向關係", @@ -3110,6 +3111,7 @@ "sum": "總和", "summary": "摘要", "sunday": "星期日", + "superseded": "已取代", "superseded-by": "取代它的記憶", "support": "支援", "support-url": "支援 URL", diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterMemoriesPage/ContextCenterMemoriesPage.test.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterMemoriesPage/ContextCenterMemoriesPage.test.tsx index 02a8ed6d0a32..2f2e8a85db59 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterMemoriesPage/ContextCenterMemoriesPage.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterMemoriesPage/ContextCenterMemoriesPage.test.tsx @@ -235,74 +235,84 @@ describe('ContextCenterMemoriesPage — permissions', () => { ); }); - it('filters by selected statuses while retaining author and sort controls', async () => { - mockGetResourcePermission.mockResolvedValue({ EditAll: true }); - renderPage(); - - await waitFor(() => { - expect(getListContextMemories).toHaveBeenCalledWith( - expect.objectContaining({ statuses: 'Approved,Unprocessed', offset: 0 }) - ); - }); - - fireEvent.click(screen.getByTestId('memory-status-filter')); - fireEvent.click(await screen.findByText('label.rejected')); - - await waitFor(() => { - expect(getListContextMemories).toHaveBeenCalledWith( - expect.objectContaining({ - statuses: 'Approved,Unprocessed,Rejected', - offset: 0, - }) - ); - expect(getListContextMemories).toHaveBeenCalledWith( - expect.objectContaining({ - statuses: 'Approved,Unprocessed,Rejected', - limit: 0, - offset: 0, - }) - ); - }); - - fireEvent.click(screen.getByTestId('memory-count-card-created-by-me')); - await waitFor(() => { - expect(getListContextMemories).toHaveBeenCalledWith( - expect.objectContaining({ - statuses: 'Approved,Unprocessed,Rejected', - author: 'user-1', - }) - ); - }); - - fireEvent.change(screen.getByTestId('memory-search'), { - target: { value: 'missing glossary fact' }, - }); - fireEvent.click(screen.getByTestId('mock-asset-select')); - await waitFor(() => { - expect(getListContextMemories).toHaveBeenCalledWith( - expect.objectContaining({ - statuses: 'Approved,Unprocessed,Rejected', - q: 'missing glossary fact', - assets: 'asset-1', - author: 'user-1', - }) - ); - }); - - fireEvent.click(screen.getByText(/label.sort/)); - fireEvent.click(await screen.findByText('label.most-used')); - await waitFor(() => { - expect(getListContextMemories).toHaveBeenCalledWith( - expect.objectContaining({ - statuses: 'Approved,Unprocessed,Rejected', - q: 'missing glossary fact', - assets: 'asset-1', - author: 'user-1', - sortBy: 'usageCount', - }) - ); - }); - }); + it.each([ + ['label.rejected', 'Rejected'], + ['label.superseded', 'Superseded'], + ['label.invalidated', 'Invalidated'], + ])( + 'filters by %s while retaining author and sort controls', + async (label, status) => { + mockGetResourcePermission.mockResolvedValue({ EditAll: true }); + renderPage(); + + await waitFor(() => { + expect(getListContextMemories).toHaveBeenCalledWith( + expect.objectContaining({ + statuses: 'Approved,Unprocessed', + offset: 0, + }) + ); + }); + + fireEvent.click(screen.getByTestId('memory-status-filter')); + fireEvent.click(await screen.findByText(label)); + + await waitFor(() => { + expect(getListContextMemories).toHaveBeenCalledWith( + expect.objectContaining({ + statuses: `Approved,Unprocessed,${status}`, + offset: 0, + }) + ); + expect(getListContextMemories).toHaveBeenCalledWith( + expect.objectContaining({ + statuses: `Approved,Unprocessed,${status}`, + limit: 0, + offset: 0, + }) + ); + }); + + fireEvent.click(screen.getByTestId('memory-count-card-created-by-me')); + await waitFor(() => { + expect(getListContextMemories).toHaveBeenCalledWith( + expect.objectContaining({ + statuses: `Approved,Unprocessed,${status}`, + author: 'user-1', + }) + ); + }); + + fireEvent.change(screen.getByTestId('memory-search'), { + target: { value: 'missing glossary fact' }, + }); + fireEvent.click(screen.getByTestId('mock-asset-select')); + await waitFor(() => { + expect(getListContextMemories).toHaveBeenCalledWith( + expect.objectContaining({ + statuses: `Approved,Unprocessed,${status}`, + q: 'missing glossary fact', + assets: 'asset-1', + author: 'user-1', + }) + ); + }); + + fireEvent.click(screen.getByText(/label.sort/)); + fireEvent.click(await screen.findByText('label.most-used')); + await waitFor(() => { + expect(getListContextMemories).toHaveBeenCalledWith( + expect.objectContaining({ + statuses: `Approved,Unprocessed,${status}`, + q: 'missing glossary fact', + assets: 'asset-1', + author: 'user-1', + sortBy: 'usageCount', + }) + ); + }); + } + ); it('combines the author dropdown with selected statuses', async () => { mockGetResourcePermission.mockResolvedValue({ EditAll: true }); diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterMemoriesPage/ContextCenterMemoriesPage.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterMemoriesPage/ContextCenterMemoriesPage.tsx index cac33655ea99..e702e658debd 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterMemoriesPage/ContextCenterMemoriesPage.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterMemoriesPage/ContextCenterMemoriesPage.tsx @@ -65,7 +65,7 @@ import { OperationPermission } from '../../../context/PermissionProvider/Permiss import { ResourceEntity } from '../../../enums/permissions.enum'; import { ContextMemory, - EntityStatus, + ContextMemoryStatus, } from '../../../generated/entity/context/contextMemory'; import { useApplicationStore } from '../../../hooks/useApplicationStore'; import { queryClient } from '../../../queryClient'; @@ -101,12 +101,10 @@ const getSortLabel = ( ): string => options.find((option) => option.id === sortBy)?.label ?? ''; const MEMORY_STATUSES = [ - EntityStatus.Approved, - EntityStatus.Unprocessed, - EntityStatus.Draft, - EntityStatus.Deprecated, - EntityStatus.Rejected, - EntityStatus.Archived, + ...DEFAULT_MEMORY_STATUSES, + ...Object.values(ContextMemoryStatus).filter( + (status) => !DEFAULT_MEMORY_STATUSES.includes(status) + ), ]; const CREATED_BY_ME_FILTER = 'created-by-me' as const; @@ -157,7 +155,7 @@ const getMemoriesViewFlags = ({ selectedAsset?: DataAssetOption; selectedAuthor?: MemoryFilterOption; activeFilter: MemoryFilterTab; - selectedStatuses: EntityStatus[]; + selectedStatuses: ContextMemoryStatus[]; debouncedSearch: string; isMemoriesLoading: boolean; memoriesLength: number; @@ -308,9 +306,9 @@ const ContextCenterMemoriesPage: FC = () => { const [isViewModalOpen, setIsViewModalOpen] = useState(false); const [searchValue, setSearchValue] = useState(''); const [activeFilter, setActiveFilter] = useState('all'); - const [selectedStatuses, setSelectedStatuses] = useState( - DEFAULT_MEMORY_STATUSES - ); + const [selectedStatuses, setSelectedStatuses] = useState< + ContextMemoryStatus[] + >(DEFAULT_MEMORY_STATUSES); const [currentPage, setCurrentPage] = useState(1); const [selectedAsset, setSelectedAsset] = useState(); const [selectedAuthor, setSelectedAuthor] = useState(); @@ -589,7 +587,7 @@ const ContextCenterMemoriesPage: FC = () => { setCurrentPage(1); }, []); - const handleStatusChange = useCallback((status: EntityStatus) => { + const handleStatusChange = useCallback((status: ContextMemoryStatus) => { setSelectedStatuses((current) => { if (current.includes(status)) { return current.length > 1 @@ -765,6 +763,10 @@ const ContextCenterMemoriesPage: FC = () => { entity: t('label.asset-plural'), }); const allAuthorsLabel = t('label.all-entity', { entity: t('label.author') }); + const selectedStatusLabelKey = MEMORY_STATUS_LABEL_KEYS[selectedStatuses[0]]; + const selectedStatusLabel = selectedStatusLabelKey + ? t(selectedStatusLabelKey) + : selectedStatuses[0]; const headerActions = (