Allow to retrieve a snapshot of the edited phylogenetic tree using javascript code...
[jalview.git] / forester / java / src / org / forester / phylogeny / data / Taxonomy.java
index 5d4411d..d403a8e 100644 (file)
@@ -46,6 +46,7 @@ public class Taxonomy implements PhylogenyData, MultipleUris, Comparable<Taxonom
     private String       _taxonomy_code;
     private String       _rank;
     private List<Uri>    _uris;
+    private List<String> _lineage;
 
     public Taxonomy() {
         init();
@@ -130,6 +131,14 @@ public class Taxonomy implements PhylogenyData, MultipleUris, Comparable<Taxonom
                 }
             }
         }
+        if ( getLineage() != null ) {
+            t.setLineage( new ArrayList<String>() );
+            for( final String l : getLineage() ) {
+                if ( l != null ) {
+                    t.getLineage().add( l );
+                }
+            }
+        }
         return t;
     }
 
@@ -214,13 +223,15 @@ public class Taxonomy implements PhylogenyData, MultipleUris, Comparable<Taxonom
         setAuthority( "" );
         setSynonyms( null );
         setUris( null );
+        setLineage( null );
     }
 
     public boolean isEmpty() {
         return ( ( getIdentifier() == null ) && ForesterUtil.isEmpty( getTaxonomyCode() )
                 && ForesterUtil.isEmpty( getCommonName() ) && ForesterUtil.isEmpty( getScientificName() )
                 && ForesterUtil.isEmpty( getRank() ) && ForesterUtil.isEmpty( _uris )
-                && ForesterUtil.isEmpty( getAuthority() ) && ForesterUtil.isEmpty( _synonyms ) );
+                && ForesterUtil.isEmpty( getAuthority() ) && ForesterUtil.isEmpty( _synonyms ) && ForesterUtil
+                .isEmpty( _lineage ) );
     }
 
     /**
@@ -278,7 +289,7 @@ public class Taxonomy implements PhylogenyData, MultipleUris, Comparable<Taxonom
     }
 
     public void setRank( final String rank ) {
-        if ( !ForesterUtil.isEmpty( rank ) && !PhyloXmlUtil.TAXONOMY_RANKS.contains( rank ) ) {
+        if ( !ForesterUtil.isEmpty( rank ) && !PhyloXmlUtil.TAXONOMY_RANKS_SET.contains( rank ) ) {
             throw new PhyloXmlDataFormatException( "illegal rank: [" + rank + "]" );
         }
         _rank = rank;
@@ -401,4 +412,12 @@ public class Taxonomy implements PhylogenyData, MultipleUris, Comparable<Taxonom
         }
         return 0;
     }
+
+    public void setLineage( final List<String> lineage ) {
+        _lineage = lineage;
+    }
+
+    public List<String> getLineage() {
+        return _lineage;
+    }
 }