use of gov.ca.cwds.rest.services.ServiceException in project API by ca-cwds.
the class CrossReportService 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.CrossReport create(Request request) {
assert request instanceof gov.ca.cwds.rest.api.domain.cms.CrossReport;
gov.ca.cwds.rest.api.domain.cms.CrossReport crossReport = (gov.ca.cwds.rest.api.domain.cms.CrossReport) request;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
CrossReport managed = new CrossReport(CmsKeyIdGenerator.cmsIdGenertor(lastUpdatedId), crossReport, lastUpdatedId);
managed = crossReportDao.create(managed);
return new gov.ca.cwds.rest.api.domain.cms.CrossReport(managed);
} catch (EntityExistsException e) {
LOGGER.info("CrossReport already exists : {}", crossReport);
throw new ServiceException("CrossReport already exists : {}" + crossReport, e);
}
}
use of gov.ca.cwds.rest.services.ServiceException in project API by ca-cwds.
the class LongTextService method create.
/**
* {@inheritDoc}
*
* @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
*/
@Override
public PostedLongText create(Request request) {
assert request instanceof gov.ca.cwds.rest.api.domain.cms.LongText;
gov.ca.cwds.rest.api.domain.cms.LongText longText = (gov.ca.cwds.rest.api.domain.cms.LongText) request;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
LongText managed = new LongText(CmsKeyIdGenerator.cmsIdGenertor(lastUpdatedId), longText, lastUpdatedId);
managed = longTextDao.create(managed);
return new PostedLongText(managed);
} catch (EntityExistsException e) {
LOGGER.info("LongText already exists : {}", longText);
throw new ServiceException(e);
}
}
use of gov.ca.cwds.rest.services.ServiceException in project API by ca-cwds.
the class LongTextService 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.LongText update(Serializable primaryKey, Request request) {
assert primaryKey instanceof String;
assert request instanceof gov.ca.cwds.rest.api.domain.cms.LongText;
gov.ca.cwds.rest.api.domain.cms.LongText longText = (gov.ca.cwds.rest.api.domain.cms.LongText) request;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
LongText managed = new LongText((String) primaryKey, longText, lastUpdatedId);
managed = longTextDao.update(managed);
return new gov.ca.cwds.rest.api.domain.cms.LongText(managed);
} catch (EntityNotFoundException e) {
LOGGER.info("LongText not found : {}", longText);
throw new ServiceException(e);
}
}
use of gov.ca.cwds.rest.services.ServiceException in project API by ca-cwds.
the class ReferralClientService method update.
@Override
public gov.ca.cwds.rest.api.domain.cms.ReferralClient update(Serializable primaryKeyObject, 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 {
ReferralClient managed = new ReferralClient(referralClient, "BTr");
// 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 (EntityNotFoundException e) {
LOGGER.info("Referral not found : {}", referralClient);
LOGGER.error(e.getMessage(), e);
throw new ServiceException(e);
}
}
use of gov.ca.cwds.rest.services.ServiceException in project API by ca-cwds.
the class ReporterService 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.Reporter update(Serializable primaryKey, Request request) {
assert primaryKey instanceof String;
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.update(managed);
return new gov.ca.cwds.rest.api.domain.cms.Reporter(managed);
} catch (EntityNotFoundException e) {
LOGGER.info("Reporter not found : {}", reporter);
throw new ServiceException(e);
}
}
Aggregations