Search in sources :

Example 26 with AtlasGlossary

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

the class GlossaryService method deleteGlossary.

@GraphTransaction
public void deleteGlossary(String glossaryGuid) throws AtlasBaseException {
    if (DEBUG_ENABLED) {
        LOG.debug("==> GlossaryService.deleteGlossary({})", glossaryGuid);
    }
    if (Objects.isNull(glossaryGuid)) {
        throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "glossaryGuid is null/empty");
    }
    AtlasGlossary storeObject = dataAccess.load(getGlossarySkeleton(glossaryGuid));
    Set<AtlasRelatedTermHeader> terms = storeObject.getTerms();
    deleteTerms(storeObject, terms);
    Set<AtlasRelatedCategoryHeader> categories = storeObject.getCategories();
    deleteCategories(storeObject, categories);
    // Once all relations are deleted, then delete the Glossary
    dataAccess.delete(glossaryGuid);
    if (DEBUG_ENABLED) {
        LOG.debug("<== GlossaryService.deleteGlossary()");
    }
}
Also used : AtlasGlossary(org.apache.atlas.model.glossary.AtlasGlossary) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasRelatedTermHeader(org.apache.atlas.model.glossary.relations.AtlasRelatedTermHeader) AtlasRelatedCategoryHeader(org.apache.atlas.model.glossary.relations.AtlasRelatedCategoryHeader) GraphTransaction(org.apache.atlas.annotation.GraphTransaction)

Example 27 with AtlasGlossary

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

the class GlossaryService method getDetailedGlossary.

/**
 * Get specific glossary
 *
 * @param glossaryGuid unique identifier
 * @return Glossary corresponding to specified glossaryGuid
 * @throws AtlasBaseException
 */
@GraphTransaction
public AtlasGlossary.AtlasGlossaryExtInfo getDetailedGlossary(String glossaryGuid) throws AtlasBaseException {
    if (DEBUG_ENABLED) {
        LOG.debug("==> GlossaryService.getGlossary({})", glossaryGuid);
    }
    if (Objects.isNull(glossaryGuid)) {
        throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "glossaryGuid is null/empty");
    }
    AtlasGlossary atlasGlossary = getGlossarySkeleton(glossaryGuid);
    AtlasGlossary glossary = dataAccess.load(atlasGlossary);
    AtlasGlossary.AtlasGlossaryExtInfo ret = new AtlasGlossary.AtlasGlossaryExtInfo(glossary);
    // Load all linked terms
    if (CollectionUtils.isNotEmpty(ret.getTerms())) {
        List<AtlasGlossaryTerm> termsToLoad = ret.getTerms().stream().map(id -> getAtlasGlossaryTermSkeleton(id.getTermGuid())).collect(Collectors.toList());
        Iterable<AtlasGlossaryTerm> glossaryTerms = dataAccess.load(termsToLoad);
        glossaryTerms.forEach(ret::addTermInfo);
    }
    // Load all linked categories
    if (CollectionUtils.isNotEmpty(ret.getCategories())) {
        List<AtlasGlossaryCategory> categoriesToLoad = ret.getCategories().stream().map(id -> getAtlasGlossaryCategorySkeleton(id.getCategoryGuid())).collect(Collectors.toList());
        Iterable<AtlasGlossaryCategory> glossaryCategories = dataAccess.load(categoriesToLoad);
        glossaryCategories.forEach(ret::addCategoryInfo);
    }
    if (DEBUG_ENABLED) {
        LOG.debug("<== GlossaryService.getGlossary() : {}", ret);
    }
    return ret;
}
Also used : AtlasGlossary(org.apache.atlas.model.glossary.AtlasGlossary) StringUtils(org.apache.commons.lang.StringUtils) AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasJson(org.apache.atlas.utils.AtlasJson) GlossaryUtils.getAtlasGlossaryCategorySkeleton(org.apache.atlas.glossary.GlossaryUtils.getAtlasGlossaryCategorySkeleton) GlossaryUtils.getAtlasGlossaryTermSkeleton(org.apache.atlas.glossary.GlossaryUtils.getAtlasGlossaryTermSkeleton) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ImportInfo(org.apache.atlas.bulkimport.BulkImportResponse.ImportInfo) ArrayList(java.util.ArrayList) AtlasGlossaryDTO(org.apache.atlas.repository.ogm.glossary.AtlasGlossaryDTO) Inject(javax.inject.Inject) AtlasErrorCode(org.apache.atlas.AtlasErrorCode) GraphTransaction(org.apache.atlas.annotation.GraphTransaction) AtlasEntityChangeNotifier(org.apache.atlas.repository.store.graph.v2.AtlasEntityChangeNotifier) CollectionUtils(org.apache.commons.collections.CollectionUtils) Service(org.springframework.stereotype.Service) Map(java.util.Map) FileUtils(org.apache.atlas.util.FileUtils) AtlasTermCategorizationHeader(org.apache.atlas.model.glossary.relations.AtlasTermCategorizationHeader) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) AtlasGraphUtilsV2(org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2) AtlasGlossaryCategory(org.apache.atlas.model.glossary.AtlasGlossaryCategory) DataAccess(org.apache.atlas.repository.ogm.DataAccess) AtlasRelatedCategoryHeader(org.apache.atlas.model.glossary.relations.AtlasRelatedCategoryHeader) AtlasRelatedObjectId(org.apache.atlas.model.instance.AtlasRelatedObjectId) AtlasTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry) SortOrder(org.apache.atlas.SortOrder) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) SUCCESS(org.apache.atlas.bulkimport.BulkImportResponse.ImportStatus.SUCCESS) AtlasEdgeDirection(org.apache.atlas.repository.graphdb.AtlasEdgeDirection) Collection(java.util.Collection) GlossaryUtils.getGlossarySkeleton(org.apache.atlas.glossary.GlossaryUtils.getGlossarySkeleton) Set(java.util.Set) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) AtlasEdge(org.apache.atlas.repository.graphdb.AtlasEdge) FAILED(org.apache.atlas.bulkimport.BulkImportResponse.ImportStatus.FAILED) AtlasRelationshipStore(org.apache.atlas.repository.store.graph.AtlasRelationshipStore) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) BulkImportResponse(org.apache.atlas.bulkimport.BulkImportResponse) AtlasRelatedTermHeader(org.apache.atlas.model.glossary.relations.AtlasRelatedTermHeader) Collections(java.util.Collections) AtlasGlossary(org.apache.atlas.model.glossary.AtlasGlossary) AtlasGlossaryTerm(org.apache.atlas.model.glossary.AtlasGlossaryTerm) InputStream(java.io.InputStream) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasGlossaryTerm(org.apache.atlas.model.glossary.AtlasGlossaryTerm) AtlasGlossaryCategory(org.apache.atlas.model.glossary.AtlasGlossaryCategory) GraphTransaction(org.apache.atlas.annotation.GraphTransaction)

