commit 3c6e3fc61e0a9908eafbc04f67f392c3aef0b71d
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Fri Nov 2 06:57:31 2018 +0100

    ref #7875 Adapt to TermDto based services

diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/AreasSelectionDialog.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/AreasSelectionDialog.java
index 9cfd2f1df..1d443080d 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/AreasSelectionDialog.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/AreasSelectionDialog.java
@@ -27,9 +27,9 @@ import eu.etaxonomy.cdm.api.service.IVocabularyService;
 import eu.etaxonomy.cdm.model.common.TermType;
 import eu.etaxonomy.cdm.model.common.TermVocabulary;
 import eu.etaxonomy.cdm.model.location.NamedArea;
-import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
-import eu.etaxonomy.taxeditor.editor.definedterm.TermUuidAndTitleCacheContentProvider;
-import eu.etaxonomy.taxeditor.editor.definedterm.TermUuidAndTitleCacheLabelProvider;
+import eu.etaxonomy.cdm.persistence.dto.TermDto;
+import eu.etaxonomy.taxeditor.editor.definedterm.TermDtoContentProvider;
+import eu.etaxonomy.taxeditor.editor.definedterm.TermDtoLabelProvider;
 import eu.etaxonomy.taxeditor.preference.wizard.CheckBoxTreeComposite;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
