Project

General

Profile

Download (1.85 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2014 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.io.IOException;
13
import java.net.URISyntaxException;
14
import java.util.Collection;
15

    
16
import org.apache.http.client.ClientProtocolException;
17

    
18
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifQueryServiceWrapper;
19
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse;
20

    
21
/**
22
 * @author pplitzner
23
 * @date Sep 5, 2014
24
 *
25
 */
26
public class GbifResponseImportView extends DataImportView<GbifResponse> {
27

    
28

    
29
    public static final String ID = "eu.etaxonomy.taxeditor.view.dataimport.GbifResponseImportView";
30

    
31
    /* (non-Javadoc)
32
     * @see eu.etaxonomy.taxeditor.view.dataimport.DataImportView#getTextForTableItem(java.lang.Object)
33
     */
34
    @Override
35
    protected String getTextForTableItem(GbifResponse item) {
36
        String text = "";
37
        if(item.getDataSetProtocol()!=null){
38
            text += "["+item.getDataSetProtocol()+"] ";
39
        }
40
        text += item.getDerivedUnitFacade().innerDerivedUnit().generateTitle();
41
        return text;
42
    }
43

    
44
    /* (non-Javadoc)
45
     * @see eu.etaxonomy.taxeditor.view.dataimport.DataImportView#query()
46
     */
47
    @Override
48
    public void query() {
49
        String errorMessage = "Could not execute query " + query;
50
        try{
51
            Collection<GbifResponse> results = new GbifQueryServiceWrapper().query(query);
52
            setResults(results);
53
        } catch (ClientProtocolException e) {
54
            logger.error(errorMessage, e);
55
        } catch (IOException e) {
56
            logger.error(errorMessage, e);
57
        } catch (URISyntaxException e) {
58
            logger.error(errorMessage, e);
59
        }
60

    
61
    }
62

    
63
}
(8-8/15)