Merge branch 'develop' into LibrAlign
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / dataimport / SpecimenProviderSelectionWizardPage.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;
10
11 import java.net.MalformedURLException;
12 import java.net.URI;
13 import java.net.URISyntaxException;
14 import java.net.URL;
15
16 import org.eclipse.jface.wizard.WizardPage;
17 import org.eclipse.swt.widgets.Composite;
18
19 import eu.etaxonomy.cdm.ext.common.ServiceWrapperBase;
20 import eu.etaxonomy.cdm.ext.occurrence.bioCase.BioCaseQueryServiceWrapper;
21 import eu.etaxonomy.taxeditor.view.specimenSearch.SpecimenProviderSelectionController;
22
23
24 /**
25 * Wizard page for selecting the specimen provider
26 * @author pplitzner
27 * @date 12.09.2013
28 *
29 */
30 public class SpecimenProviderSelectionWizardPage extends WizardPage{
31
32 private SpecimenProviderSelectionController specimenProviderSelectionController;
33 private URI endPoint;
34 private ServiceWrapperBase serviceWrapper;
35
36 public SpecimenProviderSelectionWizardPage(String pageName) {
37 super(pageName);
38 setTitle("Select Specimen Provider");
39 setDescription("Select the provider to query for specimens.\nTo query a BioCASE " +
40 "provider the access point URL must be entered.");
41 }
42
43 /* (non-Javadoc)
44 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
45 */
46 @Override
47 public void createControl(Composite parent) {
48 specimenProviderSelectionController = SpecimenProviderSelectionController.getInstance(parent, getWizard());
49 setControl(specimenProviderSelectionController.getComposite());
50 //serviceWrapper = new BioCaseQueryServiceWrapper();
51
52 }
53
54 public QueryType getQueryType(){
55 if(specimenProviderSelectionController.getComposite().getBtnBioCaseProvider().getSelection()){
56 return QueryType.BIOCASE;
57 }
58 else {// if(specimenProviderSelectionController.getComposite().getBtnGbif().getSelection()){
59 return QueryType.GBIF;
60 }
61 }
62
63 /**
64 * @return
65 * @throws URISyntaxException
66 */
67 public URI getEndPoint() {
68 return endPoint;
69 }
70
71 /* (non-Javadoc)
72 * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
73 */
74 @Override
75 public boolean isPageComplete() {
76 if(specimenProviderSelectionController.getComposite().getBtnBioCaseProvider().getSelection()){
77 endPoint = null;
78 try {
79 endPoint = new URL(specimenProviderSelectionController.getComposite().getTxtAccessPoint().getText()).toURI();
80 serviceWrapper = new BioCaseQueryServiceWrapper();
81 serviceWrapper.setBaseUrl(specimenProviderSelectionController.getComposite().getTxtAccessPoint().getText());
82 this.setErrorMessage(null);
83 return true;
84 } catch (MalformedURLException e) {
85 setErrorMessage("A valid URL has to be entered.");
86 return false;
87 } catch (URISyntaxException e) {
88 setErrorMessage("A valid URL has to be entered.");
89 return false;
90 }
91 }
92 else if(specimenProviderSelectionController.getComposite().getBtnGbif().getSelection()){
93 this.setErrorMessage(null);
94 return true;
95 }
96 return false;
97 }
98
99 /**
100 * @return the bioCaseQueryServiceWrapper
101 */
102 public ServiceWrapperBase getQueryServiceWrapper() {
103 return serviceWrapper;
104 }
105
106 /**
107 * @param bioCaseQueryServiceWrapper the bioCaseQueryServiceWrapper to set
108 */
109 public void setQueryServiceWrapper(ServiceWrapperBase queryServiceWrapper) {
110 this.serviceWrapper = queryServiceWrapper;
111 }
112
113 /**
114 * @return
115 */
116 public SpecimenProviderSelectionController getController() {
117 return specimenProviderSelectionController;
118 }
119
120
121
122
123 }