Search in sources :

Example 1 with LongText

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

Example 2 with LongText

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

Example 3 with LongText

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

the class LongTextDaoIT method testUpdateEntityNotFoundException.

@Override
@Test
public void testUpdateEntityNotFoundException() throws Exception {
    thrown.expect(EntityNotFoundException.class);
    gov.ca.cwds.rest.api.domain.cms.LongText vdlt = validDomainLongText();
    LongText longText = new LongText("ABC1234567", vdlt.getCountySpecificCode(), vdlt.getTextDescription());
    longTextDao.update(longText);
}
Also used : LongText(gov.ca.cwds.data.persistence.cms.LongText) Test(org.junit.Test)

Example 4 with LongText

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

the class LongTextDaoIT method testDelete.

/**
   * Delete JUnit test
   */
@Override
@Test
public void testDelete() throws Exception {
    LongText deleted = longTextDao.delete(id);
    assertThat(deleted.getId(), is(id));
}
Also used : LongText(gov.ca.cwds.data.persistence.cms.LongText) Test(org.junit.Test)

Example 5 with LongText

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

the class LongTextDaoIT method testDeleteEntityNotFoundException.

@Override
@Test
public void testDeleteEntityNotFoundException() throws Exception {
    LongText deleted = longTextDao.delete("9999999ZZZ");
    assertThat(deleted, is(nullValue()));
}
Also used : LongText(gov.ca.cwds.data.persistence.cms.LongText) Test(org.junit.Test)

Aggregations

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