Revision 5594bd68
Added by Katja Luther about 3 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionEditor.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import java.util.ArrayList; |
12 | 12 |
import java.util.Arrays; |
13 |
import java.util.Comparator; |
|
14 | 13 |
import java.util.HashMap; |
15 | 14 |
import java.util.HashSet; |
16 | 15 |
import java.util.Iterator; |
... | ... | |
93 | 92 |
import eu.etaxonomy.cdm.model.term.TermLanguageComparator; |
94 | 93 |
import eu.etaxonomy.cdm.model.term.TermType; |
95 | 94 |
import eu.etaxonomy.cdm.model.term.TermVocabulary; |
96 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto; |
|
97 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByNameComparator; |
|
98 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByRankAndNameComparator; |
|
99 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoNaturalComparator; |
|
100 | 95 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
101 | 96 |
import eu.etaxonomy.taxeditor.editor.IDistributionEditor; |
102 | 97 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
103 | 98 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
104 | 99 |
import eu.etaxonomy.taxeditor.model.ImageResources; |
105 |
import eu.etaxonomy.taxeditor.preference.NavigatorOrderEnum; |
|
106 | 100 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
107 | 101 |
import eu.etaxonomy.taxeditor.preference.Resources; |
108 | 102 |
import eu.etaxonomy.taxeditor.preference.wizard.AvailableDistributionWizard; |
... | ... | |
393 | 387 |
DistributionColumnAccessor columnPropertyAccessor = new DistributionColumnAccessor(this); |
394 | 388 |
|
395 | 389 |
DistributionEditorConfigLabelAccumulator labelAccumulator = new DistributionEditorConfigLabelAccumulator(this); |
396 |
Comparator<TaxonNodeDto> comparator; |
|
397 |
NavigatorOrderEnum orderValue = NavigatorOrderEnum.RankAndNameOrder; |
|
398 |
try{ |
|
399 |
orderValue = PreferencesUtil.getSortNodes(); |
|
400 |
}catch(IllegalArgumentException e){ |
|
401 |
|
|
402 |
} |
|
403 |
|
|
404 |
if (orderValue.equals(NavigatorOrderEnum.NaturalOrder)){ |
|
405 |
comparator = new TaxonNodeDtoNaturalComparator(); |
|
406 |
} else if (orderValue.equals(NavigatorOrderEnum.AlphabeticalOrder)){ |
|
407 |
comparator = new TaxonNodeDtoByNameComparator(); |
|
408 |
}else { |
|
409 |
comparator = new TaxonNodeDtoByRankAndNameComparator(); |
|
410 |
} |
|
411 |
bodyLayerStack = new BodyLayerStack<>(taxonList, columnPropertyAccessor, new TaxonDistributionDtoComparator(), labelAccumulator); |
|
412 | 390 |
|
391 |
// bodyLayerStack = new BodyLayerStack<>(taxonList, columnPropertyAccessor, new TaxonDistributionDtoComparator(), labelAccumulator); |
|
392 |
bodyLayerStack = new BodyLayerStack<>(taxonList, columnPropertyAccessor, null, labelAccumulator); |
|
413 | 393 |
bodyDataProvider = bodyLayerStack.getBodyDataProvider(); |
414 | 394 |
|
415 | 395 |
|
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionEditorPart.java | ||
---|---|---|
39 | 39 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
40 | 40 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
41 | 41 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
42 |
import eu.etaxonomy.cdm.api.service.TaxonNodeSortMode; |
|
42 | 43 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
43 | 44 |
import eu.etaxonomy.cdm.api.service.dto.TaxonDistributionDTO; |
44 | 45 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
... | ... | |
52 | 53 |
import eu.etaxonomy.taxeditor.model.IDirtyMarkable; |
53 | 54 |
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails; |
54 | 55 |
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData; |
56 |
import eu.etaxonomy.taxeditor.preference.NavigatorOrderEnum; |
|
57 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
|
55 | 58 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySession; |
56 | 59 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled; |
57 | 60 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
... | ... | |
63 | 66 |
* |
64 | 67 |
*/ |
65 | 68 |
public class DistributionEditorPart implements IE4SavablePart, IConversationEnabled, IDirtyMarkable, |
66 |
ICdmEntitySessionEnabled<DescriptionBase>, IPartContentHasSupplementalData, IPartContentHasDetails,
|
|
69 |
ICdmEntitySessionEnabled<DescriptionBase>, IPartContentHasSupplementalData, IPartContentHasDetails, |
|
67 | 70 |
IDistributionEditorPart { |
68 | 71 |
|
69 | 72 |
private static final List<String> TAXONNODE_PROPERTY_PATH = Arrays.asList(new String[] { |
... | ... | |
142 | 145 |
public void init(List<UuidAndTitleCache> uuidAndTitleCaches) { |
143 | 146 |
List<UUID> nodeUuids = new ArrayList<>(); |
144 | 147 |
uuidAndTitleCaches.forEach(element -> nodeUuids.add(element.getUuid())); |
145 |
this.taxonList = CdmStore.getService(ITaxonNodeService.class).getTaxonDistributionDTO(nodeUuids, TAXONNODE_PROPERTY_PATH, true); |
|
148 |
|
|
149 |
TaxonNodeSortMode sortMode = TaxonNodeSortMode.RankAndAlphabeticalOrder; |
|
150 |
NavigatorOrderEnum orderValue = NavigatorOrderEnum.RankAndNameOrder; |
|
151 |
try{ |
|
152 |
orderValue = PreferencesUtil.getSortNodes(); |
|
153 |
}catch(IllegalArgumentException e){ |
|
154 |
|
|
155 |
} |
|
156 |
|
|
157 |
if (orderValue.equals(NavigatorOrderEnum.NaturalOrder)){ |
|
158 |
sortMode = TaxonNodeSortMode.NaturalOrder; |
|
159 |
} else if (orderValue.equals(NavigatorOrderEnum.AlphabeticalOrder)){ |
|
160 |
sortMode = TaxonNodeSortMode.AlphabeticalOrder; |
|
161 |
}else { |
|
162 |
sortMode = TaxonNodeSortMode.RankAndAlphabeticalOrder; |
|
163 |
} |
|
164 |
this.taxonList = CdmStore.getService(ITaxonNodeService.class).getTaxonDistributionDTO(nodeUuids, TAXONNODE_PROPERTY_PATH,null, true, sortMode); |
|
146 | 165 |
// taxonList.stream().filter(taxonDistribution -> CdmStore.currentAuthentiationHasPermission(taxonDistribution.getTaxonUuid(), RequiredPermissions.TAXONNODE_EDIT)); |
147 | 166 |
|
148 | 167 |
|
... | ... | |
180 | 199 |
public void update(CdmDataChangeMap changeEvents) { |
181 | 200 |
// TODO Auto-generated method stub |
182 | 201 |
} |
183 |
|
|
202 |
|
|
184 | 203 |
@PreDestroy |
185 | 204 |
public void dispose(){ |
186 | 205 |
if (conversation != null) { |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/TaxonDistributionDtoComparator.java | ||
---|---|---|
30 | 30 |
|
31 | 31 |
@Override |
32 | 32 |
public int compare(TaxonDistributionDTO taxonDistr0, TaxonDistributionDTO taxonDistr1) { |
33 |
//if node is higher in tree then return 1; |
|
34 |
if (taxonDistr0.getTaxonNodeDto().getTreeIndex().split("#").length < taxonDistr1.getTaxonNodeDto().getTreeIndex().split("#").length){ |
|
35 |
return -1; |
|
36 |
}else if (taxonDistr0.getTaxonNodeDto().getTreeIndex().split("#").length > taxonDistr1.getTaxonNodeDto().getTreeIndex().split("#").length){ |
|
37 |
return 1; |
|
38 |
} |
|
33 | 39 |
|
34 | 40 |
//if parent is not the same sort by name |
35 | 41 |
if ((taxonDistr0.getTaxonNodeDto() != null && taxonDistr1.getTaxonNodeDto() != null) && !taxonDistr0.getTaxonNodeDto().getParentUUID().equals(taxonDistr1.getTaxonNodeDto().getParentUUID()) ){ |
Also available in: Unified diff
ref #8889: the dto list is already ordered for distribution editor, add sortMode to method call