use of gov.ca.cwds.data.persistence.cms.StaffPerson 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);
}
}
use of gov.ca.cwds.data.persistence.cms.StaffPerson in project API by ca-cwds.
the class ReferralService 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.Referral update(Serializable primaryKey, Request request) {
assert primaryKey instanceof String;
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((String) primaryKey, referral, lastUpdatedId);
managed = referralDao.update(managed);
// checking the staffPerson county code
StaffPerson staffperson = staffpersonDao.find(managed.getLastUpdatedId());
if (staffperson != null && (triggerTablesDao.getLaCountySpecificCode().equals(staffperson.getCountyCode()))) {
laCountyTrigger.createCountyTrigger(managed);
}
return new gov.ca.cwds.rest.api.domain.cms.Referral(managed);
} catch (EntityNotFoundException e) {
final String msg = "Referral not found : " + referral;
LOGGER.error("Referral not found : {}", referral);
throw new ServiceException(msg, e);
}
}
use of gov.ca.cwds.data.persistence.cms.StaffPerson in project API by ca-cwds.
the class StaffPersonDaoIT method testFindEntityNotFoundException.
@Override
@Test
public void testFindEntityNotFoundException() throws Exception {
String id = "ZZZ";
StaffPerson found = staffPersonDao.find(id);
assertThat(found, is(nullValue()));
}
use of gov.ca.cwds.data.persistence.cms.StaffPerson in project API by ca-cwds.
the class StaffPersonDaoIT method testCreateExistingEntityException.
@Override
@Test
public void testCreateExistingEntityException() throws Exception {
thrown.expect(EntityExistsException.class);
StaffPerson staffPerson = new StaffPerson("q1p", null, "External Interface", "external interface", "SCXCIN7", " ", "", BigDecimal.valueOf(9165672100L), 0, null, " ", "N", "MIZN02k00E", " ", " ", "99", "N", "3XPCP92q38", null);
staffPersonDao.create(staffPerson);
}
use of gov.ca.cwds.data.persistence.cms.StaffPerson in project API by ca-cwds.
the class StaffPersonDaoIT method testUpdate.
@Override
@Test
public void testUpdate() throws Exception {
StaffPerson staffPerson = new StaffPerson("q1p", null, "External Interface", "external interface", "SCXCIN7", " ", "", BigDecimal.valueOf(9165672100L), 0, null, " ", "N", "MIZN02k00E", " ", " ", "99", "N", "3XPCP92q38", null);
StaffPerson updated = staffPersonDao.update(staffPerson);
assertThat(updated, is(staffPerson));
}
Aggregations