Java Code Examples for org.apache.atlas.model.typedef.AtlasBaseTypeDef#getName()

The following examples show how to use org.apache.atlas.model.typedef.AtlasBaseTypeDef#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GraphBackedSearchIndexer.java    From atlas with Apache License 2.0 6 votes vote down vote up
private void addIndexForType(AtlasGraphManagement management, AtlasBaseTypeDef typeDef) {
    if (typeDef instanceof AtlasEnumDef) {
        // Only handle complex types like Struct, Classification and Entity
        return;
    }
    if (typeDef instanceof AtlasStructDef) {
        AtlasStructDef structDef = (AtlasStructDef) typeDef;
        List<AtlasAttributeDef> attributeDefs = structDef.getAttributeDefs();
        if (CollectionUtils.isNotEmpty(attributeDefs)) {
            for (AtlasAttributeDef attributeDef : attributeDefs) {
                createIndexForAttribute(management, structDef, attributeDef);
            }
        }
    } else if (!AtlasTypeUtil.isBuiltInType(typeDef.getName())){
        throw new IllegalArgumentException("bad data type" + typeDef.getName());
    }
}
 
Example 2
Source File: AtlasAbstractDefStoreV2.java    From atlas with Apache License 2.0 6 votes vote down vote up
public void validateType(AtlasBaseTypeDef typeDef) throws AtlasBaseException {
    if (!isValidName(typeDef.getName())) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID_FORMAT, typeDef.getName(), typeDef.getCategory().name());
    }

    try {
        final boolean allowReservedKeywords = ApplicationProperties.get().getBoolean(ALLOW_RESERVED_KEYWORDS, true);

        if (!allowReservedKeywords && typeDef instanceof AtlasStructDef) {
            final List<AtlasStructDef.AtlasAttributeDef> attributeDefs = ((AtlasStructDef) typeDef).getAttributeDefs();
            for (AtlasStructDef.AtlasAttributeDef attrDef : attributeDefs) {
                if (AtlasDSL.Parser.isKeyword(attrDef.getName())) {
                    throw new AtlasBaseException(AtlasErrorCode.ATTRIBUTE_NAME_INVALID, attrDef.getName(), typeDef.getCategory().name());
                }
            }
        }
    } catch (AtlasException e) {
        LOG.error("Exception while loading configuration ", e);
        throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, "Could not load configuration");
    }
}
 
Example 3
Source File: GraphBackedSearchIndexer.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
private void addIndexForType(AtlasGraphManagement management, AtlasBaseTypeDef typeDef) {
    if (typeDef instanceof AtlasEnumDef) {
        // Only handle complex types like Struct, Classification and Entity
        return;
    }
    if (typeDef instanceof AtlasStructDef) {
        AtlasStructDef structDef = (AtlasStructDef) typeDef;
        List<AtlasAttributeDef> attributeDefs = structDef.getAttributeDefs();
        if (CollectionUtils.isNotEmpty(attributeDefs)) {
            for (AtlasAttributeDef attributeDef : attributeDefs) {
                createIndexForAttribute(management, typeDef.getName(), attributeDef);
            }
        }
    } else if (!AtlasTypeUtil.isBuiltInType(typeDef.getName())){
        throw new IllegalArgumentException("bad data type" + typeDef.getName());
    }
}
 
Example 4
Source File: GraphBackedSearchIndexer.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
private void cleanupIndices(AtlasGraphManagement management, AtlasBaseTypeDef typeDef) {
    Preconditions.checkNotNull(typeDef, "Cannot process null typedef");
    if (LOG.isDebugEnabled()) {
        LOG.debug("Cleaning up index for {}", typeDef);
    }

    if (typeDef instanceof AtlasEnumDef) {
        // Only handle complex types like Struct, Classification and Entity
        return;
    }

    if (typeDef instanceof AtlasStructDef) {
        AtlasStructDef structDef = (AtlasStructDef) typeDef;
        List<AtlasAttributeDef> attributeDefs = structDef.getAttributeDefs();
        if (CollectionUtils.isNotEmpty(attributeDefs)) {
            for (AtlasAttributeDef attributeDef : attributeDefs) {
                cleanupIndexForAttribute(management, typeDef.getName(), attributeDef);
            }
        }
    } else if (!AtlasTypeUtil.isBuiltInType(typeDef.getName())){
        throw new IllegalArgumentException("bad data type" + typeDef.getName());
    }
}
 
Example 5
Source File: AtlasAbstractDefStoreV1.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
public void validateType(AtlasBaseTypeDef typeDef) throws AtlasBaseException {
    if (!isValidName(typeDef.getName())) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID_FORMAT, typeDef.getName(), typeDef.getCategory().name());
    }

    try {
        final boolean allowReservedKeywords = ApplicationProperties.get().getBoolean(ALLOW_RESERVED_KEYWORDS, true);

        if (!allowReservedKeywords && typeDef instanceof AtlasStructDef) {
            final List<AtlasStructDef.AtlasAttributeDef> attributeDefs = ((AtlasStructDef) typeDef).getAttributeDefs();
            for (AtlasStructDef.AtlasAttributeDef attrDef : attributeDefs) {
                if (QueryParser.isKeyword(attrDef.getName())) {
                    throw new AtlasBaseException(AtlasErrorCode.ATTRIBUTE_NAME_INVALID, attrDef.getName(), typeDef.getCategory().name());
                }
            }
        }
    } catch (AtlasException e) {
        LOG.error("Exception while loading configuration ", e);
        throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, "Could not load configuration");
    }
}
 
