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;
}
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);
}
}
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());
}
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);
}
}
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);
}
}
}
Aggregations