Skip to content

Commit

Permalink
Merge pull request #2460 from atlanhq/revert-2452-documenttype
Browse files Browse the repository at this point in the history
Revert "Add Document type under Term"
  • Loading branch information
nikhilbonte21 authored Nov 10, 2023
2 parents 407e65d + 2b8beef commit 8efed7c
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 270 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public final class Constants {
public static final String ATLAS_GLOSSARY_ENTITY_TYPE = "AtlasGlossary";
public static final String ATLAS_GLOSSARY_TERM_ENTITY_TYPE = "AtlasGlossaryTerm";
public static final String ATLAS_GLOSSARY_CATEGORY_ENTITY_TYPE = "AtlasGlossaryCategory";
public static final String DOCUMENT_ENTITY_TYPE = "Document";
public static final String CATEGORY_PARENT_EDGE_LABEL = "r:AtlasGlossaryCategoryHierarchyLink";
public static final String CATEGORY_TERMS_EDGE_LABEL = "r:AtlasGlossaryTermCategorization";
public static final String GLOSSARY_TERMS_EDGE_LABEL = "r:AtlasGlossaryTermAnchor";
Expand Down
2 changes: 1 addition & 1 deletion intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public enum AtlasErrorCode {
TYPE_HAS_RELATIONSHIPS(409, "ATLAS-409-00-005", "Given type {0} has associated relationshipDefs"),
SAVED_SEARCH_ALREADY_EXISTS(409, "ATLAS-409-00-006", "search named {0} already exists for user {1}"),
GLOSSARY_ALREADY_EXISTS(409, "ATLAS-409-00-007", "Glossary with name {0} already exists"),
GLOSSARY_TERM_ALREADY_EXISTS(409, "ATLAS-409-00-009", "Glossary {0} with name {1} already exists"),
GLOSSARY_TERM_ALREADY_EXISTS(409, "ATLAS-409-00-009", "Glossary term with name {0} already exists"),
GLOSSARY_CATEGORY_ALREADY_EXISTS(409, "ATLAS-409-00-00A", "Glossary category with name {0} already exists on this level"),
ACHOR_UPDATION_NOT_SUPPORTED(409, "ATLAS-400-00-0010", "Anchor(glossary) change not supported"),
GLOSSARY_IMPORT_FAILED(409, "ATLAS-409-00-011", "Glossary import failed"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import org.apache.atlas.repository.store.graph.v1.RestoreHandlerV1;
import org.apache.atlas.repository.store.graph.v2.preprocessor.AuthPolicyPreProcessor;
import org.apache.atlas.repository.store.graph.v2.preprocessor.ConnectionPreProcessor;
import org.apache.atlas.repository.store.graph.v2.preprocessor.glossary.DocumentPreProcessor;
import org.apache.atlas.repository.store.graph.v2.preprocessor.resource.LinkPreProcessor;
import org.apache.atlas.repository.store.graph.v2.preprocessor.PreProcessor;
import org.apache.atlas.repository.store.graph.v2.preprocessor.accesscontrol.PersonaPreProcessor;
Expand Down Expand Up @@ -1797,10 +1796,6 @@ public PreProcessor getPreProcessor(String typeName) {
preProcessor = new TermPreProcessor(typeRegistry, entityRetriever, graph, taskManagement);
break;

case DOCUMENT_ENTITY_TYPE:
preProcessor = new DocumentPreProcessor(typeRegistry, entityRetriever, graph, taskManagement);
break;

case ATLAS_GLOSSARY_CATEGORY_ENTITY_TYPE:
preProcessor = new CategoryPreProcessor(typeRegistry, entityRetriever, graph, taskManagement, entityGraphMapper);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1980,7 +1980,7 @@ private void addGlossaryAttr(AttributeMutationContext ctx, AtlasEdge edge) {
AtlasVertex toVertex = ctx.getReferringVertex();
String toVertexType = getTypeName(toVertex);

if (TYPE_TERM.equals(toVertexType) || DOCUMENT_ENTITY_TYPE.equals(toVertexType) || TYPE_CATEGORY.equals(toVertexType)) {
if (TYPE_TERM.equals(toVertexType) || TYPE_CATEGORY.equals(toVertexType)) {
// handle __glossary attribute of term or category entity
String gloQname = edge.getOutVertex().getProperty(QUALIFIED_NAME, String.class);
AtlasGraphUtilsV2.setEncodedProperty(toVertex, GLOSSARY_PROPERTY_KEY, gloQname);
Expand Down Expand Up @@ -2064,7 +2064,7 @@ private void addCategoriesToTermEntity(AttributeMutationContext ctx, List<Object
}
}

if (TYPE_TERM.equals(getTypeName(termVertex)) || DOCUMENT_ENTITY_TYPE.equals(getTypeName(termVertex))) {
if (TYPE_TERM.equals(getTypeName(termVertex))) {
List<AtlasVertex> categoryVertices = newElementsCreated.stream().map(x -> ((AtlasEdge)x).getOutVertex()).collect(Collectors.toList());
Set<String> catQnames = categoryVertices.stream().map(x -> x.getProperty(QUALIFIED_NAME, String.class)).collect(Collectors.toSet());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ public abstract class AbstractGlossaryPreProcessor implements PreProcessor {
}
}

public void termExists(String termName, String glossaryQName, String entityType) throws AtlasBaseException {
public void termExists(String termName, String glossaryQName) throws AtlasBaseException {
AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("termExists");
boolean ret = false;

try {
List mustClauseList = new ArrayList();
mustClauseList.add(mapOf("term", mapOf("__glossary", glossaryQName)));
mustClauseList.add(mapOf("term", mapOf("__typeName.keyword", entityType)));
mustClauseList.add(mapOf("term", mapOf("__typeName.keyword", ATLAS_GLOSSARY_TERM_ENTITY_TYPE)));
mustClauseList.add(mapOf("term", mapOf("__state", "ACTIVE")));
mustClauseList.add(mapOf("term", mapOf("name.keyword", termName)));

Expand All @@ -110,8 +110,7 @@ public void termExists(String termName, String glossaryQName, String entityType)
}

if (ret) {
String type = entityType.equals(ATLAS_GLOSSARY_TERM_ENTITY_TYPE) ? "term" : "document";
throw new AtlasBaseException(AtlasErrorCode.GLOSSARY_TERM_ALREADY_EXISTS, type, termName);
throw new AtlasBaseException(AtlasErrorCode.GLOSSARY_TERM_ALREADY_EXISTS, termName);
}
} finally {
RequestContext.get().endMetricRecord(metricRecorder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
import static org.apache.atlas.AtlasErrorCode.BAD_REQUEST;
import static org.apache.atlas.repository.Constants.ATLAS_GLOSSARY_CATEGORY_ENTITY_TYPE;
import static org.apache.atlas.repository.Constants.ATLAS_GLOSSARY_ENTITY_TYPE;
import static org.apache.atlas.repository.Constants.ATLAS_GLOSSARY_TERM_ENTITY_TYPE;
import static org.apache.atlas.repository.Constants.CATEGORY_PARENT_EDGE_LABEL;
import static org.apache.atlas.repository.Constants.CATEGORY_TERMS_EDGE_LABEL;
import static org.apache.atlas.repository.Constants.GUID_PROPERTY_KEY;
Expand Down Expand Up @@ -273,7 +272,7 @@ public void moveChildTermToAnotherGlossary(AtlasVertex termVertex,
LOG.info("Moving child term {} to Glossary {}", termName, targetGlossaryQualifiedName);

//check duplicate term name
termExists(termName, targetGlossaryQualifiedName, ATLAS_GLOSSARY_TERM_ENTITY_TYPE);
termExists(termName, targetGlossaryQualifiedName);

String currentTermQualifiedName = termVertex.getProperty(QUALIFIED_NAME, String.class);
String updatedTermQualifiedName = currentTermQualifiedName.replace(sourceGlossaryQualifiedName, targetGlossaryQualifiedName);
Expand Down

This file was deleted.

Loading

0 comments on commit 8efed7c

Please sign in to comment.