Search in sources :

Example 6 with PersonnelLevelEntity

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

the class PersonAction method get.

@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    PersonActionForm personActionForm = (PersonActionForm) form;
    String globalId = request.getParameter("globalPersonnelNum");
    if (globalId == null) {
        globalId = personActionForm.getGlobalPersonnelNum();
    }
    PersonnelInformationDto personnelInformationDto = this.personnelServiceFacade.getPersonnelInformationDto(null, globalId);
    SessionUtils.removeThenSetAttribute("personnelInformationDto", personnelInformationDto, request);
    // John W - for other actions downstream (like edit) business_key set (until all actions refactored)
    PersonnelBO personnelBO = this.personnelDao.findPersonnelById(personnelInformationDto.getPersonnelId());
    SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, personnelBO, request);
    String url = String.format("PersonAction.do?globalPersonnelNum=%s", personnelBO.getGlobalPersonnelNum());
    SessionUtils.removeThenSetAttribute("currentPageUrl", url, request);
    List<ValueListElement> titles = this.customerDao.retrieveTitles();
    List<ValueListElement> genders = this.customerDao.retrieveGenders();
    List<ValueListElement> maritalStatuses = this.customerDao.retrieveMaritalStatuses();
    List<ValueListElement> languages = Localization.getInstance().getLocaleForUI();
    List<RoleBO> roles = legacyRolesPermissionsDao.getRoles();
    List<PersonnelLevelEntity> personnelLevels = this.customerDao.retrievePersonnelLevels();
    for (PersonnelLevelEntity personnelLevelEntity : personnelLevels) {
        String messageTextLookup = ApplicationContextProvider.getBean(MessageLookup.class).lookup(personnelLevelEntity.getLookUpValue().getPropertiesKey());
        personnelLevelEntity.setName(messageTextLookup);
    }
    SessionUtils.setCollectionAttribute(PersonnelConstants.TITLE_LIST, titles, request);
    SessionUtils.setCollectionAttribute(PersonnelConstants.PERSONNEL_LEVEL_LIST, personnelLevels, request);
    SessionUtils.setCollectionAttribute(PersonnelConstants.GENDER_LIST, genders, request);
    SessionUtils.setCollectionAttribute(PersonnelConstants.MARITAL_STATUS_LIST, maritalStatuses, request);
    SessionUtils.setCollectionAttribute(PersonnelConstants.LANGUAGE_LIST, languages, request);
    SessionUtils.setCollectionAttribute(PersonnelConstants.ROLES_LIST, roles, request);
    SessionUtils.setCollectionAttribute(PersonnelConstants.ROLEMASTERLIST, roles, request);
    List<CustomFieldDefinitionEntity> customFieldDefs1 = new ArrayList<CustomFieldDefinitionEntity>();
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, customFieldDefs1, request);
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    personActionForm.setCustomFields(customFields);
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : PersonnelInformationDto(org.mifos.dto.screen.PersonnelInformationDto) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) MessageLookup(org.mifos.application.master.MessageLookup) ValueListElement(org.mifos.dto.domain.ValueListElement) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 7 with PersonnelLevelEntity

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

the class FeeServiceFacadeWebTier method listToMap.

private Map<Short, String> listToMap(List<? extends MasterDataEntity> masterDataEntityList) {
    Map<Short, String> idNameMap = new HashMap<Short, String>();
    for (MasterDataEntity masterDataEntity : masterDataEntityList) {
        if (masterDataEntity instanceof PersonnelStatusEntity) {
            String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
            ((PersonnelStatusEntity) masterDataEntity).setName(name);
        }
        if (masterDataEntity instanceof PersonnelLevelEntity) {
            String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
            ((PersonnelLevelEntity) masterDataEntity).setName(name);
        }
        idNameMap.put(masterDataEntity.getId(), masterDataEntity.getName());
    }
    return idNameMap;
}
Also used : HashMap(java.util.HashMap) MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) MessageLookup(org.mifos.application.master.MessageLookup) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) PersonnelStatusEntity(org.mifos.customers.personnel.business.PersonnelStatusEntity)

Example 8 with PersonnelLevelEntity

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

the class CollectionSheetServiceFacadeWebTier method convertToPaymentTypesListItemDto.

private List<ListItem<Short>> convertToPaymentTypesListItemDto(final List<? extends MasterDataEntity> paymentTypesList) {
    List<ListItem<Short>> paymentTypesDtoList = new ArrayList<ListItem<Short>>();
    for (MasterDataEntity paymentType : paymentTypesList) {
        if (paymentType instanceof PersonnelStatusEntity) {
            String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(paymentType.getLookUpValue());
            ((PersonnelStatusEntity) paymentType).setName(name);
        }
        if (paymentType instanceof PersonnelLevelEntity) {
            String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(paymentType.getLookUpValue());
            ((PersonnelLevelEntity) paymentType).setName(name);
        }
        paymentTypesDtoList.add(new ListItem<Short>(paymentType.getId(), paymentType.getName()));
    }
    return paymentTypesDtoList;
}
Also used : MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) MessageLookup(org.mifos.application.master.MessageLookup) ArrayList(java.util.ArrayList) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) PersonnelStatusEntity(org.mifos.customers.personnel.business.PersonnelStatusEntity)

