Search in sources :

Example 6 with PersonnelBusinessService

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

the class ChkListAction method get.

@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ChkListActionForm chkListActionForm = (ChkListActionForm) form;
    Short localeId = getUserContext(request).getLocaleId();
    Short checklistId = getShortValue(chkListActionForm.getCheckListId());
    CheckListBO checkList = new CheckListPersistence().getCheckList(checklistId);
    if (checkList.getCheckListType().equals(CheckListType.CUSTOMER_CHECKLIST)) {
        CustomerCheckListBO customerCheckList = (CustomerCheckListBO) checkList;
        SessionUtils.setAttribute(Constants.BUSINESS_KEY, customerCheckList, request);
        SessionUtils.setAttribute(CheckListConstants.TYPE, CheckListType.CUSTOMER_CHECKLIST.getValue(), request);
    } else {
        AccountCheckListBO accountCheckList = (AccountCheckListBO) checkList;
        SessionUtils.setAttribute(Constants.BUSINESS_KEY, accountCheckList, request);
        SessionUtils.setAttribute(CheckListConstants.TYPE, CheckListType.ACCOUNT_CHECKLIST.getValue(), request);
    }
    SessionUtils.setAttribute(CheckListConstants.CREATED_BY_NAME, new PersonnelBusinessService().getPersonnel(checkList.getCreatedBy()).getDisplayName(), request);
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) ChkListActionForm(org.mifos.customers.checklist.struts.actionforms.ChkListActionForm) CheckListPersistence(org.mifos.customers.checklist.persistence.CheckListPersistence) AccountCheckListBO(org.mifos.customers.checklist.business.AccountCheckListBO) CheckListBO(org.mifos.customers.checklist.business.CheckListBO) CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) AccountCheckListBO(org.mifos.customers.checklist.business.AccountCheckListBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 7 with PersonnelBusinessService

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

the class PersonActionStrutsTest method setUp.

@Before
public void setUp() throws Exception {
    userContext = TestUtils.makeUser();
    request.getSession().setAttribute(Constants.USERCONTEXT, userContext);
    addRequestParameter("recordLoanOfficerId", "1");
    addRequestParameter("recordOfficeId", "1");
    ActivityContext ac = new ActivityContext((short) 0, userContext.getBranchId().shortValue(), userContext.getId().shortValue());
    request.getSession(false).setAttribute("ActivityContext", ac);
    flowKey = createFlow(request, PersonAction.class);
    EntityMasterData.getInstance().init();
    FieldConfig fieldConfig = FieldConfig.getInstance();
    fieldConfig.init();
    getActionServlet().getServletContext().setAttribute(Constants.FIELD_CONFIGURATION, fieldConfig.getEntityMandatoryFieldMap());
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter("input", "CreateUser");
    PersonnelBusinessService personnelBusinessService = new PersonnelBusinessService();
    SessionUtils.setAttribute(PersonnelConstants.OFFICE, personnelBusinessService.getOffice(TestObjectFactory.HEAD_OFFICE), request);
    SessionUtils.setCollectionAttribute(PersonnelConstants.ROLES_LIST, personnelBusinessService.getRoles(), request);
    SessionUtils.setCollectionAttribute(PersonnelConstants.ROLEMASTERLIST, personnelBusinessService.getRoles(), request);
    personnelBusinessService = null;
}
Also used : ActivityContext(org.mifos.security.util.ActivityContext) PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) FieldConfig(org.mifos.framework.components.fieldConfiguration.util.helpers.FieldConfig) Before(org.junit.Before)

Example 8 with PersonnelBusinessService

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

the class PersonnelSettingsActionStrutsTest method setUp.

@Before
public void setUp() throws Exception {
    userContext = TestUtils.makeUser();
    request.getSession().setAttribute(Constants.USERCONTEXT, userContext);
    addRequestParameter("recordLoanOfficerId", "1");
    addRequestParameter("recordOfficeId", "1");
    ActivityContext ac = new ActivityContext((short) 0, userContext.getBranchId().shortValue(), userContext.getId().shortValue());
    request.getSession(false).setAttribute("ActivityContext", ac);
    flowKey = createFlow(request, PersonnelSettingsAction.class);
    EntityMasterData.getInstance().init();
    FieldConfig fieldConfig = FieldConfig.getInstance();
    fieldConfig.init();
    getActionServlet().getServletContext().setAttribute(Constants.FIELD_CONFIGURATION, fieldConfig.getEntityMandatoryFieldMap());
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter("input", "CreateUser");
    PersonnelBusinessService personnelBusinessService = new PersonnelBusinessService();
    SessionUtils.setAttribute(PersonnelConstants.OFFICE, personnelBusinessService.getOffice(TestObjectFactory.HEAD_OFFICE), request);
    SessionUtils.setCollectionAttribute(PersonnelConstants.ROLES_LIST, personnelBusinessService.getRoles(), request);
    SessionUtils.setCollectionAttribute(PersonnelConstants.ROLEMASTERLIST, personnelBusinessService.getRoles(), request);
    personnelBusinessService = null;
}
Also used : ActivityContext(org.mifos.security.util.ActivityContext) PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) FieldConfig(org.mifos.framework.components.fieldConfiguration.util.helpers.FieldConfig) Before(org.junit.Before)

Example 9 with PersonnelBusinessService

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

the class BranchReportServiceIntegrationTest method testResultsForStaffingLevelAreSorted.

