Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(backend): Add new PDL entities + models for persona capture #9637

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.linkedin.datahub.graphql;

import com.google.common.collect.ImmutableSet;
import java.util.Set;

/** Constants relating to GraphQL type system & execution. */
public class Constants {

Expand All @@ -25,4 +28,11 @@ private Constants() {}
public static final String BROWSE_PATH_V2_DELIMITER = "␟";
public static final String VERSION_STAMP_FIELD_NAME = "versionStamp";
public static final String ENTITY_FILTER_NAME = "_entityType";

public static final Set<String> DEFAULT_PERSONA_URNS =
ImmutableSet.of(
"urn:li:dataHubPersona:technicalUser",
"urn:li:dataHubPersona:businessUser",
"urn:li:dataHubPersona:dataLeader",
"urn:li:dataHubPersona:dataSteward");
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.linkedin.datahub.graphql.generated.CorpGroup;
import com.linkedin.datahub.graphql.generated.CorpGroupInfo;
import com.linkedin.datahub.graphql.generated.CorpUser;
import com.linkedin.datahub.graphql.generated.CorpUserEditableProperties;
import com.linkedin.datahub.graphql.generated.CorpUserInfo;
import com.linkedin.datahub.graphql.generated.CorpUserViewsSettings;
import com.linkedin.datahub.graphql.generated.Dashboard;
Expand All @@ -49,6 +50,7 @@
import com.linkedin.datahub.graphql.generated.DataHubView;
import com.linkedin.datahub.graphql.generated.DataJob;
import com.linkedin.datahub.graphql.generated.DataJobInputOutput;
import com.linkedin.datahub.graphql.generated.DataPlatform;
import com.linkedin.datahub.graphql.generated.DataPlatformInstance;
import com.linkedin.datahub.graphql.generated.Dataset;
import com.linkedin.datahub.graphql.generated.DatasetStatsSummary;
Expand Down Expand Up @@ -1661,6 +1663,18 @@ private void configureCorpUserResolvers(final RuntimeWiring.Builder builder) {
new LoadableTypeResolver<>(
corpUserType,
(env) -> ((CorpUserInfo) env.getSource()).getManager().getUrn())));
builder.type(
"CorpUserEditableProperties",
typeWiring ->
typeWiring.dataFetcher(
"platforms",
new LoadableTypeBatchResolver<>(
dataPlatformType,
(env) ->
((CorpUserEditableProperties) env.getSource())
.getPlatforms().stream()
.map(DataPlatform::getUrn)
.collect(Collectors.toList()))));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.linkedin.datahub.graphql.types.corpuser;

import static com.linkedin.datahub.graphql.Constants.DEFAULT_PERSONA_URNS;
import static com.linkedin.datahub.graphql.resolvers.mutate.MutationUtils.*;
import static com.linkedin.metadata.Constants.*;

