-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui/java) Update domains to be nested (#8841)
Allow the ability to now nest domains underneath other domains. This should work much like the business glossary where you can add domains underneath other domains, move domains underneath other domains or at the root, and navigate domains using a nice new navigator.
- Loading branch information
1 parent
5882fe4
commit 85fa5a1
Showing
101 changed files
with
3,083 additions
and
415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...re/src/main/java/com/linkedin/datahub/graphql/resolvers/domain/ParentDomainsResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.linkedin.datahub.graphql.resolvers.domain; | ||
|
||
import com.linkedin.common.urn.Urn; | ||
import com.linkedin.common.urn.UrnUtils; | ||
import com.linkedin.datahub.graphql.QueryContext; | ||
import com.linkedin.datahub.graphql.generated.Entity; | ||
import com.linkedin.datahub.graphql.generated.ParentDomainsResult; | ||
import com.linkedin.datahub.graphql.resolvers.mutate.util.DomainUtils; | ||
import com.linkedin.entity.client.EntityClient; | ||
import graphql.schema.DataFetcher; | ||
import graphql.schema.DataFetchingEnvironment; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
import static com.linkedin.metadata.Constants.DOMAIN_ENTITY_NAME; | ||
|
||
public class ParentDomainsResolver implements DataFetcher<CompletableFuture<ParentDomainsResult>> { | ||
|
||
private final EntityClient _entityClient; | ||
|
||
public ParentDomainsResolver(final EntityClient entityClient) { | ||
_entityClient = entityClient; | ||
} | ||
|
||
@Override | ||
public CompletableFuture<ParentDomainsResult> get(DataFetchingEnvironment environment) { | ||
final QueryContext context = environment.getContext(); | ||
final Urn urn = UrnUtils.getUrn(((Entity) environment.getSource()).getUrn()); | ||
final List<Entity> parentDomains = new ArrayList<>(); | ||
final Set<String> visitedParentUrns = new HashSet<>(); | ||
|
||
if (!DOMAIN_ENTITY_NAME.equals(urn.getEntityType())) { | ||
throw new IllegalArgumentException(String.format("Failed to resolve parents for entity type %s", urn)); | ||
} | ||
|
||
return CompletableFuture.supplyAsync(() -> { | ||
try { | ||
Entity parentDomain = DomainUtils.getParentDomain(urn, context, _entityClient); | ||
|
||
while (parentDomain != null && !visitedParentUrns.contains(parentDomain.getUrn())) { | ||
parentDomains.add(parentDomain); | ||
visitedParentUrns.add(parentDomain.getUrn()); | ||
parentDomain = DomainUtils.getParentDomain(Urn.createFromString(parentDomain.getUrn()), context, _entityClient); | ||
} | ||
|
||
final ParentDomainsResult result = new ParentDomainsResult(); | ||
result.setCount(parentDomains.size()); | ||
result.setDomains(parentDomains); | ||
return result; | ||
} catch (Exception e) { | ||
throw new RuntimeException(String.format("Failed to load parent domains for entity %s", urn), e); | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.