patrickjm
patrickjm

Reputation: 177

How do I load an EDMX schema file in Java with OLingo 4?

I have a large edmx schema file that would be very inconvenient to manually re-create, one EntityType at a time, in Java using OLingo. While I'm not opposed to writing a loader of some kind, I wanted to make sure that OLingo 4 doesn't already provide this functionality.

I found an article that shows how OLingo 2 can load this kind of information:

 @Override
 public Edm readMetadata(final InputStream inputStream, final boolean validate) 
    throws EntityProviderException {
    EdmProvider provider = new EdmxProvider().parse(inputStream, validate);
    return new EdmImplProv(provider);
 }

But I need to use version 4. I haven't found the same interfaces in the documentation for version 4, so I'm at a bit of a loss. Any pointers much appreciated.

Upvotes: 0

Views: 1210

Answers (2)

Fr Jeremy Krieg
Fr Jeremy Krieg

Reputation: 583

If you're not bound to OLingo, you could also try odata-client: https://github.com/davidmoten/odata-client

I've not had a good chance to use it myself as unfortunately the web service I'm trying to connect to is OData 2, and odata-client only supports 4. However, it looked to have some neat features (including type safety and automatic/transparent paging).

Upvotes: 0

patrickjm
patrickjm

Reputation: 177

After more investigation, I found that I needed the odata-server-core-ext package and I could import org.apache.olingo.server.core.MetadataParser. Among other things, this class has a function called buildEdmProvider(Reader) which does the work of building a SchemaBasedEdmProvider for you.

Upvotes: 1

Related Questions