Search in sources :

Example 1 with UserDashboard

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();
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) UserDashboard(org.devgateway.ocds.persistence.dao.UserDashboard)

Example 2 with UserDashboard

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);
    }
}
Also used : UserDashboard(org.devgateway.ocds.persistence.dao.UserDashboard)

Example 3 with UserDashboard

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);
}
Also used : UserDashboard(org.devgateway.ocds.persistence.dao.UserDashboard) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with UserDashboard

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());
}
Also used : UserDashboard(org.devgateway.ocds.persistence.dao.UserDashboard) Test(org.junit.Test) AbstractSpringDataRestControllerTest(org.devgateway.toolkit.web.AbstractSpringDataRestControllerTest) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails)

Aggregations

UserDashboard (org.devgateway.ocds.persistence.dao.UserDashboard)4 AbstractSpringDataRestControllerTest (org.devgateway.toolkit.web.AbstractSpringDataRestControllerTest)1 Test (org.junit.Test)1 PageRequest (org.springframework.data.domain.PageRequest)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1