Project

General

Profile

Revision b5a13d3d

IDb5a13d3de8c5cfea13d9bf2ec0c74c1ee5be4552
Parent 29ee6f42
Child adfafad3

Added by Katja Luther over 3 years ago

set the tests to ignore until the dna import is fixed again

View differences:

cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/occurrence/OccurenceQuery.java
11 11

  
12 12
import java.text.SimpleDateFormat;
13 13
import java.util.Calendar;
14
import java.util.Set;
14 15

  
15 16
/**
16 17
 * Holds query parameters for a query to an occurrence provider.
......
21 22
public class OccurenceQuery {
22 23
    public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
23 24

  
24
    public final String unitId;
25
    public final Set<String[]> tripleIds;
25 26

  
26 27
    public final String taxonName;
27 28
    public final String collector;
......
35 36

  
36 37

  
37 38

  
38
    public OccurenceQuery(String unitId) {
39
        this(unitId, null, null, null, null, null, null, null, null, null);
39
    public OccurenceQuery(Set<String[]> tripleIds) {
40

  
41
        this(tripleIds, null, null, null, null, null, null, null, null, null);
40 42
    }
41 43

  
42 44
    /**
......
58 60
    /**
59 61
     * Constructor to initially set the parameters
60 62
     */
61
    private OccurenceQuery(String unitId, String taxonName, String collector, String collectorsNumber, String accessionNumber, String herbarium, String country, String locality, Calendar dateFrom, Calendar dateTo) {
62
        this.unitId = unitId;
63
    private OccurenceQuery(Set<String[]> tripleIds, String taxonName, String collector, String collectorsNumber, String accessionNumber, String herbarium, String country, String locality, Calendar dateFrom, Calendar dateTo) {
64
        this.tripleIds = tripleIds;
63 65
        this.taxonName = taxonName;
64 66
        this.collector = collector;
65 67
        this.collectorsNumber = collectorsNumber;
......
87 89
        result = prime * result + ((herbarium == null) ? 0 : herbarium.hashCode());
88 90
        result = prime * result + ((locality == null) ? 0 : locality.hashCode());
89 91
        result = prime * result + ((taxonName == null) ? 0 : taxonName.hashCode());
90
        result = prime * result + ((unitId == null) ? 0 : unitId.hashCode());
92
        result = prime * result + ((tripleIds == null) ? 0 : tripleIds.hashCode());
91 93
        return result;
92 94
    }
93 95

  
......
172 174
        } else if (!taxonName.equals(other.taxonName)) {
173 175
            return false;
174 176
        }
