My Java application uses SAP's repackaged Olingo library for v2 OData services, https://mvnrepository.com/artifact/com.sap.cds.repackaged/odata-v2-lib, to parse the metadata.xml document of an OData service:
Edm parsedMetadata = EntityProvider.readMetadata(inputStream, true);
I do this to analyze the available entities and associations, and it works fine. However, the metadata document also contains <Annotations>
that I am interested in:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx ...>
<edmx:Reference ... /></edmx:Reference>
<edmx:DataServices ...>
<Schema ...>
<EntityType .../>
...
<ComplexType ...>...</ComplexType>
...
<Association ...>...</Association>
...
<Annotations ...>...</Annotations> <!-- I want these here -->
...
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Olingo's Edm
object provides all sorts of getters for the different parts, like entity types, complex types, and associations, but none for annotations. I also didn't find any other classes in Olingo that would support me in retrieving them.
Is there a possibility to get these Annotations details via Olingo, too? If not, are there other possibilities how I could get these?
They are available at the EntityContainer level
You can retieve them like this
Or if you have multiple containers or want to use the named API it would be
Otherwise on all the properties there is a
getAnnotations
method but then you'll have to loop over all the properties and consolidate the annotationsFor example