Package org.sete.domain

Examples of org.sete.domain.ScienceProject


     * Tests that a non-null and size 1 list is returned for a project with 1 form.
     */
    @Test
    public void testLoadAllProjectFilesForOneFileOnly(){
        int toTestID = 2;
        ScienceProject p = new ScienceProject();
        Set<Attachment> f  = new HashSet<Attachment>();
        p.setForms(f);
        Attachment a = new Attachment();
        a.setId(toTestID);
        p.getForms().add(a);
        p.setId(toTestID);
        List<ScienceProject> l = new ArrayList<ScienceProject>();
        l.add(p);
        EasyMock.expect(mockScienceProjectDao.getAllScienceProjects()).andReturn(l);
        EasyMock.replay(mockScienceProjectDao);
        List<AttachmentVo> att = scienceProjectService.loadAllProjectFilesFor(toTestID);
View Full Code Here


     * Tests that a non-null and size 2 list is returned for a project with 2 forms.
     */
    @Test
    public void testLoadAllProjectFilesForMultipleFilesOnly(){
        int toTestID = 2;
        ScienceProject p = new ScienceProject();
        p.setId(toTestID);
        Set<Attachment> f  = new HashSet<Attachment>();
        p.setForms(f);
        Attachment a = new Attachment();
        a.setId(1);
        p.getForms().add(a);
        Attachment b = new Attachment();
        b.setId(2);
        p.getForms().add(b);
        List<ScienceProject> l = new ArrayList<ScienceProject>();
        l.add(p);
        EasyMock.expect(mockScienceProjectDao.getAllScienceProjects()).andReturn(l);
        EasyMock.replay(mockScienceProjectDao);
        List<AttachmentVo> att = scienceProjectService.loadAllProjectFilesFor(toTestID);
View Full Code Here

    @Test
    public void testLoadProjectFilesDataForBadProject(){
       
        int badID = 1;
        int toTestID = 2;
        ScienceProject p = new ScienceProject();
        p.setId(badID);
        primeProjectWithStudentandSponsor(p);
        List<ScienceProject> l = new ArrayList<ScienceProject>();
        l.add(p);
        EasyMock.expect(mockScienceProjectDao.getAllScienceProjects()).andReturn(l);
        EasyMock.replay(mockScienceProjectDao);
View Full Code Here

    @Test
    public void testLoadProjectFilesDataForBadFormID(){
       
        int badID = 1;
        int toTestID = 2;
        ScienceProject p = new ScienceProject();
        p.setId(toTestID);
        Set<Attachment> f  = new HashSet<Attachment>();
        p.setForms(f);
        primeProjectWithStudentandSponsor(p);
        List<ScienceProject> l = new ArrayList<ScienceProject>();
        l.add(p);
        EasyMock.expect(mockScienceProjectDao.getAllScienceProjects()).andReturn(l);
        EasyMock.replay(mockScienceProjectDao);
View Full Code Here

    @Test
    public void testLoadProjectFilesDataForOneFormSecurityHole(){
        int proejctID = 2;
        int formID = 5;
        String name = "form";
        ScienceProject p = new ScienceProject();
        p.setId(proejctID);
        Set<Attachment> f  = new HashSet<Attachment>();
        Attachment a = new Attachment();
        a.setId(formID);
        a.setName(name);
        f.add(a);
        p.setForms(f);
        primeProjectWithStudentandSponsor(p);
        List<ScienceProject> l = new ArrayList<ScienceProject>();
        l.add(p);
       
        EasyMock.expect(mockScienceProjectDao.getAllScienceProjects()).andReturn(l);
View Full Code Here

    public void testLoadProjectFilesDataForOneForm(){
       
        int toTestID = 2;
        int formID = 5;
        String name = "form";
        ScienceProject p = new ScienceProject();
        p.setId(toTestID);
        Set<Attachment> f  = new HashSet<Attachment>();
        Attachment a = new Attachment();
        a.setId(formID);
        a.setName(name);
        f.add(a);
        p.setForms(f);
        primeProjectWithStudentandSponsor(p);
        List<ScienceProject> l = new ArrayList<ScienceProject>();
        l.add(p);
        EasyMock.expect(mockScienceProjectDao.getAllScienceProjects()).andReturn(l);
        EasyMock.replay(mockScienceProjectDao);
View Full Code Here

        int toTestID = 2;
        int formID = 5;
        String name = "form";
        int badformID = 9;
        String badname = "badform";
        ScienceProject p = new ScienceProject();
        p.setId(toTestID);
        primeProjectWithStudentandSponsor(p);
        Set<Attachment> f  = new HashSet<Attachment>();
        Attachment a = new Attachment();
        a.setId(formID);
        a.setName(name);
        f.add(a);
        Attachment bada = new Attachment();
        bada.setId(badformID);
        bada.setName(badname);
        f.add(bada);
        p.setForms(f);
        List<ScienceProject> l = new ArrayList<ScienceProject>();
        l.add(p);
        EasyMock.expect(mockScienceProjectDao.getAllScienceProjects()).andReturn(l);
        EasyMock.replay(mockScienceProjectDao);
        AttachmentVo att = scienceProjectService.loadProjectFilesData(studentId,toTestID,formID);
View Full Code Here

    public void testLoadAllScienceProjectsSponsoredByOneProjects(){
        int toTestID = 2;
        SeteUser p = new SeteUser();
        p.setId(toTestID);
        List<ScienceProject> projects = new ArrayList<ScienceProject>();
        ScienceProject proj = new ScienceProject();
        projects.add(proj);
        ScienceProjectCategoryType t = new ScienceProjectCategoryType();
        t.setLabel("");
        Set<SeteUser> students = new HashSet<SeteUser>();
        SeteUser stud = new SeteUser();
        stud.setFirstName("");
        stud.setLastName("");
        students.add(stud);
        proj.setStudents(students);
        proj.setScienceProjectCategoryType(t);
        EasyMock.expect(mockScienceProjectDao.findSponsoredBy(p)).andReturn(projects);
        EasyMock.replay(mockScienceProjectDao);
        EasyMock.expect(mockUserDao.findById(new Integer(toTestID))).andReturn(p);
        EasyMock.replay(mockUserDao);
        List<ScienceProjectVo> att = scienceProjectService.loadAllScienceProjectsSponsoredBy(toTestID);
View Full Code Here

        return projectVos;
    }
   
    public ScienceProjectVo loadScienceProject(String projectId) {
        ScienceProject sp = projectDao.findById(projectId);
        ScienceProjectVo spvo = new ScienceProjectVo();
        List<String> students = new ArrayList<String>();
       
        spvo.setId(sp.getId());
        spvo.setName(sp.getName());
        spvo.setDescription(sp.getDescription());
        spvo.setExhibitId(sp.getExhibitIdentifier());
        spvo.setCategory(sp.getScienceProjectCategoryType().getLabel());

        for(SeteUser u : sp.getStudents()) {
            students.add(u.getFirstName() + " " + u.getLastName());
        }
        spvo.setStudents(students);

        if(sp.getSponsor() != null) {
            spvo.setSponsor(sp.getSponsor().getFirstName() + " " + sp.getSponsor().getLastName());
        }
        if(sp.getScienceProjectStatusType()!=null){
          spvo.setStatus(sp.getScienceProjectStatusType().getLabel());
        }
        if(sp.getAwards()!=null){
        Set<Award> awards = sp.getAwards();
        spvo.setAwards(awards);
        }
        return spvo;
    }
View Full Code Here

                Double.valueOf(spvo.getProjectScore16())+
                Double.valueOf(spvo.getProjectScore17())+
                Double.valueOf(spvo.getProjectScore18())+
                Double.valueOf(spvo.getProjectScore19());
  
    ScienceProject sp = projectDao.findById(spvo.getProjectId());
   
    if(ScienceProjectStatusType.Key.SCORINGINPROGRESS_KEY.equals(sp.getScienceProjectStatusType().getKey())) {
      Calendar cal = Calendar.getInstance()
      long timeDiff = cal.getTime().getTime() - sp.getStatusChangedOn().getTime() -300000;
      if(!spvo.getScorer().equalsIgnoreCase(sp.getStatusChangedBy().toString())){
        if(timeDiff>0){
          // 5 minutes over for the scorer who set the scoring in progress, now this user can set it to in progress
          sp.setScienceProjectStatusType(ScienceProjectStatusType.forKey(ScienceProjectStatusType.Key.SCORINGINPROGRESS_KEY));
          sp.setStatusChangedBy(Integer.valueOf(spvo.getScorer()));
        }
        else{
          BusinessRuleException bre = new BusinessRuleException();
          bre.addCodedMessage("scienceProject.error.scoringInProgress",new String[]{sp.getName()});
          throw bre;
        }
      }
    } 
     
    if(sp.getScore()!= null){
      sp.getScore().setScore(scoreValue);
    }
    else{
      Score score = new Score();
      score.setScore(scoreValue);
      projectDao.saveProjectScore(score);
      sp.setScore(score);
    }
   
    AwardType awtp = TypeUtil.forKey(AwardType.class, spvo.getAwardType());
    Award aw = new Award();
    aw.setAwardType(awtp);
    projectDao.saveAward(aw);
    Set<Award> awards = sp.getAwards();
    TreeSet<Award> noDups = new TreeSet<Award>(new Comparator<Award>() {
       
          public int compare(Award o1, Award o2) {
              return o1.getAwardType().getKey().compareTo(o2.getAwardType().getKey());
          }
     
      });
    noDups.addAll(awards);
      noDups.add(aw);
    sp.setAwards(noDups);
    ScienceProjectStatusType spstScored = ScienceProjectStatusType.forKey(ScienceProjectStatusType.Key.SCORED_KEY);
    sp.setScienceProjectStatusType(spstScored);
    sp.setStatusChangedBy(Integer.valueOf(spvo.getScorer()));
    projectDao.saveScienceProject(sp);
               
   }
View Full Code Here

TOP

Related Classes of org.sete.domain.ScienceProject

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.