Search in sources :

Example 96 with AtlasException

use of org.apache.atlas.AtlasException in project incubator-atlas by apache.

the class StructInstance method setDate.

public void setDate(String attrName, Date val) throws AtlasException {
    AttributeInfo i = fieldMapping.fields.get(attrName);
    if (i == null) {
        throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName()));
    }
    if (i.dataType() != DataTypes.DATE_TYPE) {
        throw new AtlasException(String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, getTypeName(), DataTypes.DATE_TYPE.getName()));
    }
    int pos = fieldMapping.fieldPos.get(attrName);
    int nullPos = fieldMapping.fieldNullPos.get(attrName);
    nullFlags[nullPos] = val == null;
    dates[pos] = val;
    explicitSets[nullPos] = true;
}
Also used : AttributeInfo(org.apache.atlas.typesystem.types.AttributeInfo) AtlasException(org.apache.atlas.AtlasException)

Example 97 with AtlasException

use of org.apache.atlas.AtlasException in project incubator-atlas by apache.

the class StructInstance method getBigDecimal.

public BigDecimal getBigDecimal(String attrName) throws AtlasException {
    AttributeInfo i = fieldMapping.fields.get(attrName);
    if (i == null) {
        throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName()));
    }
    if (i.dataType() != DataTypes.BIGDECIMAL_TYPE) {
        throw new AtlasException(String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, getTypeName(), DataTypes.BIGDECIMAL_TYPE.getName()));
    }
    int pos = fieldMapping.fieldPos.get(attrName);
    int nullPos = fieldMapping.fieldNullPos.get(attrName);
    if (nullFlags[nullPos]) {
        return DataTypes.BIGDECIMAL_TYPE.nullValue();
    }
    return bigDecimals[pos];
}
Also used : AttributeInfo(org.apache.atlas.typesystem.types.AttributeInfo) AtlasException(org.apache.atlas.AtlasException)

Example 98 with AtlasException

use of org.apache.atlas.AtlasException in project incubator-atlas by apache.

the class StructInstance method getShort.

public short getShort(String attrName) throws AtlasException {
    AttributeInfo i = fieldMapping.fields.get(attrName);
    if (i == null) {
        throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName()));
    }
    if (i.dataType() != DataTypes.SHORT_TYPE) {
        throw new AtlasException(String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, getTypeName(), DataTypes.SHORT_TYPE.getName()));
    }
    int pos = fieldMapping.fieldPos.get(attrName);
    int nullPos = fieldMapping.fieldNullPos.get(attrName);
    if (nullFlags[nullPos]) {
        return DataTypes.SHORT_TYPE.nullValue();
    }
    return shorts[pos];
}
Also used : AttributeInfo(org.apache.atlas.typesystem.types.AttributeInfo) AtlasException(org.apache.atlas.AtlasException)

Example 99 with AtlasException

use of org.apache.atlas.AtlasException in project incubator-atlas by apache.

the class StructInstance method getLong.

public long getLong(String attrName) throws AtlasException {
    AttributeInfo i = fieldMapping.fields.get(attrName);
    if (i == null) {
        throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName()));
    }
    if (i.dataType() != DataTypes.LONG_TYPE) {
        throw new AtlasException(String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, getTypeName(), DataTypes.LONG_TYPE.getName()));
    }
    int pos = fieldMapping.fieldPos.get(attrName);
    int nullPos = fieldMapping.fieldNullPos.get(attrName);
    if (nullFlags[nullPos]) {
        return DataTypes.LONG_TYPE.nullValue();
    }
    return longs[pos];
}
Also used : AttributeInfo(org.apache.atlas.typesystem.types.AttributeInfo) AtlasException(org.apache.atlas.AtlasException)

Example 100 with AtlasException

use of org.apache.atlas.AtlasException in project incubator-atlas by apache.

the class StructInstance method getBigInt.

public BigInteger getBigInt(String attrName) throws AtlasException {
    AttributeInfo i = fieldMapping.fields.get(attrName);
    if (i == null) {
        throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName()));
    }
    if (i.dataType() != DataTypes.BIGINTEGER_TYPE) {
        throw new AtlasException(String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, getTypeName(), DataTypes.BIGINTEGER_TYPE.getName()));
    }
    int pos = fieldMapping.fieldPos.get(attrName);
    int nullPos = fieldMapping.fieldNullPos.get(attrName);
    if (nullFlags[nullPos]) {
        return DataTypes.BIGINTEGER_TYPE.nullValue();
    }
    return bigIntegers[pos];
}
Also used : AttributeInfo(org.apache.atlas.typesystem.types.AttributeInfo) AtlasException(org.apache.atlas.AtlasException)

Aggregations

AtlasException (org.apache.atlas.AtlasException)101 AttributeInfo (org.apache.atlas.typesystem.types.AttributeInfo)26 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)19 IOException (java.io.IOException)13 ITypedReferenceableInstance (org.apache.atlas.typesystem.ITypedReferenceableInstance)13 RepositoryException (org.apache.atlas.repository.RepositoryException)12 JSONObject (org.codehaus.jettison.json.JSONObject)12 CreateUpdateEntitiesResult (org.apache.atlas.CreateUpdateEntitiesResult)9 EntityNotFoundException (org.apache.atlas.typesystem.exception.EntityNotFoundException)9 Configuration (org.apache.commons.configuration.Configuration)9 ArrayList (java.util.ArrayList)7 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)7 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)6 Id (org.apache.atlas.typesystem.persistence.Id)6 AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)6 HashMap (java.util.HashMap)5 GraphTransaction (org.apache.atlas.annotation.GraphTransaction)5 CatalogRuntimeException (org.apache.atlas.catalog.exception.CatalogRuntimeException)5 Referenceable (org.apache.atlas.typesystem.Referenceable)5 EntityExistsException (org.apache.atlas.typesystem.exception.EntityExistsException)5