Example 6
Source File: AtlasTypeRegistry.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
private void addTypeWithNoRefResolve(AtlasBaseTypeDef typeDef) throws AtlasBaseException{
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasTypeRegistry.addTypeWithNoRefResolve({})", typeDef);
    }

    if (typeDef != null) {
        if (this.isRegisteredType(typeDef.getName())) {
            throw new AtlasBaseException(AtlasErrorCode.TYPE_ALREADY_EXISTS, typeDef.getName());
        }

        if (typeDef.getClass().equals(AtlasEnumDef.class)) {
            AtlasEnumDef enumDef = (AtlasEnumDef) typeDef;

            registryData.enumDefs.addType(enumDef, new AtlasEnumType(enumDef));
        } else if (typeDef.getClass().equals(AtlasStructDef.class)) {
            AtlasStructDef structDef = (AtlasStructDef) typeDef;

            registryData.structDefs.addType(structDef, new AtlasStructType(structDef));
        } else if (typeDef.getClass().equals(AtlasClassificationDef.class)) {
            AtlasClassificationDef classificationDef = (AtlasClassificationDef) typeDef;

            registryData.classificationDefs.addType(classificationDef,
                    new AtlasClassificationType(classificationDef));
        } else if (typeDef.getClass().equals(AtlasEntityDef.class)) {
            AtlasEntityDef entityDef = (AtlasEntityDef) typeDef;

            registryData.entityDefs.addType(entityDef, new AtlasEntityType(entityDef));
        } else if (typeDef.getClass().equals(AtlasRelationshipDef.class)) {
            AtlasRelationshipDef relationshipDef = (AtlasRelationshipDef) typeDef;

            registryData.relationshipDefs.addType(relationshipDef, new AtlasRelationshipType(relationshipDef));
        }

        addedTypes.add(typeDef);
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasTypeRegistry.addTypeWithNoRefResolve({})", typeDef);
    }
}
 
Example 7
Source File: AtlasTypeRegistry.java    From atlas with Apache License 2.0 4 votes vote down vote up
private void addTypeWithNoRefResolve(AtlasBaseTypeDef typeDef) throws AtlasBaseException{
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasTypeRegistry.addTypeWithNoRefResolve({})", typeDef);
    }

    if (typeDef != null) {
        if (this.isRegisteredType(typeDef.getName())) {
            throw new AtlasBaseException(AtlasErrorCode.TYPE_ALREADY_EXISTS, typeDef.getName());
        }

        if (typeDef.getClass().equals(AtlasEnumDef.class)) {
            AtlasEnumDef enumDef = (AtlasEnumDef) typeDef;

            registryData.enumDefs.addType(enumDef, new AtlasEnumType(enumDef));
        } else if (typeDef.getClass().equals(AtlasStructDef.class)) {
            AtlasStructDef structDef = (AtlasStructDef) typeDef;

            registryData.structDefs.addType(structDef, new AtlasStructType(structDef));
        } else if (typeDef.getClass().equals(AtlasClassificationDef.class)) {
            AtlasClassificationDef classificationDef = (AtlasClassificationDef) typeDef;

            registryData.classificationDefs.addType(classificationDef,
                    new AtlasClassificationType(classificationDef));
        } else if (typeDef.getClass().equals(AtlasEntityDef.class)) {
            AtlasEntityDef entityDef = (AtlasEntityDef) typeDef;

            registryData.entityDefs.addType(entityDef, new AtlasEntityType(entityDef));
        } else if (typeDef.getClass().equals(AtlasRelationshipDef.class)) {
            AtlasRelationshipDef relationshipDef = (AtlasRelationshipDef) typeDef;

            registryData.relationshipDefs.addType(relationshipDef, new AtlasRelationshipType(relationshipDef));
        } else if (typeDef.getClass().equals(AtlasBusinessMetadataDef.class)) {
            AtlasBusinessMetadataDef businessMetadataDef = (AtlasBusinessMetadataDef) typeDef;
            registryData.businessMetadataDefs.addType(businessMetadataDef, new AtlasBusinessMetadataType(businessMetadataDef));
        }

        addedTypes.add(typeDef);
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasTypeRegistry.addTypeWithNoRefResolve({})", typeDef);
    }
}
 
Example 8
Source File: AtlasType.java    From atlas with Apache License 2.0 4 votes vote down vote up
protected AtlasType(AtlasBaseTypeDef typeDef) {
    this(typeDef.getName(), typeDef.getCategory(), typeDef.getServiceType());
}
 
Example 9
Source File: AtlasType.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
protected AtlasType(AtlasBaseTypeDef typeDef) {
    this(typeDef.getName(), typeDef.getCategory());
}