use of org.mifos.dto.screen.DefinePersonnelDto in project head by mifos.
the class SystemUserController method createUserFormBean.
public UserFormBean createUserFormBean(final Long officeId, final UserFormBean formBean) {
OfficeDto selectedOffice = this.officeServiceFacade.retrieveOfficeById(officeId.shortValue());
formBean.setOfficeId(officeId);
formBean.setOfficeName(selectedOffice.getName());
MandatoryHiddenFieldsDto dtoFields = this.adminServiceFacade.retrieveHiddenMandatoryFields();
formBean.getAddress().setAddress1Mandatory(dtoFields.isMandatorySystemAddress1());
formBean.getAddress().setAddress2Hidden(dtoFields.isHideSystemAddress2());
formBean.getAddress().setAddress3Hidden(dtoFields.isHideSystemAddress3());
formBean.getAddress().setCityDistrictHidden(dtoFields.isHideSystemCity());
formBean.getAddress().setStateHidden(dtoFields.isHideSystemState());
formBean.getAddress().setCountryHidden(dtoFields.isHideSystemCountry());
formBean.getAddress().setPostalCodeHidden(dtoFields.isHideSystemPostalCode());
DefinePersonnelDto userRefData = this.personnelServiceFacade.retrieveInfoForNewUserDefinition(officeId.shortValue());
Map<String, String> genderOptions = new LinkedHashMap<String, String>();
for (ListElement option : userRefData.getGenderList()) {
genderOptions.put(option.getId().toString(), option.getName());
}
formBean.setGenderOptions(genderOptions);
Map<String, String> maritalStatusOptions = new LinkedHashMap<String, String>();
for (ListElement option : userRefData.getMaritalStatusList()) {
maritalStatusOptions.put(option.getId().toString(), option.getName());
}
formBean.setMaritalStatusOptions(maritalStatusOptions);
Map<String, String> preferredLanguageOptions = new LinkedHashMap<String, String>();
for (ListElement option : userRefData.getLanguageList()) {
preferredLanguageOptions.put(option.getId().toString(), option.getName());
}
formBean.setPreferredLanguageOptions(preferredLanguageOptions);
Map<String, String> userTitleOptions = new LinkedHashMap<String, String>();
for (ListElement option : userRefData.getTitleList()) {
userTitleOptions.put(option.getId().toString(), option.getName());
}
formBean.setUserTitleOptions(userTitleOptions);
Map<String, String> userHierarchyOptions = new LinkedHashMap<String, String>();
for (ListElement option : userRefData.getPersonnelLevelList()) {
userHierarchyOptions.put(option.getId().toString(), option.getName());
}
formBean.setUserHierarchyOptions(userHierarchyOptions);
Map<String, String> availableRolesOptions = new LinkedHashMap<String, String>();
for (ListElement option : userRefData.getRolesList()) {
availableRolesOptions.put(option.getId().toString(), option.getName());
}
formBean.setAvailableRolesOptions(availableRolesOptions);
formBean.setSelectedRolesOptions(new LinkedHashMap<String, String>());
DateTime today = new DateTime();
formBean.setMfiJoiningDateDay(today.getDayOfMonth());
formBean.setMfiJoiningDateMonth(today.getMonthOfYear());
formBean.setMfiJoiningDateYear(today.getYearOfEra());
return formBean;
}
use of org.mifos.dto.screen.DefinePersonnelDto in project head by mifos.
the class PersonAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
PersonActionForm personActionForm = (PersonActionForm) form;
Short officeId = getShortValue(personActionForm.getOfficeId());
OfficeBO office = this.officeDao.findOfficeById(officeId);
SessionUtils.setAttribute(PersonnelConstants.OFFICE, office, request);
personActionForm.clear();
//Shahid - keeping the previous session objects for the sake of existing tests, once fully converted to spring
//then we can get rid of the session objects made redundant by the dto
DefinePersonnelDto definePersonnelDto = this.personnelServiceFacade.retrieveInfoForNewUserDefinition(officeId);
SessionUtils.setAttribute("definePersonnelDto", definePersonnelDto, 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();
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);
if (office.getOfficeLevel() != OfficeLevel.BRANCHOFFICE) {
for (MasterDataEntity level : personnelLevels) {
if (level.getId().equals(PersonnelLevel.LOAN_OFFICER.getValue())) {
personnelLevels.remove(level);
break;
}
}
}
personActionForm.setCustomFields(new ArrayList<CustomFieldDto>());
personActionForm.setDateOfJoiningMFI(DateUtils.makeDateAsSentFromBrowser());
return mapping.findForward(ActionForwards.load_success.toString());
}
use of org.mifos.dto.screen.DefinePersonnelDto 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;
}
use of org.mifos.dto.screen.DefinePersonnelDto in project head by mifos.
the class PersonnelServiceFacadeWebTierTest method shouldRetrieveOfficeName.
@Test
public void shouldRetrieveOfficeName() {
// setup
Short officeId = Short.valueOf("3");
OfficeBO office = new OfficeBuilder().withName("officeTestName").build();
when(officeDao.findOfficeById(officeId)).thenReturn(office);
// exercise test
DefinePersonnelDto personnelDto = this.personnelServiceFacade.retrieveInfoForNewUserDefinition(officeId);
// verification
assertThat(personnelDto.getOfficeName(), is("officeTestName"));
}
Aggregations