Search in sources :

Example 36 with AtlasEnumDef

use of org.apache.atlas.model.typedef.AtlasEnumDef in project atlas by apache.

the class AtlasEnumDefStoreV1 method updateByName.

@Override
public AtlasEnumDef updateByName(String name, AtlasEnumDef enumDef) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasEnumDefStoreV1.updateByName({}, {})", name, enumDef);
    }
    AtlasEnumDef existingDef = typeRegistry.getEnumDefByName(name);
    AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_UPDATE, existingDef), "update enum-def ", name);
    validateType(enumDef);
    AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.ENUM);
    if (vertex == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
    }
    typeDefStore.updateTypeVertex(enumDef, vertex);
    toVertex(enumDef, vertex);
    AtlasEnumDef ret = toEnumDef(vertex);
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasEnumDefStoreV1.updateByName({}, {}): {}", name, enumDef, ret);
    }
    return ret;
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasTypeAccessRequest(org.apache.atlas.authorize.AtlasTypeAccessRequest) AtlasEnumDef(org.apache.atlas.model.typedef.AtlasEnumDef)

Example 37 with AtlasEnumDef

use of org.apache.atlas.model.typedef.AtlasEnumDef in project atlas by apache.

the class AtlasEnumDefStoreV1 method getByGuid.

@Override
public AtlasEnumDef getByGuid(String guid) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasEnumDefStoreV1.getByGuid({})", guid);
    }
    AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.ENUM);
    if (vertex == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
    }
    AtlasEnumDef ret = toEnumDef(vertex);
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasEnumDefStoreV1.getByGuid({}): {}", guid, ret);
    }
    return ret;
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasEnumDef(org.apache.atlas.model.typedef.AtlasEnumDef)

Example 38 with AtlasEnumDef

use of org.apache.atlas.model.typedef.AtlasEnumDef in project atlas by apache.

the class AtlasEnumDefStoreV1 method update.

@Override
public AtlasEnumDef update(AtlasEnumDef enumDef) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasEnumDefStoreV1.update({})", enumDef);
    }
    validateType(enumDef);
    AtlasEnumDef ret = StringUtils.isNotBlank(enumDef.getGuid()) ? updateByGuid(enumDef.getGuid(), enumDef) : updateByName(enumDef.getName(), enumDef);
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasEnumDefStoreV1.update({}): {}", enumDef, ret);
    }
    return ret;
}
Also used : AtlasEnumDef(org.apache.atlas.model.typedef.AtlasEnumDef)

Example 39 with AtlasEnumDef

use of org.apache.atlas.model.typedef.AtlasEnumDef in project atlas by apache.

the class TypeAttributeDifference method updateEnumDef.

private void updateEnumDef(AtlasTypesDef typeDefinitionMap, AtlasImportResult result) throws AtlasBaseException {
    for (AtlasEnumDef def : typeDefinitionMap.getEnumDefs()) {
        AtlasEnumDef existing = typeRegistry.getEnumDefByName(def.getName());
        if (existing != null && addElements(existing, def)) {
            typeDefStore.updateEnumDefByName(existing.getName(), existing);
            result.incrementMeticsCounter("typedef:enum:update");
        }
    }
}
Also used : AtlasEnumDef(org.apache.atlas.model.typedef.AtlasEnumDef)

Example 40 with AtlasEnumDef

use of org.apache.atlas.model.typedef.AtlasEnumDef in project atlas by apache.

the class TypeConverterUtil method toAtlasEnumDefs.

private static List<AtlasEnumDef> toAtlasEnumDefs(List<EnumTypeDefinition> enumTypeDefinitions) {
    List<AtlasEnumDef> ret = new ArrayList<AtlasEnumDef>();
    for (EnumTypeDefinition enumType : enumTypeDefinitions) {
        AtlasEnumDef enumDef = new AtlasEnumDef();
        enumDef.setName(enumType.getName());
        enumDef.setDescription(enumType.getDescription());
        enumDef.setTypeVersion(enumType.getVersion());
        enumDef.setElementDefs(getAtlasEnumElementDefs(enumType.getEnumValues()));
        ret.add(enumDef);
    }
    return ret;
}
Also used : EnumTypeDefinition(org.apache.atlas.v1.model.typedef.EnumTypeDefinition) AtlasEnumDef(org.apache.atlas.model.typedef.AtlasEnumDef)

Aggregations

AtlasEnumDef (org.apache.atlas.model.typedef.AtlasEnumDef)61 AtlasStructDef (org.apache.atlas.model.typedef.AtlasStructDef)33 AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)29 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)27 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)24 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)16 AtlasEnumElementDef (org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef)14 AtlasAttributeDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef)13 ArrayList (java.util.ArrayList)12 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)12 Test (org.testng.annotations.Test)11 AtlasConstraintDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef)9 HashMap (java.util.HashMap)8 AtlasTypeAccessRequest (org.apache.atlas.authorize.AtlasTypeAccessRequest)5 AtlasServiceException (org.apache.atlas.AtlasServiceException)2 AtlasRelationshipDef (org.apache.atlas.model.typedef.AtlasRelationshipDef)2 AtlasRelationshipEndDef (org.apache.atlas.model.typedef.AtlasRelationshipEndDef)2 TypesDef (org.apache.atlas.typesystem.TypesDef)2 EnumTypeDefinition (org.apache.atlas.typesystem.types.EnumTypeDefinition)2 EnumTypeDefinition (org.apache.atlas.v1.model.typedef.EnumTypeDefinition)2