Project

General

Profile

« Previous | Next » 

Revision bd3475a0

Added by Patrick Plitzner about 8 years ago

  • removed parse logic because it was moved to cdmlib-ext

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenImportEditorInput.java
11 11

  
12 12
import java.io.IOException;
13 13
import java.io.InputStream;
14
import java.io.StringWriter;
15 14
import java.net.URISyntaxException;
16 15
import java.util.ArrayList;
17 16
import java.util.Collection;
18 17

  
19
import net.sf.json.JSONArray;
20
import net.sf.json.JSONObject;
21

  
22
import org.apache.commons.io.IOUtils;
23 18
import org.apache.http.client.ClientProtocolException;
24 19
import org.eclipse.swt.widgets.Display;
25 20

  
......
30 25
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
31 26
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
32 27
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
33
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
34 28
import eu.etaxonomy.taxeditor.editor.view.dataimport.transientServices.TransientCdmRepository;
35 29
import eu.etaxonomy.taxeditor.store.CdmStore;
36 30

  
......
61 55
            InputStream resultStream;
62 56
            switch (queryType) {
63 57
            case GBIF:
64
                resultStream = new GbifQueryServiceWrapper().query(query);
65
                StringWriter stringWriter = new StringWriter();
66
                IOUtils.copy(resultStream, stringWriter);
67
                String jsonString = stringWriter.toString();
68
                JSONArray resultsArray = JSONObject.fromObject(jsonString).getJSONArray("results");
69
                for(Object o:resultsArray){
70
                    //parse every record
71
                    if(o instanceof JSONObject){
72
                        DerivedUnitFacade derivedUnitFacade = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
73
                        JSONObject record = (JSONObject)o;
74

  
75
                        if(record.has("locality")){
76
                            String locality = record.getString("locality");
77
                            derivedUnitFacade.setLocality(locality);
78
                        }
79
                        results.add(derivedUnitFacade.innerDerivedUnit());
80
                    }
81

  
58
                Collection<DerivedUnitFacade> facades = new GbifQueryServiceWrapper().query(query);
59
                for(DerivedUnitFacade facade:facades){
60
                    results.add(facade.innerDerivedUnit());
82 61
                }
83 62
                break;
84 63
            case BIOCASE:
85
                resultStream = new BioCaseQueryServiceWrapper().query(SpecimenImportEditorInput.this.query);
64
                resultStream = new BioCaseQueryServiceWrapper().query(query);
86 65
                Abcd206ImportConfigurator configurator = Abcd206ImportConfigurator.NewInstance(resultStream, null, false);
87 66
                TransientCdmRepository repo =
88 67
                        new TransientCdmRepository(CdmStore.getCurrentApplicationConfiguration());

Also available in: Unified diff