コード例 #1
0
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String context = "context0";
    context = ServletUtilities.getContext(request);
    String langCode = ServletUtilities.getLanguageCode(request);
    Shepherd myShepherd = new Shepherd(context);
    // set up for response
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    boolean locked = false;
    boolean isOwner = true;

    if (request.getParameter("number") != null) {
      myShepherd.beginDBTransaction();
      Encounter enc2reject = myShepherd.getEncounter(request.getParameter("number"));
      setDateLastModified(enc2reject);
      boolean isOK = enc2reject.isAssignedToMarkedIndividual().equals("Unassigned");
      myShepherd.rollbackDBTransaction();
      if (isOK) {

        myShepherd.beginDBTransaction();
        try {

          // enc2reject.reject();
          enc2reject.setState("unidentifiable");
          enc2reject.addComments(
              "<p><em>"
                  + request.getRemoteUser()
                  + " on "
                  + (new java.util.Date()).toString()
                  + "</em><br>Set this encounter as unidentifiable in the database.</p>");
          // enc2reject.approved = false;
          enc2reject.setState("unidentifiable");
        } catch (Exception le) {
          locked = true;
          le.printStackTrace();
          myShepherd.rollbackDBTransaction();
        }

        if (!locked) {
          String submitterEmail = enc2reject.getSubmitterEmail();
          myShepherd.commitDBTransaction();
          out.println(ServletUtilities.getHeader(request));
          out.println(
              "<strong>Success:</strong> I have set encounter "
                  + request.getParameter("number")
                  + " as unidentifiable in the database.");
          out.println(
              "<p><a href=\"http://"
                  + CommonConfiguration.getURLLocation(request)
                  + "/encounters/encounter.jsp?number="
                  + request.getParameter("number")
                  + "\">View unidentifiable encounter #"
                  + request.getParameter("number")
                  + "</a></p>\n");
          ArrayList<String> allStates =
              CommonConfiguration.getSequentialPropertyValues("encounterState", context);
          int allStatesSize = allStates.size();
          if (allStatesSize > 0) {
            for (int i = 0; i < allStatesSize; i++) {
              String stateName = allStates.get(i);
              out.println(
                  "<p><a href=\"encounters/searchResults.jsp?state="
                      + stateName
                      + "\">View all "
                      + stateName
                      + " encounters</a></font></p>");
            }
          }
          out.println(ServletUtilities.getFooter(context));
          String message =
              "Encounter "
                  + request.getParameter("number")
                  + " was set as unidentifiable in the database.";
          ServletUtilities.informInterestedParties(
              request, request.getParameter("number"), message, context);

          // Email submitter about change
          Map<String, String> tagMap = NotificationMailer.createBasicTagMap(request, enc2reject);
          tagMap.put("@TEXT_CONTENT@", message);
          ThreadPoolExecutor es = MailThreadExecutorService.getExecutorService();
          NotificationMailer mailer =
              new NotificationMailer(context, null, submitterEmail, "encounterDataUpdate", tagMap);
          es.execute(mailer);
          es.shutdown();

        } else {
          out.println(ServletUtilities.getHeader(request));
          out.println(
              "<strong>Failure:</strong> I have NOT modified encounter "
                  + request.getParameter("number")
                  + " in the database because another user is currently modifying its entry. Please try this operation again in a few seconds.");
          out.println(
              "<p><a href=\"http://"
                  + CommonConfiguration.getURLLocation(request)
                  + "/encounters/encounter.jsp?number="
                  + request.getParameter("number")
                  + "\">View unidentifiable encounter #"
                  + request.getParameter("number")
                  + "</a></p>\n");
          ArrayList<String> allStates =
              CommonConfiguration.getSequentialPropertyValues("encounterState", context);
          int allStatesSize = allStates.size();
          if (allStatesSize > 0) {
            for (int i = 0; i < allStatesSize; i++) {
              String stateName = allStates.get(i);
              out.println(
                  "<p><a href=\"encounters/searchResults.jsp?state="
                      + stateName
                      + "\">View all "
                      + stateName
                      + " encounters</a></font></p>");
            }
          }
          out.println(ServletUtilities.getFooter(context));
        }

      } else {
        out.println(ServletUtilities.getHeader(request));
        out.println(
            "Encounter# "
                + request.getParameter("number")
                + " is assigned to an individual and cannot be set as unidentifiable until it has been removed from that individual.");
        out.println(ServletUtilities.getFooter(context));
      }
    } else {
      out.println(ServletUtilities.getHeader(request));
      out.println(
          "<strong>Error:</strong> I do not know which encounter you are trying to remove.");
      out.println(ServletUtilities.getFooter(context));
    }

    out.close();
    myShepherd.closeDBTransaction();
  }
