1
|
/**
|
2
|
* Copyright (C) 2013 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.dataimport.e4;
|
10
|
|
11
|
import java.net.MalformedURLException;
|
12
|
import java.net.URISyntaxException;
|
13
|
import java.net.URL;
|
14
|
|
15
|
import javax.inject.Inject;
|
16
|
|
17
|
import org.apache.commons.lang3.StringUtils;
|
18
|
import org.eclipse.jface.wizard.WizardPage;
|
19
|
import org.eclipse.swt.widgets.Composite;
|
20
|
|
21
|
import eu.etaxonomy.cdm.common.URI;
|
22
|
import eu.etaxonomy.cdm.ext.common.ServiceWrapperBase;
|
23
|
import eu.etaxonomy.cdm.ext.occurrence.bioCase.BioCaseQueryServiceWrapper;
|
24
|
import eu.etaxonomy.taxeditor.view.dataimport.QueryType;
|
25
|
import eu.etaxonomy.taxeditor.view.search.specimen.SpecimenProviderSelectionController;
|
26
|
|
27
|
/**
|
28
|
* Wizard page for selecting the specimen provider
|
29
|
* @author pplitzner
|
30
|
* @date 12.09.2013
|
31
|
*/
|
32
|
public class SpecimenProviderSelectionWizardPageE4 extends WizardPage{
|
33
|
|
34
|
private SpecimenProviderSelectionController specimenProviderSelectionController;
|
35
|
private URI endPoint;
|
36
|
private String dataSet;
|
37
|
private ServiceWrapperBase serviceWrapper;
|
38
|
|
39
|
@Inject
|
40
|
public SpecimenProviderSelectionWizardPageE4() {
|
41
|
super("Select specimen provider");
|
42
|
setTitle("Select Specimen Provider");
|
43
|
setDescription("Select the provider to query for specimens.\nTo query a BioCASE " +
|
44
|
"provider the access point URL must be entered.");
|
45
|
}
|
46
|
|
47
|
@Override
|
48
|
public void createControl(Composite parent) {
|
49
|
specimenProviderSelectionController = SpecimenProviderSelectionController.getInstance(parent, getWizard());
|
50
|
setControl(specimenProviderSelectionController.getComposite());
|
51
|
//serviceWrapper = new BioCaseQueryServiceWrapper();
|
52
|
|
53
|
}
|
54
|
|
55
|
public QueryType getQueryType(){
|
56
|
if(specimenProviderSelectionController.getComposite().getBtnBioCaseProvider().getSelection()){
|
57
|
return QueryType.BIOCASE;
|
58
|
}
|
59
|
else {// if(specimenProviderSelectionController.getComposite().getBtnGbif().getSelection()){
|
60
|
return QueryType.GBIF;
|
61
|
}
|
62
|
}
|
63
|
|
64
|
public URI getEndPoint() {
|
65
|
return endPoint;
|
66
|
}
|
67
|
|
68
|
@Override
|
69
|
public boolean isPageComplete() {
|
70
|
if(specimenProviderSelectionController.getComposite().getBtnBioCaseProvider().getSelection()){
|
71
|
endPoint = null;
|
72
|
try {
|
73
|
String dataSetAccesPoint = specimenProviderSelectionController.getComposite().getTxtAccessPoint().getText();
|
74
|
if (StringUtils.isNotBlank(dataSetAccesPoint)){
|
75
|
String accessPoint = dataSetAccesPoint;
|
76
|
if (dataSetAccesPoint.contains(" - ")){
|
77
|
dataSet = dataSetAccesPoint.substring(0, dataSetAccesPoint.indexOf(" - "));
|
78
|
accessPoint = dataSetAccesPoint.substring(dataSetAccesPoint.indexOf(" - ") + 3);
|
79
|
|
80
|
}
|
81
|
|
82
|
endPoint = URI.fromUrl(new URL(accessPoint));
|
83
|
serviceWrapper = new BioCaseQueryServiceWrapper();
|
84
|
serviceWrapper.setBaseUrl(specimenProviderSelectionController.getComposite().getTxtAccessPoint().getText());
|
85
|
this.setErrorMessage(null);
|
86
|
return true;
|
87
|
}
|
88
|
} catch (MalformedURLException e) {
|
89
|
setErrorMessage("A valid URL has to be entered.");
|
90
|
return false;
|
91
|
} catch (URISyntaxException e) {
|
92
|
setErrorMessage("A valid URL has to be entered.");
|
93
|
return false;
|
94
|
}
|
95
|
}
|
96
|
else if(specimenProviderSelectionController.getComposite().getBtnGbif().getSelection()){
|
97
|
this.setErrorMessage(null);
|
98
|
return true;
|
99
|
}
|
100
|
return false;
|
101
|
}
|
102
|
|
103
|
public ServiceWrapperBase getQueryServiceWrapper() {
|
104
|
return serviceWrapper;
|
105
|
}
|
106
|
|
107
|
public void setQueryServiceWrapper(ServiceWrapperBase queryServiceWrapper) {
|
108
|
this.serviceWrapper = queryServiceWrapper;
|
109
|
}
|
110
|
|
111
|
public SpecimenProviderSelectionController getController() {
|
112
|
return specimenProviderSelectionController;
|
113
|
}
|
114
|
}
|