简体   繁体   English

Olingo V4 注释未反映在 $metadata 中

[英]Olingo V4 Annotations not getting reflected in $metadata

I have implemented Odata V4 service using Olingo.我已经使用 Olingo 实现了 Odata V4 服务。 I am trying to include我正在尝试包括
Aggregation.ApplySupported annotation to my service. Aggregation.ApplySupported注释到我的服务。 However the annotation term value is blank in my $metadata document.但是,我的 $metadata 文档中的注释项值是空白的。 Below is my code snippet下面是我的代码片段

List<CsdlAnnotation> list = new ArrayList<CsdlAnnotation>();
CsdlAnnotation annotationAttribute = new CsdlAnnotation();
annotationAttribute.setTerm("Aggregation.ApplySupported");
annotationAttribute.setExpression(new CsdlConstantExpression(CsdlConstantExpression.ConstantExpressionType.String, "true"));
list.add(annotationAttribute);
entityContainer.setAnnotations(list);

$metadata $元数据

<EntityContainer Name="myContainer">
   <!-- .....sets -->
  <Annotation>   <!-- term is blank -->
     <String>true</String>
  </Annotation>
</EntityContainer>

Can't figure out whats I am missing on.无法弄清楚我错过了什么。 Thanks in advance.提前致谢。

You should override getTerm method in your provider.您应该覆盖提供程序中的getTerm方法。

@Override
    public CsdlTerm getTerm(final FullQualifiedName termName) throws ODataException {
        return new CsdlTerm().setAppliesTo(Arrays.asList("EntityContainer"))
                .setName("ApplySupported");
    }

See example here: https://apache.googlesource.com/olingo-odata4/+/master/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java请参阅此处的示例: https : //apache.googlesource.com/olingo-odata4/+/master/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest。爪哇

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM