use of io.gravitee.management.model.ViewEntity in project gravitee-management-rest-api by gravitee-io.
the class ViewServiceImpl method convert.
private ViewEntity convert(final View view) {
final ViewEntity viewEntity = new ViewEntity();
viewEntity.setId(view.getId());
viewEntity.setName(view.getName());
viewEntity.setDescription(view.getDescription());
viewEntity.setDefaultView(view.isDefaultView());
viewEntity.setOrder(view.getOrder());
viewEntity.setHidden(view.isHidden());
viewEntity.setUpdatedAt(view.getUpdatedAt());
viewEntity.setCreatedAt(view.getCreatedAt());
return viewEntity;
}
use of io.gravitee.management.model.ViewEntity in project gravitee-management-rest-api by gravitee-io.
the class ViewServiceImpl method update.
@Override
public List<ViewEntity> update(final List<UpdateViewEntity> viewEntities) {
final List<ViewEntity> savedViews = new ArrayList<>(viewEntities.size());
viewEntities.forEach(viewEntity -> {
try {
View view = convert(viewEntity);
Optional<View> viewOptional = viewRepository.findById(view.getId());
if (viewOptional.isPresent()) {
savedViews.add(convert(viewRepository.update(view)));
auditService.createPortalAuditLog(Collections.singletonMap(VIEW, view.getId()), VIEW_UPDATED, new Date(), viewOptional.get(), view);
}
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while trying to update view {}", viewEntity.getName(), ex);
throw new TechnicalManagementException("An error occurs while trying to update view " + viewEntity.getName(), ex);
}
});
return savedViews;
}
Aggregations