use of com.linkedin.restli.restspec.CustomAnnotationContentSchemaMap in project rest.li by linkedin.
the class ResourceModelEncoder method buildEntitySchema.
private EntitySchema buildEntitySchema(ResourceModel resourceModel) {
EntitySchema entityNode = new EntitySchema();
entityNode.setPath(buildPathForEntity(resourceModel));
if (resourceModel.getResourceLevel() == ResourceLevel.COLLECTION) {
ActionSchemaArray actions = createActions(resourceModel, ResourceLevel.ENTITY);
if (actions.size() > 0) {
entityNode.setActions(actions);
}
}
// subresources
ResourceSchemaArray subresources = new ResourceSchemaArray();
for (ResourceModel subResourceModel : resourceModel.getSubResources()) {
ResourceSchema subresource = new ResourceSchema();
switch(subResourceModel.getResourceType()) {
case COLLECTION:
case ASSOCIATION:
appendCollection(subresource, subResourceModel);
break;
case SIMPLE:
appendSimple(subresource, subResourceModel);
break;
default:
break;
}
final DataMap customAnnotation = subResourceModel.getCustomAnnotationData();
if (!customAnnotation.isEmpty()) {
subresource.setAnnotations(new CustomAnnotationContentSchemaMap(customAnnotation));
}
subresources.add(subresource);
}
if (subresources.size() > 0) {
Collections.sort(subresources, new Comparator<ResourceSchema>() {
@Override
public int compare(ResourceSchema resourceSchema, ResourceSchema resourceSchema2) {
return resourceSchema.getName().compareTo(resourceSchema2.getName());
}
});
entityNode.setSubresources(subresources);
}
return entityNode;
}
Aggregations