use of javax.persistence.EntityExistsException 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 javax.persistence.EntityExistsException 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 javax.persistence.EntityExistsException 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 javax.persistence.EntityExistsException 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 javax.persistence.EntityExistsException in project API by ca-cwds.
the class ChildClientService method create.
/**
* {@inheritDoc}
*
* @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
*/
@Override
public gov.ca.cwds.rest.api.domain.cms.ChildClient create(Request request) {
assert request instanceof gov.ca.cwds.rest.api.domain.cms.ChildClient;
gov.ca.cwds.rest.api.domain.cms.ChildClient childClient = (gov.ca.cwds.rest.api.domain.cms.ChildClient) request;
if (childClient.getVictimClientId() == null) {
LOGGER.info("ChildClient cannot be created with null or empty VictimClientId");
throw new ServiceException("ChildClient cannot be created with null or empty VictimClientId");
}
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
ChildClient managed = new ChildClient(childClient.getVictimClientId(), childClient, lastUpdatedId);
managed = childClientDao.create(managed);
return new gov.ca.cwds.rest.api.domain.cms.ChildClient(managed);
} catch (EntityExistsException e) {
LOGGER.info("ChildClient already exists : {}", childClient);
throw new ServiceException("ChildClient already exists : {}" + childClient, e);
}
}
Aggregations