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());
}
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());
}
}
Aggregations