Revision 10f96af0
Added by Katja Luther over 5 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionEditor.java | ||
---|---|---|
81 | 81 |
import eu.etaxonomy.cdm.model.common.Representation; |
82 | 82 |
import eu.etaxonomy.cdm.model.common.TermIdInVocabularyComparator; |
83 | 83 |
import eu.etaxonomy.cdm.model.common.TermLanguageComparator; |
84 |
import eu.etaxonomy.cdm.model.common.TermType; |
|
84 | 85 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
85 | 86 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
86 | 87 |
import eu.etaxonomy.cdm.model.description.Distribution; |
... | ... | |
409 | 410 |
GridData gridData2 = new GridData(); |
410 | 411 |
gridData2.horizontalSpan = 1; |
411 | 412 |
gridData2.horizontalAlignment = SWT.RIGHT; |
413 |
|
|
412 | 414 |
button1.setLayoutData(gridData2); |
413 | 415 |
|
414 | 416 |
|
... | ... | |
482 | 484 |
GridData gridData2 = new GridData(); |
483 | 485 |
gridData2.horizontalSpan = 1; |
484 | 486 |
gridData2.horizontalAlignment = SWT.RIGHT; |
487 |
gridData2.horizontalIndent = 3; |
|
485 | 488 |
parent.setLayoutData(gridData2); |
486 | 489 |
parent.setLayout(gridLayout); |
487 | 490 |
searchText = createSearchBar(parent); |
... | ... | |
539 | 542 |
} |
540 | 543 |
|
541 | 544 |
loadNamedAreas(); |
545 |
if (areas == null){ |
|
546 |
areas = new TreeSet<>(); |
|
547 |
} |
|
542 | 548 |
for (DefinedTermBase area: areas) { |
543 | 549 |
this.areaToColumnIndexMap.put(index++, (NamedArea)area); |
544 | 550 |
String areaLabel; |
... | ... | |
575 | 581 |
String property = areaLabel; |
576 | 582 |
propertyToLabelMap.put(property, areaLabel); |
577 | 583 |
} |
584 |
|
|
578 | 585 |
} |
579 | 586 |
|
580 | 587 |
private SortedSet<DefinedTermBase> loadNamedAreas() { |
... | ... | |
582 | 589 |
|
583 | 590 |
String valuesAreas = PreferencesUtil.getStringValue(EditorPreferencePredicate.AvailableDistributionAreaTerms.getKey()); |
584 | 591 |
String values = PreferencesUtil.getStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey()); |
592 |
Set<UUID> uuidList = new HashSet<UUID>(); |
|
593 |
String[] split; |
|
594 |
List<String> listValue; |
|
595 |
List<DefinedTermBase> termlist = new ArrayList<DefinedTermBase>(); |
|
585 | 596 |
if (values != null && values != "") { //$NON-NLS-1$ |
586 |
String[] split = values.split(";"); //$NON-NLS-1$
|
|
587 |
List<String> listValue = Arrays.asList(split);
|
|
588 |
List<DefinedTermBase> termlist = new ArrayList<DefinedTermBase>(); |
|
589 |
Set<UUID> uuidList = new HashSet<UUID>(); |
|
597 |
split = values.split(";"); //$NON-NLS-1$ |
|
598 |
listValue = Arrays.asList(split); |
|
599 |
|
|
600 |
|
|
590 | 601 |
UUID uuid; |
591 | 602 |
for(String s : listValue){ |
592 | 603 |
uuid = UUID.fromString(s); |
593 | 604 |
uuidList.add(uuid); |
594 | 605 |
|
595 | 606 |
} |
596 |
IVocabularyService service = CdmStore.getService(IVocabularyService.class); |
|
597 |
List<TermVocabulary> vocs = service.find(uuidList); |
|
598 |
split = valuesAreas.split(";"); |
|
599 |
listValue = Arrays.asList(split); |
|
600 |
for (TermVocabulary voc: vocs){ |
|
601 |
termlist.addAll(service.getTerms(voc, null, null, null, null).getRecords()); |
|
602 |
} |
|
603 |
List<DefinedTermBase> filteredList = new ArrayList(); |
|
604 |
for (DefinedTermBase area: termlist){ |
|
605 |
if (listValue.contains(area.getUuid().toString())) { |
|
606 |
filteredList.add(area); |
|
607 |
} |
|
607 |
} |
|
608 | 608 |
|
609 |
List<TermVocabulary> vocs = new ArrayList<>(); |
|
610 |
IVocabularyService service = CdmStore.getService(IVocabularyService.class); |
|
611 |
if (uuidList.isEmpty()){ |
|
612 |
List<TermVocabulary<DefinedTermBase>> vocList = CdmStore.getService(IVocabularyService.class).findByTermType(TermType.NamedArea, null); |
|
613 |
vocs.addAll(vocList); |
|
614 |
}else{ |
|
615 |
vocs= service.find(uuidList); |
|
616 |
} |
|
617 |
split = valuesAreas.split(";"); |
|
618 |
listValue = Arrays.asList(split); |
|
619 |
for (TermVocabulary voc: vocs){ |
|
620 |
termlist.addAll(service.getTerms(voc, null, null, null, null).getRecords()); |
|
621 |
} |
|
622 |
List<DefinedTermBase> filteredList = new ArrayList(); |
|
623 |
for (DefinedTermBase area: termlist){ |
|
624 |
if (listValue.contains(area.getUuid().toString())) { |
|
625 |
filteredList.add(area); |
|
609 | 626 |
} |
610 | 627 |
|
611 |
if (PreferencesUtil.isSortNamedAreaByOrderInVocabulary()){ |
|
612 |
areas = getTermsOrderedByVocabularyOrder(filteredList); |
|
613 |
} else if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){ |
|
614 |
areas = getTermsOrderedByIdInVocabulary(filteredList); |
|
615 |
}else{ |
|
616 |
areas = getTermsOrderedByLabels(filteredList, CdmStore.getDefaultLanguage()); |
|
617 |
} |
|
618 | 628 |
} |
629 |
|
|
630 |
if (PreferencesUtil.isSortNamedAreaByOrderInVocabulary()){ |
|
631 |
areas = getTermsOrderedByVocabularyOrder(filteredList); |
|
632 |
} else if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){ |
|
633 |
areas = getTermsOrderedByIdInVocabulary(filteredList); |
|
634 |
}else{ |
|
635 |
areas = getTermsOrderedByLabels(filteredList, CdmStore.getDefaultLanguage()); |
|
636 |
} |
|
637 |
|
|
619 | 638 |
return null; |
620 | 639 |
} |
621 | 640 |
|
Also available in: Unified diff
ref #7999: if no pref exists for area vocs then use all vocs