use of gov.ca.cwds.data.persistence.cms.Reporter 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);
}
}
use of gov.ca.cwds.data.persistence.cms.Reporter in project API by ca-cwds.
the class ReporterService method create.
/**
* {@inheritDoc}
*
* @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
*/
@Override
public PostedReporter create(Request request) {
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.create(managed);
return new PostedReporter(managed);
} catch (EntityExistsException e) {
LOGGER.info("Reporter already exists : {}", reporter);
throw new ServiceException(e);
}
}
use of gov.ca.cwds.data.persistence.cms.Reporter in project API by ca-cwds.
the class ReporterDaoIT method testUpdate.
@Override
@Test
public void testUpdate() throws Exception {
Reporter reporter = new Reporter("AbiQCgu0Hj", " ", "City", (short) 591, (short) 0, "N", null, " ", null, "N", "Fred", "Reporter", "N", 0, BigDecimal.valueOf(0), " ", " ", BigDecimal.valueOf(0L), 0, (short) 1828, "Street", "12345", " ", new Integer(95845), "AbiQCgu0Hk", (short) 0, "51");
Reporter updated = reporterDao.update(reporter);
assertThat(reporter, is(updated));
}
use of gov.ca.cwds.data.persistence.cms.Reporter in project API by ca-cwds.
the class ReporterDaoIT method testDeleteEntityNotFoundException.
@Override
@Test
public void testDeleteEntityNotFoundException() throws Exception {
String id = "ZZZZZZZ999";
Reporter deleted = reporterDao.delete(id);
assertThat(deleted, is(nullValue()));
}
use of gov.ca.cwds.data.persistence.cms.Reporter in project API by ca-cwds.
the class ReporterDaoIT method testFindAllReturnsCorrectList.
@Override
@Test
public void testFindAllReturnsCorrectList() throws Exception {
Query query = session.getNamedQuery("gov.ca.cwds.data.persistence.cms.Reporter.findAll");
@SuppressWarnings("unchecked") final List<Reporter> list = query.list();
System.out.println("size of query list is: " + list.size());
for (Reporter c : list) {
System.out.println("id " + c.getPrimaryKey() + " " + c.getLastName());
}
assertThat(query.list().size(), is(0));
}
Aggregations