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());
}
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;
}
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;
}
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;
}
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();
}
}
Aggregations