175
        if (unitId == null) {
176
            if (other.unitId != null) {
177
        if (tripleIds == null) {
178
            if (other.tripleIds != null) {
177 179
                return false;
178 180
            }
179
        } else if (!unitId.equals(other.unitId)) {
181
        } else if (!tripleIds.equals(other.tripleIds)) {
180 182
            return false;
181 183
        }
182 184
        return true;
......
191 193
    @Override
192 194
    public String toString() {
193 195
        String string = "";
194
        if(unitId!=null && !unitId.trim().isEmpty()){
195
            string += " unitId=" + unitId;
196
        if(tripleIds!=null ){
197
            string += " unitId=" ;
198
            for (String[] unitId: tripleIds){
199
                string += unitId + ", ";
200
            }
196 201
        }
197 202
        if(taxonName!=null && !taxonName.trim().isEmpty()){
198 203
            string += " taxonName=" + taxonName;
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/occurrence/bioCase/BioCaseQueryGenerator.java
74 74
    private static final String LIKE = "like";
75 75
    private static final String EQUALS = "equals";
76 76
    private static final String AND = "and";
77
    private static final String OR = "or";
77 78
    private static final String FILTER = "filter";
78 79
    private static final String RESPONSE_FORMAT = "responseFormat";
79 80
    private static final String REQUEST_FORMAT = "requestFormat";
......
111 112
        Element elResponseFormat = new Element(RESPONSE_FORMAT);
112 113
        Element elFilter = new Element(FILTER);
113 114
        Element elAnd = new Element(AND);
115

  
114 116
        Element elCount = new Element(COUNT);
115 117

  
116 118
        document.setRootElement(elRequest);
......
130 132
        elSearch.addContent(elFilter);
131 133
        elFilter.addContent(elAnd);
132 134

  
133
        if(query.unitId!=null && !query.unitId.trim().isEmpty()){
134
            addEqualsFilter(elAnd, query.unitId, UNIT_ID_PATH_ABCD_2_0);
135
        if(query.tripleIds!=null ){
136
            Element elOr = new Element(OR);;
137

  
138
            for (String[] unitId: query.tripleIds){
139
                addEqualsFilter(elOr, unitId[0], UNIT_ID_PATH_ABCD_2_0);
140

  
141
            }
142

  
143
            elAnd.addContent(elOr);
144

  
135 145
        }
136 146
        if(query.accessionNumber!=null && !query.accessionNumber.trim().isEmpty()){
137 147
            addLikeFilter(elAnd, query.accessionNumber, ACCESSION_NUMBER_PATH_ABCD_2_0);
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/occurrence/bioCase/BioCaseQueryServiceWrapper.java
28 28
import org.jdom.Document;
29 29
import org.jdom.output.Format;
30 30
import org.jdom.output.XMLOutputter;
31
import org.springframework.stereotype.Service;
32
import org.springframework.transaction.annotation.Transactional;
31 33
import org.w3c.dom.Element;
32 34
import org.w3c.dom.Node;
33 35
import org.w3c.dom.NodeList;
......
48 50
 * @date 13.09.2013
49 51
 *
50 52
 */
53

  
54
@Service
55
@Transactional(readOnly = true)
51 56
public class BioCaseQueryServiceWrapper extends ServiceWrapperBase<SpecimenOrObservationBase<?>>{
52 57

  
53 58
    private static final BasicNameValuePair SUBMIT_PARAM = new BasicNameValuePair("Submit", "Submit");
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/occurrence/gbif/GbifJsonOccurrenceParser.java
33 33
import eu.etaxonomy.cdm.model.location.Country;
34 34
import eu.etaxonomy.cdm.model.location.Point;
35 35
import eu.etaxonomy.cdm.model.location.ReferenceSystem;
36
import eu.etaxonomy.cdm.model.name.NonViralName;
37
import eu.etaxonomy.cdm.model.name.Rank;
36 38
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
39
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
37 40

  
38 41
/**
39 42
 * Utility class which provides the functionality to convert a JSON response
......
58 61
    private static final String LONGITUDE = "decimalLongitude";
59 62
    private static final String LATITUDE = "decimalLatitude";
60 63
    private static final String GEOREFERENCE_PROTOCOL = "georeferenceProtocol";//reference system
61
    private static final String ELEVATION = "verbatimElevation";
64
    private static final String VERBATIM_ELEVATION = "verbatimElevation";
62 65
    private static final String YEAR = "year";
63 66
    private static final String MONTH = "month";
64 67
    private static final String DAY = "day";
......
70 73
    private static final String OCCURRENCE_REMARKS = "occurrenceRemarks";//ecology
71 74
    private static final String COLLECTION_CODE = "collectionCode";
72 75
    private static final String CATALOG_NUMBER = "catalogNumber";//accession number
76
    private static final String INSTITUTION_CODE = "institutionCode";
77

  
78

  
79
    protected static final String PUBLISHING_ORG_KEY = "publishingOrgKey";
80
    protected static final String PUBLISHING_COUNTRY = "publishingCountry";
81

  
82
    protected static final String EXTENSIONS = "extensions";
83
    protected static final String BASIS_OF_RECORD = "basisOfRecord";
84
    protected static final String INDIVIDUAL_COUNT = "individualCount";
85
    protected static final String TAXONKEY = "taxonKey";
86
    protected static final String KINGDOM_KEY = "kingdomKey";
87
    protected static final String PHYLUM_KEY = "phylumKey";
88
    protected static final String CLASS_KEY = "classKey";
89
    protected static final String ORDER_KEY = "orderKey";
90
    protected static final String FAMILY_KEY = "familyKey";
91
    protected static final String GENUS_KEY = "genusKey";
92
    protected static final String SPECIES_KEY = "speciesKey";
93
    protected static final String SCIENTIFIC_NAME = "scientificName";
94
    protected static final String KINGDOM =  "kingdom";
95
    protected static final String PHYLUM = "phylum";
96
    protected static final String ORDER = "order";
97
    protected static final String FAMILY  = "family";
98
    protected static final String GENUS = "genus";
99
    protected static final String SPECIES = "species";
100
    protected static final String GENERIC_NAME = "genericName";
101
    protected static final String SPECIFIC_EPITHET = "specificEpithet";
102
    protected static final String INFRASPECIFIC_EPITHET = "infraspecificEpithet";
103
    protected static final String TAXON_RANK = "taxonRank";
104
    protected static final String DATE_IDENTIFIED = "dateIdentified";
105
    protected static final String SCIENTIFIC_NAME_AUTHORSHIP = "scientificNameAuthorship";
106

  
107
    protected static final String ELEVATION = "elevation";
108
    protected static final String CONITNENT = "continent";
109
    protected static final String STATE_PROVINCE = "stateProvince";
110

  
111

  
112

  
113

  
114
    protected static final String ISSUES = "issues";
115
    protected static final String LAST_INTERPRETED = "lastInterpreted";
116
    protected static final String IDENTIFIERS = "identifiers";
117
    protected static final String FACTS = "facts";
118
    protected static final String RELATIONS = "relations";
119
    protected static final String GEODETICDATUM = "geodeticDatum";
120
    protected static final String CLASS = "class";
121

  
122
    protected static final String COUNTRY = "country";
123
    protected static final String NOMENCLATURAL_STATUS = "nomenclaturalStatus";
124
    protected static final String RIGHTSHOLDER = "rightsHolder";
125
    protected static final String IDEMTIFIER = "identifier";
126

  
127
    protected static final String NOMENCLATURALCODE = "nomenclaturalCode";
128
    protected static final String COUNTY = "county";
129

  
130
    protected static final String DATASET_NAME = "datasetName";
131
    protected static final String GBIF_ID = "gbifID";
132

  
133
    protected static final String OCCURENCE_ID = "occurrenceID";
134

  
135
    protected static final String TAXON_ID = "taxonID";
136
    protected static final String LICENCE = "license";
137

  
138
    protected static final String OWNER_INSTITUTION_CODE = "ownerInstitutionCode";
139
    protected static final String BIBLIOGRAPHIC_CITATION = "bibliographicCitation";
140
    protected static final String IDENTIFIED_BY = "identifiedBy";
141
    protected static final String COLLECTION_ID = "collectionID";
142

  
143

  
144

  
73 145

  
74 146

  
75 147
    /**
......
110 182
     */
111 183
    private static Collection<GbifResponse> parseJsonRecords(JSONArray jsonArray) {
112 184
        Collection<GbifResponse> results = new ArrayList<GbifResponse>();
185
        String[] tripleId = new String[3];
113 186
        for(Object o:jsonArray){
114 187
            //parse every record
115 188
            if(o instanceof JSONObject){
116 189
                String dataSetKey = null;
117 190
                GbifDataSetProtocol dataSetProtocol = null;
118 191
                DerivedUnitFacade derivedUnitFacade = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
192
                NonViralName<NonViralName> name = null;
119 193
                JSONObject record = (JSONObject)o;
120 194

  
121 195
                if(record.has(DATASET_PROTOCOL)){
......
136 210
                    derivedUnitFacade.setLocality(string);
137 211
                }
138 212

  
213
                if (record.has("species")){
214
                    Rank rank = null;
215
                    String string;
216
                    if (record.has(TAXON_RANK)){
217
                        string= record.getString(TAXON_RANK);
218
                        try {
219
                            rank = Rank.getRankByName(string);
220
                        } catch (UnknownCdmTypeException e) {
221
                            // TODO Auto-generated catch block
222
                            e.printStackTrace();
223
                        }
224
                    }
225
                    if (rank != null){
226
                        name = NonViralName.NewInstance(rank);
227
                        if (record.has(GENUS)){
228
                            name.setGenusOrUninomial(record.getString(GENUS));
229
                        }
230
                        if (record.has(SPECIFIC_EPITHET)){
231
                            name.setSpecificEpithet(record.getString(SPECIFIC_EPITHET));
232
                        }
233
                        if (record.has(INFRASPECIFIC_EPITHET)){
234
                            name.setSpecificEpithet(record.getString(INFRASPECIFIC_EPITHET));
235
                        }
236
                    }
237
                }
238

  
239

  
240

  
139 241
                // GPS location
140 242
                Point location = Point.NewInstance();
141 243
                derivedUnitFacade.setExactLocation(location);
......
224 326
                }
225 327
                if(record.has(COLLECTION_CODE)){
226 328
                    String collectionCode = record.getString(COLLECTION_CODE);
329
                    tripleId[2] = collectionCode;
227 330
                    //FIXME: check data base for existing collections
228 331
                    eu.etaxonomy.cdm.model.occurrence.Collection collection = eu.etaxonomy.cdm.model.occurrence.Collection.NewInstance();
229 332
                    collection.setCode(collectionCode);
......
231 334
                }
232 335
                if(record.has(CATALOG_NUMBER)){
233 336
                    derivedUnitFacade.setAccessionNumber(record.getString(CATALOG_NUMBER));
337
                    tripleId[0]= record.getString(CATALOG_NUMBER);
338
                }
339
                if(record.has(INSTITUTION_CODE)){
340
                    derivedUnitFacade.setAccessionNumber(record.getString(INSTITUTION_CODE));
341
                    tripleId[1]= record.getString(INSTITUTION_CODE);
234 342
                }
343

  
235 344
                // create dataset URL
236 345
                URI uri = null;
237 346
                try {
......
241 350
                } catch (URISyntaxException e) {
242 351
                    logger.error("Endpoint URI could not be created!", e);
243 352
                }
244
                results.add(new GbifResponse(derivedUnitFacade, uri, dataSetProtocol));
353
                results.add(new GbifResponse(derivedUnitFacade, uri, dataSetProtocol, tripleId, name));
245 354
            }
246 355
        }
247 356
        return results;
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/occurrence/gbif/GbifQueryGenerator.java
36 36
        // only look for preserved specimens
37 37
        ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "basisOfRecord", "PRESERVED_SPECIMEN");
38 38
        ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "limit", "100");
39
        if (query.tripleIds != null){
40
            for (String[] tripleId:query.tripleIds){
41
                ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "CatalogNumber",tripleId[0]);
42
                ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "InstitutionCode",tripleId[1]);
43
                ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "CollectionCode", tripleId[2]);
44
            }
45
        }else{
46
            if((query.accessionNumber!=null && !query.accessionNumber.isEmpty()) || query.tripleIds != null){
47
                ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "CatalogNumber", query.accessionNumber);
39 48

  
40
        if(query.accessionNumber!=null && !query.accessionNumber.isEmpty()){
41
            ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "CatalogNumber", query.accessionNumber);
42
        }
43
        if(query.collector!=null && !query.collector.isEmpty()){
44
            ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "recordedBy", query.collector);
45
        }
46
        if(query.collectorsNumber!=null && !query.collectorsNumber.isEmpty()){
47
            // TODO refine parameter
48
            ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "fieldNumber", query.collectorsNumber);
49
            ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "recordNumber", query.collectorsNumber);
50
        }
