Skip to content

Commit

Permalink
Merge branch 'master' into david-leifker/elasticsearch-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
david-leifker authored Oct 24, 2022
2 parents 588d2a3 + 18df38e commit ccadade
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class GlossaryTermType implements SearchableEntityType<GlossaryTerm, Stri
OWNERSHIP_ASPECT_NAME,
STATUS_ASPECT_NAME,
BROWSE_PATHS_ASPECT_NAME,
DOMAINS_ASPECT_NAME,
DEPRECATION_ASPECT_NAME
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
import com.linkedin.datahub.graphql.types.common.mappers.InstitutionalMemoryMapper;
import com.linkedin.datahub.graphql.types.common.mappers.OwnershipMapper;
import com.linkedin.datahub.graphql.types.common.mappers.util.MappingHelper;
import com.linkedin.datahub.graphql.types.domain.DomainAssociationMapper;
import com.linkedin.datahub.graphql.types.glossary.GlossaryTermUtils;
import com.linkedin.datahub.graphql.types.mappers.ModelMapper;
import com.linkedin.entity.EntityResponse;
import com.linkedin.entity.EnvelopedAspectMap;
import com.linkedin.glossary.GlossaryTermInfo;
import com.linkedin.metadata.key.GlossaryTermKey;
import com.linkedin.domain.Domains;
import javax.annotation.Nonnull;

