Examples of TaxonLabel


Examples of org.cipres.treebase.domain.taxon.TaxonLabel

    return TaxonLabel.class.equals(pClass);
  }

  public void validate(Object pValidatable, Errors pError) {
    // ValidationUtils.rejectIfEmpty(e, "name", "name.empty");
    TaxonLabel myTaxonLabel = (TaxonLabel) pValidatable;

    // Checking Taxon Label is not Empty
    // IMPORTANT: taxonLabel in the following line and everywhere below refers to
    // getTaxonLabel() method in myTaxonLabel class
    ValidationUtils.rejectIfEmptyOrWhitespace(
      pError,
      "taxonLabel",
      "Taxon Label cannot be empty.",
      null,
      "Taxon Label cannot be empty.");

    // Check string length
    String valueLabel = myTaxonLabel.getTaxonLabel().trim();
    if (valueLabel.length() > TBPersistable.COLUMN_LENGTH_STRING) {
      pError.rejectValue("taxonLabel", null, "Taxon Label cannot exceed "
        + TBPersistable.COLUMN_LENGTH_STRING + " characters.");
    }
   
    // Check for integer values, float are acceptable
    if ( valueLabel.matches("^[0-9]+$") ) {
      pError.rejectValue("taxonLabel", null, "Taxon Label cannot consist of integers alone.");
    }

    // Checking for the duplication of the Taxon Labels (String) in the Set
    Study study = myTaxonLabel.getStudy();
    List<TaxonLabel> taxonLabelSet = study.getSubmission().getSubmittedTaxonLabelsReadOnly();
    String testLbl = null;
    long valueId = myTaxonLabel.getId();
    String valueLabelUC = valueLabel.toUpperCase();   
    Iterator<TaxonLabel> itTxnLbl = taxonLabelSet.iterator();
    while (itTxnLbl.hasNext()) {
      TaxonLabel testTxnLbl = itTxnLbl.next();
      testLbl = testTxnLbl.getTaxonLabel().trim().toUpperCase();
      if (testLbl.equals(valueLabelUC) && testTxnLbl.getId() != valueId ) {
        pError.rejectValue("taxonLabel", null, "This Label already exists.");
        break;
      }
    }
  }
View Full Code Here

Examples of org.cipres.treebase.domain.taxon.TaxonLabel

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

    //pretty much a dummy test.
    String desc = "Durinskia baltica";
    TaxonLabel aLabel = new TaxonLabel();
    aLabel.setTaxonLabel(desc);
   
    TaxonVariant variant = getFixture().createFromUBIOService(aLabel);
    logger.info("variant full name =" + variant.getFullName());
   
    assertTrue("variant.", variant != null);
View Full Code Here

Examples of org.cipres.treebase.domain.taxon.TaxonLabel

      if (tl.getTaxonVariant() != null) {
        tlsOneEolphus.add(tl);
      }
    }
    assertTrue(tlsOneEolphus.size()>=1);
    TaxonLabel tlEolphus = tlsOneEolphus.iterator().next();

    TaxonVariant tvEolphus = getFixture().findTaxonVariant(tlEolphus);
    assertNotNull(tvEolphus);

    // I expect a whole bunch of equivalent TVs
View Full Code Here

Examples of org.cipres.treebase.domain.taxon.TaxonLabel

      if (tl.getTaxonVariant() != null) {
        tlsOneEolphus.add(tl);
      }
    }
    assertTrue(tlsOneEolphus.size()>=1);
    TaxonLabel tlEolphus = tlsOneEolphus.iterator().next();

    Collection<TaxonLabel> tlsOneCacatua = new HashSet<TaxonLabel>();
    for (TaxonLabel tl : tlsCacatua) {
      if (tl.getTaxonVariant() != null) {
        tlsOneCacatua.add(tl);
      }
    }
    assertTrue(tlsOneCacatua.size()>=1);
    TaxonLabel tlCacatua = tlsOneCacatua.iterator().next();

    TaxonVariant tvEolphus = getFixture().findTaxonVariant(tlEolphus);
    assertNotNull(tvEolphus);
    TaxonVariant tvCacatua = getFixture().findTaxonVariant(tlCacatua);
    assertNotNull(tvCacatua);
View Full Code Here

Examples of org.cipres.treebase.domain.taxon.TaxonLabel

    s.setCitation(c);
    c.setStudy(s);
    s.addAnalysis(a1);
    s.addAnalysis(a2);

    TaxonLabel label = new TaxonLabel();
    label.setTaxonLabel(newName);
    label.setStudy(s);

    getStudyHome().store(label);
    getStudyHome().store(s);

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

    onSetUp();

    // Notes: this is important: why?? there are two copies of s in the same session.
    // how???
    s = (Study) hibernateTemplate.merge(s);

    Long studyID = s.getId();
    Long citationID = c.getId();
    logger.info("study created: " + s.getName() + "id = " + studyID);
    logger.info("citation created: " + c.getTitle() + "id = " + citationID);
    logger.info("analysis created: " + a1.getName() + "id = " + a1.getId());
    logger.info("analysis created: " + a2.getName() + "id = " + a2.getId());
    logger.info("taxonLabel created: " + label.getTaxonLabel() + "id = " + label.getId());

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

    String taxonLabelsql = "select count(*) from taxonLabel where taxonLabel_id="
      + label.getId();
    int taxonLabelCount = jdbcTemplate.queryForInt(taxonLabelsql);
    assertTrue(taxonLabelCount == 1);

    // 3. delete
    // fixture.delete(testRole);
View Full Code Here

