Revision fea04d02
Added by Katja Luther over 1 year ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/TermManager.java | ||
---|---|---|
24 | 24 |
import org.apache.commons.lang3.StringUtils; |
25 | 25 |
|
26 | 26 |
import eu.etaxonomy.cdm.api.service.ITermService; |
27 |
import eu.etaxonomy.cdm.model.term.DefinedTerm; |
|
27 | 28 |
import eu.etaxonomy.cdm.model.term.DefinedTermBase; |
28 | 29 |
import eu.etaxonomy.cdm.model.term.TermBase; |
29 | 30 |
import eu.etaxonomy.cdm.model.term.TermType; |
... | ... | |
215 | 216 |
protected <T extends DefinedTermBase> List<T> getTermsFromStringValues(List<String> listValue, TermType type) { |
216 | 217 |
List<DefinedTermBase> termlist = new ArrayList<>(); |
217 | 218 |
ITermService termService = CdmStore.getService(ITermService.class); |
218 |
Set<UUID> uuidList = new HashSet<>(); |
|
219 |
List<UUID> uuidList = new ArrayList<>(); |
|
220 |
|
|
219 | 221 |
for (String s : listValue) { |
220 | 222 |
if (StringUtils.isNotBlank(s)){ |
221 | 223 |
UUID uuid = UUID.fromString(s); |
222 | 224 |
uuidList.add(uuid); |
223 | 225 |
} |
224 | 226 |
} |
225 |
if (!uuidList.isEmpty()){ |
|
226 |
termlist = termService.find(uuidList); |
|
227 |
|
|
228 |
List<T> allTerms = getTerms(uuidList, type); |
|
229 |
if (!allTerms.isEmpty()) { |
|
230 |
return allTerms; |
|
231 |
} |
|
232 |
|
|
233 |
if (!uuidList.isEmpty() && allTerms.isEmpty()){ |
|
234 |
termlist = termService.find(new HashSet(uuidList)); |
|
227 | 235 |
}else{ |
228 | 236 |
termlist = termService.listByTermType(type, null, null, null, null); |
229 | 237 |
} |
... | ... | |
399 | 407 |
if (uuidList == null || uuidList.isEmpty()){ |
400 | 408 |
return terms; |
401 | 409 |
} |
410 |
Set<UUID> alreadyAdded = new HashSet<>(); |
|
411 |
Set<UUID> temp = new HashSet<>(); |
|
402 | 412 |
for (T term : terms){ |
403 | 413 |
if(uuidList.contains(term.getUuid())){ |
404 | 414 |
filteredTerms.add(term); |
415 |
alreadyAdded.add(term.getUuid()); |
|
405 | 416 |
} |
406 |
} |
|
407 |
|
|
417 |
} |
|
408 | 418 |
return filteredTerms; |
409 | 419 |
} |
410 | 420 |
|
Also available in: Unified diff
use cached terms also for uuid list