fix #8258: default feature tree without name features
authorKatja Luther <k.luther@bgbm.org>
Tue, 7 May 2019 07:43:05 +0000 (09:43 +0200)
committerKatja Luther <k.luther@bgbm.org>
Wed, 8 May 2019 11:37:21 +0000 (13:37 +0200)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/DynamicFeatureMenuE4.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/input/TermEditorInput.java

index ccdc081..950497b 100644 (file)
@@ -34,6 +34,7 @@ import eu.etaxonomy.cdm.model.term.DefinedTermBase;
 import eu.etaxonomy.cdm.model.term.FeatureNode;
 import eu.etaxonomy.cdm.model.term.FeatureTree;
 import eu.etaxonomy.cdm.model.term.VocabularyEnum;
+import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateDescriptionElementOperation;
 import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
@@ -136,12 +137,8 @@ public class DynamicFeatureMenuE4 {
                }
 
                if (featureTree == null) {
-                   List<Feature> terms = CdmStore.getTermManager().getPreferredTerms(CdmStore.getService(IVocabularyService.class).load(VocabularyEnum.Feature.getUuid()), null);
-            terms.remove(Feature.IMAGE());
-
-                       featureTree = FeatureTree.NewInstance(terms);
-
-               }
+                   featureTree = TermEditorInput.getDefaultFeatureTree();
+                               }
                if (description instanceof TaxonNameDescription){
                    List<Feature> terms = CdmStore.getTermManager().getPreferredTerms(CdmStore.getService(IVocabularyService.class).load(VocabularyEnum.NameFeature.getUuid()));
                    terms.remove(Feature.PROTOLOGUE());
index d0d626d..0c61050 100644 (file)
@@ -15,11 +15,12 @@ import java.util.List;
 import java.util.Set;
 
 import eu.etaxonomy.cdm.api.service.IVocabularyService;
+import eu.etaxonomy.cdm.model.description.Feature;
 import eu.etaxonomy.cdm.model.term.DefinedTerm;
+import eu.etaxonomy.cdm.model.term.FeatureTree;
 import eu.etaxonomy.cdm.model.term.TermType;
 import eu.etaxonomy.cdm.model.term.TermVocabulary;
-import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.model.term.FeatureTree;
+import eu.etaxonomy.cdm.model.term.VocabularyEnum;
 import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.store.TermStore;
@@ -98,7 +99,15 @@ public class TermEditorInput extends AbstractDefinedTermEditorInput<DefinedTerm>
 
     public static FeatureTree getDefaultFeatureTree() {
         if(defaultFeatureTree == null) {
-            defaultFeatureTree = FeatureTree.NewInstance(TermStore.getTerms(Feature.class));
+            List<Feature> features = TermStore.getTerms(Feature.class);
+            List<Feature> nameFeatures = CdmStore.getTermManager().getPreferredTerms(CdmStore.getService(IVocabularyService.class).load(VocabularyEnum.NameFeature.getUuid()), null);
+            List<Feature> copy = new ArrayList(features);
+            for (Feature feature: copy){
+                if (nameFeatures.contains(feature)){
+                    features.remove(feature);
+                }
+            }
+            defaultFeatureTree = FeatureTree.NewInstance(features);
         }
         return defaultFeatureTree;
     }