Examples of TaxonLabelHome


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

class RepatriateTaxonLabelsToSubmissions extends AbstractStandalone {
 
  public static void main(String [] args) {
    RepatriateTaxonLabelsToSubmissions rt = new RepatriateTaxonLabelsToSubmissions();
    rt.setupContext();
    TaxonLabelHome tlHome = ContextManager.getTaxonLabelHome();
   
    // Map taxonlabels to the submissions that contain them
    Map<TaxonLabel,List<Submission>> submissions = new HashMap<TaxonLabel,List<Submission>> ();
    for (Object o : tlHome.findAll(Submission.class)) {
      Submission sub = (Submission) o;
      for (TaxonLabel tl : sub.getSubmittedTaxonLabelsReadOnly()) {
        if (! submissions.containsKey(tl)) {
          submissions.put(tl, new LinkedList<Submission> ());
        }
        submissions.get(tl).add(sub);
      }
    }

    for (Object o : tlHome.findAll(TaxonLabel.class)) {
      TaxonLabel tl = (TaxonLabel) o;
      Submission correctSub = tl.getSubmission();
      List<Submission> otherSubs = submissions.get(tl);

      warn("#" + tl.getId());
      if (otherSubs.size() == 1
          && otherSubs.iterator().next().equals(correctSub)) {
        warn("  already correct");
        continue;
      }

      Transaction trans = rt.beginTransaction();
           
      for (Submission otherSub : otherSubs) {
        if (otherSub == correctSub) continue;
   
        warn("  removing from " + otherSub.getId());
        otherSub.removeTaxonLabel(tl);
      }
      tlHome.flush();
      warn("  adding to " + correctSub.getId());
      correctSub.addTaxonLabel(tl);
     
      trans.commit();
      warn("  committed");
View Full Code Here

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

    else if (className.equals("taxonlabel")) doDeleteTaxonLabel(id);
    else die("Unrecognized class name '" + className + "'");
  }
 
  public void doDeleteTaxonLabel(Long id) {
    TaxonLabelHome tlh = (TaxonLabelHome) ContextManager.getBean("taxonLabelHome");
    TaxonLabel tl = tlh.findPersistedObjectByID(TaxonLabel.class, id);
    if (tl == null) return;
    tlh.delete(tl);
  }
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.