use of org.mifos.customers.personnel.struts.actionforms.PersonActionForm in project head by mifos.
the class PersonAction method cancel.
@SuppressWarnings("unused")
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward cancel(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
String forward = null;
PersonActionForm actionForm = (PersonActionForm) form;
String fromPage = actionForm.getInput();
if (fromPage.equals(PersonnelConstants.MANAGE_USER) || fromPage.equals(PersonnelConstants.UNLOCK_USER)) {
forward = ActionForwards.cancelEdit_success.toString();
} else {
forward = ActionForwards.cancel_success.toString();
}
return mapping.findForward(forward.toString());
}
use of org.mifos.customers.personnel.struts.actionforms.PersonActionForm 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());
}
use of org.mifos.customers.personnel.struts.actionforms.PersonActionForm 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.customers.personnel.struts.actionforms.PersonActionForm in project head by mifos.
the class PersonAction method preview.
@SuppressWarnings("unchecked")
@TransactionDemarcate(joinToken = true)
public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
PersonActionForm personActionForm = (PersonActionForm) form;
UserContext userContext = getUserContext(request);
personActionForm.setDateOfJoiningBranch(DateUtils.getCurrentDate(userContext.getPreferredLocale()));
PersonActionForm personActionForm1 = (PersonActionForm) form;
boolean addFlag = false;
List<RoleBO> selectList = new ArrayList<RoleBO>();
if (personActionForm1.getPersonnelRoles() != null) {
List<RoleBO> masterList = (List<RoleBO>) SessionUtils.getAttribute(PersonnelConstants.ROLEMASTERLIST, request);
for (RoleBO role : masterList) {
for (String roleId : personActionForm1.getPersonnelRoles()) {
if (roleId != null && role.getId().intValue() == Integer.valueOf(roleId).intValue()) {
selectList.add(role);
addFlag = true;
}
}
}
}
if (addFlag) {
SessionUtils.setCollectionAttribute(PersonnelConstants.PERSONNEL_ROLES_LIST, selectList, request);
} else {
SessionUtils.setAttribute(PersonnelConstants.PERSONNEL_ROLES_LIST, null, request);
}
return createGroupQuestionnaire.fetchAppliedQuestions(mapping, personActionForm, request, ActionForwards.preview_success);
}
use of org.mifos.customers.personnel.struts.actionforms.PersonActionForm in project head by mifos.
the class PersonAction method update.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
PersonActionForm actionForm = (PersonActionForm) form;
try {
CreateOrUpdatePersonnelInformation perosonnelInfo = translateFormToCreatePersonnelInformationDto(request, actionForm);
UserDetailDto userDetails = this.personnelServiceFacade.updatePersonnel(perosonnelInfo);
String globalPersonnelNum = userDetails.getSystemId();
Name name = new Name(actionForm.getFirstName(), actionForm.getMiddleName(), actionForm.getSecondLastName(), actionForm.getLastName());
request.setAttribute("displayName", name.getDisplayName());
request.setAttribute("globalPersonnelNum", globalPersonnelNum);
//refresh user context roles if active
Set<Short> roles = new HashSet<Short>();
for (ListElement userNewRole : perosonnelInfo.getRoles()) {
roles.add(userNewRole.getId().shortValue());
}
refreshUserContextIfActive(request, perosonnelInfo.getId(), perosonnelInfo.getUserName(), roles);
return mapping.findForward(ActionForwards.update_success.toString());
} catch (BusinessRuleException e) {
throw new PersonnelException(e.getMessageKey(), e.getMessageValues());
}
}
Aggregations