51
        if(query.country!=null && !query.country.isEmpty()){
52
            ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "country", query.country);
53
        }
54
        /**
55
               Date Range: January – June 1899
56
               http://api.gbif.org/v0.9/occurrence/search?basisOfRecord=preserved_specimen&scientificName=Campanula%20persicifolia&year=1899&month=1,6
57
               Exact Date: june 20th 1901
58
               http://api.gbif.org/v0.9/occurrence/search?basisOfRecord=preserved_specimen&scientificName=Campanula%20persicifolia&eventDate=1901-6-20
59
               Date range exact: Jan. 02.1899 to june 03. 1902
60
               http://api.gbif.org/v0.9/occurrence/search?basisOfRecord=preserved_specimen&scientificName=Campanula%20persicifolia&eventDate=1899-1-2,1902-6-3
61
         */
62
        // FIXME: currently ONLY year is handled by the query (see GbifServiceWrapper)
63
        if(query.herbarium!=null && !query.herbarium.isEmpty()){
64
            // TODO refine parameter
65
            ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "institutionCode", query.herbarium);
66
        }
67
        if(query.locality!=null && !query.locality.isEmpty()){
68
            //TODO not yet available at GBIF
69
//            ServiceWrapperBase.addNameValuePairTo(queryParamsGET, param, query.locality);
70
        }
