Search in sources :

Example 1 with PersonnelBusinessService

use of org.mifos.customers.personnel.business.service.PersonnelBusinessService in project head by mifos.

the class ShutdownServiceFacadeWebTier method getLoggedUsers.

@Override
public List<LoggedUserDto> getLoggedUsers(HttpServletRequest request) {
    ShutdownManager shutdownManager = (ShutdownManager) ServletUtils.getGlobal(request, ShutdownManager.class.getName());
    Collection<HttpSession> sessions = shutdownManager.getActiveSessions();
    List<PersonnelInfo> personnelInfos = new ArrayList<PersonnelInfo>();
    UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
    if (ActivityMapper.getInstance().isViewActiveSessionsPermitted(userContext, userContext.getBranchId())) {
        PersonnelBusinessService personnelBusinessService = new PersonnelBusinessService();
        for (HttpSession session : sessions) {
            UserContext userContextFromSession = (UserContext) session.getAttribute(LoginConstants.USERCONTEXT);
            if (userContextFromSession == null) {
                continue;
            }
            PersonnelBO personnel;
            try {
                personnel = personnelBusinessService.getPersonnel(userContextFromSession.getId());
            } catch (ServiceException e) {
                continue;
            }
            String offices = generateOfficeChain(personnel.getOffice());
            String names = personnel.getPersonnelDetails().getName().getFirstName() + " " + personnel.getPersonnelDetails().getName().getLastName();
            DateTimeFormatter formatter = DateTimeFormat.shortDateTime().withOffsetParsed().withLocale(userContext.getCurrentLocale());
            String activityTime = formatter.print(session.getLastAccessedTime());
            ActivityContext activityContext = (ActivityContext) session.getAttribute(LoginConstants.ACTIVITYCONTEXT);
            String activityDesc = "[" + activityContext.getLastForward().getName() + "] " + activityContext.getLastForward().getPath();
            personnelInfos.add(new PersonnelInfo(offices, names, activityTime, activityDesc));
        }
    }
    Collections.sort(personnelInfos);
    List<LoggedUserDto> loggedUsers = new ArrayList<LoggedUserDto>();
    for (PersonnelInfo personnelInfo : personnelInfos) {
        loggedUsers.add(new LoggedUserDto(personnelInfo.getOffices(), personnelInfo.getNames(), personnelInfo.getActivityTime(), personnelInfo.getActivityContext()));
    }
    return loggedUsers;
}
Also used : ActivityContext(org.mifos.security.util.ActivityContext) PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) HttpSession(javax.servlet.http.HttpSession) UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) PersonnelInfo(org.mifos.application.admin.system.PersonnelInfo) ShutdownManager(org.mifos.application.admin.system.ShutdownManager) ServiceException(org.mifos.framework.exceptions.ServiceException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) LoggedUserDto(org.mifos.application.admin.servicefacade.LoggedUserDto) DateTimeFormatter(org.joda.time.format.DateTimeFormatter)

Example 2 with PersonnelBusinessService

use of org.mifos.customers.personnel.business.service.PersonnelBusinessService in project head by mifos.

the class BranchReportPersistenceIntegrationTest method testExtractStaffSummaryGetsOnlyLoanOfficers.

@Test
public void testExtractStaffSummaryGetsOnlyLoanOfficers() throws Exception {
    List<BranchReportStaffSummaryBO> staffSummaries = branchReportPersistence.extractBranchReportStaffSummary(BRANCH_ID, Integer.valueOf(1), DEFAULT_CURRENCY);
    for (BranchReportStaffSummaryBO summaryBO : staffSummaries) {
        PersonnelLevel retrievedPersonnelLevel = new PersonnelBusinessService().getPersonnel(summaryBO.getPersonnelId()).getLevelEnum();
        Assert.assertEquals(PersonnelLevel.LOAN_OFFICER, retrievedPersonnelLevel);
    }
}
Also used : PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) BranchReportStaffSummaryBO(org.mifos.reports.branchreport.BranchReportStaffSummaryBO) PersonnelLevel(org.mifos.customers.personnel.util.helpers.PersonnelLevel) Test(org.junit.Test)

Example 3 with PersonnelBusinessService

use of org.mifos.customers.personnel.business.service.PersonnelBusinessService in project head by mifos.

the class BranchReportServiceIntegrationTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    branchReport = new BranchReportBO(BRANCH_ID_SHORT, RUN_DATE);
    populateClientSummary();
    populateLoanArrearSummary();
    session = StaticHibernateUtil.getSessionTL();
    //        transaction = session.beginTransaction();
    officeBusinessServiceMock = createMock(OfficeBusinessService.class);
    branchReportService = new BranchReportService(officeBusinessServiceMock, new PersonnelBusinessService(), new BranchReportPersistence());
}
Also used : PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) OfficeBusinessService(org.mifos.customers.office.business.service.OfficeBusinessService) BranchReportBO(org.mifos.reports.branchreport.BranchReportBO) BranchReportPersistence(org.mifos.reports.branchreport.persistence.BranchReportPersistence) Before(org.junit.Before)

