Uploaded image for project: 'Olingo'
  1. Olingo
  2. OLINGO-651

Function Imports feature missing in olingo 2.0.3

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Later
    • V2 2.0.3
    • None
    • odata2-annotation
    • 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()

      { 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.

      Attachments

        Issue Links

          Activity

            People

              mirbo mibo
              srikirreddy Kiran Kumar Peramareddy
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: