Revision 31abf522
Added by Andreas Müller over 6 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/distributionStatus/settings/AreaAndTaxonSettingsPresenter.java | ||
---|---|---|
17 | 17 |
import com.vaadin.data.util.IndexedContainer; |
18 | 18 |
import com.vaadin.server.VaadinSession; |
19 | 19 |
|
20 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|
21 | 20 |
import eu.etaxonomy.cdm.model.common.TermType; |
22 | 21 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
23 | 22 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
23 |
import eu.etaxonomy.cdm.model.metadata.CdmPreference; |
|
24 |
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate; |
|
24 | 25 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
25 | 26 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
26 | 27 |
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper; |
... | ... | |
33 | 34 |
*/ |
34 | 35 |
public class AreaAndTaxonSettingsPresenter extends SettingsPresenterBase { |
35 | 36 |
|
36 |
private Container distributionContainer;
|
|
37 |
private Container areaContainer;
|
|
37 | 38 |
private UUID areaVocabUUID; |
38 | 39 |
|
39 | 40 |
/** |
... | ... | |
42 | 43 |
*/ |
43 | 44 |
public AreaAndTaxonSettingsPresenter() { |
44 | 45 |
super(); |
45 |
Object selectedVocabularyUuidString = VaadinSession.getCurrent().getAttribute(DistributionEditorUtil.SATTR_SELECTED_AREA_VOCABULARY_UUID); |
|
46 |
Object selectedVocabularyUuidString = VaadinSession.getCurrent() |
|
47 |
.getAttribute(DistributionEditorUtil.SATTR_SELECTED_AREA_VOCABULARY_UUID); |
|
46 | 48 |
if(selectedVocabularyUuidString!=null){ |
47 | 49 |
areaVocabUUID = UUID.fromString(selectedVocabularyUuidString.toString()); |
48 | 50 |
} |
49 |
distributionContainer = new IndexedContainer(getNamedAreaList());
|
|
51 |
areaContainer = new IndexedContainer(getNamedAreaList());
|
|
50 | 52 |
} |
51 | 53 |
|
52 |
public Container getDistributionContainer() { |
|
53 |
return distributionContainer; |
|
54 |
|
|
55 |
|
|
56 |
public Container getAreaContainer() { |
|
57 |
return areaContainer; |
|
58 |
} |
|
59 |
|
|
60 |
private List<TermVocabulary<? extends NamedArea>> getNamedAreaList() { |
|
61 |
CdmPreference areaVocPref = CdmSpringContextHelper.getPreferenceService() |
|
62 |
.findVaadin(PreferencePredicate.AvailableDistributionAreaVocabularies); |
|
63 |
if (areaVocPref != null){ |
|
64 |
List<UUID> uuidList = areaVocPref.getValueUuidList(); |
|
65 |
return (List)CdmSpringContextHelper.getVocabularyService().load(uuidList, VOCABULARY_INIT_STRATEGY); |
|
66 |
}else{ |
|
67 |
return (List)CdmSpringContextHelper.getVocabularyService().findByTermType(TermType.NamedArea, VOCABULARY_INIT_STRATEGY); |
|
68 |
} |
|
54 | 69 |
} |
55 | 70 |
|
56 |
private List<TermVocabulary<DefinedTermBase>> getNamedAreaList() { |
|
57 |
List<TermVocabulary<DefinedTermBase>> termList = CdmSpringContextHelper.getVocabularyService().findByTermType(TermType.NamedArea, VOCABULARY_INIT_STRATEGY);
|
|
58 |
return termList;
|
|
71 |
|
|
72 |
public TermVocabulary<NamedArea> getChosenAreaVoc(){
|
|
73 |
return CdmSpringContextHelper.getVocabularyService().load(areaVocabUUID);
|
|
59 | 74 |
} |
60 | 75 |
|
76 |
|
|
61 | 77 |
public List<TaxonNode> getChosenTaxonNodes(){ |
62 |
List<UUID> nodeUuids = (List<UUID>) VaadinSession.getCurrent().getAttribute(DistributionEditorUtil.SATTR_TAXON_NODES_UUID); |
|
78 |
List<UUID> nodeUuids = (List<UUID>) VaadinSession.getCurrent() |
|
79 |
.getAttribute(DistributionEditorUtil.SATTR_TAXON_NODES_UUID); |
|
63 | 80 |
if(nodeUuids!=null){ |
64 | 81 |
return CdmSpringContextHelper.getTaxonNodeService().load(nodeUuids, null); |
65 | 82 |
} |
... | ... | |
74 | 91 |
return null; |
75 | 92 |
} |
76 | 93 |
|
77 |
public TermVocabulary<NamedArea> getChosenAreaVoc(){ |
|
78 |
return CdmSpringContextHelper.getVocabularyService().load(areaVocabUUID); |
|
79 |
} |
|
80 | 94 |
|
81 | 95 |
protected static final List<String> VOCABULARY_INIT_STRATEGY = Arrays.asList(new String []{ |
82 | 96 |
"$", |
Also available in: Unified diff
ref #6903 allow preferences for distribution area vocabulary and distribution status