Package org.sete.domain

Examples of org.sete.domain.ScienceProject


    if(userId == null){
      throw new IllegalArgumentException("UserId cannot be null.");     
    }
    else{
      SeteUser student = userDao.findById(userId);
      ScienceProject p = projectDao.findBy(student);
            if(p == null){
                return null;
            }
      ScienceProjectVo vo = new ScienceProjectVo();
      List<AttachmentVo> files = new ArrayList<AttachmentVo>();
      List<String> partner = new ArrayList<String>();
            vo.setId(p.getId());
      vo.setName(p.getName());
      vo.setDescription(p.getDescription());
      vo.setCategory(p.getScienceProjectCategoryType().getLabel());
      vo.setSponsor(p.getSponsor().getFirstName()+" "+p.getSponsor().getLastName());
           
      for(Attachment a: p.getForms()){
                AttachmentVo avo = new AttachmentVo();
                avo.setId(a.getId());
                avo.setType(a.getType());
                files.add(avo);
            }
      vo.setFiles(files);
     
            for(SeteUser a: p.getStudents()){
              //add the Student Partner to the ProjectVo
                if(a.getId() != userId){                
                  partner.add(a.getFirstName()+" "+a.getLastName());
                }
            }
View Full Code Here


 
  //determine the student uploading the file
  SeteUser student = userDao.findById(ufvo.getUserId());
 
  //get the student's project for update
  ScienceProject project = projectDao.findBy(student);
 
  /*Get the existing project forms,
   * iterate and remove the AttachmentType being added if it exists
   * to avoid duplicate documents of the same AttachmentType.
   */
  Set<Attachment> forms =  project.getForms();
  for(Iterator <Attachment> it = forms.iterator(); it.hasNext();){   
    if(key.equalsIgnoreCase(it.next().getType().getKey())){
      it.remove();     
    }   
  }
  forms.add(att);
  project.setForms(forms);
  //update the Science Project with the new/updated Attachment
  projectDao.saveScienceProject(project);

}
View Full Code Here

     *  Tests that a non-null and empty list is returned for a project key that does not exist.
     */
    public void testLoadProjectFilesForBadProject(){
        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);
        List<AttachmentVo> att = scienceProjectService.loadAllProjectFilesFor(toTestID);
View Full Code Here

    /**
     * Tests that a non-null and empty list is returned for a project without forms.
     */
    public void testLoadProjectFilesForProjectWithoutFiles(){
        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);
        List<AttachmentVo> att = scienceProjectService.loadAllProjectFilesFor(toTestID);
View Full Code Here

            }

            students.add(userDao.findById(Integer.valueOf(vo.getPartner())));
        }

        ScienceProject sp = new ScienceProject();
        sp.setSponsor(userDao.findById(Integer.valueOf(vo.getSponsor())));
        sp.setStudents(students);
        sp.setName(vo.getProjectName());
        sp.setDescription(vo.getDescription());
        sp.setScienceProjectCategoryType(TypeUtil.forKey(ScienceProjectCategoryType.class,
                                                         vo.getCategory()));
        sp.setScienceProjectStatusType(TypeUtil.forKey(ScienceProjectStatusType.class,
                                                       ScienceProjectStatusType.REGISTERED_KEY));

        projectDao.saveScienceProject(sp);
    }
View Full Code Here

              throw bre;
       }
    }

    public CreateScienceProjectVo loadScienceProject(String projId) {
      ScienceProject sp = projectDao.findById(projId);
      CreateScienceProjectVo spvo = new CreateScienceProjectVo();
     
      if(sp != null){
       
        spvo.setProjId(sp.getIdAsString());
        spvo.setName(sp.getName());
        spvo.setDescription(sp.getDescription());
        spvo.setCategory(sp.getScienceProjectCategoryType().getKey());
       
        int i = 0;
        for(SeteUser su : sp.getStudents()){
          if((i % 2) == 0){
            spvo.setCreator(su.getIdAsString());
          }else{
            spvo.setPartner(su.getIdAsString());
          }
          i++;
        }
       
        if(sp.getSponsor() != null){
          spvo.setSponsor(sp.getSponsor().getIdAsString());
        }
      }
     
      return spvo;
    }
View Full Code Here

      throw new IllegalArgumentException("UserId cannot be null.");     
    }
    else{
      System.out.println("\nUser ID is: "+userId+"\n");
      SeteUser student = userDao.findById(userId);
      ScienceProject p = projectDao.findBy(student);
            if(p == null){
                return null;
            }
      ScienceProjectVo vo = new ScienceProjectVo();
      List<AttachmentVo> files = new ArrayList<AttachmentVo>();
      List<String> partner = new ArrayList<String>();
            vo.setId(p.getId());
      vo.setName(p.getName());
      vo.setDescription(p.getDescription());
      vo.setCategory(p.getScienceProjectCategoryType().getLabel());
      vo.setSponsor(p.getSponsor().getFirstName()+" "+p.getSponsor().getLastName());
           
      if(p.getForms() != null) {
        for(Attachment a: p.getForms()){
                  AttachmentVo avo = new AttachmentVo();
                  avo.setId(a.getId());
                  avo.setType(a.getType());
                  files.add(avo);
              }
      }
      vo.setFiles(files);
     
            for(SeteUser a: p.getStudents()){
              //add the Student Partner to the ProjectVo
                if(a.getId() != userId){                
                  partner.add(a.getFirstName()+" "+a.getLastName());
                }
            }
View Full Code Here

 
  //determine the student uploading the file
  SeteUser student = userDao.findById(ufvo.getUserId());
 
  //get the student's project for update
  ScienceProject project = projectDao.findBy(student);
 
  /*Get the existing project forms,
   * iterate and remove the AttachmentType being added if it exists
   * to avoid duplicate documents of the same AttachmentType.
   */
  Set<Attachment> forms =  project.getForms();
  for(Iterator <Attachment> it = forms.iterator(); it.hasNext();){   
    if(key.equalsIgnoreCase(it.next().getType().getKey())){
      it.remove();     
    }   
  }
  forms.add(att);
  project.setForms(forms);
  //update the Science Project with the new/updated Attachment
  projectDao.saveScienceProject(project);

}
View Full Code Here

     */
    @Test
    public void testLoadProjectFilesForBadProject(){
        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);
        List<AttachmentVo> att = scienceProjectService.loadAllProjectFilesFor(toTestID);
View Full Code Here

     * Tests that a non-null and empty list is returned for a project without forms.
     */
    @Test
    public void testLoadProjectFilesForProjectWithoutFiles(){
        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);
        List<AttachmentVo> att = scienceProjectService.loadAllProjectFilesFor(toTestID);
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.