use of org.mifos.customers.personnel.exceptions.PersonnelException in project head by mifos.
the class PersonAction method create.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
PersonActionForm personActionForm = (PersonActionForm) form;
CreateOrUpdatePersonnelInformation perosonnelInfo = translateFormToCreatePersonnelInformationDto(request, personActionForm);
try {
UserDetailDto userDetails = this.personnelServiceFacade.createPersonnelInformation(perosonnelInfo);
String globalPersonnelNum = userDetails.getSystemId();
Name name = new Name(personActionForm.getFirstName(), personActionForm.getMiddleName(), personActionForm.getSecondLastName(), personActionForm.getLastName());
request.setAttribute("displayName", name.getDisplayName());
request.setAttribute("globalPersonnelNum", globalPersonnelNum);
createGroupQuestionnaire.saveResponses(request, personActionForm, userDetails.getId());
return mapping.findForward(ActionForwards.create_success.toString());
} catch (BusinessRuleException e) {
throw new PersonnelException(e.getMessageKey(), e, e.getMessageValues());
}
}
use of org.mifos.customers.personnel.exceptions.PersonnelException 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