2 * Copyright (C) 2014 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
.io
.IOException
;
12 import java
.net
.URISyntaxException
;
13 import java
.util
.Collection
;
15 import org
.apache
.http
.client
.ClientProtocolException
;
17 import eu
.etaxonomy
.cdm
.ext
.occurrence
.gbif
.GbifQueryServiceWrapper
;
18 import eu
.etaxonomy
.cdm
.ext
.occurrence
.gbif
.GbifResponse
;
25 public class GbifResponseImportView
extends DataImportView
<GbifResponse
> {
28 public static final String ID
= "eu.etaxonomy.taxeditor.view.dataimport.e4.GbifResponseImportView";
31 protected String
getTextForTableItem(GbifResponse item
) {
35 if(item
.getDataSetProtocol()!=null){
36 text
+= "["+item
.getDataSetProtocol()+"] ";
38 if (item
.getDerivedUnitFacade().getAccessionNumber() != null) {
39 unitId
= item
.getDerivedUnitFacade().getAccessionNumber();
40 }else if (item
.getDerivedUnitFacade().getBarcode() != null) {
41 unitId
= item
.getDerivedUnitFacade().getBarcode();
43 unitId
= item
.getDerivedUnitFacade().getCatalogNumber();
45 if(item
.getScientificName() != null){
47 text
= item
.getScientificName().getTitleCache();
50 String collectionCode
= item
.getDerivedUnitFacade().getCollection() != null ?
" - " + item
.getDerivedUnitFacade().getCollection().getCode(): "";
51 String kindOfUnit
= item
.getDerivedUnitFacade().getDerivedUnitKindOfUnit() != null ?
" - " + item
.getDerivedUnitFacade().getDerivedUnitKindOfUnit().toString():"";
53 return text
+ collectionCode
+ unitId
+ kindOfUnit
;
57 // if(item.getDataSetProtocol()!=null){
58 // text += "["+item.getDataSetProtocol()+"] ";
60 // text += item.getDerivedUnitFacade().innerDerivedUnit().generateTitle();
65 * @see eu.etaxonomy.taxeditor.view.dataimport.DataImportView#query()
69 String errorMessage
= "Could not execute query " + query
;
71 Collection
<GbifResponse
> results
= new GbifQueryServiceWrapper().query(query
);
73 } catch (ClientProtocolException e
) {
74 logger
.error(errorMessage
, e
);
75 } catch (IOException e
) {
76 logger
.error(errorMessage
, e
);
77 } catch (URISyntaxException e
) {
78 // TODO Auto-generated catch block