Search in sources :

Example 1 with ScreeningListResponse

use of gov.ca.cwds.rest.api.domain.ScreeningListResponse in project API by ca-cwds.

the class ScreeningService method find.

/**
   * {@inheritDoc}
   * 
   * @see gov.ca.cwds.rest.services.CrudsService#find(java.io.Serializable)
   */
@Override
public Response find(Serializable primaryKey) {
    if (primaryKey instanceof Long) {
        gov.ca.cwds.data.persistence.ns.Screening screening = screeningDao.find(primaryKey);
        if (screening != null) {
            return new ScreeningResponse(screening, screening.getParticipants());
        }
        return null;
    } else {
        List<gov.ca.cwds.data.persistence.ns.Screening> screenings = findByCriteria(primaryKey);
        ImmutableSet.Builder<ScreeningResponse> builder = ImmutableSet.builder();
        for (gov.ca.cwds.data.persistence.ns.Screening screening : screenings) {
            if (screening != null) {
                builder.add(new ScreeningResponse(screening, screening.getParticipants()));
            }
        }
        return new ScreeningListResponse(builder.build());
    }
}
Also used : Restrictions(org.hibernate.criterion.Restrictions) PostedScreening(gov.ca.cwds.rest.api.domain.PostedScreening) Screening(gov.ca.cwds.rest.api.domain.Screening) ImmutableSet(com.google.common.collect.ImmutableSet) ScreeningResponse(gov.ca.cwds.rest.api.domain.ScreeningResponse) ScreeningListResponse(gov.ca.cwds.rest.api.domain.ScreeningListResponse)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)1 PostedScreening (gov.ca.cwds.rest.api.domain.PostedScreening)1 Screening (gov.ca.cwds.rest.api.domain.Screening)1 ScreeningListResponse (gov.ca.cwds.rest.api.domain.ScreeningListResponse)1 ScreeningResponse (gov.ca.cwds.rest.api.domain.ScreeningResponse)1 Restrictions (org.hibernate.criterion.Restrictions)1