package eu.etaxonomy.taxeditor.editor.name.container;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
if (text.length() < start + length) {
length = text.length() - start;
}
-
+ if (length<0){
+ return null;
+ }
return new Position(start, length);
}
return null;
return enableFreetext;
}
+ /**
+ * Checks whether there are more than one, non-orphaned taxon bases
+ * attached to the taxon name
+ *
+ * @return
+ */
private boolean isNameUsedMultipleTimes() {
- if (getName().getTaxonBases().size() > 1) {
+
+ Set<TaxonBase> taxonBases = getName().getTaxonBases();
+ Iterator<TaxonBase> tbItr = taxonBases.iterator();
+ int nonOrphanedTaxonBaseCount = taxonBases.size();
+
+ while(tbItr.hasNext()) {
+ TaxonBase tb = tbItr.next();
+ if(tb.isOrphaned()) {
+ nonOrphanedTaxonBaseCount--;
+ }
+ }
+ if(nonOrphanedTaxonBaseCount > 1) {
return true;
}
return false;