[英]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.我有一个很大的 edmx 模式文件,使用 OLingo 在 Java 中手动重新创建一个实体类型非常不方便。 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.
虽然我不反对编写某种加载程序,但我想确保 OLingo 4 尚未提供此功能。
I found an article that shows how OLingo 2 can load this kind of information:我找到了一篇文章,展示了 OLingo 2 如何加载此类信息:
@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.但是我需要使用版本4。我没有在版本4的文档中找到相同的接口,所以我有点不知所措。 Any pointers much appreciated.
任何指针都非常感谢。
After more investigation, I found that I needed the odata-server-core-ext package and I could import org.apache.olingo.server.core.MetadataParser
.经过更多调查,我发现我需要odata-server-core-ext包,我可以导入
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.除其他外,这个类有一个名为
buildEdmProvider(Reader)
的函数,它为您完成构建SchemaBasedEdmProvider
的工作。
If you're not bound to OLingo, you could also try odata-client: https://github.com/davidmoten/odata-client如果你没有绑定 OLingo,你也可以尝试 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).我自己没有很好的机会使用它,因为不幸的是,我尝试连接的 Web 服务是 OData 2,而 odata-client 仅支持 4。但是,它看起来具有一些简洁的功能(包括类型安全和自动/透明分页)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.