Examples of Study


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

    Set<PhyloTree> phyloTreeSet = getResults();
    if ( phyloTreeSet != null ) {

      // for each tree in the result set we need to traverse its associated study
      for ( PhyloTree phyloTree : phyloTreeSet ) {
        Study study = phyloTree.getStudy();
       
        // need to resurrect the study, otherwise we get a LazyInitializationException
        Study resurrectedStudy = getStudyService().resurrect(study);
       
        if ( resurrectedStudy != null ) {
          Collection<AnalysisStep> analysisStepCollection = resurrectedStudy.getAnalysisSteps();
         
          // for the study we need to iterate over all analysis steps
          for ( AnalysisStep analysisStep : analysisStepCollection ) {
            Collection<AnalyzedData> analyzedDataCollection = analysisStep.getDataSetReadOnly();
            boolean treeIsOutput = false;
View Full Code Here

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

    Map<String,Study> nexusFileStudy = new HashMap<String,Study> ();

    warn("Searching studies for nexus files");
    int nStudies = 0;
    for (TBPersistable obj : ContextManager.getStudyHome().findAll(Study.class)) {
      Study s = (Study) obj;
 
      Map<String,String> studyNexusFile = s.getNexusFiles();
      for (String fileName : studyNexusFile.keySet()) {
        if (nexusFileStudy.containsKey(fileName)) {
          nexusFileStudy.remove(fileName);
          warn("Nexus file name " + fileName + " is not unique; ignoring");
        } else {
          nexusFileStudy.put(fileName, s);
        }
      }
      nStudies++;
      if (nStudies % 100 == 0) {
        warn(nStudies + " studies, " + nexusFileStudy.size() + " nexus files");
      }
    }
       
    for (TBPersistable obj : ContextManager.getStudyHome().findAll(Matrix.class)) {
      Matrix m = (Matrix) obj;
      String nexusFileName = m.getNexusFileName();
      Transaction trans = me.beginTransaction();

      if (! nexusFileStudy.containsKey(nexusFileName)) continue;
      Study oldStudy = nexusFileStudy.get(nexusFileName);
      Study newStudy = m.getStudy()
      if (newStudy == null || oldStudy == null) continue;
     
      newStudy.getNexusFiles().put(nexusFileName, oldStudy.getNexusFiles().remove(nexusFileName));
      trans.commit();
      warn("Repatriated nexus file " + nexusFileName + " from study " + oldStudy.getId() + " to " + newStudy.getId());
    }
   
    for (TBPersistable obj : ContextManager.getStudyHome().findAll(PhyloTree.class)) {
      PhyloTree t = (PhyloTree) obj;
      String nexusFileName = t.getNexusFileName();
      Transaction trans = me.beginTransaction();

      if (! nexusFileStudy.containsKey(nexusFileName)) continue;
      Study oldStudy = nexusFileStudy.get(nexusFileName);
      Study newStudy = t.getStudy();   
      if (newStudy == null || oldStudy == null) continue;
   
      newStudy.getNexusFiles().put(nexusFileName, oldStudy.getNexusFiles().remove(nexusFileName));
      trans.commit();
      warn("Repatriated nexus file " + nexusFileName + " from study " + oldStudy.getId() + " to " + newStudy.getId());
    }
  }
View Full Code Here

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

    * @return the submission
    * @author mjd 20080929
    */
    @Transient
    public Submission getSubmission() {
      Study s = getStudy();
      return s == null ? null : s.getSubmission();
    }
View Full Code Here

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

    // create a new study. Initialize bi-directional relationships.
    StudyStatus initStatus = getStudyStatusHome().findStatusInProgress();

    if (pStudy == null) {
      pStudy = new Study();
    }
    pStudy.setStudyStatus(initStatus);
    pStudy.setLastModifiedDate(new Date());
    sub.setStudy(pStudy);
    pStudy.setSubmission(sub);
View Full Code Here

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

    }

    // FIXME: rework the delete logic, make it faster!!

    // first delete all analyzed data before deleting trees:
    Study s = pSubmission.getStudy();

    getAnalysisService().deleteAnalyses(s);

    deleteSubmittedData(pSubmission);

    if (s != null) {
      // getStudyHome().refresh(s);

      // for now only delete in progress study until we have a better
      // security handling:

      /*
       * if (!s.isInProgress()) { String msg = "This method deletes only in progress study
       * until a better security is in place."; throw new IllegalArgumentException(msg); }
       */

      // Cascade delete:
      // * study
      // * matrices,
      // * trees
      // * taxon labels
      // getMatrixHome().delete(new
      // ArrayList<Matrix>(pSubmission.getSubmittedMatricesReadOnly()));
      // getPhyloTreeHome().deleteTreeBlocks(
      // new ArrayList<TreeBlock>(pSubmission.getSubmittedTreeBlocksReadOnly()));
      //
      // pSubmission.clearSubmittedData();
      // // taxon labels need to be deleted last, after everyone referencing to them
      // // are gone
      // getTaxonLabelHome().delete(pSubmission.getSubmittedTaxonLabelsReadOnly());
      //
      // manage bi-directional relationships:
      // pStudy.getSubmitter().removeSubmission(pSubmission);
      // Note: ---important: the delete order is important---
      // Cascade delete
      // all the analyses
      // submission
      // all taxonLabelSet
      // all study specific taxonlabels
      // citation
      // getAnalysisService().deleteAnalyses(pStudy.getAnalyses());
      // getAnalysisService().deleteAnalyses(pStudy.getAnalysesReadOnly());
      // Study specific taxonlabels: handled by submission.delete.
      // all taxonLabelSet
      getStudyHome().deleteAll(s.getTaxonLabelSets());
      s.getTaxonLabelSets().clear();

      // manage bi-directional relationships:
      if (pSubmission.getSubmitter() != null) {
        pSubmission.getSubmitter().removeSubmission(pSubmission);
      }

      getSubmissionHome().deletePersist(pSubmission);

      // need to delete study after deleting the submission.

      // have to after delete all taxonLabel sets:
      getDomainHome().flush();
      getTaxonLabelHome().deleteByStudy(s);

      Citation c = s.getCitation();

      getStudyHome().deletePersist(s);

      // Notes: must delete study first before delete the citation, not-null constraint!
      if (c != null) {
View Full Code Here

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

public class NexmlSerializationTest extends AbstractDAOTest  {
  private TaxonLabelHome mTaxonLabelHome;

  public void testSerializeStudy() {
    long studyId = 1787;
    Study study = (Study)loadObject(Study.class, studyId);
    Document doc = DocumentFactory.safeCreateDocument();
    NexmlDocumentWriter conv = new NexmlDocumentWriter(study,getTaxonLabelHome(),doc);
    String xml = conv.fromTreeBaseToXml(study).getXmlString();   
    System.out.println(xml);
    Assert.assertNotNull(xml);
View Full Code Here

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

    if (! opts.getBoolOpt("m")) {
      for (TBPersistable tbM : ContextManager.getMatrixHome().findAll(Matrix.class)) {
        Transaction tr = rt.beginTransaction();
        Matrix m = (Matrix) tbM;
        Study s = m.getStudy();
        tlService.updateStudyForAllLabels(m, s);
        tr.commit();
        System.err.println("Repatriated labels of matrix " + m.getId());
      }
    }

    if (! opts.getBoolOpt("t")) {
      for (TBPersistable tbT : ContextManager.getPhyloTreeHome().findAll(PhyloTree.class)) {
        Transaction tr = rt.beginTransaction();
        PhyloTree t = (PhyloTree) tbT;
        Study s = t.getStudy();
        System.err.print("Repatriating labels of tree " + t.getId() + "...");
        tlService.updateStudyForAllLabels(t, s);
        tr.commit();
        System.err.println(" Done.");
      }
View Full Code Here

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

    StudyStatus inprogress = getStudyStatusHome().findStatusInProgress();

    Citation c = new ArticleCitation();
    c.setTitle(newName);

    Study s = new Study();
    s.setName(newName);
    s.setStudyStatus(inprogress);
    s.setCitation(c);
    c.setStudy(s);

    Analysis a1 = new Analysis();
    a1.setName("1 " + newName);
    Analysis a2 = new Analysis();
    a2.setName("2 " + newName);
    s.addAnalysis(a1);
    s.addAnalysis(a2);

    getStudyHome().store(s);

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

    Long studyID = s.getId();
    Long citationID = c.getId();
    Long a1ID = a1.getId();
    Long a2ID = a2.getId();

    logger.info("study created: " + s.getName() + "id = " + studyID);
    logger.info("citation created: " + c.getTitle() + "id = " + citationID);
    logger.info("2 analyses created: id= " + a1ID + ", " + a2ID);
    assertTrue("need to return Analysis ID.", a1.getId() != null && a2.getId() != null);

    // 2. verify
    String sqlStr = "select count(*) from analysis where study_id=" + s.getId();
    int count = jdbcTemplate.queryForInt(sqlStr);
    assertTrue(count == 2);

    // 3. delete

View Full Code Here

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

    }
   
    long studyId = 794; // this study seems to have character sets
   
    // this is the full study as it is stored by the database
    Study tbStudy = (Study)loadObject(Study.class, studyId);

    // these are the character state matrices that are part of the study
    Set<org.cipres.treebase.domain.matrix.Matrix> tbMatrices = tbStudy.getMatrices();

    // this is an object representation of a NeXML document
    Document nexDoc = DocumentFactory.safeCreateDocument();
   
    // the converter populates the NeXML document with the contents of the treebase study
View Full Code Here

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

    }
   
    long studyId = 586; //this study is known to output an empty Nexml matrix
   
    // this is the full study as it is stored by the database
    Study tbStudy = (Study)loadObject(Study.class, studyId);

    // these are the character state matrices that are part of the study
    Set<org.cipres.treebase.domain.matrix.Matrix> tbMatrices = tbStudy.getMatrices();
   

    // this is an object representation of a NeXML document
    Document nexDoc = DocumentFactory.safeCreateDocument();
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.