Search in sources :

Example 1 with Screening

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

the class ScreeningService method update.

/**
   * {@inheritDoc}
   * 
   * @see gov.ca.cwds.rest.services.CrudsService#update(java.io.Serializable,
   *      gov.ca.cwds.rest.api.Request)
   */
@Override
public ScreeningResponse update(Serializable primaryKey, Request request) {
    assert primaryKey instanceof Long;
    assert request instanceof ScreeningRequest;
    ScreeningRequest screeningRequest = (ScreeningRequest) request;
    Set<gov.ca.cwds.data.persistence.ns.Participant> participants = new HashSet<>();
    Address address = new Address(screeningRequest.getAddress(), null, null);
    gov.ca.cwds.data.persistence.ns.Screening screening = new gov.ca.cwds.data.persistence.ns.Screening((Long) primaryKey, screeningRequest, address, participants, null, null);
    screening = screeningDao.update(screening);
    if (screeningDao.getSessionFactory() != null) {
        screeningDao.getSessionFactory().getCurrentSession().flush();
        screeningDao.getSessionFactory().getCurrentSession().refresh(screening);
    }
    return new ScreeningResponse(screening, screening.getParticipants());
}
Also used : ScreeningRequest(gov.ca.cwds.rest.api.domain.ScreeningRequest) Address(gov.ca.cwds.data.persistence.ns.Address) Restrictions(org.hibernate.criterion.Restrictions) PostedScreening(gov.ca.cwds.rest.api.domain.PostedScreening) Screening(gov.ca.cwds.rest.api.domain.Screening) ScreeningResponse(gov.ca.cwds.rest.api.domain.ScreeningResponse) HashSet(java.util.HashSet)

Example 2 with Screening

use of gov.ca.cwds.rest.api.domain.Screening 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

PostedScreening (gov.ca.cwds.rest.api.domain.PostedScreening)2 Screening (gov.ca.cwds.rest.api.domain.Screening)2 ScreeningResponse (gov.ca.cwds.rest.api.domain.ScreeningResponse)2 Restrictions (org.hibernate.criterion.Restrictions)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Address (gov.ca.cwds.data.persistence.ns.Address)1 ScreeningListResponse (gov.ca.cwds.rest.api.domain.ScreeningListResponse)1 ScreeningRequest (gov.ca.cwds.rest.api.domain.ScreeningRequest)1 HashSet (java.util.HashSet)1