Package org.sete.domain

Examples of org.sete.domain.ScienceProject


  this.projectDao = projectDao;
}


public void updateProjectStatus(String projectId, String scorer, ScienceProjectStatusType spst) {
  ScienceProject sp = projectDao.findById(projectId);
  
    if(!ScienceProjectStatusType.Key.SCORINGINPROGRESS_KEY.equals(sp.getScienceProjectStatusType().getKey())) {
      sp.setScienceProjectStatusType(spst);
      sp.setStatusChangedBy(Integer.valueOf(scorer));
      projectDao.saveScienceProject(sp);
  }
    else{
      Calendar cal = Calendar.getInstance();
      long timeDiff = cal.getTime().getTime() - sp.getStatusChangedOn().getTime() -300000;
      if(!scorer.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(scorer));
        }
        else{
          BusinessRuleException bre = new BusinessRuleException();
          bre.addCodedMessage("scienceProject.error.scoringInProgress",new String[]{sp.getName()});
          throw bre;
        }
      }
    }   
}
View Full Code Here


      }
    }   
}

public void refreshProjectStatus(String projectId){
  ScienceProject sp = projectDao.findById(projectId);
  Calendar cal = Calendar.getInstance();
  if(sp.getScienceProjectStatusType()!=null) {
        if(ScienceProjectStatusType.Key.SCORINGINPROGRESS_KEY.equals(sp.getScienceProjectStatusType().getKey())) {
                long timeDiff = cal.getTime().getTime() - sp.getStatusChangedOn().getTime() -300000;
                if(timeDiff>0){
                  // 5 minutes over for the scorer who set the scoring in progress
                    sp.setScienceProjectStatusType(ScienceProjectStatusType.forKey(ScienceProjectStatusType.Key.SCORINGINCOMPLETE_KEY));
                    projectDao.saveScienceProject(sp);
                }
           
        }
  }
View Full Code Here

        }
  }
}

public void submitProjectToAward(ScoreProjectVo spvo) {
      ScienceProject sp = projectDao.findById(spvo.getProjectId());
      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) {
            // TODO Auto-generated method stub
            return o1.getAwardType().getKey().compareTo(o2.getAwardType().getKey());
        }
   
    });
      noDups.addAll(awards);
      noDups.add(aw);
      sp.setAwards(noDups);
      projectDao.saveScienceProject(sp);
}
View Full Code Here

      sp.setAwards(noDups);
      projectDao.saveScienceProject(sp);
}

public boolean deleteProjectAward(String projectId, String awardKey) {
    ScienceProject sp = projectDao.findById(projectId);
    Set<Award> awards = sp.getAwards();
    for(Award a : awards){
        if(a.getAwardType().getKey().equals(awardKey)){
            awards.remove(a);
            sp.setAwards(awards);
            projectDao.saveScienceProject(sp);
            return true;
        }
    }
    return false;
View Full Code Here

    /**
     * Tests that a non-null and size 1 list is returned for a project with 1 form.
     */
    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.
     */
    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

     */
    public void testLoadProjectFilesDataForBadProject(){
       
        int badID = 1;
        int toTestID = 2;
        ScienceProject p = new ScienceProject();
        p.setId(badID);
        List<ScienceProject> l = new ArrayList<ScienceProject>();
        l.add(p);
        EasyMock.expect(mockScienceProjectDao.getAllScienceProjects()).andReturn(l);
        EasyMock.replay(mockScienceProjectDao);
        AttachmentVo att = scienceProjectService.loadProjectFilesData(toTestID,0);
View Full Code Here

     */
    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);
        List<ScienceProject> l = new ArrayList<ScienceProject>();
        l.add(p);
        EasyMock.expect(mockScienceProjectDao.getAllScienceProjects()).andReturn(l);
        EasyMock.replay(mockScienceProjectDao);
        AttachmentVo att = scienceProjectService.loadProjectFilesData(toTestID,badID);
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);
        List<ScienceProject> l = new ArrayList<ScienceProject>();
        l.add(p);
        EasyMock.expect(mockScienceProjectDao.getAllScienceProjects()).andReturn(l);
        EasyMock.replay(mockScienceProjectDao);
        AttachmentVo att = scienceProjectService.loadProjectFilesData(toTestID,formID);
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);
        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(toTestID,formID);
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.