Search in sources :

Example 1 with LegacyAuditDao

use of org.mifos.framework.components.audit.persistence.LegacyAuditDao in project head by mifos.

the class AuditBusinessService method getAuditLogRecords.

public List<AuditLogView> getAuditLogRecords(Short entityType, Integer entityId) throws ServiceException {
    try {
        LegacyAuditDao auditPersistence = ApplicationContextProvider.getBean(LegacyAuditDao.class);
        PersonnelBusinessService personnelService = new PersonnelBusinessService();
        List<AuditLog> auditLogRecords = auditPersistence.getAuditLogRecords(entityType, entityId);
        List<AuditLogView> auditLogViewList = new ArrayList<AuditLogView>();
        for (AuditLog auditLog : auditLogRecords) {
            for (AuditLogRecord auditLogRecord : auditLog.getAuditLogRecords()) {
                AuditLogView auditLogView = new AuditLogView();
                auditLogView.setDate(auditLog.getUpdatedDate().toString());
                Short userId = auditLog.getUpdatedBy();
                PersonnelBO personnel = personnelService.getPersonnel(userId);
                auditLogView.setUser(personnel.getUserName());
                auditLogView.setField(auditLogRecord.getFieldName());
                String encryptedPasswordAuditFieldName = AuditConfiguration.getColumnNameForPropertyName(AuditConstants.PERSONNEL, AuditConstants.Audit_PASSWORD);
                if ((null != encryptedPasswordAuditFieldName) && (auditLogRecord.getFieldName().equals(encryptedPasswordAuditFieldName.trim()))) {
                    auditLogView.setOldValue(AuditConstants.HIDDEN_PASSWORD);
                    auditLogView.setNewValue(AuditConstants.HIDDEN_PASSWORD);
                } else {
                    auditLogView.setOldValue(auditLogRecord.getOldValue());
                    auditLogView.setNewValue(auditLogRecord.getNewValue());
                }
                auditLogViewList.add(auditLogView);
            }
        }
        return auditLogViewList;
    } catch (PersistenceException e) {
        throw new ServiceException(e);
    }
}
Also used : PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) ArrayList(java.util.ArrayList) AuditLogView(org.mifos.framework.components.audit.util.helpers.AuditLogView) AuditLog(org.mifos.framework.components.audit.business.AuditLog) LegacyAuditDao(org.mifos.framework.components.audit.persistence.LegacyAuditDao) AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) ServiceException(org.mifos.framework.exceptions.ServiceException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Aggregations

ArrayList (java.util.ArrayList)1 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)1 PersonnelBusinessService (org.mifos.customers.personnel.business.service.PersonnelBusinessService)1 AuditLog (org.mifos.framework.components.audit.business.AuditLog)1 AuditLogRecord (org.mifos.framework.components.audit.business.AuditLogRecord)1 LegacyAuditDao (org.mifos.framework.components.audit.persistence.LegacyAuditDao)1 AuditLogView (org.mifos.framework.components.audit.util.helpers.AuditLogView)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1 ServiceException (org.mifos.framework.exceptions.ServiceException)1