示例#1
0
  /**
   * Load the feedbacks that are saved between the previous editor submission and the latest in
   * order to allow the reviewer to see their previous comment for each entry.
   *
   * @param user
   * @param survey
   * @param question
   * @param harmonized
   * @return
   * @throws BadRequestServiceEx
   */
  public List<Feedback> loadPreviousReviewFeedbacks(User user, SurveyInstance survey, Long question)
      throws BadRequestServiceEx {

    List<Feedback> list = new ArrayList<Feedback>();
    try {

      Search search = new Search();
      search.addFilterEqual("user", user);
      search.addFilterEqual("survey", survey);
      search.addFilterEqual("entry.question.id", question);
      Long prev =
          (survey.getStatus().getPreviousPendingFix() != null)
              ? survey.getStatus().getPreviousPendingFix()
              : 0;

      // Long last = (survey.getStatus().getLastSurveyReview() !=
      // null)?survey.getStatus().getLastSurveyReview():0;
      Long last =
          (survey.getStatus().getLastPendingFixSubmit() != null)
              ? survey.getStatus().getLastPendingFixSubmit()
              : 0;

      search.addFilterGreaterThan("timestamp", prev);
      search.addFilterLessThan("timestamp", last);
      list = feedbackDAO.search(search);
    } catch (Exception e) {

      LOGGER.error(e.getLocalizedMessage());
      throw new BadRequestServiceEx(e.getLocalizedMessage());
    }
    return list;
  }
示例#2
0
  /**
   * Load All feedbacks related to the Latest review / ReviewEditing. The feedback is loaded only if
   * his timestamp is > to the LastContributorSubmission field stored in the survey status
   *
   * @param user
   * @param survey
   * @param question
   * @param harmonized
   * @return
   * @throws BadRequestServiceEx
   */
  public List<Feedback> loadFeedback(User user, SurveyInstance survey, Long question)
      throws BadRequestServiceEx {

    List<Feedback> list = new ArrayList<Feedback>();
    List<Feedback> harmonizedList = new ArrayList<Feedback>();
    try {

      Search search = new Search();
      if (user != null) {
        search.addFilterEqual("user", user);
      }
      search.addFilterEqual("harmonized", false);
      search.addFilterEqual("survey", survey);
      search.addFilterEqual("entry.question.id", question);

      // search.addFilterGreaterThan("timestamp", survey.getStatus().getLastSurveyReview());
      search.addFilterGreaterThan("timestamp", survey.getStatus().getLastPendingFixSubmit());

      list = feedbackDAO.search(search);
    } catch (Exception e) {

      LOGGER.error(e.getLocalizedMessage());
      throw new BadRequestServiceEx(e.getLocalizedMessage());
    }
    list.addAll(harmonizedList);
    return list;
  }
示例#3
0
  /* (non-Javadoc)
   * @see it.geosolutions.fra2015.services.SurveyService#getStatus(java.lang.String)
   */
  @Override
  public Status getStatus(String iso3) {
    SurveyInstance survey = surveyDAO.findByCountry(iso3);
    if (survey != null) {
      return survey.getStatus();
    }

    return null;
  }
示例#4
0
  public boolean checkQuestionFeedbackStatus(User user, SurveyInstance survey, Long question) {

    Collection<Entry> entries = catalog.getEntriesForQuestion(question);

    Search search = new Search();
    search.addFilterEqual("user", user);
    search.addFilterEqual("harmonized", false);
    search.addFilterEqual("survey", survey);
    search.addFilterEqual("entry.question.id", question);
    search.addFilterIn("status", "ok", "ko");
    search.addFilterGreaterThan("timestamp", survey.getStatus().getLastContributorSubmission());
    List<Feedback> list = feedbackDAO.search(search);
    return (list.size() == entries.size());
  }
示例#5
0
  /**
   * Counts feedback for a survey
   *
   * @param survey
   * @param harmonized
   * @return
   */
  public int[] getFeedbackCounter(SurveyInstance survey, boolean harmonized) {
    List<Feedback> list = new ArrayList<Feedback>();
    int[] counts = new int[22];
    for (int q = 0; q < counts.length; q++) {
      Search search = new Search();

      search.addFilterEqual("harmonized", harmonized);
      if (!harmonized) {
        search.addFilterEqual("status", "ko");
      }
      search.addFilterEqual("survey", survey);
      search.addFilterEqual("entry.question.id", q);

      search.addFilterGreaterThan("timestamp", survey.getStatus().getLastContributorSubmission());
      counts[q] = feedbackDAO.count(search);
    }
    return counts;
  }
示例#6
0
  public List<Feedback> loadAllHarmonizedfeedbacks(SurveyInstance survey)
      throws BadRequestServiceEx {

    List<Feedback> list = new ArrayList<Feedback>();
    List<Feedback> harmonizedList = new ArrayList<Feedback>();
    try {

      Search search = new Search();
      search.addFilterEqual("harmonized", true);
      search.addFilterEqual("survey", survey);
      // search.addFilterEqual("entry.question.id", question);
      search.addFilterGreaterThan("timestamp", survey.getStatus().getLastContributorSubmission());
      list = feedbackDAO.search(search);
    } catch (Exception e) {

      LOGGER.error(e.getLocalizedMessage());
      throw new BadRequestServiceEx(e.getLocalizedMessage());
    }
    list.addAll(harmonizedList);
    return list;
  }
示例#7
0
 /* (non-Javadoc)
  * @see it.geosolutions.fra2015.services.SurveyService#changeStatus(it.geosolutions.fra2015.server.model.survey.Status)
  */
 @Override
 public String changeStatus(Status status) throws BadRequestServiceEx, NotFoundServiceEx {
   SurveyInstance survey = surveyDAO.findByCountry(status.getCountry());
   if (survey != null) {
     survey.getStatus().setMessage(status.getMessage());
     survey.getStatus().setStatus(status.getStatus());
     survey.getStatus().setRevisionNumber(status.getRevisionNumber());
     survey.getStatus().setLastSurveyReview(status.getLastSurveyReview());
     survey.getStatus().setPreviousPendingFix(status.getPreviousPendingFix());
     survey.getStatus().setLastContributorSubmission(status.getLastContributorSubmission());
     survey.getStatus().setReviewerSubmit(status.getReviewerSubmit());
     survey.getStatus().setCoverage(status.getCoverage());
     survey.getStatus().setLastAcceptanceRequest(status.getLastAcceptanceRequest());
     survey.getStatus().setLastPendingFixSubmit(status.getLastPendingFixSubmit());
     survey.getStatus().setLastStatusAccepted(status.getLastStatusAccepted());
     survey.getStatus().setLastContributorSave(status.getLastContributorSave());
     surveyDAO.merge(survey);
     return survey.getStatus().getStatus();
   }
   return null;
 }