Search in sources :

Example 31 with EntityNotFoundException

use of javax.persistence.EntityNotFoundException in project API by ca-cwds.

the class ReferralClientService method update.

@Override
public gov.ca.cwds.rest.api.domain.cms.ReferralClient update(Serializable primaryKeyObject, Request request) {
    assert request instanceof gov.ca.cwds.rest.api.domain.cms.ReferralClient;
    gov.ca.cwds.rest.api.domain.cms.ReferralClient referralClient = (gov.ca.cwds.rest.api.domain.cms.ReferralClient) request;
    try {
        ReferralClient managed = new ReferralClient(referralClient, "BTr");
        // checking the staffPerson county code
        StaffPerson staffperson = staffpersonDao.find(managed.getLastUpdatedId());
        if (staffperson != null && (triggerTablesDao.getLaCountySpecificCode().equals(staffperson.getCountyCode()))) {
            laCountyTrigger.createCountyTrigger(managed);
        } else {
            nonLaTriggers.createAndUpdateReferralClientCoutyOwnership(managed);
        }
        return new gov.ca.cwds.rest.api.domain.cms.ReferralClient(managed);
    } catch (EntityNotFoundException e) {
        LOGGER.info("Referral not found : {}", referralClient);
        LOGGER.error(e.getMessage(), e);
        throw new ServiceException(e);
    }
}
Also used : StaffPerson(gov.ca.cwds.data.persistence.cms.StaffPerson) ServiceException(gov.ca.cwds.rest.services.ServiceException) EntityNotFoundException(javax.persistence.EntityNotFoundException) ReferralClient(gov.ca.cwds.data.persistence.cms.ReferralClient)

Example 32 with EntityNotFoundException

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

Example 33 with EntityNotFoundException

use of javax.persistence.EntityNotFoundException in project API by ca-cwds.

the class ClientUcService 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.ClientUc update(Serializable primaryKey, Request request) {
    assert request instanceof gov.ca.cwds.rest.api.domain.cms.ClientUc;
    gov.ca.cwds.rest.api.domain.cms.ClientUc clientUc = (gov.ca.cwds.rest.api.domain.cms.ClientUc) request;
    try {
        String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
        ClientUc managed = new ClientUc(clientUc, lastUpdatedId);
        managed = clientucDao.update(managed);
        return new gov.ca.cwds.rest.api.domain.cms.ClientUc(managed);
    } catch (EntityNotFoundException e) {
        LOGGER.info("Client not found : {}", clientUc);
        throw new ServiceException(e);
    }
}
Also used : ServiceException(gov.ca.cwds.rest.services.ServiceException) ClientUc(gov.ca.cwds.data.persistence.cms.ClientUc) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 34 with EntityNotFoundException

use of javax.persistence.EntityNotFoundException in project API by ca-cwds.

the class ChildClientService 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.ChildClient update(Serializable primaryKey, Request request) {
    assert request instanceof gov.ca.cwds.rest.api.domain.cms.ChildClient;
    gov.ca.cwds.rest.api.domain.cms.ChildClient childClient = (gov.ca.cwds.rest.api.domain.cms.ChildClient) request;
    try {
        String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
        ChildClient managed = new ChildClient(childClient.getVictimClientId(), childClient, lastUpdatedId);
        managed = childClientDao.update(managed);
        return new gov.ca.cwds.rest.api.domain.cms.ChildClient(managed);
    } catch (EntityNotFoundException e) {
        LOGGER.info("childClient not found : {}", childClient);
        throw new ServiceException(e);
    }
}
Also used : ServiceException(gov.ca.cwds.rest.services.ServiceException) EntityNotFoundException(javax.persistence.EntityNotFoundException) ChildClient(gov.ca.cwds.data.persistence.cms.ChildClient)

Example 35 with EntityNotFoundException

use of javax.persistence.EntityNotFoundException in project API by ca-cwds.

the class ClientAddressService method update.

@Override
public Response update(Serializable primaryKey, Request request) {
    assert primaryKey instanceof String;
    assert request instanceof gov.ca.cwds.rest.api.domain.cms.ClientAddress;
    gov.ca.cwds.rest.api.domain.cms.ClientAddress clientAddress = (gov.ca.cwds.rest.api.domain.cms.ClientAddress) request;
    try {
        String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
        ClientAddress managed = new ClientAddress((String) primaryKey, clientAddress, lastUpdatedId);
        // checking the staffPerson county code
        StaffPerson staffperson = staffpersonDao.find(managed.getLastUpdatedId());
        if (staffperson != null && (triggerTablesDao.getLaCountySpecificCode().equals(staffperson.getCountyCode()))) {
            laCountyTrigger.createClientAddressCountyTrigger(managed);
        }
        managed = clientAddressDao.update(managed);
        return new gov.ca.cwds.rest.api.domain.cms.ClientAddress(managed, true);
    } catch (EntityNotFoundException e) {
        LOGGER.info("ClientAddress not found : {}", clientAddress);
        throw new ServiceException(e);
    }
}
Also used : StaffPerson(gov.ca.cwds.data.persistence.cms.StaffPerson) ClientAddress(gov.ca.cwds.data.persistence.cms.ClientAddress) EntityNotFoundException(javax.persistence.EntityNotFoundException) ServiceException(gov.ca.cwds.rest.services.ServiceException)

Aggregations

EntityNotFoundException (javax.persistence.EntityNotFoundException)75 EntityManager (javax.persistence.EntityManager)20 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)18 ServiceException (gov.ca.cwds.rest.services.ServiceException)15 Transactional (org.springframework.transaction.annotation.Transactional)14 BusinessServiceException (sic.service.BusinessServiceException)11 Test (org.junit.Test)10 Calendar (java.util.Calendar)9 GregorianCalendar (java.util.GregorianCalendar)9 ArrayList (java.util.ArrayList)7 BooleanBuilder (com.querydsl.core.BooleanBuilder)6 TblMle (com.intel.mtwilson.as.data.TblMle)5 IllegalOrphanException (com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException)4 TblModuleManifest (com.intel.mtwilson.as.data.TblModuleManifest)4 PersistenceException (javax.persistence.PersistenceException)4 Sort (org.springframework.data.domain.Sort)4 TblHosts (com.intel.mtwilson.as.data.TblHosts)3 OptimisticLockException (javax.persistence.OptimisticLockException)3 TblEventType (com.intel.mtwilson.as.data.TblEventType)2 TblHostSpecificManifest (com.intel.mtwilson.as.data.TblHostSpecificManifest)2