public void createRequestList() {
   requestList.clear();
   if (isDeptList) {
     requestList.addAll(RequestDao.getRequestList("requesterd"));
   } else {
     requestList.addAll(RequestDao.getRequestList("requesterp"));
   }
   for (Request request : requestList) {
     request.setStatusValue("requester");
   }
 }
  public void newDialog() {
    editRequest = new Request();
    attachments.clear();
    deletedAttachment.clear();
    dialogHeader = "New Request";

    editRequest.setPhoneNumber(RequestDao.getPhoneNumber());
  }
 public void deleteRequest() {
   editRequest.setDataStatus(DataStatus.DELETED);
   RequestDao.saveRequest(editRequest);
   if (filtered != null) {
     filtered.remove(editRequest);
   }
   editRequest = new Request();
   createRequestList();
   FacesContext.getCurrentInstance()
       .addMessage(
           null,
           new FacesMessage(
               FacesMessage.SEVERITY_INFO, "Success !!", "Your request has been deleted."));
 }
  public void onRate(Request request) {
    if (request.getStatus().equals("CLOSED")) {
      if (request.getRating() == 0) {
        SessionUtils.getNotification()
            .setRequester(SessionUtils.getNotification().getRequester() + 1);
      }
    } else {
      SessionUtils.getNotification()
          .setRequester(SessionUtils.getNotification().getRequester() - 1);
    }

    RequestDao.saveRating(request);
    for (Request req : requestList) {
      req.setStatusValue("requester");
    }
  }
  public void saveRequest() {
    List<FacesMessage> msgs = new ArrayList<FacesMessage>();

    if (editRequest.getTitle().trim().length() == 0)
      msgs.add(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Missing !!", "Title is required."));
    if (editRequest.getUseDate() == null)
      msgs.add(
          new FacesMessage(FacesMessage.SEVERITY_ERROR, "Missing !!", "Use date is required."));
    if (editRequest.getIssueType() == null)
      msgs.add(
          new FacesMessage(FacesMessage.SEVERITY_ERROR, "Missing !!", "Issue type is required."));
    if (editRequest.getPhoneNumber().trim().length() == 0)
      msgs.add(
          new FacesMessage(FacesMessage.SEVERITY_ERROR, "Missing !!", "Phone number is required."));
    if (editRequest.getSystemName().trim().length() == 0)
      msgs.add(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Missing !!", "System is required."));
    if (editRequest.getPurpose().trim().length() == 0)
      msgs.add(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Missing !!", "Purpose is required."));
    if (editRequest.getDescription().trim().length() == 0)
      msgs.add(
          new FacesMessage(FacesMessage.SEVERITY_ERROR, "Missing !!", "Description is required."));
    if (editRequest.isBudget() == true) {
      if (editRequest.getBudgetType() == null)
        msgs.add(
            new FacesMessage(
                FacesMessage.SEVERITY_ERROR, "Missing !!", "Budget type is required."));
      if (editRequest.getBudgetUse().equals(new BigDecimal("0")))
        msgs.add(
            new FacesMessage(
                FacesMessage.SEVERITY_ERROR, "Missing !!", "Budget amount is required."));
    }

    if (msgs.size() == 0) {
      editRequest.setRequester(SessionUtils.getUserSession().getStaff());

      if (editRequest.getId() == null) {
        editRequest.setRequestNumber(RequestDao.getNextRequestNumber());
        editRequest.setIssueDate(new Date());
      }
      if (!editRequest.isBudget()) {
        editRequest.setBudgetType(null);
      }
      if (editRequest.getIssueType().equals(IssueType.PERSONAL)) {
        editRequest.setStateType(StateType.NEW_P);
      } else {
        editRequest.setStateType(StateType.NEW_D);
      }

      RequestDao.saveRequest(editRequest);

      for (Attachment file : attachments) {
        if (file.getId() == null) {
          try {
            boolean isSuccess =
                SVNUtils.uploadFile(file.getUploadedFile().getInputstream(), file.getLogicalName());

            if (isSuccess) {
              file.setRequest(editRequest);
              RequestDao.saveAttachment(file);
            }
          } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
      }

      for (Attachment deletedFile : deletedAttachment) {
        if (deletedFile.getId() != null) {
          try {
            SVNUtils.deleteFile(deletedFile.getLogicalName());
            RequestDao.deleteAttachment(deletedFile);
          } catch (SVNException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
      }

      resetData();
      createRequestList();
      RequestContext.getCurrentInstance().execute("newRequestDialog.hide();blockUI.unblock()");
      FacesContext.getCurrentInstance()
          .addMessage(
              null,
              new FacesMessage(
                  FacesMessage.SEVERITY_INFO, "Success !!", "We have received your request."));
    } else {
      for (FacesMessage msg : msgs) {
        FacesContext.getCurrentInstance().addMessage(null, msg);
      }
      RequestContext.getCurrentInstance().execute("blockUI.unblock()");
    }
  }