Revision be7068cc
Added by Katja Luther over 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AbstractAreaSelectionWizard.java | ||
---|---|---|
15 | 15 |
import java.util.Set; |
16 | 16 |
import java.util.UUID; |
17 | 17 |
|
18 |
import org.apache.commons.lang.StringUtils; |
|
18 | 19 |
import org.eclipse.jface.viewers.CheckboxTableViewer; |
19 | 20 |
import org.eclipse.jface.viewers.CheckboxTreeViewer; |
20 | 21 |
import org.eclipse.jface.viewers.ColumnViewer; |
... | ... | |
24 | 25 |
import eu.etaxonomy.cdm.api.service.ITermService; |
25 | 26 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
26 | 27 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
28 |
import eu.etaxonomy.cdm.model.common.TermType; |
|
27 | 29 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
28 | 30 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
29 | 31 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
... | ... | |
37 | 39 |
|
38 | 40 |
private ColumnViewer viewer; |
39 | 41 |
private List<TermVocabulary<DefinedTermBase>> vocabularies = new ArrayList<>(); |
42 |
boolean localPref; |
|
40 | 43 |
|
41 | 44 |
|
42 | 45 |
/** |
... | ... | |
74 | 77 |
/** |
75 | 78 |
* @param vocs |
76 | 79 |
*/ |
77 |
protected void setVocabularies(List<TermVocabulary> vocs) { |
|
80 |
protected void setVocabularies(List<TermVocabulary<DefinedTermBase>> vocs) {
|
|
78 | 81 |
for (TermVocabulary voc:vocs){ |
79 | 82 |
vocabularies.add(voc); |
80 | 83 |
} |
... | ... | |
87 | 90 |
getViewer().setInput(getVocabularies()); |
88 | 91 |
|
89 | 92 |
if (grayedValues != null && grayedValues != "") { |
90 |
String[] listGrayed = grayedValues.split(";"); |
|
93 |
String[] arrayGrayed = grayedValues.split(";"); |
|
94 |
List<String> listGrayed = Arrays.asList(arrayGrayed); |
|
91 | 95 |
ArrayList listGrayedTerms = new ArrayList(); |
92 | 96 |
getTermsFromStringValues(listGrayed, listGrayedTerms); |
93 | 97 |
for(Object element : listGrayedTerms){ |
... | ... | |
99 | 103 |
} |
100 | 104 |
} |
101 | 105 |
if (checkedValues != null && checkedValues != "") { |
102 |
String[] listChecked = checkedValues.split(","); |
|
106 |
String[] listChecked = checkedValues.split(";"); |
|
107 |
String[] listCheckedComma = checkedValues.split(","); |
|
108 |
List<String> checked = new ArrayList<>(); |
|
109 |
if (listChecked != null ){ |
|
110 |
checked = Arrays.asList(listChecked); |
|
111 |
} |
|
112 |
if (listCheckedComma != null && checkedValues.contains(",")){ |
|
113 |
checked = Arrays.asList(listCheckedComma); |
|
114 |
} |
|
103 | 115 |
ArrayList<DefinedTermBase<?>> listCheckedTerms = new ArrayList<DefinedTermBase<?>>(); |
104 |
getTermsFromStringValues(listChecked, listCheckedTerms);
|
|
116 |
getTermsFromStringValues(checked, listCheckedTerms);
|
|
105 | 117 |
for(Object element : listCheckedTerms){ |
106 | 118 |
if(element != null){ |
107 | 119 |
if (getViewer() instanceof CheckboxTreeViewer) { |
... | ... | |
118 | 130 |
* @param split |
119 | 131 |
* @param termlist |
120 | 132 |
*/ |
121 |
private void getTermsFromStringValues(String[] split, ArrayList termlist) {
|
|
122 |
List<String> listValue = Arrays.asList(split); |
|
133 |
private void getTermsFromStringValues(List<String> listValue, ArrayList termlist) {
|
|
134 |
|
|
123 | 135 |
for (String s : listValue) { |
124 |
UUID uuid = UUID.fromString(s); |
|
125 |
ITermService termService = CdmStore.getService(ITermService.class); |
|
126 |
DefinedTermBase definedTermBase = termService.load(uuid); |
|
127 |
if(definedTermBase != null){ |
|
128 |
termlist.add(definedTermBase); |
|
129 |
}else{ |
|
130 |
IVocabularyService vocabularyService = CdmStore.getService(IVocabularyService.class); |
|
131 |
TermVocabulary termVocabulary = vocabularyService.load(uuid); |
|
132 |
termlist.add(termVocabulary); |
|
136 |
if (!StringUtils.isBlank(s)){ |
|
137 |
UUID uuid = UUID.fromString(s); |
|
138 |
ITermService termService = CdmStore.getService(ITermService.class); |
|
139 |
DefinedTermBase definedTermBase = termService.load(uuid); |
|
140 |
if(definedTermBase != null){ |
|
141 |
termlist.add(definedTermBase); |
|
142 |
}else{ |
|
143 |
IVocabularyService vocabularyService = CdmStore.getService(IVocabularyService.class); |
|
144 |
TermVocabulary termVocabulary = vocabularyService.load(uuid); |
|
145 |
termlist.add(termVocabulary); |
|
146 |
} |
|
133 | 147 |
} |
134 | 148 |
} |
135 | 149 |
} |
... | ... | |
139 | 153 |
if (getVocabularies() != null) { |
140 | 154 |
getVocabularies().clear(); |
141 | 155 |
} |
156 |
List<TermVocabulary<DefinedTermBase>> vocs = new ArrayList<>(); |
|
157 |
if (localPref){ |
|
158 |
String vocString = PreferencesUtil.getPreferenceStore().getString(PreferencesUtil.DISTRIBUTION_VOCABULARIES); |
|
159 |
String[] arrayVocs = vocString.split(";"); |
|
160 |
|
|
161 |
Set<UUID> uuidVocs = new HashSet(); |
|
162 |
for (String voc: arrayVocs){ |
|
163 |
if (!StringUtils.isBlank(voc)){ |
|
164 |
uuidVocs.add(UUID.fromString(voc)); |
|
165 |
} |
|
166 |
} |
|
167 |
List<TermVocabulary> tempVocs = CdmStore.getService(IVocabularyService.class).find(uuidVocs); |
|
168 |
for (TermVocabulary voc: tempVocs){ |
|
169 |
vocs.add(voc); |
|
170 |
} |
|
142 | 171 |
|
143 |
String vocString = PreferencesUtil.getPreferenceStore().getString(PreferencesUtil.DISTRIBUTION_VOCABULARIES); |
|
144 |
String[] arrayVocs = vocString.split(";"); |
|
145 |
|
|
146 |
Set<UUID> uuidVocs = new HashSet(); |
|
147 |
for (String voc: arrayVocs){ |
|
148 |
uuidVocs.add(UUID.fromString(voc)); |
|
172 |
}else{ |
|
173 |
vocs = CdmStore.getService(IVocabularyService.class).findByTermType( |
|
174 |
TermType.NamedArea, null); |
|
149 | 175 |
} |
150 |
|
|
151 |
List<TermVocabulary> vocs = CdmStore.getService(IVocabularyService.class).find(uuidVocs); |
|
152 |
|
|
153 | 176 |
setVocabularies(vocs); |
154 | 177 |
} |
155 | 178 |
|
Also available in: Unified diff
ref #7063:handle orderedTerms without orderindex and order by lable