*/\r
package eu.etaxonomy.cdm.model.common;\r
\r
-import java.util.HashSet;\r
import java.util.Iterator;\r
-import java.util.List;\r
import java.util.NoSuchElementException;\r
import java.util.Set;\r
import java.util.SortedSet;\r
\r
import javax.persistence.Entity;\r
import javax.persistence.Transient;\r
+import javax.xml.bind.annotation.XmlAccessType;\r
+import javax.xml.bind.annotation.XmlAccessorType;\r
+import javax.xml.bind.annotation.XmlRootElement;\r
+import javax.xml.bind.annotation.XmlType;\r
\r
import org.apache.log4j.Logger;\r
\r
* @author a.mueller\r
*\r
*/\r
+@XmlAccessorType(XmlAccessType.FIELD)\r
+@XmlType(name = "OrderedTermVocabulary")\r
+@XmlRootElement(name = "OrderedTermVocabulary")\r
@Entity\r
+//@Audited\r
public class OrderedTermVocabulary<T extends OrderedTermBase> extends TermVocabulary<T> {\r
+ private static final long serialVersionUID = 7871741306306371242L;\r
+ @SuppressWarnings("unused")\r
private static final Logger logger = Logger.getLogger(OrderedTermVocabulary.class);\r
- \r
- /**\r
- * \r
- */\r
- public OrderedTermVocabulary() {\r
- super();\r
- }\r
\r
/**\r
* @param term\r
* @param label\r
* @param termSourceUri\r
*/\r
- public OrderedTermVocabulary(String term, String label, String termSourceUri) {\r
- super(term, label, termSourceUri);\r
+ public OrderedTermVocabulary(String term, String label, String labelAbbrev, String termSourceUri) {\r
+ super(term, label, labelAbbrev, termSourceUri);\r
+ }\r
+\r
+ public OrderedTermVocabulary() {\r
+ super();\r
}\r
\r
- @Override\r
@Transient\r
- protected Set<T> getNewTermSet(){\r
+ @Override\r
+ public Set<T> getNewTermSet() {\r
return new TreeSet<T>();\r
}\r
+\r
+ @Transient\r
+ public SortedSet<T> getOrderedTerms(T otb) {\r
+ SortedSet<T> result = new TreeSet<T>();\r
+ result.addAll(terms);\r
+ return result;\r
+ }\r
\r
@Transient\r
public SortedSet<T> getHigherAndEqualTerms(T otb) {\r
}\r
\r
@Override\r
- public void addTerm(T term) throws WrongTermTypeException {\r
- SortedSet sortedTerms = ((SortedSet<T>)terms);\r
+ public void addTerm(T term) {\r
+ SortedSet<T> sortedTerms = (SortedSet<T>)terms;\r
int lowestOrderIndex;\r
if (sortedTerms.size() == 0){\r
lowestOrderIndex = 0;\r
}else{\r
- Object first = (T)sortedTerms.first();\r
- lowestOrderIndex = ((T)first).orderIndex;\r
+ T first = sortedTerms.first();\r
+ lowestOrderIndex = first.orderIndex;\r
}\r
term.orderIndex = lowestOrderIndex + 1;\r
super.addTerm(term); \r
super.addTerm(termToBeAdded);\r
}\r
\r
-// public void addTermEqualLevel(T termToBeAdded, T equalLevelTerm) throws WrongTermTypeException {\r
-// int orderInd = equalLevelTerm.orderIndex;\r
-// termToBeAdded.orderIndex = orderInd;\r
-// super.addTerm(termToBeAdded);\r
-// }\r
+ public void addTermEqualLevel(T termToBeAdded, T equalLevelTerm) throws WrongTermTypeException {\r
+ int orderInd = equalLevelTerm.orderIndex;\r
+ termToBeAdded.orderIndex = orderInd;\r
+ super.addTerm(termToBeAdded);\r
+ }\r
\r
@Override\r
public void removeTerm(T term) {\r
toBeChangedByObject = null;\r
}\r
}\r
- term.setVocabulary(null);\r
+ super.removeTerm(term);\r
}\r
\r
private T toBeChangedByObject;\r