Package org.cipres.treebase.domain.study

Examples of org.cipres.treebase.domain.study.Study


    Collection<Study> studies = new LinkedList<Study> ();
   
    if (args.length > 0) {
      for (String arg : args) {
        Long id = Long.valueOf(arg);
        Study s = me.getStudyHome().findPersistedObjectByID(Study.class, id);
        if (s == null) {
          warn("No study with ID " + arg + "; skipping");
          continue;
        }
        studies.add(s);
View Full Code Here


    String newName = testName + " test " + Math.random();

    User submitter = (User) loadObject(User.class);
    assertTrue("Empty user table.", submitter != null);

    Study s = new Study();
    s.setName(newName);

    Submission sub = getFixture().createSubmission(submitter, s);

    getSubmissionHome().store(s);

    // force commit immediately, important:
    setComplete();
    endTransaction();

    logger.info("study created: " + s.getName() + "id = " + s.getId());
    logger.info("submission created: " + "id = " + sub.getId());

    onSetUp();

    // 2. add a nexus file:
    // String path = "/TestNexusFile.nex";
    String path = "/M12c11.nex";
    File nexusFile = new File(getClass().getResource(path).toURI());
    Collection<File> files = new ArrayList<File>();
    files.add(nexusFile);

    getSubmissionHome().refresh(sub);
    getFixture().addNexusFiles(sub, files, null);
    getStudyService().addNexusFiles(s, files);

    // force commit immediately, important:
    setComplete();
    endTransaction();

    logger.info("files added: " + s.getName() + "id = " + s.getId());

    onSetUp();

    // 3. verify
    String studySQL = "select count(*) from Study where study_id=" + s.getId();
    String subSQL = "select count(*) from Submission where submission_id=" + sub.getId();
    int count = jdbcTemplate.queryForInt(studySQL);
    assertTrue(count == 1);

    count = jdbcTemplate.queryForInt(subSQL);
    assertTrue(count == 1);

    logger.info(" verified: " + s.getName() + "id = " + s.getId());

    // 4. delete: delete submission:
    // after add Nexus files, sub is outdated:
    hibernateTemplate.refresh(sub);

View Full Code Here

    if (logger.isInfoEnabled()) {
      logger.info("\n\t\tRunning Test: " + testName);
    }

    // 1. create a new submission:
    Study s = getTestStudy();
    Submission sub = s.getSubmission();

    getFixture().deleteSubmittedData(sub);

    setComplete();
    endTransaction();
View Full Code Here

    Set<Matrix> matrixSet = getResults();
    if ( matrixSet != null ) {

      // for each matrix in the result set we need to traverse the associated study
      for ( Matrix matrix : matrixSet ) {
        Study study = matrix.getStudy();
       
        // need to resurrect the study, otherwise we get a LazyInitializationException
        Study resurrectedStudy = getStudyService().resurrect(study);
        Collection<AnalysisStep> analysisStepCollection = resurrectedStudy.getAnalysisSteps();
       
        // for that study we need to iterate over all analysis steps
        for ( AnalysisStep analysisStep : analysisStepCollection ) {
          Collection<AnalyzedData> analyzedDataCollection = analysisStep.getDataSetReadOnly();
          boolean matrixIsInput = false;
View Full Code Here

   * @param studyService
   * @param tb1StudyId
   * @return
   */
  private Study findStudy(String tb1StudyId) {
    Study study = null;
    Iterator<Study> studyIterator = getStudyService().findByTBStudyID(tb1StudyId).iterator();
    if ( studyIterator.hasNext() ) {
      study = studyIterator.next();
    }                     
    return study;
View Full Code Here

      if ( fields[0].startsWith("*") ) {
        warn("Line is commented out, skipping");
        return;
      }
      String tb1StudyId = fields[18];
      Study study = findStudy(tb1StudyId);
      if ( study == null ) {
        warn("No such study (TB1 accession): " + tb1StudyId);
        return;
      }
      Citation citationStub = study.getCitation();
      Citation citation = null;
      if ( citationStub != null ) {
        warn("Study "+tb1StudyId+" already associated with a citation "+citationStub.getId());
//         In general, citation stubs already exist for each study. However, these
//         stubs are all of type ArticleCitation, which means that, in the case of
//         BookCitations (for example) we'll get a class cast exception when we try
//         to cast the citation to a book in order to set the editors.
        //getCitationService().deleteCitation(citationStub);
        //citation = createCitation(fields[0]);
        citation = citationStub;
      }   
      else {
        warn("No citation stub association with study (TB1 accession) " + tb1StudyId);
        citation = createCitation(fields[0]);
      }
      if ( citation == null ) {
        warn("No citation was instantiated, skipping this record (TB1 accession) "+tb1StudyId);
        return;
      }
      for ( int i = 0; i < fields.length; i++ ) {
        if ( ! TreebaseUtil.isEmpty(fields[i]) ) {
          switch(i) {
            case 0: citation.setCitationType(fields[i]); break;
            case 1: setAuthors(citation,fields[i],personHome,false); break;
            case 2: citation.setPublishYear(Integer.parseInt(fields[i])); break;
            case 3: if ( citation instanceof BookCitation ) {
              ((BookCitation)citation).setBookTitle(fields[i]);
              citation.setTitle(fields[i]);
            } else {
              citation.setTitle(fields[i]);
            } break;
            case 4: setAuthors(citation,fields[i],personHome,true); break;
            case 5: if ( citation instanceof ArticleCitation ) {
              ((ArticleCitation)citation).setJournal(fields[i]);
              warn("Setting journal name "+fields[i]);
            } else {
              warn("Setting book title "+fields[i]);
              ((BookCitation)citation).setBookTitle(fields[i]);
            } break;
            case 6: if ( citation instanceof BookCitation ) {                          
              ((BookCitation)citation).setCity(fields[i]);
            } else {
              warn("Record has an entry for city, yet it's not a book (TB1 accession) "+tb1StudyId);
            } break;
            case 7: if ( citation instanceof BookCitation ) {                          
              ((BookCitation)citation).setPublisher(fields[i]);
            } else {
              warn("Record has an entry for publisher, yet it's not a book (TB1 accession) "+tb1StudyId);
            } break;
            case 8: if ( citation instanceof ArticleCitation ) {
              ((ArticleCitation)citation).setVolume(fields[i]);
            } else {
              warn("Record has an entry for volume, yet it's not an article (TB1 accession) "+tb1StudyId);
            } break;
            case 10: if ( citation instanceof ArticleCitation ) {
              ((ArticleCitation)citation).setIssue(fields[i]);
            } else {
              warn("Record has an entry for issue, yet it's not an article (TB1 accession)"+tb1StudyId);
            } break;
            case 11: citation.setPages(fields[i]); break;
            case 15: if ( fields[i].equals("in press") ) {
              citation.setCitationStatusDescription(CitationStatus.INPRESS);                         
            }
            case 16: citation.setKeywords(fields[i]); break;
            case 17: citation.setAbstract(checkAbstractLength(fields[i])); break;
            case 18: citation.setStudy(study); break;
            case 19: citation.setURL(fields[i]); break;
            case 20: citation.setDoi(fields[i]); break;
            default: warn("Empty field expected, found: " + fields[i] + " for line: " + /*was: line */fields.toString()); break;
          }
        }
      }
      warn("Storing citation "+citation.getId());
      warn(citation.getAuthorsCitationStyleWithoutHtml());  
      if ( ! testMode ) {
          study.setCitation(citation);
          getStudyService().update(study);
          Long id = study.getCitation().getId();
          warn("Stored citation at ID " + id);
      }
      else {
        warn("Test run, not saving");
      }   
View Full Code Here

          if ( fields[0].startsWith("*") ) {
            warn("Line is commented out, skipping");
            continue LINE;
          }
          String tb1StudyId = fields[18];
          Study study = findStudy(tb1StudyId);
          if ( study == null ) {
            warn("No such study (TB1 accession): " + tb1StudyId);
            continue LINE;
          }
          Citation citationStub = study.getCitation();
          Citation citation = null;
          if ( citationStub != null ) {
            warn("Study "+tb1StudyId+" already associated with a citation "+citationStub.getId());
//             In general, citation stubs already exist for each study. However, these
//             stubs are all of type ArticleCitation, which means that, in the case of
//             BookCitations (for example) we'll get a class cast exception when we try
//             to cast the citation to a book in order to set the editors.
            //getCitationService().deleteCitation(citationStub);
            //citation = createCitation(fields[0]);
            citation = citationStub;
          }   
          else {
            warn("No citation stub association with study (TB1 accession) " + tb1StudyId);
            citation = createCitation(fields[0]);
          }
          if ( citation == null ) {
            warn("No citation was instantiated, skipping this record (TB1 accession) "+tb1StudyId);
            continue LINE;
          }
          for ( int i = 0; i < fields.length; i++ ) {
            if ( ! TreebaseUtil.isEmpty(fields[i]) ) {
              switch(i) {
                case 0: citation.setCitationType(fields[i]); break;
                case 1: setAuthors(citation,fields[i],personHome,false); break;
                case 2: citation.setPublishYear(Integer.parseInt(fields[i])); break;
                case 3: if ( citation instanceof BookCitation ) {
                  ((BookCitation)citation).setBookTitle(fields[i]);
                  citation.setTitle(fields[i]);
                } else {
                  citation.setTitle(fields[i]);
                } break;
                case 4: setAuthors(citation,fields[i],personHome,true); break;
                case 5: if ( citation instanceof ArticleCitation ) {
                  ((ArticleCitation)citation).setJournal(fields[i]);
                  warn("Setting journal name "+fields[i]);
                } else {
                  warn("Setting book title "+fields[i]);
                  ((BookCitation)citation).setBookTitle(fields[i]);
                } break;
                case 6: if ( citation instanceof BookCitation ) {                          
                  ((BookCitation)citation).setCity(fields[i]);
                } else {
                  warn("Record has an entry for city, yet it's not a book (TB1 accession) "+tb1StudyId);
                } break;
                case 7: if ( citation instanceof BookCitation ) {                          
                  ((BookCitation)citation).setPublisher(fields[i]);
                } else {
                  warn("Record has an entry for publisher, yet it's not a book (TB1 accession) "+tb1StudyId);
                } break;
                case 8: if ( citation instanceof ArticleCitation ) {
                  ((ArticleCitation)citation).setVolume(fields[i]);
                } else {
                  warn("Record has an entry for volume, yet it's not an article (TB1 accession) "+tb1StudyId);
                } break;
                case 10: if ( citation instanceof ArticleCitation ) {
                  ((ArticleCitation)citation).setIssue(fields[i]);
                } else {
                  warn("Record has an entry for issue, yet it's not an article (TB1 accession)"+tb1StudyId);
                } break;
                case 11: citation.setPages(fields[i]); break;
                case 15: if ( fields[i].equals("in press") ) {
                  citation.setCitationStatusDescription(CitationStatus.INPRESS);                         
                }
                case 16: citation.setKeywords(fields[i]); break;
                case 17: citation.setAbstract(checkAbstractLength(fields[i])); break;
                case 18: citation.setStudy(study); break;
                case 19: citation.setURL(fields[i]); break;
                case 20: citation.setDoi(fields[i]); break;
                default: warn("Empty field expected, found: " + fields[i] + " for line: " + line); break;
              }
            }
          }
          warn("Storing citation "+citation.getId());
          warn(citation.getAuthorsCitationStyleWithoutHtml());  
          if ( ! testMode ) {
            study.setCitation(citation);
            getStudyService().update(study);
            Long id = study.getCitation().getId();
            if ( id > maxId ) {
              maxId = id;
            }
            getCurrentSession().getTransaction().commit();
            getCurrentSession().beginTransaction();
View Full Code Here

    for ( int i = 0; i < maxId.intValue(); i++ ) {
      Long id = new Long(i);
      Citation citation = (Citation)getCitationHome().findPersistedObjectByID(Citation.class, id);
      //warn("Checking id "+id);
      if ( citation != null ) {
        Study study = citation.getStudy();
        if ( study == null ) {
          warn("Removing orphan: "+citation.getId()+" "+citation.getAuthorsCitationStyleWithoutHtml());
          duplicates++;
          getCitationService().deleteCitation(citation);
        }
        else if ( study.getCitation().getId() != citation.getId() ) {
          warn("Orphan: "+citation.getId()+" "+citation.getAuthorsCitationStyle());
        }
        else {
          warn("Makes sense: citation "+citation.getId()+" -study-> "+study.getId());
        }
      }
    }
    warn("I removed "+duplicates+" orphans");
  }
View Full Code Here

      }

    }

    // Third start a new transaction, use Hibernate to store the original nexus files.
    Study study = pSubmission.getStudy();
    getStudyService().addNexusFiles(study, pNexusFiles);
   
    if (LOGGER.isDebugEnabled()) {
      long timeEnd = System.currentTimeMillis();
      LOGGER.debug("total time=" + (timeEnd - timeStart) / 1000); //$NON-NLS-1$
View Full Code Here

  private NexusDataSet addNexusFile(Submission pSubmission, File pNexusFile) {

    // better to refresh:
    Submission sub = update(pSubmission);

    Study study = sub.getStudy();

    NexusDataSet data = getNexusService().parseNexus(study, pNexusFile);

    if (data != null) {
View Full Code Here

TOP

Related Classes of org.cipres.treebase.domain.study.Study

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.