import com.datahub.authorization.ConjunctivePrivilegeGroup;
import com.datahub.authorization.DisjunctivePrivilegeGroup;
import com.google.common.collect.ImmutableList;
import com.linkedin.common.UrnArray;
import com.linkedin.common.url.Url;
import com.linkedin.common.urn.Urn;
import com.linkedin.common.urn.UrnUtils;
Expand All @@ -14,6 +16,8 @@
import com.linkedin.datahub.graphql.QueryContext;
import com.linkedin.datahub.graphql.authorization.AuthorizationUtils;
import com.linkedin.datahub.graphql.exception.AuthorizationException;
import com.linkedin.datahub.graphql.exception.DataHubGraphQLErrorCode;
import com.linkedin.datahub.graphql.exception.DataHubGraphQLException;
import com.linkedin.datahub.graphql.featureflags.FeatureFlags;
import com.linkedin.datahub.graphql.generated.AutoCompleteResults;
import com.linkedin.datahub.graphql.generated.CorpUser;
Expand Down Expand Up @@ -247,7 +251,20 @@ private RecordTemplate mapCorpUserEditableInfo(
if (input.getEmail() != null) {
result.setEmail(input.getEmail());
}

if (input.getPlatformUrns() != null) {
result.setPlatforms(
new UrnArray(
input.getPlatformUrns().stream().map(UrnUtils::getUrn).collect(Collectors.toList())));
}
if (input.getPersonaUrn() != null) {
if (DEFAULT_PERSONA_URNS.contains(input.getPersonaUrn())) {
result.setPersona(UrnUtils.getUrn(input.getPersonaUrn()));
} else {
throw new DataHubGraphQLException(
String.format("Provided persona urn %s does not exist", input.getPersonaUrn()),
DataHubGraphQLErrorCode.NOT_FOUND);
}
}
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.linkedin.datahub.graphql.types.corpuser.mappers;

import com.linkedin.datahub.graphql.generated.CorpUserEditableProperties;
import com.linkedin.datahub.graphql.generated.DataHubPersona;
import com.linkedin.datahub.graphql.generated.DataPlatform;
import com.linkedin.datahub.graphql.types.mappers.ModelMapper;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;

/**
Expand Down Expand Up @@ -34,6 +37,22 @@ public CorpUserEditableProperties apply(
if (info.hasPictureLink()) {
result.setPictureLink(info.getPictureLink().toString());
}
if (info.hasPlatforms()) {
result.setPlatforms(
info.getPlatforms().stream()
.map(
urn -> {
DataPlatform platform = new DataPlatform();
platform.setUrn(urn.toString());
return platform;
})
.collect(Collectors.toList()));
}
if (info.hasPersona()) {
DataHubPersona persona = new DataHubPersona();
persona.setUrn(info.getPersona().toString());
result.setPersona(persona);
}
return result;
}
}
31 changes: 31 additions & 0 deletions datahub-graphql-core/src/main/resources/entity.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3807,6 +3807,16 @@ type CorpUserEditableProperties {
Email address for the user
"""
email: String

"""
User persona, if present
"""
persona: DataHubPersona

"""
Platforms commonly used by the user, if present.
"""
platforms: [DataPlatform!]
}

"""
Expand Down Expand Up @@ -3857,6 +3867,16 @@ input CorpUserUpdateInput {
Email address for the user
"""
email: String

"""
The platforms that the user frequently works with
"""
platformUrns: [String!]

"""
The user's persona urn"
"""
personaUrn: String
}

"""
Expand Down Expand Up @@ -11345,6 +11365,7 @@ input CreateDataProductPropertiesInput {
description: String
}


"""
Input properties required for update a DataProduct
"""
Expand Down Expand Up @@ -11510,6 +11531,16 @@ input UpdateOwnershipTypeInput {
description: String
}

"""
A standardized type of a user
"""
type DataHubPersona {
"""
The urn of the persona type
"""
urn: String!
}

"""
Describes a generic filter on a dataset
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace com.linkedin.identity

import com.linkedin.common.Url
import com.linkedin.common.Urn

/**
* Linkedin corp user information that can be edited from UI
Expand Down Expand Up @@ -56,6 +57,26 @@ record CorpUserEditableInfo {
*/
title: optional string

/**
* The platforms that the user commonly works with
*/
@Relationship = {
"/*": {
"name": "IsUserOf",
"entityTypes": ["dataPlatform"]
}
}
platforms: optional array[Urn]

/**
* The user's persona type, based on their role
*/
@Relationship = {
"name": "IsPersona",
"entityTypes": ["dataHubPersona"]
}
persona: optional Urn

/**
* Slack handle for the user
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace com.linkedin.metadata.key

/**
* Key for a persona type
*/
@Aspect = {
"name": "dataHubPersonaKey"
}
record DataHubPersonaKey {
/**
* A unique id for the persona type
*/
id: string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace com.linkedin.persona

/**
* Placeholder aspect for persona type info
*/
@Aspect = {
"name": "dataHubPersonaInfo"
}
record DataHubPersonaInfo {
}
5 changes: 5 additions & 0 deletions metadata-models/src/main/resources/entity-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,11 @@ entities:
- dataContractProperties
- dataContractStatus
- status
- name: dataHubPersona
category: internal
keyAspect: dataHubPersonaKey
aspects:
- dataHubPersonaInfo
- name: entityType
doc: A type of entity in the DataHub Metadata Model.
category: core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2322,6 +2322,29 @@
"type" : "string",
"doc" : "DataHub-native Title, e.g. 'Software Engineer'",
"optional" : true
}, {
"name" : "platforms",
"type" : {
"type" : "array",
"items" : "com.linkedin.common.Urn"
},
"doc" : "The platforms that the user commonly works with",
"optional" : true,
"Relationship" : {
"/*" : {
"entityTypes" : [ "dataPlatform" ],
"name" : "IsUserOf"
}
}
}, {
"name" : "persona",
"type" : "com.linkedin.common.Urn",
"doc" : "The user's persona type, based on their role",
"optional" : true,
"Relationship" : {
"entityTypes" : [ "dataHubPersona" ],
"name" : "IsPersona"
}
}, {
"name" : "slack",
"type" : "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2731,6 +2731,29 @@
"type" : "string",
"doc" : "DataHub-native Title, e.g. 'Software Engineer'",
"optional" : true
}, {
"name" : "platforms",
"type" : {
"type" : "array",
"items" : "com.linkedin.common.Urn"
},
"doc" : "The platforms that the user commonly works with",
"optional" : true,
"Relationship" : {
"/*" : {
"entityTypes" : [ "dataPlatform" ],
"name" : "IsUserOf"
}
}
}, {
"name" : "persona",
"type" : "com.linkedin.common.Urn",
"doc" : "The user's persona type, based on their role",
"optional" : true,
"Relationship" : {
"entityTypes" : [ "dataHubPersona" ],
"name" : "IsPersona"
}
}, {
"name" : "slack",
"type" : "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,29 @@
"type" : "string",
"doc" : "DataHub-native Title, e.g. 'Software Engineer'",
"optional" : true
}, {
"name" : "platforms",
"type" : {
"type" : "array",
"items" : "com.linkedin.common.Urn"
},
"doc" : "The platforms that the user commonly works with",
"optional" : true,
"Relationship" : {
"/*" : {
"entityTypes" : [ "dataPlatform" ],
"name" : "IsUserOf"
}
}
}, {
"name" : "persona",
"type" : "com.linkedin.common.Urn",
"doc" : "The user's persona type, based on their role",
"optional" : true,
"Relationship" : {
"entityTypes" : [ "dataHubPersona" ],
"name" : "IsPersona"
}
}, {
"name" : "slack",
"type" : "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2050,6 +2050,29 @@
"type" : "string",
"doc" : "DataHub-native Title, e.g. 'Software Engineer'",
"optional" : true
}, {
"name" : "platforms",
"type" : {
"type" : "array",
"items" : "com.linkedin.common.Urn"
},
"doc" : "The platforms that the user commonly works with",
"optional" : true,
"Relationship" : {
"/*" : {
"entityTypes" : [ "dataPlatform" ],
"name" : "IsUserOf"
}
}
}, {
"name" : "persona",
"type" : "com.linkedin.common.Urn",
"doc" : "The user's persona type, based on their role",
"optional" : true,
"Relationship" : {
"entityTypes" : [ "dataHubPersona" ],
"name" : "IsPersona"
}
}, {
"name" : "slack",
"type" : "string",
Expand Down
Loading
Loading