This is an automated email from the ASF dual-hosted git repository.
pinal pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 195ba5bb0 ATLAS-3403 : Term assigned to historical entity is not
visible in Search results page
195ba5bb0 is described below
commit 195ba5bb07ea0bc5c68ec77753336b9844e1937c
Author: chaitali borole <[email protected]>
AuthorDate: Thu Nov 17 17:01:17 2022 +0530
ATLAS-3403 : Term assigned to historical entity is not visible in Search
results page
Signed-off-by: Pinal Shah <[email protected]>
(cherry picked from commit e51e16aa3c93a5443cb223666aa188b6d70a22f4)
---
.../store/graph/v2/EntityGraphRetriever.java | 2 +-
.../apache/atlas/glossary/GlossaryServiceTest.java | 42 ++++++++++++++++++++++
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java
index 0ed418330..b96d5ce30 100644
---
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java
+++
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java
@@ -901,7 +901,7 @@ public class EntityGraphRetriever {
if (edges != null) {
for (final AtlasEdge edge : (Iterable<AtlasEdge>) edges) {
- if (edge != null && GraphHelper.getStatus(edge) !=
AtlasEntity.Status.DELETED) {
+ if (edge != null) {
ret.add(toTermAssignmentHeader(edge));
}
}
diff --git
a/repository/src/test/java/org/apache/atlas/glossary/GlossaryServiceTest.java
b/repository/src/test/java/org/apache/atlas/glossary/GlossaryServiceTest.java
index 27717c313..007b2f24e 100644
---
a/repository/src/test/java/org/apache/atlas/glossary/GlossaryServiceTest.java
+++
b/repository/src/test/java/org/apache/atlas/glossary/GlossaryServiceTest.java
@@ -21,7 +21,9 @@ import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.SortOrder;
import org.apache.atlas.TestModules;
import org.apache.atlas.bulkimport.BulkImportResponse;
+import org.apache.atlas.discovery.AtlasDiscoveryService;
import org.apache.atlas.exception.AtlasBaseException;
+import org.apache.atlas.model.discovery.SearchParameters;
import org.apache.atlas.model.glossary.AtlasGlossary;
import org.apache.atlas.model.glossary.AtlasGlossaryCategory;
import org.apache.atlas.model.glossary.AtlasGlossaryTerm;
@@ -30,6 +32,7 @@ import
org.apache.atlas.model.glossary.relations.AtlasGlossaryHeader;
import org.apache.atlas.model.glossary.relations.AtlasRelatedCategoryHeader;
import org.apache.atlas.model.glossary.relations.AtlasRelatedTermHeader;
import org.apache.atlas.model.glossary.relations.AtlasTermCategorizationHeader;
+import org.apache.atlas.model.glossary.relations.AtlasTermAssignmentHeader;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntityHeader;
@@ -40,6 +43,7 @@ import org.apache.atlas.model.typedef.AtlasTypesDef;
import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.repository.store.graph.v2.AtlasEntityStream;
import org.apache.atlas.store.AtlasTypeDefStore;
+import org.apache.atlas.type.AtlasType;
import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.atlas.util.FileUtils;
import org.apache.atlas.utils.AtlasJson;
@@ -90,6 +94,8 @@ public class GlossaryServiceTest {
private AtlasGlossaryCategory customerCategory, accountCategory,
mortgageCategory;
private AtlasRelatedObjectId relatedObjectId;
+ @Inject
+ private AtlasDiscoveryService discoveryService;
public static final String CSV_FILES = "/csvFiles/";
public static final String EXCEL_FILES = "/excelFiles/";
@@ -291,6 +297,42 @@ public class GlossaryServiceTest {
fail("Term creation with relation should've succeeded", e);
}
}
+ @Test(groups = "Glossary.UPDATE", dependsOnGroups = "Glossary.CREATE")
+ public void testTermAfterEntityIsDeleted() throws AtlasBaseException {
+ SearchParameters params = new SearchParameters();
+ params.setTypeName("Asset");
+ AtlasTermAssignmentHeader loan = new AtlasTermAssignmentHeader();
+ loan.setTermGuid(fixedRateMortgage.getGuid());
+ loan.setRelationGuid(fixedRateMortgage.getAnchor().getRelationGuid());
+ loan.setQualifiedName(fixedRateMortgage.getQualifiedName());
+ AtlasEntity assetEntity = new AtlasEntity("Asset");
+ assetEntity.setAttribute("qualifiedName", "testAsset");
+ assetEntity.setAttribute("name", "testAsset");
+ assetEntity.addMeaning(loan);
+ try {
+
+ EntityMutationResponse response = entityStore.createOrUpdate(new
AtlasEntityStream(assetEntity), false);
+ AtlasEntityHeader firstEntityCreated =
response.getFirstEntityCreated();
+ relatedObjectId = new AtlasRelatedObjectId();
+ relatedObjectId.setGuid(firstEntityCreated.getGuid());
+ relatedObjectId.setTypeName(firstEntityCreated.getTypeName());
+ assertNotNull(relatedObjectId);
+ } catch (AtlasBaseException e) {
+ fail("Entity creation should've succeeded", e);
+ }
+ try {
+ glossaryService.assignTermToEntities(fixedRateMortgage.getGuid(),
Arrays.asList(relatedObjectId));
+ } catch (AtlasBaseException e) {
+ fail("Term assignment to asset should've succeeded", e);
+ }
+ try {
+ entityStore.deleteById(relatedObjectId.getGuid());
+ List<AtlasEntityHeader> entityHeaders =
discoveryService.searchWithParameters(params).getEntities();
+
assertNotNull(AtlasType.toJson(entityHeaders.get(0).getMeaningNames()));
+ } catch (AtlasBaseException e) {
+ fail("Entity delete should've succeeded");
+ }
+ }
@Test(groups = "Glossary.CREATE" , dependsOnMethods =
"testCategoryCreation")
public void testTermCreationWithCategory() {