Search in sources :

Example 1 with UtkastFilter

use of se.inera.intyg.webcert.persistence.utkast.repository.UtkastFilter in project webcert by sklintyg.

the class UtkastApiController method filterDraftsForUnit.

/**
 * Creates a filtered query to get drafts for a specific unit.
 */
@GET
@Path("/")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response filterDraftsForUnit(@QueryParam("") QueryIntygParameter filterParameters) {
    authoritiesValidator.given(getWebCertUserService().getUser()).features(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST).orThrow();
    UtkastFilter utkastFilter = createUtkastFilter(filterParameters);
    QueryIntygResponse queryResponse = performUtkastFilterQuery(utkastFilter);
    return Response.ok(queryResponse).build();
}
Also used : QueryIntygResponse(se.inera.intyg.webcert.web.web.controller.api.dto.QueryIntygResponse) UtkastFilter(se.inera.intyg.webcert.persistence.utkast.repository.UtkastFilter) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with UtkastFilter

use of se.inera.intyg.webcert.persistence.utkast.repository.UtkastFilter in project webcert by sklintyg.

the class UtkastApiController method createUtkastFilter.

private UtkastFilter createUtkastFilter(QueryIntygParameter filterParameters) {
    WebCertUser user = getWebCertUserService().getUser();
    String selectedUnitHsaId = user.getValdVardenhet().getId();
    UtkastFilter utkastFilter = new UtkastFilter(selectedUnitHsaId);
    if (filterParameters != null) {
        if (Boolean.FALSE.equals(filterParameters.getComplete())) {
            utkastFilter.setStatusList(INCOMPLETE_DRAFTS);
        } else if (Boolean.TRUE.equals(filterParameters.getComplete())) {
            utkastFilter.setStatusList(COMPLETE_DRAFTS);
        } else {
            utkastFilter.setStatusList(ALL_DRAFTS);
        }
        utkastFilter.setSavedFrom(filterParameters.getSavedFrom());
        utkastFilter.setSavedTo(filterParameters.getSavedTo());
        utkastFilter.setSavedByHsaId(filterParameters.getSavedBy());
        utkastFilter.setNotified(filterParameters.getNotified());
        utkastFilter.setPageSize(filterParameters.getPageSize() == null ? DEFAULT_PAGE_SIZE : filterParameters.getPageSize());
        utkastFilter.setStartFrom(filterParameters.getStartFrom() == null ? 0 : filterParameters.getStartFrom());
    }
    return utkastFilter;
}
Also used : UtkastFilter(se.inera.intyg.webcert.persistence.utkast.repository.UtkastFilter) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Aggregations

UtkastFilter (se.inera.intyg.webcert.persistence.utkast.repository.UtkastFilter)2 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)1 QueryIntygResponse (se.inera.intyg.webcert.web.web.controller.api.dto.QueryIntygResponse)1