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()");
}
}
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;
}
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;
}
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);
}
Aggregations