2 * Copyright (C) 2019 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.view
.search
.facet
.term
;
11 import java
.util
.ArrayList
;
12 import java
.util
.Collection
;
13 import java
.util
.Comparator
;
14 import java
.util
.List
;
16 import org
.eclipse
.swt
.SWT
;
17 import org
.eclipse
.swt
.widgets
.Composite
;
19 import eu
.etaxonomy
.cdm
.api
.service
.ITermService
;
20 import eu
.etaxonomy
.cdm
.persistence
.dto
.TermDto
;
21 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
22 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
23 import eu
.etaxonomy
.taxeditor
.view
.search
.facet
.SearchComposite
;
24 import eu
.etaxonomy
.taxeditor
.view
.search
.facet
.SearchController
;
31 public class TermSearchController
extends SearchController
<TermSearchResult
, TermDto
> {
33 public TermSearchController(SearchComposite composite
) {
38 protected Comparator
<TermSearchResult
> getResultComparator(String searchString
) {
39 return new Comparator
<TermSearchResult
>() {
41 public int compare(TermSearchResult o1
, TermSearchResult o2
) {
42 String label1
= o1
.getContent().getRepresentation_L10n();
43 String label2
= o2
.getContent().getRepresentation_L10n();
44 return StoreUtil
.compareBySearchString(searchString
, label1
, label2
);
51 protected List
<TermSearchResult
> searchResults(String searchString
){
52 List
<TermSearchResult
> searchResults
= new ArrayList
<>();
53 Collection
<TermDto
> dtos
= CdmStore
.getService(ITermService
.class).findByTitleAsDto(searchString
);
54 dtos
.stream().forEach(dto
->searchResults
.add(new TermSearchResult(dto
)));
59 protected TermSearchResultComposite
createResultComposite(TermSearchResult result
, Composite parent
) {
60 return new TermSearchResultComposite(result
, parent
, SWT
.NONE
);
64 protected List
<TermSearchResult
> getSelectedResults() {