fix #6921 Migrate ABCD and GBIF import views
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / dataimport / e4 / SpecimenProviderSelectionWizardPageE4.java
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.URI;
13 import java.net.URISyntaxException;
14 import java.net.URL;
15
16 import javax.inject.Inject;
17
18 import org.eclipse.jface.wizard.WizardPage;
19 import org.eclipse.swt.widgets.Composite;
20
21 import eu.etaxonomy.cdm.ext.common.ServiceWrapperBase;
22 import eu.etaxonomy.cdm.ext.occurrence.bioCase.BioCaseQueryServiceWrapper;
23 import eu.etaxonomy.taxeditor.view.dataimport.QueryType;
24 import eu.etaxonomy.taxeditor.view.specimenSearch.SpecimenProviderSelectionController;
25
26
27 /**
28 * Wizard page for selecting the specimen provider
29 * @author pplitzner
30 * @date 12.09.2013
31 *
32 */
33 public class SpecimenProviderSelectionWizardPageE4 extends WizardPage{
34
35 private SpecimenProviderSelectionController specimenProviderSelectionController;
36 private URI endPoint;
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 /* (non-Javadoc)
48 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
49 */
50 @Override
51 public void createControl(Composite parent) {
52 specimenProviderSelectionController = SpecimenProviderSelectionController.getInstance(parent, getWizard());
53 setControl(specimenProviderSelectionController.getComposite());
54 //serviceWrapper = new BioCaseQueryServiceWrapper();
55
56 }
57
58 public QueryType getQueryType(){
59 if(specimenProviderSelectionController.getComposite().getBtnBioCaseProvider().getSelection()){
60 return QueryType.BIOCASE;
61 }
62 else {// if(specimenProviderSelectionController.getComposite().getBtnGbif().getSelection()){
63 return QueryType.GBIF;
64 }
65 }
66
67 /**
68 * @return
69 * @throws URISyntaxException
70 */
71 public URI getEndPoint() {
72 return endPoint;
73 }
74
75 /* (non-Javadoc)
76 * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
77 */
78 @Override
79 public boolean isPageComplete() {
80 if(specimenProviderSelectionController.getComposite().getBtnBioCaseProvider().getSelection()){
81 endPoint = null;
82 try {
83 endPoint = new URL(specimenProviderSelectionController.getComposite().getTxtAccessPoint().getText()).toURI();
84 serviceWrapper = new BioCaseQueryServiceWrapper();
85 serviceWrapper.setBaseUrl(specimenProviderSelectionController.getComposite().getTxtAccessPoint().getText());
86 this.setErrorMessage(null);
87 return true;
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 /**
104 * @return the bioCaseQueryServiceWrapper
105 */
106 public ServiceWrapperBase getQueryServiceWrapper() {
107 return serviceWrapper;
108 }
109
110 /**
111 * @param bioCaseQueryServiceWrapper the bioCaseQueryServiceWrapper to set
112 */
113 public void setQueryServiceWrapper(ServiceWrapperBase queryServiceWrapper) {
114 this.serviceWrapper = queryServiceWrapper;
115 }
116
117 /**
118 * @return
119 */
120 public SpecimenProviderSelectionController getController() {
121 return specimenProviderSelectionController;
122 }
123
124
125
126
127 }