Search in sources :

Example 1 with AtlasBaseTypeDef

use of org.apache.atlas.model.typedef.AtlasBaseTypeDef in project incubator-atlas by apache.

the class GraphBackedSearchIndexer method onChange.

@Override
public void onChange(ChangedTypeDefs changedTypeDefs) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Processing changed typedefs {}", changedTypeDefs);
    }
    AtlasGraphManagement management = null;
    try {
        management = provider.get().getManagementSystem();
        // Update index for newly created types
        if (CollectionUtils.isNotEmpty(changedTypeDefs.getCreateTypeDefs())) {
            for (AtlasBaseTypeDef typeDef : changedTypeDefs.getCreateTypeDefs()) {
                updateIndexForTypeDef(management, typeDef);
            }
        }
        // Update index for updated types
        if (CollectionUtils.isNotEmpty(changedTypeDefs.getUpdatedTypeDefs())) {
            for (AtlasBaseTypeDef typeDef : changedTypeDefs.getUpdatedTypeDefs()) {
                updateIndexForTypeDef(management, typeDef);
            }
        }
        // Invalidate the property key for deleted types
        if (CollectionUtils.isNotEmpty(changedTypeDefs.getDeletedTypeDefs())) {
            for (AtlasBaseTypeDef typeDef : changedTypeDefs.getDeletedTypeDefs()) {
                cleanupIndices(management, typeDef);
            }
        }
        //Commit indexes
        commit(management);
    } catch (RepositoryException | IndexException e) {
        LOG.error("Failed to update indexes for changed typedefs", e);
        attemptRollback(changedTypeDefs, management);
    }
}
Also used : AtlasGraphManagement(org.apache.atlas.repository.graphdb.AtlasGraphManagement) IndexException(org.apache.atlas.repository.IndexException) AtlasBaseTypeDef(org.apache.atlas.model.typedef.AtlasBaseTypeDef) RepositoryException(org.apache.atlas.repository.RepositoryException)

Example 2 with AtlasBaseTypeDef

use of org.apache.atlas.model.typedef.AtlasBaseTypeDef in project incubator-atlas by apache.

the class AtlasTypeUtil method dumpTypeNames.

private static void dumpTypeNames(List<? extends AtlasBaseTypeDef> typeDefs, StringBuilder sb) {
    if (CollectionUtils.isNotEmpty(typeDefs)) {
        for (int i = 0; i < typeDefs.size(); i++) {
            AtlasBaseTypeDef typeDef = typeDefs.get(i);
            if (i > 0) {
                sb.append(",");
            }
            sb.append(typeDef.getName());
        }
    }
}
Also used : AtlasBaseTypeDef(org.apache.atlas.model.typedef.AtlasBaseTypeDef)

Example 3 with AtlasBaseTypeDef

use of org.apache.atlas.model.typedef.AtlasBaseTypeDef in project incubator-atlas by apache.

the class TypedefsJerseyResourceIT method verifyByNameAndGUID.

private void verifyByNameAndGUID(AtlasBaseTypeDef typeDef) {
    try {
        AtlasBaseTypeDef byName = null;
        if (typeDef.getCategory() == TypeCategory.ENUM) {
            byName = clientV2.getEnumDefByName(typeDef.getName());
        } else if (typeDef.getCategory() == TypeCategory.ENTITY) {
            byName = clientV2.getEntityDefByName(typeDef.getName());
        } else if (typeDef.getCategory() == TypeCategory.CLASSIFICATION) {
            byName = clientV2.getClassificationDefByName(typeDef.getName());
        } else if (typeDef.getCategory() == TypeCategory.STRUCT) {
            byName = clientV2.getStructDefByName(typeDef.getName());
        }
        assertNotNull(byName);
    } catch (AtlasServiceException e) {
        fail("Get byName should've succeeded", e);
    }
    if (StringUtils.isNotBlank(typeDef.getGuid())) {
        try {
            AtlasBaseTypeDef byGuid = null;
            if (typeDef.getCategory() == TypeCategory.ENUM) {
                byGuid = clientV2.getEnumDefByGuid(typeDef.getGuid());
            } else if (typeDef.getCategory() == TypeCategory.ENTITY) {
                byGuid = clientV2.getEntityDefByGuid(typeDef.getGuid());
            } else if (typeDef.getCategory() == TypeCategory.CLASSIFICATION) {
                byGuid = clientV2.getClassificationDefByGuid(typeDef.getGuid());
            } else if (typeDef.getCategory() == TypeCategory.STRUCT) {
                byGuid = clientV2.getStructDefByGuid(typeDef.getGuid());
            }
            assertNotNull(byGuid);
        } catch (AtlasServiceException e) {
            fail("Get byGuid should've succeeded", e);
        }
    }
}
Also used : AtlasServiceException(org.apache.atlas.AtlasServiceException) AtlasBaseTypeDef(org.apache.atlas.model.typedef.AtlasBaseTypeDef)

Aggregations

AtlasBaseTypeDef (org.apache.atlas.model.typedef.AtlasBaseTypeDef)3 AtlasServiceException (org.apache.atlas.AtlasServiceException)1 IndexException (org.apache.atlas.repository.IndexException)1 RepositoryException (org.apache.atlas.repository.RepositoryException)1 AtlasGraphManagement (org.apache.atlas.repository.graphdb.AtlasGraphManagement)1