Search in sources :

Example 1 with PersonnelDetailsEntity

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

the class PersonnelServiceFacadeWebTier method getPersonnelInformationDto.

@Override
public PersonnelInformationDto getPersonnelInformationDto(final Long userId, final String globalNumber) {
    PersonnelBO personnel = null;
    if (userId != null) {
        personnel = personnelDao.findPersonnelById(userId.shortValue());
    } else {
        personnel = personnelDao.findByGlobalPersonnelNum(globalNumber);
    }
    if (personnel == null) {
        throw new MifosRuntimeException("personnel not found for id" + userId);
    }
    String displayName = personnel.getDisplayName();
    PersonnelStatusEntity personnelStatus = personnel.getStatus();
    String statusName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(personnelStatus.getLookUpValue());
    ListElement status = new ListElement(new Integer(personnelStatus.getId()), statusName);
    boolean locked = personnel.isLocked();
    PersonnelDetailsEntity personnelDetailsEntity = personnel.getPersonnelDetails();
    Address address = personnelDetailsEntity.getAddress();
    AddressDto addressDto = new AddressDto(address.getLine1(), address.getLine2(), address.getLine3(), address.getCity(), address.getState(), address.getCountry(), address.getZip(), address.getPhoneNumber());
    Name name = personnelDetailsEntity.getName();
    PersonnelDetailsDto personnelDetails = new PersonnelDetailsDto(personnelDetailsEntity.getGovernmentIdNumber(), new DateTime(personnelDetailsEntity.getDob()).toDateMidnight().toDateTime(), personnelDetailsEntity.getMaritalStatus(), personnelDetailsEntity.getGender(), new DateTime(personnelDetailsEntity.getDateOfJoiningMFI()).toDateMidnight().toDateTime(), new DateTime(personnelDetailsEntity.getDateOfJoiningBranch()).toDateMidnight().toDateTime(), new DateTime(personnelDetailsEntity.getDateOfLeavingBranch()).toDateMidnight().toDateTime(), addressDto, name.getFirstName(), name.getMiddleName(), name.getSecondLastName(), name.getLastName(), new DateTime(personnelDetailsEntity.getPersonnel().getPasswordExpirationDate()).toDateMidnight().toDateTime());
    String emailId = personnel.getEmailId();
    Short preferredLocale = personnel.getPreferredLocale();
    String languageName = Localization.getInstance().getDisplayName(preferredLocale);
    if (preferredLocale != null) {
        languageName = Localization.getInstance().getDisplayName(preferredLocale);
    }
    PersonnelLevelEntity level = personnel.getLevel();
    OfficeBO office = personnel.getOffice();
    Integer title = personnel.getTitle();
    Set<PersonnelRoleEntity> personnelRoleEntities = personnel.getPersonnelRoles();
    Set<ListElement> personnelRoles = new LinkedHashSet<ListElement>();
    for (PersonnelRoleEntity entity : personnelRoleEntities) {
        ListElement element = new ListElement(entity.getRole().getId().intValue(), entity.getRole().getName());
        personnelRoles.add(element);
    }
    Short personnelId = personnel.getPersonnelId();
    String userName = personnel.getUserName();
    Set<PersonnelCustomFieldEntity> personnelCustomFields = personnel.getCustomFields();
    Set<CustomFieldDto> customFields = new LinkedHashSet<CustomFieldDto>();
    for (PersonnelCustomFieldEntity fieldDef : personnelCustomFields) {
        customFields.add(new CustomFieldDto(fieldDef.getFieldId(), fieldDef.getFieldValue()));
    }
    Set<PersonnelNotesEntity> personnelNotesEntity = personnel.getPersonnelNotes();
    Set<PersonnelNoteDto> personnelNotes = new LinkedHashSet<PersonnelNoteDto>();
    for (PersonnelNotesEntity entity : personnelNotesEntity) {
        personnelNotes.add(new PersonnelNoteDto(new DateTime(entity.getCommentDate()), entity.getComment(), entity.getPersonnelName()));
    }
    return new PersonnelInformationDto(personnel.getPersonnelId().intValue(), personnel.getGlobalPersonnelNum(), displayName, status, locked, personnelDetails, emailId, languageName, preferredLocale.intValue(), level.getId(), office.getOfficeId().intValue(), office.getOfficeName(), title, personnelRoles, personnelId, userName, customFields, personnelNotes, personnel.getPasswordExpirationDate());
}
Also used : PersonnelDetailsEntity(org.mifos.customers.personnel.business.PersonnelDetailsEntity) LinkedHashSet(java.util.LinkedHashSet) PersonnelInformationDto(org.mifos.dto.screen.PersonnelInformationDto) Address(org.mifos.framework.business.util.Address) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) DateTime(org.joda.time.DateTime) PersonnelStatusEntity(org.mifos.customers.personnel.business.PersonnelStatusEntity) Name(org.mifos.framework.business.util.Name) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelRoleEntity(org.mifos.customers.personnel.business.PersonnelRoleEntity) MessageLookup(org.mifos.application.master.MessageLookup) PersonnelCustomFieldEntity(org.mifos.customers.personnel.business.PersonnelCustomFieldEntity) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) AddressDto(org.mifos.dto.domain.AddressDto) PersonnelNoteDto(org.mifos.dto.screen.PersonnelNoteDto) PersonnelNotesEntity(org.mifos.customers.personnel.business.PersonnelNotesEntity) ValueListElement(org.mifos.dto.domain.ValueListElement) ListElement(org.mifos.dto.screen.ListElement) PersonnelDetailsDto(org.mifos.dto.screen.PersonnelDetailsDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with PersonnelDetailsEntity

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

the class PersonAction method manage.

@TransactionDemarcate(joinToken = true)
public ActionForward manage(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    PersonActionForm actionform = (PersonActionForm) form;
    actionform.clear();
    PersonnelBO personnelInSession = (PersonnelBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    PersonnelBO personnel = this.personnelDao.findPersonnelById(personnelInSession.getPersonnelId());
    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> customFieldDefs = new ArrayList<CustomFieldDefinitionEntity>();
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, customFieldDefs, request);
    UserContext userContext = getUserContext(request);
    List<PersonnelStatusEntity> statuses = legacyMasterDao.findMasterDataEntitiesWithLocale(PersonnelStatusEntity.class);
    for (PersonnelStatusEntity personnelStatusEntity : statuses) {
        String messageTextLookup = ApplicationContextProvider.getBean(MessageLookup.class).lookup(personnelStatusEntity.getLookUpValue().getPropertiesKey());
        personnelStatusEntity.setName(messageTextLookup);
    }
    SessionUtils.setCollectionAttribute(PersonnelConstants.STATUS_LIST, statuses, request);
    OfficeBO loggedInOffice = this.officeDao.findOfficeById(userContext.getBranchId());
    List<OfficeDetailsDto> officeHierarchy = new OfficePersistence().getChildOffices(loggedInOffice.getSearchId());
    SessionUtils.setCollectionAttribute(PersonnelConstants.OFFICE_LIST, officeHierarchy, request);
    actionform.setPersonnelId(personnel.getPersonnelId().toString());
    if (personnel.getOffice() != null) {
        actionform.setOfficeId(personnel.getOffice().getOfficeId().toString());
    }
    if (personnel.getTitle() != null) {
        actionform.setTitle(personnel.getTitle().toString());
    }
    if (personnel.getLevel() != null) {
        actionform.setLevel(personnel.getLevelEnum().getValue().toString());
    }
    if (personnel.getStatus() != null) {
        actionform.setStatus(personnel.getStatus().getId().toString());
    }
    actionform.setLoginName(personnel.getUserName());
    actionform.setGlobalPersonnelNum(personnel.getGlobalPersonnelNum());
    actionform.setCustomFields(new ArrayList<CustomFieldDto>());
    if (personnel.getPersonnelDetails() != null) {
        PersonnelDetailsEntity personnelDetails = personnel.getPersonnelDetails();
        actionform.setFirstName(personnelDetails.getName().getFirstName());
        actionform.setMiddleName(personnelDetails.getName().getMiddleName());
        actionform.setSecondLastName(personnelDetails.getName().getSecondLastName());
        actionform.setLastName(personnelDetails.getName().getLastName());
        if (personnelDetails.getGender() != null) {
            actionform.setGender(personnelDetails.getGender().toString());
        }
        if (personnelDetails.getMaritalStatus() != null) {
            actionform.setMaritalStatus(personnelDetails.getMaritalStatus().toString());
        }
        actionform.setAddress(personnelDetails.getAddress());
        if (personnelDetails.getDateOfJoiningMFI() != null) {
            actionform.setDateOfJoiningMFI(DateUtils.makeDateAsSentFromBrowser(personnelDetails.getDateOfJoiningMFI()));
        }
        if (personnelDetails.getDob() != null) {
            actionform.setDob(DateUtils.makeDateAsSentFromBrowser(personnelDetails.getDob()));
        }
    }
    actionform.setEmailId(personnel.getEmailId());
    if (personnel.getPreferredLocale() != null) {
        actionform.setPreferredLocale(personnel.getPreferredLocale());
    }
    if (personnel.getPasswordExpirationDate() != null) {
        actionform.setPasswordExpirationDate(DateUtils.makeDateAsSentFromBrowser(personnel.getPasswordExpirationDate()));
    }
    List<RoleBO> selectList = new ArrayList<RoleBO>();
    for (PersonnelRoleEntity personnelRole : personnel.getPersonnelRoles()) {
        selectList.add(personnelRole.getRole());
    }
    SessionUtils.setCollectionAttribute(PersonnelConstants.PERSONNEL_ROLES_LIST, selectList, request);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, personnel, request);
    return mapping.findForward(ActionForwards.manage_success.toString());
}
Also used : PersonnelDetailsEntity(org.mifos.customers.personnel.business.PersonnelDetailsEntity) UserContext(org.mifos.security.util.UserContext) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) PersonnelStatusEntity(org.mifos.customers.personnel.business.PersonnelStatusEntity) PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelRoleEntity(org.mifos.customers.personnel.business.PersonnelRoleEntity) MessageLookup(org.mifos.application.master.MessageLookup) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) ValueListElement(org.mifos.dto.domain.ValueListElement) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

MessageLookup (org.mifos.application.master.MessageLookup)2 OfficeBO (org.mifos.customers.office.business.OfficeBO)2 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 PersonnelDetailsEntity (org.mifos.customers.personnel.business.PersonnelDetailsEntity)2 PersonnelLevelEntity (org.mifos.customers.personnel.business.PersonnelLevelEntity)2 PersonnelRoleEntity (org.mifos.customers.personnel.business.PersonnelRoleEntity)2 PersonnelStatusEntity (org.mifos.customers.personnel.business.PersonnelStatusEntity)2 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)2 ValueListElement (org.mifos.dto.domain.ValueListElement)2 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 DateTime (org.joda.time.DateTime)1 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)1 PersonnelCustomFieldEntity (org.mifos.customers.personnel.business.PersonnelCustomFieldEntity)1 PersonnelNotesEntity (org.mifos.customers.personnel.business.PersonnelNotesEntity)1 PersonActionForm (org.mifos.customers.personnel.struts.actionforms.PersonActionForm)1 AddressDto (org.mifos.dto.domain.AddressDto)1 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)1