예제 #1
0
  @Override
  public void createCustomerNote(CustomerNoteFormDto customerNoteForm) {

    MifosUser user =
        (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);

    CustomerBO customer = this.customerDao.findCustomerBySystemId(customerNoteForm.getGlobalNum());
    customer.updateDetails(userContext);

    PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());

    CustomerNoteEntity customerNote =
        new CustomerNoteEntity(
            customerNoteForm.getComment(),
            new DateTimeService().getCurrentJavaSqlDate(),
            loggedInUser,
            customer);
    customer.addCustomerNotes(customerNote);

    try {
      this.transactionHelper.startTransaction();
      this.customerDao.save(customer);
      this.transactionHelper.commitTransaction();
    } catch (Exception e) {
      this.transactionHelper.rollbackTransaction();
      throw new BusinessRuleException(customer.getCustomerAccount().getAccountId().toString(), e);
    } finally {
      this.transactionHelper.closeSession();
    }
  }
예제 #2
0
 @CloseSession
 @TransactionDemarcate(validateAndResetToken = true)
 public ActionForward create(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   logger.debug("In CustomerNotesAction::create()");
   ActionForward forward = null;
   CustomerNotesActionForm notesActionForm = (CustomerNotesActionForm) form;
   CustomerBO customerBO =
       getCustomerBusinessService()
           .getCustomer(Integer.valueOf(((CustomerNotesActionForm) form).getCustomerId()));
   UserContext uc = getUserContext(request);
   if (customerBO.getPersonnel() != null) {
     checkPermissionForAddingNotes(
         AccountTypes.CUSTOMER_ACCOUNT,
         customerBO.getLevel(),
         uc,
         customerBO.getOffice().getOfficeId(),
         customerBO.getPersonnel().getPersonnelId());
   } else {
     checkPermissionForAddingNotes(
         AccountTypes.CUSTOMER_ACCOUNT,
         customerBO.getLevel(),
         uc,
         customerBO.getOffice().getOfficeId(),
         uc.getId());
   }
   PersonnelBO personnelBO = new PersonnelPersistence().getPersonnel(uc.getId());
   CustomerNoteEntity customerNote =
       new CustomerNoteEntity(
           notesActionForm.getComment(),
           new DateTimeService().getCurrentJavaSqlDate(),
           personnelBO,
           customerBO);
   customerBO.addCustomerNotes(customerNote);
   customerBO.setUserContext(uc);
   customerBO.update();
   forward = mapping.findForward(getDetailCustomerPage(notesActionForm));
   customerBO = null;
   return forward;
 }