use of gov.ca.cwds.data.persistence.cms.Allegation 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);
}
}
use of gov.ca.cwds.data.persistence.cms.Allegation in project API by ca-cwds.
the class AllegationDaoIT method testDeleteEntityNotFoundException.
@Override
@Test
public void testDeleteEntityNotFoundException() throws Exception {
Allegation deleted = allegationDao.delete("9999999ZZZ");
assertThat(deleted, is(nullValue()));
}
use of gov.ca.cwds.data.persistence.cms.Allegation in project API by ca-cwds.
the class AllegationDaoIT method testUpdateEntityNotFoundException.
@Override
@Test
public void testUpdateEntityNotFoundException() throws Exception {
thrown.expect(EntityNotFoundException.class);
gov.ca.cwds.rest.api.domain.cms.Allegation vda = validDomainAllegation();
Allegation allegation = new Allegation("1234567ABC", DomainChef.uncookDateString(vda.getAbuseEndDate()), DomainChef.uncookDateString(vda.getAbuseStartDate()), vda.getAbuseFrequency(), vda.getAbuseFrequencyPeriodCode(), vda.getAbuseLocationDescription(), vda.getAllegationDispositionType(), vda.getAllegationType(), vda.getDispositionDescription(), DomainChef.uncookDateString(vda.getDispositionDate()), DomainChef.cookBoolean(vda.getInjuryHarmDetailIndicator()), vda.getNonProtectingParentCode(), DomainChef.cookBoolean(vda.getStaffPersonAddedIndicator()), vda.getVictimClientId(), vda.getPerpetratorClientId(), vda.getReferralId(), vda.getCountySpecificCode(), DomainChef.cookBoolean(vda.getZippyCreatedIndicator()), vda.getPlacementFacilityType(), null, null);
allegationDao.update(allegation);
}
use of gov.ca.cwds.data.persistence.cms.Allegation in project API by ca-cwds.
the class AllegationDaoIT method testFindEntityNotFoundException.
@Override
@Test
public void testFindEntityNotFoundException() throws Exception {
Allegation found = allegationDao.find("9999999ZZZ");
assertThat(found, is(nullValue()));
}
use of gov.ca.cwds.data.persistence.cms.Allegation in project API by ca-cwds.
the class AllegationService 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.Allegation update(Serializable primaryKey, Request request) {
assert primaryKey instanceof String;
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((String) primaryKey, allegation, lastUpdatedId);
managed = allegationDao.update(managed);
return new gov.ca.cwds.rest.api.domain.cms.Allegation(managed);
} catch (EntityNotFoundException e) {
LOGGER.info("Allegation not found : {}", allegation);
throw new ServiceException(e);
}
}
Aggregations