use of gov.ca.cwds.rest.services.ServiceException 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);
}
}
use of gov.ca.cwds.rest.services.ServiceException in project API by ca-cwds.
the class ChildClientService 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.ChildClient update(Serializable primaryKey, 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;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
ChildClient managed = new ChildClient(childClient.getVictimClientId(), childClient, lastUpdatedId);
managed = childClientDao.update(managed);
return new gov.ca.cwds.rest.api.domain.cms.ChildClient(managed);
} catch (EntityNotFoundException e) {
LOGGER.info("childClient not found : {}", childClient);
throw new ServiceException(e);
}
}
use of gov.ca.cwds.rest.services.ServiceException in project API by ca-cwds.
the class ClientAddressService method update.
@Override
public Response update(Serializable primaryKey, Request request) {
assert primaryKey instanceof String;
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 {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
ClientAddress managed = new ClientAddress((String) primaryKey, clientAddress, lastUpdatedId);
// checking the staffPerson county code
StaffPerson staffperson = staffpersonDao.find(managed.getLastUpdatedId());
if (staffperson != null && (triggerTablesDao.getLaCountySpecificCode().equals(staffperson.getCountyCode()))) {
laCountyTrigger.createClientAddressCountyTrigger(managed);
}
managed = clientAddressDao.update(managed);
return new gov.ca.cwds.rest.api.domain.cms.ClientAddress(managed, true);
} catch (EntityNotFoundException e) {
LOGGER.info("ClientAddress not found : {}", clientAddress);
throw new ServiceException(e);
}
}
use of gov.ca.cwds.rest.services.ServiceException in project API by ca-cwds.
the class AllegationPerpetratorHistoryService 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.AllegationPerpetratorHistory update(Serializable primaryKey, Request request) {
assert primaryKey instanceof String;
assert request instanceof gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory;
gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory allegationPerpetratorHistory = (gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory) request;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
AllegationPerpetratorHistory managed = new AllegationPerpetratorHistory((String) primaryKey, allegationPerpetratorHistory, lastUpdatedId);
managed = allegationPerpetratorHistoryDao.update(managed);
return new gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory(managed);
} catch (EntityNotFoundException e) {
LOGGER.info("AllegationPerpetratorHistory not found : {}", allegationPerpetratorHistory);
throw new ServiceException(e);
}
}
use of gov.ca.cwds.rest.services.ServiceException in project API by ca-cwds.
the class AllegationService method create.
/**
* {@inheritDoc}
*
* @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
*/
@Override
public PostedAllegation create(Request request) {
assert request instanceof gov.ca.cwds.rest.api.domain.cms.Allegation;
gov.ca.cwds.rest.api.domain.cms.Allegation allegation = (gov.ca.cwds.rest.api.domain.cms.Allegation) request;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
Allegation managed = new Allegation(CmsKeyIdGenerator.cmsIdGenertor(lastUpdatedId), allegation, lastUpdatedId);
managed = allegationDao.create(managed);
return new PostedAllegation(managed);
} catch (EntityExistsException e) {
LOGGER.info("Allegation already exists : {}", allegation);
throw new ServiceException(e);
}
}
Aggregations