@Test
public void testResultsForStaffingLevelAreSorted() throws PersistenceException, ServiceException {
    BranchReportPersistence branchReportPersistenceMock = createMock(BranchReportPersistence.class);
    branchReportService = new BranchReportService(officeBusinessServiceMock, new PersonnelBusinessService(), branchReportPersistenceMock);
    ArrayList<BranchReportStaffingLevelSummaryBO> staffingLevelResult = new ArrayList<BranchReportStaffingLevelSummaryBO>();
    BranchReportStaffingLevelSummaryBO totalStaffSummaryBO = new BranchReportStaffingLevelSummaryBO(IS_TOTAL, "A", 1);
    staffingLevelResult.add(totalStaffSummaryBO);
    staffingLevelResult.add(new BranchReportStaffingLevelSummaryBO(IS_NOT_TOTAL, "A", 1));
    staffingLevelResult.add(new BranchReportStaffingLevelSummaryBO(IS_NOT_TOTAL, "B", 1));
    expect(branchReportPersistenceMock.getBranchReportStaffingLevelSummary(BRANCH_ID_SHORT, RUN_DATE)).andReturn(staffingLevelResult);
    replay(branchReportPersistenceMock);
    List<BranchReportStaffingLevelSummaryBO> retrievedStaffingLevel = branchReportService.getStaffingLevelSummary(BRANCH_ID, RUN_DATE_STR);
    verify(branchReportPersistenceMock);
    BranchReportStaffingLevelSummaryBO lastBO = null;
    for (BranchReportStaffingLevelSummaryBO summaryBO : retrievedStaffingLevel) {
        if (lastBO != null) {
            Assert.assertEquals(1, summaryBO.compareTo(lastBO));
        }
        lastBO = summaryBO;
    }
    Assert.assertEquals(0, totalStaffSummaryBO.compareTo(lastBO));
}
Also used : PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) ArrayList(java.util.ArrayList) BranchReportPersistence(org.mifos.reports.branchreport.persistence.BranchReportPersistence) BranchReportStaffingLevelSummaryBO(org.mifos.reports.branchreport.BranchReportStaffingLevelSummaryBO) Test(org.junit.Test)

Example 10 with PersonnelBusinessService

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

the class PersonnelServiceFacadeWebTier method updatePersonnel.

@Override
public UserDetailDto updatePersonnel(CreateOrUpdatePersonnelInformation personnel) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(user);
    PersonnelBO userForUpdate = this.personnelDao.findPersonnelById(personnel.getId().shortValue());
    userForUpdate.updateDetails(userContext);
    AddressDto addressDto = personnel.getAddress();
    Address address = new Address(addressDto.getLine1(), addressDto.getLine2(), addressDto.getLine3(), addressDto.getCity(), addressDto.getState(), addressDto.getCountry(), addressDto.getZip(), addressDto.getPhoneNumber());
    PersonnelStatus status = PersonnelStatus.getPersonnelStatus(personnel.getPersonnelStatusId());
    PersonnelLevel userHierarchyLevel = PersonnelLevel.fromInt(personnel.getPersonnelLevelId().intValue());
    OfficeBO newOffice = this.officeDao.findOfficeById(personnel.getOfficeId());
    validateForUpdate(userForUpdate, status, newOffice, userHierarchyLevel);
    List<RoleBO> selectedRoles = new ArrayList<RoleBO>();
    try {
        List<RoleBO> allRoles = new PersonnelBusinessService().getRoles();
        for (RoleBO role : allRoles) {
            if (isRoleSelected(role, personnel.getRoles())) {
                selectedRoles.add(role);
            }
        }
        PersonnelStatusEntity personnelStatus = legacyMasterDao.getPersistentObject(PersonnelStatusEntity.class, status.getValue());
        PersonnelLevelEntity personnelLevel = legacyMasterDao.getPersistentObject(PersonnelLevelEntity.class, userHierarchyLevel.getValue());
        Short preferredLocaleId = personnel.getPreferredLocale();
        transactionHelper.startTransaction();
        transactionHelper.beginAuditLoggingFor(userForUpdate);
        userForUpdate.updateUserDetails(personnel.getFirstName(), personnel.getMiddleName(), personnel.getSecondLastName(), personnel.getLastName(), personnel.getEmailId(), personnel.getGender(), personnel.getMaritalStatus(), preferredLocaleId, personnelStatus, address, personnel.getTitle(), personnelLevel, selectedRoles, newOffice);
        userForUpdate.getPersonnelDetails().setDob(personnel.getDob().toDate());
        userForUpdate.setPasswordExpirationDate(personnel.getPasswordExpirationDate().toDate());
        if (!StringUtils.isEmpty(personnel.getPassword())) {
            this.personelService.changePassword(userForUpdate, personnel.getPassword(), false);
        }
        this.personnelDao.save(userForUpdate);
        transactionHelper.commitTransaction();
        return userForUpdate.toDto();
    } catch (BusinessRuleException e) {
        transactionHelper.rollbackTransaction();
        throw e;
    } catch (PersistenceException e) {
        transactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } catch (Exception e) {
        transactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        transactionHelper.closeSession();
    }
}
Also used : PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) Address(org.mifos.framework.business.util.Address) UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) AddressDto(org.mifos.dto.domain.AddressDto) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) ValidationException(org.mifos.framework.exceptions.ValidationException) BusinessRuleException(org.mifos.service.BusinessRuleException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ServiceException(org.mifos.framework.exceptions.ServiceException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) PersonnelStatusEntity(org.mifos.customers.personnel.business.PersonnelStatusEntity) PersonnelStatus(org.mifos.customers.personnel.util.helpers.PersonnelStatus) BusinessRuleException(org.mifos.service.BusinessRuleException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersistenceException(org.mifos.framework.exceptions.PersistenceException) PersonnelLevel(org.mifos.customers.personnel.util.helpers.PersonnelLevel) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

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