From 513ad5488db9a519c0beda7a216de4b4359c0022 Mon Sep 17 00:00:00 2001 From: RyanHolstien Date: Thu, 5 Dec 2024 11:11:21 -0600 Subject: [PATCH] feat(entityVersioning): rename endpoint and update field name --- .../linkedin/datahub/graphql/GmsGraphQLEngine.java | 13 +++++++------ ...nResolver.java => LinkAssetVersionResolver.java} | 4 ++-- ...esolver.java => UnlinkAssetVersionResolver.java} | 4 ++-- .../src/main/resources/entity.graphql | 4 ++-- .../main/java/com/linkedin/metadata/Constants.java | 1 + .../versioning/EntityVersioningServiceImpl.java | 5 ++++- .../com/linkedin/common/VersionProperties.pdl | 3 ++- 7 files changed, 20 insertions(+), 14 deletions(-) rename datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/entity/versioning/{LinkVersionResolver.java => LinkAssetVersionResolver.java} (96%) rename datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/entity/versioning/{UnlinkVersionResolver.java => UnlinkAssetVersionResolver.java} (95%) diff --git a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/GmsGraphQLEngine.java b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/GmsGraphQLEngine.java index e452b069bb8614..e7e3430d9d0c67 100644 --- a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/GmsGraphQLEngine.java +++ b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/GmsGraphQLEngine.java @@ -173,8 +173,8 @@ import com.linkedin.datahub.graphql.resolvers.embed.UpdateEmbedResolver; import com.linkedin.datahub.graphql.resolvers.entity.EntityExistsResolver; import com.linkedin.datahub.graphql.resolvers.entity.EntityPrivilegesResolver; -import com.linkedin.datahub.graphql.resolvers.entity.versioning.LinkVersionResolver; -import com.linkedin.datahub.graphql.resolvers.entity.versioning.UnlinkVersionResolver; +import com.linkedin.datahub.graphql.resolvers.entity.versioning.LinkAssetVersionResolver; +import com.linkedin.datahub.graphql.resolvers.entity.versioning.UnlinkAssetVersionResolver; import com.linkedin.datahub.graphql.resolvers.form.BatchAssignFormResolver; import com.linkedin.datahub.graphql.resolvers.form.BatchRemoveFormResolver; import com.linkedin.datahub.graphql.resolvers.form.CreateDynamicFormAssignmentResolver; @@ -1394,11 +1394,12 @@ private void configureMutationResolvers(final RuntimeWiring.Builder builder) { if (featureFlags.isEntityVersioning()) { typeWiring .dataFetcher( - "linkVersion", - new LinkVersionResolver(this.entityVersioningService, this.featureFlags)) + "linkAssetVersion", + new LinkAssetVersionResolver(this.entityVersioningService, this.featureFlags)) .dataFetcher( - "unlinkVersion", - new UnlinkVersionResolver(this.entityVersioningService, this.featureFlags)); + "unlinkAssetVersion", + new UnlinkAssetVersionResolver( + this.entityVersioningService, this.featureFlags)); } return typeWiring; }); diff --git a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/entity/versioning/LinkVersionResolver.java b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/entity/versioning/LinkAssetVersionResolver.java similarity index 96% rename from datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/entity/versioning/LinkVersionResolver.java rename to datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/entity/versioning/LinkAssetVersionResolver.java index 4485f416ce8716..69e049af1e87b7 100644 --- a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/entity/versioning/LinkVersionResolver.java +++ b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/entity/versioning/LinkAssetVersionResolver.java @@ -26,12 +26,12 @@ /** * Currently only supports linking the latest version, but may be modified later to support inserts */ -public class LinkVersionResolver implements DataFetcher> { +public class LinkAssetVersionResolver implements DataFetcher> { private final EntityVersioningService entityVersioningService; private final FeatureFlags featureFlags; - public LinkVersionResolver( + public LinkAssetVersionResolver( EntityVersioningService entityVersioningService, FeatureFlags featureFlags) { this.entityVersioningService = entityVersioningService; this.featureFlags = featureFlags; diff --git a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/entity/versioning/UnlinkVersionResolver.java b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/entity/versioning/UnlinkAssetVersionResolver.java similarity index 95% rename from datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/entity/versioning/UnlinkVersionResolver.java rename to datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/entity/versioning/UnlinkAssetVersionResolver.java index 3f575df4b31f3e..3d5027a0d668ac 100644 --- a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/entity/versioning/UnlinkVersionResolver.java +++ b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/entity/versioning/UnlinkAssetVersionResolver.java @@ -19,12 +19,12 @@ import io.datahubproject.metadata.context.OperationContext; import java.util.concurrent.CompletableFuture; -public class UnlinkVersionResolver implements DataFetcher> { +public class UnlinkAssetVersionResolver implements DataFetcher> { private final EntityVersioningService entityVersioningService; private final FeatureFlags featureFlags; - public UnlinkVersionResolver( + public UnlinkAssetVersionResolver( EntityVersioningService entityVersioningService, FeatureFlags featureFlags) { this.entityVersioningService = entityVersioningService; this.featureFlags = featureFlags; diff --git a/datahub-graphql-core/src/main/resources/entity.graphql b/datahub-graphql-core/src/main/resources/entity.graphql index 164666f6f61d1f..20940ac6df2932 100644 --- a/datahub-graphql-core/src/main/resources/entity.graphql +++ b/datahub-graphql-core/src/main/resources/entity.graphql @@ -952,12 +952,12 @@ type Mutation { """ Link the latest versioned entity to a Version Set """ - linkVersion(input: LinkVersionInput!): String + linkAssetVersion(input: LinkVersionInput!): String """ Unlink a versioned entity from a Version Set """ - unlinkVersion(input: UnlinkVersionInput!): Boolean + unlinkAssetVersion(input: UnlinkVersionInput!): Boolean } """ diff --git a/li-utils/src/main/java/com/linkedin/metadata/Constants.java b/li-utils/src/main/java/com/linkedin/metadata/Constants.java index d4be8c6e985f17..50e9ad072b0b76 100644 --- a/li-utils/src/main/java/com/linkedin/metadata/Constants.java +++ b/li-utils/src/main/java/com/linkedin/metadata/Constants.java @@ -465,6 +465,7 @@ public class Constants { // Versioning related public static final String INITIAL_VERSION_SORT_ID = "AAAAAAAA"; + public static final String VERSION_SORT_ID_FIELD_NAME = "versionSortId"; public static final String DISPLAY_PROPERTIES_ASPECT_NAME = "displayProperties"; diff --git a/metadata-io/src/main/java/com/linkedin/metadata/entity/versioning/EntityVersioningServiceImpl.java b/metadata-io/src/main/java/com/linkedin/metadata/entity/versioning/EntityVersioningServiceImpl.java index e081e74a453eef..d03c4dd808c7c0 100644 --- a/metadata-io/src/main/java/com/linkedin/metadata/entity/versioning/EntityVersioningServiceImpl.java +++ b/metadata-io/src/main/java/com/linkedin/metadata/entity/versioning/EntityVersioningServiceImpl.java @@ -5,6 +5,7 @@ import static com.linkedin.metadata.Constants.VERSION_SET_ENTITY_NAME; import static com.linkedin.metadata.Constants.VERSION_SET_KEY_ASPECT_NAME; import static com.linkedin.metadata.Constants.VERSION_SET_PROPERTIES_ASPECT_NAME; +import static com.linkedin.metadata.Constants.VERSION_SORT_ID_FIELD_NAME; import com.datahub.util.RecordUtils; import com.google.common.collect.ImmutableList; @@ -243,7 +244,9 @@ public List unlinkVersion( null, 2, ImmutableList.of( - new SortCriterion().setField("sortId").setOrder(SortOrder.DESCENDING))); + new SortCriterion() + .setField(VERSION_SORT_ID_FIELD_NAME) + .setOrder(SortOrder.DESCENDING))); String updatedLatestVersionUrn = null; SearchEntityArray linkedEntities = linkedVersions.getEntities(); diff --git a/metadata-models/src/main/pegasus/com/linkedin/common/VersionProperties.pdl b/metadata-models/src/main/pegasus/com/linkedin/common/VersionProperties.pdl index 430f3b9e7b38fd..49f56d18a54e94 100644 --- a/metadata-models/src/main/pegasus/com/linkedin/common/VersionProperties.pdl +++ b/metadata-models/src/main/pegasus/com/linkedin/common/VersionProperties.pdl @@ -51,7 +51,8 @@ record VersionProperties { * What this looks like depends on the Version Scheme. For sort ids generated by DataHub we use an 8 character string representation. */ @Searchable = { - "queryByDefault": false + "queryByDefault": false, + "fieldName": "versionSortId" } sortId: string