use of javax.persistence.EntityExistsException 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);
}
}
use of javax.persistence.EntityExistsException in project API by ca-cwds.
the class ClientUcService 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.ClientUc create(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);
// NOSONAR
managed = clientucDao.create(managed);
return mockDomain;
} catch (EntityExistsException e) {
LOGGER.info("Client already exists : {}", clientUc);
throw new ServiceException(e);
}
}
use of javax.persistence.EntityExistsException in project API by ca-cwds.
the class ReferralClientService method create.
@Override
public gov.ca.cwds.rest.api.domain.cms.ReferralClient create(Request request) {
assert request instanceof gov.ca.cwds.rest.api.domain.cms.ReferralClient;
gov.ca.cwds.rest.api.domain.cms.ReferralClient referralClient = (gov.ca.cwds.rest.api.domain.cms.ReferralClient) request;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
ReferralClient managed = new ReferralClient(referralClient, lastUpdatedId);
managed = referralClientDao.create(managed);
// checking the staffPerson county code
StaffPerson staffperson = staffpersonDao.find(managed.getLastUpdatedId());
if (staffperson != null && (triggerTablesDao.getLaCountySpecificCode().equals(staffperson.getCountyCode()))) {
laCountyTrigger.createCountyTrigger(managed);
} else {
nonLaTriggers.createAndUpdateReferralClientCoutyOwnership(managed);
}
return new gov.ca.cwds.rest.api.domain.cms.ReferralClient(managed);
} catch (EntityExistsException e) {
LOGGER.info("Referral Client already exists : {}", referralClient);
throw new ServiceException(e);
}
}
use of javax.persistence.EntityExistsException in project API by ca-cwds.
the class ReferralService method create.
/**
* {@inheritDoc}
*
* @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
*/
@Override
public PostedReferral create(Request request) {
assert request instanceof gov.ca.cwds.rest.api.domain.cms.Referral;
gov.ca.cwds.rest.api.domain.cms.Referral referral = (gov.ca.cwds.rest.api.domain.cms.Referral) request;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
Referral managed = new Referral(CmsKeyIdGenerator.cmsIdGenertor(lastUpdatedId), referral, lastUpdatedId);
managed = referralDao.create(managed);
if (managed.getId() == null) {
throw new ServiceException("Referral ID cannot be null");
}
// checking the staffPerson county code
StaffPerson staffperson = staffpersonDao.find(managed.getLastUpdatedId());
if (staffperson != null && (triggerTablesDao.getLaCountySpecificCode().equals(staffperson.getCountyCode()))) {
laCountyTrigger.createCountyTrigger(managed);
}
return new PostedReferral(managed);
} catch (EntityExistsException e) {
LOGGER.info("Referral already exists : {}", referral);
throw new ServiceException(e);
}
}
Aggregations