Search in sources :

Example 1 with DataAccessBundle

use of gov.ca.cwds.cms.data.access.service.lifecycle.DataAccessBundle in project api-core by ca-cwds.

the class DataAccessServiceBase method update.

@Override
public T update(P entityAwareDTO) throws DataAccessServicesException, DroolsException {
    try {
        DataAccessBundle<P> dataAccessBundle = new DataAccessBundle<>(entityAwareDTO);
        updateLifecycle.beforeDataProcessing(dataAccessBundle);
        PerryAccount perryAccount = PrincipalUtils.getPrincipal();
        updateLifecycle.dataProcessing(dataAccessBundle, perryAccount);
        updateLifecycle.afterDataProcessing(dataAccessBundle);
        updateLifecycle.beforeBusinessValidation(dataAccessBundle);
        updateLifecycle.businessValidation(dataAccessBundle, perryAccount);
        updateLifecycle.afterBusinessValidation(dataAccessBundle);
        T t = crudDao.update(entityAwareDTO.getEntity());
        updateLifecycle.afterStore(dataAccessBundle);
        return t;
    } catch (DroolsException e) {
        throw new DataAccessServicesException(e);
    }
}
Also used : DataAccessBundle(gov.ca.cwds.cms.data.access.service.lifecycle.DataAccessBundle) DroolsException(gov.ca.cwds.drools.DroolsException) PerryAccount(gov.ca.cwds.security.realm.PerryAccount)

Example 2 with DataAccessBundle

use of gov.ca.cwds.cms.data.access.service.lifecycle.DataAccessBundle in project api-core by ca-cwds.

the class DataAccessServiceBase method create.

@Override
public T create(P entityAwareDTO) throws DataAccessServicesException {
    try {
        DataAccessBundle<P> dataAccessBundle = new DataAccessBundle<>(entityAwareDTO);
        createLifecycle.beforeDataProcessing(dataAccessBundle);
        PerryAccount perryAccount = PrincipalUtils.getPrincipal();
        createLifecycle.dataProcessing(dataAccessBundle, perryAccount);
        createLifecycle.afterDataProcessing(dataAccessBundle);
        createLifecycle.beforeBusinessValidation(dataAccessBundle);
        createLifecycle.businessValidation(dataAccessBundle, perryAccount);
        createLifecycle.afterBusinessValidation(dataAccessBundle);
        T t = crudDao.create(entityAwareDTO.getEntity());
        createLifecycle.afterStore(dataAccessBundle);
        return t;
    } catch (DroolsException e) {
        throw new DataAccessServicesException(e);
    }
}
Also used : DataAccessBundle(gov.ca.cwds.cms.data.access.service.lifecycle.DataAccessBundle) DroolsException(gov.ca.cwds.drools.DroolsException) PerryAccount(gov.ca.cwds.security.realm.PerryAccount)

Aggregations

DataAccessBundle (gov.ca.cwds.cms.data.access.service.lifecycle.DataAccessBundle)2 DroolsException (gov.ca.cwds.drools.DroolsException)2 PerryAccount (gov.ca.cwds.security.realm.PerryAccount)2