Project

General

Profile

« Previous | Next » 

Revision dfd55109

Added by Katja Luther almost 8 years ago

smaller changes for specimen import

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/SpecimenProviderSelectionWizardPage.java
1
// $Id$
2
/**
3
* Copyright (C) 2013 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.dataimport;
11

  
12
import java.net.MalformedURLException;
13
import java.net.URI;
14
import java.net.URISyntaxException;
15
import java.net.URL;
16

  
17
import org.eclipse.jface.wizard.WizardPage;
18
import org.eclipse.swt.widgets.Composite;
19

  
20
import eu.etaxonomy.taxeditor.view.specimenSearch.SpecimenProviderSelectionController;
21

  
22

  
23
/**
24
 * Wizard page for selecting the specimen provider
25
 * @author pplitzner
26
 * @date 12.09.2013
27
 *
28
 */
29
public class SpecimenProviderSelectionWizardPage extends WizardPage{
30

  
31
    private SpecimenProviderSelectionController specimenProviderSelectionController;
32
    private URI endPoint;
33

  
34
    public SpecimenProviderSelectionWizardPage(String pageName) {
35
        super(pageName);
36
        setTitle("Select Specimen Provider");
37
        setDescription("Select the provider to query for specimens.\nTo query a BioCASE " +
38
        		"provider the access point URL must be entered.");
39
    }
40

  
41
    /* (non-Javadoc)
42
     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
43
     */
44
    @Override
45
    public void createControl(Composite parent) {
46
        specimenProviderSelectionController = SpecimenProviderSelectionController.getInstance(parent, getWizard());
47
        setControl(specimenProviderSelectionController.getComposite());
48
    }
49

  
50
    public QueryType getQueryType(){
51
        if(specimenProviderSelectionController.getComposite().getBtnBioCaseProvider().getSelection()){
52
            return QueryType.BIOCASE;
53
        }
54
        else {// if(specimenProviderSelectionController.getComposite().getBtnGbif().getSelection()){
55
            return QueryType.GBIF;
56
        }
57
    }
58

  
59
    /**
60
     * @return
61
     * @throws URISyntaxException
62
     */
63
    public URI getEndPoint() {
64
        return endPoint;
65
    }
66

  
67
    /* (non-Javadoc)
68
     * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
69
     */
70
    @Override
71
    public boolean isPageComplete() {
72
        if(specimenProviderSelectionController.getComposite().getBtnBioCaseProvider().getSelection()){
73
            endPoint = null;
74
            try {
75
                endPoint = new URL(specimenProviderSelectionController.getComposite().getTxtAccessPoint().getText()).toURI();
76
                this.setErrorMessage(null);
77
                return true;
78
            } catch (MalformedURLException e) {
79
                setErrorMessage("A valid URL has to be entered.");
80
                return false;
81
            } catch (URISyntaxException e) {
82
                setErrorMessage("A valid URL has to be entered.");
83
                return false;
84
            }
85
        }
86
        else if(specimenProviderSelectionController.getComposite().getBtnGbif().getSelection()){
87
            this.setErrorMessage(null);
88
            return true;
89
        }
90
        return false;
91
    }
92

  
93
    /**
94
     * @return
95
     */
96
    public SpecimenProviderSelectionController getController() {
97
        return specimenProviderSelectionController;
98
    }
99

  
100

  
101

  
102

  
103
}
1
// $Id$
2
/**
3
* Copyright (C) 2013 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.dataimport;
11

  
12
import java.net.MalformedURLException;
13
import java.net.URI;
14
import java.net.URISyntaxException;
15
import java.net.URL;
16

  
17
import org.eclipse.jface.wizard.WizardPage;
18
import org.eclipse.swt.widgets.Composite;
19

  
20
import eu.etaxonomy.cdm.ext.common.ServiceWrapperBase;
21
import eu.etaxonomy.cdm.ext.occurrence.bioCase.BioCaseQueryServiceWrapper;
22
import eu.etaxonomy.taxeditor.view.specimenSearch.SpecimenProviderSelectionController;
23

  
24

  
25
/**
26
 * Wizard page for selecting the specimen provider
27
 * @author pplitzner
28
 * @date 12.09.2013
29
 *
30
 */
31
public class SpecimenProviderSelectionWizardPage extends WizardPage{
32

  
33
    private SpecimenProviderSelectionController specimenProviderSelectionController;
34
    private URI endPoint;
35
    private ServiceWrapperBase serviceWrapper;
36

  
37
    public SpecimenProviderSelectionWizardPage(String pageName) {
38
        super(pageName);
39
        setTitle("Select Specimen Provider");
40
        setDescription("Select the provider to query for specimens.\nTo query a BioCASE " +
41
        		"provider the access point URL must be entered.");
42
    }
43

  
44
    /* (non-Javadoc)
45
     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
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
    /**
65
     * @return
66
     * @throws URISyntaxException
67
     */
68
    public URI getEndPoint() {
69
        return endPoint;
70
    }
71

  
72
    /* (non-Javadoc)
73
     * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
74
     */
75
    @Override
76
    public boolean isPageComplete() {
77
        if(specimenProviderSelectionController.getComposite().getBtnBioCaseProvider().getSelection()){
78
            endPoint = null;
79
            try {
80
                endPoint = new URL(specimenProviderSelectionController.getComposite().getTxtAccessPoint().getText()).toURI();
81
                serviceWrapper = new BioCaseQueryServiceWrapper();
82
                serviceWrapper.setBaseUrl(specimenProviderSelectionController.getComposite().getTxtAccessPoint().getText());
83
                this.setErrorMessage(null);
84
                return true;
85
            } catch (MalformedURLException e) {
86
                setErrorMessage("A valid URL has to be entered.");
87
                return false;
88
            } catch (URISyntaxException e) {
89
                setErrorMessage("A valid URL has to be entered.");
90
                return false;
91
            }
92
        }
93
        else if(specimenProviderSelectionController.getComposite().getBtnGbif().getSelection()){
94
            this.setErrorMessage(null);
95
            return true;
96
        }
97
        return false;
98
    }
99

  
100
    /**
101
     * @return the bioCaseQueryServiceWrapper
102
     */
103
    public ServiceWrapperBase getQueryServiceWrapper() {
104
        return serviceWrapper;
105
    }
106

  
107
    /**
108
     * @param bioCaseQueryServiceWrapper the bioCaseQueryServiceWrapper to set
109
     */
110
    public void setQueryServiceWrapper(ServiceWrapperBase queryServiceWrapper) {
111
        this.serviceWrapper = queryServiceWrapper;
112
    }
113

  
114
    /**
115
     * @return
116
     */
117
    public SpecimenProviderSelectionController getController() {
118
        return specimenProviderSelectionController;
119
    }
120

  
121

  
122

  
123

  
124
}

Also available in: Unified diff