import static com.linkedin.metadata.Constants.*;
Expand Down Expand Up @@ -54,6 +56,7 @@ public GlossaryTerm apply(@Nonnull final EntityResponse entityResponse) {
glossaryTerm.setProperties(GlossaryTermPropertiesMapper.map(new GlossaryTermInfo(dataMap), entityUrn)));
mappingHelper.mapToResult(OWNERSHIP_ASPECT_NAME, (glossaryTerm, dataMap) ->
glossaryTerm.setOwnership(OwnershipMapper.map(new Ownership(dataMap), entityUrn)));
mappingHelper.mapToResult(DOMAINS_ASPECT_NAME, this::mapDomains);
mappingHelper.mapToResult(DEPRECATION_ASPECT_NAME, (glossaryTerm, dataMap) ->
glossaryTerm.setDeprecation(DeprecationMapper.map(new Deprecation(dataMap))));
mappingHelper.mapToResult(INSTITUTIONAL_MEMORY_ASPECT_NAME, (dataset, dataMap) ->
Expand All @@ -74,4 +77,9 @@ private void mapGlossaryTermKey(@Nonnull GlossaryTerm glossaryTerm, @Nonnull Dat
glossaryTerm.setName(GlossaryTermUtils.getGlossaryTermName(glossaryTermKey.getName()));
glossaryTerm.setHierarchicalName(glossaryTermKey.getName());
}

private void mapDomains(@Nonnull GlossaryTerm glossaryTerm, @Nonnull DataMap dataMap) {
final Domains domains = new Domains(dataMap);
glossaryTerm.setDomain(DomainAssociationMapper.map(domains, glossaryTerm.getUrn()));
}
}
5 changes: 5 additions & 0 deletions datahub-graphql-core/src/main/resources/entity.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,11 @@ type GlossaryTerm implements Entity {
"""
ownership: Ownership

"""
The Domain associated with the glossary term
"""
domain: DomainAssociation

"""
References to internal resources related to the Glossary Term
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { SidebarAboutSection } from '../shared/containers/profile/sidebar/Sideba
import GlossaryEntitiesPath from '../../glossary/GlossaryEntitiesPath';
import { EntityMenuItems } from '../shared/EntityDropdown/EntityDropdown';
import { EntityActionItem } from '../shared/entity/EntityActions';
import { SidebarDomainSection } from '../shared/containers/profile/sidebar/Domain/SidebarDomainSection';

/**
* Definition of the DataHub Dataset entity.
Expand Down Expand Up @@ -112,6 +113,12 @@ export class GlossaryTermEntity implements Entity<GlossaryTerm> {
{
component: SidebarOwnerSection,
},
{
component: SidebarDomainSection,
properties: {
hideOwnerType: true,
},
},
]}
getOverrideProperties={this.getOverridePropertiesFromEntity}
customNavBar={<GlossaryEntitiesPath />}
Expand Down Expand Up @@ -139,6 +146,7 @@ export class GlossaryTermEntity implements Entity<GlossaryTerm> {
name={this.displayName(data)}
description={data?.properties?.description || ''}
owners={data?.ownership?.owners}
domain={data.domain?.domain}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { BookOutlined } from '@ant-design/icons';
import { Deprecation, EntityType, Owner, ParentNodesResult } from '../../../../types.generated';
import { Deprecation, Domain, EntityType, Owner, ParentNodesResult } from '../../../../types.generated';
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard';
import { useEntityRegistry } from '../../../useEntityRegistry';
import { IconStyleType, PreviewType } from '../../Entity';
Expand All @@ -13,6 +13,7 @@ export const Preview = ({
deprecation,
parentNodes,
previewType,
domain,
}: {
urn: string;
name: string;
Expand All @@ -21,6 +22,7 @@ export const Preview = ({
deprecation?: Deprecation | null;
parentNodes?: ParentNodesResult | null;
previewType: PreviewType;
domain?: Domain | undefined;
}): JSX.Element => {
const entityRegistry = useEntityRegistry();
return (
Expand All @@ -36,6 +38,7 @@ export const Preview = ({
typeIcon={entityRegistry.getIcon(EntityType.GlossaryTerm, 14, IconStyleType.ACCENT)}
deprecation={deprecation}
parentNodes={parentNodes}
domain={domain}
/>
);
};
8 changes: 5 additions & 3 deletions datahub-web-react/src/app/preview/DefaultPreviewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const PreviewContainer = styled.div`
align-items: center;
`;

const LeftColumn = styled.div`
max-width: 60%;
const LeftColumn = styled.div<{ expandWidth: boolean }>`
max-width: ${(props) => (props.expandWidth ? '100%' : '60%')};
`;

const RightColumn = styled.div`
Expand Down Expand Up @@ -245,9 +245,11 @@ export default function DefaultPreviewCard({
event.stopPropagation();
};

const shouldShowRightColumn = (topUsers && topUsers.length > 0) || (owners && owners.length > 0);

return (
<PreviewContainer data-testid={dataTestID} onMouseDown={onPreventMouseDown}>
<LeftColumn>
<LeftColumn expandWidth={!shouldShowRightColumn}>
<TitleContainer>
<PlatformContentView
platformName={platform}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const HoverEntityTooltip = ({ entity, canOpen = true, children }: Props)
visible={canOpen ? undefined : false}
color="white"
placement="topRight"
overlayStyle={{ minWidth: 500 }}
overlayStyle={{ minWidth: 300, maxWidth: 500, width: 'fit-content' }}
overlayInnerStyle={{ padding: 12 }}
title={<a href={url}>{entityRegistry.renderPreview(entity.type, PreviewType.HOVER_CARD, entity)}</a>}
>
Expand Down
3 changes: 3 additions & 0 deletions datahub-web-react/src/graphql/glossaryTerm.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ query getGlossaryTerm($urn: String!, $start: Int, $count: Int) {
ownership {
...ownershipFields
}
domain {
...entityDomain
}
institutionalMemory {
...institutionalMemoryFields
}
Expand Down
3 changes: 3 additions & 0 deletions datahub-web-react/src/graphql/search.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@ fragment searchResultFields on Entity {
parentNodes {
...parentNodesFields
}
domain {
...entityDomain
}
}
... on GlossaryNode {
...glossaryNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.codahale.metrics.Timer;
import com.datahub.util.Statement;
import com.datahub.util.exception.RetryLimitReached;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMap;
import com.linkedin.common.urn.Urn;
import com.linkedin.metadata.graph.Edge;
Expand Down Expand Up @@ -254,6 +255,11 @@ public void clear() {
removeNodesMatchingLabel(".*");
}

@VisibleForTesting
public void wipe() {
runQuery(new Statement("MATCH (n) DETACH DELETE n", Map.of())).consume();
}

// visible for testing
@Nonnull
Statement buildStatement(@Nonnull String queryTemplate, @Nonnull Map<String, Object> params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import org.neo4j.driver.Driver;
import org.neo4j.driver.GraphDatabase;
import org.testng.SkipException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

Expand All @@ -28,15 +29,21 @@ public class Neo4jGraphServiceTest extends GraphServiceTestBase {
private Driver _driver;
private Neo4jGraphService _client;

@BeforeMethod
@BeforeClass
public void init() {
_serverBuilder = new Neo4jTestServerBuilder();
_serverBuilder.newServer();
_driver = GraphDatabase.driver(_serverBuilder.boltURI());
_client = new Neo4jGraphService(new LineageRegistry(SnapshotEntityRegistry.getInstance()), _driver);
_client.clear();
}

@BeforeMethod
public void wipe() {
_client.wipe();
}

@AfterMethod
@AfterClass
public void tearDown() {
_serverBuilder.shutdown();
}
Expand Down
1 change: 1 addition & 0 deletions metadata-models/src/main/resources/entity-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ entities:
- schemaMetadata
- ownership
- deprecation
- domains
- name: glossaryNode
keyAspect: glossaryNodeKey
aspects:
Expand Down

0 comments on commit ccadade

Please sign in to comment.