【问题标题】:Olingo (OData 4) How to create annotations for entityType?Olingo (OData 4) 如何为 entityType 创建注释?
【发布时间】:2016-01-19 15:55:15
【问题描述】:

如何从代码entityTypes中注解如下:
http://services.odata.org/OData/OData.svc/$metadata ?
提前谢谢。

【问题讨论】:

  • 欢迎来到 Stack Overflow!您似乎在要求某人为您编写一些代码。 Stack Overflow 是一个问答网站,而不是代码编写服务。请see here学习如何写出有效的问题。
  • 好的,谢谢!编辑了这个。

标签: java odata olingo


【解决方案1】:

收到答复。在这里:
1.在EdmProvider中的注解集,在EntitySets中:

public CsdlEntitySet getEntitySet(...) throws ... {
...
    return new CsdlEntitySet()
        .setName(...)
        .setType(...)
        .setAnnotations(Arrays.asList(new CsdlAnnotation()
            .setTerm("termName").setExpression(
                new CsdlConstantExpression(CsdlConstantExpression
                    .ConstantExpressionType.String, "someInfo"))));
...
}

2。术语可以在单独的 TermProvider 中定义。

【讨论】:

    【解决方案2】:
    @EdmEntityType(name = "Team")
    @EdmEntitySet(name = "Teams")
    public class Team extends RefBase {
      @EdmProperty(type = EdmType.BOOLEAN)
      private Boolean isScrumTeam;
      @EdmNavigationProperty(name = "nt_Employees", association = "TeamEmployees")
      private List<Employee> employees = new ArrayList<Employee>();
    

    请查看 here 文档了解完整详情。

    【讨论】:

      猜你喜欢
      • 2016-11-14
      • 2017-05-24
      • 2014-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-15
      • 2014-12-10
      • 1970-01-01
      相关资源
      最近更新 更多