Revision 3799b968
Added by Patrick Plitzner almost 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java | ||
---|---|---|
392 | 392 |
public static String ChecklistEditorGeneralPreference_show_symbol; |
393 | 393 |
public static String ChecklistEditorGeneralPreference_sort_areas; |
394 | 394 |
|
395 |
public static String GfBioTerminologyImportPresenter_NO_CONNECTION_MESSAGE; |
|
396 |
|
|
397 |
|
|
398 |
public static String GfBioTerminologyImportPresenter_NO_CONNECTION_TITLE; |
|
399 |
|
|
400 |
|
|
401 |
public static String GfBioTerminologyImportPresenter_NO_RESULTS_MESSAGE; |
|
402 |
|
|
403 |
|
|
404 |
public static String GfBioTerminologyImportPresenter_NO_RESULTS_TITLE; |
|
405 |
|
|
406 |
|
|
395 | 407 |
public static String PublishFlagPreference_description; |
396 | 408 |
public static String PublishFlagPreference_do_not_set; |
397 | 409 |
public static String PublishFlagPreference_inherit; |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties | ||
---|---|---|
301 | 301 |
ChecklistEditorGeneralPreference_show_rank=Show Rank in Distribution Editor |
302 | 302 |
ChecklistEditorGeneralPreference_show_symbol=Show Symbol of the Status, if existing |
303 | 303 |
ChecklistEditorGeneralPreference_sort_areas=Sort Areas by Order in Vocabulary |
304 |
GfBioTerminologyImportPresenter_NO_CONNECTION_MESSAGE=Could not retrieve data from web service |
|
305 |
GfBioTerminologyImportPresenter_NO_CONNECTION_TITLE=Web service unavailable |
|
306 |
GfBioTerminologyImportPresenter_NO_RESULTS_MESSAGE=No results found for the query. |
|
307 |
GfBioTerminologyImportPresenter_NO_RESULTS_TITLE=No results found |
|
304 | 308 |
|
305 | 309 |
PublishFlagPreference_description=Configure the default settings for the publish flag in new created taxa |
306 | 310 |
PublishFlagPreference_do_not_set=Set no publish flag |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties | ||
---|---|---|
301 | 301 |
ChecklistEditorGeneralPreference_show_rank=Rank anzeigen |
302 | 302 |
ChecklistEditorGeneralPreference_show_symbol=Symbol des Status anzeigen, wenn es existiert |
303 | 303 |
ChecklistEditorGeneralPreference_sort_areas=Areas nach der Sortierung im Vokabular anzeigen |
304 |
GfBioTerminologyImportPresenter_NO_CONNECTION_MESSAGE=Konnte keine Verbindung zum Webservice herstellen. |
|
305 |
GfBioTerminologyImportPresenter_NO_CONNECTION_TITLE=Webservice nicht erreichbar |
|
306 |
GfBioTerminologyImportPresenter_NO_RESULTS_MESSAGE=Keine Ergebnisse f?r die Anfrage gefunden. |
|
307 |
GfBioTerminologyImportPresenter_NO_RESULTS_TITLE=Keine Ergebnisse |
|
304 | 308 |
|
305 | 309 |
PublishFlagPreference_description=Konfiguration des Default Verhaltens beim Setzen des Publish Flags in einem neu erzeugten Taxon. |
306 | 310 |
PublishFlagPreference_do_not_set=Kein Publish Flag |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportComposite.java | ||
---|---|---|
1 | 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 |
*/ |
|
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 | 9 |
package eu.etaxonomy.taxeditor.view.webimport.termimport; |
10 | 10 |
|
11 |
import org.eclipse.jface.viewers.ComboViewer; |
|
11 | 12 |
import org.eclipse.jface.viewers.TreeViewer; |
12 | 13 |
import org.eclipse.swt.SWT; |
13 | 14 |
import org.eclipse.swt.layout.GridData; |
14 | 15 |
import org.eclipse.swt.layout.GridLayout; |
15 | 16 |
import org.eclipse.swt.widgets.Button; |
17 |
import org.eclipse.swt.widgets.Combo; |
|
16 | 18 |
import org.eclipse.swt.widgets.Composite; |
17 | 19 |
import org.eclipse.swt.widgets.Text; |
18 | 20 |
import org.eclipse.swt.widgets.Tree; |
19 | 21 |
|
22 |
import eu.etaxonomy.taxeditor.model.ImageResources; |
|
23 |
|
|
20 | 24 |
/** |
21 | 25 |
* @author pplitzner |
22 | 26 |
* @since Apr 23, 2018 |
... | ... | |
26 | 30 |
private TreeViewer treeTermHierarchy; |
27 | 31 |
private Text txtSearch; |
28 | 32 |
private Button btnSearch; |
33 |
private Composite composite; |
|
34 |
private Button btnRemoveTerminology; |
|
35 |
private ComboViewer comboTerminologies; |
|
29 | 36 |
|
30 | 37 |
public GfBioTerminologyImportComposite(Composite parent, int style) { |
31 | 38 |
super(parent, style); |
32 |
setLayout(new GridLayout(2, false)); |
|
39 |
setLayout(new GridLayout(1, false)); |
|
40 |
|
|
41 |
composite = new Composite(this, SWT.NONE); |
|
42 |
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); |
|
43 |
composite.setLayout(new GridLayout(4, false)); |
|
33 | 44 |
|
34 |
txtSearch = new Text(this, SWT.BORDER);
|
|
45 |
txtSearch = new Text(composite, SWT.BORDER);
|
|
35 | 46 |
txtSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); |
36 | 47 |
|
37 |
btnSearch = new Button(this, SWT.NONE); |
|
48 |
comboTerminologies = new ComboViewer(composite, SWT.NONE); |
|
49 |
Combo combo = comboTerminologies.getCombo(); |
|
50 |
combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); |
|
51 |
|
|
52 |
btnRemoveTerminology = new Button(composite, SWT.NONE); |
|
53 |
btnRemoveTerminology.setImage(ImageResources.getImage(ImageResources.TRASH_ICON)); |
|
54 |
|
|
55 |
btnSearch = new Button(composite, SWT.NONE); |
|
38 | 56 |
btnSearch.setText("Search"); |
39 | 57 |
|
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);
|
|
58 |
treeTermHierarchy = new TreeViewer(this, SWT.BORDER); |
|
59 |
Tree tree = treeTermHierarchy.getTree(); |
|
60 |
GridData gd_tree = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
|
|
61 |
gd_tree.widthHint = 423; |
|
62 |
tree.setLayoutData(gd_tree); |
|
45 | 63 |
} |
46 | 64 |
public TreeViewer getTreeTermHierarchy() { |
47 | 65 |
return treeTermHierarchy; |
... | ... | |
52 | 70 |
public Text getTxtSearch() { |
53 | 71 |
return txtSearch; |
54 | 72 |
} |
73 |
public Button getBtnRemoveTerminology() { |
|
74 |
return btnRemoveTerminology; |
|
75 |
} |
|
76 |
public ComboViewer getComboTerminologies() { |
|
77 |
return comboTerminologies; |
|
78 |
} |
|
55 | 79 |
} |
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; |
|
11 | 12 |
import java.util.Collection; |
12 | 13 |
|
13 | 14 |
import org.eclipse.jface.util.LocalSelectionTransfer; |
15 |
import org.eclipse.jface.viewers.ArrayContentProvider; |
|
16 |
import org.eclipse.jface.viewers.ComboViewer; |
|
17 |
import org.eclipse.jface.viewers.ISelection; |
|
18 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
14 | 19 |
import org.eclipse.swt.SWT; |
15 | 20 |
import org.eclipse.swt.dnd.DND; |
16 | 21 |
import org.eclipse.swt.dnd.DragSourceAdapter; |
... | ... | |
21 | 26 |
import org.eclipse.swt.events.SelectionAdapter; |
22 | 27 |
import org.eclipse.swt.events.SelectionEvent; |
23 | 28 |
|
29 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
|
24 | 30 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
25 | 31 |
import eu.etaxonomy.taxeditor.view.webimport.termimport.parser.SuggestParser; |
32 |
import eu.etaxonomy.taxeditor.view.webimport.termimport.parser.TerminologyParser; |
|
33 |
import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestSearch; |
|
26 | 34 |
import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestSuggest; |
35 |
import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestTerminologies; |
|
27 | 36 |
import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.OntologyTermWrapper; |
37 |
import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.TerminologyWrapper; |
|
28 | 38 |
|
29 | 39 |
/** |
30 | 40 |
* @author pplitzner |
... | ... | |
33 | 43 |
*/ |
34 | 44 |
public class GfBioTerminologyImportPresenter { |
35 | 45 |
|
46 |
private static final String NO_CONNECTION_TITLE = Messages.GfBioTerminologyImportPresenter_NO_CONNECTION_TITLE; |
|
47 |
private static final String NO_CONNECTION_MESSAGE = Messages.GfBioTerminologyImportPresenter_NO_CONNECTION_MESSAGE; |
|
48 |
|
|
36 | 49 |
private GfBioTerminologyImportComposite composite; |
37 | 50 |
|
38 | 51 |
public GfBioTerminologyImportPresenter(GfBioTerminologyImportComposite composite) { |
... | ... | |
55 | 68 |
} |
56 | 69 |
} |
57 | 70 |
}); |
71 |
String response = new RequestTerminologies().request(); |
|
72 |
if(response==null){ |
|
73 |
MessagingUtils.informationDialog(NO_CONNECTION_TITLE, NO_CONNECTION_MESSAGE); |
|
74 |
return; |
|
75 |
} |
|
76 |
Collection<TerminologyWrapper> terminologies = TerminologyParser.parse(response); |
|
77 |
//combo |
|
78 |
ComboViewer comboOntologies = composite.getComboTerminologies(); |
|
79 |
comboOntologies.setLabelProvider(new TerminologyLabelProvider()); |
|
80 |
comboOntologies.setContentProvider(new ArrayContentProvider()); |
|
81 |
comboOntologies.setInput(terminologies); |
|
82 |
composite.getBtnRemoveTerminology().addSelectionListener(new SelectionAdapter() { |
|
83 |
@Override |
|
84 |
public void widgetSelected(SelectionEvent e) { |
|
85 |
composite.getComboTerminologies().setSelection(null); |
|
86 |
} |
|
87 |
}); |
|
88 |
|
|
89 |
composite.getTreeTermHierarchy().setContentProvider(new OntologyTermContentProvider()); |
|
90 |
composite.getTreeTermHierarchy().setLabelProvider(new OntologyTermLabelProvider()); |
|
91 |
|
|
58 | 92 |
//tree results |
59 | 93 |
composite.getTreeTermHierarchy().setContentProvider(new OntologyTermContentProvider()); |
60 | 94 |
composite.getTreeTermHierarchy().setLabelProvider(new OntologyTermLabelProvider()); |
... | ... | |
77 | 111 |
|
78 | 112 |
private void search(){ |
79 | 113 |
String searchString = composite.getTxtSearch().getText(); |
80 |
String response = new RequestSuggest(searchString).request(); |
|
81 |
if(response==null){ |
|
82 |
MessagingUtils.informationDialog("Web service unavailable", "Could not retrieve data from web service"); |
|
83 |
return; |
|
114 |
ISelection selection = composite.getComboTerminologies().getSelection(); |
|
115 |
Collection<OntologyTermWrapper> wrapperList = new ArrayList<>(); |
|
116 |
if(selection instanceof IStructuredSelection && !selection.isEmpty()){ |
|
117 |
//FIXME add support for mutliple terminology selection |
|
118 |
Object next = ((IStructuredSelection) selection).iterator().next(); |
|
119 |
if(next instanceof TerminologyWrapper){ |
|
120 |
String response = new RequestSearch(searchString, ((TerminologyWrapper) next).getName()).request(); |
|
121 |
if(response==null){ |
|
122 |
MessagingUtils.informationDialog(NO_CONNECTION_TITLE, NO_CONNECTION_MESSAGE); |
|
123 |
return; |
|
124 |
} |
|
125 |
wrapperList = SuggestParser.parse(response); |
|
126 |
} |
|
127 |
} |
|
128 |
else{ |
|
129 |
String response = new RequestSuggest(searchString).request(); |
|
130 |
if(response==null){ |
|
131 |
MessagingUtils.informationDialog(NO_CONNECTION_TITLE, NO_CONNECTION_MESSAGE); |
|
132 |
return; |
|
133 |
} |
|
134 |
wrapperList = SuggestParser.parse(response); |
|
135 |
} |
|
136 |
if(wrapperList.isEmpty()){ |
|
137 |
MessagingUtils.informationDialog(Messages.GfBioTerminologyImportPresenter_NO_RESULTS_TITLE, Messages.GfBioTerminologyImportPresenter_NO_RESULTS_MESSAGE); |
|
84 | 138 |
} |
85 |
Collection<OntologyTermWrapper> wrapperList = SuggestParser.parse(response); |
|
86 | 139 |
composite.getTreeTermHierarchy().setInput(wrapperList); |
87 | 140 |
} |
88 | 141 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/TerminologyLabelProvider.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2018 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.taxeditor.view.webimport.termimport; |
|
11 |
|
|
12 |
import org.eclipse.jface.viewers.LabelProvider; |
|
13 |
|
|
14 |
import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.TerminologyWrapper; |
|
15 |
|
|
16 |
/** |
|
17 |
* @author pplitzner |
|
18 |
* @date 15.05.2018 |
|
19 |
* |
|
20 |
*/ |
|
21 |
public class TerminologyLabelProvider extends LabelProvider { |
|
22 |
|
|
23 |
|
|
24 |
@Override |
|
25 |
public String getText(Object element) { |
|
26 |
if(element instanceof TerminologyWrapper){ |
|
27 |
return ((TerminologyWrapper) element).getName(); |
|
28 |
} |
|
29 |
return super.getText(element); |
|
30 |
} |
|
31 |
|
|
32 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/parser/TerminologyParser.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.TerminologyWrapper; |
|
20 |
|
|
21 |
/** |
|
22 |
* @author pplitzner |
|
23 |
* @since May 9, 2018 |
|
24 |
* |
|
25 |
*/ |
|
26 |
public class TerminologyParser { |
|
27 |
public static Collection<TerminologyWrapper> parse(String response){ |
|
28 |
List<TerminologyWrapper> 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 name = terminology.getString("name"); |
|
35 |
String acronym = terminology.getString("acronym"); |
|
36 |
String description = terminology.getString("description"); |
|
37 |
String uriString = terminology.getString("uri"); |
|
38 |
wrapperList.add(new TerminologyWrapper(name, acronym, description, uriString)); |
|
39 |
} |
|
40 |
} catch (JSONException e) { |
|
41 |
e.printStackTrace(); |
|
42 |
} |
|
43 |
return wrapperList; |
|
44 |
} |
|
45 |
|
|
46 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/requests/RequestSearch.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 RequestSearch extends AbstractTerminologyServiceRequest{ |
|
20 |
|
|
21 |
private String searchString; |
|
22 |
private String terminology; |
|
23 |
|
|
24 |
public RequestSearch(String searchString, String terminology) { |
|
25 |
super(); |
|
26 |
this.searchString = searchString; |
|
27 |
this.terminology = terminology; |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
protected String getServiceUri() { |
|
32 |
return TerminologyServiceConstants.SEARCH_SERVICE_URL; |
|
33 |
} |
|
34 |
|
|
35 |
@Override |
|
36 |
protected String getTerminologyId() { |
|
37 |
return null; |
|
38 |
} |
|
39 |
|
|
40 |
@Override |
|
41 |
protected List<RequestParameter> getServiceParameters() { |
|
42 |
List<RequestParameter> params = new ArrayList<>(); |
|
43 |
params.add(new RequestParameter(TerminologyServiceConstants.ATTR_QUERY, ".*"+searchString+".*")); |
|
44 |
params.add(new RequestParameter(TerminologyServiceConstants.ATTR_LIMIT, "20")); |
|
45 |
params.add(new RequestParameter("match_type", "regex")); |
|
46 |
params.add(new RequestParameter("internal_only", "true")); |
|
47 |
params.add(new RequestParameter("terminologies", terminology)); |
|
48 |
return params; |
|
49 |
} |
|
50 |
|
|
51 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/requests/TerminologyServiceConstants.java | ||
---|---|---|
18 | 18 |
public static final String NARROWER_SERVICE_URL = "narrower"; |
19 | 19 |
public static final String BROADER_SERVICE_URL = "broader"; |
20 | 20 |
public static final String SUGGEST_SERVICE_URL = "suggest"; |
21 |
public static final String SEARCH_SERVICE_URL = "search"; |
|
21 | 22 |
public static final String HIERARCHY_SERVICE_URL = "hierarchy"; |
22 | 23 |
public static final String TERM_SERVICE_URL = "term"; |
23 | 24 |
|
Also available in: Unified diff
ref #7362 Add ontology selection to GfBio import