You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@olingo.apache.org by "Michael Bolz (JIRA)" <ji...@apache.org> on 2015/05/11 09:37:00 UTC

[jira] [Updated] (OLINGO-651) Function Imports feature missing in olingo 2.0.3

     [ https://issues.apache.org/jira/browse/OLINGO-651?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Bolz updated OLINGO-651:
--------------------------------
    Summary: Function Imports feature missing in olingo 2.0.3  (was: Function Imports feture missing in olingo 2.0.3)

> Function Imports feature missing in olingo 2.0.3
> ------------------------------------------------
>
>                 Key: OLINGO-651
>                 URL: https://issues.apache.org/jira/browse/OLINGO-651
>             Project: Olingo
>          Issue Type: New Feature
>          Components: odata2-core
>    Affects Versions: V2 2.0.3
>         Environment: olingo 2.0.3
>            Reporter: Kiran Kumar Peramareddy
>            Assignee: Michael Bolz
>              Labels: FunctionImports
>
> 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() {
> 		  return "Incident 100";            
>       }	  
> }
> 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) {
>         builder.addEntitySet(createEntitySet(typeName, aClass));
>       }     
>     
>       Method[] entityFunctions = aClass.getMethods();
>       for (Method function : entityFunctions) {    	  
>       	EdmFunctionImport funcImp = function.getAnnotation(EdmFunctionImport.class);      	 
>   		if (funcImp != null)  
>   		{
>   			FunctionImport fi = new FunctionImport();  		  		
>   			fi.setEntitySet(funcImp.entitySet());
>   			fi.setHttpMethod(funcImp.httpMethod().name());
>   			fi.setName(funcImp.name());  		  		
>   			builder.addFunctionImport(fi);
>   		}
>   	  }      
>     }
>   }
> 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.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)