Details
-
New Feature
-
Status: Closed
-
Major
-
Resolution: Later
-
V2 2.0.3
-
None
-
olingo 2.0.3
Description
Present we are implementing a project which uses Olingo 2.0.3 framework. In this version we found that Function Imports feature is missing.To make this feature available, we modified the AnnotationEdmProvider class which is available in the olingo-odata2-annotation-processor-core-2.0.3-sources.jar Olingo library.
Here are the changes we made to implement the feature.
1) Created a new class which define the functions.
@EdmEntityType(name="CasmFunctions", namespace="IncidentMgt")
@EdmEntitySet(name="CasmFunctions")
public class CasmFunctions {
@EdmFunctionImport(name = "getIncidentName", returnType = @ReturnType(type = Type.SIMPLE, isCollection = false),httpMethod = HttpMethod.GET)
public String getIncidentName()
}
2) Add a new method in the container builder class
public ContainerBuilder addFunctionImport(final FunctionImport functionImport)
{ functionImports.add(functionImport); return this; }3) Modified the handleEntityContainer method in AnnotatinEdmProvider class as follows.
private void handleEntityContainer(final Class<?> aClass) {
String containerName = ANNOTATION_HELPER.extractContainerName(aClass);
ContainerBuilder builder = containerName2ContainerBuilder.get(containerName);
EdmEntityType entityType = aClass.getAnnotation(EdmEntityType.class);
if (entityType != null) {
FullQualifiedName typeName = createFqnForEntityType(aClass);
if (builder == null)
{ builder = ContainerBuilder.init(typeName.getNamespace(), containerName); containerName2ContainerBuilder.put(containerName, builder); } EdmEntitySet entitySet = aClass.getAnnotation(EdmEntitySet.class);
if (entitySet != null)
Method[] entityFunctions = aClass.getMethods();
for (Method function : entityFunctions) {
EdmFunctionImport funcImp = function.getAnnotation(EdmFunctionImport.class);
if (funcImp != null)
}
}
}
After the above changes the functions are started available in the odata metadata document.
Please validate code and suggest us for any improvements on this.
Attachments
Issue Links
- is duplicated by
-
OLINGO-1038 Function Imports feature missing
- Closed