Search in sources :

Example 1 with AuditLogView

use of org.mifos.framework.components.audit.util.helpers.AuditLogView in project head by mifos.

the class CenterServiceFacadeWebTier method retrieveChangeLogs.

@Override
public List<AuditLogDto> retrieveChangeLogs(Integer centerId) {
    try {
        List<AuditLogDto> auditLogs = new ArrayList<AuditLogDto>();
        Short entityType = EntityType.CENTER.getValue();
        AuditBusinessService auditBusinessService = new AuditBusinessService();
        List<AuditLogView> centerAuditLogs = auditBusinessService.getAuditLogRecords(entityType, centerId);
        for (AuditLogView auditLogView : centerAuditLogs) {
            auditLogs.add(auditLogView.toDto());
        }
        return auditLogs;
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : AuditBusinessService(org.mifos.framework.components.audit.business.service.AuditBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) ArrayList(java.util.ArrayList) AuditLogView(org.mifos.framework.components.audit.util.helpers.AuditLogView) AuditLogDto(org.mifos.dto.domain.AuditLogDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with AuditLogView

use of org.mifos.framework.components.audit.util.helpers.AuditLogView in project head by mifos.

the class AuditBusinessServiceIntegrationTest method testGetAuditLogRecords.

@Test
public void testGetAuditLogRecords() throws Exception {
    AuditLog auditLog = new AuditLog(1, (short) 2, "Mifos", new Date(System.currentTimeMillis()), (short) 3);
    Set<AuditLogRecord> auditLogRecords = new HashSet<AuditLogRecord>();
    AuditLogRecord auditLogRecord = new AuditLogRecord("ColumnName_1", "test_1", "new_test_1", auditLog);
    auditLogRecords.add(auditLogRecord);
    auditLog.addAuditLogRecords(auditLogRecords);
    legacyAuditDao.save(auditLog);
    AuditBusinessService auditBusinessService = new AuditBusinessService();
    List<AuditLogView> auditLogViewList = auditBusinessService.getAuditLogRecords((short) 2, 1);
    Assert.assertEquals(1, auditLogViewList.size());
    auditLog = getAuditLog(1, (short) 2);
}
Also used : AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) AuditLogView(org.mifos.framework.components.audit.util.helpers.AuditLogView) AuditLog(org.mifos.framework.components.audit.business.AuditLog) Date(java.sql.Date) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with AuditLogView

use of org.mifos.framework.components.audit.util.helpers.AuditLogView in project head by mifos.

the class AdminServiceFacadeWebTier method retrieveLoanProductAuditLogs.

@Override
public List<AuditLogDto> retrieveLoanProductAuditLogs(Integer productId) {
    List<AuditLogDto> auditLogDtos = new ArrayList<AuditLogDto>();
    AuditBusinessService auditBusinessService = new AuditBusinessService();
    try {
        List<AuditLogView> auditLogs = auditBusinessService.getAuditLogRecords(EntityType.LOANPRODUCT.getValue(), productId);
        for (AuditLogView auditLogView : auditLogs) {
            auditLogDtos.add(auditLogView.toDto());
        }
        return auditLogDtos;
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : AuditBusinessService(org.mifos.framework.components.audit.business.service.AuditBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) ArrayList(java.util.ArrayList) AuditLogView(org.mifos.framework.components.audit.util.helpers.AuditLogView) AuditLogDto(org.mifos.dto.domain.AuditLogDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 4 with AuditLogView

use of org.mifos.framework.components.audit.util.helpers.AuditLogView in project head by mifos.

the class AdminServiceFacadeWebTier method retrieveSavingsProductAuditLogs.

@Override
public List<AuditLogDto> retrieveSavingsProductAuditLogs(Integer productId) {
    List<AuditLogDto> auditLogDtos = new ArrayList<AuditLogDto>();
    AuditBusinessService auditBusinessService = new AuditBusinessService();
    try {
        List<AuditLogView> auditLogs = auditBusinessService.getAuditLogRecords(EntityType.SAVINGSPRODUCT.getValue(), productId);
        for (AuditLogView auditLogView : auditLogs) {
            auditLogDtos.add(auditLogView.toDto());
        }
        return auditLogDtos;
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : AuditBusinessService(org.mifos.framework.components.audit.business.service.AuditBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) ArrayList(java.util.ArrayList) AuditLogView(org.mifos.framework.components.audit.util.helpers.AuditLogView) AuditLogDto(org.mifos.dto.domain.AuditLogDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 5 with AuditLogView

use of org.mifos.framework.components.audit.util.helpers.AuditLogView 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

AuditLogView (org.mifos.framework.components.audit.util.helpers.AuditLogView)8 ArrayList (java.util.ArrayList)5 ServiceException (org.mifos.framework.exceptions.ServiceException)5 MifosRuntimeException (org.mifos.core.MifosRuntimeException)4 AuditLogDto (org.mifos.dto.domain.AuditLogDto)4 AuditBusinessService (org.mifos.framework.components.audit.business.service.AuditBusinessService)4 Test (org.junit.Test)3 AuditLog (org.mifos.framework.components.audit.business.AuditLog)3 AuditLogRecord (org.mifos.framework.components.audit.business.AuditLogRecord)3 Date (java.sql.Date)2 HashSet (java.util.HashSet)2 Date (java.util.Date)1 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)1 PersonnelBusinessService (org.mifos.customers.personnel.business.service.PersonnelBusinessService)1 LegacyAuditDao (org.mifos.framework.components.audit.persistence.LegacyAuditDao)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1