private void printRemainingDataSourcesList(PrintWriter out, User user, ConnectToDB ctdb)
     throws SQLException {
   DataSource dataSource = null;
   String dataSourceName = null;
   Vector remainingDataSourcesList =
       ctdb.getDataSourceListsDifference(
           this.dataSourceVectorForDataSourceNames(
               ctdb.getValuesVectorForOneColumnUnderOneCondition(
                   new Column("DATASOURCENAME"), new Column("ISCANDIDATE", "no"), "ACDATASOURCE")),
           user.getDataSourceList());
   if (remainingDataSourcesList.size() == 0) {
     out.println("<table class=transparenttable>");
     out.println("<tr><td><FONT COLOR=#000000>No virtaul sensor is available.</td></tr>");
     out.println("</table>");
   } else {
     out.println("<table>");
     out.println("<tr><th> virtual sensor name </th>");
     out.println("<th> access right</th></tr>");
     for (int i = 0; i < remainingDataSourcesList.size(); i++) {
       dataSource = (DataSource) (remainingDataSourcesList.get(i));
       dataSourceName = dataSource.getDataSourceName();
       if (ctdb.valueExistsForThisColumnUnderTwoConditions(
           new Column("ISUSERWAITING", "yes"),
           new Column("USERNAME", user.getUserName()),
           new Column("DATASOURCENAME", dataSource.getDataSourceName()),
           "ACUSER_ACDATASOURCE")) {
         out.println("<tr><td>" + dataSourceName + " </td>");
       } else {
         out.println("<FORM ACTION=/gsn/MyUpdateUserWaitingForDataSourceServlet METHOD=POST>");
         out.println("<tr><td>" + dataSourceName + " </td>");
         out.println("<td><INPUT TYPE=RADIO NAME=" + dataSourceName + " VALUE= 1> read ");
         out.println("<INPUT TYPE=RADIO NAME=" + dataSourceName + " VALUE= 2> write ");
         out.println("<INPUT TYPE=RADIO NAME=" + dataSourceName + " VALUE=3> read/write ");
       }
       if (ctdb.valueExistsForThisColumnUnderTwoConditions(
           new Column("ISUSERWAITING", "yes"),
           new Column("USERNAME", user.getUserName()),
           new Column("DATASOURCENAME", dataSource.getDataSourceName()),
           "ACUSER_ACDATASOURCE")) {
         out.println("<td>" + "<FONT COLOR=#0000FF>in updates waiting list!</td></tr>");
       } else {
         out.println(
             "&nbsp&nbsp&nbsp<INPUT TYPE=SUBMIT TYPE=SUBMIT class= buttonstyle VALUE=\"add\"></td></tr>");
         out.println("</FORM>");
       }
     }
     out.println("</table>");
   }
 }
 private void printUserInformation(PrintWriter out, User user) {
   out.println("<table>");
   out.println("<tr><th>username</th>");
   out.println("<th>user first name</th>");
   out.println("<th>user last name</th>");
   out.println("<th>user E-mail</th></tr>");
   out.println("<tr><td>" + user.getUserName() + "</td>");
   out.println("<td>" + user.getFirstName() + " </td>");
   out.println("<td>" + user.getLastName() + "</td>");
   out.println("<td>" + user.getEmail() + "</td></tr>");
   out.println("</table>");
 }
  // new version without group ds combunation
  private void printUserGroupList(PrintWriter out, User user) {
    Group group = null;
    String label = null;
    String groupName = null;
    String groupType = null;
    String userName = user.getUserName();
    if (user.getGroupList().size() == 0) {

      out.println("<p>No group is selected.</p>");
    } else {
      out.println("<table >");
      out.println("<tr><th> group name </th>");
      out.println("<th> group structure</th>");
      out.println("<th> user choice</th>");
      out.println("<th> admin decision</th>");
      out.println("<th> admin decision</th></tr>");
      for (int i = 0; i < user.getGroupList().size(); i++) {

        group = (Group) (user.getGroupList().get(i));
        groupName = group.getGroupName();
        groupType = group.getGroupType();

        if (groupType.equals("5")) {
          label = " user wants to add this group ";
        } else if (groupType.equals("0")) {
          label = " user wants to delete this group ";
        }
        out.println("<tr><td>" + groupName + "</td>");
        this.printGroupStructureLink(out, group.getGroupName());
        out.println("<td>" + label + " </td>");

        out.println("<FORM ACTION=/gsn/MyUpdateUserGroupServlet METHOD=POST>");
        out.println("<INPUT  TYPE=HIDDEN NAME=groupname VALUE=" + groupName + ">");
        out.println("<INPUT  TYPE=HIDDEN NAME=grouptype VALUE=" + groupType + ">");
        out.println("<INPUT TYPE=HIDDEN NAME=username VALUE= " + userName + ">");
        out.println("<INPUT TYPE=HIDDEN NAME=update VALUE= yes>");
        out.println(
            "<td><INPUT TYPE=SUBMIT class=creategroupbuttonstyle VALUE=\"agree to update\"></td>");
        out.println("</FORM>");

        out.println("<FORM ACTION=/gsn/MyUpdateUserGroupServlet METHOD=POST>");
        out.println("<INPUT  TYPE=HIDDEN NAME=groupname VALUE=" + groupName + ">");
        out.println("<INPUT  TYPE=HIDDEN NAME=grouptype VALUE=" + groupType + ">");
        out.println("<INPUT TYPE=HIDDEN NAME=username VALUE= " + userName + ">");
        out.println("<INPUT TYPE=HIDDEN NAME=update VALUE= no>");
        out.println(
            "<td><INPUT TYPE=SUBMIT class=creategroupbuttonstyle VALUE=\"refuse to update\"></td></tr>");
        out.println("</FORM>");
      }
      out.println("</table>");
    }
  }
  private void printRemainingGroupsList(PrintWriter out, User user, ConnectToDB ctdb)
      throws SQLException {
    Vector remainingGroupList =
        ctdb.getGroupListsDifference(ctdb.getGroupList(), user.getGroupList());
    Group group = null;
    String groupName = null;
    String userName = user.getUserName();
    if (remainingGroupList.size() == 0) {
      out.println("<table class =transparenttable>");
      out.println("<tr><td><FONT COLOR=#000000>No group is available.</td></tr>");
      out.println("</table>");
    } else {
      out.println("<table>");
      out.println("<tr>");
      out.println("<th>group name</th>");
      out.println("<th>group structure</th>");
      out.println("<th>updates</th>");
      out.println("</tr>");

      for (int i = 0; i < remainingGroupList.size(); i++) {
        group = (Group) (remainingGroupList.get(i));
        groupName = group.getGroupName();
        out.println("<tr>");
        out.println("<td>" + groupName + "</td>");
        this.printGroupStructureLink(out, groupName);
        if (ctdb.valueExistsForThisColumnUnderTwoConditions(
                new Column("ISUSERWAITING", "yes"),
                new Column("GROUPNAME", groupName),
                new Column("USERNAME", userName),
                "ACUSER_ACGROUP")
            == false) {
          out.println("<FORM ACTION=/gsn/MyUpdateUserWaitingForGroupServlet METHOD=POST>");
          out.println("<INPUT  TYPE=HIDDEN NAME=groupname VALUE=" + groupName + ">");
          out.println("<INPUT  TYPE=HIDDEN NAME=addgroup VALUE=Yes>");
          out.println(
              "<td style=text-align:center><INPUT TYPE=SUBMIT class= buttonstyle VALUE=\"add\"></td>");
          out.println("</FORM>");
        } else {
          out.println("<td>" + "<FONT COLOR=#0000FF>in updates waiting list!</td>");
        }
        out.println("</tr>");
      }
      out.println("</table>");
    }
  }
  private void printGroupListModulo(PrintWriter out, User user, int index) {
    Group group = null;
    String label = null;
    String groupName = null;
    String groupType = null;
    String userName = user.getUserName();
    group = (Group) (user.getGroupList().get(index));
    groupName = group.getGroupName();
    groupType = group.getGroupType();
    if (groupType.equals("5")) {
      label = " user wants to add this group ";
    } else if (groupType.equals("0")) {
      label = " user wants to delete this group ";
    }

    out.println("<table class=\"transparenttable\">");
    out.println("<tr><td><B>groupname: </B>" + groupName + "</td></tr>");
    out.println("<tr><td><B>user choice: </B>" + label + " </td></tr>");
    out.println("</table>");
    out.println("<BR>");
    this.printGroupDataSourceList(out, group);
    out.println("<BR>");

    out.println("<FORM ACTION=/gsn/MyUpdateUserGroupServlet METHOD=POST>");
    out.println("<INPUT  TYPE=HIDDEN NAME=groupname VALUE=" + groupName + ">");
    out.println("<INPUT  TYPE=HIDDEN NAME=grouptype VALUE=" + groupType + ">");
    out.println("<INPUT TYPE=HIDDEN NAME=username VALUE= " + userName + ">");
    out.println("<INPUT TYPE=HIDDEN NAME=update VALUE= yes>");
    out.println("<table class=\"transparenttable\">");
    out.println(
        "<td><INPUT TYPE=SUBMIT class=creategroupbuttonstyle VALUE=\"agree to update\"></td>");
    out.println("</FORM>");

    out.println("<FORM ACTION=/gsn/MyUpdateUserGroupServlet METHOD=POST>");
    out.println("<INPUT  TYPE=HIDDEN NAME=groupname VALUE=" + groupName + ">");
    out.println("<INPUT  TYPE=HIDDEN NAME=grouptype VALUE=" + groupType + ">");
    out.println("<INPUT TYPE=HIDDEN NAME=username VALUE= " + userName + ">");
    out.println("<INPUT TYPE=HIDDEN NAME=update VALUE= no>");
    out.println(
        "<td><INPUT TYPE=SUBMIT class=creategroupbuttonstyle VALUE=\"refuse to update\"></td></tr>");
    out.println("</FORM>");

    out.println("</table>");
  }
