Package cn.edu.zju.acm.onlinejudge.bean.request

Examples of cn.edu.zju.acm.onlinejudge.bean.request.SubmissionCriteria


        }
    }

    public SubmissionCriteria toSubmissionCriteria() throws ParseException, NumberFormatException, PersistenceException {

        SubmissionCriteria criteria = new SubmissionCriteria();
        if (this.contestId != null && this.contestId.trim().length() > 0) {
            criteria.setContestId(Long.valueOf(this.contestId.trim()));
        }
        if (this.problemCode != null && this.problemCode.trim().length() > 0) {
            criteria.setProblemCode(this.problemCode);
        }
        if (this.handle != null && this.handle.trim().length() > 0) {
            criteria.setHandle(this.handle);
        }
        if (this.idStart != null && this.idStart.trim().length() > 0) {
            criteria.setIdStart(Long.valueOf(this.idStart.trim()));
        }
        if (this.idEnd != null && this.idEnd.trim().length() > 0) {
            criteria.setIdEnd(Long.valueOf(this.idEnd.trim()));
        }
        if (this.timeStart != null && this.timeStart.trim().length() > 0) {
            criteria.setTimeStart(Utility.parseTimestamp(this.timeStart));
        }
        if (this.timeEnd != null && this.timeEnd.trim().length() > 0) {
            criteria.setTimeEnd(Utility.parseTimestamp(this.timeEnd));
        }
        if (this.languageIds != null && this.languageIds.length > 0) {
            LanguagePersistence persistence = PersistenceManager.getInstance().getLanguagePersistence();
            List<Language> languages = new ArrayList<Language>();
            for (int i = 0; i < this.languageIds.length; ++i) {
                languages.add(persistence.getLanguage(Long.parseLong(this.languageIds[i])));
            }
            criteria.setLanguages(languages);
        }
        if (this.judgeReplyIds != null && this.judgeReplyIds.length > 0) {
            List<JudgeReply> judgeReplies = new ArrayList<JudgeReply>();
            for (int i = 0; i < this.judgeReplyIds.length; ++i) {
                judgeReplies.add(JudgeReply.findById(Long.parseLong(this.judgeReplyIds[i])));
            }
            criteria.setJudgeReplies(judgeReplies);
        }
        return criteria;
    }
View Full Code Here


   * Tests searchSubmissions method
   * @throws Exception to JUnit
   */
  public void testSearchSubmissions8() throws Exception {
    List submissions = null;
    SubmissionCriteria criteria = new SubmissionCriteria();
   
    criteria.setProblemId(new Long(problem2.getId()));   
    criteria.setContestId(new Long(contest.getId()));
    criteria.setHandle(userProfile2.getHandle());
    criteria.setIdStart(new Long(submission1.getId()));
    criteria.setIdEnd(new Long(submission4.getId()));
    criteria.setTimeStart(submission1.getSubmitDate());
    criteria.setTimeEnd(submission4.getSubmitDate());
    criteria.setJudgeReplies(Arrays.asList(new Object[] {judgeReply1, judgeReply2, judgeReply3}));
    criteria.setLanguages(Arrays.asList(new Object[] {language1, language2, language3}));
   
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(Arrays.asList(new Object[] {submission3}), submissions);       
   
  }
