import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.UUID;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
import eu.etaxonomy.cdm.model.common.Language;
+import eu.etaxonomy.cdm.model.common.TermIdInVocabularyComparator;
import eu.etaxonomy.cdm.model.common.TermLanguageComparator;
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
import eu.etaxonomy.cdm.model.description.Distribution;
public static final String DEFAULT_ENTRY = "";
private IDescriptionService descriptionService;
- private final List<DefinedTermBase<?>> namedAreas;
+ private final SortedSet<DefinedTermBase> namedAreas;
TableViewer viewer = null;
/**
//TODO load areas by this list
List<TaxonDescription> listTaxonDescriptions = descriptionService.listTaxonDescriptions(taxon, null, null, null, null, null, DESC_INIT_STRATEGY);;
- NonViralName<?> nonVirlaName = HibernateProxyHelper.deproxy(taxon.getName(), NonViralName.class);
+ NonViralName<?> nonViralName = HibernateProxyHelper.deproxy(taxon.getName(), NonViralName.class);
switch (columnIndex) {
case 0:
String taxonName = null;
- taxonName = (nonVirlaName != null) ? nonVirlaName.getNameCache() : null;
+ taxonName = (nonViralName != null) ? nonViralName.getNameCache() : null;
return (taxonName != null) ? taxonName : DEFAULT_ENTRY;
case 1:
String authorship = null;
- authorship = (nonVirlaName != null) ? nonVirlaName.getAuthorshipCache() : null;
+ authorship = (nonViralName != null) ? nonViralName.getAuthorshipCache() : null;
return (authorship != null) ? authorship : DEFAULT_ENTRY;
// case 2:
// String ref = null;
for (TaxonDescription td : listTaxonDescriptions) {
for (DescriptionElementBase deb : td.getElements()) {
if (deb instanceof Distribution) {
- Distribution distribution = (Distribution) deb;
- String area = distribution.toString();
+ Distribution distribution = HibernateProxyHelper.deproxy(deb, Distribution.class);
+ String area = null;
+ if (distribution.getArea() != null ){
+ if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
+ area = distribution.getArea().getIdInVocabulary();
+ }else{
+ area = distribution.getArea().getTitleCache();
+ }
+ }else{
+ continue;
+ }
+
if(viewer != null){
TableColumn column = viewer.getTable().getColumn(columnIndex);
if (area.equalsIgnoreCase(column.getText())) {
- return (distribution.getStatus().getTitleCache() != null)?distribution.getStatus().getTitleCache():DEFAULT_ENTRY;
- }
+ return (distribution.getStatus().getTitleCache() != null)?distribution.getStatus().getTitleCache():DEFAULT_ENTRY;
+ }
+
}
}
}
"descriptions.*", "description.state" });
- private List<DefinedTermBase<?>> loadNamedAreas() {
+ private SortedSet<DefinedTermBase> loadNamedAreas() {
IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
String values = preferenceStore.getString(PreferencesUtil.DISTRIBUTION_AREA_OCCURENCE_STATUS);
if (values != null && values != "") {
String[] split = values.split(",");
List<String> listValue = Arrays.asList(split);
- ArrayList<DefinedTermBase<?>> termlist = new ArrayList<DefinedTermBase<?>>();
+ List<DefinedTermBase> termlist = new ArrayList<DefinedTermBase>();
+ Set<UUID> uuidList = new HashSet<UUID>();
+ UUID uuid;
for(String s : listValue){
- UUID uuid = UUID.fromString(s);
- ITermService service = CdmStore.getService(ITermService.class);
- DefinedTermBase definedTermBase = service.load(uuid);
- termlist.add(definedTermBase);
+ uuid = UUID.fromString(s);
+ uuidList.add(uuid);
+
}
- return termlist;
+ ITermService service = CdmStore.getService(ITermService.class);
+ termlist = service.find(uuidList);
+
+ return getTermsOrderedByIdInVocabulary(termlist);
}
return null;
}
/**
* @return the namedAreas
*/
- public List<DefinedTermBase<?>> getNamedAreas() {
+ public SortedSet<DefinedTermBase> getNamedAreas() {
return namedAreas;
}
+
+ /**
+ * @param namedAreas
+ * @param defaultLanguage
+ * @return
+ */
+ public SortedSet<DefinedTermBase> getTermsOrderedByIdInVocabulary(List<DefinedTermBase> namedAreas) {
+ TermIdInVocabularyComparator comp = new TermIdInVocabularyComparator();
+
+ SortedSet result = new TreeSet(comp);
+ if(namedAreas != null){
+ result.addAll(namedAreas);
+ }
+ return result;
+ }
}