Exemplo n.º 1
0
  public static List<UserJournalFormBean> getUserJournalFormData(
      List<UserJournalBean> listUserJournalBean) {

    List<UserJournalFormBean> listFormBean = new ArrayList<UserJournalFormBean>();
    Double mark = null;

    for (UserJournalBean userJournalBean : listUserJournalBean) {
      UserJournalFormBean formBean = new UserJournalFormBean();
      List<Double> marks = userJournalBean.getMarks();
      if (marks != null) {
        if (marks.size() > 0) {
          mark = marks.get(0);
          formBean.setMark1(mark == null ? null : mark.toString());
        }
        if (marks.size() > 1) {
          mark = marks.get(1);
          formBean.setMark2(mark == null ? null : mark.toString());
        }
        if (marks.size() > 2) {
          mark = marks.get(2);
          formBean.setMark3(mark == null ? null : mark.toString());
        }
      }
      Integer numberOfAttempts = userJournalBean.getNumberOfAttempts();
      formBean.setNumberOfAttempts(numberOfAttempts != null ? numberOfAttempts.toString() : null);
      String markDate =
          CalendarHelper.FormatDate(userJournalBean.getMarkDate(), "dd-MM-yyyy HH:mm");
      formBean.setMarkDate(CalendarHelper.ParseDate(markDate));
      formBean.setComment(userJournalBean.getComment());
      listFormBean.add(formBean);
    }

    return listFormBean;
  }
Exemplo n.º 2
0
 public static void addUserTaskToStatement(
     PreparedStatement preparedStatement, UserJournalBean userJournalBean, Long idGroupTask)
     throws SQLException {
   int cursor = 1;
   preparedStatement.setLong(cursor++, userJournalBean.getUser().getId());
   preparedStatement.setLong(cursor++, idGroupTask);
   if (userJournalBean.getNumberOfAttempts() != null) {
     preparedStatement.setInt(cursor++, userJournalBean.getNumberOfAttempts());
   } else {
     preparedStatement.setObject(cursor++, null);
   }
   preparedStatement.setString(cursor++, userJournalBean.getComment());
   preparedStatement.setByte(cursor++, (byte) 1);
   List<Double> marks = userJournalBean.getMarks();
   int counter = 0;
   if (marks != null) {
     for (Double mark : marks) {
       if (mark == null) {
         preparedStatement.setObject(cursor++, null);
       } else {
         preparedStatement.setDouble(cursor++, mark);
       }
       ++counter;
     }
   }
   while (counter < 3) {
     preparedStatement.setObject(cursor++, null);
     ++counter;
   }
   preparedStatement.setTimestamp(
       cursor++, CalendarHelper.getStamp(userJournalBean.getMarkDate()));
 }
Exemplo n.º 3
0
  public static List<UserJournalFormBean> getUserJournalFormData(Map<String, String[]> parameters) {

    List<UserJournalFormBean> listFormBean = new ArrayList<UserJournalFormBean>();

    String[] marks1 = parameters.get("mark1");
    String[] marks2 = parameters.get("mark2");
    String[] marks3 = parameters.get("mark3");
    String[] numberOfAttempts = parameters.get("numberOfAttempts");
    String[] markDates = parameters.get("markDate");
    String[] comments = parameters.get("comment");

    for (int i = 0; comments != null && i < comments.length; ++i) {
      UserJournalFormBean formBean = new UserJournalFormBean();
      if (marks1 != null && !marks1[i].isEmpty()) {
        formBean.setMark1(marks1[i].trim());
      }
      if (marks2 != null && !marks2[i].isEmpty()) {
        formBean.setMark2(marks2[i].trim());
      }
      if (marks3 != null && !marks3[i].isEmpty()) {
        formBean.setMark3(marks3[i].trim());
      }
      if (numberOfAttempts != null && !numberOfAttempts[i].isEmpty()) {
        formBean.setNumberOfAttempts(numberOfAttempts[i].trim());
      }
      if (markDates != null && (markDates[i] != null & markDates[i] != "")) {
        formBean.setMarkDate(CalendarHelper.ParseDate(markDates[i]));
      }
      formBean.setComment(comments[i]);
      listFormBean.add(formBean);
    }

    return listFormBean;
  }