"supported and will be ignored (dataTypeUri={})",
dataType);
}
}
}
IndexValue constraintValue;
if(indexDataTypes.isEmpty()){ // if no supported types are present
// get the dataType based on the type of the value
try {
constraintValue = indexValueFactory.createIndexValue(valueConstraint.getValue());
} catch (NoConverterException e) {
// if not found use the toString() and string as type
log.warn("Unable to create IndexValue for value {} (type: {}). Create IndexValue manually by using the first parsed IndexDataType {}",
new Object[]{
valueConstraint.getValue(), valueConstraint.getValue().getClass(),
IndexDataTypeEnum.STR.getIndexType()
});
constraintValue = new IndexValue(valueConstraint.getValue().toString(),
IndexDataTypeEnum.STR.getIndexType());
}
acceptedDataTypes.add(constraintValue.getType().getId());
} else {
constraintValue = new IndexValue(valueConstraint.getValue().toString(), indexDataTypes.get(0));
//we support only a single dataType ...
// ... therefore remove additional data types from the ValueConstraint
if(indexDataTypes.size() > 1){
log.warn("Only a single DataType is supported for ValueConstraints!");
while(acceptedDataTypes.size()>1){
String ignored = acceptedDataTypes.remove(acceptedDataTypes.size()-1);
log.warn(" > ignore parsed dataType {}",ignored);
}
}
}
indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.DATATYPE, constraintValue);
if(IndexDataTypeEnum.TXT.getIndexType().equals(constraintValue.getType())){
//NOTE: in case of TEXT we need also to add the language to create a valid
//query!
indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.LANG,
Collections.singleton(constraintValue.getLanguage()));
}
indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.EQ, constraintValue);
//update this constraint!
if(valueConstraint instanceof ReferenceConstraint){
indexConstraint.setFieldQueryConstraint(valueConstraint);