Search in sources :

Example 1 with CrossReport

use of gov.ca.cwds.data.persistence.cms.CrossReport in project API by ca-cwds.

the class CrossReportService 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.CrossReport update(Serializable primaryKey, 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(crossReport.getThirdId(), crossReport, lastUpdatedId);
        managed = crossReportDao.update(managed);
        return new gov.ca.cwds.rest.api.domain.cms.CrossReport(managed);
    } catch (EntityNotFoundException e) {
        LOGGER.info("CrossReport not found : {}", crossReport);
        throw new ServiceException(e);
    }
}
Also used : CrossReport(gov.ca.cwds.data.persistence.cms.CrossReport) ServiceException(gov.ca.cwds.rest.services.ServiceException) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 2 with CrossReport

use of gov.ca.cwds.data.persistence.cms.CrossReport 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);
    }
}
Also used : CrossReport(gov.ca.cwds.data.persistence.cms.CrossReport) ServiceException(gov.ca.cwds.rest.services.ServiceException) EntityExistsException(javax.persistence.EntityExistsException)

Example 3 with CrossReport

use of gov.ca.cwds.data.persistence.cms.CrossReport in project API by ca-cwds.

the class CrossReportDaoIT method testUpdateEntityNotFoundException.

@Override
@Test
public void testUpdateEntityNotFoundException() throws Exception {
    thrown.expect(EntityNotFoundException.class);
    CrossReport crossreport = new CrossReport("ZZ20cK10WS", "ZZDUfmj0WS", (short) 2094, "N", "N", null, "  ", 0, BigDecimal.ZERO, null, " ", " ", "925q4As0AC", "0AC", " ", " ", " ", "34", "N", "N", "N");
    crossreportDao.update(crossreport);
}
Also used : CrossReport(gov.ca.cwds.data.persistence.cms.CrossReport) Test(org.junit.Test)

Example 4 with CrossReport

use of gov.ca.cwds.data.persistence.cms.CrossReport in project API by ca-cwds.

the class CrossReportDaoIT method testDelete.

@Override
@Test
public void testDelete() throws Exception {
    String thirdId = "FsMh09h00J";
    CrossReport delete = crossreportDao.delete(thirdId);
    assertThat(delete.getThirdId(), is(thirdId));
}
Also used : CrossReport(gov.ca.cwds.data.persistence.cms.CrossReport) Test(org.junit.Test)

Example 5 with CrossReport

use of gov.ca.cwds.data.persistence.cms.CrossReport in project API by ca-cwds.

the class CrossReportDaoIT method testUpdate.

@Override
@Test
public void testUpdate() throws Exception {
    CrossReport crossreport = new CrossReport("Aj20cK10WS", "CVDUfmj0WS", (short) 2094, "N", "N", null, "  ", 0, BigDecimal.ZERO, null, " ", " ", "925q4As0AC", "0AC", " ", " ", " ", "34", "N", "N", "N");
    CrossReport updated = crossreportDao.update(crossreport);
    assertThat(updated, is(crossreport));
}
Also used : CrossReport(gov.ca.cwds.data.persistence.cms.CrossReport) Test(org.junit.Test)

Aggregations

CrossReport (gov.ca.cwds.data.persistence.cms.CrossReport)10 Test (org.junit.Test)8 ServiceException (gov.ca.cwds.rest.services.ServiceException)2 EntityExistsException (javax.persistence.EntityExistsException)1 EntityNotFoundException (javax.persistence.EntityNotFoundException)1