Search in sources :

Example 21 with AtlasGlossaryTerm

use of org.apache.atlas.model.glossary.AtlasGlossaryTerm in project atlas by apache.

the class GlossaryTermUtils method getGlossaryTermDataWithRelations.

protected List<AtlasGlossaryTerm> getGlossaryTermDataWithRelations(List<String[]> fileData, BulkImportResponse bulkImportResponse) throws AtlasBaseException {
    List<AtlasGlossaryTerm> glossaryTerms = new ArrayList<>();
    int rowCount = 1;
    for (String[] record : fileData) {
        List<String> failedTermMsgs = new ArrayList<>();
        if (ArrayUtils.isNotEmpty(record) && StringUtils.isNotBlank(record[INDEX_FOR_GLOSSARY_AT_RECORD])) {
            AtlasGlossaryTerm glossaryTerm = new AtlasGlossaryTerm();
            String glossaryName = record[INDEX_FOR_GLOSSARY_AT_RECORD];
            String glossaryGuid = glossaryNameGuidCache.get().get(glossaryName);
            if (StringUtils.isNotEmpty(glossaryGuid)) {
                glossaryTerm = populateGlossaryTermObject(failedTermMsgs, record, glossaryGuid, true);
                glossaryTerm.setQualifiedName(getGlossaryTermQualifiedName(glossaryTerm.getName(), glossaryName));
                glossaryTerms.add(glossaryTerm);
            }
            if (failedTermMsgs.size() > 0) {
                String failedTermMsg = StringUtils.join(failedTermMsgs, System.lineSeparator());
                String glossaryTermName = glossaryTerm.getName();
                bulkImportResponse.addToFailedImportInfoList(new ImportInfo(glossaryName, glossaryTermName, FAILED, failedTermMsg, rowCount));
            }
        }
        rowCount++;
    }
    return glossaryTerms;
}
Also used : AtlasGlossaryTerm(org.apache.atlas.model.glossary.AtlasGlossaryTerm) ArrayList(java.util.ArrayList) ImportInfo(org.apache.atlas.bulkimport.BulkImportResponse.ImportInfo)

Example 22 with AtlasGlossaryTerm

use of org.apache.atlas.model.glossary.AtlasGlossaryTerm in project atlas by apache.

the class GlossaryClientV2IT method testCreateTerm.

@Test(dependsOnMethods = "testCreateGlossary")
public void testCreateTerm() throws Exception {
    AtlasGlossaryTerm term = new AtlasGlossaryTerm();
    AtlasGlossaryHeader header = new AtlasGlossaryHeader();
    header.setGlossaryGuid(educationGlossary.getGuid());
    header.setDisplayText(educationGlossary.getName());
    term.setAnchor(header);
    term.setName("termForEducation");
    educationTerm = atlasClientV2.createGlossaryTerm(term);
    assertNotNull(educationTerm);
    assertNotNull(educationTerm.getGuid());
}
Also used : AtlasGlossaryHeader(org.apache.atlas.model.glossary.relations.AtlasGlossaryHeader) AtlasGlossaryTerm(org.apache.atlas.model.glossary.AtlasGlossaryTerm) Test(org.testng.annotations.Test)

Example 23 with AtlasGlossaryTerm

use of org.apache.atlas.model.glossary.AtlasGlossaryTerm in project atlas by apache.

the class GlossaryClientV2IT method testDisassociateTermAssignmentFromEntities.

@Test(dependsOnMethods = "testAssignTermToEntities")
public void testDisassociateTermAssignmentFromEntities() throws Exception {
    atlasClientV2.disassociateTermFromEntities(educationTerm.getGuid(), relatedObjectIds);
    AtlasGlossaryTerm term = atlasClientV2.getGlossaryTerm(educationTerm.getGuid());
    atlasClientV2.deleteEntityByGuid(entityHeader.getGuid());
    assertNotNull(term);
    assertNull(term.getAssignedEntities());
}
Also used : AtlasGlossaryTerm(org.apache.atlas.model.glossary.AtlasGlossaryTerm) Test(org.testng.annotations.Test)

Example 24 with AtlasGlossaryTerm

use of org.apache.atlas.model.glossary.AtlasGlossaryTerm in project atlas by apache.

the class GlossaryClientV2IT method testUpdateGlossaryTermByGuid.

@Test(dependsOnMethods = "testCreateGlossary")
public void testUpdateGlossaryTermByGuid() throws Exception {
    AtlasGlossaryTerm term = new AtlasGlossaryTerm(educationTerm);
    term.setAbbreviation("trm");
    AtlasGlossaryTerm responseTerm = atlasClientV2.updateGlossaryTermByGuid(educationTerm.getGuid(), term);
    assertNotNull(responseTerm);
    assertEquals(responseTerm.getAbbreviation(), term.getAbbreviation());
}
Also used : AtlasGlossaryTerm(org.apache.atlas.model.glossary.AtlasGlossaryTerm) Test(org.testng.annotations.Test)

Example 25 with AtlasGlossaryTerm

use of org.apache.atlas.model.glossary.AtlasGlossaryTerm in project atlas by apache.

the class GlossaryClientV2IT method testPartialUpdateTermByGuid.

@Test(dependsOnMethods = "testCreateGlossary")
public void testPartialUpdateTermByGuid() throws Exception {
    Map<String, String> partialUpdates = new HashMap<>();
    partialUpdates.put("shortDescription", "shortDescriptionTerm");
    partialUpdates.put("longDescription", "longDescriptionTerm");
    AtlasGlossaryTerm term = atlasClientV2.partialUpdateTermByGuid(educationTerm.getGuid(), partialUpdates);
    assertNotNull(term);
    assertEquals(term.getShortDescription(), "shortDescriptionTerm");
    assertEquals(term.getLongDescription(), "longDescriptionTerm");
}
Also used : HashMap(java.util.HashMap) AtlasGlossaryTerm(org.apache.atlas.model.glossary.AtlasGlossaryTerm) Test(org.testng.annotations.Test)

Aggregations

AtlasGlossaryTerm (org.apache.atlas.model.glossary.AtlasGlossaryTerm)41 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)22 GraphTransaction (org.apache.atlas.annotation.GraphTransaction)12 Test (org.testng.annotations.Test)11 ArrayList (java.util.ArrayList)9 AtlasGlossaryHeader (org.apache.atlas.model.glossary.relations.AtlasGlossaryHeader)7 ImportInfo (org.apache.atlas.bulkimport.BulkImportResponse.ImportInfo)5 AtlasRelatedTermHeader (org.apache.atlas.model.glossary.relations.AtlasRelatedTermHeader)5 AtlasRelatedObjectId (org.apache.atlas.model.instance.AtlasRelatedObjectId)5 List (java.util.List)4 Set (java.util.Set)4 AtlasGlossary (org.apache.atlas.model.glossary.AtlasGlossary)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 AtlasGlossaryCategory (org.apache.atlas.model.glossary.AtlasGlossaryCategory)3 Collection (java.util.Collection)2 Path (javax.ws.rs.Path)2 Timed (org.apache.atlas.annotation.Timed)2 BulkImportResponse (org.apache.atlas.bulkimport.BulkImportResponse)2 AtlasTermCategorizationHeader (org.apache.atlas.model.glossary.relations.AtlasTermCategorizationHeader)2