[OLINGO-202] Required changes provided
This commit is contained in:
parent
05b26700ad
commit
081df2aa70
|
@ -30,6 +30,8 @@ public class EdmActionImportImpl extends EdmOperationImportImpl implements EdmAc
|
|||
|
||||
private final ActionImport actionImport;
|
||||
|
||||
private FullQualifiedName actionFQN;
|
||||
|
||||
public EdmActionImportImpl(final Edm edm, final EdmEntityContainer container, final String name,
|
||||
final ActionImport actionImport) {
|
||||
|
||||
|
@ -37,18 +39,17 @@ public class EdmActionImportImpl extends EdmOperationImportImpl implements EdmAc
|
|||
this.actionImport = actionImport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmAction getUnboundAction() {
|
||||
return getBoundAction(null, null);
|
||||
public FullQualifiedName getActionFQN() {
|
||||
if (actionFQN == null) {
|
||||
actionFQN = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(actionImport.getAction()).
|
||||
setDefaultNamespace(container.getNamespace()).build().getFullQualifiedName();
|
||||
}
|
||||
return actionFQN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmAction getBoundAction(
|
||||
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) {
|
||||
|
||||
return edm.getAction(new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(actionImport.getAction()).
|
||||
setDefaultNamespace(container.getNamespace()).build().getFullQualifiedName(),
|
||||
bindingParameterTypeName, isBindingParameterCollection);
|
||||
public EdmAction getUnboundAction() {
|
||||
return edm.getUnboundAction(getActionFQN());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -210,6 +210,37 @@ public class EdmClientImpl extends AbstractEdm {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<EdmFunction> createUnboundFunctions(final FullQualifiedName functionName) {
|
||||
final List<EdmFunction> result = new ArrayList<EdmFunction>();
|
||||
|
||||
final Schema schema = xmlSchemaByNamespace.get(functionName.getNamespace());
|
||||
if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) {
|
||||
final List<Function> functions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).
|
||||
getFunctions(functionName.getName());
|
||||
for (final Iterator<Function> itor = functions.iterator(); itor.hasNext();) {
|
||||
final Function function = itor.next();
|
||||
if (!function.isBound()) {
|
||||
result.add(EdmFunctionImpl.getInstance(this, functionName, function));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (EntityContainer entityContainer : schema.getEntityContainers()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<FunctionImport> functionImports =
|
||||
(List<FunctionImport>) entityContainer.getFunctionImports(functionName.getName());
|
||||
for (final Iterator<FunctionImport> itor = functionImports.iterator(); itor.hasNext();) {
|
||||
final FunctionImport functionImport = itor.next();
|
||||
if (FunctionImportUtils.canProxyFunction(functionImport) && !functionImport.isBindable()) {
|
||||
result.add(EdmFunctionProxy.getInstance(this, functionName, functionImport));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmFunction createUnboundFunction(final FullQualifiedName functionName, final List<String> parameterNames) {
|
||||
EdmFunction result = null;
|
||||
|
@ -235,8 +266,8 @@ public class EdmClientImpl extends AbstractEdm {
|
|||
} else {
|
||||
for (EntityContainer entityContainer : schema.getEntityContainers()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<FunctionImport> functionImports = (List<FunctionImport>) entityContainer.
|
||||
getFunctionImports(functionName.getName());
|
||||
final List<FunctionImport> functionImports =
|
||||
(List<FunctionImport>) entityContainer.getFunctionImports(functionName.getName());
|
||||
boolean found = false;
|
||||
for (final Iterator<FunctionImport> itor = functionImports.iterator(); itor.hasNext() && !found;) {
|
||||
final FunctionImport functionImport = itor.next();
|
||||
|
|
|
@ -32,6 +32,8 @@ public class EdmFunctionImportImpl extends EdmOperationImportImpl implements Edm
|
|||
|
||||
private final FunctionImport functionImport;
|
||||
|
||||
private FullQualifiedName functionFQN;
|
||||
|
||||
public EdmFunctionImportImpl(final Edm edm, final EdmEntityContainer container, final String name,
|
||||
final FunctionImport functionImport) {
|
||||
|
||||
|
@ -40,17 +42,22 @@ public class EdmFunctionImportImpl extends EdmOperationImportImpl implements Edm
|
|||
}
|
||||
|
||||
@Override
|
||||
public EdmFunction getUnboundFunction(final List<String> parameterNames) {
|
||||
return getBoundFunction(parameterNames, null, null);
|
||||
public FullQualifiedName getFunctionFqn() {
|
||||
if (functionFQN == null) {
|
||||
functionFQN = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(functionImport.getFunction()).
|
||||
setDefaultNamespace(container.getNamespace()).build().getFullQualifiedName();
|
||||
}
|
||||
return functionFQN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmFunction getBoundFunction(final List<String> parameterNames,
|
||||
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) {
|
||||
public List<EdmFunction> getUnboundFunctions() {
|
||||
return edm.getUnboundFunctions(getFunctionFqn());
|
||||
}
|
||||
|
||||
return edm.getFunction(new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(functionImport.getFunction()).
|
||||
setDefaultNamespace(container.getNamespace()).build().getFullQualifiedName(),
|
||||
bindingParameterTypeName, isBindingParameterCollection, parameterNames);
|
||||
@Override
|
||||
public EdmFunction getUnboundFunction(final List<String> parameterNames) {
|
||||
return edm.getUnboundFunction(getFunctionFqn(), parameterNames);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,8 +65,4 @@ public class EdmFunctionImportImpl extends EdmOperationImportImpl implements Edm
|
|||
return functionImport.isIncludeInServiceDocument();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FullQualifiedName getFunctionFqn() {
|
||||
return new FullQualifiedName(functionImport.getFunction());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ public class EdmActionImportProxy extends EdmOperationImportImpl implements EdmA
|
|||
|
||||
private final FunctionImport functionImport;
|
||||
|
||||
private FullQualifiedName actionFQN;
|
||||
|
||||
public EdmActionImportProxy(final Edm edm, final EdmEntityContainer container, final String name,
|
||||
final FunctionImport functionImport) {
|
||||
|
||||
|
@ -38,19 +40,17 @@ public class EdmActionImportProxy extends EdmOperationImportImpl implements EdmA
|
|||
this.functionImport = functionImport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmAction getUnboundAction() {
|
||||
return edm.getAction(new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(functionImport.getName()).
|
||||
setDefaultNamespace(container.getNamespace()).build().getFullQualifiedName(), null, null);
|
||||
public FullQualifiedName getActionFQN() {
|
||||
if (actionFQN == null) {
|
||||
actionFQN = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(functionImport.getName()).
|
||||
setDefaultNamespace(container.getNamespace()).build().getFullQualifiedName();
|
||||
}
|
||||
return actionFQN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmAction getBoundAction(
|
||||
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) {
|
||||
|
||||
return edm.getAction(new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(functionImport.getName()).
|
||||
setDefaultNamespace(container.getNamespace()).build().getFullQualifiedName(),
|
||||
bindingParameterTypeName, isBindingParameterCollection);
|
||||
public EdmAction getUnboundAction() {
|
||||
return edm.getUnboundAction(getActionFQN());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.List;
|
|||
|
||||
import org.apache.olingo.client.api.edm.xml.v3.FunctionImport;
|
||||
import org.apache.olingo.client.core.edm.EdmOperationImportImpl;
|
||||
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunction;
|
||||
|
@ -33,6 +32,8 @@ public class EdmFunctionImportProxy extends EdmOperationImportImpl implements Ed
|
|||
|
||||
private final FunctionImport functionImport;
|
||||
|
||||
private FullQualifiedName functionFQN;
|
||||
|
||||
public EdmFunctionImportProxy(final Edm edm, final EdmEntityContainer container, final String name,
|
||||
final FunctionImport functionImport) {
|
||||
|
||||
|
@ -41,27 +42,27 @@ public class EdmFunctionImportProxy extends EdmOperationImportImpl implements Ed
|
|||
}
|
||||
|
||||
@Override
|
||||
public EdmFunction getUnboundFunction(final List<String> parameterNames) {
|
||||
return getBoundFunction(parameterNames, null, null);
|
||||
public FullQualifiedName getFunctionFqn() {
|
||||
if (functionFQN == null) {
|
||||
functionFQN = new FullQualifiedName(container.getNamespace(), getName());
|
||||
}
|
||||
return functionFQN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmFunction getBoundFunction(final List<String> parameterNames,
|
||||
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) {
|
||||
public List<EdmFunction> getUnboundFunctions() {
|
||||
return edm.getUnboundFunctions(getFunctionFqn());
|
||||
}
|
||||
|
||||
return edm.getFunction(new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(functionImport.getName()).
|
||||
setDefaultNamespace(container.getNamespace()).build().getFullQualifiedName(),
|
||||
bindingParameterTypeName, isBindingParameterCollection, parameterNames);
|
||||
@Override
|
||||
public EdmFunction getUnboundFunction(final List<String> parameterNames) {
|
||||
return edm.getUnboundFunction(getFunctionFqn(), parameterNames);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIncludeInServiceDocument() {
|
||||
//V3 states that all function imports are included in the service document
|
||||
// V3 states that all function imports are included in the service document
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FullQualifiedName getFunctionFqn() {
|
||||
return new FullQualifiedName(container.getNamespace(), getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,13 +48,13 @@ import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
|
|||
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmAction;
|
||||
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.EdmParameter;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
|
||||
import org.junit.Test;
|
||||
|
@ -244,10 +244,10 @@ public class InvokeTestITCase extends AbstractTestITCase {
|
|||
assertNotNull(edm);
|
||||
|
||||
final EdmEntityContainer container = edm.getSchemas().get(0).getEntityContainer();
|
||||
final EdmActionImport actImp = container.getActionImport(operation.getTitle());
|
||||
final EdmTypeInfo createdTypeInfo =
|
||||
new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(created.getName()).build();
|
||||
final EdmAction action = actImp.getBoundAction(
|
||||
final EdmAction action = edm.getBoundAction(
|
||||
new FullQualifiedName(container.getNamespace(), operation.getTitle()),
|
||||
createdTypeInfo.getFullQualifiedName(), createdTypeInfo.isCollection());
|
||||
|
||||
final ODataInvokeRequest<ODataNoContent> req = getClient().getInvokeRequestFactory().
|
||||
|
@ -294,11 +294,11 @@ public class InvokeTestITCase extends AbstractTestITCase {
|
|||
assertNotNull(edm);
|
||||
|
||||
final EdmEntityContainer container = edm.getSchemas().get(0).getEntityContainer();
|
||||
final EdmActionImport actImp = container.getActionImport("IncreaseSalaries");
|
||||
|
||||
final EdmTypeInfo employeesTypeInfo = new EdmTypeInfo.Builder().setEdm(edm).
|
||||
setTypeExpression("Collection(Microsoft.Test.OData.Services.AstoriaDefaultService.Employee)").build();
|
||||
final EdmAction action = actImp.getBoundAction(
|
||||
final EdmAction action = edm.getBoundAction(
|
||||
new FullQualifiedName(container.getNamespace(), "IncreaseSalaries"),
|
||||
employeesTypeInfo.getFullQualifiedName(), employeesTypeInfo.isCollection());
|
||||
|
||||
final EdmParameter param = action.getParameter(action.getParameterNames().get(1));
|
||||
|
@ -308,7 +308,7 @@ public class InvokeTestITCase extends AbstractTestITCase {
|
|||
build();
|
||||
|
||||
final ODataInvokeRequest<ODataNoContent> req = getClient().getInvokeRequestFactory().getInvokeRequest(
|
||||
builder.appendOperationCallSegment(actImp.getName()).build(), action,
|
||||
builder.appendOperationCallSegment(action.getName()).build(), action,
|
||||
Collections.<String, ODataValue>singletonMap(param.getName(), paramValue));
|
||||
final ODataInvokeResponse<ODataNoContent> res = req.execute();
|
||||
assertNotNull(res);
|
||||
|
|
|
@ -189,16 +189,16 @@ public class MetadataTest extends AbstractTest {
|
|||
final EdmEntityType computer = metadata.getEntityType(new FullQualifiedName(container.getNamespace(), "Computer"));
|
||||
assertNotNull(computer);
|
||||
|
||||
final EdmFunction getComputer = metadata.getFunction(
|
||||
final EdmFunction getComputer = metadata.getBoundFunction(
|
||||
new FullQualifiedName(container.getNamespace(), "GetComputer"),
|
||||
new FullQualifiedName(container.getNamespace(), computer.getName()),
|
||||
Boolean.FALSE, Arrays.asList(new String[] {"computer"}));
|
||||
Boolean.FALSE, Arrays.asList("computer"));
|
||||
assertNotNull(getComputer);
|
||||
assertEquals(computer, getComputer.getParameter("computer").getType());
|
||||
assertEquals(computer, getComputer.getReturnType().getType());
|
||||
|
||||
final EdmAction resetDataSource2 = metadata.getAction(
|
||||
new FullQualifiedName(container.getNamespace(), "ResetDataSource"), null, Boolean.FALSE);
|
||||
final EdmAction resetDataSource2 = metadata.getUnboundAction(
|
||||
new FullQualifiedName(container.getNamespace(), "ResetDataSource"));
|
||||
assertNotNull(resetDataSource2);
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ public class MetadataTest extends AbstractTest {
|
|||
assertEquals(folder, user.getNavigationProperty("Inbox").getType());
|
||||
|
||||
// 4. Action
|
||||
final EdmAction move = edm.getAction(
|
||||
final EdmAction move = edm.getBoundAction(
|
||||
new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "Move"),
|
||||
new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "Folder"),
|
||||
false);
|
||||
|
@ -209,9 +209,8 @@ public class MetadataTest extends AbstractTest {
|
|||
assertNotNull(fi);
|
||||
assertEquals(demoService.getEntitySet("Products"), fi.getReturnedEntitySet());
|
||||
|
||||
final EdmFunction function = edm.getFunction(
|
||||
new FullQualifiedName(metadata.getSchema(0).getNamespace(), "ProductsByRating"),
|
||||
null, Boolean.FALSE, null);
|
||||
final EdmFunction function = edm.getUnboundFunction(
|
||||
new FullQualifiedName(metadata.getSchema(0).getNamespace(), "ProductsByRating"), null);
|
||||
assertNotNull(function);
|
||||
assertEquals(function.getName(), fi.getUnboundFunction(null).getName());
|
||||
assertEquals(function.getNamespace(), fi.getUnboundFunction(null).getNamespace());
|
||||
|
|
|
@ -27,92 +27,117 @@ import java.util.List;
|
|||
*/
|
||||
public interface Edm {
|
||||
|
||||
/**
|
||||
* This method <b>DOES NOT</b> support lazy loading. All schemas are loaded completely!
|
||||
*
|
||||
* @return all schemas defined for this EDM
|
||||
*/
|
||||
List<EdmSchema> getSchemas();
|
||||
/**
|
||||
* This method <b>DOES NOT</b> support lazy loading. All schemas are loaded completely!
|
||||
*
|
||||
* @return all schemas defined for this EDM
|
||||
*/
|
||||
List<EdmSchema> getSchemas();
|
||||
|
||||
/**
|
||||
* Get entity container by full qualified name.
|
||||
* <br/>
|
||||
* See {@link EdmEntityContainer} for more information.
|
||||
*
|
||||
* @param name
|
||||
* @return {@link EdmEntityContainer}
|
||||
*/
|
||||
EdmEntityContainer getEntityContainer(FullQualifiedName name);
|
||||
/**
|
||||
* Get entity container by full qualified name.
|
||||
* <br/>
|
||||
* See {@link EdmEntityContainer} for more information.
|
||||
*
|
||||
* @param name
|
||||
* @return {@link EdmEntityContainer}
|
||||
*/
|
||||
EdmEntityContainer getEntityContainer(FullQualifiedName name);
|
||||
|
||||
/**
|
||||
* Get enum type by full qualified name.
|
||||
* <br/>
|
||||
* See {@link EdmEnumType} for more information
|
||||
*
|
||||
* @param name
|
||||
* @return {@link EdmEnumType}
|
||||
*/
|
||||
EdmEnumType getEnumType(FullQualifiedName name);
|
||||
/**
|
||||
* Get enum type by full qualified name.
|
||||
* <br/>
|
||||
* See {@link EdmEnumType} for more information
|
||||
*
|
||||
* @param name
|
||||
* @return {@link EdmEnumType}
|
||||
*/
|
||||
EdmEnumType getEnumType(FullQualifiedName name);
|
||||
|
||||
/**
|
||||
* Get a type definition by full qualified name.
|
||||
* <br/>
|
||||
* See {@link EdmTypeDefinition} for more information
|
||||
*
|
||||
* @param name
|
||||
* @return {@link EdmTypeDefinition}
|
||||
*/
|
||||
EdmTypeDefinition getTypeDefinition(FullQualifiedName name);
|
||||
/**
|
||||
* Get a type definition by full qualified name.
|
||||
* <br/>
|
||||
* See {@link EdmTypeDefinition} for more information
|
||||
*
|
||||
* @param name
|
||||
* @return {@link EdmTypeDefinition}
|
||||
*/
|
||||
EdmTypeDefinition getTypeDefinition(FullQualifiedName name);
|
||||
|
||||
/**
|
||||
* Get entity type by full qualified name.
|
||||
* <br/>
|
||||
* See {@link EdmEntityType} for more information.
|
||||
*
|
||||
* @param name
|
||||
* @return {@link EdmEntityType}
|
||||
*/
|
||||
EdmEntityType getEntityType(FullQualifiedName name);
|
||||
/**
|
||||
* Get entity type by full qualified name.
|
||||
* <br/>
|
||||
* See {@link EdmEntityType} for more information.
|
||||
*
|
||||
* @param name
|
||||
* @return {@link EdmEntityType}
|
||||
*/
|
||||
EdmEntityType getEntityType(FullQualifiedName name);
|
||||
|
||||
/**
|
||||
* Get complex type by full qualified name..
|
||||
* <br/>
|
||||
* See {@link EdmComplexType} for more information.
|
||||
*
|
||||
* @param name
|
||||
* @return {@link EdmComplexType}
|
||||
*/
|
||||
EdmComplexType getComplexType(FullQualifiedName name);
|
||||
/**
|
||||
* Get complex type by full qualified name..
|
||||
* <br/>
|
||||
* See {@link EdmComplexType} for more information.
|
||||
*
|
||||
* @param name
|
||||
* @return {@link EdmComplexType}
|
||||
*/
|
||||
EdmComplexType getComplexType(FullQualifiedName name);
|
||||
|
||||
/**
|
||||
* Get Action by full qualified name and binding parameter type.
|
||||
*
|
||||
* @param actionName must not be null
|
||||
* @param bindingParameterTypeName may be null if it is an unbound action
|
||||
* @param isBindingParameterCollection may be null if it is an unbound action
|
||||
* @return {@link EdmAction}
|
||||
*/
|
||||
EdmAction getAction(FullQualifiedName actionName, FullQualifiedName bindingParameterTypeName,
|
||||
Boolean isBindingParameterCollection);
|
||||
/**
|
||||
* Get unbound Action by full qualified name.
|
||||
*
|
||||
* @param actionName must not be null
|
||||
* @return {@link EdmAction}
|
||||
*/
|
||||
EdmAction getUnboundAction(FullQualifiedName actionName);
|
||||
|
||||
/**
|
||||
* Get Function by full qualified name and binding parameter type and binding parameter names.
|
||||
*
|
||||
* @param functionName
|
||||
* @param bindingParameterTypeName may be null if it is an unbound function
|
||||
* @param isBindingParameterCollection may be null if it is an unbound function
|
||||
* @param parameterNames may be null if it is an unbound function
|
||||
* @return {@link EdmFunction}
|
||||
*/
|
||||
EdmFunction getFunction(FullQualifiedName functionName, FullQualifiedName bindingParameterTypeName,
|
||||
Boolean isBindingParameterCollection, List<String> parameterNames);
|
||||
/**
|
||||
* Get Action by full qualified name and binding parameter type.
|
||||
*
|
||||
* @param actionName must not be null
|
||||
* @param bindingParameterTypeName must not be null
|
||||
* @param isBindingParameterCollection may be null
|
||||
* @return {@link EdmAction}
|
||||
*/
|
||||
EdmAction getBoundAction(FullQualifiedName actionName, FullQualifiedName bindingParameterTypeName,
|
||||
Boolean isBindingParameterCollection);
|
||||
|
||||
/**
|
||||
* Get service metadata.
|
||||
* <br/>
|
||||
* See {@link EdmServiceMetadata} for more information.
|
||||
*
|
||||
* @return {@link EdmServiceMetadata}
|
||||
*/
|
||||
EdmServiceMetadata getServiceMetadata();
|
||||
/**
|
||||
* Get Function by full qualified name.
|
||||
*
|
||||
* @param functionName must not be null
|
||||
* @return {@link EdmFunction}
|
||||
*/
|
||||
List<EdmFunction> getUnboundFunctions(FullQualifiedName functionName);
|
||||
|
||||
/**
|
||||
* Get Function by full qualified name.
|
||||
*
|
||||
* @param functionName must not be null
|
||||
* @param parameterNames may be null: in this case it is considered as empty
|
||||
* @return {@link EdmFunction}
|
||||
*/
|
||||
EdmFunction getUnboundFunction(FullQualifiedName functionName, List<String> parameterNames);
|
||||
|
||||
/**
|
||||
* Get Function by full qualified name and binding parameter type and binding parameter names.
|
||||
*
|
||||
* @param functionName must not be null
|
||||
* @param bindingParameterTypeName must not be null
|
||||
* @param isBindingParameterCollection may be null
|
||||
* @param parameterNames may be null: in this case it is considered as empty
|
||||
* @return {@link EdmFunction}
|
||||
*/
|
||||
EdmFunction getBoundFunction(FullQualifiedName functionName, FullQualifiedName bindingParameterTypeName,
|
||||
Boolean isBindingParameterCollection, List<String> parameterNames);
|
||||
|
||||
/**
|
||||
* Get service metadata.
|
||||
* <br/>
|
||||
* See {@link EdmServiceMetadata} for more information.
|
||||
*
|
||||
* @return {@link EdmServiceMetadata}
|
||||
*/
|
||||
EdmServiceMetadata getServiceMetadata();
|
||||
}
|
||||
|
|
|
@ -29,13 +29,4 @@ public interface EdmActionImport extends EdmOperationImport {
|
|||
* @return unbound action.
|
||||
*/
|
||||
EdmAction getUnboundAction();
|
||||
|
||||
/**
|
||||
* Gets bound action.
|
||||
*
|
||||
* @param bindingParameterTypeName may be null if it is an unbound function
|
||||
* @param isBindingParameterCollection may be null if it is an unbound function
|
||||
* @return bound action with given parameter names
|
||||
*/
|
||||
EdmAction getBoundAction(FullQualifiedName bindingParameterTypeName, Boolean isBindingParameterCollection);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,13 @@ import java.util.List;
|
|||
*/
|
||||
public interface EdmFunctionImport extends EdmOperationImport {
|
||||
|
||||
/**
|
||||
* Gets unbound functions.
|
||||
*
|
||||
* @return unbound functions
|
||||
*/
|
||||
List<EdmFunction> getUnboundFunctions();
|
||||
|
||||
/**
|
||||
* Gets unbound function with given parameter names.
|
||||
*
|
||||
|
@ -33,17 +40,6 @@ public interface EdmFunctionImport extends EdmOperationImport {
|
|||
*/
|
||||
EdmFunction getUnboundFunction(List<String> parameterNames);
|
||||
|
||||
/**
|
||||
* Gets bound function with given parameter names.
|
||||
*
|
||||
* @param parameterNames parameter names
|
||||
* @param bindingParameterTypeName may be null if it is an unbound function
|
||||
* @param isBindingParameterCollection may be null if it is an unbound function
|
||||
* @return bound function with given parameter names
|
||||
*/
|
||||
EdmFunction getBoundFunction(List<String> parameterNames,
|
||||
FullQualifiedName bindingParameterTypeName, Boolean isBindingParameterCollection);
|
||||
|
||||
/**
|
||||
* @return the Full qualified name for the function as specified in the metadata
|
||||
*/
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.apache.olingo.commons.core.edm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -37,12 +38,12 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
|||
public abstract class AbstractEdm implements Edm {
|
||||
|
||||
private final Map<FullQualifiedName, EdmEntityContainer> entityContainers =
|
||||
new HashMap<FullQualifiedName, EdmEntityContainer>();
|
||||
new HashMap<FullQualifiedName, EdmEntityContainer>();
|
||||
|
||||
private final Map<FullQualifiedName, EdmEnumType> enumTypes = new HashMap<FullQualifiedName, EdmEnumType>();
|
||||
|
||||
private final Map<FullQualifiedName, EdmTypeDefinition> typeDefinitions =
|
||||
new HashMap<FullQualifiedName, EdmTypeDefinition>();
|
||||
new HashMap<FullQualifiedName, EdmTypeDefinition>();
|
||||
|
||||
private final Map<FullQualifiedName, EdmEntityType> entityTypes = new HashMap<FullQualifiedName, EdmEntityType>();
|
||||
|
||||
|
@ -50,7 +51,10 @@ public abstract class AbstractEdm implements Edm {
|
|||
|
||||
private final Map<FullQualifiedName, EdmAction> unboundActions = new HashMap<FullQualifiedName, EdmAction>();
|
||||
|
||||
private final Map<FunctionMapKey, EdmFunction> unboundFunctions = new HashMap<FunctionMapKey, EdmFunction>();
|
||||
private final Map<FullQualifiedName, List<EdmFunction>> unboundFunctionsByName =
|
||||
new HashMap<FullQualifiedName, List<EdmFunction>>();
|
||||
|
||||
private final Map<FunctionMapKey, EdmFunction> unboundFunctionsByKey = new HashMap<FunctionMapKey, EdmFunction>();
|
||||
|
||||
private final Map<ActionMapKey, EdmAction> boundActions = new HashMap<ActionMapKey, EdmAction>();
|
||||
|
||||
|
@ -69,26 +73,26 @@ public abstract class AbstractEdm implements Edm {
|
|||
if (schemas != null) {
|
||||
aliasToNamespaceInfo = new HashMap<String, String>();
|
||||
for (EdmSchema schema : schemas) {
|
||||
String namespace = schema.getNamespace();
|
||||
final String namespace = schema.getNamespace();
|
||||
if (schema.getAlias() != null) {
|
||||
aliasToNamespaceInfo.put(schema.getAlias(), namespace);
|
||||
}
|
||||
|
||||
List<EdmEnumType> localEnumTypes = schema.getEnumTypes();
|
||||
final List<EdmEnumType> localEnumTypes = schema.getEnumTypes();
|
||||
if (localEnumTypes != null) {
|
||||
for (EdmEnumType enumType : localEnumTypes) {
|
||||
enumTypes.put(new FullQualifiedName(namespace, enumType.getName()), enumType);
|
||||
}
|
||||
}
|
||||
|
||||
List<EdmTypeDefinition> localTypeDefinitions = schema.getTypeDefinitions();
|
||||
final List<EdmTypeDefinition> localTypeDefinitions = schema.getTypeDefinitions();
|
||||
if (localTypeDefinitions != null) {
|
||||
for (EdmTypeDefinition typeDef : localTypeDefinitions) {
|
||||
typeDefinitions.put(new FullQualifiedName(namespace, typeDef.getName()), typeDef);
|
||||
}
|
||||
}
|
||||
|
||||
List<EdmComplexType> localComplexTypes = schema.getComplexTypes();
|
||||
final List<EdmComplexType> localComplexTypes = schema.getComplexTypes();
|
||||
if (localComplexTypes != null) {
|
||||
for (EdmComplexType complexType : localComplexTypes) {
|
||||
complexTypes.put(new FullQualifiedName(namespace, complexType.getName()), complexType);
|
||||
|
@ -102,39 +106,45 @@ public abstract class AbstractEdm implements Edm {
|
|||
}
|
||||
}
|
||||
|
||||
List<EdmAction> localActions = schema.getActions();
|
||||
final List<EdmAction> localActions = schema.getActions();
|
||||
if (localActions != null) {
|
||||
for (EdmAction action : localActions) {
|
||||
final FullQualifiedName name = new FullQualifiedName(namespace, action.getName());
|
||||
if (action.isBound()) {
|
||||
ActionMapKey key = new ActionMapKey(new FullQualifiedName(namespace, action.getName()),
|
||||
action.getBindingParameterTypeFqn(), action.isBindingParameterTypeCollection());
|
||||
final ActionMapKey key = new ActionMapKey(name,
|
||||
action.getBindingParameterTypeFqn(), action.isBindingParameterTypeCollection());
|
||||
boundActions.put(key, action);
|
||||
} else {
|
||||
unboundActions.put(new FullQualifiedName(namespace, action.getName()), action);
|
||||
unboundActions.put(name, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<EdmFunction> localFunctions = schema.getFunctions();
|
||||
final List<EdmFunction> localFunctions = schema.getFunctions();
|
||||
if (localFunctions != null) {
|
||||
for (EdmFunction function : localFunctions) {
|
||||
FunctionMapKey key =
|
||||
new FunctionMapKey(new FullQualifiedName(namespace, function.getName()), function
|
||||
.getBindingParameterTypeFqn(), function.isBindingParameterTypeCollection(), function
|
||||
.getParameterNames());
|
||||
final FullQualifiedName name = new FullQualifiedName(namespace, function.getName());
|
||||
final FunctionMapKey key = new FunctionMapKey(name,
|
||||
function.getBindingParameterTypeFqn(), function.isBindingParameterTypeCollection(),
|
||||
function.getParameterNames());
|
||||
|
||||
if (function.isBound()) {
|
||||
boundFunctions.put(key, function);
|
||||
} else {
|
||||
unboundFunctions.put(key, function);
|
||||
if (!unboundFunctionsByName.containsKey(name)) {
|
||||
unboundFunctionsByName.put(name, new ArrayList<EdmFunction>());
|
||||
}
|
||||
unboundFunctionsByName.get(name).add(function);
|
||||
|
||||
unboundFunctionsByKey.put(key, function);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EdmEntityContainer entityContainer = schema.getEntityContainer();
|
||||
if(entityContainer != null){
|
||||
|
||||
final EdmEntityContainer entityContainer = schema.getEntityContainer();
|
||||
if (entityContainer != null) {
|
||||
entityContainers.put(new FullQualifiedName(namespace, entityContainer.getName()), entityContainer);
|
||||
if(!entityContainers.containsKey(null)){
|
||||
if (!entityContainers.containsKey(null)) {
|
||||
entityContainers.put(null, entityContainer);
|
||||
}
|
||||
}
|
||||
|
@ -213,29 +223,12 @@ public abstract class AbstractEdm implements Edm {
|
|||
}
|
||||
|
||||
@Override
|
||||
public EdmAction getAction(final FullQualifiedName actionName, final FullQualifiedName bindingParameterTypeName,
|
||||
final Boolean isBindingParameterCollection) {
|
||||
|
||||
EdmAction action = null;
|
||||
|
||||
final FullQualifiedName actionFqn = resolvePossibleAlias(actionName);
|
||||
if (bindingParameterTypeName == null) {
|
||||
action = unboundActions.get(actionName);
|
||||
if (action == null) {
|
||||
action = createUnboundAction(actionFqn);
|
||||
if (action != null) {
|
||||
unboundActions.put(actionName, action);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final FullQualifiedName bindingParameterTypeFqn = resolvePossibleAlias(bindingParameterTypeName);
|
||||
final ActionMapKey key = new ActionMapKey(actionFqn, bindingParameterTypeFqn, isBindingParameterCollection);
|
||||
action = boundActions.get(key);
|
||||
if (action == null) {
|
||||
action = createBoundAction(actionFqn, bindingParameterTypeFqn, isBindingParameterCollection);
|
||||
if (action != null) {
|
||||
boundActions.put(key, action);
|
||||
}
|
||||
public EdmAction getUnboundAction(final FullQualifiedName actionName) {
|
||||
EdmAction action = unboundActions.get(actionName);
|
||||
if (action == null) {
|
||||
action = createUnboundAction(resolvePossibleAlias(actionName));
|
||||
if (action != null) {
|
||||
unboundActions.put(actionName, action);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,34 +236,83 @@ public abstract class AbstractEdm implements Edm {
|
|||
}
|
||||
|
||||
@Override
|
||||
public EdmFunction getFunction(final FullQualifiedName functionName,
|
||||
final FullQualifiedName bindingParameterTypeName,
|
||||
final Boolean isBindingParameterCollection, final List<String> parameterNames) {
|
||||
public EdmAction getBoundAction(final FullQualifiedName actionName,
|
||||
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) {
|
||||
|
||||
EdmFunction function = null;
|
||||
final FullQualifiedName actionFqn = resolvePossibleAlias(actionName);
|
||||
final FullQualifiedName bindingParameterTypeFqn = resolvePossibleAlias(bindingParameterTypeName);
|
||||
final ActionMapKey key = new ActionMapKey(actionFqn, bindingParameterTypeFqn, isBindingParameterCollection);
|
||||
EdmAction action = boundActions.get(key);
|
||||
if (action == null) {
|
||||
action = createBoundAction(actionFqn, bindingParameterTypeFqn, isBindingParameterCollection);
|
||||
if (action != null) {
|
||||
boundActions.put(key, action);
|
||||
}
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmFunction> getUnboundFunctions(final FullQualifiedName functionName) {
|
||||
final FullQualifiedName functionFqn = resolvePossibleAlias(functionName);
|
||||
if (bindingParameterTypeName == null) {
|
||||
final FunctionMapKey key = new FunctionMapKey(
|
||||
functionFqn, bindingParameterTypeName, isBindingParameterCollection, parameterNames);
|
||||
function = unboundFunctions.get(key);
|
||||
if (function == null) {
|
||||
function = createUnboundFunction(functionFqn, parameterNames);
|
||||
if (function != null) {
|
||||
unboundFunctions.put(key, function);
|
||||
|
||||
List<EdmFunction> functions = unboundFunctionsByName.get(functionFqn);
|
||||
if (functions == null) {
|
||||
functions = createUnboundFunctions(functionFqn);
|
||||
if (functions != null) {
|
||||
unboundFunctionsByName.put(functionFqn, functions);
|
||||
|
||||
for (EdmFunction unbound : functions) {
|
||||
final FunctionMapKey key = new FunctionMapKey(
|
||||
new FullQualifiedName(unbound.getNamespace(), unbound.getName()),
|
||||
unbound.getBindingParameterTypeFqn(),
|
||||
unbound.isBindingParameterTypeCollection(),
|
||||
unbound.getParameterNames());
|
||||
unboundFunctionsByKey.put(key, unbound);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final FullQualifiedName bindingParameterTypeFqn = resolvePossibleAlias(bindingParameterTypeName);
|
||||
final FunctionMapKey key =
|
||||
new FunctionMapKey(functionFqn, bindingParameterTypeFqn, isBindingParameterCollection, parameterNames);
|
||||
function = boundFunctions.get(key);
|
||||
if (function == null) {
|
||||
function = createBoundFunction(functionFqn, bindingParameterTypeFqn, isBindingParameterCollection,
|
||||
parameterNames);
|
||||
if (function != null) {
|
||||
boundFunctions.put(key, function);
|
||||
}
|
||||
|
||||
return functions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmFunction getUnboundFunction(final FullQualifiedName functionName, final List<String> parameterNames) {
|
||||
final FullQualifiedName functionFqn = resolvePossibleAlias(functionName);
|
||||
|
||||
final FunctionMapKey key = new FunctionMapKey(functionFqn, null, null, parameterNames);
|
||||
EdmFunction function = unboundFunctionsByKey.get(key);
|
||||
if (function == null) {
|
||||
function = createUnboundFunction(functionFqn, parameterNames);
|
||||
if (function != null) {
|
||||
unboundFunctionsByKey.put(key, function);
|
||||
|
||||
if (!unboundFunctionsByName.containsKey(functionFqn)) {
|
||||
unboundFunctionsByName.put(functionFqn, new ArrayList<EdmFunction>());
|
||||
}
|
||||
unboundFunctionsByName.get(functionFqn).add(function);
|
||||
}
|
||||
}
|
||||
|
||||
return function;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmFunction getBoundFunction(final FullQualifiedName functionName,
|
||||
final FullQualifiedName bindingParameterTypeName,
|
||||
final Boolean isBindingParameterCollection, final List<String> parameterNames) {
|
||||
|
||||
final FullQualifiedName functionFqn = resolvePossibleAlias(functionName);
|
||||
final FullQualifiedName bindingParameterTypeFqn = resolvePossibleAlias(bindingParameterTypeName);
|
||||
final FunctionMapKey key =
|
||||
new FunctionMapKey(functionFqn, bindingParameterTypeFqn, isBindingParameterCollection, parameterNames);
|
||||
EdmFunction function = boundFunctions.get(key);
|
||||
if (function == null) {
|
||||
function = createBoundFunction(functionFqn, bindingParameterTypeFqn, isBindingParameterCollection,
|
||||
parameterNames);
|
||||
if (function != null) {
|
||||
boundFunctions.put(key, function);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -316,15 +358,17 @@ public abstract class AbstractEdm implements Edm {
|
|||
|
||||
protected abstract EdmAction createUnboundAction(FullQualifiedName actionName);
|
||||
|
||||
protected abstract List<EdmFunction> createUnboundFunctions(FullQualifiedName functionName);
|
||||
|
||||
protected abstract EdmFunction createUnboundFunction(FullQualifiedName functionName, List<String> parameterNames);
|
||||
|
||||
protected abstract EdmAction createBoundAction(FullQualifiedName actionName,
|
||||
FullQualifiedName bindingParameterTypeName,
|
||||
Boolean isBindingParameterCollection);
|
||||
FullQualifiedName bindingParameterTypeName,
|
||||
Boolean isBindingParameterCollection);
|
||||
|
||||
protected abstract EdmFunction createBoundFunction(FullQualifiedName functionName,
|
||||
FullQualifiedName bindingParameterTypeName, Boolean isBindingParameterCollection,
|
||||
List<String> parameterNames);
|
||||
FullQualifiedName bindingParameterTypeName, Boolean isBindingParameterCollection,
|
||||
List<String> parameterNames);
|
||||
|
||||
protected abstract EdmServiceMetadata createServiceMetadata();
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import static org.mockito.Mockito.mock;
|
|||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -41,7 +42,6 @@ import org.apache.olingo.commons.api.edm.EdmSchema;
|
|||
import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
|
||||
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.core.edm.AbstractEdm;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -57,14 +57,14 @@ public class EdmImplCachingTest {
|
|||
public void cacheSchema() {
|
||||
List<EdmSchema> schemas = edm.getSchemas();
|
||||
assertNotNull(schemas);
|
||||
|
||||
|
||||
assertEquals(1, schemas.size());
|
||||
|
||||
|
||||
List<EdmSchema> cachedSchemas = edm.getSchemas();
|
||||
assertTrue(schemas == cachedSchemas );
|
||||
assertTrue(schemas == cachedSchemas);
|
||||
assertEquals(schemas, schemas);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void cacheEntityContainer() {
|
||||
EdmEntityContainer entityContainer = edm.getEntityContainer(null);
|
||||
|
@ -158,32 +158,32 @@ public class EdmImplCachingTest {
|
|||
|
||||
@Test
|
||||
public void cacheUnboundAction() {
|
||||
EdmAction action = edm.getAction(NAME1, null, null);
|
||||
EdmAction action = edm.getUnboundAction(NAME1);
|
||||
assertNotNull(action);
|
||||
|
||||
EdmAction cachedAction = edm.getAction(NAME1, null, null);
|
||||
EdmAction cachedAction = edm.getUnboundAction(NAME1);
|
||||
assertNotNull(cachedAction);
|
||||
|
||||
assertTrue(action == cachedAction);
|
||||
assertEquals(action, cachedAction);
|
||||
|
||||
EdmAction action2 = edm.getAction(NAME2, null, false);
|
||||
EdmAction action2 = edm.getUnboundAction(NAME2);
|
||||
assertNotNull(action2);
|
||||
assertNotSame(action, action2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cacheBoundAction() {
|
||||
EdmAction action = edm.getAction(NAME1, NAME2, true);
|
||||
EdmAction action = edm.getBoundAction(NAME1, NAME2, true);
|
||||
assertNotNull(action);
|
||||
|
||||
EdmAction cachedAction = edm.getAction(NAME1, NAME2, true);
|
||||
EdmAction cachedAction = edm.getBoundAction(NAME1, NAME2, true);
|
||||
assertNotNull(cachedAction);
|
||||
|
||||
assertTrue(action == cachedAction);
|
||||
assertEquals(action, cachedAction);
|
||||
|
||||
EdmAction action2 = edm.getAction(NAME2, NAME2, true);
|
||||
EdmAction action2 = edm.getBoundAction(NAME2, NAME2, true);
|
||||
assertNotNull(action2);
|
||||
assertNotSame(action, action2);
|
||||
|
||||
|
@ -191,16 +191,16 @@ public class EdmImplCachingTest {
|
|||
|
||||
@Test
|
||||
public void cacheUnboundFunctionNoParameters() {
|
||||
EdmFunction function = edm.getFunction(NAME1, null, null, null);
|
||||
EdmFunction function = edm.getUnboundFunction(NAME1, null);
|
||||
assertNotNull(function);
|
||||
|
||||
EdmFunction cachedfunction = edm.getFunction(NAME1, null, null, null);
|
||||
EdmFunction cachedfunction = edm.getUnboundFunction(NAME1, null);
|
||||
assertNotNull(cachedfunction);
|
||||
|
||||
assertTrue(function == cachedfunction);
|
||||
assertEquals(function, cachedfunction);
|
||||
|
||||
EdmFunction function2 = edm.getFunction(NAME2, null, false, null);
|
||||
EdmFunction function2 = edm.getBoundFunction(NAME2, null, false, null);
|
||||
assertNotNull(function2);
|
||||
|
||||
assertNotSame(function, function2);
|
||||
|
@ -208,16 +208,16 @@ public class EdmImplCachingTest {
|
|||
|
||||
@Test
|
||||
public void cacheBoundFunction() {
|
||||
EdmFunction function = edm.getFunction(NAME1, NAME2, true, new ArrayList<String>());
|
||||
EdmFunction function = edm.getBoundFunction(NAME1, NAME2, true, new ArrayList<String>());
|
||||
assertNotNull(function);
|
||||
|
||||
EdmFunction cachedfunction = edm.getFunction(NAME1, NAME2, true, new ArrayList<String>());
|
||||
EdmFunction cachedfunction = edm.getBoundFunction(NAME1, NAME2, true, new ArrayList<String>());
|
||||
assertNotNull(cachedfunction);
|
||||
|
||||
assertTrue(function == cachedfunction);
|
||||
assertEquals(function, cachedfunction);
|
||||
|
||||
EdmFunction function2 = edm.getFunction(NAME2, NAME2, true, new ArrayList<String>());
|
||||
EdmFunction function2 = edm.getBoundFunction(NAME2, NAME2, true, new ArrayList<String>());
|
||||
assertNotNull(function2);
|
||||
|
||||
assertNotSame(function, function2);
|
||||
|
@ -228,19 +228,19 @@ public class EdmImplCachingTest {
|
|||
ArrayList<String> parameters1 = new ArrayList<String>();
|
||||
parameters1.add("A");
|
||||
parameters1.add("B");
|
||||
EdmFunction function = edm.getFunction(NAME1, NAME2, true, parameters1);
|
||||
EdmFunction function = edm.getBoundFunction(NAME1, NAME2, true, parameters1);
|
||||
assertNotNull(function);
|
||||
|
||||
ArrayList<String> parameters2 = new ArrayList<String>();
|
||||
parameters2.add("B");
|
||||
parameters2.add("A");
|
||||
EdmFunction cachedfunction = edm.getFunction(NAME1, NAME2, true, parameters2);
|
||||
EdmFunction cachedfunction = edm.getBoundFunction(NAME1, NAME2, true, parameters2);
|
||||
assertNotNull(cachedfunction);
|
||||
|
||||
assertTrue(function == cachedfunction);
|
||||
assertEquals(function, cachedfunction);
|
||||
|
||||
EdmFunction function2 = edm.getFunction(NAME2, NAME2, true, new ArrayList<String>());
|
||||
EdmFunction function2 = edm.getBoundFunction(NAME2, NAME2, true, new ArrayList<String>());
|
||||
assertNotNull(function2);
|
||||
|
||||
assertNotSame(function, function2);
|
||||
|
@ -383,6 +383,22 @@ public class EdmImplCachingTest {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<EdmFunction> createUnboundFunctions(final FullQualifiedName fqn) {
|
||||
if (NAME1.equals(fqn)) {
|
||||
EdmFunction function = mock(EdmFunction.class);
|
||||
when(function.getNamespace()).thenReturn(fqn.getNamespace());
|
||||
when(function.getName()).thenReturn(fqn.getName());
|
||||
return Collections.singletonList(function);
|
||||
} else if (NAME2.equals(fqn)) {
|
||||
EdmFunction function = mock(EdmFunction.class);
|
||||
when(function.getNamespace()).thenReturn(fqn.getNamespace());
|
||||
when(function.getName()).thenReturn(fqn.getName());
|
||||
return Collections.singletonList(function);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmFunction createUnboundFunction(final FullQualifiedName fqn, final List<String> parameterNames) {
|
||||
if (NAME1.equals(fqn)) {
|
||||
|
|
|
@ -26,6 +26,7 @@ import static org.mockito.Mockito.mock;
|
|||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -41,7 +42,6 @@ import org.apache.olingo.commons.api.edm.EdmSchema;
|
|||
import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
|
||||
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.core.edm.AbstractEdm;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class EdmImplCallCreateTest {
|
|||
List<EdmSchema> schemas = edm.getSchemas();
|
||||
assertNotNull(schemas);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void callCreateEntityContainer() {
|
||||
EdmEntityContainer entityContainer = edm.getEntityContainer(FQN);
|
||||
|
@ -116,36 +116,36 @@ public class EdmImplCallCreateTest {
|
|||
|
||||
@Test
|
||||
public void callCreateAction() {
|
||||
EdmAction action = edm.getAction(FQN, null, null);
|
||||
EdmAction action = edm.getUnboundAction(FQN);
|
||||
assertNotNull(action);
|
||||
assertEquals(FQN.getNamespace(), action.getNamespace());
|
||||
assertEquals(FQN.getName(), action.getName());
|
||||
|
||||
EdmAction action2 = edm.getAction(FQN, FQN, true);
|
||||
EdmAction action2 = edm.getBoundAction(FQN, FQN, true);
|
||||
assertNotNull(action2);
|
||||
assertEquals(FQN.getNamespace(), action2.getNamespace());
|
||||
assertEquals(FQN.getName(), action2.getName());
|
||||
|
||||
assertNotSame(action, action2);
|
||||
|
||||
assertNull(edm.getAction(WRONG_FQN, null, null));
|
||||
assertNull(edm.getUnboundAction(WRONG_FQN));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void callCreateFunction() {
|
||||
EdmFunction function = edm.getFunction(FQN, null, null, null);
|
||||
EdmFunction function = edm.getUnboundFunction(FQN, null);
|
||||
assertNotNull(function);
|
||||
assertEquals(FQN.getNamespace(), function.getNamespace());
|
||||
assertEquals(FQN.getName(), function.getName());
|
||||
|
||||
EdmFunction function2 = edm.getFunction(FQN, FQN, true, new ArrayList<String>());
|
||||
EdmFunction function2 = edm.getBoundFunction(FQN, FQN, true, new ArrayList<String>());
|
||||
assertNotNull(function2);
|
||||
assertEquals(FQN.getNamespace(), function2.getNamespace());
|
||||
assertEquals(FQN.getName(), function2.getName());
|
||||
|
||||
assertNotSame(function, function2);
|
||||
|
||||
assertNull(edm.getFunction(WRONG_FQN, null, null, null));
|
||||
assertNull(edm.getUnboundFunction(WRONG_FQN, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -261,6 +261,17 @@ public class EdmImplCallCreateTest {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<EdmFunction> createUnboundFunctions(final FullQualifiedName fqn) {
|
||||
if (FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
|
||||
EdmFunction function = mock(EdmFunction.class);
|
||||
when(function.getNamespace()).thenReturn(fqn.getNamespace());
|
||||
when(function.getName()).thenReturn(fqn.getName());
|
||||
return Collections.singletonList(function);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmFunction createUnboundFunction(final FullQualifiedName fqn, final List<String> parameterNames) {
|
||||
if (FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.apache.olingo.commons.api.edm.Edm;
|
|||
import org.apache.olingo.commons.api.edm.EdmAction;
|
||||
import org.apache.olingo.commons.api.edm.EdmActionImport;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.server.api.edm.provider.ActionImport;
|
||||
|
||||
public class EdmActionImportImpl extends EdmOperationImportImpl implements EdmActionImport {
|
||||
|
@ -37,14 +36,7 @@ public class EdmActionImportImpl extends EdmOperationImportImpl implements EdmAc
|
|||
|
||||
@Override
|
||||
public EdmAction getUnboundAction() {
|
||||
return getBoundAction(null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmAction getBoundAction(
|
||||
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) {
|
||||
|
||||
return edm.getAction(actionImport.getAction(), bindingParameterTypeName, isBindingParameterCollection);
|
||||
return edm.getUnboundAction(actionImport.getAction());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,17 +38,18 @@ public class EdmFunctionImportImpl extends EdmOperationImportImpl implements Edm
|
|||
}
|
||||
|
||||
@Override
|
||||
public EdmFunction getUnboundFunction(final List<String> parameterNames) {
|
||||
return getBoundFunction(parameterNames, null, null);
|
||||
public FullQualifiedName getFunctionFqn() {
|
||||
return functionImport.getFunction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmFunction getBoundFunction(final List<String> parameterNames,
|
||||
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) {
|
||||
|
||||
return edm.getFunction(functionImport.getFunction(),
|
||||
bindingParameterTypeName, isBindingParameterCollection, parameterNames);
|
||||
public EdmFunction getUnboundFunction(final List<String> parameterNames) {
|
||||
return edm.getUnboundFunction(getFunctionFqn(), parameterNames);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmFunction> getUnboundFunctions() {
|
||||
return edm.getUnboundFunctions(getFunctionFqn());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,8 +57,4 @@ public class EdmFunctionImportImpl extends EdmOperationImportImpl implements Edm
|
|||
return functionImport.isIncludeInServiceDocument();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FullQualifiedName getFunctionFqn() {
|
||||
return functionImport.getFunction();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ public class EdmProviderImpl extends AbstractEdm {
|
|||
|
||||
@Override
|
||||
public EdmAction createBoundAction(final FullQualifiedName actionName,
|
||||
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) {
|
||||
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) {
|
||||
|
||||
try {
|
||||
List<Action> actions = actionsMap.get(actionName);
|
||||
|
@ -147,7 +147,7 @@ public class EdmProviderImpl extends AbstractEdm {
|
|||
final List<Parameter> parameters = action.getParameters();
|
||||
final Parameter parameter = parameters.get(0);
|
||||
if (bindingParameterTypeName.equals(parameter.getType())
|
||||
&& isBindingParameterCollection.booleanValue() == parameter.isCollection()) {
|
||||
&& isBindingParameterCollection.booleanValue() == parameter.isCollection()) {
|
||||
|
||||
return EdmActionImpl.getInstance(this, actionName, action);
|
||||
}
|
||||
|
@ -162,8 +162,8 @@ public class EdmProviderImpl extends AbstractEdm {
|
|||
|
||||
@Override
|
||||
public EdmFunction createBoundFunction(final FullQualifiedName functionName,
|
||||
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection,
|
||||
final List<String> parameterNames) {
|
||||
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection,
|
||||
final List<String> parameterNames) {
|
||||
|
||||
try {
|
||||
List<Function> functions = functionsMap.get(functionName);
|
||||
|
@ -175,8 +175,8 @@ public class EdmProviderImpl extends AbstractEdm {
|
|||
functionsMap.put(functionName, functions);
|
||||
}
|
||||
}
|
||||
final List<String> parameterNamesCopy =
|
||||
parameterNames == null ? Collections.<String> emptyList() : parameterNames;
|
||||
final List<String> parameterNamesCopy
|
||||
= parameterNames == null ? Collections.<String>emptyList() : parameterNames;
|
||||
for (Function function : functions) {
|
||||
if (function.isBound()) {
|
||||
List<Parameter> providerParameters = function.getParameters();
|
||||
|
@ -185,7 +185,7 @@ public class EdmProviderImpl extends AbstractEdm {
|
|||
}
|
||||
final Parameter bindingParameter = providerParameters.get(0);
|
||||
if (bindingParameterTypeName.equals(bindingParameter.getType())
|
||||
&& isBindingParameterCollection.booleanValue() == bindingParameter.isCollection()) {
|
||||
&& isBindingParameterCollection.booleanValue() == bindingParameter.isCollection()) {
|
||||
|
||||
if (parameterNamesCopy.size() == providerParameters.size() - 1) {
|
||||
final List<String> providerParameterNames = new ArrayList<String>();
|
||||
|
@ -251,19 +251,44 @@ public class EdmProviderImpl extends AbstractEdm {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected EdmFunction createUnboundFunction(final FullQualifiedName functionName, final List<String> parameterNames) {
|
||||
protected List<EdmFunction> createUnboundFunctions(final FullQualifiedName functionName) {
|
||||
List<EdmFunction> result = new ArrayList<EdmFunction>();
|
||||
|
||||
try {
|
||||
List<Function> functions = functionsMap.get(functionName);
|
||||
if (functions == null) {
|
||||
functions = provider.getFunctions(functionName);
|
||||
if (functions != null) {
|
||||
functionsMap.put(functionName, functions);
|
||||
} else {
|
||||
return null;
|
||||
|
||||
for (Function function : functions) {
|
||||
if (!function.isBound()) {
|
||||
result.add(EdmFunctionImpl.getInstance(this, functionName, function));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final List<String> parameterNamesCopy =
|
||||
parameterNames == null ? Collections.<String> emptyList() : parameterNames;
|
||||
} catch (ODataException e) {
|
||||
throw new EdmException(e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmFunction createUnboundFunction(final FullQualifiedName functionName, final List<String> parameterNames) {
|
||||
try {
|
||||
List<Function> functions = functionsMap.get(functionName);
|
||||
if (functions == null) {
|
||||
functions = provider.getFunctions(functionName);
|
||||
if (functions == null) {
|
||||
return null;
|
||||
} else {
|
||||
functionsMap.put(functionName, functions);
|
||||
}
|
||||
}
|
||||
final List<String> parameterNamesCopy
|
||||
= parameterNames == null ? Collections.<String>emptyList() : parameterNames;
|
||||
for (Function function : functions) {
|
||||
if (!function.isBound()) {
|
||||
List<Parameter> providerParameters = function.getParameters();
|
||||
|
@ -271,7 +296,7 @@ public class EdmProviderImpl extends AbstractEdm {
|
|||
providerParameters = Collections.emptyList();
|
||||
}
|
||||
if (parameterNamesCopy.size() == providerParameters.size()) {
|
||||
List<String> functionParameterNames = new ArrayList<String>();
|
||||
final List<String> functionParameterNames = new ArrayList<String>();
|
||||
for (Parameter parameter : providerParameters) {
|
||||
functionParameterNames.add(parameter.getName());
|
||||
}
|
||||
|
|
|
@ -558,7 +558,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
FullQualifiedName fullBindingTypeName = new FullQualifiedName(source.type.getNamespace(), source.type.getName());
|
||||
|
||||
// check for action
|
||||
EdmAction action = edm.getAction(fullFilterName, fullBindingTypeName, source.isCollection);
|
||||
EdmAction action = edm.getBoundAction(fullFilterName, fullBindingTypeName, source.isCollection);
|
||||
if (action != null) {
|
||||
UriResourceActionImpl pathInfoAction = new UriResourceActionImpl();
|
||||
pathInfoAction.setAction(action);
|
||||
|
@ -583,7 +583,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
names.add(item.getName());
|
||||
}
|
||||
|
||||
EdmFunction function = edm.getFunction(fullFilterName, fullBindingTypeName, source.isCollection, names);
|
||||
EdmFunction function = edm.getBoundFunction(fullFilterName, fullBindingTypeName, source.isCollection, names);
|
||||
|
||||
if (function != null) {
|
||||
UriResourceFunctionImpl pathInfoFunction = new UriResourceFunctionImpl()
|
||||
|
@ -597,7 +597,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
}
|
||||
|
||||
// check for unbound function in the $filter case ( where the previous resource segment is a $it)
|
||||
function = edm.getFunction(fullFilterName, null, null, names);
|
||||
function = edm.getUnboundFunction(fullFilterName, names);
|
||||
|
||||
if (function != null) {
|
||||
UriResourceFunctionImpl pathInfoFunction = new UriResourceFunctionImpl()
|
||||
|
@ -1972,7 +1972,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
FullQualifiedName finalTypeName = new FullQualifiedName(prevType.getNamespace(), prevType.getName());
|
||||
|
||||
// check for action
|
||||
EdmAction action = edm.getAction(fullName, finalTypeName, null);
|
||||
EdmAction action = edm.getBoundAction(fullName, finalTypeName, null);
|
||||
|
||||
if (action != null) {
|
||||
UriResourceActionImpl uriAction = new UriResourceActionImpl();
|
||||
|
@ -1983,7 +1983,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
}
|
||||
|
||||
// check for function
|
||||
EdmFunction function = edm.getFunction(fullName, finalTypeName, null, null);
|
||||
EdmFunction function = edm.getBoundFunction(fullName, finalTypeName, null, null);
|
||||
|
||||
if (function != null) {
|
||||
UriResourceFunctionImpl uriFunction = new UriResourceFunctionImpl();
|
||||
|
|
|
@ -57,7 +57,7 @@ public class EdmActionImportImplTest {
|
|||
container = mock(EdmEntityContainer.class);
|
||||
when(edm.getEntityContainer(entityContainerFqn)).thenReturn(container);
|
||||
action = mock(EdmAction.class);
|
||||
when(edm.getAction(actionFqn, null, null)).thenReturn(action);
|
||||
when(edm.getUnboundAction(actionFqn)).thenReturn(action);
|
||||
|
||||
entitySet = mock(EdmEntitySet.class);
|
||||
when(container.getEntitySet("entitySetName")).thenReturn(entitySet);
|
||||
|
|
|
@ -104,46 +104,46 @@ public class EdmProviderImplOverloadingTest {
|
|||
|
||||
@Test
|
||||
public void simpleActionGet() {
|
||||
EdmAction action = edm.getAction(operationName1, null, null);
|
||||
EdmAction action = edm.getUnboundAction(operationName1);
|
||||
assertNotNull(action);
|
||||
assertEquals(operationName1.getNamespace(), action.getNamespace());
|
||||
assertEquals(operationName1.getName(), action.getName());
|
||||
|
||||
assertNull(edm.getAction(wrongOperationName, null, null));
|
||||
assertNull(edm.getUnboundAction(wrongOperationName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void boundActionOverloading() {
|
||||
EdmAction action = edm.getAction(operationName1, operationType1, false);
|
||||
EdmAction action = edm.getBoundAction(operationName1, operationType1, false);
|
||||
assertNotNull(action);
|
||||
assertEquals(operationName1.getNamespace(), action.getNamespace());
|
||||
assertEquals(operationName1.getName(), action.getName());
|
||||
assertTrue(action == edm.getAction(operationName1, operationType1, false));
|
||||
assertTrue(action == edm.getBoundAction(operationName1, operationType1, false));
|
||||
|
||||
EdmAction action2 = edm.getAction(operationName1, operationType1, true);
|
||||
EdmAction action2 = edm.getBoundAction(operationName1, operationType1, true);
|
||||
assertNotNull(action2);
|
||||
assertEquals(operationName1.getNamespace(), action2.getNamespace());
|
||||
assertEquals(operationName1.getName(), action2.getName());
|
||||
assertTrue(action2 == edm.getAction(operationName1, operationType1, true));
|
||||
assertTrue(action2 == edm.getBoundAction(operationName1, operationType1, true));
|
||||
|
||||
assertNotSame(action, action2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleFunctionGet() {
|
||||
EdmFunction function = edm.getFunction(operationName1, null, null, null);
|
||||
EdmFunction function = edm.getUnboundFunction(operationName1, null);
|
||||
assertNotNull(function);
|
||||
assertEquals(operationName1.getNamespace(), function.getNamespace());
|
||||
assertEquals(operationName1.getName(), function.getName());
|
||||
|
||||
EdmFunction function2 = edm.getFunction(operationName1, null, null, new ArrayList<String>());
|
||||
EdmFunction function2 = edm.getUnboundFunction(operationName1, new ArrayList<String>());
|
||||
assertNotNull(function2);
|
||||
assertEquals(operationName1.getNamespace(), function2.getNamespace());
|
||||
assertEquals(operationName1.getName(), function2.getName());
|
||||
|
||||
assertEquals(function, function2);
|
||||
|
||||
assertNull(edm.getFunction(wrongOperationName, null, null, new ArrayList<String>()));
|
||||
assertNull(edm.getUnboundFunction(wrongOperationName, new ArrayList<String>()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -152,28 +152,28 @@ public class EdmProviderImplOverloadingTest {
|
|||
parameter1Names.add("a");
|
||||
List<String> parameter2Names = new ArrayList<String>();
|
||||
parameter2Names.add("b");
|
||||
EdmFunction function = edm.getFunction(operationName1, null, null, new ArrayList<String>());
|
||||
EdmFunction function = edm.getUnboundFunction(operationName1, new ArrayList<String>());
|
||||
assertNotNull(function);
|
||||
assertFalse(function.isBound());
|
||||
|
||||
EdmFunction function1 = edm.getFunction(operationName1, null, null, parameter1Names);
|
||||
EdmFunction function1 = edm.getUnboundFunction(operationName1, parameter1Names);
|
||||
assertNotNull(function1);
|
||||
assertFalse(function1.isBound());
|
||||
|
||||
assertFalse(function == function1);
|
||||
assertNotSame(function, function1);
|
||||
|
||||
EdmFunction function2 = edm.getFunction(operationName1, null, null, parameter2Names);
|
||||
EdmFunction function2 = edm.getUnboundFunction(operationName1, parameter2Names);
|
||||
assertNotNull(function2);
|
||||
assertFalse(function2.isBound());
|
||||
|
||||
assertFalse(function1 == function2);
|
||||
assertNotSame(function1, function2);
|
||||
|
||||
EdmFunction function3 = edm.getFunction(operationName1, operationType1, false, parameter2Names);
|
||||
EdmFunction function3 = edm.getBoundFunction(operationName1, operationType1, false, parameter2Names);
|
||||
assertNotNull(function3);
|
||||
assertTrue(function3.isBound());
|
||||
EdmFunction function4 = edm.getFunction(operationName1, operationType2, false, parameter2Names);
|
||||
EdmFunction function4 = edm.getBoundFunction(operationName1, operationType2, false, parameter2Names);
|
||||
assertNotNull(function4);
|
||||
assertTrue(function4.isBound());
|
||||
|
||||
|
@ -192,7 +192,7 @@ public class EdmProviderImplOverloadingTest {
|
|||
|
||||
@Test(expected = EdmException.class)
|
||||
public void noParametersAtBoundFunctionReslutsInException() {
|
||||
edm.getFunction(badOperationName, operationType1, true, null);
|
||||
edm.getBoundFunction(badOperationName, operationType1, true, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -89,10 +89,10 @@ public class EdmProviderImplTest {
|
|||
when(localProvider.getActions(FQN)).thenReturn(null);
|
||||
when(localProvider.getFunctions(FQN)).thenReturn(null);
|
||||
Edm localEdm = new EdmProviderImpl(localProvider);
|
||||
localEdm.getAction(FQN, null, null);
|
||||
localEdm.getFunction(FQN, null, null, null);
|
||||
localEdm.getAction(FQN, FQN, true);
|
||||
localEdm.getFunction(FQN, FQN, true, null);
|
||||
localEdm.getUnboundAction(FQN);
|
||||
localEdm.getUnboundFunction(FQN, null);
|
||||
localEdm.getBoundAction(FQN, FQN, true);
|
||||
localEdm.getBoundFunction(FQN, FQN, true, null);
|
||||
localEdm.getComplexType(FQN);
|
||||
localEdm.getEntityContainer(FQN);
|
||||
localEdm.getEntityType(FQN);
|
||||
|
@ -123,24 +123,24 @@ public class EdmProviderImplTest {
|
|||
|
||||
// seperate because of signature
|
||||
try {
|
||||
localEdm.getAction(fqn, null, null);
|
||||
localEdm.getUnboundAction(fqn);
|
||||
} catch (EdmException e) {
|
||||
assertEquals("org.apache.olingo.commons.api.ODataException: msg", e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
localEdm.getFunction(fqn, null, null, null);
|
||||
localEdm.getUnboundFunction(fqn, null);
|
||||
} catch (EdmException e) {
|
||||
assertEquals("org.apache.olingo.commons.api.ODataException: msg", e.getMessage());
|
||||
}
|
||||
try {
|
||||
localEdm.getAction(fqn, fqn, true);
|
||||
localEdm.getBoundAction(fqn, fqn, true);
|
||||
} catch (EdmException e) {
|
||||
assertEquals("org.apache.olingo.commons.api.ODataException: msg", e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
localEdm.getFunction(fqn, fqn, true, null);
|
||||
localEdm.getBoundFunction(fqn, fqn, true, null);
|
||||
} catch (EdmException e) {
|
||||
assertEquals("org.apache.olingo.commons.api.ODataException: msg", e.getMessage());
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ public class EdmSchemaImplTest {
|
|||
assertEquals(2, actions.size());
|
||||
|
||||
for (EdmAction action : actions) {
|
||||
assertTrue(action == edm.getAction(new FullQualifiedName("namespace", action.getName()), null, null));
|
||||
assertTrue(action == edm.getUnboundAction(new FullQualifiedName("namespace", action.getName())));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ public class EdmSchemaImplTest {
|
|||
|
||||
for (EdmFunction function : functions) {
|
||||
FullQualifiedName functionName = new FullQualifiedName("namespace", function.getName());
|
||||
assertTrue(function == edm.getFunction(functionName, null, null, null));
|
||||
assertTrue(function == edm.getUnboundFunction(functionName, null));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public class UriResourceImplTest {
|
|||
assertEquals("", impl.toString());
|
||||
|
||||
// action
|
||||
EdmAction action = edm.getAction(ActionProvider.nameUARTETParam, null, null);
|
||||
EdmAction action = edm.getUnboundAction(ActionProvider.nameUARTETParam);
|
||||
impl.setAction(action);
|
||||
assertEquals(action, impl.getAction());
|
||||
assertEquals(ActionProvider.nameUARTETParam.getName(), impl.toString());
|
||||
|
|
|
@ -135,7 +135,7 @@ public class ExpressionTest {
|
|||
EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETKeyNav);
|
||||
|
||||
// UriResourceImplTyped
|
||||
EdmAction action = edm.getAction(ActionProvider.nameUARTPrimParam, null, null);
|
||||
EdmAction action = edm.getUnboundAction(ActionProvider.nameUARTPrimParam);
|
||||
UriInfoResource uriInfo = new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
|
||||
new UriResourceActionImpl().setAction(action)).asUriInfoResource();
|
||||
expression.setResourcePath(uriInfo);
|
||||
|
@ -149,21 +149,21 @@ public class ExpressionTest {
|
|||
assertEquals(false, expression.isCollection());
|
||||
|
||||
// UriResourceImplTyped check collection = true case
|
||||
action = edm.getAction(ActionProvider.nameUARTPrimCollParam, null, null);
|
||||
action = edm.getUnboundAction(ActionProvider.nameUARTPrimCollParam);
|
||||
expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
|
||||
new UriResourceActionImpl().setAction(action))
|
||||
.asUriInfoResource());
|
||||
assertEquals(true, expression.isCollection());
|
||||
|
||||
// UriResourceImplTyped with filter
|
||||
action = edm.getAction(ActionProvider.nameUARTPrimParam, null, null);
|
||||
action = edm.getUnboundAction(ActionProvider.nameUARTPrimParam);
|
||||
expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
|
||||
new UriResourceActionImpl().setAction(action).setTypeFilter(entityType))
|
||||
.asUriInfoResource());
|
||||
assertEquals(entityType, expression.getType());
|
||||
|
||||
// UriResourceImplKeyPred
|
||||
EdmFunction function = edm.getFunction(FunctionProvider.nameUFCRTETKeyNav, null, null, null);
|
||||
EdmFunction function = edm.getUnboundFunction(FunctionProvider.nameUFCRTETKeyNav, null);
|
||||
expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
|
||||
new UriResourceFunctionImpl().setFunction(function))
|
||||
.asUriInfoResource());
|
||||
|
@ -171,8 +171,7 @@ public class ExpressionTest {
|
|||
|
||||
// UriResourceImplKeyPred typeFilter on entry
|
||||
EdmEntityType entityBaseType = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
|
||||
function = edm.getFunction(FunctionProvider.nameUFCRTESTwoKeyNavParam, null, null,
|
||||
Arrays.asList(("ParameterInt16")));
|
||||
function = edm.getUnboundFunction(FunctionProvider.nameUFCRTESTwoKeyNavParam, Arrays.asList("ParameterInt16"));
|
||||
expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
|
||||
new UriResourceFunctionImpl().setFunction(function).setEntryTypeFilter(entityBaseType))
|
||||
.asUriInfoResource());
|
||||
|
@ -180,8 +179,7 @@ public class ExpressionTest {
|
|||
|
||||
// UriResourceImplKeyPred typeFilter on entry
|
||||
entityBaseType = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
|
||||
function = edm.getFunction(FunctionProvider.nameUFCRTESTwoKeyNavParam, null, null,
|
||||
Arrays.asList(("ParameterInt16")));
|
||||
function = edm.getUnboundFunction(FunctionProvider.nameUFCRTESTwoKeyNavParam, Arrays.asList("ParameterInt16"));
|
||||
expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
|
||||
new UriResourceFunctionImpl().setFunction(function).setCollectionTypeFilter(entityBaseType))
|
||||
.asUriInfoResource());
|
||||
|
@ -189,8 +187,7 @@ public class ExpressionTest {
|
|||
|
||||
// no typed
|
||||
entityBaseType = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
|
||||
function = edm.getFunction(FunctionProvider.nameUFCRTESTwoKeyNavParam, null, null,
|
||||
Arrays.asList(("ParameterInt16")));
|
||||
function = edm.getUnboundFunction(FunctionProvider.nameUFCRTESTwoKeyNavParam, Arrays.asList("ParameterInt16"));
|
||||
expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.all));
|
||||
assertEquals(null, expression.getType());
|
||||
|
||||
|
|
Loading…
Reference in New Issue