/**
 *
 *  Copyright 2012-2013 The MITRE Corporation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * **************************************************************************
 *                          NOTICE
 * This software was produced for the U. S. Government under Contract No.
 * W15P7T-12-C-F600, and is subject to the Rights in Noncommercial Computer
 * Software and Noncommercial Computer Software Documentation Clause
 * 252.227-7014 (JUN 1995)
 *
 * (c) 2012 The MITRE Corporation. All Rights Reserved.
 * **************************************************************************
 */
package org.opensextant.data;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

/**
 * For now, what seems useful are catalog, name, terms.

 * @author ubaldino
 */
public class Taxon {

    /**  Catalog, for example "fruit" */
    public String catalog = null;

    /** Node name: citrus.tropical */
    public String name = null;
    /** Nod OID:  1.2.3  */
    public String id = null;
    /** Node root: citrus */
    public String rootid = null;
    /** Terms: "pineapple", "mango", ... */
    public Set<String> termset = null;
    public Set<String> tagset = null;
    /** Acronyms are assumed to be ALL UPPER CASE; granted this does not
     * always apply.   But this is used to inform post-processing if a match, such as
     * 'abc' matched 'ABC' incorrectly.  If the match is lower case, but the Taxon is Acronym,
     * then you have a mismatch of case and semantics likley.
     */
    public boolean isAcronym = false;

    public Taxon() {
    }

    public void setName(String n) {
        name = n;
    }

    public void setId(String i) {
        id = i;
    }

    public void setRootid(String i) {
        rootid = i;
    }

    public void setTerms(String[] t) {
        if (t == null) {
            return;
        }
        if (termset == null) {
            termset = new HashSet<String>();
        }
        termset.addAll(Arrays.asList(t));

    }

    public void addTags(Collection<Object> tlist) {
        if (tlist == null) {
            return;
        }

        for (Object o : tlist) {
            addTag((String) o);
        }
    }

    public void addTag(String t) {
        if (t == null) {
            return;
        }

        if (tagset == null) {
            tagset = new HashSet<String>();
        }
        tagset.add(t);
    }

    public void addTerm(String t) {
        if (termset == null) {
            termset = new HashSet<String>();
        }
        termset.add(t);
    }

    public void addTerms(Collection<String> tlist) {
        if (tlist == null) {
            return;
        }
        if (termset == null) {
            termset = new HashSet<String>();
        }
        termset.addAll(tlist);
    }

    @Override
    public String toString() {
        if (termset == null) {
            return name;
        }
        return name + " " + termset.toString();
    }
}

@@ -1216,16 +1216,39 @@
 ashSet;%0A
+import java.util.List;%0A
 import j
@@ -1261,16 +1261,16 @@
 il.Set;%0A
-
 %0A/**%0A * 
@@ -1322,17 +1322,20 @@
  terms.%0A
+ * 
 %0A
-
  * @auth
@@ -1379,17 +1379,16 @@
 %0A    /**
- 
  Catalog
@@ -1536,17 +1536,15 @@
 OID:
- 
  1.2.3 
- 
 */%0A 
@@ -1761,16 +1761,23 @@
 %0A    /**
+%0A     *
  Acronym
@@ -1837,31 +1837,29 @@
  not
-%0A     *
  always
+%0A     *
  apply.
-  
  But
@@ -1957,17 +1957,16 @@
 rrectly.
- 
  If the 
@@ -1993,16 +1993,23 @@
  but the
+%0A     *
  Taxon i
@@ -2018,23 +2018,16 @@
 Acronym,
-%0A     *
  then yo
@@ -2554,17 +2554,16 @@
 st(t));%0A
-%0A
     %7D%0A%0A 
@@ -2589,25 +2589,19 @@
 ags(
-Collection%3CObject
+List%3CString
 %3E tl
@@ -2666,25 +2666,24 @@
       %7D%0A
-%0A
         
 for (Obj
@@ -2678,62 +2678,71 @@
     
-for (Object o : tlist) %7B%0A            addTag((
+if (tagset == null) %7B%0A            tagset = new HashSet%3C
 String
-) o
+%3E(
 );%0A 
@@ -2746,24 +2746,54 @@
 ;%0A        %7D%0A
+        tagset.addAll(tlist);%0A
     %7D%0A%0A    p

Migrate Taxon tags list to a more generic solution using strings, instead of objects; Some updates related to how SolrUtil gets strings from SolrDocument