private void map(AtlasEntity entity, AtlasEntityExtInfo entityExtInfo, StringBuilder sb, Set<String> processedGuids) throws AtlasBaseException { if (entity == null || processedGuids.contains(entity.getGuid())) { return; } processedGuids.add(entity.getGuid()); sb.append(entity.getTypeName()).append(FULL_TEXT_DELIMITER); mapAttributes(entity.getAttributes(), entityExtInfo, sb, processedGuids); List<AtlasClassification> classifications = entity.getClassifications(); if (CollectionUtils.isNotEmpty(classifications)) { for (AtlasClassification classification : classifications) { sb.append(classification.getTypeName()).append(FULL_TEXT_DELIMITER); mapAttributes(classification.getAttributes(), entityExtInfo, sb, processedGuids); } } }
public AtlasEntityHeader(AtlasEntity entity) { super(entity.getTypeName(), entity.getAttributes()); setGuid(entity.getGuid()); setClassifications(entity.getClassifications()); if (CollectionUtils.isNotEmpty(entity.getClassifications())) { this.classificationNames = new ArrayList<>(entity.getClassifications().size()); for (AtlasClassification classification : entity.getClassifications()) { this.classificationNames.add(classification.getTypeName()); } } }
@Override public void apply(AtlasTransformableEntity transformableEntity) { AtlasEntity entity = transformableEntity.getEntity(); if (entity.getClassifications() == null) { entity.setClassifications(new ArrayList<>()); } boolean hasClassification = false; for (AtlasClassification c : entity.getClassifications()) { hasClassification = c.getTypeName().equals(classificationName); if (hasClassification) { break; } } if (!hasClassification) { entity.getClassifications().add(new AtlasClassification(classificationName)); } }
private void addTypes(AtlasEntity entity, ExportContext context) { addEntityType(entity.getTypeName(), context); if(CollectionUtils.isNotEmpty(entity.getClassifications())) { for (AtlasClassification c : entity.getClassifications()) { addClassificationType(c.getTypeName(), context); } } }
public void addTypes(AtlasEntity entity, ExportService.ExportContext context) { addEntityType(entity.getTypeName(), context); if(CollectionUtils.isNotEmpty(entity.getClassifications())) { for (AtlasClassification c : entity.getClassifications()) { addClassificationType(c.getTypeName(), context); } } }
private void assertTag(AtlasEntity entity, String tagName) { assertTrue(entity.getClassifications().size() > 0, String.format("%s not tagged", entity.getTypeName())); assertEquals(entity.getClassifications().get(0).getTypeName(), tagName); }
private void assertApplyTransform(List<BaseEntityHandler> handlers) { for (AtlasEntity entity : getAllEntities()) { applyTransforms(entity, handlers); if(entity.getTypeName().equals("hive_db") && entity.getAttribute("qualifiedName").equals("hr@cl1")) { assertNotNull(entity.getClassifications()); } else{ assertNull(entity.getClassifications()); } } }
private void map(AtlasEntity entity, AtlasEntityExtInfo entityExtInfo, StringBuilder sb, Set<String> processedGuids) throws AtlasBaseException { if (entity == null || processedGuids.contains(entity.getGuid())) { return; } processedGuids.add(entity.getGuid()); sb.append(entity.getTypeName()).append(FULL_TEXT_DELIMITER); Set<String> excludeAttributes = getExcludeAttributesForIndexText(entity.getTypeName()); mapAttributes(entity.getAttributes(), entityExtInfo, sb, processedGuids, excludeAttributes); List<AtlasClassification> classifications = entity.getClassifications(); if (CollectionUtils.isNotEmpty(classifications)) { for (AtlasClassification classification : classifications) { sb.append(classification.getTypeName()).append(FULL_TEXT_DELIMITER); Set<String> excludeClassificationAttributes = getExcludeAttributesForIndexText(classification.getTypeName()); mapAttributes(classification.getAttributes(), entityExtInfo, sb, processedGuids, excludeClassificationAttributes); } } }
@Test(dataProvider = "sales") public void importDB1(ZipSource zipSource) throws AtlasBaseException, IOException { loadBaseModel(); runAndVerifyQuickStart_v1_Import(importService, zipSource); assertEntityCount("DB_v1", "bfe88eb8-7556-403c-8210-647013f44a44", 1); AtlasEntity entity = assertEntity("Table_v1", "fe91bf93-eb0c-4638-8361-15937390c810"); assertEquals(entity.getClassifications().size(), 1); assertFalse(entity.getClassifications().get(0).isPropagate(), "Default propagate should be false"); }
private void assertClassificationExistInEntity(String entityName, String tagName, String sourceEntityGuid) throws AtlasBaseException { List<AtlasClassification> classifications = getEntity(entityName).getClassifications(); String classificationName = tagName; String entityGuid = sourceEntityGuid; if (CollectionUtils.isNotEmpty(classifications)) { boolean foundClassification = false; for (AtlasClassification c : classifications) { if (c.getTypeName().equals(classificationName) && c.getEntityGuid().equals(entityGuid)) { foundClassification = true; } } if (!foundClassification) { fail("Propagated classification is not present in entity!"); } } }
@Test(dataProvider = "tag-prop-2") public void importTagProp2(ZipSource zipSource) throws IOException, AtlasBaseException { loadBaseModel(); loadFsModel(); loadHiveModel(); runImportWithNoParameters(importService, zipSource); assertEntityCount("hive_db", "7d7d5a18-d992-457e-83c0-e36f5b95ebdb", 1); assertEntityCount("hive_table", "dbe729bb-c614-4e23-b845-3258efdf7a58", 1); AtlasEntity entity = assertEntity("hive_table", "092e9888-de96-4908-8be3-925ee72e3395"); assertEquals(entity.getClassifications().size(), 2); assertTrue(entity.getClassifications().get(0).isPropagate()); assertFalse(entity.getClassifications().get(0).getEntityGuid().equalsIgnoreCase(entity.getGuid())); assertFalse(entity.getClassifications().get(1).getEntityGuid().equalsIgnoreCase(entity.getGuid())); }
private void assertClassificationExistInEntity(String entityName, String tagName, String sourceEntityGuid) throws AtlasBaseException { List<AtlasClassification> classifications = getEntity(entityName).getClassifications(); String classificationName = tagName; String entityGuid = sourceEntityGuid; if (CollectionUtils.isNotEmpty(classifications)) { boolean foundClassification = false; for (AtlasClassification c : classifications) { if (c.getTypeName().equals(classificationName) && c.getEntityGuid().equals(entityGuid)) { foundClassification = true; } } if (!foundClassification) { fail("Propagated classification is not present in entity!"); } } }
private void assertClassificationNotExistInEntity(String entityName, AtlasClassification classification) throws AtlasBaseException { List<AtlasClassification> classifications = getEntity(entityName).getClassifications(); String classificationName = classification.getTypeName(); String entityGuid = classification.getEntityGuid(); if (CollectionUtils.isNotEmpty(classifications)) { for (AtlasClassification c : classifications) { if (c.getTypeName().equals(classificationName) && c.getEntityGuid().equals(entityGuid)) { fail("Propagated classification should not be present in entity!"); } } } }
private void assertClassificationNotExistInEntity(String entityName, AtlasClassification classification) throws AtlasBaseException { List<AtlasClassification> classifications = getEntity(entityName).getClassifications(); String classificationName = classification.getTypeName(); String entityGuid = classification.getEntityGuid(); if (CollectionUtils.isNotEmpty(classifications)) { for (AtlasClassification c : classifications) { if (c.getTypeName().equals(classificationName) && c.getEntityGuid().equals(entityGuid)) { fail("Propagated classification should not be present in entity!"); } } } }
@Test(dataProvider = "zipFileStocksFloat") public void attemptToSerializeLongFloats(ZipSource zipSource) throws IOException, AtlasBaseException { Assert.assertTrue(zipSource.hasNext()); assertTrue(zipSource.hasNext()); assertTrue(zipSource.hasNext()); AtlasEntity.AtlasEntityWithExtInfo e = zipSource.getNextEntityWithExtInfo(); assertNotNull(e); assertTrue(e.getEntity().getClassifications().size() > 0); assertNotNull(e.getEntity().getClassifications().get(0).getAttribute("fv")); assertEquals(e.getEntity().getClassifications().get(0).getAttribute("fv").toString(), "3.4028235E+38"); assertTrue(zipSource.hasNext()); }
@Test(dataProvider = "zipFileStocksFloat") public void attemptToSerializeLongFloats(ZipSource zipSource) throws IOException, AtlasBaseException { Assert.assertTrue(zipSource.hasNext()); assertTrue(zipSource.hasNext()); assertTrue(zipSource.hasNext()); AtlasEntity.AtlasEntityWithExtInfo e = zipSource.getNextEntityWithExtInfo(); assertNotNull(e); assertTrue(e.getEntity().getClassifications().size() > 0); assertNotNull(e.getEntity().getClassifications().get(0).getAttribute("fv")); assertEquals(e.getEntity().getClassifications().get(0).getAttribute("fv").toString(), "3.4028235E+38"); assertTrue(zipSource.hasNext()); }
AtlasEntity tblEntityFromDb = getEntityFromStore(tblEntityGuid); Set<String> actualDBClassifications = new HashSet<>(CollectionUtils.collect(dbEntityFromDb.getClassifications(), o -> ((AtlasClassification) o).getTypeName())); Set<String> actualTblClassifications = new HashSet<>(CollectionUtils.collect(tblEntityFromDb.getClassifications(), o -> ((AtlasClassification) o).getTypeName())); Set<String> actualDBAssociatedEntityGuid = new HashSet<>(CollectionUtils.collect(dbEntityFromDb.getClassifications(), o -> ((AtlasClassification) o).getEntityGuid())); Set<String> actualTblAssociatedEntityGuid = new HashSet<>(CollectionUtils.collect(tblEntityFromDb.getClassifications(), o -> ((AtlasClassification) o).getEntityGuid()));
@Test(dependsOnMethods = "testCreate") public void associateMultipleTagsToOneEntity() throws AtlasBaseException { final String TAG_NAME = "tag_xy"; final String TAG_NAME_2 = TAG_NAME + "_2"; final String TAG_ATTRIBUTE_NAME = "testAttribute"; final String TAG_ATTRIBUTE_VALUE = "test-string"; final String TAG_ATTRIBUTE_VALUE_2 = TAG_ATTRIBUTE_VALUE + "-2"; createTag(TAG_NAME, "string"); createTag(TAG_NAME_2, "string"); List<AtlasClassification> addedClassifications = new ArrayList<>(); addedClassifications.add(new AtlasClassification(TAG_NAME, TAG_ATTRIBUTE_NAME, TAG_ATTRIBUTE_VALUE)); addedClassifications.add(new AtlasClassification(TAG_NAME_2, TAG_ATTRIBUTE_NAME, TAG_ATTRIBUTE_VALUE_2)); entityStore.addClassifications(dbEntityGuid, addedClassifications); AtlasEntity dbEntityFromDb = getEntityFromStore(dbEntityGuid); List<String> actualClassifications = (List<String>) CollectionUtils.collect(dbEntityFromDb.getClassifications(), o -> ((AtlasClassification) o).getTypeName()); Set<String> classificationSet = new HashSet<>(actualClassifications); assertTrue(classificationSet.contains(TAG_NAME)); assertTrue(classificationSet.contains(TAG_NAME_2)); for (String actualClassificationName : actualClassifications) { entityStore.deleteClassification(dbEntityGuid, actualClassificationName); } }
public AtlasEntity(AtlasEntity other) { super(other); if (other != null) { setGuid(other.getGuid()); setStatus(other.getStatus()); setCreatedBy(other.getCreatedBy()); setUpdatedBy(other.getUpdatedBy()); setCreateTime(other.getCreateTime()); setUpdateTime(other.getUpdateTime()); setVersion(other.getVersion()); setClassifications(other.getClassifications()); } }
public AtlasEntity(AtlasEntity other) { super(other); if (other != null) { setGuid(other.getGuid()); setHomeId(other.getHomeId()); setIsProxy(other.isProxy()); setStatus(other.getStatus()); setCreatedBy(other.getCreatedBy()); setUpdatedBy(other.getUpdatedBy()); setCreateTime(other.getCreateTime()); setUpdateTime(other.getUpdateTime()); setVersion(other.getVersion()); setClassifications(other.getClassifications()); } }