Merge branch 'release/5.18.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / preference / GeneralTermPreferencePage.java
1 /**
2 * Copyright (C) 2019 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.taxeditor.preference;
10
11 import java.util.ArrayList;
12 import java.util.Collection;
13 import java.util.List;
14 import java.util.UUID;
15
16 import org.apache.commons.lang3.StringUtils;
17
18 import eu.etaxonomy.cdm.api.service.ITermService;
19 import eu.etaxonomy.cdm.persistence.dto.TermDto;
20 import eu.etaxonomy.taxeditor.store.CdmStore;
21
22 /**
23 * @author k.luther
24 * @since 26.09.2019
25 */
26 public class GeneralTermPreferencePage extends AbstractGeneralTermPreference<TermDto> {
27
28
29 public GeneralTermPreferencePage(String title) {
30 super(title);
31 }
32 public GeneralTermPreferencePage() {
33 super();
34 }
35
36 @Override
37 protected List<TermDto> getTermsFromStringValues(List<String> listValue) {
38 Collection<TermDto> termlist = new ArrayList<>();
39 ITermService termService = CdmStore.getService(ITermService.class);
40 List<UUID> uuidList = new ArrayList();
41 for (String s : listValue) {
42 if (!StringUtils.isBlank(s)){
43 UUID uuid = UUID.fromString(s);
44 uuidList.add(uuid);
45 }
46 }
47 if (!uuidList.isEmpty()){
48 termlist = termService.findByUUIDsAsDto(uuidList);
49 }
50
51 if (listValue == null || listValue.isEmpty() ){
52 termlist = termService.findByTitleAsDto("", type);
53
54 }
55
56 return new ArrayList(termlist);
57 }
58 }