@Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    // super.doPost(req, resp);

    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    Gson gson = new Gson();
    Plan pl = gson.fromJson(req.getParameter("PARAM"), Plan.class);
    Entity plan = new Entity("Plan");

    plan.setProperty("title", pl.getTitle());
    plan.setProperty("description", pl.getDesc());
    plan.setProperty("domain", pl.getDomain());
    plan.setProperty("totalLength", pl.getTotalTime());
    System.out.println(pl.getTotalTime());

    Key planKey = datastore.put(plan);

    List<Exercise> listEx = pl.getExercises();
    Entity exercise;

    for (Exercise ex : listEx) {
      exercise = new Entity("Exercise", planKey);
      exercise.setProperty("title", ex.getTitle());
      exercise.setProperty("description", ex.getDesc());
      String length = ex.getLength();
      String[] splitStr = length.split(":");
      Integer seconds = Integer.parseInt(splitStr[0]) * 60 + Integer.parseInt(splitStr[1]);
      exercise.setProperty("length", seconds);
      exercise.setProperty("row", ex.getRow());
      datastore.put(exercise);
    }
  }
예제 #2
0
  public void setPanHaut() {
    // JPanel panHaut = new JPanel();
    panHaut.setLayout(new BorderLayout());

    String color1 = "black";
    String color2 = "grey";
    panHaut.add(
        new JLabel(
            "<html><p style=\"margin-left: 380x;\"><br/>Vous faites l'exercice : "
                + e.getTitle()
                + "</p></html>"),
        BorderLayout.NORTH);

    panHaut.add(
        new JLabel(
            "<html><p style=\"font-size: 16px;margin-left: 50x; color: "
                + color2
                + ";\"><br/>Énoncé : "
                + e.getWordingText()
                + "</p></html>"),
        BorderLayout.CENTER);
  }