in repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java [1133:1228]
private Predicate toInMemoryPredicate(AtlasStructType type, String attrName, SearchParameters.Operator op, String attrVal) {
Predicate ret = null;
AtlasAttribute attribute = type.getAttribute(attrName);
ElementAttributePredicateGenerator predicate = OPERATOR_PREDICATE_MAP.get(op);
if (attribute != null && predicate != null) {
final AtlasType attrType = attribute.getAttributeType();
final Class<?> attrClass;
final Object attrValue;
Object attrValue2 = null;
// Some operators support null comparison, thus the parsing has to be conditional
switch (attrType.getTypeName()) {
case AtlasBaseTypeDef.ATLAS_TYPE_STRING:
attrClass = String.class;
attrValue = attrVal;
break;
case AtlasBaseTypeDef.ATLAS_TYPE_SHORT:
attrClass = Short.class;
attrValue = StringUtils.isEmpty(attrVal) ? null : Short.parseShort(attrVal);
break;
case AtlasBaseTypeDef.ATLAS_TYPE_INT:
attrClass = Integer.class;
attrValue = StringUtils.isEmpty(attrVal) ? null : Integer.parseInt(attrVal);
break;
case AtlasBaseTypeDef.ATLAS_TYPE_BIGINTEGER:
attrClass = BigInteger.class;
attrValue = StringUtils.isEmpty(attrVal) ? null : new BigInteger(attrVal);
break;
case AtlasBaseTypeDef.ATLAS_TYPE_BOOLEAN:
attrClass = Boolean.class;
attrValue = StringUtils.isEmpty(attrVal) ? null : Boolean.parseBoolean(attrVal);
break;
case AtlasBaseTypeDef.ATLAS_TYPE_BYTE:
attrClass = Byte.class;
attrValue = StringUtils.isEmpty(attrVal) ? null : Byte.parseByte(attrVal);
break;
case AtlasBaseTypeDef.ATLAS_TYPE_LONG:
case AtlasBaseTypeDef.ATLAS_TYPE_DATE:
attrClass = Long.class;
String rangeStart = "";
String rangeEnd = "";
if (op == SearchParameters.Operator.TIME_RANGE) {
String[] parts = attrVal.split(ATTRIBUTE_VALUE_DELIMITER);
if (parts.length == 2) {
rangeStart = parts[0];
rangeEnd = parts[1];
}
}
if (StringUtils.isNotEmpty(rangeStart) && StringUtils.isNotEmpty(rangeEnd)) {
attrValue = Long.parseLong(rangeStart);
attrValue2 = Long.parseLong(rangeEnd);
} else {
attrValue = StringUtils.isEmpty(attrVal) ? null : Long.parseLong(attrVal);
}
break;
case AtlasBaseTypeDef.ATLAS_TYPE_FLOAT:
attrClass = Float.class;
attrValue = StringUtils.isEmpty(attrVal) ? null : Float.parseFloat(attrVal);
break;
case AtlasBaseTypeDef.ATLAS_TYPE_DOUBLE:
attrClass = Double.class;
attrValue = StringUtils.isEmpty(attrVal) ? null : Double.parseDouble(attrVal);
break;
case AtlasBaseTypeDef.ATLAS_TYPE_BIGDECIMAL:
attrClass = BigDecimal.class;
attrValue = StringUtils.isEmpty(attrVal) ? null : new BigDecimal(attrVal);
break;
default:
if (attrType instanceof AtlasEnumType) {
attrClass = String.class;
} else if (attrType instanceof AtlasArrayType) {
attrClass = List.class;
} else {
attrClass = Object.class;
}
attrValue = attrVal;
break;
}
String vertexPropertyName = attribute.getVertexPropertyName();
if (attrValue != null && attrValue2 != null) {
ret = predicate.generatePredicate(StringUtils.isEmpty(vertexPropertyName) ? attribute.getQualifiedName() : vertexPropertyName, attrValue, attrValue2, attrClass);
} else {
ret = predicate.generatePredicate(StringUtils.isEmpty(vertexPropertyName) ? attribute.getQualifiedName() : vertexPropertyName, attrValue, attrClass);
}
}
return ret;
}