@@ -42,12 +42,12 @@ public class AreasSelectionDialog extends Dialog{
 
     private CheckBoxTreeComposite treeComposite;
 
-    private Set<UuidAndTitleCache> selectedAreas = new HashSet<>();
+    private Set<TermDto> selectedAreas = new HashSet<>();
 
     private Collection<TermVocabulary<NamedArea>> areaVocabularies;
 
 
-    protected AreasSelectionDialog(Shell parentShell, Set<UuidAndTitleCache> selectedAreas) {
+    protected AreasSelectionDialog(Shell parentShell, Set<TermDto> selectedAreas) {
         super(parentShell);
         this.selectedAreas = selectedAreas;
         this.areaVocabularies = CdmStore.getService(IVocabularyService.class).findByTermType(TermType.NamedArea, null);
@@ -56,7 +56,7 @@ public class AreasSelectionDialog extends Dialog{
     @Override
     protected Control createDialogArea(Composite parent) {
         parent.setLayout(new GridLayout());
-        treeComposite = new CheckBoxTreeComposite(parent, new TermUuidAndTitleCacheContentProvider(), new TermUuidAndTitleCacheLabelProvider(), SWT.NONE);
+        treeComposite = new CheckBoxTreeComposite(parent, new TermDtoContentProvider(), new TermDtoLabelProvider(), SWT.NONE);
         treeComposite.getViewer().setInput(areaVocabularies);
         treeComposite.setCheckedElements(selectedAreas.toArray());
         treeComposite.getViewer().reveal(selectedAreas);
@@ -75,7 +75,7 @@ public class AreasSelectionDialog extends Dialog{
     protected void okPressed() {
         selectedAreas.clear();
         List<Object> checkedElements = Arrays.asList(treeComposite.getViewer().getCheckedElements());
-        checkedElements = checkedElements.stream().filter(element->element instanceof UuidAndTitleCache).collect(Collectors.toList());
+        checkedElements = checkedElements.stream().filter(element->element instanceof TermDto).collect(Collectors.toList());
         selectedAreas = new HashSet(checkedElements);
         super.okPressed();
     }
@@ -85,7 +85,7 @@ public class AreasSelectionDialog extends Dialog{
         return true;
     }
 
-    public Set<UuidAndTitleCache> getSelectedAreas(){
+    public Set<TermDto> getSelectedAreas(){
         return selectedAreas;
     }
 }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/DescriptiveDataSetComposite.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/DescriptiveDataSetComposite.java
index 9107a0acc..4ad5a73fd 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/DescriptiveDataSetComposite.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/DescriptiveDataSetComposite.java
@@ -25,7 +25,8 @@ import org.eclipse.swt.widgets.Tree;
 import eu.etaxonomy.cdm.model.common.TermType;
 import eu.etaxonomy.cdm.model.description.FeatureTree;
 import eu.etaxonomy.cdm.model.name.Rank;
-import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
+import eu.etaxonomy.cdm.persistence.dto.TermDto;
+import eu.etaxonomy.cdm.remote.l10n.TermRepresentation_L10n;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
 import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditorComposite;
 import eu.etaxonomy.taxeditor.model.ImageResources;
@@ -44,7 +45,7 @@ public class DescriptiveDataSetComposite extends Composite {
     private TermUuidComboViewer comboRankMax;
     private FeatureTreeEditorComposite featureTreeEditorComposite;
     private TreeViewer taxonNodeTree;
-    private Set<UuidAndTitleCache> areas = new HashSet<>();
+    private Set<TermDto> areas = new HashSet<>();
     private Text textAreaText;
     private Button btnChooseArea;
     private Button btnRemoveRankMin;
@@ -173,12 +174,15 @@ public class DescriptiveDataSetComposite extends Composite {
     public TreeViewer getTaxonNodeTree() {
         return taxonNodeTree;
     }
-    public Set<UuidAndTitleCache> getAreas() {
+    public Set<TermDto> getAreas() {
         return areas;
     }
-    public void setAreas(Set<UuidAndTitleCache> areas) {
+    public void setAreas(Set<TermDto> areas) {
         this.areas = areas;
-        textAreaText.setText(areas.stream().map(area->area.getTitleCache()).collect(Collectors.joining(", ")));
+        textAreaText.setText(areas.stream().map(area->{
+            area.localize(new TermRepresentation_L10n());
+            return area.getRepresentation_L10n();
+        }).collect(Collectors.joining(", ")));
     }
     public Button getBtnChooseArea() {
         return btnChooseArea;
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/DescriptiveDataSetEditor.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/DescriptiveDataSetEditor.java
index 43dc1a1dd..d4b4a9dab 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/DescriptiveDataSetEditor.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/DescriptiveDataSetEditor.java
@@ -65,7 +65,7 @@ import eu.etaxonomy.cdm.model.name.Rank;
 import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
-import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
+import eu.etaxonomy.cdm.persistence.dto.TermDto;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
 import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
@@ -156,7 +156,7 @@ IPartContentHasDetails, IPartContentHasSupplementalData, IDirtyMarkable {
             public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                 AreasSelectionDialog areasSelectionDialog = new AreasSelectionDialog(composite.getShell(), composite.getAreas());
                 if(areasSelectionDialog.open()==Window.OK){
-                    Set<UuidAndTitleCache> selectedAreas = areasSelectionDialog.getSelectedAreas();
+                    Set<TermDto> selectedAreas = areasSelectionDialog.getSelectedAreas();
                     if(selectedAreas!=null){
                         composite.setAreas(selectedAreas);
                         dirty.setDirty(true);
@@ -204,8 +204,13 @@ IPartContentHasDetails, IPartContentHasSupplementalData, IDirtyMarkable {
         }
         Set<NamedArea> geoFilter = descriptiveDataSet.getGeoFilter();
         if(geoFilter!=null && !geoFilter.isEmpty()){
-            Set<UuidAndTitleCache> uuidAndTitleCaches = geoFilter.stream().map(filter->new UuidAndTitleCache(filter.getUuid(), filter.getId(), filter.getTitleCache())).collect(Collectors.toSet());
-            composite.setAreas(uuidAndTitleCaches);
+            Set<TermDto> terms = geoFilter.stream().map(filter->new TermDto(
+                    filter.getUuid(),
+                    filter.getRepresentations(),
+                    filter.getPartOf()!=null?filter.getPartOf().getUuid():null,
+                    filter.getVocabulary().getUuid(),
+                    filter.getOrderIndex())).collect(Collectors.toSet());
+            composite.setAreas(terms);
         }
         Set<TaxonNode> taxonSubtreeFilter = descriptiveDataSet.getTaxonSubtreeFilter();
         if(taxonSubtreeFilter!=null){
@@ -269,7 +274,7 @@ IPartContentHasDetails, IPartContentHasSupplementalData, IDirtyMarkable {
     @Persist
     @Override
     public void save(IProgressMonitor monitor) {
-        Set<UuidAndTitleCache> areas = composite.getAreas();
+        Set<TermDto> areas = composite.getAreas();
         Object input = composite.getTaxonNodeTree().getInput();
         if(input!=null){
             descriptiveDataSet.setTaxonSubtreeFilter(new HashSet<>());//clear existing filter
@@ -303,7 +308,7 @@ IPartContentHasDetails, IPartContentHasSupplementalData, IDirtyMarkable {
         descriptiveDataSet.setMinRank(rankMin);
         descriptiveDataSet.setDescriptiveSystem(characters);
         List<DefinedTermBase> terms = CdmStore.getService(ITermService.class)
-                .loadByIds(areas.stream().map(area -> area.getId()).collect(Collectors.toList()), null);
+                .load(areas.stream().map(area -> area.getUuid()).collect(Collectors.toList()), null);
         Set<NamedArea> areaTerms = new HashSet<>();
         terms.forEach(term->areaTerms.add((NamedArea) term));
         descriptiveDataSet.setGeoFilter(areaTerms);
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/TermDtoContentProvider.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/TermDtoContentProvider.java
new file mode 100644
index 000000000..975df0b60
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/TermDtoContentProvider.java
@@ -0,0 +1,86 @@
+/**
+* Copyright (C) 2009 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.editor.definedterm;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.eclipse.jface.viewers.TreeNodeContentProvider;
+
+import eu.etaxonomy.cdm.api.service.ITermService;
+import eu.etaxonomy.cdm.api.service.IVocabularyService;
+import eu.etaxonomy.cdm.model.common.DefinedTermBase;
+import eu.etaxonomy.cdm.model.common.TermVocabulary;
+import eu.etaxonomy.cdm.persistence.dto.TermDto;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ *
+ * @author pplitzner
+ * @since Oct 29, 2018
+ *
+ */
+public class TermDtoContentProvider extends TreeNodeContentProvider {
+
+	@Override
+	public Object[] getElements(Object inputElement) {
+		Collection<TermVocabulary> inputElements = (Collection<TermVocabulary>) inputElement;
+		return inputElements.toArray();
+	}
+
+	@Override
+	public Object[] getChildren(Object parentElement) {
+	    Collection<Object> children = new HashSet<>();
+	    if(parentElement instanceof TermVocabulary){
+	        children.addAll(CdmStore.getService(IVocabularyService.class).getTopLevelTerms(((TermVocabulary)parentElement).getId()));
+	    } else {
+	        Collection<Object> includes = new HashSet<>();
+	        Collection<Object> generalizationOfs = new HashSet<>();
+	        if (parentElement instanceof DefinedTermBase) {
+	            includes = ((DefinedTermBase) parentElement).getIncludes();
+	            generalizationOfs = ((DefinedTermBase) parentElement).getGeneralizationOf();
+	        }
+	        else if(parentElement instanceof TermDto){
+	            includes.addAll(CdmStore.getService(ITermService.class).getIncludesAsUuidAndTitleCache((TermDto) parentElement));
+	            generalizationOfs.addAll(CdmStore.getService(ITermService.class).getKindOfsAsUuidAndTitleCache((TermDto) parentElement));
+	        }
+	        children.addAll(includes);
+	        children.addAll(generalizationOfs);
+	    }
+	    return children.toArray();
+	}
+
+	@Override
+	public Object getParent(Object element) {
+		if(element instanceof DefinedTermBase){
+			DefinedTermBase definedTermBase = (DefinedTermBase)element;
+			if (definedTermBase.getPartOf() != null) {
+			    return definedTermBase.getPartOf();
+			}else if (definedTermBase.getKindOf() != null) {
+                return definedTermBase.getKindOf();
+            } else {
+			    return definedTermBase.getVocabulary();
+			}
+		}
+		else if(element instanceof TermDto){
+		    return CdmStore.getService(ITermService.class).getParentUuidAndTitleCache((TermDto)element);
+		}
+		return null;
+
+	}
+
+	@Override
+	public boolean hasChildren(Object element) {
+		if (getChildren(element) != null){
+			return getChildren(element).length > 0;
+		}
+		return false;
+	}
+
+}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/TermDtoLabelProvider.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/TermDtoLabelProvider.java
new file mode 100644
index 000000000..102844989
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/TermDtoLabelProvider.java
@@ -0,0 +1,38 @@
+/**
+ * Copyright (C) 2009 EDIT
+ * European Distributed Institute of Taxonomy
+ * http://www.e-taxonomy.eu
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
+package eu.etaxonomy.taxeditor.editor.definedterm;
+
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+
+import eu.etaxonomy.cdm.model.common.TermVocabulary;
+import eu.etaxonomy.cdm.persistence.dto.TermDto;
+import eu.etaxonomy.cdm.remote.l10n.TermRepresentation_L10n;
+
+/**
+ *
+ * @author pplitzner
+ * @since Oct 29, 2018
+ *
+ */
+public class TermDtoLabelProvider extends ColumnLabelProvider {
+
+    @Override
+    public String getText(Object element) {
+        if(element instanceof TermVocabulary){
+            return ((TermVocabulary) element).getTitleCache();
+        }
+        else if(element instanceof TermDto){
+            TermDto termDto = (TermDto) element;
+            termDto.localize(new TermRepresentation_L10n());
+            return termDto.getRepresentation_L10n();
+        }
+        return element.toString();
+    }
+
+}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/TermUuidAndTitleCacheContentProvider.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/TermUuidAndTitleCacheContentProvider.java
deleted file mode 100644
index 52c7db678..000000000
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/TermUuidAndTitleCacheContentProvider.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
-* Copyright (C) 2009 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-package eu.etaxonomy.taxeditor.editor.definedterm;
-
-import java.util.Collection;
-import java.util.HashSet;
-
-import org.eclipse.jface.viewers.TreeNodeContentProvider;
-
-import eu.etaxonomy.cdm.api.service.ITermService;
-import eu.etaxonomy.cdm.api.service.IVocabularyService;
-import eu.etaxonomy.cdm.model.common.DefinedTermBase;
-import eu.etaxonomy.cdm.model.common.TermVocabulary;
-import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
-import eu.etaxonomy.taxeditor.store.CdmStore;
-
-/**
- *
- * @author pplitzner
- * @since Oct 29, 2018
- *
- */
-public class TermUuidAndTitleCacheContentProvider extends TreeNodeContentProvider {
-
-	@Override
-	public Object[] getElements(Object inputElement) {
-		Collection<TermVocabulary> inputElements = (Collection<TermVocabulary>) inputElement;
-		return inputElements.toArray();
-	}
-
-	@Override
-	public Object[] getChildren(Object parentElement) {
-	    Collection<Object> children = new HashSet<>();
-	    if(parentElement instanceof TermVocabulary){
-	        children.addAll(CdmStore.getService(IVocabularyService.class).getTopLevelTerms(((TermVocabulary)parentElement).getId()));
-	    } else {
-	        Collection<Object> includes = new HashSet<>();
-	        Collection<Object> generalizationOfs = new HashSet<>();
-	        if (parentElement instanceof DefinedTermBase) {
-	            includes = ((DefinedTermBase) parentElement).getIncludes();
-	            generalizationOfs = ((DefinedTermBase) parentElement).getGeneralizationOf();
-	        }
-	        else if(parentElement instanceof UuidAndTitleCache){
-	            includes.addAll(CdmStore.getService(ITermService.class).getIncludesAsUuidAndTitleCache((UuidAndTitleCache<DefinedTermBase>) parentElement));
-	            generalizationOfs.addAll(CdmStore.getService(ITermService.class).getKindOfsAsUuidAndTitleCache((UuidAndTitleCache<DefinedTermBase>) parentElement));
-	        }
-	        children.addAll(includes);
-	        children.addAll(generalizationOfs);
-	    }
-	    return children.toArray();
-	}
-
-	@Override
-	public Object getParent(Object element) {
-		if(element instanceof DefinedTermBase){
-			DefinedTermBase definedTermBase = (DefinedTermBase)element;
-			if (definedTermBase.getPartOf() != null) {
-			    return definedTermBase.getPartOf();
-			}else if (definedTermBase.getKindOf() != null) {
-                return definedTermBase.getKindOf();
-            } else {
-			    return definedTermBase.getVocabulary();
-			}
-		}
-		else if(element instanceof UuidAndTitleCache){
-		    return CdmStore.getService(ITermService.class).getParentUuidAndTitleCache((UuidAndTitleCache)element);
-		}
-		return null;
-
-	}
-
-	@Override
-	public boolean hasChildren(Object element) {
-		if (getChildren(element) != null){
-			return getChildren(element).length > 0;
-		}
-		return false;
-	}
-
-}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/TermUuidAndTitleCacheLabelProvider.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/TermUuidAndTitleCacheLabelProvider.java
deleted file mode 100644
index 485597905..000000000
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/TermUuidAndTitleCacheLabelProvider.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Copyright (C) 2009 EDIT
- * European Distributed Institute of Taxonomy
- * http://www.e-taxonomy.eu
- *
- * The contents of this file are subject to the Mozilla Public License Version 1.1
- * See LICENSE.TXT at the top of this package for the full license terms.
- */
-package eu.etaxonomy.taxeditor.editor.definedterm;
-
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-
-import eu.etaxonomy.cdm.model.common.TermVocabulary;
-import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
-
-/**
- *
- * @author pplitzner
- * @since Oct 29, 2018
- *
- */
-public class TermUuidAndTitleCacheLabelProvider extends ColumnLabelProvider {
-
-    @Override
-    public String getText(Object element) {
-        if(element instanceof TermVocabulary){
-            return ((TermVocabulary) element).getTitleCache();
-        }
-        else if(element instanceof UuidAndTitleCache){
-            return ((UuidAndTitleCache) element).getTitleCache();
-        }
-        return element.toString();
-    }
-
-}
