Search in sources :

Example 1 with PersonnelInformationDto

use of org.mifos.dto.screen.PersonnelInformationDto 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 PersonnelInformationDto

use of org.mifos.dto.screen.PersonnelInformationDto in project head by mifos.

the class ApprovalController method details.

@RequestMapping("restApproval/id-{id}/details.ftl")
public ModelAndView details(@PathVariable Long id) {
    ModelAndView mav = new ModelAndView("approval/details");
    mav.addObject("waitingForApprovalList", approvalService.getAllWaiting());
    RESTApprovalEntity approval = approvalService.getDetails(id);
    mav.addObject("approval", approval);
    PersonnelInformationDto p = personnelServiceFacade.getPersonnelInformationDto(approval.getCreatedBy().longValue(), null);
    mav.addObject("createdBy", p.getDisplayName());
    if (!approval.getState().equals(ApprovalState.WAITING)) {
        p = personnelServiceFacade.getPersonnelInformationDto(approval.getApprovedBy().longValue(), null);
        mav.addObject("approvedBy", p.getDisplayName());
    }
    return mav;
}
Also used : PersonnelInformationDto(org.mifos.dto.screen.PersonnelInformationDto) RESTApprovalEntity(org.mifos.rest.approval.domain.RESTApprovalEntity) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with PersonnelInformationDto

use of org.mifos.dto.screen.PersonnelInformationDto in project head by mifos.

the class PersonActionStrutsTest method testLoadChangeLog.

@SuppressWarnings("unchecked")
@Test
public void testLoadChangeLog() throws Exception {
    addActionAndMethod(Methods.get.toString());
    addRequestParameter("globalPersonnelNum", "1");
    actionPerform();
    flowKey = request.getAttribute(Constants.CURRENTFLOWKEY).toString();
    // personnel = (PersonnelBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    // Changed the PersonnelBO to PersonnelInformationDto as the former is no longer stored in session using
    // business key
    PersonnelInformationDto personnel = (PersonnelInformationDto) SessionUtils.getAttribute("personnelInformationDto", request);
    AuditLog auditLog = new AuditLog(personnel.getPersonnelId().intValue(), EntityType.PERSONNEL.getValue(), "Mifos", new java.sql.Date(System.currentTimeMillis()), Short.valueOf("3"));
    Set<AuditLogRecord> auditLogRecords = new HashSet<AuditLogRecord>();
    AuditLogRecord auditLogRecord = new AuditLogRecord("ColumnName_1", "test_1", "new_test_1", auditLog);
    auditLogRecords.add(auditLogRecord);
    auditLog.addAuditLogRecords(auditLogRecords);
    legacyAuditDao.save(auditLog);
    setRequestPathInfo("/PersonAction.do");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter("method", "loadChangeLog");
    addRequestParameter("entityType", "Personnel");
    addRequestParameter("entityId", personnel.getPersonnelId().toString());
    actionPerform();
    Assert.assertEquals(1, ((List) request.getSession().getAttribute(AuditConstants.AUDITLOGRECORDS)).size());
    verifyForward("viewPersonnelChangeLog");
    personnel = null;
}
Also used : PersonnelInformationDto(org.mifos.dto.screen.PersonnelInformationDto) AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) AuditLog(org.mifos.framework.components.audit.business.AuditLog) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with PersonnelInformationDto

use of org.mifos.dto.screen.PersonnelInformationDto 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 5 with PersonnelInformationDto

use of org.mifos.dto.screen.PersonnelInformationDto in project head by mifos.

the class SystemUserController method createPopulatedUserFormBean.

