/**
   * Method execute
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return ActionForward
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    MentorReqResponseForm responseForm =
        (MentorReqResponseForm) form; // TODO Auto-generated method stub
    RootMaster rootMaster = new RootMaster();
    AdvtMaster advtMaster = new AdvtMaster();
    HttpSession session = request.getSession();
    String uId = (String) session.getAttribute("uId");

    String compId = (String) session.getAttribute("compId");
    Vector allRights = (Vector) session.getAttribute("allRights");
    String adminFlag = allRights.elementAt(18).toString();
    if (((String) session.getAttribute("flag1")).equalsIgnoreCase("1")) {

      Vector<String> dataVec = new Vector<String>();
      String responseTextt = responseForm.getResponsetext();
      ////
      // System.out.println("request.getParameter...respIdrespIdrespId>>>>>"+request.getParameter("respid"));
      String respId = request.getParameter("respid");
      String complaintId = request.getParameter("compId");
      String flagforcom =
          (request.getParameter("flagforcom") != null) ? request.getParameter("flagforcom") : "";
      String recpType =
          (request.getParameter("respType") != null) ? request.getParameter("respType") : "";
      String accept1 =
          (request.getParameter("accept") != null) ? request.getParameter("accept") : "";
      //// System.out.println("to accept...in respons  .....accept....."+accept1);
      String flag = (request.getParameter("flag") != null) ? request.getParameter("flag") : "";
      if (request.getParameter("flag") != null) {
        flag = request.getParameter("flag").trim();
      } else {
        flag = "0";
      }
      //////// System.out.println("to flag...in respons  .....flag.IN RESPaCTION	...."+flag);
      String uid = (String) session.getAttribute("uId");
      java.util.Date dt = new java.util.Date();
      SimpleDateFormat sform = new SimpleDateFormat("yyyy-MM-dd, HH:mm:ss");
      String completeRemDate = sform.format(dt);
      StringTokenizer sttotal = new StringTokenizer(completeRemDate, ",");
      String creationDate = sttotal.nextToken();
      String creationTime = sttotal.nextToken();

      dataVec.add(responseTextt);
      dataVec.add(creationDate);
      dataVec.add(complaintId);
      dataVec.add(uid);
      dataVec.add(creationTime);
      dataVec.add(respId);
      dataVec.add(flag);
      dataVec.add("0");
      dataVec.add("1");
      dataVec.add("0");
      if (flag.equalsIgnoreCase("1")) {
        dataVec.add("Accept");

      } else if (flag.equalsIgnoreCase("0")) {
        dataVec.add("Reject");

      } else {
        dataVec.add("");
      }
      dataVec.add(flagforcom);
      String result = rootMaster.insertMenResponse(getDataSource(request, "advt"), dataVec);

      if ((result.equalsIgnoreCase("success")) && (!respId.equalsIgnoreCase("0"))) {
        ActionErrors errors = new ActionErrors();
        errors.clear();
        errors.add("reply", new ActionError("errors.entp.replySuccess"));
        saveErrors(request, errors);
        result = "success";
      } else if (result.equalsIgnoreCase("success")) {
        ActionErrors errors = new ActionErrors();
        errors.clear();
        errors.add("response", new ActionError("errors.entp.responseSuccess"));
        saveErrors(request, errors);
        result = "success";
      }

      if (result.equalsIgnoreCase("success")) {
        if (!respId.equalsIgnoreCase("0")) {
          Vector<String> respVec = new Vector<String>();
          respVec.add(respId);
          respVec.add("advt");
          // update `entp_rflag` for communication table.
          result = rootMaster.updateResponseFlag(getDataSource(request, "advt"), respVec);
        }
      }

      ////////////// for mail///////////////
      if (result.equalsIgnoreCase("success")) {

        EntpMaster entpMaster = new EntpMaster();
        IndvMaster indvMaster = new IndvMaster();
        Vector<String> complaintVec = new Vector<String>();
        int cid = Integer.parseInt(complaintId);
        complaintVec = entpMaster.getComplaintDetails(getDataSource(request, "advt"), cid);
        String login_id = complaintVec.elementAt(3).toString();
        String cu_id = complaintVec.elementAt(6).toString();
        String fcomId = complaintVec.elementAt(7).toString();

        Vector<String> paramVec = new Vector<String>();

        //////// System.out.println("to Enterprise.............mail");
        paramVec.add(uid);
        paramVec.add(login_id);
        if (!cu_id.equalsIgnoreCase("0")) {
          paramVec.add(cu_id);
          //////// System.out.println(" to Enterprise..in if...........mail");
        }
        Vector emailVec = indvMaster.getEmailList(getDataSource(request, "advt"), paramVec);
        //////// System.out.println("emailVec..............."+emailVec);

        Vector<String> tempMailParam = new Vector<String>();
        tempMailParam.add("Corporates"); // sender company type Advertiser
        tempMailParam.add("Student"); // receipient company type Enterprise
        if (respId.equalsIgnoreCase("0")) {
          //////// System.out.println("Response if status in brand");
          tempMailParam.add("Response"); // mail description
        } else {
          //////// System.out.println("Reply else status in brand");
          tempMailParam.add("Reply"); // mail description
        }

        // get mail text alert fot sending mail to core user and admin core user
        String mailTextLAlert =
            rootMaster.getMailText(getDataSource(request, "advt"), tempMailParam);
        Vector brandVec = (Vector) emailVec.elementAt(0);
        String brandName =
            brandVec.elementAt(0).toString() + " " + brandVec.elementAt(1).toString();
        String brandmail = brandVec.elementAt(2).toString().trim();
        String subject = "";
        if (flag.equalsIgnoreCase("1")) {
          // dataVec.add("Accept");
          subject = "Acceptance of the mentoring request having reference id as (" + fcomId + ").";

        } else if (flag.equalsIgnoreCase("0")) {
          // dataVec.add("Reject");
          subject = "Denial of the mentoring request having reference id as (" + fcomId + ").";

        } else if (respId.equalsIgnoreCase("0")) {

          subject = "Response on mentoring request Id (" + fcomId + ") By " + brandName + ".";
        } else {

          subject =
              "Reply to your mail on mentoring request Id (" + fcomId + ") By " + brandName + ".";
        }

        for (int i = 1; i < emailVec.size(); i++) {
          MailText mt = new MailText();
          Resource resr = new Resource();
          Vector coreMailVec = (Vector) emailVec.elementAt(i);
          String strMailText =
              mt.getReplyByBrand(coreMailVec, fcomId, mailTextLAlert, brandName, flag);

          ////// System.out.println("strMailText....."+strMailText);

          String strEmailStatus =
              resr.sendMail(
                  strMailText,
                  Constant.Email_Sender,
                  ((Vector) emailVec.elementAt(i)).elementAt(2).toString(),
                  subject);
          ////// System.out.println("str Email status in corpo....."+strEmailStatus);
        }
      }
      ///////////////// end mail////////////

      session.setAttribute("numCid", complaintId);
      session.setAttribute("strResult", result);

      Vector dataVec1 = new Vector();
      dataVec1.add(uId);
      dataVec1.add(compId);
      dataVec1.add(adminFlag);
      Vector advtCountVec = advtMaster.complaintCountAdvt(getDataSource(request, "advt"), dataVec1);
      session.setAttribute("advtCountVec", advtCountVec);
      //////// System.out.println("advtCountVec.............ResponseAction...........
      // "+advtCountVec);
      if (result.equalsIgnoreCase("success")) {
        session.setAttribute("flag1", "0");
      }
      return mapping.findForward(result);
    } else {

      return mapping.findForward("success");
    }
  }
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    MyPreferencesForm myPreferencesForm = new MyPreferencesForm();

    HttpSession session = request.getSession();
    String uId = (String) session.getAttribute("uId");
    String compId = (String) session.getAttribute("compId");

    int numCompId = Integer.parseInt(compId);
    int numUId = Integer.parseInt(uId);

    EntpMaster entpMaster = new EntpMaster();
    RootMaster rootMaster = new RootMaster();

    Vector resultVec = entpMaster.getCommunityUnnamedMap(getDataSource(request, "indv"), numCompId);
    request.setAttribute("resultVec", resultVec);
    System.out.println("resultVec//////MyPreferencesPreAction////////" + resultVec);

    Vector consumerUnName = new Vector();
    if (resultVec.size() != 0) {

      consumerUnName =
          rootMaster.getUserUnNameInfo(getDataSource(request, "indv"), numUId, numCompId);
      request.setAttribute("consumerUnName", consumerUnName);
      System.out.println("consumerUnName//////MyPreferencesPreAction////////" + consumerUnName);

      if (consumerUnName.size() != 0) {
        myPreferencesForm.setField1(consumerUnName.elementAt(0).toString());
        myPreferencesForm.setField2(consumerUnName.elementAt(1).toString());
        myPreferencesForm.setField3(consumerUnName.elementAt(2).toString());
        myPreferencesForm.setField4(consumerUnName.elementAt(3).toString());
        myPreferencesForm.setField5(consumerUnName.elementAt(4).toString());
        myPreferencesForm.setField6(consumerUnName.elementAt(5).toString());
        myPreferencesForm.setField7(consumerUnName.elementAt(6).toString());
        myPreferencesForm.setField8(consumerUnName.elementAt(7).toString());
        myPreferencesForm.setField9(consumerUnName.elementAt(8).toString());
        myPreferencesForm.setField10(consumerUnName.elementAt(9).toString());
        myPreferencesForm.setField11(consumerUnName.elementAt(10).toString());
        myPreferencesForm.setField12(consumerUnName.elementAt(11).toString());
        myPreferencesForm.setField13(consumerUnName.elementAt(12).toString());
        myPreferencesForm.setField14(consumerUnName.elementAt(13).toString());
        myPreferencesForm.setField15(consumerUnName.elementAt(14).toString());
        myPreferencesForm.setField16(consumerUnName.elementAt(15).toString());
        myPreferencesForm.setField17(consumerUnName.elementAt(16).toString());
        myPreferencesForm.setField18(consumerUnName.elementAt(17).toString());
        myPreferencesForm.setField19(consumerUnName.elementAt(18).toString());
        myPreferencesForm.setField20(consumerUnName.elementAt(19).toString());
        myPreferencesForm.setField21(consumerUnName.elementAt(20).toString());
        myPreferencesForm.setField22(consumerUnName.elementAt(21).toString());
        myPreferencesForm.setField23(consumerUnName.elementAt(22).toString());
        myPreferencesForm.setField24(consumerUnName.elementAt(23).toString());
        myPreferencesForm.setField25(consumerUnName.elementAt(24).toString());
        myPreferencesForm.setField26(consumerUnName.elementAt(25).toString());
        myPreferencesForm.setField27(consumerUnName.elementAt(26).toString());
        myPreferencesForm.setField28(consumerUnName.elementAt(27).toString());
        myPreferencesForm.setField29(consumerUnName.elementAt(28).toString());
        myPreferencesForm.setField30(consumerUnName.elementAt(29).toString());
        myPreferencesForm.setField31(consumerUnName.elementAt(30).toString());
        myPreferencesForm.setField32(consumerUnName.elementAt(31).toString());
        myPreferencesForm.setField33(consumerUnName.elementAt(32).toString());
        myPreferencesForm.setField34(consumerUnName.elementAt(33).toString());
        myPreferencesForm.setField35(consumerUnName.elementAt(34).toString());
      }
    }
    request.setAttribute("indvMyPreferencesForm", myPreferencesForm);
    return mapping.findForward("success");
  }