Example 9 with PersonnelLevelEntity

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

the class PersonnelServiceFacadeWebTier method retrieveInfoForNewUserDefinition.

@Override
public DefinePersonnelDto retrieveInfoForNewUserDefinition(Short officeId) {
    String officeName = "";
    if (officeId != null) {
        OfficeBO office = officeDao.findOfficeById(officeId);
        officeName = office.getOfficeName();
    }
    List<ValueListElement> titles = customerDao.retrieveTitles();
    List<ListElement> titleList = new ArrayList<ListElement>();
    for (ValueListElement element : titles) {
        ListElement listElement = new ListElement(element.getId(), element.getName());
        titleList.add(listElement);
    }
    List<PersonnelLevelEntity> personnelLevels = customerDao.retrievePersonnelLevels();
    List<ListElement> personnelLevelList = new ArrayList<ListElement>();
    for (PersonnelLevelEntity level : personnelLevels) {
        String name = level.getLookUpValue().getLookUpName();
        String localisedName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(name);
        ListElement listElement = new ListElement(new Integer(level.getId()), localisedName);
        personnelLevelList.add(listElement);
    }
    List<ValueListElement> genders = customerDao.retrieveGenders();
    List<ListElement> genderList = new ArrayList<ListElement>();
    for (ValueListElement element : genders) {
        ListElement listElement = new ListElement(element.getId(), element.getName());
        genderList.add(listElement);
    }
    List<ValueListElement> maritalStatuses = customerDao.retrieveMaritalStatuses();
    List<ListElement> maritalStatusList = new ArrayList<ListElement>();
    for (ValueListElement element : maritalStatuses) {
        ListElement listElement = new ListElement(element.getId(), element.getName());
        maritalStatusList.add(listElement);
    }
    List<RoleBO> roles = new ArrayList<RoleBO>();
    try {
        roles = rolesPermissionsPersistence.getRoles();
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
    List<ListElement> roleList = new ArrayList<ListElement>();
    for (RoleBO element : roles) {
        ListElement listElement = new ListElement(new Integer(element.getId()), element.getName());
        roleList.add(listElement);
    }
    List<ListElement> languageList = Localization.getInstance().getLocaleList();
    DefinePersonnelDto defineUserDto = new DefinePersonnelDto(officeName, titleList, personnelLevelList, genderList, maritalStatusList, languageList, roleList);
    return defineUserDto;
}
Also used : ArrayList(java.util.ArrayList) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) DefinePersonnelDto(org.mifos.dto.screen.DefinePersonnelDto) OfficeBO(org.mifos.customers.office.business.OfficeBO) MessageLookup(org.mifos.application.master.MessageLookup) ValueListElement(org.mifos.dto.domain.ValueListElement) ListElement(org.mifos.dto.screen.ListElement) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ValueListElement(org.mifos.dto.domain.ValueListElement) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 10 with PersonnelLevelEntity

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

PersonnelLevelEntity (org.mifos.customers.personnel.business.PersonnelLevelEntity)11 MessageLookup (org.mifos.application.master.MessageLookup)7 PersonnelStatusEntity (org.mifos.customers.personnel.business.PersonnelStatusEntity)7 ArrayList (java.util.ArrayList)6 OfficeBO (org.mifos.customers.office.business.OfficeBO)5 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)5 ValueListElement (org.mifos.dto.domain.ValueListElement)5 RoleBO (org.mifos.security.rolesandpermission.business.RoleBO)5 MasterDataEntity (org.mifos.application.master.business.MasterDataEntity)4 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)4 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)3 MifosRuntimeException (org.mifos.core.MifosRuntimeException)3 PersonActionForm (org.mifos.customers.personnel.struts.actionforms.PersonActionForm)3 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)3 PersonnelDetailsEntity (org.mifos.customers.personnel.business.PersonnelDetailsEntity)2 PersonnelRoleEntity (org.mifos.customers.personnel.business.PersonnelRoleEntity)2 AddressDto (org.mifos.dto.domain.AddressDto)2 DefinePersonnelDto (org.mifos.dto.screen.DefinePersonnelDto)2 ListElement (org.mifos.dto.screen.ListElement)2 PersonnelInformationDto (org.mifos.dto.screen.PersonnelInformationDto)2