Search in sources :

Example 1 with AtlasTermCategorizationHeader

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);
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasGlossaryTerm(org.apache.atlas.model.glossary.AtlasGlossaryTerm) AtlasTermCategorizationHeader(org.apache.atlas.model.glossary.relations.AtlasTermCategorizationHeader) Test(org.testng.annotations.Test)

Example 2 with AtlasTermCategorizationHeader

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;
}
Also used : AtlasStruct(org.apache.atlas.model.instance.AtlasStruct) AbstractDataTransferObject(org.apache.atlas.repository.ogm.AbstractDataTransferObject) AtlasBaseModelObject(org.apache.atlas.model.AtlasBaseModelObject) AtlasTermCategorizationHeader(org.apache.atlas.model.glossary.relations.AtlasTermCategorizationHeader) AtlasTermRelationshipStatus(org.apache.atlas.model.glossary.enums.AtlasTermRelationshipStatus)

Example 3 with AtlasTermCategorizationHeader

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);
        }
    }
}
Also used : AtlasTermCategorizationHeader(org.apache.atlas.model.glossary.relations.AtlasTermCategorizationHeader)

Example 4 with AtlasTermCategorizationHeader

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);
        }
    }
}
Also used : AtlasTermCategorizationHeader(org.apache.atlas.model.glossary.relations.AtlasTermCategorizationHeader) AtlasRelationship(org.apache.atlas.model.instance.AtlasRelationship)

Aggregations

AtlasTermCategorizationHeader (org.apache.atlas.model.glossary.relations.AtlasTermCategorizationHeader)4 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)1 AtlasBaseModelObject (org.apache.atlas.model.AtlasBaseModelObject)1 AtlasGlossaryTerm (org.apache.atlas.model.glossary.AtlasGlossaryTerm)1 AtlasTermRelationshipStatus (org.apache.atlas.model.glossary.enums.AtlasTermRelationshipStatus)1 AtlasRelationship (org.apache.atlas.model.instance.AtlasRelationship)1 AtlasStruct (org.apache.atlas.model.instance.AtlasStruct)1 AbstractDataTransferObject (org.apache.atlas.repository.ogm.AbstractDataTransferObject)1 Test (org.testng.annotations.Test)1