use of io.gravitee.rest.api.model.RatingSummaryEntity in project gravitee-management-rest-api by gravitee-io.
the class PortalApisResource method convert.
private ApiListItem convert(ApiEntity api) {
final ApiListItem apiItem = new ApiListItem();
apiItem.setId(api.getId());
apiItem.setName(api.getName());
apiItem.setVersion(api.getVersion());
apiItem.setDescription(api.getDescription());
final UriBuilder ub = uriInfo.getBaseUriBuilder();
final UriBuilder uriBuilder = ub.path("apis").path(api.getId()).path("picture");
if (api.getPicture() != null) {
// force browser to get if updated
uriBuilder.queryParam("hash", api.getUpdatedAt().getTime());
}
apiItem.setPictureUrl(uriBuilder.build().toString());
apiItem.setCategories(api.getCategories());
apiItem.setCreatedAt(api.getCreatedAt());
apiItem.setUpdatedAt(api.getUpdatedAt());
apiItem.setLabels(api.getLabels());
apiItem.setCategories(api.getCategories());
apiItem.setPrimaryOwner(api.getPrimaryOwner());
if (api.getVisibility() != null) {
apiItem.setVisibility(io.gravitee.rest.api.model.Visibility.valueOf(api.getVisibility().toString()));
}
if (api.getState() != null) {
apiItem.setState(Lifecycle.State.valueOf(api.getState().toString()));
}
if (api.getProxy() != null) {
apiItem.setVirtualHosts(api.getProxy().getVirtualHosts());
}
if (ratingService.isEnabled()) {
final RatingSummaryEntity ratingSummary = ratingService.findSummaryByApi(api.getId());
apiItem.setRate(ratingSummary.getAverageRate());
apiItem.setNumberOfRatings(ratingSummary.getNumberOfRatings());
}
apiItem.setTags(api.getTags());
if (api.getLifecycleState() != null) {
apiItem.setLifecycleState(ApiLifecycleState.valueOf(api.getLifecycleState().toString()));
}
return apiItem;
}
Aggregations