use of gov.ca.cwds.rest.services.ServiceException in project API by ca-cwds.
the class ReporterService method create.
/**
* {@inheritDoc}
*
* @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
*/
@Override
public PostedReporter create(Request request) {
assert request instanceof gov.ca.cwds.rest.api.domain.cms.Reporter;
gov.ca.cwds.rest.api.domain.cms.Reporter reporter = (gov.ca.cwds.rest.api.domain.cms.Reporter) request;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
Reporter managed = new Reporter(reporter, lastUpdatedId);
managed = reporterDao.create(managed);
return new PostedReporter(managed);
} catch (EntityExistsException e) {
LOGGER.info("Reporter already exists : {}", reporter);
throw new ServiceException(e);
}
}
use of gov.ca.cwds.rest.services.ServiceException in project API by ca-cwds.
the class StaffPersonService method create.
/**
* {@inheritDoc}
*
* @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
*/
@Override
public PostedStaffPerson create(Request request) {
assert request instanceof gov.ca.cwds.rest.api.domain.cms.StaffPerson;
StaffPerson staffPerson = (StaffPerson) request;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
gov.ca.cwds.data.persistence.cms.StaffPerson managed = new gov.ca.cwds.data.persistence.cms.StaffPerson(IdGenerator.randomString(3), staffPerson, lastUpdatedId);
managed = staffPersonDao.create(managed);
return new PostedStaffPerson(managed);
} catch (EntityExistsException e) {
LOGGER.info("StaffPerson already exists : {}", staffPerson);
throw new ServiceException(e);
}
}
use of gov.ca.cwds.rest.services.ServiceException 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.rest.services.ServiceException in project API by ca-cwds.
the class ClientService method create.
/**
* {@inheritDoc}
*
* @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
*/
@Override
public PostedClient create(Request request) {
assert request instanceof gov.ca.cwds.rest.api.domain.cms.Client;
gov.ca.cwds.rest.api.domain.cms.Client client = (gov.ca.cwds.rest.api.domain.cms.Client) request;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
Client managed = new Client(CmsKeyIdGenerator.cmsIdGenertor(lastUpdatedId), client, lastUpdatedId);
managed = clientDao.create(managed);
// checking the staffPerson county code
StaffPerson staffperson = staffpersonDao.find(managed.getLastUpdatedId());
if (staffperson != null && !(triggerTablesDao.getLaCountySpecificCode().equals(staffperson.getCountyCode()))) {
nonLaCountyTriggers.createClientCountyTrigger(managed);
}
return new PostedClient(managed, false);
} catch (EntityExistsException e) {
LOGGER.info("Client already exists : {}", client);
throw new ServiceException(e);
}
}
use of gov.ca.cwds.rest.services.ServiceException in project API by ca-cwds.
the class ClientUcService method update.
/**
* {@inheritDoc}
*
* @see gov.ca.cwds.rest.services.CrudsService#update(java.io.Serializable,
* gov.ca.cwds.rest.api.Request)
*/
@Override
public gov.ca.cwds.rest.api.domain.cms.ClientUc update(Serializable primaryKey, Request request) {
assert request instanceof gov.ca.cwds.rest.api.domain.cms.ClientUc;
gov.ca.cwds.rest.api.domain.cms.ClientUc clientUc = (gov.ca.cwds.rest.api.domain.cms.ClientUc) request;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
ClientUc managed = new ClientUc(clientUc, lastUpdatedId);
managed = clientucDao.update(managed);
return new gov.ca.cwds.rest.api.domain.cms.ClientUc(managed);
} catch (EntityNotFoundException e) {
LOGGER.info("Client not found : {}", clientUc);
throw new ServiceException(e);
}
}
Aggregations