コード例 #2
0
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String context = "context0";
    context = ServletUtilities.getContext(request);
    Shepherd myShepherd = new Shepherd(context);
    // set up for response
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    boolean locked = false;
    boolean isOwner = true;

    if ((request.getParameter("number") != null) && (request.getParameter("state") != null)) {
      myShepherd.beginDBTransaction();
      Encounter changeMe = myShepherd.getEncounter(request.getParameter("number"));
      setDateLastModified(changeMe);
      String state = request.getParameter("state");

      String oldScar = "None";

      try {
        if (changeMe.getState() != null) {
          oldScar = changeMe.getState();
        }
        changeMe.setState(state);
        changeMe.addComments(
            "<p><em>"
                + request.getRemoteUser()
                + " on "
                + (new java.util.Date()).toString()
                + "</em><br>Changed state from "
                + oldScar
                + " to "
                + state
                + ".</p>");
      } catch (Exception le) {
        locked = true;
        le.printStackTrace();
        myShepherd.rollbackDBTransaction();
      }

      if (!locked) {
        myShepherd.commitDBTransaction();
        out.println(ServletUtilities.getHeader(request));
        out.println(
            "<strong>Success:</strong> Encounter state has been updated from "
                + oldScar
                + " to "
                + state
                + ".");
        out.println(
            "<p><a href=\"http://"
                + CommonConfiguration.getURLLocation(request)
                + "/encounters/encounter.jsp?number="
                + request.getParameter("number")
                + "\">Return to encounter #"
                + request.getParameter("number")
                + "</a></p>\n");
        List<String> allStates =
            CommonConfiguration.getIndexedPropertyValues("encounterState", context);
        int allStatesSize = allStates.size();
        if (allStatesSize > 0) {
          for (int i = 0; i < allStatesSize; i++) {
            String stateName = allStates.get(i);
            out.println(
                "<p><a href=\"encounters/searchResults.jsp?state="
                    + stateName
                    + "\">View all "
                    + stateName
                    + " encounters</a></font></p>");
          }
        }
        out.println(
            "<p><a href=\"individualSearchResults.jsp\">View all individuals</a></font></p>");
        out.println(ServletUtilities.getFooter(context));
        String message =
            "Encounter "
                + request.getParameter("number")
                + " state has been updated from "
                + oldScar
                + " to "
                + state
                + ".";
        ServletUtilities.informInterestedParties(
            request, request.getParameter("number"), message, context);
      } else {
        out.println(ServletUtilities.getHeader(request));
        out.println(
            "<strong>Failure:</strong> Encounter state was NOT updated because another user is currently modifying this reconrd. Please try to reset the scarring again in a few seconds.");
        out.println(
            "<p><a href=\"http://"
                + CommonConfiguration.getURLLocation(request)
                + "/encounters/encounter.jsp?number="
                + request.getParameter("number")
                + "\">Return to encounter #"
                + request.getParameter("number")
                + "</a></p>\n");
        List<String> allStates =
            CommonConfiguration.getIndexedPropertyValues("encounterState", context);
        int allStatesSize = allStates.size();
        if (allStatesSize > 0) {
          for (int i = 0; i < allStatesSize; i++) {
            String stateName = allStates.get(i);
            out.println(
                "<p><a href=\"encounters/searchResults.jsp?state="
                    + stateName
                    + "\">View all "
                    + stateName
                    + " encounters</a></font></p>");
          }
        }
        out.println(
            "<p><a href=\"individualSearchResults.jsp\">View all individuals</a></font></p>");
        out.println(ServletUtilities.getFooter(context));
      }
    } else {
      out.println(ServletUtilities.getHeader(request));
      out.println(
          "<strong>Error:</strong> I don't have enough information to complete your request.");
      out.println(
          "<p><a href=\"http://"
              + CommonConfiguration.getURLLocation(request)
              + "/encounters/encounter.jsp?number="
              + request.getParameter("number")
              + "\">Return to encounter #"
              + request.getParameter("number")
              + "</a></p>\n");
      List<String> allStates =
          CommonConfiguration.getIndexedPropertyValues("encounterState", context);
      int allStatesSize = allStates.size();
      if (allStatesSize > 0) {
        for (int i = 0; i < allStatesSize; i++) {
          String stateName = allStates.get(i);
          out.println(
              "<p><a href=\"encounters/searchResults.jsp?state="
                  + stateName
                  + "\">View all "
                  + stateName
                  + " encounters</a></font></p>");
        }
      }
      out.println("<p><a href=\"individualSearchResults.jsp\">View all individuals</a></font></p>");
      out.println(ServletUtilities.getFooter(context));
    }

    out.close();
    myShepherd.closeDBTransaction();
  }