Examples of org.cipres.treebase.domain.taxon.TaxonLabel

   * @see org.cipres.treebase.util.JUNK#knownTaxonLabelCache()
   */
  public Map<String, Set<TaxonLabel>> knownTaxonLabelCache() {
    Map<String, Set<TaxonLabel>> knownTaxonLabel = new HashMap<String, Set<TaxonLabel>> ();
    for (TBPersistable tX : taxonHome.findAll(TaxonLabel.class)) {
      TaxonLabel tl = (TaxonLabel) tX;
      String label = tl.getTaxonLabel();
      if (label != null) {
        if (! knownTaxonLabel.containsKey(label))
          knownTaxonLabel.put(label, new HashSet<TaxonLabel> ());
        knownTaxonLabel.get(label).add(tl);
      }
View Full Code Here

Examples of org.cipres.treebase.domain.taxon.TaxonLabel

    MatrixColumn c2 = new MatrixColumn();
    c2.setCharacter(dnaChar);
    matrix.addColumn(c2);

    // add two rows:
    TaxonLabel taxonLabel = new TaxonLabel();
    taxonLabel.setTaxonLabel(newName);

    // missing symbol is ?
    DiscreteCharState aState = dnaChar.getStateByDescription("" + DiscreteCharState.MISSING_SYMBOL);
    assertTrue("? is not a valid state", aState != null);

    // create one row with 2 elements:
    MatrixRow r1 = new MatrixRow();
    r1.setTaxonLabel(taxonLabel);

    DiscreteMatrixElement e1 = new DiscreteMatrixElement();
    e1.setColumn(c1);
    e1.setCharState(aState);
    r1.addElement(e1);

    DiscreteMatrixElement e2 = new DiscreteMatrixElement();
    e2.setColumn(c2);
    e2.setCharState(aState);
    r1.addElement(e2);

    // add two segments, each with one element:
    RowSegment seg1 = new RowSegment();

    seg1.setStartIndex(0);
    seg1.setEndIndex(0);
    r1.addSegment(seg1);

    RowSegment seg2 = new RowSegment();

    seg2.setStartIndex(1);
    seg2.setEndIndex(1);
    r1.addSegment(seg2);

    matrix.addRow(r1);

    // TODO: add a second row.
 
    //getMatrixHome().store(taxonLabel);
    getMatrixHome().store(c1);
    getMatrixHome().store(c2);
    getMatrixHome().store(e1);
    getMatrixHome().store(e2);
    getMatrixHome().store(matrix);
   
    // 2. verify
    Long matrixID = matrix.getId();
    Long c1ID = c1.getId();
    Long c2ID = c2.getId();
    Long r1ID = r1.getId();
    Long seg1ID = seg1.getId();
    Long seg2ID = seg2.getId();
    Long e1ID = e1.getId();
    Long e2ID = e2.getId();
    Long taxonID = taxonLabel.getId();

      logger.info("matrix created: " + matrix.getTitle() + "id = " + matrixID + " symbols=" + matrix.getSymbols() + " gap =" + matrix.getGapSymbol());
    logger.info("taxonLabel created: " + taxonLabel.getTaxonLabel() + "id = " + taxonID);
    logger.info("2 columns created: id = " + c1ID + ", " + c2ID);
    logger.info("2 rows created: id = " + r1.getId() + ", ");
    logger.info("2 segments created: id = " + seg1.getId() + ", " + seg2.getId());
    logger.info("2 elements created: id = " + e1.getId() + ", " + e2.getId());

    // force commit immediately, important:
    //setComplete();
    //endTransaction();
 
    Matrix m = (Matrix)loadObject(Matrix.class, matrixID);
    TaxonLabel tl = (TaxonLabel)loadObject(TaxonLabel.class, taxonID);
      //String sqlStr = "select count(*) from matrix where matrix_id=" + matrixID;
    //int count = jdbcTemplate.queryForInt(sqlStr);
    //assertTrue(count == 1);
    assertTrue( m!=null );
    //assertTrue( tl!=null );
View Full Code Here

Examples of org.cipres.treebase.domain.taxon.TaxonLabel

   *
   * @see org.cipres.treebase.domain.taxon.TaxonLabelHome#findByDescription(java.lang.String,
   *      org.cipres.treebase.domain.study.Study)
   */
  public TaxonLabel findByDescription(String pDescription, Study pStudy) {
    TaxonLabel returnVal = null;

    if (!TreebaseUtil.isEmpty(pDescription) && pStudy != null) {
      Criteria c = getSession().createCriteria(TaxonLabel.class);
      c.add(Expression.eq("taxonLabel", pDescription));
      c.add(Expression.eq("study", pStudy));
View Full Code Here

Examples of org.cipres.treebase.domain.taxon.TaxonLabel

  public TaxonLabel getDefaultByDescription(String pDescription) {
    String desc = "";
    if (pDescription != null) {
      desc = pDescription;
    }
    TaxonLabel defaultLabel = findByDescription(desc, null);

    // create new one if it is not found:
    if (defaultLabel == null) {
      defaultLabel = new TaxonLabel();
      defaultLabel.setTaxonLabel(desc);
      // TODO: how to set Taxon??
    }

    return defaultLabel;
  }
View Full Code Here

Examples of org.cipres.treebase.domain.taxon.TaxonLabel

    String desc = "";
    if (pLabel != null) {
      desc = pLabel;
    }

    TaxonLabel aLabel = findByDescription(desc, pStudy);

    // create new one if it is not found:
    if (aLabel == null && !TreebaseUtil.isEmpty(desc)) {
      aLabel = new TaxonLabel();
      aLabel.setTaxonLabel(desc);
      aLabel.setStudy(pStudy);
    }

    return aLabel;
  }
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.