From 10f96af07491e9b8207ee3a891b3f8865852ef52 Mon Sep 17 00:00:00 2001 From: Katja Luther Date: Thu, 17 Jan 2019 15:06:00 +0100 Subject: [PATCH] ref #7999: if no pref exists for area vocs then use all vocs --- .../view/checklist/e4/DistributionEditor.java | 65 ++++++++++++------- .../AbstractTermSelectionWizardPage.java | 1 + .../wizard/AvailableDistributionPage.java | 5 +- 3 files changed, 47 insertions(+), 24 deletions(-) diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionEditor.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionEditor.java index 8fc71bf5b..94aff6e4a 100755 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionEditor.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionEditor.java @@ -81,6 +81,7 @@ import eu.etaxonomy.cdm.model.common.OrderedTermComparator; import eu.etaxonomy.cdm.model.common.Representation; import eu.etaxonomy.cdm.model.common.TermIdInVocabularyComparator; import eu.etaxonomy.cdm.model.common.TermLanguageComparator; +import eu.etaxonomy.cdm.model.common.TermType; import eu.etaxonomy.cdm.model.common.TermVocabulary; import eu.etaxonomy.cdm.model.description.DescriptionElementBase; import eu.etaxonomy.cdm.model.description.Distribution; @@ -409,6 +410,7 @@ public class DistributionEditor extends Composite { GridData gridData2 = new GridData(); gridData2.horizontalSpan = 1; gridData2.horizontalAlignment = SWT.RIGHT; + button1.setLayoutData(gridData2); @@ -482,6 +484,7 @@ public class DistributionEditor extends Composite { GridData gridData2 = new GridData(); gridData2.horizontalSpan = 1; gridData2.horizontalAlignment = SWT.RIGHT; + gridData2.horizontalIndent = 3; parent.setLayoutData(gridData2); parent.setLayout(gridLayout); searchText = createSearchBar(parent); @@ -539,6 +542,9 @@ public class DistributionEditor extends Composite { } loadNamedAreas(); + if (areas == null){ + areas = new TreeSet<>(); + } for (DefinedTermBase area: areas) { this.areaToColumnIndexMap.put(index++, (NamedArea)area); String areaLabel; @@ -575,6 +581,7 @@ public class DistributionEditor extends Composite { String property = areaLabel; propertyToLabelMap.put(property, areaLabel); } + } private SortedSet loadNamedAreas() { @@ -582,40 +589,52 @@ public class DistributionEditor extends Composite { String valuesAreas = PreferencesUtil.getStringValue(EditorPreferencePredicate.AvailableDistributionAreaTerms.getKey()); String values = PreferencesUtil.getStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey()); + Set uuidList = new HashSet(); + String[] split; + List listValue; + List termlist = new ArrayList(); if (values != null && values != "") { //$NON-NLS-1$ - String[] split = values.split(";"); //$NON-NLS-1$ - List listValue = Arrays.asList(split); - List termlist = new ArrayList(); - Set uuidList = new HashSet(); + split = values.split(";"); //$NON-NLS-1$ + listValue = Arrays.asList(split); + + UUID uuid; for(String s : listValue){ uuid = UUID.fromString(s); uuidList.add(uuid); } - IVocabularyService service = CdmStore.getService(IVocabularyService.class); - List vocs = service.find(uuidList); - split = valuesAreas.split(";"); - listValue = Arrays.asList(split); - for (TermVocabulary voc: vocs){ - termlist.addAll(service.getTerms(voc, null, null, null, null).getRecords()); - } - List filteredList = new ArrayList(); - for (DefinedTermBase area: termlist){ - if (listValue.contains(area.getUuid().toString())) { - filteredList.add(area); - } + } + List vocs = new ArrayList<>(); + IVocabularyService service = CdmStore.getService(IVocabularyService.class); + if (uuidList.isEmpty()){ + List> vocList = CdmStore.getService(IVocabularyService.class).findByTermType(TermType.NamedArea, null); + vocs.addAll(vocList); + }else{ + vocs= service.find(uuidList); + } + split = valuesAreas.split(";"); + listValue = Arrays.asList(split); + for (TermVocabulary voc: vocs){ + termlist.addAll(service.getTerms(voc, null, null, null, null).getRecords()); + } + List filteredList = new ArrayList(); + for (DefinedTermBase area: termlist){ + if (listValue.contains(area.getUuid().toString())) { + filteredList.add(area); } - if (PreferencesUtil.isSortNamedAreaByOrderInVocabulary()){ - areas = getTermsOrderedByVocabularyOrder(filteredList); - } else if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){ - areas = getTermsOrderedByIdInVocabulary(filteredList); - }else{ - areas = getTermsOrderedByLabels(filteredList, CdmStore.getDefaultLanguage()); - } } + + if (PreferencesUtil.isSortNamedAreaByOrderInVocabulary()){ + areas = getTermsOrderedByVocabularyOrder(filteredList); + } else if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){ + areas = getTermsOrderedByIdInVocabulary(filteredList); + }else{ + areas = getTermsOrderedByLabels(filteredList, CdmStore.getDefaultLanguage()); + } + return null; } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AbstractTermSelectionWizardPage.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AbstractTermSelectionWizardPage.java index fa322be89..7b954fc79 100755 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AbstractTermSelectionWizardPage.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AbstractTermSelectionWizardPage.java @@ -121,6 +121,7 @@ public abstract class AbstractTermSelectionWizardPage extends WizardPage { } } } + return termlist; } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableDistributionPage.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableDistributionPage.java index c8ee45031..678c4b96c 100755 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableDistributionPage.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableDistributionPage.java @@ -94,7 +94,10 @@ public class AvailableDistributionPage extends AbstractTermSelectionWizardPage { vocs = CdmStore.getService(IVocabularyService.class).findVocabularyDtoByTermType(type); }else{ String vocString = PreferencesUtil.getStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey()); - + if (vocString.equals("")){ + vocs = CdmStore.getService(IVocabularyService.class).findVocabularyDtoByTermType(type); + return vocs; + } String[] arrayVocs = vocString.split(";"); //$NON-NLS-1$ Set uuidVocs = new HashSet<>(); -- 2.34.1