use of org.apache.atlas.model.glossary.relations.AtlasTermCategorizationHeader in project atlas by apache.
the class GlossaryServiceTest method testTermCreationWithCategory.
@Test(groups = "Glossary.CREATE", dependsOnMethods = "testCategoryCreation")
public void testTermCreationWithCategory() {
try {
AtlasTermCategorizationHeader termCategorizationHeader = new AtlasTermCategorizationHeader();
termCategorizationHeader.setCategoryGuid(mortgageCategory.getGuid());
termCategorizationHeader.setDescription("Test description");
termCategorizationHeader.setStatus(AtlasTermRelationshipStatus.DRAFT);
fixedRateMortgage.setCategories(Collections.singleton(termCategorizationHeader));
adjustableRateMortgage.setCategories(Collections.singleton(termCategorizationHeader));
List<AtlasGlossaryTerm> terms = glossaryService.createTerms(Arrays.asList(fixedRateMortgage, adjustableRateMortgage));
fixedRateMortgage.setGuid(terms.get(0).getGuid());
adjustableRateMortgage.setGuid(terms.get(1).getGuid());
} catch (AtlasBaseException e) {
fail("Term creation should've succeeded", e);
}
}
use of org.apache.atlas.model.glossary.relations.AtlasTermCategorizationHeader in project atlas by apache.
the class AbstractGlossaryDTO method constructTermCategorizationId.
protected AtlasTermCategorizationHeader constructTermCategorizationId(final AtlasRelatedObjectId category) {
AtlasTermCategorizationHeader ret = new AtlasTermCategorizationHeader();
ret.setCategoryGuid(category.getGuid());
ret.setRelationGuid(category.getRelationshipGuid());
AtlasStruct relationshipAttributes = category.getRelationshipAttributes();
if (relationshipAttributes != null) {
ret.setDescription((String) relationshipAttributes.getAttribute("description"));
Object status = relationshipAttributes.getAttribute("status");
if (status instanceof AtlasTermRelationshipStatus) {
ret.setStatus((AtlasTermRelationshipStatus) status);
} else if (status instanceof String) {
ret.setStatus(AtlasTermRelationshipStatus.valueOf((String) status));
}
}
return ret;
}
use of org.apache.atlas.model.glossary.relations.AtlasTermCategorizationHeader in project atlas by apache.
the class GlossaryService method setDisplayNameForCategories.
private void setDisplayNameForCategories(final Set<AtlasTermCategorizationHeader> categorizationHeaders) throws AtlasBaseException {
if (CollectionUtils.isEmpty(categorizationHeaders)) {
return;
}
for (AtlasTermCategorizationHeader termCategorizationHeader : categorizationHeaders) {
String categoryGuid = termCategorizationHeader.getCategoryGuid();
String categoryName = getGlossaryCategoryName(categoryGuid);
if (StringUtils.isNotEmpty(categoryName)) {
termCategorizationHeader.setDisplayText(categoryName);
}
}
}
use of org.apache.atlas.model.glossary.relations.AtlasTermCategorizationHeader in project atlas by apache.
the class GlossaryTermUtils method updateTermCategorizationRelationships.
private void updateTermCategorizationRelationships(AtlasGlossaryTerm storeObject, Collection<AtlasTermCategorizationHeader> toUpdate) throws AtlasBaseException {
if (CollectionUtils.isNotEmpty(toUpdate)) {
for (AtlasTermCategorizationHeader categorizationHeader : toUpdate) {
if (DEBUG_ENABLED) {
LOG.debug("Updating relation between term = {} and category = {}", storeObject.getGuid(), categorizationHeader.getDisplayText());
}
AtlasRelationship relationship = relationshipStore.getById(categorizationHeader.getRelationGuid());
updateRelationshipAttributes(relationship, categorizationHeader);
relationshipStore.update(relationship);
}
}
}
Aggregations