Search in sources :

Example 16 with StaffPerson

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

the class StaffPersonService method update.

/**
   * {@inheritDoc}
   * 
   * @see gov.ca.cwds.rest.services.CrudsService#update(java.io.Serializable,
   *      gov.ca.cwds.rest.api.Request)
   */
@Override
public StaffPerson update(Serializable primaryKey, Request request) {
    assert primaryKey instanceof String;
    assert request instanceof gov.ca.cwds.rest.api.domain.cms.StaffPerson;
    gov.ca.cwds.rest.api.domain.cms.StaffPerson staffPerson = (gov.ca.cwds.rest.api.domain.cms.StaffPerson) request;
    try {
        String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
        gov.ca.cwds.data.persistence.cms.StaffPerson managed = new gov.ca.cwds.data.persistence.cms.StaffPerson((String) primaryKey, staffPerson, lastUpdatedId);
        managed = staffPersonDao.update(managed);
        return new gov.ca.cwds.rest.api.domain.cms.StaffPerson(managed);
    } catch (EntityNotFoundException e) {
        LOGGER.info("StaffPerson not found : {}", staffPerson);
        throw new ServiceException(e);
    }
}
Also used : PostedStaffPerson(gov.ca.cwds.rest.api.domain.cms.PostedStaffPerson) StaffPerson(gov.ca.cwds.rest.api.domain.cms.StaffPerson) EntityNotFoundException(javax.persistence.EntityNotFoundException) ServiceException(gov.ca.cwds.rest.services.ServiceException) StaffPerson(gov.ca.cwds.rest.api.domain.cms.StaffPerson)

Aggregations

StaffPerson (gov.ca.cwds.rest.api.domain.cms.StaffPerson)16 Test (org.junit.Test)14 PostedStaffPerson (gov.ca.cwds.rest.api.domain.cms.PostedStaffPerson)12 ServiceException (gov.ca.cwds.rest.services.ServiceException)6 BigDecimal (java.math.BigDecimal)4 EntityNotFoundException (javax.persistence.EntityNotFoundException)2 Response (gov.ca.cwds.rest.api.Response)1 ValidationErrorMessage (io.dropwizard.jersey.validation.ValidationErrorMessage)1 EntityExistsException (javax.persistence.EntityExistsException)1 Response (javax.ws.rs.core.Response)1 ExpectedException (org.junit.rules.ExpectedException)1