Esempio n. 1
0
  /** Do a Zappos Search and return the result and returns the result */
  public String GetResult(int page) throws IOException {
    String urlStr =
        "http://api.zappos.com/Search?key="
            + zapposKey
            + "&term=&limit=100&sort={\"price\":\"asc\"}";
    if (page != 0) {
      urlStr += "&page=" + page;
    }
    URL url = new URL(urlStr);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();

    if (conn.getResponseCode() != 200) {
      throw new IOException(conn.getResponseMessage());
    }

    // Buffer the result into a string
    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    StringBuilder sb = new StringBuilder();
    String line;
    while ((line = rd.readLine()) != null) {
      sb.append(line);
    }
    rd.close();

    conn.disconnect();
    return sb.toString();
  }
Esempio n. 2
0
  public StringBuilder listToCSV(List list) {
    StringBuilder csv = new StringBuilder();
    csv.append(
        "Work Product,,Name,State,Owner,Plan Estimate,Task Estimate,Task Remaining,Time Spent\n");

    for (int i = 0; i < list.size(); i++) {
      Map map = (Map) list.get(i);
      String type = (String) map.get("type");
      String formattedId = (String) map.get("formattedId");
      String name = (String) map.get("name");
      String taskStatus = (String) map.get("taskStatus");
      String owner = (String) map.get("owner");
      String planEstimate = (String) map.get("planEstimate");
      String taskEstimateTotal = (String) map.get("taskEstimateTotal");
      String taskRemainingTotal = (String) map.get("taskRemainingTotal");
      String taskTimeSpentTotal = (String) map.get("taskTimeSpentTotal");

      if ("task".equals(type)) {
        csv.append("," + formattedId + ",");
      } else if ("userstory".equals(type)) {
        csv.append(formattedId + ",,");
      } else if ("iteration".equals(type)) {
        csv.append(",,");
      }

      if (planEstimate == null) {
        planEstimate = "";
      }

      if (taskEstimateTotal == null) {
        taskEstimateTotal = "";
      }

      if (taskRemainingTotal == null) {
        taskRemainingTotal = "";
      }

      csv.append("\"" + name + "\",");
      csv.append(taskStatus + ",");
      csv.append(owner + ",");
      csv.append(planEstimate + ",");
      csv.append(taskEstimateTotal + ",");
      csv.append(taskRemainingTotal + ",");
      csv.append(taskTimeSpentTotal + "\n");
    }

    return csv;
  }
Esempio n. 3
0
  public StringBuilder listToCSVForUserView(List list) {
    StringBuilder csv = new StringBuilder();

    csv.append(
        "Project,Iteration,Work Product,Name,State,Owner,Task Estimate,Task Remaining,Time Spent\n");

    for (int i = 0; i < list.size(); i++) {
      Map map = (Map) list.get(i);
      String projectName = (String) map.get("projectName");
      String iterationName = (String) map.get("iterationName");
      String formattedId = (String) map.get("taskFormattedId");
      String taskName = (String) map.get("taskName");
      String taskState = (String) map.get("taskState");
      String owner = (String) map.get("owner");
      String taskEstimate = (String) map.get("taskEstimate");
      String taskRemaining = (String) map.get("taskRemaining");
      String taskTimeSpent = (String) map.get("hours");

      if (taskEstimate == null) {
        taskEstimate = "";
      }

      if (taskRemaining == null) {
        taskRemaining = "";
      }

      csv.append("" + projectName + ",");
      csv.append("\"" + iterationName + "\",");
      csv.append(formattedId + ",");
      csv.append(taskName + ",");
      csv.append(taskState + ",");
      csv.append(owner + ",");
      csv.append(taskEstimate + ",");
      csv.append(taskRemaining + ",");
      csv.append(taskTimeSpent + "\n");
    }

    return csv;
  }