Project

General

Profile

Revision 5eee5e77

ID5eee5e77823528cc6638bc9b25e239b1a2be7e2b
Parent e6f55e01
Child 652496d7

Added by Patrick Plitzner about 2 years ago

ref #7362 Implement search interface for terminology service

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportComposite.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.view.webimport.termimport;
10 10

  
11
import org.eclipse.jface.viewers.ComboViewer;
12 11
import org.eclipse.jface.viewers.TreeViewer;
13 12
import org.eclipse.swt.SWT;
14 13
import org.eclipse.swt.layout.GridData;
15 14
import org.eclipse.swt.layout.GridLayout;
16
import org.eclipse.swt.widgets.Combo;
15
import org.eclipse.swt.widgets.Button;
17 16
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.swt.widgets.Text;
18 18
import org.eclipse.swt.widgets.Tree;
19 19

  
20 20
/**
......
24 24
 */
25 25
public class GfBioTerminologyImportComposite extends Composite{
26 26
    private TreeViewer treeTermHierarchy;
27
    private ComboViewer comboOntologies;
27
    private Text txtSearch;
28
    private Button btnSearch;
28 29

  
29 30
    public GfBioTerminologyImportComposite(Composite parent, int style) {
30 31
        super(parent, style);
31
        setLayout(new GridLayout(1, false));
32
        setLayout(new GridLayout(2, false));
32 33

  
33
        comboOntologies = new ComboViewer(this, SWT.NONE);
34
        Combo combo = comboOntologies.getCombo();
35
        combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
34
        txtSearch = new Text(this, SWT.BORDER);
35
        txtSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
36 36

  
37
        treeTermHierarchy = new TreeViewer(this, SWT.BORDER);
38
        Tree tree = treeTermHierarchy.getTree();
39
        tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
37
        btnSearch = new Button(this, SWT.NONE);
38
        btnSearch.setText("Search");
39

  
40
                treeTermHierarchy = new TreeViewer(this, SWT.BORDER);
41
                Tree tree = treeTermHierarchy.getTree();
42
                GridData gd_tree = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
43
                gd_tree.widthHint = 423;
44
                tree.setLayoutData(gd_tree);
40 45
    }
41 46
    public TreeViewer getTreeTermHierarchy() {
42 47
        return treeTermHierarchy;
43 48
    }
44
    public ComboViewer getComboOntologies() {
45
        return comboOntologies;
49
    public Button getBtnSearch() {
50
        return btnSearch;
51
    }
52
    public Text getTxtSearch() {
53
        return txtSearch;
46 54
    }
47 55
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportPresenter.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.view.webimport.termimport;
10 10

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

  
16
import org.eclipse.jface.viewers.ArrayContentProvider;
17
import org.eclipse.jface.viewers.ComboViewer;
18
import org.eclipse.jface.viewers.ISelectionChangedListener;
19
import org.eclipse.jface.viewers.SelectionChangedEvent;
20
import org.json.JSONArray;
21
import org.json.JSONException;
22
import org.json.JSONObject;
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.events.KeyEvent;
15
import org.eclipse.swt.events.KeyListener;
16
import org.eclipse.swt.events.SelectionEvent;
17
import org.eclipse.swt.events.SelectionListener;
23 18

  
24 19
import eu.etaxonomy.taxeditor.model.MessagingUtils;
25
import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestTerminologies;
26
import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.TerminologyServiceConstants;
20
import eu.etaxonomy.taxeditor.view.webimport.termimport.parser.SuggestParser;
21
import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestSuggest;
27 22
import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.OntologyTermWrapper;
28
import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.TerminologyWrapper;
29 23

  
30 24
/**
31 25
 * @author pplitzner
32 26
 * @since Apr 23, 2018
33 27
 *
34 28
 */
35
public class GfBioTerminologyImportPresenter implements ISelectionChangedListener {
29
public class GfBioTerminologyImportPresenter implements SelectionListener, KeyListener  {
36 30

  
37 31
    private GfBioTerminologyImportComposite composite;
38
    private OntologyTermContentProvider contentProvider;
39 32

  
40
    /**
41
     * @param composite
42
     */
43 33
    public GfBioTerminologyImportPresenter(GfBioTerminologyImportComposite composite) {
44 34
        super();
45 35
        this.composite = composite;
46
        String response = new RequestTerminologies().request();
36
        //text search
37
        composite.getBtnSearch().addSelectionListener(this);
38
        composite.getTxtSearch().addKeyListener(this);
39
        //tree results
40
        composite.getTreeTermHierarchy().setContentProvider(new OntologyTermContentProvider());
41
        composite.getTreeTermHierarchy().setLabelProvider(new OntologyTermLabelProvider());
42
    }
43

  
44
    private void search(){
45
        String searchString = composite.getTxtSearch().getText();
46
        String response = new RequestSuggest(searchString).request();
47 47
        if(response==null){
48 48
            MessagingUtils.informationDialog("Web service unavailable", "Could not retrieve data from web service");
49 49
            return;
50 50
        }
51
        //fetch terminology list via web service
52
        List<TerminologyWrapper> wrapperList = new ArrayList<>();
53
        try {
54
            JSONObject jsonResponse = new JSONObject(response);
55
            JSONArray responseArray = jsonResponse.getJSONArray("results");
56
            for(int i=0;i<responseArray.length();i++){
57
                JSONObject terminology = responseArray.getJSONObject(i);
58
                String name = terminology.getString("name");
59
                String acronym = terminology.getString("acronym");
60
                String description = terminology.getString("description");
61
                String uriString = terminology.getString("uri");
62
                wrapperList.add(new TerminologyWrapper(name, acronym, description, uriString));
63
            }
64
        } catch (JSONException e) {
65
            e.printStackTrace();
51
        Collection<OntologyTermWrapper> wrapperList = SuggestParser.parse(response);
52
        composite.getTreeTermHierarchy().setInput(wrapperList);
53
    }
54

  
55
    @Override
56
    public void widgetSelected(SelectionEvent e) {
57
        if(e.widget==composite.getBtnSearch()){
58
            search();
66 59
        }
67
        //combo
68
        ComboViewer comboOntologies = composite.getComboOntologies();
69
        comboOntologies.setLabelProvider(new TerminologyLabelProvider());
70
        comboOntologies.setContentProvider(new ArrayContentProvider());
71
        comboOntologies.setInput(wrapperList);
72
        comboOntologies.addSelectionChangedListener(this);
60
    }
73 61

  
74
        contentProvider = new OntologyTermContentProvider();
75
        composite.getTreeTermHierarchy().setContentProvider(contentProvider);
76
        composite.getTreeTermHierarchy().setLabelProvider(new OntologyTermLabelProvider());
62
    @Override
63
    public void widgetDefaultSelected(SelectionEvent e) {
77 64
    }
78 65

  
79
    /**
80
     * {@inheritDoc}
81
     */
82 66
    @Override
83
    public void selectionChanged(SelectionChangedEvent event) {
84
        //get root elements of selected ontology
85
        //FIXME: this service endpoint does not exist yet
86
        //so we use the root element of the PO for all selections
87
        String selectedOntology = "PO";
88
        contentProvider.setOntologyLabel(selectedOntology);
89
        Collection<OntologyTermWrapper> termWrappers = new HashSet<>();
90
        termWrappers.add(new OntologyTermWrapper(TerminologyServiceConstants.PO_ROOT_ELEMENT, "plant anatomical entity"));
91
        composite.getTreeTermHierarchy().setInput(termWrappers);
67
    public void keyPressed(KeyEvent e) {
68
        if(e.keyCode==SWT.CR){
69
            search();
70
        }
92 71
    }
93 72

  
73
    @Override
74
    public void keyReleased(KeyEvent e) {
75

  
76
    }
94 77

  
95 78
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/OntologyTermContentProvider.java
12 12
import java.util.Collection;
13 13

  
14 14
import org.eclipse.jface.viewers.ITreeContentProvider;
15
import org.json.JSONArray;
16
import org.json.JSONException;
17
import org.json.JSONObject;
18 15

  
19
import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestNarrower;
16
import eu.etaxonomy.taxeditor.view.webimport.termimport.parser.OntologyTermParser;
17
import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestBroader;
20 18
import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.OntologyTermWrapper;
21 19

  
22 20
/**
......
26 24
 */
27 25
public class OntologyTermContentProvider implements ITreeContentProvider {
28 26

  
29
    private String ontologyLabel;
30

  
31 27
    @Override
32 28
    public Object[] getElements(Object inputElement) {
33 29
        Collection<Object> elements = new ArrayList<>();
......
39 35

  
40 36
    @Override
41 37
    public Object[] getChildren(Object parentElement) {
42
        Collection<OntologyTermWrapper> wrapperList = new ArrayList<>();
43 38
        if(parentElement instanceof OntologyTermWrapper){
44
            String parentUri = ((OntologyTermWrapper) parentElement).getUri();
45
            String response = new RequestNarrower(parentUri, ontologyLabel).request();
46
            try {
47
                JSONObject jsonResponse = new JSONObject(response);
48
                JSONArray responseArray = jsonResponse.getJSONArray("results");
49
                for(int i=0;i<responseArray.length();i++){
50
                    JSONObject terminology = responseArray.getJSONObject(i);
51
                    String label = terminology.getString("label");
52
                    String uriString = terminology.getString("uri");
53
                    wrapperList.add(new OntologyTermWrapper(uriString, label));
54
                }
55
            } catch (JSONException e) {
56
                e.printStackTrace();
57
            }
39
            OntologyTermWrapper wrapper = (OntologyTermWrapper) parentElement;
40
            String response = new RequestBroader(wrapper.getUri(), wrapper.getSourceTerminology()).request();
41
            Collection<OntologyTermWrapper> broader = OntologyTermParser.parse(response, ((OntologyTermWrapper) parentElement).getSourceTerminology());
42
            return broader.toArray();
58 43
        }
59
        return wrapperList.toArray();
44
        return null;
60 45
    }
61 46

  
62 47
    @Override
......
69 54
        return true;
70 55
    }
71 56

  
72
    public void setOntologyLabel(String ontologyLabel) {
73
        this.ontologyLabel = ontologyLabel;
74
    }
75

  
76 57
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/OntologyTermLabelProvider.java
22 22
    @Override
23 23
    public String getText(Object element) {
24 24
        if(element instanceof OntologyTermWrapper){
25
            return ((OntologyTermWrapper) element).getLabel();
25
            OntologyTermWrapper wrapper = (OntologyTermWrapper) element;
26
            return wrapper.getSourceTerminology()+": "+wrapper.getLabel();
26 27
        }
27 28
        return super.getText(element);
28 29
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/TerminologyLabelProvider.java
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;
10

  
11
import org.eclipse.jface.viewers.LabelProvider;
12

  
13
import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.TerminologyWrapper;
14

  
15
/**
16
 * @author pplitzner
17
 * @since Apr 23, 2018
18
 *
19
 */
20
public class TerminologyLabelProvider extends LabelProvider {
21

  
22
    @Override
23
    public String getText(Object element) {
24
        if(element instanceof TerminologyWrapper){
25
            return ((TerminologyWrapper) element).getName();
26
        }
27
        return super.getText(element);
28
    }
29
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/parser/HierarchyParser.java
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.parser;
10

  
11
import java.util.Collection;
12
import java.util.LinkedList;
13

  
14
import org.json.JSONArray;
15
import org.json.JSONException;
16
import org.json.JSONObject;
17

  
18
import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.HierarchyTermWrapper;
19

  
20
/**
21
 * @author pplitzner
22
 * @since May 9, 2018
23
 *
24
 */
25
public class HierarchyParser {
26
    public static Collection<HierarchyTermWrapper> parse(String response){
27
        LinkedList<HierarchyTermWrapper> wrapperList = new LinkedList<>();
28
        try {
29
            JSONObject jsonResponse = new JSONObject(response);
30
            JSONArray responseArray = jsonResponse.getJSONArray("results");
31
            HierarchyTermWrapper childTerm = null;
32
            for(int i=0;i<responseArray.length();i++){
33
                JSONObject terminology = responseArray.getJSONObject(i);
34
                String label = terminology.getString("label");
35
                String uri = terminology.getString("uri");
36
                HierarchyTermWrapper hierarchyTermWrapper = new HierarchyTermWrapper(uri, label);
37
                wrapperList.add(hierarchyTermWrapper);
38
                if(childTerm!=null){
39
                    childTerm.setParentTerm(hierarchyTermWrapper);
40
                }
41
                childTerm = hierarchyTermWrapper;
42
            }
43
        } catch (JSONException jsonException) {
44
            jsonException.printStackTrace();
45
        }
46
        return wrapperList;
47
    }
48

  
49
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/parser/OntologyTermParser.java
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.parser;
10

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

  
15
import org.json.JSONArray;
16
import org.json.JSONException;
17
import org.json.JSONObject;
18

  
19
import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.OntologyTermWrapper;
20

  
21
/**
22
 * @author pplitzner
23
 * @since May 9, 2018
24
 *
25
 */
26
public class OntologyTermParser {
27
    public static Collection<OntologyTermWrapper> parse(String response, String terminology){
28
        List<OntologyTermWrapper> wrapperList = new ArrayList<>();
29
        try {
30
            JSONObject jsonResponse = new JSONObject(response);
31
            JSONArray responseArray = jsonResponse.getJSONArray("results");
32
            for(int i=0;i<responseArray.length();i++){
33
                JSONObject jsonObject = responseArray.getJSONObject(i);
34
                String label = jsonObject.getString("label");
35
                String uriString = jsonObject.getString("uri");
36
                wrapperList.add(new OntologyTermWrapper(uriString, label, terminology));
37
            }
38
        } catch (JSONException e) {
39
            e.printStackTrace();
40
        }
41
        return wrapperList;
42
    }
43

  
44
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/parser/SuggestParser.java
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.parser;
10

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

  
15
import org.json.JSONArray;
16
import org.json.JSONException;
17
import org.json.JSONObject;
18

  
19
import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.OntologyTermWrapper;
20

  
21
/**
22
 * @author pplitzner
23
 * @since May 9, 2018
24
 *
25
 */
26
public class SuggestParser {
27
    public static Collection<OntologyTermWrapper> parse(String response){
28
        List<OntologyTermWrapper> wrapperList = new ArrayList<>();
29
        try {
30
            JSONObject jsonResponse = new JSONObject(response);
31
            JSONArray responseArray = jsonResponse.getJSONArray("results");
32
            for(int i=0;i<responseArray.length();i++){
33
                JSONObject terminology = responseArray.getJSONObject(i);
34
                String label = terminology.getString("label");
35
                String uri = terminology.getString("uri");
36
                String sourceTerminology = terminology.getString("sourceTerminology");
37
                wrapperList.add(new OntologyTermWrapper(uri, label, sourceTerminology));
38
            }
39
        } catch (JSONException jsonException) {
40
            jsonException.printStackTrace();
41
        }
42
        return wrapperList;
43
    }
44

  
45
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/requests/AbstractTerminologyServiceRequest.java
30 30

  
31 31
            List<RequestParameter> serviceParameters = getServiceParameters();
32 32
            if(serviceParameters!=null){
33
                uriString += "?";
33
                uriString += "?format=json&";
34 34
                StringBuilder params = new StringBuilder();
35 35
                serviceParameters.forEach(param->params.append(param.key+"="+param.value+"&"));
36 36
                uriString += params.toString();
37 37
            }
38 38
            URL url = new URL(uriString);
39 39
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
40
            conn.setRequestProperty("format", "json");
41
            conn.setRequestMethod("GET");
42 40
            conn.setRequestProperty("Accept", "application/json");
43 41

  
44 42
            if (conn.getResponseCode() != 200) {
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/requests/RequestBroader.java
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.List;
13

  
14
/**
15
 * @author pplitzner
16
 * @since Apr 23, 2018
17
 *
18
 */
19
public class RequestBroader extends AbstractTerminologyServiceRequest{
20

  
21
    private String termUri;
22
    private String ontologyLabel;
23

  
24
    public RequestBroader(String termUri, String ontologyLabel) {
25
        super();
26
        this.termUri = termUri;
27
        this.ontologyLabel = ontologyLabel;
28
    }
29

  
30
    @Override
31
    protected String getServiceUri() {
32
        return TerminologyServiceConstants.BROADER_SERVICE_URL;
33
    }
34

  
35
    @Override
36
    protected String getTerminologyId() {
37
        return ontologyLabel;
38
    }
39

  
40
    @Override
41
    protected List<RequestParameter> getServiceParameters() {
42
        List<RequestParameter> params = new ArrayList<>();
43
        params.add(new RequestParameter(TerminologyServiceConstants.ATTR_URI, termUri));
44
        return params;
45
    }
46

  
47
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/requests/RequestHierarchy.java
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.List;
13

  
14
/**
15
 * @author pplitzner
16
 * @since Apr 23, 2018
17
 *
18
 */
19
public class RequestHierarchy extends AbstractTerminologyServiceRequest{
20

  
21
    private String termUri;
22

  
23
    public RequestHierarchy(String termUri) {
24
        super();
25
        this.termUri = termUri;
26
    }
27

  
28
    @Override
29
    protected String getServiceUri() {
30
        return TerminologyServiceConstants.HIERARCHY_SERVICE_URL;
31
    }
32

  
33
    /**
34
     * {@inheritDoc}
35
     */
36
    @Override
37
    protected String getTerminologyId() {
38
        return null;
39
    }
40

  
41
    /**
42
     * {@inheritDoc}
43
     */
44
    @Override
45
    protected List<RequestParameter> getServiceParameters() {
46
        List<RequestParameter> params = new ArrayList<>();
47
        params.add(new RequestParameter(TerminologyServiceConstants.ATTR_URI, termUri));
48
        return params;
49
    }
50

  
51
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/requests/RequestNarrower.java
32 32
        return TerminologyServiceConstants.NARROWER_SERVICE_URL;
33 33
    }
34 34

  
35
    /**
36
     * {@inheritDoc}
37
     */
38 35
    @Override
39 36
    protected String getTerminologyId() {
40 37
        return ontologyLabel;
41 38
    }
42 39

  
43
    /**
44
     * {@inheritDoc}
45
     */
46 40
    @Override
47 41
    protected List<RequestParameter> getServiceParameters() {
48 42
        List<RequestParameter> params = new ArrayList<>();
49
        params.add(new RequestParameter(TerminologyServiceConstants.ATR_URI, termUri));
43
        params.add(new RequestParameter(TerminologyServiceConstants.ATTR_URI, termUri));
50 44
        return params;
51 45
    }
52 46

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/requests/RequestSuggest.java
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.List;
13

  
14
/**
15
 * @author pplitzner
16
 * @since Apr 23, 2018
17
 *
18
 */
19
public class RequestSuggest extends AbstractTerminologyServiceRequest{
20

  
21
    private String suggestString;
22

  
23
    public RequestSuggest(String suggestString) {
24
        super();
25
        this.suggestString = suggestString;
26
    }
27

  
28
    @Override
29
    protected String getServiceUri() {
30
        return TerminologyServiceConstants.SUGGEST_SERVICE_URL;
31
    }
32

  
33
    /**
34
     * {@inheritDoc}
35
     */
36
    @Override
37
    protected String getTerminologyId() {
38
        return null;
39
    }
40

  
41
    /**
42
     * {@inheritDoc}
43
     */
44
    @Override
45
    protected List<RequestParameter> getServiceParameters() {
46
        List<RequestParameter> params = new ArrayList<>();
47
        params.add(new RequestParameter(TerminologyServiceConstants.ATTR_QUERY, suggestString));
48
        params.add(new RequestParameter(TerminologyServiceConstants.ATTR_LIMIT, "20"));
49
        return params;
50
    }
51

  
52
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/requests/TerminologyServiceConstants.java
17 17

  
18 18
    public static final String SERVICE_URL = "https://dev-gfbio.bgbm.org/api/terminologies/";
19 19
    public static final String NARROWER_SERVICE_URL = "narrower";
20
    public static final String BROADER_SERVICE_URL = "broader";
21
    public static final String SUGGEST_SERVICE_URL = "suggest";
22
    public static final String HIERARCHY_SERVICE_URL = "hierarchy";
20 23
    public static final String TERM_SERVICE_URL = "term";
21
    public static final String ATR_URI = "uri";
24

  
25
    public static final String ATTR_QUERY = "query";
26
    public static final String ATTR_URI = "uri";
27
    public static final String ATTR_LIMIT = "limit";
22 28

  
23 29
    public static final String PO_ROOT_ELEMENT = "http://purl.obolibrary.org/obo/PO_0025131";
24 30
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/wrapper/HierarchyTermWrapper.java
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.wrapper;
10

  
11
/**
12
 * @author pplitzner
13
 * @since Apr 23, 2018
14
 *
15
 */
16
public class HierarchyTermWrapper extends TermWrapper{
17

  
18
    private HierarchyTermWrapper parentTerm;
19
    public HierarchyTermWrapper(String uri, String label) {
20
        super(uri, label);
21
    }
22
    public HierarchyTermWrapper getParentTerm() {
23
        return parentTerm;
24
    }
25
    public void setParentTerm(HierarchyTermWrapper parentTerm) {
26
        this.parentTerm = parentTerm;
27
    }
28
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/wrapper/OntologyTermWrapper.java
13 13
 * @since Apr 23, 2018
14 14
 *
15 15
 */
16
public class OntologyTermWrapper {
16
public class OntologyTermWrapper extends TermWrapper{
17 17

  
18
    private String uri;
19
    private String label;
20
    public OntologyTermWrapper(String uri, String label) {
21
        this.uri = uri;
22
        this.label = label;
18
    private String sourceTerminology;
19
    public OntologyTermWrapper(String uri, String label, String sourceTerminology) {
20
        super(uri, label);
21
        this.sourceTerminology = sourceTerminology;
23 22
    }
24
    public String getUri() {
25
        return uri;
23
    public String getSourceTerminology() {
24
        return sourceTerminology;
26 25
    }
27
    public String getLabel() {
28
        return label;
29
    }
30

  
31 26
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/wrapper/TermWrapper.java
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.wrapper;
10

  
11
/**
12
 * @author pplitzner
13
 * @since May 9, 2018
14
 *
15
 */
16
public class TermWrapper {
17
    private String uri;
18
    private String label;
19
    public TermWrapper(String uri, String label) {
20
        this.uri = uri;
21
        this.label = label;
22
    }
23
    public String getUri() {
24
        return uri;
25
    }
26
    public String getLabel() {
27
        return label;
28
    }
29
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)