Project

General

Profile

Download (1.73 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2018 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.view.webimport.termimport.requests;
10

    
11
import java.util.ArrayList;
12
import java.util.Collection;
13
import java.util.List;
14
import java.util.stream.Collectors;
15

    
16
import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.TerminologyWrapper;
17

    
18
/**
19
 * @author pplitzner
20
 * @since Apr 23, 2018
21
 *
22
 */
23
public class RequestSearch extends AbstractTerminologyServiceRequest{
24

    
25
    private String searchString;
26
    private Collection<TerminologyWrapper> selectedOntologies;
27

    
28
    public RequestSearch(String searchString, Collection<TerminologyWrapper> selectedOntologies) {
29
        super();
30
        this.searchString = searchString;
31
        this.selectedOntologies = selectedOntologies;
32
    }
33

    
34
    @Override
35
    protected String getServiceUri() {
36
        return "search";
37
    }
38

    
39
    @Override
40
    protected String getTerminologyId() {
41
        return null;
42
    }
43

    
44
    @Override
45
    protected List<RequestParameter> getServiceParameters() {
46
        List<RequestParameter> params = new ArrayList<>();
47
        params.add(new RequestParameter(TerminologyServiceConstants.ATTR_QUERY, searchString));
48
        params.add(new RequestParameter("match_type", "regex"));
49
        params.add(new RequestParameter("internal_only", "true"));
50
        params.add(new RequestParameter(TerminologyServiceConstants.ATTR_TERMINOLOGIES,
51
                selectedOntologies.stream()
52
                .map(wrapper->wrapper.getAcronym())
53
                .collect(Collectors.joining(","))));
54
        return params;
55
    }
56

    
57
}
(5-5/9)