Search in sources :

Example 1 with PersonnelException

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());
    }
}
Also used : PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) BusinessRuleException(org.mifos.service.BusinessRuleException) CreateOrUpdatePersonnelInformation(org.mifos.dto.domain.CreateOrUpdatePersonnelInformation) UserDetailDto(org.mifos.dto.domain.UserDetailDto) PersonnelException(org.mifos.customers.personnel.exceptions.PersonnelException) Name(org.mifos.framework.business.util.Name) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with PersonnelException

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());
    }
}
Also used : PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) BusinessRuleException(org.mifos.service.BusinessRuleException) CreateOrUpdatePersonnelInformation(org.mifos.dto.domain.CreateOrUpdatePersonnelInformation) UserDetailDto(org.mifos.dto.domain.UserDetailDto) ValueListElement(org.mifos.dto.domain.ValueListElement) ListElement(org.mifos.dto.screen.ListElement) PersonnelException(org.mifos.customers.personnel.exceptions.PersonnelException) Name(org.mifos.framework.business.util.Name) HashSet(java.util.HashSet) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

PersonnelException (org.mifos.customers.personnel.exceptions.PersonnelException)2 PersonActionForm (org.mifos.customers.personnel.struts.actionforms.PersonActionForm)2 CreateOrUpdatePersonnelInformation (org.mifos.dto.domain.CreateOrUpdatePersonnelInformation)2 UserDetailDto (org.mifos.dto.domain.UserDetailDto)2 Name (org.mifos.framework.business.util.Name)2 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 HashSet (java.util.HashSet)1 ValueListElement (org.mifos.dto.domain.ValueListElement)1 ListElement (org.mifos.dto.screen.ListElement)1 CloseSession (org.mifos.framework.util.helpers.CloseSession)1