Package org.cipres.treebase.domain.matrix

Examples of org.cipres.treebase.domain.matrix.Matrix


    long matrixId = jdbcTemplate.queryForLong(matrixStr);
    logger.info("matrix id: " + matrixId);
    assertTrue(matrixId > 0);

    // 2. query
    Matrix m = (Matrix) loadObject(Matrix.class, matrixId);
    assertTrue(m != null);

    Collection<AnalyzedData> data = getFixture().findByMatrix(m);
    assertTrue(data != null && !data.isEmpty());

    // 3. verify
    long dataId = data.iterator().next().getId();
    String sqlStr = "select count(*) from analyzedData where AnalyzedData_id = " + dataId
      + " and matrix_id = " + m.getId();
    int count = jdbcTemplate.queryForInt(sqlStr);
    assertTrue(count > 0);

    if (logger.isInfoEnabled()) {
      logger.info(testName + " verified.");
View Full Code Here


    }
 
    // Matrices
    NexmlMatrixReader nmc = new NexmlMatrixReader(pStudy,getTaxonLabelHome(),document);
    for ( org.nexml.model.Matrix<?> xmlMatrix : document.getMatrices() ) {
      Matrix tbMatrix = nmc.fromXmlToTreeBase(xmlMatrix);
      tbMatrix.setNexusFileName(pFile.getName());
      pDataSet.getMatrices().add(tbMatrix);
    }   
   
    // Trees
    NexmlTreeBlockReader ntbc = new NexmlTreeBlockReader(pStudy,getTaxonLabelHome(),document);
View Full Code Here

    long matrixId = jdbcTemplate.queryForLong(matrixStr);
    logger.info("matrix id: " + matrixId);
    assertTrue(matrixId > 0);

    // 2. query
    Matrix m = (Matrix) loadObject(Matrix.class, matrixId);
    assertTrue(m != null);

    Submission s = getFixture().findByMatrix(m);
    assertTrue(s != null);

    // 3. verify
    String sqlStr = "select count(*) from sub_matrix where submission_id = " + s.getId()
      + " and matrix_id = " + m.getId();
    int count = jdbcTemplate.queryForInt(sqlStr);
    assertTrue(count == 1);

    if (logger.isInfoEnabled()) {
      logger.info(testName + " verified.");
View Full Code Here

    tlh.delete(tl);
  }

  public void doDeleteMatrix(Long id) {
    MatrixHome mh = (MatrixHome) ContextManager.getBean("matrixHome");
    Matrix m = mh.findPersistedObjectByID(Matrix.class, id);
    if (m == null) return;
   
    if (m instanceof CharacterMatrix) {
      CharacterMatrix cm = (CharacterMatrix) m;
      mh.cascadeDeleteRows(cm.getRowsReadOnly());
View Full Code Here

    // getFixture().deleteSubmittedData(sub);
    //
    // setComplete();
    // endTransaction();

    Matrix m = getFixture().findPersistedObjectByID(Matrix.class, new Long(766));
    assertTrue(m != null);

    // 2. verify
    String matrixSQL = "select count(*) from matrix where matrix_id = " + m.getId();
    int count = jdbcTemplate.queryForInt(matrixSQL);
    assertTrue(count == 1);

    // 3. delete:
    getFixture().delete(m);
View Full Code Here

   * @param xmlMatrix
   * @return
   */
  public Matrix fromXmlToTreeBase(org.nexml.model.Matrix<?> xmlMatrix) {
    OTUs xmlOTUs = xmlMatrix.getOTUs();
    Matrix tbMatrix = null;
    TaxonLabelSet tbTaxa = null;
    Long tbTaxonLabelSetID = readTreeBaseID((Annotatable) xmlOTUs);
    if ( null != tbTaxonLabelSetID ) {
      tbTaxa = getTaxonLabelHome()
        .findPersistedObjectByID(TaxonLabelSet.class, tbTaxonLabelSetID);
    }   
    if ( xmlMatrix instanceof CategoricalMatrix ) {
      tbMatrix = fromXmlToTreeBase((CategoricalMatrix) xmlMatrix);
    }
    else if ( xmlMatrix instanceof org.nexml.model.ContinuousMatrix ) {
      tbMatrix = fromXmlToTreeBase((org.nexml.model.ContinuousMatrix) xmlMatrix);
    }
    if ( null != tbMatrix ) {
      attachTreeBaseID((Annotatable) xmlMatrix, tbMatrix,Matrix.class);
      if ( null != tbTaxa ) {
        tbMatrix.setTaxa(tbTaxa);
      }
      tbMatrix.setStudy(getStudy());
      tbMatrix.setTitle(xmlMatrix.getLabel());
      tbMatrix.setPublished(false);     
    }
    return tbMatrix;   
 
View Full Code Here

   */
  public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
    throws Exception {

    String matrix_id = ServletRequestUtils.getStringParameter(request, "id", null);
    Matrix matrix = mMatrixService.findByID(Long.parseLong(matrix_id));

    request.getSession().setAttribute("MATRIX_ID", matrix_id); // This session variable is used
    // for the cancel button in the
    // matrixRowSegmentList.jsp page

View Full Code Here

  }

  @Override
  protected String getFileContent(long objectId, HttpServletRequest request) {
    Study pStudy = ControllerUtil.findStudy(request, getStudyService());
    Matrix matrix = getMatrixService().findByID(objectId);
    TaxonLabelSet taxa = matrix.getTaxa();   
    if ( getFormat(request) == FORMAT_NEXML || getFormat(request) == FORMAT_RDF ) {
      NexusDataSet pNexusDataSet = new NexusDataSet();
      pNexusDataSet.getTaxonLabelSets().add(taxa);
      pNexusDataSet.getMatrices().add(matrix);
      return getNexmlService().serialize(pNexusDataSet,getDefaultProperties(request),matrix.getStudy());
    }
    /*else if ( getFormat(request) == FORMAT_RDF ) {
      NexusDataSet pNexusDataSet = new NexusDataSet();
      pNexusDataSet.getTaxonLabelSets().add(taxa);
      pNexusDataSet.getMatrices().add(matrix);
      return getRdfaService().serialize(pNexusDataSet,getDefaultProperties(request),matrix.getStudy());     
    }*/
    else { // FORMAT_NEXUS or none
      StringBuilder matrixContent = new StringBuilder();
      matrixContent.append("#NEXUS\n");
      TreebaseUtil.attachStudyHeader(pStudy, matrixContent);
      if (taxa != null) {
        //one taxon per line, no line number:
        taxa.buildNexusBlockTaxa(matrixContent, true, false);
      }
      matrix.generateNexusBlock(matrixContent);   
      return matrixContent.toString();     
    }
  }
View Full Code Here

    }
  }

  @Override
  protected Study getStudy(long objectId, HttpServletRequest request) {
    Matrix matrix = getMatrixService().findByID(objectId);
    return matrix.getStudy();
  }
View Full Code Here

   
    theMatrix = null;
    if (param.containsKey("matrixid"))
    {
      Long matrixID = getIDParam(param, "matrixid");
      Matrix m = getMatrixService().findByID(matrixID);
      if (m instanceof CharacterMatrix) {
        theMatrix = (CharacterMatrix) m;
      }
    }
   
View Full Code Here

TOP

Related Classes of org.cipres.treebase.domain.matrix.Matrix

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.