Dear Wiki user,

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

The "Documentation/AnnotationProcessor" page has been changed by MichaelBolz:
https://wiki.apache.org/Olingo/Documentation/AnnotationProcessor

Comment:
Inital

New page:
= General idea =
To fill the gap between a EDM definition with the API with full implementation 
of ODataSingleProcessor and the use of a generated EDM with the JPA Processor 
and JPA Annotations we created a PoC with Java Annotation to do a EDM 
definition with a generic AnnotationProcessor (first evaluation/POC can be 
found [here|PIC:PocEdmAnnotationsExtension]) and to provide an option for 
simplified data access (read/write).

The idea behind this feature was to create your model as POJOs which then can 
be annotated with special {{{@EdmXXX}}} (Java) annotations to define the EDM 
for an OData Service.
Based on these annotation then the {{{edmx}}} document ({{{$metadata}}}) can be 
generated as well as a generic {{{Processor}}} ({{{ODataSingleProcessor}}}) for 
e.g. {{{JSON}}} can be written.
This feature will fill the gap between the currently existing JPA processor 
extension (which allows easy connection to a database with JPA annotations) and 
the need to do a full implementation of an Processor (ODataSingleProcessor).

As initial contribution and starting point for discussions about this feature 
on the issue [OLINGO-32|https://issues.apache.org/jira/browse/OLINGO-32] was 
created and a feature branch with name {{{PocEdmAnnotationsExtension}}} 
([link|https://git-wip-us.apache.org/repos/asf?p=incubator-olingo-odata2.git;a=shortlog;h=refs/heads/PocEdmAnnotationsExtension]
 and commit id: {{{ae0d7d14161d4da7ff05492566bec7e66425c168}}}) was created 
with a basic _Proof of Concept_.

= Concept =

Following submodules were created within the Apache Olingo project for 
realization of this _PoC_:
 * {{{annotation-processor-api}}}: API/Interfaces
 * {{{annotation-processor-core}}}: Implementation
 * {{{annotation-processor-ref}}}: Reference Scenario/Integration Tests
 * {{{annotation-processor-ref-web}}}: Reference Scenario as Web Projekt 
(Deployable WAR Archive)

== Annotations ==
New defined (Java) annotations for definition of an {{{EDM}}}.
These can be found in the {{{Apache Olingo}}} project within sub module 
{{{olingo-odata2-api-annotation}}} in package 
{{{org.apache.olingo.odata2.api.annotation.edm}}} and below.
In addition to this list all available annotations can be found in the [Javadoc 
of odata2-api-annotation|^api-annotation-apidocs.zip].

 * EDM Annotations: All (currently) existing annotations for definition of the 
{{{EDM}}}.
  * {{{EdmEntitySet}}}: for definition of a entity set class
   * {{{String  name() default ""}}}: name for entity set 
   * {{{String  container() default ""}}}: container name for this entity set
  * {{{EdmEntityType}}}: for definition of a entity type class 
   * {{{String  name() default ""}}}: optional name for entity type. If not set 
class name is used.
   * {{{String  namespace() default ""}}}: namespace for this entity 
  * {{{EdmComplexType}}}: for definition of a complex entity class which can be 
used as complex property.
   * {{{String  name() default ""}}}: optional name for entity type. If not set 
class name is used.
   * {{{String  namespace() default ""}}}: 
  * {{{EdmKey}}}: marker annotation for property which is used as _KeyProperty_
  * {{{EdmProperty}}}: for definition of a property within an entity class
   * {{{String name() default ""}}}: 
   * {{{EdmType type() default EdmType.Null}}}: type of the property. If not 
set the type is guessed based on field type.
   * {{{EdmFacets facets() default @EdmFacets}}}: 
  * {{{EdmNavigationProperty}}}: 
   * {{{String name() default ""}}}: used property name for _Navigation 
property_
   * {{{String association() default ""}}}: used association name for 
_Navigation property_
   * {{{String toRole() default ""}}}: target role name of this navigation
   * {{{String toType() default Object.class;}}}: class which provides an 
entity type (name) as target of this navigation
   * {{{Multiplicity toMultiplicity() default Multiplicity.ONE;}}}: 
multiplicity to target of this navigation
  * {{{EdmType}}}: The EdmTypes which can be used for property definition in 
the EDM. The available values are based on {{{EdmSimpleTypeKind}}} values as 
defined in _OData_ with the additional type {{{COMPLEX}}} which can be used to 
explicit define a EdmProperty as complex.
  * {{{EdmMediaResourceContent}}}: Annotation for definition of an 
{{{EdmProperty}}} as _media resource content_ for the according 
{{{EntityType}}} which contains the {{{EdmProperty}}}. Additionally an 
{{{EdmEntityType}}} will be flagged in the EDM as _hasStream == true_ if an 
{{{EdmProperty}}} in conjunction with the {{{EdmMediaResourceContent}}} 
annotation is defined.
  * {{{EdmMediaResourceMimeType}}}: Annotation for definition of an 
{{{EdmProperty}}} as _mime type for the media resource_ of the 
{{{EdmEntityType}}} which contains the {{{EdmProperty}}}. The value of the 
{{{EdmMediaResourceMimeType}}} annotated field will be used as _Content-Type_ 
of the media content response (of an OData _$value_ request).
  * {{{EdmMediaResourceSource}}}: Annotation for definition of an 
{{{EdmProperty}}} as _media resource source_ for the {{{EdmEntityType}}} which 
contains the {{{EdmProperty}}}. 
  * {{{EdmFunctionImport}}}: Annotation for definition of an method as an 
{{{EdmFunctionImport}}} call/endpoint
   * {{{String name() default "";}}}: 
   * {{{String entitySet() default "";}}}: 
   * {{{ReturnType returnType();}}}: 
    * {{{ReturnType}}}
     * {{{Type type();}}}: 
      * {{{enum Type [SIMPLE, ENTITY, COMPLEX]}}}
     * {{{boolean isCollection() default false;}}}: Define if the return type 
for the function import is a collection (entity set) or an single entity 
(entity).
   * {{{HttpMethod httpMethod() default HttpMethod.GET;}}}: 
    * {{{enum HttpMethod [OST, PUT, GET, MERGE, DELETE, PATCH]}}}:
   * {{{EdmDocumentation documentation() default @EdmDocumentation;}}}:
  * {{{EdmFunctionImportParameter}}}: 
  * {{{EdmFacets}}}: for definition of property facets
   * {{{int maxLength() default -1;}}}
   * {{{int scale() default -1;}}}
   * {{{int precision() default -1;}}}
   * {{{boolean nullable() default false;}}}
  * {{{EdmConcurrencyControl}}}: If a property is annotated with 
{{{EdmConcurrencyControl}}} this is equivalent with {{{ConcurrencyMode = 
FIXED}}}. Default of a property not annotated with {{{EdmConcurrencyControl}}} 
this is equivalent with  {{{ConcurrencyMode = NONE}}}. 
  * {{{EdmDocumentation}}}: for definition of additional documentation
   * {{{String summary() default "";}}}: Define a summary for this 
documentation.
   * {{{String longDescription() default "";}}}: Complete description for this 
documentation.

Reply via email to