use of org.apache.atlas.AtlasException in project incubator-atlas by apache.
the class AtlasEntityChangeNotifier method updateFullTextMapping.
private void updateFullTextMapping(String entityId, List<AtlasClassification> classifications) {
try {
if (!AtlasRepositoryConfiguration.isFullTextSearchEnabled()) {
return;
}
} catch (AtlasException e) {
LOG.warn("Unable to determine if FullText is disabled. Proceeding with FullText mapping");
}
if (StringUtils.isEmpty(entityId) || CollectionUtils.isEmpty(classifications)) {
return;
}
AtlasVertex atlasVertex = AtlasGraphUtilsV1.findByGuid(entityId);
if (atlasVertex == null) {
return;
}
if (atlasVertex == null) {
LOG.warn("updateFullTextMapping(): no entity exists with guid {}", entityId);
return;
}
try {
String classificationFullText = fullTextMapperV2.getIndexTextForClassifications(entityId, classifications);
String existingFullText = (String) GraphHelper.getProperty(atlasVertex, Constants.ENTITY_TEXT_PROPERTY_KEY);
String newFullText = existingFullText + " " + classificationFullText;
GraphHelper.setProperty(atlasVertex, Constants.ENTITY_TEXT_PROPERTY_KEY, newFullText);
} catch (AtlasBaseException e) {
LOG.error("FullText mapping failed for Vertex[ guid = {} ]", entityId, e);
}
}
use of org.apache.atlas.AtlasException in project incubator-atlas by apache.
the class StructInstance method setByte.
public void setByte(String attrName, byte 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.BYTE_TYPE) {
throw new AtlasException(String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, getTypeName(), DataTypes.BYTE_TYPE.getName()));
}
int pos = fieldMapping.fieldPos.get(attrName);
int nullPos = fieldMapping.fieldNullPos.get(attrName);
nullFlags[nullPos] = false;
bytes[pos] = val;
explicitSets[nullPos] = true;
}
use of org.apache.atlas.AtlasException in project incubator-atlas by apache.
the class StructInstance method get.
public Object get(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()));
}
int pos = fieldMapping.fieldPos.get(attrName);
int nullPos = fieldMapping.fieldNullPos.get(attrName);
if (nullFlags[nullPos]) {
if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.PRIMITIVE) {
return ((DataTypes.PrimitiveType) i.dataType()).nullValue();
} else {
return null;
}
}
if (i.dataType() == DataTypes.BOOLEAN_TYPE) {
return bools[pos];
} else if (i.dataType() == DataTypes.BYTE_TYPE) {
return bytes[pos];
} else if (i.dataType() == DataTypes.SHORT_TYPE) {
return shorts[pos];
} else if (i.dataType() == DataTypes.INT_TYPE) {
return ints[pos];
} else if (i.dataType() == DataTypes.LONG_TYPE) {
return longs[pos];
} else if (i.dataType() == DataTypes.FLOAT_TYPE) {
return floats[pos];
} else if (i.dataType() == DataTypes.DOUBLE_TYPE) {
return doubles[pos];
} else if (i.dataType() == DataTypes.BIGINTEGER_TYPE) {
return bigIntegers[pos];
} else if (i.dataType() == DataTypes.BIGDECIMAL_TYPE) {
return bigDecimals[pos];
} else if (i.dataType() == DataTypes.DATE_TYPE) {
return dates[pos];
} else if (i.dataType() == DataTypes.STRING_TYPE) {
return strings[pos];
} else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.ENUM) {
return ((EnumType) i.dataType()).fromOrdinal(ints[pos]);
} else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.ARRAY) {
return arrays[pos];
} else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.MAP) {
return maps[pos];
} else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.STRUCT || i.dataType().getTypeCategory() == DataTypes.TypeCategory.TRAIT) {
return structs[pos];
} else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.CLASS) {
if (ids[pos] != null) {
return ids[pos];
} else {
return referenceables[pos];
}
} else {
throw new AtlasException(String.format("Unknown datatype %s", i.dataType()));
}
}
use of org.apache.atlas.AtlasException in project incubator-atlas by apache.
the class StructInstance method getDate.
public Date getDate(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.DATE_TYPE) {
throw new AtlasException(String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, getTypeName(), DataTypes.DATE_TYPE.getName()));
}
int pos = fieldMapping.fieldPos.get(attrName);
int nullPos = fieldMapping.fieldNullPos.get(attrName);
if (nullFlags[nullPos]) {
return DataTypes.DATE_TYPE.nullValue();
}
return dates[pos];
}
use of org.apache.atlas.AtlasException in project incubator-atlas by apache.
the class StructInstance method setShort.
public void setShort(String attrName, short 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.SHORT_TYPE) {
throw new AtlasException(String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, getTypeName(), DataTypes.SHORT_TYPE.getName()));
}
int pos = fieldMapping.fieldPos.get(attrName);
int nullPos = fieldMapping.fieldNullPos.get(attrName);
nullFlags[nullPos] = false;
shorts[pos] = val;
explicitSets[nullPos] = true;
}
Aggregations