Enhancing the FunctionImport invoke API enhancement

This commit is contained in:
Francesco Chicchiriccò 2014-05-20 08:37:40 +02:00
parent 5c28df5071
commit 5fb2b80e40
3 changed files with 22 additions and 4 deletions

View File

@ -25,7 +25,7 @@ import org.apache.olingo.commons.api.domain.ODataValue;
public interface EdmEnabledInvokeRequestFactory extends InvokeRequestFactory {
/**
* Gets an invoke request instance for the first function import with the given name (no overloading supported).
* Gets an invoke request instance for the function import with the given name and no parameters.
*
* @param <RES> OData domain object result, derived from return type defined in the function import
* @param functionImportName operation to be invoked
@ -35,7 +35,7 @@ public interface EdmEnabledInvokeRequestFactory extends InvokeRequestFactory {
String functionImportName);
/**
* Gets an invoke request instance for the first function import with the given name (no overloading supported).
* Gets an invoke request instance for the function import with the given name and matching parameter names.
*
* @param <RES> OData domain object result, derived from return type defined in the function import
* @param functionImportName operation to be invoked

View File

@ -18,6 +18,7 @@
*/
package org.apache.olingo.client.core.communication.request.invoke.v3;
import java.util.ArrayList;
import java.util.Map;
import org.apache.olingo.client.api.communication.request.invoke.EdmEnabledInvokeRequestFactory;
import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
@ -26,6 +27,7 @@ import org.apache.olingo.commons.api.domain.ODataInvokeResult;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.edm.EdmActionImport;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmFunction;
import org.apache.olingo.commons.api.edm.EdmFunctionImport;
import org.apache.olingo.commons.api.edm.EdmSchema;
@ -63,9 +65,16 @@ public class EdmEnabledInvokeRequestFactoryImpl
throw new IllegalArgumentException("Could not find FunctionImport for name " + functionImportName);
}
final EdmFunction function = edmClient.getCachedEdm().
getUnboundFunction(efi.getFunctionFqn(),
parameters == null ? null : new ArrayList<String>(parameters.keySet()));
if (function == null) {
throw new IllegalArgumentException("Could not find Function " + efi.getFunctionFqn());
}
return getInvokeRequest(
edmClient.getURIBuilder().appendOperationCallSegment(functionImportName).build(),
efi.getUnboundFunctions().get(0),
function,
parameters);
}

View File

@ -18,6 +18,7 @@
*/
package org.apache.olingo.client.core.communication.request.invoke.v4;
import java.util.ArrayList;
import java.util.Map;
import org.apache.olingo.client.api.communication.request.invoke.EdmEnabledInvokeRequestFactory;
import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
@ -26,6 +27,7 @@ import org.apache.olingo.commons.api.domain.ODataInvokeResult;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.edm.EdmActionImport;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmFunction;
import org.apache.olingo.commons.api.edm.EdmFunctionImport;
import org.apache.olingo.commons.api.edm.EdmSchema;
@ -63,9 +65,16 @@ public class EdmEnabledInvokeRequestFactoryImpl
throw new IllegalArgumentException("Could not find FunctionImport for name " + functionImportName);
}
final EdmFunction function = edmClient.getCachedEdm().
getUnboundFunction(efi.getFunctionFqn(),
parameters == null ? null : new ArrayList<String>(parameters.keySet()));
if (function == null) {
throw new IllegalArgumentException("Could not find Function " + efi.getFunctionFqn());
}
return getInvokeRequest(
edmClient.getURIBuilder().appendOperationCallSegment(functionImportName).build(),
efi.getUnboundFunctions().get(0),
function,
parameters);
}