2 * Copyright (C) 2013 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
.dataimport
.e4
;
11 import java
.net
.MalformedURLException
;
12 import java
.net
.URISyntaxException
;
15 import javax
.inject
.Inject
;
17 import org
.apache
.commons
.lang3
.StringUtils
;
18 import org
.eclipse
.jface
.wizard
.WizardPage
;
19 import org
.eclipse
.swt
.widgets
.Composite
;
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
;
28 * Wizard page for selecting the specimen provider
32 public class SpecimenProviderSelectionWizardPageE4
extends WizardPage
{
34 private SpecimenProviderSelectionController specimenProviderSelectionController
;
36 private String dataSet
;
37 private ServiceWrapperBase serviceWrapper
;
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.");
48 public void createControl(Composite parent
) {
49 specimenProviderSelectionController
= SpecimenProviderSelectionController
.getInstance(parent
, getWizard());
50 setControl(specimenProviderSelectionController
.getComposite());
51 //serviceWrapper = new BioCaseQueryServiceWrapper();
55 public QueryType
getQueryType(){
56 if(specimenProviderSelectionController
.getComposite().getBtnBioCaseProvider().getSelection()){
57 return QueryType
.BIOCASE
;
59 else {// if(specimenProviderSelectionController.getComposite().getBtnGbif().getSelection()){
60 return QueryType
.GBIF
;
64 public URI
getEndPoint() {
69 public boolean isPageComplete() {
70 if(specimenProviderSelectionController
.getComposite().getBtnBioCaseProvider().getSelection()){
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);
82 endPoint
= URI
.fromUrl(new URL(accessPoint
));
83 serviceWrapper
= new BioCaseQueryServiceWrapper();
84 serviceWrapper
.setBaseUrl(specimenProviderSelectionController
.getComposite().getTxtAccessPoint().getText());
85 this.setErrorMessage(null);
88 } catch (MalformedURLException e
) {
89 setErrorMessage("A valid URL has to be entered.");
91 } catch (URISyntaxException e
) {
92 setErrorMessage("A valid URL has to be entered.");
96 else if(specimenProviderSelectionController
.getComposite().getBtnGbif().getSelection()){
97 this.setErrorMessage(null);
103 public ServiceWrapperBase
getQueryServiceWrapper() {
104 return serviceWrapper
;
107 public void setQueryServiceWrapper(ServiceWrapperBase queryServiceWrapper
) {
108 this.serviceWrapper
= queryServiceWrapper
;
111 public SpecimenProviderSelectionController
getController() {
112 return specimenProviderSelectionController
;