Example 28 with AtlasGlossary

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

the class GlossaryUtils method getGlossarySkeleton.

public static AtlasGlossary getGlossarySkeleton(String glossaryGuid) {
    AtlasGlossary glossary = new AtlasGlossary();
    glossary.setGuid(glossaryGuid);
    return glossary;
}
Also used : AtlasGlossary(org.apache.atlas.model.glossary.AtlasGlossary)

Example 29 with AtlasGlossary

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

the class GlossaryExample method createGlossary.

public void createGlossary() throws Exception {
    AtlasGlossary glossary = new AtlasGlossary();
    glossary.setName(GLOSSARY_NAME);
    glossary.setLanguage("English");
    glossary.setShortDescription("This is a test Glossary");
    empGlossary = client.createGlossary(glossary);
}
Also used : AtlasGlossary(org.apache.atlas.model.glossary.AtlasGlossary)

Aggregations

AtlasGlossary (org.apache.atlas.model.glossary.AtlasGlossary)29 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)15 GraphTransaction (org.apache.atlas.annotation.GraphTransaction)8 AtlasRelatedCategoryHeader (org.apache.atlas.model.glossary.relations.AtlasRelatedCategoryHeader)6 Test (org.testng.annotations.Test)6 ArrayList (java.util.ArrayList)5 AtlasGlossaryHeader (org.apache.atlas.model.glossary.relations.AtlasGlossaryHeader)5 AtlasGlossaryCategory (org.apache.atlas.model.glossary.AtlasGlossaryCategory)4 AtlasGlossaryTerm (org.apache.atlas.model.glossary.AtlasGlossaryTerm)4 AtlasRelatedTermHeader (org.apache.atlas.model.glossary.relations.AtlasRelatedTermHeader)4 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Path (javax.ws.rs.Path)2 Timed (org.apache.atlas.annotation.Timed)2 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)2 AtlasRelatedObjectId (org.apache.atlas.model.instance.AtlasRelatedObjectId)2 AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)2 IOException (java.io.IOException)1