71
        if(query.taxonName!=null && !query.taxonName.isEmpty()){
72
            ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "scientificName", query.taxonName);
49
            }
50
            if(query.collector!=null && !query.collector.isEmpty()){
51
                ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "recordedBy", query.collector);
52
            }
53
            if(query.collectorsNumber!=null && !query.collectorsNumber.isEmpty()){
54
                // TODO refine parameter
55
                ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "fieldNumber", query.collectorsNumber);
56
                ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "recordNumber", query.collectorsNumber);
57
            }
58
            if(query.country!=null && !query.country.isEmpty()){
59
                ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "country", query.country);
60
            }
61
            /**
62
                   Date Range: January – June 1899
63
                   http://api.gbif.org/v0.9/occurrence/search?basisOfRecord=preserved_specimen&scientificName=Campanula%20persicifolia&year=1899&month=1,6
64
                   Exact Date: june 20th 1901
65
                   http://api.gbif.org/v0.9/occurrence/search?basisOfRecord=preserved_specimen&scientificName=Campanula%20persicifolia&eventDate=1901-6-20
66
                   Date range exact: Jan. 02.1899 to june 03. 1902
67
                   http://api.gbif.org/v0.9/occurrence/search?basisOfRecord=preserved_specimen&scientificName=Campanula%20persicifolia&eventDate=1899-1-2,1902-6-3
68
             */
