Reputation: 861
I see there is documentation that describes using annotations with Olingo for Odata v2: https://olingo.apache.org/doc/odata2/tutorials/AnnotationProcessorExtension.html
So for example, instead of manually creating a provider that details all the EDM metadata, I'd like to add annotations to my model and have a generic EDM provider to generate all the meta data. And similarly for the data provider. It would like something like this:
@EdmEntityType
@EdmEntitySet
public class Car {
@EdmKey
@EdmProperty
private String id;
@EdmProperty
private String model;
@EdmNavigationProperty
private Manufacturer manufacturer;
}
Is there similar functionality for Olingo Odata4? I couldn't find any examples and searching didn't seen the annotations defined in their source code. As I recall this approach works with other frameworks, .Nets web API, SDL Odata, Olingo Odata2, etc.
Update: I ended up using SDL Odata instead which also supports Odata v4 and has notations. For an example look here: https://github.com/sdl/odata-example
Here is what a model looks like in Scala:
@EdmEntity(namespace = "SDL.OData.Example", key = Array("id"), containerName = "SDLExample")
@EdmEntitySet
case class Person (
@(EdmProperty @field)(name="id", nullable = false) var personId: String,
@(EdmProperty @field)(name="firstName",nullable = false) var firstName: String,
@(EdmProperty @field)(name="lastName", nullable = false) var lastName: String,
@(EdmProperty @field)(name="age", nullable = false) var age: Int
)
Upvotes: 3
Views: 3004
Reputation: 543
There is currently no documentation on this topic. I would suggest you look at the Olingo TechSvc module which is used in their integration tests. There you can see how the annotations are set for an EntitySet: https://github.com/apache/olingo-odata4/blob/2e24ffd1d3c343fdec45f8dbf0398783a0a86f3f/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java#L179
Basically you use the classes you can find in the org.apache.olingo.commons.api.edm.annotation package and add instances of those clases to you CsdlProvider elements which you want to be annotated.
Upvotes: 4