Skip to content

Commit

Permalink
feat(backend): Add new PDL entities + models for persona capture (#9637)
Browse files Browse the repository at this point in the history
Co-authored-by: John Joyce <[email protected]>
  • Loading branch information
jjoyce0510 and John Joyce authored Jun 28, 2024
1 parent b4b8a23 commit a350890
Show file tree
Hide file tree
Showing 14 changed files with 257 additions and 1 deletion.
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 Down Expand Up @@ -28,4 +31,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 @@ -42,6 +42,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 @@ -53,6 +54,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.DataQualityContract;
import com.linkedin.datahub.graphql.generated.Dataset;
Expand Down Expand Up @@ -1823,6 +1825,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 @@ -246,7 +250,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
Expand Up @@ -2,7 +2,10 @@

import com.linkedin.datahub.graphql.QueryContext;
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;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -38,6 +41,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 @@ -4139,6 +4139,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 @@ -4189,6 +4199,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 @@ -12142,6 +12162,7 @@ input CreateDataProductPropertiesInput {
description: String
}


"""
Input properties required for update a DataProduct
"""
Expand Down Expand Up @@ -12307,6 +12328,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 @@ -542,6 +542,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 @@ -2353,6 +2353,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 @@ -2766,6 +2766,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 @@ -2086,6 +2086,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 @@ -2080,6 +2080,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

0 comments on commit a350890

Please sign in to comment.