public void initExhibits() throws Throwable {

    if (prmtContext != null) {

      cmplncItemEt = prmtContext.getParentCmplncItemEt();
      consntOrder = cmplncItemEt.getConsentOrder();
      cmplncItemId = consntOrder.getCmplncItemId();

      prmtNo = prmtContext.getOffclPrmtId();
      seqNo = prmtContext.getSeqNo();

      if (prmtNo == 0) {
        srchCmplncItemId = cmplncItemId;
      }

      if (prmtNo == 0) prmtNo = null;
      if (seqNo == 0) seqNo = null;

      //           selectedExhibit = new ConsntOrdExhbt();
      //           selectedExhibit.setExhbtTpCd(82L);

      if ((!constOrdAction.isCurDocOwner() && consntOrder.getStgCd() != 1540)
          || consntOrder.getStgCd() == 1541) {
        disableButtons = true;
      } else {
        disableButtons = false;
      }

      if (this.getCid() == null) {
        cid = (String) getReqParamMap().get("_cid");
      }

      if (this.getScanFileNm() != null && !this.getScanFileNm().equals("")) {
        try {
          String path = this.getScanFileNm().trim();
          this.addFileAsExhibit(null, path);
          setUploadDocs(true);
          setUploadFilesFlag(false);
        } catch (Exception e) {
          e.printStackTrace();
        }
        this.setScanFileNm(null);
        editFlag = false;
      }
      // setting the list for ordering
      this.exhibitsList(consntOrder.getConsntOrdExhbts());
    }
  }
 private Long nextSequenceNumber() {
   curExhSeqNo = new Long(consntOrder.getConsntOrdExhbts().size());
   if (curExhSeqNo != 0) {
     curExhSeqNo += 1L;
   } else {
     curExhSeqNo = 1L;
   }
   return curExhSeqNo;
 }
  public void save() throws Exception {
    ConsentOrderService consentOrderService = ConsentOrderService.getConsentOrderService();
    this.reOrderActnSet();
    int idx;
    consntOrder.getConsntOrdExhbts().clear();
    Iterator it = actnList.iterator();

    while (it.hasNext()) {

      ConsntOrdExhbt exhb = (ConsntOrdExhbt) it.next();
      idx = actnList.indexOf(exhb);
      exhb.setSeqNo(idx + 1);
      if (0 == exhb.getId().getRegDocEt().getUsrId()) {
        exhb.getId().getRegDocEt().setUsrId(usrBean.getUsrId());
      }
      consntOrder.getConsntOrdExhbts().add(exhb);
    }

    if (isUploadDocs()) {
      uploadFiles(); // first saving the documents and setting upload info
      setUploadFilesFlag(true);
    }
    for (ConsntOrdExhbt exhibit : getConsntOrder().getConsntOrdExhbts()) {
      if (exhibit.getId().getRegDocEt().isToBeUploaded()) {
        DocumentService.getDocumentService().saveNoCommit(exhibit.getId().getRegDocEt());
        exhibit.getId().getRegDocEt().setToBeUploaded(false);
      }
    }
    log.info("Saving  Exhibits to the Consent Order");
    consentOrderService.saveConsentOrder(consntOrder);
    this.setDocName("");
    this.setFileName("");
    this.setSelectedFileListSize(0);
    this.setPreviousSelFiles(0);
    this.setAddNewExhibits(false);
    if (!isUploadDocs()) {
      this.addMessage(FacesMessage.SEVERITY_INFO, " Exhibits Saved successfully.");
    }
  }