0
votes

How to annotate from code entityTypes like this:
http://services.odata.org/OData/OData.svc/$metadata ?
Thanx in advance.

2
Welcome to Stack Overflow! You seem to be asking for someone to write some code for you. Stack Overflow is a question and answer site, not a code-writing service. Please see here to learn how to write effective questions. - Quotidian
Ok, thanx! Edited this one. - slider

2 Answers

1
votes

Received the answer. Here it:
1. Annotations sets in EdmProvider, at an 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. Terms can be defined in the separated TermProvider.

0
votes
@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>();

Just check here the documentation for full details.