slider
slider

Reputation: 431

Olingo (OData 4) How to create annotations for entityType?

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

Upvotes: 0

Views: 1703

Answers (2)

slider
slider

Reputation: 431

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.

Upvotes: 1

Sushant Kumar Singh
Sushant Kumar Singh

Reputation: 323

@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.

Upvotes: 0

Related Questions