use of gov.ca.cwds.data.persistence.cms.Address in project API by ca-cwds.
the class AddressService method create.
@Override
public Response create(Request request) {
assert request instanceof gov.ca.cwds.rest.api.domain.cms.Address;
gov.ca.cwds.rest.api.domain.cms.Address address = (gov.ca.cwds.rest.api.domain.cms.Address) request;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
Address managed = new Address(CmsKeyIdGenerator.cmsIdGenertor(lastUpdatedId), address, lastUpdatedId);
managed = addressDao.create(managed);
if (managed.getId() == null) {
throw new ServiceException("Address ID cannot be null");
}
return new PostedAddress(managed, true);
} catch (EntityExistsException e) {
LOGGER.info("Address already exists : ()", address);
throw new ServiceException(e);
}
}
use of gov.ca.cwds.data.persistence.cms.Address in project API by ca-cwds.
the class AddressService method update.
@Override
public Response update(Serializable primaryKey, Request request) {
assert primaryKey instanceof String;
assert request instanceof gov.ca.cwds.rest.api.domain.cms.Address;
gov.ca.cwds.rest.api.domain.cms.Address address = (gov.ca.cwds.rest.api.domain.cms.Address) request;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
Address managed = new Address((String) primaryKey, address, lastUpdatedId);
managed = addressDao.update(managed);
return new gov.ca.cwds.rest.api.domain.cms.Address(managed, true);
} catch (EntityNotFoundException e) {
LOGGER.info("Address not found : {}", address);
throw new ServiceException(e);
}
}
Aggregations