}
@Override
public ODataResponse executeFunctionImport(final GetFunctionImportUriInfo uriInfo, final String contentType)
throws ODataException {
final EdmFunctionImport functionImport = uriInfo.getFunctionImport();
final EdmType type = functionImport.getReturnType().getType();
final Object data = dataSource.readData(
functionImport,
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
null);
if (data == null) {
throw new ODataNotFoundException(ODataHttpException.COMMON);
}
Object value;
if (type.getKind() == EdmTypeKind.SIMPLE) {
value = type == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance() ?
((BinaryData) data).getData() : data;
} else if (functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY) {
List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
for (final Object typeData : (List<?>) data) {
values.add(getStructuralTypeValueMap(typeData, (EdmStructuralType) type));
}
value = values;