コード例 #1
0
  @Override
  // @Transactional
  public String delete() {

    financeTxnAction.deletePayment(entity);
    accountTxnAction.deletePayment(entity);

    getMatchProvider().delete(getMatchModels());

    for (int i = 0; i < entity.getItems().size(); i++) {
      deleteItem(i);
    }

    if (entity == null) {
      return BaseConsts.FAIL;
    }

    try {
      getEntityManager().remove(getReference());
      getEntityManager().flush();
    } catch (Exception e) {
      log.debug("Hata : #0", e);
      facesMessages.add("#{messages['general.message.record.DeleteFaild']}");
      return BaseConsts.FAIL;
    }

    log.debug("Entity Removed : {0} ", entity);
    entity = null;
    facesMessages.add("#{messages['general.message.record.DeleteSuccess']}");

    raiseRefreshBrowserEvent();
    endCurrentConversation();
    return BaseConsts.SUCCESS;
  }
コード例 #2
0
  @Override
  @TransactionAttribute(TransactionAttributeType.REQUIRED)
  public String save() {
    String res = BaseConsts.FAIL;
    manualFlush();
    recalculate();
    // TODO: Çoklu dil desteği.

    try {
      makeValidations();

      res = super.save();

      if (res.equals(BaseConsts.SUCCESS)) {

        saveMatches();

        // FIXME: bu kodlar burada ne arıyor?
        for (PaymentItem pItem : entity.getItems()) {

          if (pItem instanceof PaymentItemCheque) {

            Cheque pic = ((PaymentItemCheque) pItem).getCheque();
            ChequeParamModel cpm;

            if (pic != null) {

              pic.setContact(entity.getContact());

              if (!chequeAction.alreadySaved(pic, DocumentType.Collection, entity.getId())) {

                cpm = new ChequeParamModel();
                cpm.setCheque(pic);
                cpm.setDocumentId(entity.getId());
                cpm.setDocumentType(DocumentType.Collection);
                cpm.setNewStatus(ChequeStatus.Portfoy);
                cpm.setWorkBunch(pItem.getWorkBunch());
                cpm.setDocumentSerial(entity.getSerial());
                cpm.setToAccount(entity.getAccount());
                cpm.setToContact(entity.getContact());
                chequeAction.changePosition(cpm);

                entityManager.merge(pic);
              }
            }

          } else if (pItem instanceof PaymentItemPromissoryNote) {

            PromissoryNote pipn = ((PaymentItemPromissoryNote) pItem).getPromissoryNote();
            PromissoryParamModel cpm;

            if (pipn != null) {

              pipn.setContact(entity.getContact());

              if (!promissoryAction.alreadySaved(pipn, DocumentType.Collection, entity.getId())) {

                cpm = new PromissoryParamModel();
                cpm.setPromissory(pipn);
                cpm.setDocumentId(entity.getId());
                cpm.setDocumentType(DocumentType.Collection);
                cpm.setNewStatus(ChequeStatus.Portfoy);
                cpm.setWorkBunch(pItem.getWorkBunch());
                cpm.setDocumentSerial(entity.getSerial());
                cpm.setToContact(entity.getContact());
                cpm.setToAccount(entity.getAccount());
                promissoryAction.changePosition(cpm);

                entityManager.merge(pipn);
              }
            }
          }
        }

        financeTxnAction.savePayment(entity);
        accountTxnAction.savePayment(entity);

        if (entity.getItems() != null && entity.getItems().size() != 0) {

          for (PaymentItem pItem : entity.getItems()) {

            if (pItem.getLineType() != PaymentType.Cash) {

              financeTxnAction.savePaymentItem(pItem);
            }
          }
        }
        entityManager.flush();
      }

    } catch (Exception e) {
      FacesMessages.afterPhase();
      facesMessages.clear();
      facesMessages.add(e.getMessage());
      log.error("Hata :", e);
      res = BaseConsts.FAIL;
    }
    return res;
  }