gpt4 book ai didi

java - Olingo V4 注释未反射(reflect)在 $metadata 中

转载 作者:行者123 更新时间:2023-11-30 06:54:29 26 4
gpt4 key购买 nike

我已经使用 Olingo 实现了 Odata V4 服务。我正在尝试包括
对我的服务进行 Aggregation.ApplySupported 注释。但是,我的 $metadata 文档中的注释术语值是空白的。下面是我的代码片段

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);

$元数据

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

不知道我错过了什么。提前致谢。

最佳答案

您应该重写提供商中的getTerm方法。

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

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

关于java - Olingo V4 注释未反射(reflect)在 $metadata 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42105353/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com