Series<Parameter> parameters) throws ResourceException {
Representation result = null;
Metadata metadata = (Metadata) getMetadata();
if (metadata != null && service != null) {
// Look for the FunctionImport element.
FunctionImport function = null;
for (EntityContainer container : metadata.getContainers()) {
for (FunctionImport f : container.getFunctionImports()) {
if (service.equals(f.getName())) {
function = f;
break;
}
}
if (function != null) {
break;
}
}
if (function != null) {
ClientResource resource = createResource(service);
resource.setMethod(function.getMethod());
if (parameters != null) {
for (org.restlet.ext.odata.internal.edm.Parameter parameter : function
.getParameters()) {
resource.getReference().addQueryParameter(
parameter.getName(),
TypeUtils.getLiteralForm(parameters
.getFirstValue(parameter.getName()),