use of org.apache.atlas.model.glossary.AtlasGlossaryTerm in project atlas by apache.
the class GlossaryClientV2IT method testGetGlossaryTerms.
@Test(dependsOnMethods = "testCreateTerm")
public void testGetGlossaryTerms() throws Exception {
AtlasRelatedTermHeader relatedTermHeader = new AtlasRelatedTermHeader();
relatedTermHeader.setTermGuid(educationTerm.getGuid());
relatedTermHeader.setDescription("test description");
relatedTermHeader.setExpression("test expression");
relatedTermHeader.setSource("School");
relatedTermHeader.setSteward("School");
relatedTermHeader.setStatus(AtlasTermRelationshipStatus.ACTIVE);
schoolEducationTerm = new AtlasGlossaryTerm();
AtlasGlossaryHeader header = new AtlasGlossaryHeader();
header.setGlossaryGuid(educationGlossary.getGuid());
header.setDisplayText(educationGlossary.getName());
schoolEducationTerm.setAnchor(header);
schoolEducationTerm.setName("termForSchool");
schoolEducationTerm.setSeeAlso(Collections.singleton(relatedTermHeader));
schoolEducationTerm = clientV2.createGlossaryTerm(schoolEducationTerm);
assertNotNull(schoolEducationTerm);
assertNotNull(schoolEducationTerm.getGuid());
// Getting multiple terms
List<AtlasGlossaryTerm> terms = atlasClientV2.getGlossaryTerms(educationGlossary.getGuid(), "ASC", 2, 0);
assertNotNull(terms);
assertEquals(terms.size(), 2);
}
use of org.apache.atlas.model.glossary.AtlasGlossaryTerm in project atlas by apache.
the class AtlasGlossaryTermDTO method from.
@Override
public AtlasGlossaryTerm from(final AtlasEntity entity) {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasGlossaryTermDTO.from()", entity);
}
Objects.requireNonNull(entity, "entity");
AtlasGlossaryTerm ret = new AtlasGlossaryTerm();
ret.setGuid(entity.getGuid());
ret.setQualifiedName((String) entity.getAttribute("qualifiedName"));
ret.setName((String) entity.getAttribute("name"));
ret.setShortDescription((String) entity.getAttribute("shortDescription"));
ret.setLongDescription((String) entity.getAttribute("longDescription"));
ret.setExamples((List<String>) entity.getAttribute("examples"));
ret.setAbbreviation((String) entity.getAttribute("abbreviation"));
ret.setUsage((String) entity.getAttribute("usage"));
ret.setAdditionalAttributes((Map) entity.getAttribute("additionalAttributes"));
Object anchor = entity.getRelationshipAttribute("anchor");
if (anchor instanceof AtlasRelatedObjectId) {
LOG.debug("Processing anchor");
ret.setAnchor(constructGlossaryId((AtlasRelatedObjectId) anchor));
}
Object categories = entity.getRelationshipAttribute("categories");
if (categories instanceof Collection) {
LOG.debug("Processing categories");
for (Object category : (Collection) categories) {
if (category instanceof AtlasRelatedObjectId) {
ret.addCategory(constructTermCategorizationId((AtlasRelatedObjectId) category));
}
}
}
// ret.setContextRelevantTerms(toRelatedObjectIdsSet(entity.getRelationshipAttribute("contextRelevantTerms")));
// ret.setUsedInContexts(toRelatedObjectIdsSet(entity.getRelationshipAttribute("usedInContexts")));
Object assignedEntities = entity.getRelationshipAttribute("assignedEntities");
if (assignedEntities instanceof Collection) {
LOG.debug("Processing assigned entities");
for (Object assignedEntity : (Collection) assignedEntities) {
if (assignedEntity instanceof AtlasRelatedObjectId) {
AtlasRelatedObjectId id = (AtlasRelatedObjectId) assignedEntity;
// Since the edges are not a hard delete we need to filter the DELETED ones
if (id.getRelationshipStatus() == AtlasRelationship.Status.ACTIVE) {
ret.addAssignedEntity(id);
}
}
}
}
Object seeAlso = entity.getRelationshipAttribute("seeAlso");
if (seeAlso instanceof Collection && CollectionUtils.isNotEmpty((Collection) seeAlso)) {
LOG.debug("Processing RelatedTerm(seeAlso)");
ret.setSeeAlso(toRelatedTermIdsSet(seeAlso));
}
Object synonyms = entity.getRelationshipAttribute("synonyms");
if (synonyms instanceof Collection && CollectionUtils.isNotEmpty((Collection) synonyms)) {
LOG.debug("Processing Synonym(synonyms)");
ret.setSynonyms(toRelatedTermIdsSet(synonyms));
}
Object antonyms = entity.getRelationshipAttribute("antonyms");
if (antonyms instanceof Collection && CollectionUtils.isNotEmpty((Collection) antonyms)) {
LOG.debug("Processing Antonym(antonyms)");
ret.setAntonyms(toRelatedTermIdsSet(antonyms));
}
Object preferredTerms = entity.getRelationshipAttribute("preferredTerms");
if (preferredTerms instanceof Collection && CollectionUtils.isNotEmpty((Collection) preferredTerms)) {
LOG.debug("Processing preferredTerm(preferredTerms)");
ret.setPreferredTerms(toRelatedTermIdsSet(preferredTerms));
}
Object preferredToTerms = entity.getRelationshipAttribute("preferredToTerms");
if (preferredToTerms instanceof Collection && CollectionUtils.isNotEmpty((Collection) preferredToTerms)) {
LOG.debug("Processing preferredTerm(preferredToTerms)");
ret.setPreferredToTerms(toRelatedTermIdsSet(preferredToTerms));
}
Object replacementTerms = entity.getRelationshipAttribute("replacementTerms");
if (replacementTerms instanceof Collection && CollectionUtils.isNotEmpty((Collection) replacementTerms)) {
LOG.debug("Processing ReplacementTerm(replacementTerms)");
ret.setReplacementTerms(toRelatedTermIdsSet(replacementTerms));
}
Object replacedBy = entity.getRelationshipAttribute("replacedBy");
if (replacedBy instanceof Collection && CollectionUtils.isNotEmpty((Collection) replacedBy)) {
LOG.debug("Processing ReplacementTerm(replacedBy)");
ret.setReplacedBy(toRelatedTermIdsSet(replacedBy));
}
Object translationTerms = entity.getRelationshipAttribute("translationTerms");
if (translationTerms instanceof Collection && CollectionUtils.isNotEmpty((Collection) translationTerms)) {
LOG.debug("Processing Translation(translationTerms)");
ret.setTranslationTerms(toRelatedTermIdsSet(translationTerms));
}
Object translatedTerms = entity.getRelationshipAttribute("translatedTerms");
if (translatedTerms instanceof Collection && CollectionUtils.isNotEmpty((Collection) translatedTerms)) {
LOG.debug("Processing Translation(translatedTerms)");
ret.setTranslatedTerms(toRelatedTermIdsSet(translatedTerms));
}
Object isA = entity.getRelationshipAttribute("isA");
if (isA instanceof Collection && CollectionUtils.isNotEmpty((Collection) isA)) {
LOG.debug("Processing Classifies(isA)");
ret.setIsA(toRelatedTermIdsSet(isA));
}
Object classifies = entity.getRelationshipAttribute("classifies");
if (classifies instanceof Collection && CollectionUtils.isNotEmpty((Collection) classifies)) {
LOG.debug("Processing Classifies(classifies)");
ret.setClassifies(toRelatedTermIdsSet(classifies));
}
Object validValues = entity.getRelationshipAttribute("validValues");
if (validValues instanceof Collection && CollectionUtils.isNotEmpty((Collection) validValues)) {
LOG.debug("Processing validValue(validValues)");
ret.setValidValues(toRelatedTermIdsSet(validValues));
}
Object validValuesFor = entity.getRelationshipAttribute("validValuesFor");
if (validValuesFor instanceof Collection && CollectionUtils.isNotEmpty((Collection) validValuesFor)) {
LOG.debug("Processing validValue(validValuesFor)");
ret.setValidValuesFor(toRelatedTermIdsSet(validValuesFor));
}
if (CollectionUtils.isNotEmpty(entity.getClassifications())) {
if (LOG.isDebugEnabled()) {
LOG.debug("Processing term classifications");
}
ret.setClassifications(entity.getClassifications());
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasGlossaryTermDTO.from() : {}", ret);
}
return ret;
}
use of org.apache.atlas.model.glossary.AtlasGlossaryTerm in project atlas by apache.
the class AtlasGlossaryTermDTO method from.
@Override
public AtlasGlossaryTerm from(final AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo) {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasGlossaryTermDTO.from()", entityWithExtInfo);
}
Objects.requireNonNull(entityWithExtInfo, "entityWithExtInfo");
AtlasGlossaryTerm ret = from(entityWithExtInfo.getEntity());
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasGlossaryTermDTO.from() : {}", ret);
}
return ret;
}
use of org.apache.atlas.model.glossary.AtlasGlossaryTerm in project atlas by apache.
the class TestEntitiesREST method createTerms.
private void createTerms() throws AtlasBaseException {
term1 = new AtlasGlossaryTerm();
// Glossary anchor
AtlasGlossaryHeader glossaryId = new AtlasGlossaryHeader();
glossaryId.setGlossaryGuid(glossary.getGuid());
term1.setName("term1");
term1.setShortDescription("Short description");
term1.setLongDescription("Long description");
term1.setAbbreviation("CHK");
term1.setExamples(Arrays.asList("Personal", "Joint"));
term1.setUsage("N/A");
term1.setAnchor(glossaryId);
AtlasGlossaryTerm created1 = glossaryService.createTerm(term1);
term1.setGuid(created1.getGuid());
}
use of org.apache.atlas.model.glossary.AtlasGlossaryTerm in project atlas by apache.
the class BasicTestSetup method assignGlossary.
public void assignGlossary() {
try {
AtlasGlossary glossary = new AtlasGlossary();
glossary.setName(SALES_GLOSSARY);
glossary = glossaryService.createGlossary(glossary);
AtlasGlossaryTerm term = new AtlasGlossaryTerm();
term.setAnchor(new AtlasGlossaryHeader(glossary.getGuid()));
term.setName(SALES_TERM);
term = glossaryService.createTerm(term);
AtlasGlossaryTerm modernTrade = new AtlasGlossaryTerm();
modernTrade.setAnchor(new AtlasGlossaryHeader(glossary.getGuid()));
modernTrade.setName(MODERNTRADE_TERM);
modernTrade = glossaryService.createTerm(modernTrade);
AtlasGlossaryTerm ecomm = new AtlasGlossaryTerm();
ecomm.setAnchor(new AtlasGlossaryHeader(glossary.getGuid()));
ecomm.setName(ECOMMERCE_TERM);
ecomm = glossaryService.createTerm(ecomm);
List<AtlasRelatedObjectId> guids = new ArrayList<>();
List<AtlasRelatedObjectId> mordernTradeGuids = new ArrayList<>();
List<AtlasRelatedObjectId> ecomGuid = new ArrayList<>();
for (AtlasEntityHeader p : hiveEntities.getCreatedEntities()) {
if (StringUtils.equals(p.getTypeName(), HIVE_TABLE_TYPE)) {
AtlasRelatedObjectId obj = new AtlasRelatedObjectId();
obj.setGuid(p.getGuid());
obj.setTypeName(p.getTypeName());
guids.add(obj);
if (p.getAttribute("name").equals(timeDim.getAttribute("name"))) {
timeDim.setGuid(p.getGuid());
AtlasRelatedObjectId obj1 = new AtlasRelatedObjectId();
obj1.setGuid(p.getGuid());
obj1.setTypeName(p.getTypeName());
mordernTradeGuids.add(obj1);
} else if (p.getAttribute("name").equals(productDim.getAttribute("name"))) {
productDim.setGuid(p.getGuid());
AtlasRelatedObjectId obj2 = new AtlasRelatedObjectId();
obj2.setGuid(p.getGuid());
obj2.setTypeName(p.getTypeName());
ecomGuid.add(obj2);
} else if (p.getAttribute("name").equals(loggingFactMonthly.getAttribute("name"))) {
loggingFactMonthly.setGuid(p.getGuid());
AtlasRelatedObjectId obj3 = new AtlasRelatedObjectId();
obj3.setGuid(p.getGuid());
obj3.setTypeName(p.getTypeName());
mordernTradeGuids.add(obj3);
}
}
}
glossaryService.assignTermToEntities(term.getGuid(), guids);
glossaryService.assignTermToEntities(modernTrade.getGuid(), mordernTradeGuids);
glossaryService.assignTermToEntities(ecomm.getGuid(), ecomGuid);
} catch (AtlasBaseException e) {
fail("Failed to assign glossary term");
}
}
Aggregations