[
https://issues.apache.org/jira/browse/OLINGO-983?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Punith DG updated OLINGO-983:
-----------------------------
Attachment: EdmAnnotationImpl.java
Hi Ramesh,
I understand annotations are dynamic in nature. But as of now I don't find any
API which is reading the annotation "term". I get null value when I use the
method getTerm() of EdmAnnotationImpl to get the term of the annotation. That
is because the method is as below:
public EdmTerm getTerm() {
if (term == null) {
if (annotation.getTerm() == null) {
throw new EdmException("Term must not be null for an annotation.");
}
term = edm.getTerm(new FullQualifiedName(annotation.getTerm()));
}
return term;
}
The 'term' is returned by reading it from edm.getTerm() which looks in the
cached terms (calls cacheTerm() method). But generally there's no terms cached
for the annotations like Description, Permissions, etc.
For example : check the below metadata
http://services.odata.org/V4/%28S%28ejvhxps3mcxirdp43lusmkc3%29%29/TripPinServiceRW/$metadata
Try to read the "term" of the annotation e.g. Permissions:
<Property Name="Id" Type="Edm.Int64" Nullable="false"><Annotation
Term="Org.OData.Core.V1.Permissions"><EnumMember>Org.OData.Core.V1.Permission/Read</EnumMember></Annotation></Property>
But the edm.getTerm(new FullQualifiedName("Org.OData.Core.V1.Permissions"))
returns null.
Then I added a method getAnnotation() to the EdmAnnotationImpl class which
returns annotation. Then I could able to read the terms from the CsdlAnnotation
instance.
Please investigate this and try.
Thanks,
Punith
> Not able to access property annotations
> ---------------------------------------
>
> Key: OLINGO-983
> URL: https://issues.apache.org/jira/browse/OLINGO-983
> Project: Olingo
> Issue Type: Improvement
> Components: odata4-commons
> Affects Versions: (Java) V4 4.2.0
> Reporter: Punith DG
> Labels: newbie
> Attachments: EdmAnnotationImpl.java
>
>
> Not able to consume CsdlAnnotation data from
> "org.apache.olingo.commons.core.edm.EdmAnnotationImpl" class.
> There is no API that returns CsdlAnnotation data which contains annotations
> details like Permissions, Description, Immutatable, etc.
> This is much required to read the annotation information which describes much
> about the field behavior like creatable or just readable field or immutable.
> Could we have a method like getAnnotation() which returns the
> "CsdlAnnotation" data.
> Please point me if there is any other way to do so :) That will be more
> helpful.
> Thanks & Regards,
> Punith DG
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)