public UserFormBean createPopulatedUserFormBean(final Long userId, final UserFormBean formBean) {
    PersonnelInformationDto personnelInformation = this.personnelServiceFacade.getPersonnelInformationDto(userId, "");
    UserFormBean populatedBean = createUserFormBean(personnelInformation.getOfficeId().longValue(), formBean);
    populatedBean.setUserId(userId);
    populatedBean.setStatusId(personnelInformation.getStatus().getId());
    populatedBean.setDisplayName(personnelInformation.getDisplayName());
    PersonnelDetailsDto details = personnelInformation.getPersonnelDetails();
    populatedBean.setFirstName(details.getFirstName());
    populatedBean.setMiddleName(details.getMiddleName());
    populatedBean.setSecondLastName(details.getSecondLastName());
    populatedBean.setLastName(details.getLastName());
    populatedBean.setGovernmentId(details.getGovernmentIdNumber());
    populatedBean.setEmail(personnelInformation.getEmailId());
    populatedBean.setDateOfBirthDay(details.getDob().getDayOfMonth());
    populatedBean.setDateOfBirthMonth(details.getDob().getMonthOfYear());
    populatedBean.setDateOfBirthYear(details.getDob().getYearOfEra());
    if (details.getDateOfJoiningMFI() != null) {
        populatedBean.setDateOfBirthDay(details.getPasswordExpirationDate().getDayOfMonth());
        populatedBean.setDateOfBirthMonth(details.getPasswordExpirationDate().getMonthOfYear());
        populatedBean.setDateOfBirthYear(details.getPasswordExpirationDate().getYearOfEra());
    }
    if (details.getDateOfJoiningMFI() != null) {
        populatedBean.setMfiJoiningDateDay(details.getDateOfJoiningMFI().getDayOfMonth());
        populatedBean.setMfiJoiningDateMonth(details.getDateOfJoiningMFI().getMonthOfYear());
        populatedBean.setMfiJoiningDateYear(details.getDateOfJoiningMFI().getYearOfEra());
    }
    populatedBean.setSelectedGender(details.getGender().toString());
    if (details.getMaritalStatus() != null) {
        populatedBean.setSelectedMaritalStatus(details.getMaritalStatus().toString());
    }
    if (personnelInformation.getPreferredLanguageId() != null) {
        populatedBean.setSelectedPreferredLanguage(personnelInformation.getPreferredLanguageId().toString());
    }
    AddressDto address = details.getAddress();
    AddressBean bean = populatedBean.getAddress();
    bean.setAddress1(address.getLine1());
    bean.setAddress2(address.getLine2());
    bean.setAddress3(address.getLine3());
    bean.setCityDistrict(address.getCity());
    bean.setState(address.getState());
    bean.setCountry(address.getCountry());
    bean.setPostalCode(address.getZip());
    bean.setTelephoneNumber(address.getPhoneNumber());
    populatedBean.setAddress(bean);
    if (personnelInformation.getTitle() != null) {
        populatedBean.setSelectedUserTitle(personnelInformation.getTitle().toString());
    }
    populatedBean.setSelectedUserHierarchy(personnelInformation.getLevelId().toString());
    Set<ListElement> roles = personnelInformation.getPersonnelRoles();
    String[] selectedRoles = new String[roles.size()];
    int roleIndex = 0;
    for (ListElement listElement : roles) {
        selectedRoles[roleIndex] = listElement.getId().toString();
        roleIndex++;
    }
    populatedBean.setSelectedRoles(selectedRoles);
    populatedBean.setUsername(personnelInformation.getUserName());
    List<CustomFieldDto> currentBeanFields = new ArrayList<CustomFieldDto>();
    List<CustomFieldDto> defaultBeanFields = populatedBean.getCustomFields();
    for (CustomFieldDto customFieldDto : defaultBeanFields) {
        CustomFieldDto matchingField = findMatchingAndSetFieldValue(customFieldDto, personnelInformation.getCustomFields());
        if (matchingField != null) {
            currentBeanFields.add(matchingField);
        }
    }
    populatedBean.setRecentNotes(personnelInformation.getRecentPersonnelNotes());
    populatedBean.setCustomFields(currentBeanFields);
    populatedBean.prepareForPreview();
    populatedBean.prepateForReEdit();
    return populatedBean;
}
Also used : PersonnelInformationDto(org.mifos.dto.screen.PersonnelInformationDto) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) AddressDto(org.mifos.dto.domain.AddressDto) ListElement(org.mifos.dto.screen.ListElement) PersonnelDetailsDto(org.mifos.dto.screen.PersonnelDetailsDto)

Aggregations

PersonnelInformationDto (org.mifos.dto.screen.PersonnelInformationDto)5 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)3 ArrayList (java.util.ArrayList)2 MessageLookup (org.mifos.application.master.MessageLookup)2 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 PersonnelLevelEntity (org.mifos.customers.personnel.business.PersonnelLevelEntity)2 AddressDto (org.mifos.dto.domain.AddressDto)2 ValueListElement (org.mifos.dto.domain.ValueListElement)2 ListElement (org.mifos.dto.screen.ListElement)2 PersonnelDetailsDto (org.mifos.dto.screen.PersonnelDetailsDto)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 OfficeBO (org.mifos.customers.office.business.OfficeBO)1 PersonnelCustomFieldEntity (org.mifos.customers.personnel.business.PersonnelCustomFieldEntity)1 PersonnelDetailsEntity (org.mifos.customers.personnel.business.PersonnelDetailsEntity)1 PersonnelNotesEntity (org.mifos.customers.personnel.business.PersonnelNotesEntity)1