use of org.mifos.framework.components.audit.util.helpers.AuditInterceptor in project head by mifos.
the class GenericDaoHibernate method update.
@Override
public final void update(final Object entity) {
try {
Session session = getSession();
session.update(entity);
AuditInterceptor interceptor = (AuditInterceptor) StaticHibernateUtil.getInterceptor();
if (interceptor.isAuditLogRequired()) {
interceptor.createChangeValueMap(entity);
}
} catch (Exception e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.framework.components.audit.util.helpers.AuditInterceptor in project head by mifos.
the class LegacyGenericDao method save.
public Object save(final Object object) throws PersistenceException {
try {
getSession().saveOrUpdate(object);
AuditInterceptor interceptor = (AuditInterceptor) StaticHibernateUtil.getInterceptor();
if (interceptor.isAuditLogRequired()) {
interceptor.createChangeValueMap(object);
}
} catch (HibernateException e) {
throw new PersistenceException(e);
}
return object;
}
use of org.mifos.framework.components.audit.util.helpers.AuditInterceptor in project head by mifos.
the class LoanOfferingBOIntegrationTest method testUpdateLoanOfferingForLogging.
@Test
public void testUpdateLoanOfferingForLogging() throws ProductDefinitionException, FeeException {
createIntitalObjects();
Date startDate = offSetCurrentDate(0);
Date endDate = offSetCurrentDate(2);
periodicFee = TestObjectFactory.createPeriodicAmountFee("Loan Periodic", FeeCategory.LOAN, "100", RecurrenceType.MONTHLY, (short) 1);
oneTimeFee = TestObjectFactory.createOneTimeAmountFee("Loan One time", FeeCategory.LOAN, "100", FeePayment.UPFRONT);
List<FeeBO> fees = new ArrayList<FeeBO>();
fees.add(periodicFee);
fees.add(oneTimeFee);
product = createLoanOfferingBO("Loan Product", "LOAP");
((AuditInterceptor) StaticHibernateUtil.getInterceptor()).createInitialValueMap(product);
product.update((short) 1, "Loan Product", "LOAN", productCategory, prdApplicableMaster, startDate, endDate, "Loan Product updated", PrdStatus.LOAN_ACTIVE, null, interestTypes, (short) 0, 12.0, 2.0, 12.0, false, true, true, null, fees, null, (short) 2, RecurrenceType.MONTHLY, populateLoanPrdActionForm("1", "1", new Double("3000"), new Double("1000"), new Double("1000"), "12", "1", "2"), waiverInterest, null);
StaticHibernateUtil.flushAndClearSession();
StaticHibernateUtil.getInterceptor().afterTransactionCompletion(new AuditTransactionForTests());
product = (LoanOfferingBO) TestObjectFactory.getObject(LoanOfferingBO.class, product.getPrdOfferingId());
List<AuditLog> auditLogList = TestObjectFactory.getChangeLog(EntityType.LOANPRODUCT, new Integer(product.getPrdOfferingId().toString()));
Assert.assertEquals(1, auditLogList.size());
Assert.assertEquals(EntityType.LOANPRODUCT.getValue(), auditLogList.get(0).getEntityType());
Assert.assertEquals(15, auditLogList.get(0).getAuditLogRecords().size());
for (AuditLogRecord auditLogRecord : auditLogList.get(0).getAuditLogRecords()) {
if (auditLogRecord.getFieldName().equalsIgnoreCase("Min Loan Amount")) {
Assert.assertEquals("300.0", auditLogRecord.getOldValue());
Assert.assertEquals("1000.0", auditLogRecord.getNewValue());
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Description")) {
Assert.assertEquals("-", auditLogRecord.getOldValue());
Assert.assertEquals("Loan Product updated", auditLogRecord.getNewValue());
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Applicable For")) {
Assert.assertEquals("Groups", auditLogRecord.getOldValue());
Assert.assertEquals("Clients", auditLogRecord.getNewValue());
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Frequency Of Installments")) {
Assert.assertEquals("Week(s)", auditLogRecord.getOldValue());
Assert.assertEquals("Month(s)", auditLogRecord.getNewValue());
}
}
}
use of org.mifos.framework.components.audit.util.helpers.AuditInterceptor in project head by mifos.
the class LegacyGenericDao method createOrUpdate.
/**
* @deprecated - move away from using this as starts transaction but doesn't not commit..
*/
@Deprecated
public Object createOrUpdate(final Object object) throws PersistenceException {
try {
StaticHibernateUtil.startTransaction();
getSession().saveOrUpdate(object);
AuditInterceptor interceptor = (AuditInterceptor) StaticHibernateUtil.getInterceptor();
if (interceptor.isAuditLogRequired()) {
interceptor.createChangeValueMap(object);
}
} catch (HibernateException e) {
throw new PersistenceException(e);
}
return object;
}
use of org.mifos.framework.components.audit.util.helpers.AuditInterceptor in project head by mifos.
the class GenericDaoHibernate method createOrUpdate.
@Override
public final void createOrUpdate(final Object entity) {
try {
Session session = getSession();
session.saveOrUpdate(entity);
AuditInterceptor interceptor = (AuditInterceptor) StaticHibernateUtil.getInterceptor();
if (interceptor.isAuditLogRequired()) {
interceptor.createChangeValueMap(entity);
}
} catch (Exception e) {
throw new MifosRuntimeException(e);
}
}
Aggregations