use of org.apache.atlas.model.glossary.relations.AtlasRelatedTermHeader in project atlas by apache.
the class AbstractGlossaryDTO method constructRelatedTermId.
protected AtlasRelatedTermHeader constructRelatedTermId(AtlasRelatedObjectId relatedObjectId) {
AtlasRelatedTermHeader ret = new AtlasRelatedTermHeader();
ret.setTermGuid(relatedObjectId.getGuid());
ret.setRelationGuid(relatedObjectId.getRelationshipGuid());
ret.setDisplayText(relatedObjectId.getDisplayText());
AtlasStruct relationshipAttributes = relatedObjectId.getRelationshipAttributes();
if (relationshipAttributes != null) {
ret.setDescription((String) relationshipAttributes.getAttribute("description"));
ret.setExpression((String) relationshipAttributes.getAttribute("expression"));
ret.setSource((String) relationshipAttributes.getAttribute("source"));
ret.setSteward((String) relationshipAttributes.getAttribute("steward"));
Object status = relationshipAttributes.getAttribute("status");
if (status instanceof String) {
ret.setStatus(AtlasTermRelationshipStatus.valueOf((String) status));
} else if (status instanceof AtlasTermRelationshipStatus) {
ret.setStatus((AtlasTermRelationshipStatus) status);
}
}
return ret;
}
use of org.apache.atlas.model.glossary.relations.AtlasRelatedTermHeader in project atlas by apache.
the class GlossaryServiceTest method testAddTermsToCategory.
@Test(groups = "Glossary.UPDATE", dependsOnGroups = "Glossary.CREATE")
public void testAddTermsToCategory() {
assertNotNull(accountCategory);
try {
accountCategory = glossaryService.getCategory(accountCategory.getGuid());
assertTrue(CollectionUtils.isEmpty(accountCategory.getTerms()));
} catch (AtlasBaseException e) {
fail("Fetch of accountCategory should've succeeded", e);
}
for (AtlasGlossaryTerm term : Arrays.asList(checkingAccount, savingsAccount)) {
try {
AtlasGlossaryTerm termEntry = glossaryService.getTerm(term.getGuid());
AtlasRelatedTermHeader relatedTermId = new AtlasRelatedTermHeader();
relatedTermId.setTermGuid(termEntry.getGuid());
relatedTermId.setStatus(AtlasTermRelationshipStatus.ACTIVE);
relatedTermId.setSteward("UT");
relatedTermId.setSource("UT");
relatedTermId.setExpression("N/A");
relatedTermId.setDescription("Categorization under account category");
accountCategory.addTerm(relatedTermId);
} catch (AtlasBaseException e) {
fail("Term fetching should've succeeded", e);
}
}
try {
AtlasGlossaryCategory updated = glossaryService.updateCategory(accountCategory);
assertNotNull(updated.getTerms());
assertEquals(updated.getTerms().size(), 2);
accountCategory = updated;
} catch (AtlasBaseException e) {
fail("Glossary category update should've succeeded", e);
}
assertNotNull(accountCategory);
try {
accountCategory = glossaryService.getCategory(accountCategory.getGuid());
} catch (AtlasBaseException e) {
fail("Fetch of accountCategory should've succeeded", e);
}
for (AtlasGlossaryTerm term : Arrays.asList(fixedRateMortgage, adjustableRateMortgage)) {
try {
AtlasGlossaryTerm termEntry = glossaryService.getTerm(term.getGuid());
AtlasRelatedTermHeader relatedTermId = new AtlasRelatedTermHeader();
relatedTermId.setTermGuid(termEntry.getGuid());
relatedTermId.setStatus(AtlasTermRelationshipStatus.ACTIVE);
relatedTermId.setSteward("UT");
relatedTermId.setSource("UT");
relatedTermId.setExpression("N/A");
relatedTermId.setDescription("Categorization under mortgage category");
mortgageCategory.addTerm(relatedTermId);
} catch (AtlasBaseException e) {
fail("Term fetching should've succeeded", e);
}
}
try {
AtlasGlossaryCategory updated = glossaryService.updateCategory(mortgageCategory);
assertNotNull(updated.getTerms());
assertEquals(updated.getTerms().size(), 2);
mortgageCategory = updated;
} catch (AtlasBaseException e) {
fail("Glossary category update should've succeeded", e);
}
}
use of org.apache.atlas.model.glossary.relations.AtlasRelatedTermHeader in project atlas by apache.
the class GlossaryServiceTest method testGetCategoryTerms.
@Test(dataProvider = "getCategoryTermsProvider", dependsOnGroups = "Glossary.CREATE")
public void testGetCategoryTerms(int offset, int limit, int expected) {
for (AtlasGlossaryCategory c : Arrays.asList(accountCategory, mortgageCategory)) {
try {
List<AtlasRelatedTermHeader> categoryTerms = glossaryService.getCategoryTerms(c.getGuid(), offset, limit, SortOrder.ASCENDING);
assertNotNull(categoryTerms);
assertEquals(categoryTerms.size(), expected);
} catch (AtlasBaseException e) {
fail("Category term retrieval should've been a success", e);
}
}
}
use of org.apache.atlas.model.glossary.relations.AtlasRelatedTermHeader in project atlas by apache.
the class GlossaryServiceTest method testGetGlossaryTerms.
@Test(dataProvider = "getGlossaryTermsProvider", groups = "Glossary.GET.postUpdate", dependsOnGroups = "Glossary.UPDATE")
public void testGetGlossaryTerms(int offset, int limit, int expected) {
String guid = bankGlossary.getGuid();
SortOrder sortOrder = SortOrder.ASCENDING;
try {
List<AtlasRelatedTermHeader> glossaryTerms = glossaryService.getGlossaryTermsHeaders(guid, offset, limit, sortOrder);
assertNotNull(glossaryTerms);
assertEquals(glossaryTerms.size(), expected);
} catch (AtlasBaseException e) {
fail("Glossary term fetching should've succeeded", e);
}
}
use of org.apache.atlas.model.glossary.relations.AtlasRelatedTermHeader in project atlas by apache.
the class GlossaryCategoryUtils method updateTermCategorizationRelationships.
private void updateTermCategorizationRelationships(AtlasGlossaryCategory storeObject, Collection<AtlasRelatedTermHeader> terms) throws AtlasBaseException {
if (CollectionUtils.isNotEmpty(terms)) {
for (AtlasRelatedTermHeader term : terms) {
if (DEBUG_ENABLED) {
LOG.debug("Updating term relation with category = {}, term = {}", storeObject.getName(), term.getDisplayText());
}
AtlasRelationship relationship = relationshipStore.getById(term.getRelationGuid());
updateRelationshipAttributes(relationship, term);
relationshipStore.update(relationship);
}
}
}
Aggregations