Example 4 with PersonnelBusinessService

use of org.mifos.customers.personnel.business.service.PersonnelBusinessService 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)

Example 5 with PersonnelBusinessService

use of org.mifos.customers.personnel.business.service.PersonnelBusinessService in project head by mifos.

the class AuditLogServiceImpl method addAuditLogRegistry.

@Override
public void addAuditLogRegistry(QuestionGroupDetail questionGroupDetail, QuestionGroupDetail oldQuestionGroupDetail, int creatorId, int entityId, String source, String event) {
    PersonnelBusinessService pbs = new PersonnelBusinessService();
    String modifierName;
    if (oldQuestionGroupDetail != null && event.toLowerCase().equals(CREATE)) {
        String questionGroupName;
        String sectionName;
        String fieldName;
        String fieldValue;
        try {
            modifierName = pbs.getPersonnel((short) creatorId).getDisplayName();
        } catch (ServiceException e) {
            modifierName = "";
        }
        questionGroupName = questionGroupDetail.getTitle();
        AuditLog auditLog = new AuditLog(entityId, EntityType.getEntityValue(source.toUpperCase()), modifierName, new DateTimeService().getCurrentJavaSqlDate(), (short) creatorId);
        Set<AuditLogRecord> auditLogRecords = new HashSet<AuditLogRecord>();
        for (int sectionPosition = 0; sectionPosition < questionGroupDetail.getSectionDetails().size(); sectionPosition++) {
            SectionDetail sectionDetail = questionGroupDetail.getSectionDetails().get(sectionPosition);
            sectionName = sectionDetail.getName();
            for (int questionPosition = 0; questionPosition < sectionDetail.getQuestions().size(); questionPosition++) {
                SectionQuestionDetail sectionQuestionDetail = sectionDetail.getQuestions().get(questionPosition);
                fieldName = sectionQuestionDetail.getText();
                fieldValue = sectionQuestionDetail.getAnswer();
                String oldFieldValue = null;
                for (SectionDetail oldSectionDetail : oldQuestionGroupDetail.getSectionDetails()) {
                    if (oldSectionDetail.getName().equals(sectionName)) {
                        for (SectionQuestionDetail oldSectionQuestionDetail : oldSectionDetail.getQuestions()) {
                            if (oldSectionQuestionDetail.getText().equals(fieldName)) {
                                oldFieldValue = oldSectionQuestionDetail.getAnswer();
                                break;
                            }
                        }
                        break;
                    }
                }
                if (!fieldValue.equals("")) {
                    if (oldFieldValue != null && !oldFieldValue.equals("")) {
                        if (!oldFieldValue.equals(fieldValue)) {
                            auditLogRecords.add(new AuditLogRecord(trimField(questionGroupName + "/" + sectionName + "/" + fieldName, 100), trimField(oldFieldValue, 200), trimField(fieldValue, 200), auditLog));
                        }
                    } else {
                        auditLogRecords.add(new AuditLogRecord(trimField(questionGroupName + "/" + sectionName + "/" + fieldName, 100), "-", trimField(fieldValue, 200), auditLog));
                    }
                }
            }
        }
        if (!auditLogRecords.isEmpty()) {
            auditLog.addAuditLogRecords(auditLogRecords);
            legacyAuditDao.save(auditLog);
        }
    }
}
Also used : AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) DateTimeService(org.mifos.framework.util.DateTimeService) AuditLog(org.mifos.framework.components.audit.business.AuditLog) HashSet(java.util.HashSet)

Aggregations

PersonnelBusinessService (org.mifos.customers.personnel.business.service.PersonnelBusinessService)12 ArrayList (java.util.ArrayList)6 ServiceException (org.mifos.framework.exceptions.ServiceException)6 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)5 Before (org.junit.Before)3 PersistenceException (org.mifos.framework.exceptions.PersistenceException)3 ActivityContext (org.mifos.security.util.ActivityContext)3 UserContext (org.mifos.security.util.UserContext)3 HttpSession (javax.servlet.http.HttpSession)2 Test (org.junit.Test)2 ShutdownManager (org.mifos.application.admin.system.ShutdownManager)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 OfficeBO (org.mifos.customers.office.business.OfficeBO)2 PersonnelLevel (org.mifos.customers.personnel.util.helpers.PersonnelLevel)2 AddressDto (org.mifos.dto.domain.AddressDto)2 Address (org.mifos.framework.business.util.Address)2 AuditLog (org.mifos.framework.components.audit.business.AuditLog)2 AuditLogRecord (org.mifos.framework.components.audit.business.AuditLogRecord)2 FieldConfig (org.mifos.framework.components.fieldConfiguration.util.helpers.FieldConfig)2 ValidationException (org.mifos.framework.exceptions.ValidationException)2