Exemple #6
0
  /**
   * Creates a GPX-formatted file attachment for the given entry.
   *
   * @param user
   * @param entryId
   * @param fileName
   * @param activityId
   * @param track
   * @param track
   */
  public void createAttachment(
      User user, int entryId, String fileName, String title, String activityId, GpsTrack track)
      throws DataAccessException, IOException {
    Attachment a = new Attachment();
    a.setUserName(user.getUserName());
    a.setUserId(user.getUserId());
    a.setEntryId(entryId);
    a.setFileType("map");
    a.setFileName(fileName);
    a.setActivityId(activityId);
    a.setTitle(title);

    GpxFormatter formatter = new GpxFormatter();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    List<GpsTrack> tracks = new ArrayList<GpsTrack>();
    tracks.add(track);

    formatter.format(tracks, baos);
    log.debug(new String(baos.toByteArray()));
    a.setBytes(baos.toByteArray());

    new AttachmentDao().create(a);
  }
  private void printUserDataSourceList(PrintWriter out, User user) {
    String userName = user.getUserName();
    DataSource ds = null;
    String dsname = null;
    String dstype = null;
    String ownerDecision = null;
    String label = null;

    if (user.getDataSourceList().size() == 0) {
      out.println("<p>No virtaul sensor is selected.</p>");
      out.println("<BR>");
    } else {

      out.println("<table>");
      out.println("<tr><th> virtual sensor name </th>");
      out.println("<th> access right</th>");
      out.println("<th> owner decision</th>");
      out.println("<th> admin decision</th>");
      out.println("<th> admin decision</th></tr>");
      for (int i = 0; i < user.getDataSourceList().size(); i++) {

        ds = (DataSource) (user.getDataSourceList().get(i));

        dsname = ds.getDataSourceName();
        dstype = ds.getDataSourceType();
        ownerDecision = ds.getOwnerDecision();

        if (dstype.charAt(1) == '1') {
          label = "read";
        } else if (dstype.charAt(1) == '2') {
          label = "write";
        } else if (dstype.charAt(1) == '3') {
          label = "read/write";
        } else if (dstype.charAt(1) == '0') {
          label = "delete";
        }
        if (ownerDecision.equals("notreceived")) {
          ownerDecision = "not received";
        }
        out.println("<tr><td>" + dsname + "</td>");
        out.println("<td>" + label + "</td>");
        out.println("<td>" + ownerDecision + "</td>");

        out.println("<FORM ACTION=/gsn/MyUpdateUserDataSourceServlet METHOD=POST>");
        out.println("<INPUT TYPE=HIDDEN NAME=username VALUE= " + userName + ">");
        out.println("<INPUT TYPE=HIDDEN NAME= datasourcename VALUE= " + dsname + "> ");
        out.println("<INPUT TYPE=HIDDEN NAME= datasourcetype VALUE= " + dstype + "> ");
        out.println("<INPUT TYPE=HIDDEN NAME=update VALUE= yes>");
        out.println(
            "<td><INPUT TYPE=SUBMIT class=creategroupbuttonstyle VALUE=\"agree to update \"></td>");
        out.println("</FORM>");

        out.println("<FORM ACTION=/gsn/MyUpdateUserDataSourceServlet METHOD=POST>");
        out.println("<INPUT TYPE=HIDDEN NAME=username VALUE= " + userName + ">");
        out.println("<INPUT TYPE=HIDDEN NAME= datasourcename VALUE= " + dsname + "> ");
        out.println("<INPUT TYPE=HIDDEN NAME= datasourcetype VALUE= " + dstype + "> ");
        out.println("<INPUT TYPE=HIDDEN NAME=update VALUE= no>");
        out.println(
            "<td><INPUT TYPE=SUBMIT class=creategroupbuttonstyle VALUE=\"refuse to update\"></td></tr>");
        out.println("</FORM>");
      }
    }
    out.println("</table>");
  }
 private void printUserName(PrintWriter out, User user) {
   // String username=user.getUserName();
   out.println("<p id=\"login\">logged in as : " + user.getUserName() + "</p>");
 }
  private void printUserDataSourceList(PrintWriter out, User user, ConnectToDB ctdb)
      throws SQLException {
    DataSource dataSource = null;
    String dataSourceName = null;
    String dataSourceType = null;

    if (user.getDataSourceList().size() == 0) {
      out.println("<table class =transparenttable>");
      out.println("<tr><td><FONT COLOR=#000000>No virtaul sensor is available.</td></tr>");
      out.println("</table>");
    } else {
      out.println("<table>");
      out.println("<tr><th> virtual sensor name </th>");
      out.println("<th> access right</th></tr>");
      for (int j = 0; j < user.getDataSourceList().size(); j++) {
        dataSource = (DataSource) user.getDataSourceList().get(j);
        dataSourceName = dataSource.getDataSourceName();
        dataSourceType = dataSource.getDataSourceType();
        if (dataSourceType.equals("4")) {
          out.println("<tr><td>" + dataSourceName + " </td>");
          out.println("<td>own</td></tr>");
        } else {
          if (ctdb.valueExistsForThisColumnUnderTwoConditions(
              new Column("ISUSERWAITING", "yes"),
              new Column("USERNAME", user.getUserName()),
              new Column("DATASOURCENAME", dataSourceName),
              "ACUSER_ACDATASOURCE")) {
            out.println("<tr><td>" + dataSourceName + " </td>");
          } else {
            out.println("<FORM ACTION=/gsn/MyUpdateUserWaitingForDataSourceServlet METHOD=POST>");
            out.println("<tr><td>" + dataSourceName + " </td>");
            if (dataSourceType.charAt(0) == '1') {
              out.println(
                  "<td><INPUT CHECKED TYPE=RADIO NAME=" + dataSourceName + " VALUE= 1>read");
              out.println("<INPUT  TYPE=RADIO NAME=" + dataSourceName + " VALUE= 2>write ");
              out.println("<INPUT  TYPE=RADIO NAME=" + dataSourceName + " VALUE=3>read/write");
              out.println("<INPUT  TYPE=RADIO NAME=" + dataSourceName + " VALUE=0>delete ");
            }
            if (dataSourceType.charAt(0) == '2') {
              out.println("<td><INPUT TYPE=RADIO NAME=" + dataSourceName + " VALUE= 1> read ");
              out.println("<INPUT CHECKED TYPE=RADIO NAME=" + dataSourceName + " VALUE= 2> write ");
              out.println("<INPUT  TYPE=RADIO NAME=" + dataSourceName + " VALUE=3> read/write ");
              out.println("<INPUT  TYPE=RADIO NAME=" + dataSourceName + " VALUE=0> delete ");
            }
            if (dataSourceType.charAt(0) == '3') {
              out.println("<td><INPUT TYPE=RADIO NAME=" + dataSourceName + " VALUE= 1> read ");
              out.println("<INPUT  TYPE=RADIO NAME=" + dataSourceName + " VALUE= 2> write ");
              out.println(
                  "<INPUT CHECKED TYPE=RADIO NAME=" + dataSourceName + " VALUE=3> read/write ");
              out.println("<INPUT  TYPE=RADIO NAME=" + dataSourceName + " VALUE=0> delete ");
            }
          }
          if (ctdb.valueExistsForThisColumnUnderTwoConditions(
              new Column("ISUSERWAITING", "yes"),
              new Column("USERNAME", user.getUserName()),
              new Column("DATASOURCENAME", dataSourceName),
              "ACUSER_ACDATASOURCE")) {
            out.println("<td>" + "<FONT COLOR=#0000FF>in updates waiting list!</td></tr>");

          } else {

            out.println(
                "&nbsp&nbsp&nbsp<INPUT TYPE=SUBMIT class= buttonstyle VALUE=\"update\"></td></tr>");
            out.println("</FORM>");
          }
        }
      }
      out.println("</table>");
    }
  }