Search in sources :

Example 6 with ClientAddress

use of gov.ca.cwds.data.persistence.cms.ClientAddress in project API by ca-cwds.

the class ClientAddressService method create.

@Override
public Response create(Request request) {
    assert request instanceof gov.ca.cwds.rest.api.domain.cms.ClientAddress;
    gov.ca.cwds.rest.api.domain.cms.ClientAddress clientAddress = (gov.ca.cwds.rest.api.domain.cms.ClientAddress) request;
    try {
        ClientAddress managedClientAddress = new ClientAddress(IdGenerator.randomString(10), clientAddress, "BTr");
        // checking the staffPerson county code
        StaffPerson staffperson = staffpersonDao.find(managedClientAddress.getLastUpdatedId());
        if (staffperson != null && (triggerTablesDao.getLaCountySpecificCode().equals(staffperson.getCountyCode()))) {
            laCountyTrigger.createClientAddressCountyTrigger(managedClientAddress);
        }
        managedClientAddress = clientAddressDao.create(managedClientAddress);
        return new gov.ca.cwds.rest.api.domain.cms.ClientAddress(managedClientAddress, false);
    } catch (EntityExistsException e) {
        LOGGER.info("ClientAddress already exists : {}", clientAddress);
        throw new ServiceException(e);
    }
}
Also used : StaffPerson(gov.ca.cwds.data.persistence.cms.StaffPerson) ServiceException(gov.ca.cwds.rest.services.ServiceException) ClientAddress(gov.ca.cwds.data.persistence.cms.ClientAddress) EntityExistsException(javax.persistence.EntityExistsException)

Aggregations

ClientAddress (gov.ca.cwds.data.persistence.cms.ClientAddress)6 CountyTrigger (gov.ca.cwds.data.persistence.cms.CountyTrigger)4 Test (org.junit.Test)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 StaffPerson (gov.ca.cwds.data.persistence.cms.StaffPerson)2 ServiceException (gov.ca.cwds.rest.services.ServiceException)2 Date (java.util.Date)1 EntityExistsException (javax.persistence.EntityExistsException)1 EntityNotFoundException (javax.persistence.EntityNotFoundException)1