View Full Code Here

   * Tests searchSubmissions method
   * @throws Exception to JUnit
   */
  public void testSearchSubmissions9() throws Exception {
    List submissions = null;
    SubmissionCriteria criteria = new SubmissionCriteria();
         
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(Arrays.asList(new Object[] {submission1, submission2, submission3, submission4}), submissions);
   
    persistence.deleteSubmission(submission2.getId(), 11);
View Full Code Here

   * Tests searchSubmissions method
   * @throws Exception to JUnit
   */
  public void testSearchSubmissions10() throws Exception {
    List submissions = null;
    SubmissionCriteria criteria = new SubmissionCriteria();
         
    submissions = persistence.searchSubmissions(criteria, 0, 0);
    checkSubmissions(new ArrayList(), submissions);
   
    submissions = persistence.searchSubmissions(criteria, 0, 1);
View Full Code Here

   * Tests searchSubmissions method
   * @throws Exception to JUnit
   */
  public void testSearchSubmissions1() throws Exception {
    List submissions = null;
    SubmissionCriteria criteria = new SubmissionCriteria();
   
    criteria.setProblemId(new Long(problem2.getId()));       
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(Arrays.asList(new Object[] {submission2, submission3, submission4}), submissions);
       
    criteria.setProblemId(new Long(problem1.getId()));       
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(Arrays.asList(new Object[] {submission1}), submissions);
   
    criteria.setProblemId(new Long(1234567890l));       
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(new ArrayList(), submissions);
   
  }
View Full Code Here

   * Tests searchSubmissions method
   * @throws Exception to JUnit
   */
  public void testSearchSubmissions2() throws Exception {
    List submissions = null;
    SubmissionCriteria criteria = new SubmissionCriteria();
   
    criteria.setContestId(new Long(contest.getId()));       
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(Arrays.asList(new Object[] {submission1, submission2, submission3, submission4}), submissions);
           
    criteria.setContestId(new Long(1234567890l));       
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(new ArrayList(), submissions);
   
  }
View Full Code Here

   * Tests searchSubmissions method
   * @throws Exception to JUnit
   */
  public void testSearchSubmissions3() throws Exception {
    List submissions = null;
    SubmissionCriteria criteria = new SubmissionCriteria();
   
    criteria.setHandle(userProfile1.getHandle());       
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(Arrays.asList(new Object[] {submission1, submission2, submission4}), submissions);
   
    criteria.setHandle(userProfile2.getHandle());       
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(Arrays.asList(new Object[] {submission3}), submissions);
           
    criteria.setHandle("foobar");       
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(new ArrayList(), submissions);
   
 
View Full Code Here

   * Tests searchSubmissions method
   * @throws Exception to JUnit
   */
  public void testSearchSubmissions4() throws Exception {
    List submissions = null;
    SubmissionCriteria criteria = new SubmissionCriteria();
   
    criteria.setIdEnd(new Long(submission2.getId()));       
    criteria.setIdStart(null);
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(Arrays.asList(new Object[] {submission1, submission2}), submissions);
   
    criteria.setIdEnd(null);
    criteria.setIdStart(new Long(submission3.getId()));       
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(Arrays.asList(new Object[] {submission3, submission4}), submissions);
   
    criteria.setIdEnd(new Long(submission3.getId()));       
    criteria.setIdStart(new Long(submission2.getId()));
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(Arrays.asList(new Object[] {submission2, submission3}), submissions);
   
    criteria.setIdEnd(new Long(submission1.getId() - 1));       
    criteria.setIdStart(null);
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(new ArrayList(), submissions);
   
    criteria.setIdEnd(null);
    criteria.setIdStart(new Long(submission4.getId() + 1));       
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(new ArrayList(), submissions);
   
    criteria.setIdEnd(new Long(submission2.getId()));       
    criteria.setIdStart(new Long(submission3.getId()));
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(new ArrayList(), submissions);       
   
 
View Full Code Here

   * Tests searchSubmissions method
   * @throws Exception to JUnit
   */
  public void testSearchSubmissions5() throws Exception {
    List submissions = null;
    SubmissionCriteria criteria = new SubmissionCriteria();
   
    criteria.setTimeEnd(submission3.getSubmitDate());       
    criteria.setTimeStart(null);
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(Arrays.asList(new Object[] {submission1, submission3}), submissions);
   
    criteria.setTimeStart(submission3.getSubmitDate());       
    criteria.setTimeEnd(null);
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(Arrays.asList(new Object[] {submission3, submission4}), submissions);
   
    criteria.setTimeStart(submission1.getSubmitDate());       
    criteria.setTimeEnd(submission3.getSubmitDate());
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(Arrays.asList(new Object[] {submission1, submission3}), submissions);
   
    criteria.setTimeEnd(new Date(-1000));       
    criteria.setTimeStart(null);
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(new ArrayList(), submissions);
   
    criteria.setTimeStart(new Date(submission4.getSubmitDate().getTime() + 1000));       
    criteria.setTimeEnd(null);
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(new ArrayList(), submissions);
   
    criteria.setTimeStart(submission3.getSubmitDate());       
    criteria.setTimeEnd(submission1.getSubmitDate());   
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(new ArrayList(), submissions);       
   
 
View Full Code Here

   * Tests searchSubmissions method
   * @throws Exception to JUnit
   */
  public void testSearchSubmissions6() throws Exception {
    List submissions = null;
    SubmissionCriteria criteria = new SubmissionCriteria();
   
    criteria.setLanguages(Arrays.asList(new Object[] {language1, language3}));       
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(Arrays.asList(new Object[] {submission1, submission3, submission4}), submissions);
   
    criteria.setLanguages(Arrays.asList(new Object[] {language2}));       
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(Arrays.asList(new Object[] {submission2}), submissions);   
           
    criteria.setLanguages(Arrays.asList(new Object[] {
        new Language(4, "x", "x", "x", "x")}));       
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(new ArrayList(), submissions);
   
    criteria.setLanguages(new ArrayList());       
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(new ArrayList(), submissions);
   
 
View Full Code Here

TOP

Related Classes of cn.edu.zju.acm.onlinejudge.bean.request.SubmissionCriteria

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.