Search in sources :

Example 1 with DataObjectRelationship

use of org.kuali.kfs.krad.bo.DataObjectRelationship in project cu-kfs by CU-CommunityApps.

the class CuFiscalYearMakerDaoOjb method deleteNewYearRows.

/**
 * Deletes the new year records for the given fiscal year maker. If the object has an extension it first deletes the data
 * in the extension table.
 *
 * @see org.kuali.kfs.sys.batch.dataaccess.impl.FiscalYearMakersDaoOjb#deleteNewYearRows(java.lang.Integer,
 *      org.kuali.kfs.sys.batch.dataaccess.FiscalYearMaker)
 */
@Override
public void deleteNewYearRows(Integer baseYear, FiscalYearMaker objectFiscalYearMaker) {
    // Check if an extension exists and delete extension records first
    if (persistenceStructureService.hasReference(objectFiscalYearMaker.getBusinessObjectClass(), KFSPropertyConstants.EXTENSION)) {
        Map<String, DataObjectRelationship> relationships = persistenceStructureService.getRelationshipMetadata(objectFiscalYearMaker.getBusinessObjectClass(), KFSPropertyConstants.EXTENSION);
        Class extensionClass = relationships.get(KFSPropertyConstants.EXTENSION).getRelatedClass();
        LOG.info(String.format("\ndeleting %s for %d", extensionClass.getName(), baseYear + 1));
        QueryByCriteria queryExtension = new QueryByCriteria(extensionClass, objectFiscalYearMaker.createDeleteCriteria(baseYear));
        getPersistenceBrokerTemplate().deleteByQuery(queryExtension);
        getPersistenceBrokerTemplate().clearCache();
    }
    // Delete the main objects now
    if (LOG.isInfoEnabled()) {
        LOG.info(String.format("\ndeleting %s for target year(s)", objectFiscalYearMaker.getBusinessObjectClass().getName()));
    }
    QueryByCriteria queryID = new QueryByCriteria(objectFiscalYearMaker.getBusinessObjectClass(), objectFiscalYearMaker.createDeleteCriteria(baseYear));
    getPersistenceBrokerTemplate().deleteByQuery(queryID);
    getPersistenceBrokerTemplate().clearCache();
}
Also used : DataObjectRelationship(org.kuali.kfs.krad.bo.DataObjectRelationship) QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria)

Aggregations

QueryByCriteria (org.apache.ojb.broker.query.QueryByCriteria)1 DataObjectRelationship (org.kuali.kfs.krad.bo.DataObjectRelationship)1