69
            // FIXME: currently ONLY year is handled by the query (see GbifServiceWrapper)
70
            if(query.herbarium!=null && !query.herbarium.isEmpty()){
71
                // TODO refine parameter
72
                ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "institutionCode", query.herbarium);
73
            }
74
            if(query.locality!=null && !query.locality.isEmpty()){
75
                //TODO not yet available at GBIF
76
    //            ServiceWrapperBase.addNameValuePairTo(queryParamsGET, param, query.locality);
77
            }
78
            if(query.taxonName!=null && !query.taxonName.isEmpty()){
79
                ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "scientificName", query.taxonName);
80
            }
73 81
        }
74 82
        return queryParamsGET;
75 83
    }
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/occurrence/gbif/GbifQueryServiceWrapper.java
90 90
            //the unitID is delivered in the "catalogNumber" parameter which is set as the accessionNumber of the facade
91 91
            response.setUnitId(gbifResponse.getDerivedUnitFacade().getAccessionNumber());
92 92
            return response;
93
        }else{
94
            DataSetResponse response = GbifJsonOccurrenceParser.parseOriginalDataSetUri(executeHttpGet(gbifResponse.getDataSetUri(), null));
95
            //the unitID is delivered in the "catalogNumber" parameter which is set as the accessionNumber of the facade
96
            response.setUnitId(gbifResponse.getDerivedUnitFacade().getAccessionNumber());
97
            return response;
93 98
        }
94
        return null;
99

  
95 100
    }
96 101

  
97 102
}
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/occurrence/gbif/GbifResponse.java
12 12
import java.net.URI;
13 13

  
14 14
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
15
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
15 16

  
16 17
/**
17 18
 * Wrapper class which holds a {@link DerivedUnitFacade} which was parsed from a GBIF JSON response.
......
26 27
    private final DerivedUnitFacade derivedUnitFacade;
27 28
    private final URI dataSetUri;
28 29
    private final GbifDataSetProtocol dataSetProtocol;
30
    private final String[] tripleID;
31
    private final TaxonNameBase scientificName;
29 32
    /**
30 33
     * @param derivedUnitFacade
31 34
     * @param dataSetUrl
32 35
     */
