use of org.mifos.framework.util.helpers.CloseSession 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());
}
}
use of org.mifos.framework.util.helpers.CloseSession in project head by mifos.
the class ClientTransferAction method transferToBranch.
@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward transferToBranch(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
ClientTransferActionForm actionForm = (ClientTransferActionForm) form;
ClientBO clientInSession = (ClientBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
String globalCustNum = this.clientServiceFacade.transferClientToBranch(clientInSession.getGlobalCustNum(), actionForm.getOfficeIdValue());
ClientBO client = this.customerDao.findClientBySystemId(globalCustNum);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, client, request);
return mapping.findForward(ActionForwards.update_success.toString());
}
use of org.mifos.framework.util.helpers.CloseSession in project head by mifos.
the class CustHistoricalDataAction method updateHistoricalData.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updateHistoricalData(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
CustomerBO customerBOInSession = (CustomerBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
CustomerBO customerBO = this.customerDao.findCustomerById(customerBOInSession.getCustomerId());
checkVersionMismatch(customerBOInSession.getVersionNo(), customerBO.getVersionNo());
customerBO.setUserContext(getUserContext(request));
CustHistoricalDataActionForm historicalActionForm = (CustHistoricalDataActionForm) form;
CustomerHistoricalDataUpdateRequest historicalData = createHistoricalDataUpdateRequest(historicalActionForm, getUserContext(request));
this.groupServiceFacade.updateCustomerHistoricalData(customerBO.getGlobalCustNum(), historicalData);
return mapping.findForward(ActionForwards.updateHistoricalData_success.toString());
}
use of org.mifos.framework.util.helpers.CloseSession in project head by mifos.
the class PictureFormFile method updateMfiInfo.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updateMfiInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
ClientCustActionForm actionForm = (ClientCustActionForm) form;
ClientBO clientInSession = getClientFromSession(request);
Integer clientId = clientInSession.getCustomerId();
Integer oldVersionNumber = clientInSession.getVersionNo();
boolean trained = false;
if (trainedValue(actionForm) != null && trainedValue(actionForm).equals(YesNoFlag.YES.getValue())) {
trained = true;
}
DateTime trainedDate = null;
try {
java.sql.Date inputDate = trainedDate(actionForm);
if (inputDate != null) {
trainedDate = new DateTime(trainedDate(actionForm));
}
} catch (InvalidDateException e) {
throw new CustomerException(ClientConstants.TRAINED_DATE_MANDATORY);
}
Short personnelId = Short.valueOf("-1");
if (groupFlagValue(actionForm).equals(YesNoFlag.NO.getValue())) {
if (actionForm.getLoanOfficerIdValue() != null) {
personnelId = actionForm.getLoanOfficerIdValue();
}
} else if (groupFlagValue(actionForm).equals(YesNoFlag.YES.getValue())) {
// TODO for an urgent fix this reads client to get personnelId.
// Client is read again in updateClientMfiInfo. Refactor to only read in
// updateClientMfiInfo.
ClientBO client = (ClientBO) this.customerDao.findCustomerById(clientId);
personnelId = client.getPersonnel().getPersonnelId();
}
ClientMfiInfoUpdate clientMfiInfoUpdate = new ClientMfiInfoUpdate(clientId, oldVersionNumber, personnelId, externalId(actionForm), trained, trainedDate);
this.clientServiceFacade.updateClientMfiInfo(clientMfiInfoUpdate);
return mapping.findForward(ActionForwards.updateMfiInfo_success.toString());
}
use of org.mifos.framework.util.helpers.CloseSession in project head by mifos.
the class GroupTransferAction method transferToCenter.
@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward transferToCenter(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
GroupTransferActionForm actionForm = (GroupTransferActionForm) form;
GroupBO groupInSession = (GroupBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
CustomerDetailDto groupDetail = this.groupServiceFacade.transferGroupToCenter(groupInSession.getGlobalCustNum(), actionForm.getCenterSystemId(), groupInSession.getVersionNo());
GroupBO group = this.customerDao.findGroupBySystemId(groupDetail.getGlobalCustNum());
SessionUtils.setAttribute(Constants.BUSINESS_KEY, group, request);
return mapping.findForward(ActionForwards.update_success.toString());
}
Aggregations