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(graphql): enabling graphql for data platform instance aspects #7177

Merged
Show file tree
Hide file tree
Changes from 9 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
Expand Up @@ -43,7 +43,8 @@ private SearchUtils() {
EntityType.CORP_GROUP,
EntityType.CONTAINER,
EntityType.DOMAIN,
EntityType.NOTEBOOK);
EntityType.NOTEBOOK,
EntityType.DATA_PLATFORM_INSTANCE);

/**
* Entities that are part of autocomplete by default in Auto Complete Across Entities
Expand All @@ -63,7 +64,8 @@ private SearchUtils() {
EntityType.TAG,
EntityType.CORP_USER,
EntityType.CORP_GROUP,
EntityType.NOTEBOOK);
EntityType.NOTEBOOK,
EntityType.DATA_PLATFORM_INSTANCE);


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@

public class DataPlatformInstanceType implements com.linkedin.datahub.graphql.types.EntityType<DataPlatformInstance, String> {

static final Set<String> ASPECTS_TO_FETCH = ImmutableSet.of();
static final Set<String> ASPECTS_TO_FETCH = ImmutableSet.of(
Constants.DATA_PLATFORM_INSTANCE_KEY_ASPECT_NAME,
Constants.DATA_PLATFORM_INSTANCE_PROPERTIES_ASPECT_NAME,
Constants.DEPRECATION_ASPECT_NAME,
Constants.OWNERSHIP_ASPECT_NAME,
Constants.INSTITUTIONAL_MEMORY_ASPECT_NAME,
Constants.GLOBAL_TAGS_ASPECT_NAME,
sgomezvillamor marked this conversation as resolved.
Show resolved Hide resolved
Constants.STATUS_ASPECT_NAME
);
private final EntityClient _entityClient;

public DataPlatformInstanceType(final EntityClient entityClient) {
Expand Down Expand Up @@ -72,7 +80,7 @@ public List<DataFetcherResult<DataPlatformInstance>> batchLoad(@Nonnull List<Str
.collect(Collectors.toList());

} catch (Exception e) {
throw new RuntimeException("Failed to batch load DataPlatformInstance");
throw new RuntimeException("Failed to batch load DataPlatformInstance", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
package com.linkedin.datahub.graphql.types.dataplatforminstance.mappers;

import com.linkedin.common.Ownership;
import com.linkedin.common.GlobalTags;
import com.linkedin.common.InstitutionalMemory;
import com.linkedin.common.Status;
import com.linkedin.common.Deprecation;
import com.linkedin.common.urn.Urn;
import com.linkedin.datahub.graphql.types.common.mappers.OwnershipMapper;
import com.linkedin.datahub.graphql.types.common.mappers.InstitutionalMemoryMapper;
import com.linkedin.datahub.graphql.types.common.mappers.StatusMapper;
import com.linkedin.datahub.graphql.types.common.mappers.DeprecationMapper;
import com.linkedin.datahub.graphql.types.common.mappers.CustomPropertiesMapper;
import com.linkedin.datahub.graphql.types.tag.mappers.GlobalTagsMapper;
import com.linkedin.dataplatforminstance.DataPlatformInstanceProperties;
import com.linkedin.data.DataMap;
import com.linkedin.datahub.graphql.generated.DataPlatform;
import com.linkedin.datahub.graphql.generated.DataPlatformInstance;
import com.linkedin.datahub.graphql.generated.EntityType;
import com.linkedin.datahub.graphql.types.common.mappers.util.MappingHelper;
import com.linkedin.entity.EntityResponse;
import com.linkedin.entity.EnvelopedAspectMap;
import com.linkedin.metadata.Constants;
import com.linkedin.metadata.key.DataPlatformInstanceKey;

import javax.annotation.Nonnull;

import static com.linkedin.metadata.Constants.DATA_PLATFORM_INSTANCE_KEY_ASPECT_NAME;

public class DataPlatformInstanceMapper {

public static final DataPlatformInstanceMapper INSTANCE = new DataPlatformInstanceMapper();
Expand All @@ -25,14 +36,37 @@ public static DataPlatformInstance map(final EntityResponse entityResponse) {
public DataPlatformInstance apply(@Nonnull final EntityResponse entityResponse) {
final DataPlatformInstance result = new DataPlatformInstance();
final Urn entityUrn = entityResponse.getUrn();
final EnvelopedAspectMap aspects = entityResponse.getAspects();

result.setUrn(entityUrn.toString());
result.setType(EntityType.DATA_PLATFORM_INSTANCE);

final EnvelopedAspectMap aspects = entityResponse.getAspects();
MappingHelper<DataPlatformInstance> mappingHelper = new MappingHelper<>(aspects, result);
mappingHelper.mapToResult(DATA_PLATFORM_INSTANCE_KEY_ASPECT_NAME, this::mapDataPlatformInstanceKey);

mappingHelper.mapToResult(Constants.DATA_PLATFORM_INSTANCE_KEY_ASPECT_NAME,
this::mapDataPlatformInstanceKey
);
mappingHelper.mapToResult(Constants.DATA_PLATFORM_INSTANCE_PROPERTIES_ASPECT_NAME,
(dataPlatformInstance, dataMap) ->
this.mapDataPlatformInstanceProperties(dataPlatformInstance, dataMap, entityUrn)
);
mappingHelper.mapToResult(Constants.OWNERSHIP_ASPECT_NAME,
(dataPlatformInstance, dataMap) ->
dataPlatformInstance.setOwnership(OwnershipMapper.map(new Ownership(dataMap), entityUrn))
);
mappingHelper.mapToResult(Constants.GLOBAL_TAGS_ASPECT_NAME,
(dataPlatformInstance, dataMap) -> this.mapGlobalTags(dataPlatformInstance, dataMap, entityUrn)
);
mappingHelper.mapToResult(Constants.INSTITUTIONAL_MEMORY_ASPECT_NAME,
(dataPlatformInstance, dataMap) ->
dataPlatformInstance.setInstitutionalMemory(InstitutionalMemoryMapper.map(new InstitutionalMemory(dataMap)))
);
mappingHelper.mapToResult(Constants.STATUS_ASPECT_NAME,
(dataPlatformInstance, dataMap) ->
dataPlatformInstance.setStatus(StatusMapper.map(new Status(dataMap)))
);
mappingHelper.mapToResult(Constants.DEPRECATION_ASPECT_NAME,
(dataPlatformInstance, dataMap) ->
dataPlatformInstance.setDeprecation(DeprecationMapper.map(new Deprecation(dataMap)))
);
return mappingHelper.getResult();
}

Expand All @@ -44,4 +78,28 @@ private void mapDataPlatformInstanceKey(@Nonnull DataPlatformInstance dataPlatfo
.build());
dataPlatformInstance.setInstanceId(gmsKey.getInstance());
}

private void mapDataPlatformInstanceProperties(
@Nonnull DataPlatformInstance dataPlatformInstance, @Nonnull DataMap dataMap, @Nonnull Urn entityUrn
) {
final DataPlatformInstanceProperties gmsProperties = new DataPlatformInstanceProperties(dataMap);
final com.linkedin.datahub.graphql.generated.DataPlatformInstanceProperties properties =
new com.linkedin.datahub.graphql.generated.DataPlatformInstanceProperties();
properties.setName(gmsProperties.getName());
properties.setDescription(gmsProperties.getDescription());
if (gmsProperties.hasExternalUrl()) {
properties.setExternalUrl(gmsProperties.getExternalUrl().toString());
}
if (gmsProperties.hasCustomProperties()) {
properties.setCustomProperties(CustomPropertiesMapper.map(gmsProperties.getCustomProperties(), entityUrn));
}

dataPlatformInstance.setProperties(properties);
}

private void mapGlobalTags(@Nonnull DataPlatformInstance dataPlatformInstance, @Nonnull DataMap dataMap, @Nonnull final Urn entityUrn) {
com.linkedin.datahub.graphql.generated.GlobalTags globalTags = GlobalTagsMapper.map(new GlobalTags(dataMap), entityUrn);
dataPlatformInstance.setTags(globalTags);
}

}
56 changes: 56 additions & 0 deletions datahub-graphql-core/src/main/resources/entity.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,32 @@ type DatasetProperties {
}


"""
Additional read only properties about a DataPlatformInstance
"""
type DataPlatformInstanceProperties {

"""
The name of the data platform instance used in display
"""
name: String

"""
Read only technical description for the data platform instance
"""
description: String

"""
Custom properties of the data platform instance
"""
customProperties: [CustomPropertiesEntry!]

"""
External URL associated with the data platform instance
"""
externalUrl: String
}

"""
A Glossary Term, or a node in a Business Glossary representing a standardized domain
data type
Expand Down Expand Up @@ -1863,6 +1889,36 @@ type DataPlatformInstance implements Entity {
Edges extending from this entity
"""
relationships(input: RelationshipsInput!): EntityRelationshipsResult

"""
Additional read only properties associated with a data platform instance
"""
properties: DataPlatformInstanceProperties

"""
Ownership metadata of the data platform instance
"""
ownership: Ownership

"""
References to internal resources related to the data platform instance
"""
institutionalMemory: InstitutionalMemory

"""
Tags used for searching the data platform instance
"""
tags: GlobalTags
sgomezvillamor marked this conversation as resolved.
Show resolved Hide resolved

"""
The deprecation status of the data platform instance
"""
deprecation: Deprecation

"""
Status metadata of the container
"""
status: Status
}

"""
Expand Down
Loading