Search in sources :

Example 1 with PersonnelCustomFieldEntity

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

Aggregations

LinkedHashSet (java.util.LinkedHashSet)1 DateTime (org.joda.time.DateTime)1 MessageLookup (org.mifos.application.master.MessageLookup)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 OfficeBO (org.mifos.customers.office.business.OfficeBO)1 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)1 PersonnelCustomFieldEntity (org.mifos.customers.personnel.business.PersonnelCustomFieldEntity)1 PersonnelDetailsEntity (org.mifos.customers.personnel.business.PersonnelDetailsEntity)1 PersonnelLevelEntity (org.mifos.customers.personnel.business.PersonnelLevelEntity)1 PersonnelNotesEntity (org.mifos.customers.personnel.business.PersonnelNotesEntity)1 PersonnelRoleEntity (org.mifos.customers.personnel.business.PersonnelRoleEntity)1 PersonnelStatusEntity (org.mifos.customers.personnel.business.PersonnelStatusEntity)1 AddressDto (org.mifos.dto.domain.AddressDto)1 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)1 ValueListElement (org.mifos.dto.domain.ValueListElement)1 ListElement (org.mifos.dto.screen.ListElement)1 PersonnelDetailsDto (org.mifos.dto.screen.PersonnelDetailsDto)1 PersonnelInformationDto (org.mifos.dto.screen.PersonnelInformationDto)1 PersonnelNoteDto (org.mifos.dto.screen.PersonnelNoteDto)1 Address (org.mifos.framework.business.util.Address)1