use of org.devgateway.ocds.persistence.dao.UserDashboard in project ocvn by devgateway.
the class PersonDashboardJpaRepositoryProvider method iterator.
/**
* @see SortableDataProvider#iterator(long, long)
*/
@Override
public Iterator<UserDashboard> iterator(final long first, final long count) {
int page = (int) ((double) first / WebConstants.PAGE_SIZE);
Page<UserDashboard> findAll = userDashboardRepository.findDashboardsForPersonId(SecurityUtil.getCurrentAuthenticatedPerson().getId(), new PageRequest(page, WebConstants.PAGE_SIZE, translateSort()));
return findAll.iterator();
}
use of org.devgateway.ocds.persistence.dao.UserDashboard in project ocvn by devgateway.
the class EditUserPage method ensureDefaultDashboardIsAlsoAssignedDashboard.
private void ensureDefaultDashboardIsAlsoAssignedDashboard(Person person) {
if (person.getDefaultDashboard() != null && !person.getDashboards().contains(person.getDefaultDashboard())) {
UserDashboard dashboard = userDashboardRepository.findOne(person.getDefaultDashboard().getId());
dashboard.getUsers().add(person);
userDashboardRepository.save(dashboard);
}
}
use of org.devgateway.ocds.persistence.dao.UserDashboard in project ocvn by devgateway.
the class UserDashboardRestController method getDefaultDashboardForCurrentUser.
@RequestMapping(method = { RequestMethod.POST, RequestMethod.GET }, value = "/userDashboards/search/getDefaultDashboardForCurrentUser")
@PreAuthorize("hasRole('ROLE_PROCURING_ENTITY')")
@ResponseBody
public ResponseEntity<?> getDefaultDashboardForCurrentUser(PersistentEntityResourceAssembler persistentEntityResourceAssembler) {
UserDashboard dashboard = repository.getDefaultDashboardForPersonId(getCurrentAuthenticatedPerson().getId());
if (dashboard == null) {
return ResponseEntity.ok().build();
}
Resource<Object> resource = persistentEntityResourceAssembler.toResource(dashboard);
return ResponseEntity.ok(resource);
}
use of org.devgateway.ocds.persistence.dao.UserDashboard in project ocvn by devgateway.
the class UserDashboardRestControllerTest method saveDashboardForCurrentUser.
@Test
@WithUserDetails(value = "admin", userDetailsServiceBeanName = "testUserDetailsAdminProcuringEntity")
public void saveDashboardForCurrentUser() {
UserDashboard ud = new UserDashboard();
ud.setName("some name");
ud.setFormUrlEncodedBody("some body");
ResponseEntity<Void> responseEntity = userDashboardRestController.saveDashboardForCurrentUser(ud);
Assert.assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
}
Aggregations