use of org.apache.atlas.bulkimport.BulkImportResponse in project atlas by apache.
the class EntityV2JerseyResourceIT method testImportBMAttributes.
// TODO Enable this test after fixing the BulkImportResponse Deserialization issue.
@Test(dependsOnMethods = "testSubmitEntity", enabled = false)
public void testImportBMAttributes() throws AtlasServiceException {
BulkImportResponse response = atlasClientV2.bulkUpdateBusinessAttributes(TestResourceFileUtils.getTestFilePath("template_metadata.csv"));
assertNotNull(response);
}
use of org.apache.atlas.bulkimport.BulkImportResponse in project atlas by apache.
the class AtlasEntityStoreV2 method bulkCreateOrUpdateBusinessAttributes.
@Override
@GraphTransaction
public BulkImportResponse bulkCreateOrUpdateBusinessAttributes(InputStream inputStream, String fileName) throws AtlasBaseException {
BulkImportResponse ret = new BulkImportResponse();
if (StringUtils.isBlank(fileName)) {
throw new AtlasBaseException(AtlasErrorCode.FILE_NAME_NOT_FOUND, fileName);
}
List<String[]> fileData = FileUtils.readFileData(fileName, inputStream);
Map<String, AtlasEntity> attributesToAssociate = getBusinessMetadataDefList(fileData, ret);
for (AtlasEntity entity : attributesToAssociate.values()) {
Map<String, Map<String, Object>> businessAttributes = entity.getBusinessAttributes();
String guid = entity.getGuid();
try {
addOrUpdateBusinessAttributes(guid, businessAttributes, true);
ret.addToSuccessImportInfoList(new ImportInfo(guid, businessAttributes.toString()));
} catch (Exception e) {
LOG.error("Error occurred while updating BusinessMetadata Attributes for Entity " + guid);
ret.addToFailedImportInfoList(new ImportInfo(guid, businessAttributes.toString(), FAILED, e.getMessage()));
}
}
return ret;
}
use of org.apache.atlas.bulkimport.BulkImportResponse in project atlas by apache.
the class GlossaryServiceTest method testInvalidFileException.
@Test
public void testInvalidFileException() {
InputStream inputStream = getFile(EXCEL_FILES, "invalid_xls.xls");
try {
BulkImportResponse bulkImportResponse = glossaryService.importGlossaryData(inputStream, "invalid_xls.xls");
fail("Error occurred : Failed to recognize the invalid xls file.");
} catch (AtlasBaseException e) {
assertEquals(e.getMessage(), "Invalid XLS file");
}
}
use of org.apache.atlas.bulkimport.BulkImportResponse in project atlas by apache.
the class GlossaryServiceTest method testImportGlossaryData.
@Test(dependsOnGroups = "Glossary.CREATE")
public void testImportGlossaryData() {
try {
InputStream inputStream = getFile(CSV_FILES, "template_1.csv");
BulkImportResponse bulkImportResponse = glossaryService.importGlossaryData(inputStream, "template_1.csv");
assertNotNull(bulkImportResponse);
assertEquals(bulkImportResponse.getSuccessImportInfoList().size(), 1);
InputStream inputStream1 = getFile(EXCEL_FILES, "template_1.xlsx");
BulkImportResponse bulkImportResponse1 = glossaryService.importGlossaryData(inputStream1, "template_1.xlsx");
assertNotNull(bulkImportResponse1);
assertEquals(bulkImportResponse1.getSuccessImportInfoList().size(), 1);
// With circular dependent relations
InputStream inputStream2 = getFile(CSV_FILES, "template_with_circular_relationship.csv");
BulkImportResponse bulkImportResponse2 = glossaryService.importGlossaryData(inputStream2, "template_with_circular_relationship.csv");
assertNotNull(bulkImportResponse2);
assertEquals(bulkImportResponse2.getSuccessImportInfoList().size(), 3);
assertEquals(bulkImportResponse2.getFailedImportInfoList().size(), 0);
} catch (AtlasBaseException e) {
fail("The GlossaryTerm should have been created " + e);
}
}
use of org.apache.atlas.bulkimport.BulkImportResponse in project atlas by apache.
the class GlossaryClientV2IT method testImportGlossaryData.
@Test()
public void testImportGlossaryData() {
try {
String filePath = TestResourceFileUtils.getTestFilePath("template.csv");
BulkImportResponse terms = atlasClientV2.importGlossary(filePath);
assertNotNull(terms);
assertEquals(terms.getSuccessImportInfoList().size(), 1);
} catch (AtlasServiceException ex) {
fail("Import GlossaryData should've succeeded : " + ex);
}
}
Aggregations