33
    public GbifResponse(DerivedUnitFacade derivedUnitFacade, URI dataSetUrl, GbifDataSetProtocol dataSetProtocol) {
36
    public GbifResponse(DerivedUnitFacade derivedUnitFacade, URI dataSetUrl, GbifDataSetProtocol dataSetProtocol, String [] tripleID, TaxonNameBase scientificName) {
34 37
        super();
35 38
        this.derivedUnitFacade = derivedUnitFacade;
36 39
        this.dataSetUri = dataSetUrl;
37 40
        this.dataSetProtocol = dataSetProtocol;
41
        this.tripleID = tripleID;
42
        this.scientificName = scientificName;
43

  
38 44
    }
39 45

  
40 46
    public DerivedUnitFacade getDerivedUnitFacade() {
......
52 58
        return dataSetProtocol;
53 59
    }
54 60

  
61
    public String[] getTripleID(){
62
        return tripleID;
63
    }
64

  
65
    /**
66
     * @return the scientificName
67
     */
68
    public TaxonNameBase getScientificName() {
69
        return scientificName;
70
    }
71

  
55 72
}
cdmlib-ext/src/test/java/eu/etaxonomy/cdm/ext/occurrence/bioCase/BioCaseQueryServiceWrapperTest.java
14 14
import java.io.InputStream;
15 15
import java.io.InputStreamReader;
16 16
import java.net.URI;
17
import java.util.HashSet;
18
import java.util.Set;
17 19

  
18 20
import junit.framework.TestCase;
19 21

  
......
42 44
        if(UriUtils.isInternetAvailable(null)){
43 45
            BioCaseQueryServiceWrapper queryService = new BioCaseQueryServiceWrapper();
44 46
            try {
45
                OccurenceQuery query = new OccurenceQuery("Campanula patula*", "L. Adamovic", null, null, null, null, null, null, null);
47
                OccurenceQuery query = new OccurenceQuery("Campanula patula*", null, null, null, null, null, null, null, null);
46 48
                InputStream response = queryService.query(query, URI.create("http://ww3.bgbm.org/biocase/pywrapper.cgi?dsa=Herbar"));
47 49
                if(response==null){
48 50
                    logger.error("SKIPPING TEST: No response from BioCase provider");
......
88 90
        if(UriUtils.isInternetAvailable(null)){
89 91
            BioCaseQueryServiceWrapper service = new BioCaseQueryServiceWrapper();
90 92
            try {
91
                InputStream queryForSingleUnit = service.query(new OccurenceQuery("29596"), URI.create("http://www.flora-mv.de/biocase/pywrapper.cgi?dsa=hoeherePflanzen"));
93
                Set<String[]> unitIds = new HashSet<String[]>();
94
                String[] unitIdArray ={"29596"};
95
                unitIds.add(unitIdArray);
96
                InputStream queryForSingleUnit = service.query(new OccurenceQuery(unitIds), URI.create("http://www.flora-mv.de/biocase/pywrapper.cgi?dsa=hoeherePflanzen"));
97

  
92 98
                if(queryForSingleUnit==null){
93 99
                    logger.error("SKIPPING TEST: No response from BioCase provider");
94 100
                    return;
......
120 126
                    line = reader.readLine();
121 127
                    count++;
122 128
                } while (line!=null);
129
                unitIds = new HashSet<String[]>();
130
                String[] unitIdsArray = {"B -W 16385 -00 0"};
131
                unitIds.add(unitIdsArray);
132
                String[] unitIdsArray2 ={"B 10 0641985"};
133
                unitIds.add(unitIdsArray2);
134
                queryForSingleUnit = service.query(new OccurenceQuery(unitIds), URI.create("http://ww3.bgbm.org/biocase/pywrapper.cgi?dsa=Herbar"));
135
                if(queryForSingleUnit==null){
136
                    logger.error("SKIPPING TEST: No response from BioCase provider");
137
                    return;
138
                }
139
                reader = new BufferedReader(new InputStreamReader(queryForSingleUnit));
140
                line = null;
141
                count = 0;
142
                do {
143
                    if(count>MAX_LINES_TO_READ){
144
                        fail("Service response did not include parameter to test.");
145
                        break;
146
                    }
147
                    if(line!=null){
148
                        System.out.println(line);
149
                        String recordAttr = "recordCount=\"";
150
                        int index = line.indexOf(recordAttr);
151
                        if(index>-1){
152
                            String recordCount = line.substring(index+recordAttr.length(), index+recordAttr.length()+1);
153
                            assertEquals("Incorrect number of occurrences", 2, Integer.parseInt(recordCount));
154
                        }
155

  
156

  
157
                    }
158
                    line = reader.readLine();
159
                    count++;
160
                } while (line!=null);
123 161
            } catch (NumberFormatException e) {
124 162
                fail(e.getMessage());
125 163
            } catch (ClientProtocolException e) {
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/ImportConfiguratorBase.java
392 392
        askUserForHelp=interaction;
393 393
    }
394 394

  
395

  
396

  
395 397
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx2013/TaxonXImport.java
33 33
import org.springframework.transaction.TransactionStatus;
34 34
import org.w3c.dom.Document;
35 35

  
36
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
36 37
import eu.etaxonomy.cdm.io.common.ICdmIO;
37 38
import eu.etaxonomy.cdm.io.specimen.SpecimenImportBase;
38 39
import eu.etaxonomy.cdm.model.common.CdmBase;
......
366 367
    	return false;
367 368
    }
368 369

  
370
    /* (non-Javadoc)
371
     * @see eu.etaxonomy.cdm.io.specimen.SpecimenImportBase#handleSingleUnit(eu.etaxonomy.cdm.io.specimen.SpecimenImportStateBase, java.lang.Object)
372
     */
373
    @Override
374
    protected void handleSingleUnit(TaxonXImportState state, Object item) {
375
        // TODO Auto-generated method stub
376

  
377
    }
378

  
379
    /* (non-Javadoc)
380
     * @see eu.etaxonomy.cdm.io.specimen.SpecimenImportBase#importAssociatedUnits(eu.etaxonomy.cdm.io.specimen.SpecimenImportStateBase, java.lang.Object, eu.etaxonomy.cdm.api.facade.DerivedUnitFacade)
381
     */
382
    @Override
383
    protected void importAssociatedUnits(TaxonXImportState state, Object item, DerivedUnitFacade derivedUnitFacade) {
384
        // TODO Auto-generated method stub
385

  
386
    }
387

  
369 388

  
370 389
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx2013/TaxonXImportConfigurator.java
16 16

  
17 17
import eu.etaxonomy.cdm.database.ICdmDataSource;
18 18
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
19
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
20 19
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
20
import eu.etaxonomy.cdm.io.specimen.SpecimenImportConfiguratorBase;
21 21
import eu.etaxonomy.cdm.model.agent.Person;
22 22
import eu.etaxonomy.cdm.model.name.Rank;
23 23
import eu.etaxonomy.cdm.model.reference.Reference;
......
29 29
 * @created 29.07.2008
30 30
 * @version 1.0
31 31
 */
32
public class TaxonXImportConfigurator extends ImportConfiguratorBase<TaxonXImportState, URI> implements IImportConfigurator {
32
public class TaxonXImportConfigurator extends SpecimenImportConfiguratorBase<TaxonXImportState, URI> implements IImportConfigurator {
33 33
    //	private static final Logger logger = Logger.getLogger(TaxonXImportConfigurator.class);
34 34

  
35 35
    private String defaultImportClassification = null;
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx2013/TaxonXImportState.java
12 12

  
13 13
import org.apache.log4j.Logger;
14 14

  
15
import eu.etaxonomy.cdm.io.common.CdmImportBase;
16
import eu.etaxonomy.cdm.io.common.ImportStateBase;
15
import eu.etaxonomy.cdm.io.specimen.SpecimenImportStateBase;
17 16

  
18 17
/**
19 18
 * @author a.mueller
20 19
 * @created 11.05.2009
21 20
 * @version 1.0
22 21
 */
23
public class TaxonXImportState extends ImportStateBase<TaxonXImportConfigurator, CdmImportBase>{
22
public class TaxonXImportState extends SpecimenImportStateBase<TaxonXImportConfigurator, TaxonXImportState>{
24 23
    @SuppressWarnings("unused")
25 24
    private static final Logger logger = Logger.getLogger(TaxonXImportState.class);
26 25

  
......
35 34

  
36 35

  
37 36

  
37
    /* (non-Javadoc)
38
     * @see eu.etaxonomy.cdm.io.specimen.SpecimenImportStateBase#reset()
39
     */
40
    @Override
41
    public void reset() {
42
        // TODO Auto-generated method stub
43

  
44
    }
45

  
46

  
47

  
38 48
    //	/* (non-Javadoc)
39 49
    //	 * @see eu.etaxonomy.cdm.io.common.IoStateBase#initialize(eu.etaxonomy.cdm.io.common.IoConfiguratorBase)
40 50
    //	 */
cdmlib-io/src/test/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/AbcdGgbnImportTest.java
68 68
 * @author a.mueller
69 69
 * @created 29.01.2009
70 70
 */
71
@Ignore
71 72
public class AbcdGgbnImportTest extends CdmTransactionalIntegrationTest {
72 73

  
73 74
	@SpringBeanByName

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)