You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@olingo.apache.org by Apache Wiki <wi...@apache.org> on 2014/03/18 09:53:35 UTC

[Olingo Wiki] Update of "ojp-migration-edmfunctionimport" by chandanva

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Olingo Wiki" for change notification.

The "ojp-migration-edmfunctionimport" page has been changed by chandanva:
https://wiki.apache.org/Olingo/ojp-migration-edmfunctionimport

New page:
=== How to migrate Function Imports ===

==== Overview ====

The page describes how one could migrate Function Imports defined in Olingo release 1.0.0 or 1.1.0 when upgrading to Olingo release 1.2.0. If your application is dependent on following artifacts then proceed reading this migration guide

 * olingo-odata2-api-annotation-incubating:[1.0.0,1.1.0]
 * olingo-odata2-jpa-processor-api-incubating:[1.0.0,1.1.0]

==== Details ====
Follwoing EDM annotations related to function import were deprecated in 1.1.0 release of '''olingo-odata2-api-annotation-incubating'''.

 * org.apache.olingo.odata2.api.annotation.edm.!FunctionImport
 * org.apache.olingo.odata2.api.annotation.edm.Parameter
 * org.apache.olingo.odata2.api.annotation.edm.Facets
 * org.apache.olingo.odata2.api.annotation.edm.Documentation
 * org.apache.olingo.odata2.api.annotation.edmx.!HttpMethod

>From release 1.2.0 these annotations are completely removed and replaced with the following new set of EDM annotations

 * org.apache.olingo.odata2.api.annotation.edm.!EdmFunctionImport
 * org.apache.olingo.odata2.api.annotation.edm.!EdmFunctionImportParameter
 * org.apache.olingo.odata2.api.annotation.edm.!EdmFacets

The Olingo OData JPA processor library was supporting the '''deprecated''' annotations in '''release 1.0.0 and 1.1.0''' but the support is completely '''removed in 1.2.0''' release onwards. The library only supports the new set of annotations. So if you have used the deprecated annotations in your application then you need to migrate to new set of annotations as shown below

 * __Example 1__ : Shows the change in the annotation attribute '''returnType''' for the annotation '''@!EdmFunctionImport'''

{{{#!Java

/* Obsolete */

 @FunctionImport( name = "FindAllSalesOrders", 
                  entitySet = "SalesOrders", 
                  returnType = ReturnType.ENTITY_TYPE,
                  multiplicity = Multiplicity.MANY )
  public List<SalesOrderHeader> findAllSalesOrders(
                                @Parameter(name = "DeliveryStatusCode",facets = @Facets(maxLength = 2)) final String status) {
  
  }

/* New */

 @EdmFunctionImport( name = "FindAllSalesOrders", 
                     entitySet = "SalesOrders", 
                     returnType = @ReturnType(type = Type.ENTITY, isCollection = true))
  public List<SalesOrderHeader> findAllSalesOrders(
                                @EdmFunctionImportParameter(name = "DeliveryStatusCode", facets = @EdmFacets(maxLength = 2)) final String status) {

  }

}}}

----

 * __Example 2__ : Shows the change in the annotation attribute '''httpMethod''' in '''@!EdmFunctionImport'''. It also shows that the attribute '''mode''' is obsolete in '''@!EdmFunctionImportParameter'''.

{{{#!Java

/* Obsolete */

 @FunctionImport( name = "CheckATP", 
                  returnType = ReturnType.SCALAR, 
                  multiplicity = Multiplicity.ONE,
                  httpMethod = @HttpMethod(name = Name.GET) )
 public boolean checkATP(
                 @Parameter(name = "SoID", facets = @Facets(nullable = false), mode = Mode.IN) final Long soID,
                 @Parameter(name = "LiId", facets = @Facets(nullable = false), mode = Mode.IN) final Long lineItemID ) {
  
  }

/* New */

 @EdmFunctionImport(name = "CheckATP", returnType = @ReturnType(type = Type.SIMPLE, isCollection = false),httpMethod = HttpMethod.GET)
 public boolean checkATP(
                 @EdmFunctionImportParameter(name = "SoID", facets = @EdmFacets(nullable = false)) final Long soID,
                 @EdmFunctionImportParameter(name = "LiId", facets = @EdmFacets(nullable = false)) final Long lineItemID) {

  }

}}}

----

 * __Example 3__ :

{{{#!Java

/* Obsolete */

 @FunctionImport(returnType = ReturnType.ENTITY_TYPE, entitySet = "SalesOrders")
  public SalesOrderHeader calculateNetAmount(
      @Parameter(name = "SoID", facets = @Facets(nullable = false)) final Long soID) {

  }

/* New */

 @EdmFunctionImport(returnType = @ReturnType(type = Type.ENTITY, isCollection = true), entitySet = "SalesOrders")
 public SalesOrderHeader calculateNetAmount(
      @EdmFunctionImportParameter(name = "SoID", facets = @EdmFacets(nullable = false)) final Long soID) {

 }

}}}

----

 * __Example 4__ :

{{{#!Java

/* Obsolete */

 @FunctionImport(returnType = ReturnType.COMPLEX_TYPE)
 public Address getAddress(
      @Parameter(name = "SoID", facets = @Facets(nullable = false)) final Long soID) {

 }

/* New */

 @EdmFunctionImport(returnType = @ReturnType(type = Type.COMPLEX))
 public Address getAddress(
      @EdmFunctionImportParameter(name = "SoID", facets = @EdmFacets(nullable = false)) final Long soID) {

 }

}}}

----

For more details refer to the documentation 
 
 * [[http://olingo.incubator.apache.org/doc/tutorials/jpafunctionimport.html | Adding Function Imports to OData Services with the JPA Processor]]
 * [[http://olingo.incubator.apache.org/doc/tutorials/AnnotationProcessorExtension.html | Creating a Web Application with the Annotation Processor Extension]]