Revision bce192f4
Added by Patrick Plitzner almost 10 years ago
- refactored BioCaseQuery to more generic OccurrenceQuery
- for import wizard
- for DataImportEditor
- exported new cdmlib package structure for gbif and biocase querying in taxeditor.cdmlib
eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF | ||
---|---|---|
37 | 37 |
eu.etaxonomy.cdm.database.update.v25_30, |
38 | 38 |
eu.etaxonomy.cdm.database.update.v30_31, |
39 | 39 |
eu.etaxonomy.cdm.ext.bci, |
40 |
eu.etaxonomy.cdm.ext.biocase, |
|
40 |
eu.etaxonomy.cdm.ext.occurrence, |
|
41 |
eu.etaxonomy.cdm.ext.occurrence.bioCase, |
|
42 |
eu.etaxonomy.cdm.ext.occurrence.gbif, |
|
41 | 43 |
eu.etaxonomy.cdm.ext.common, |
42 | 44 |
eu.etaxonomy.cdm.ext.dc, |
43 | 45 |
eu.etaxonomy.cdm.ext.geo, |
eu.etaxonomy.taxeditor.editor/plugin.xml | ||
---|---|---|
1276 | 1276 |
category="eu.etaxonomy.taxeditor.import.category.cdm" |
1277 | 1277 |
class="eu.etaxonomy.taxeditor.editor.view.dataimport.SpecimenSearchWizard" |
1278 | 1278 |
id="eu.etaxonomy.taxeditor.editor.view.dataimport.SpecimenSearchWizard" |
1279 |
name="Query BioCASE">
|
|
1279 |
name="Specimen Search/Import">
|
|
1280 | 1280 |
<description> |
1281 |
Query BioCaseProvider
|
|
1281 |
Queries data provider (currently only GBIF) for specimens with specified parameters.
|
|
1282 | 1282 |
</description> |
1283 | 1283 |
</wizard> |
1284 | 1284 |
</extension> |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditor.java | ||
---|---|---|
100 | 100 |
setInput(input); |
101 | 101 |
setPartName(input.getName()); |
102 | 102 |
setTitleToolTip(input.getName()); |
103 |
conversation = ((DataImportEditorInput)input).getConversationHolder(); |
|
103 |
conversation = ((DataImportEditorInput<T>)input).getConversationHolder();
|
|
104 | 104 |
} |
105 | 105 |
|
106 | 106 |
/* (non-Javadoc) |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SaveSpecimenCommand.java | ||
---|---|---|
28 | 28 |
final ISelection selection = window.getActivePage().getSelection(); |
29 | 29 |
if(selection instanceof StructuredSelection){ |
30 | 30 |
StructuredSelection structuredSelection = (StructuredSelection)selection; |
31 |
Iterator iterator = structuredSelection.iterator(); |
|
31 |
Iterator<?> iterator = structuredSelection.iterator();
|
|
32 | 32 |
while(iterator.hasNext()){ |
33 | 33 |
Object next = iterator.next(); |
34 | 34 |
if(next instanceof SpecimenOrObservationBase){ |
35 | 35 |
IWorkbenchPart activePart = AbstractUtility.getActivePart(); |
36 | 36 |
if(activePart instanceof DataImportEditor){ |
37 | 37 |
SpecimenImportEditor dataImportEditor = (SpecimenImportEditor)activePart; |
38 |
CdmStore.getService(IOccurrenceService.class).saveOrUpdate((SpecimenOrObservationBase) next); |
|
38 |
CdmStore.getService(IOccurrenceService.class).saveOrUpdate((SpecimenOrObservationBase<?>) next);
|
|
39 | 39 |
dataImportEditor.getConversationHolder().commit(true); |
40 | 40 |
} |
41 | 41 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenImportEditor.java | ||
---|---|---|
17 | 17 |
* @date 20.09.2013 |
18 | 18 |
* |
19 | 19 |
*/ |
20 |
public class SpecimenImportEditor extends DataImportEditor<SpecimenOrObservationBase> { |
|
20 |
public class SpecimenImportEditor extends DataImportEditor<SpecimenOrObservationBase<?>> {
|
|
21 | 21 |
|
22 | 22 |
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.dataimport.SpecimenImportEditor"; |
23 | 23 |
|
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenImportEditorInput.java | ||
---|---|---|
18 | 18 |
import org.apache.http.client.ClientProtocolException; |
19 | 19 |
import org.eclipse.swt.widgets.Display; |
20 | 20 |
|
21 |
import eu.etaxonomy.cdm.ext.biocase.BioCaseQuery; |
|
22 |
import eu.etaxonomy.cdm.ext.biocase.BioCaseQueryServiceWrapper; |
|
23 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
|
24 |
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator; |
|
21 |
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery; |
|
22 |
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifQueryServiceWrapper; |
|
25 | 23 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
26 |
import eu.etaxonomy.taxeditor.editor.view.dataimport.transientServices.TransientCdmRepository; |
|
27 | 24 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
28 | 25 |
|
29 | 26 |
/** |
... | ... | |
31 | 28 |
* @date 25.02.2014 |
32 | 29 |
* |
33 | 30 |
*/ |
34 |
public class SpecimenImportEditorInput extends DataImportEditorInput<SpecimenOrObservationBase> { |
|
31 |
public class SpecimenImportEditorInput extends DataImportEditorInput<SpecimenOrObservationBase<?>> {
|
|
35 | 32 |
|
36 |
private final BioCaseQuery query;
|
|
33 |
private final OccurenceQuery query;
|
|
37 | 34 |
|
38 | 35 |
/** |
39 | 36 |
* @param results |
40 | 37 |
*/ |
41 |
public SpecimenImportEditorInput(BioCaseQuery query) {
|
|
38 |
public SpecimenImportEditorInput(OccurenceQuery query) {
|
|
42 | 39 |
super(); |
43 | 40 |
this.query = query; |
44 | 41 |
} |
45 | 42 |
|
46 | 43 |
public void query(){ |
47 |
String errorMessage = "Could not execute query " + SpecimenImportEditorInput.this.query;
|
|
44 |
String errorMessage = "Could not execute query " + query; |
|
48 | 45 |
|
49 |
Collection<SpecimenOrObservationBase> results = new ArrayList<SpecimenOrObservationBase>();
|
|
46 |
Collection<SpecimenOrObservationBase<?>> results = new ArrayList<SpecimenOrObservationBase<?>>();
|
|
50 | 47 |
try { |
51 |
InputStream resultStream = new BioCaseQueryServiceWrapper().query(SpecimenImportEditorInput.this.query); |
|
52 |
Abcd206ImportConfigurator configurator = Abcd206ImportConfigurator.NewInstance(resultStream, null, false); |
|
53 |
TransientCdmRepository repo = |
|
54 |
new TransientCdmRepository(CdmStore.getCurrentApplicationConfiguration()); |
|
55 |
configurator.setCdmAppController(repo); |
|
56 |
|
|
57 |
CdmDefaultImport<Abcd206ImportConfigurator> importer = new CdmDefaultImport<Abcd206ImportConfigurator>(); |
|
58 |
importer.invoke(configurator); |
|
59 |
results = repo.getUnits(); |
|
48 |
InputStream resultStream = new GbifQueryServiceWrapper().query(query); |
|
49 |
// JSONObject jsonObject = JSONObject.fromObject(dummyJson); |
|
50 |
// Object java = JSONSerializer.toJava(jsonObject); |
|
60 | 51 |
} catch (ClientProtocolException e) { |
61 | 52 |
logger.error(errorMessage, e); |
62 | 53 |
} catch (IOException e) { |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenSearchWizard.java | ||
---|---|---|
22 | 22 |
import org.eclipse.ui.PartInitException; |
23 | 23 |
import org.eclipse.ui.PlatformUI; |
24 | 24 |
|
25 |
import eu.etaxonomy.cdm.ext.biocase.BioCaseQuery;
|
|
25 |
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
|
|
26 | 26 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
27 | 27 |
|
28 | 28 |
/** |
29 |
* Wizard for querying BioCASe provider.
|
|
29 |
* Wizard for querying specimen provider.
|
|
30 | 30 |
* @author pplitzner |
31 | 31 |
* @date 11.09.2013 |
32 | 32 |
* |
... | ... | |
35 | 35 |
@SuppressWarnings("unused") |
36 | 36 |
private static final Logger logger = Logger.getLogger(SpecimenSearchWizard.class); |
37 | 37 |
|
38 |
private BioCaseQuery query;
|
|
38 |
private OccurenceQuery query = null;
|
|
39 | 39 |
private SpecimenSearchWizardPage searchPage; |
40 | 40 |
|
41 | 41 |
/** |
... | ... | |
59 | 59 |
|
60 | 60 |
query = searchPage.getQuery(); |
61 | 61 |
final SpecimenImportEditorInput input = new SpecimenImportEditorInput(query); |
62 |
Job queryJob = new Job("Query Biocase") {
|
|
62 |
Job queryJob = new Job("Query specimen provider") {
|
|
63 | 63 |
|
64 | 64 |
@Override |
65 | 65 |
protected IStatus run(IProgressMonitor monitor) { |
... | ... | |
89 | 89 |
*/ |
90 | 90 |
@Override |
91 | 91 |
public void init(IWorkbench workbench, IStructuredSelection selection) { |
92 |
query = new BioCaseQuery(); |
|
93 | 92 |
searchPage = new SpecimenSearchWizardPage("Specimen Search"); |
94 | 93 |
} |
95 | 94 |
|
96 | 95 |
/** |
97 |
* Return a {@link BioCaseQuery} with the parameters entered in the wizard
|
|
96 |
* Return a {@link OccurenceQuery} with the parameters entered in the wizard
|
|
98 | 97 |
* @return the query |
99 | 98 |
*/ |
100 |
public BioCaseQuery getQuery() {
|
|
99 |
public OccurenceQuery getQuery() {
|
|
101 | 100 |
return query; |
102 | 101 |
} |
103 | 102 |
|
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenSearchWizardPage.java | ||
---|---|---|
12 | 12 |
import org.eclipse.jface.wizard.WizardPage; |
13 | 13 |
import org.eclipse.swt.widgets.Composite; |
14 | 14 |
|
15 |
import eu.etaxonomy.cdm.ext.biocase.BioCaseQuery;
|
|
15 |
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
|
|
16 | 16 |
import eu.etaxonomy.taxeditor.view.specimenSearch.SpecimenSearchController; |
17 | 17 |
|
18 | 18 |
|
... | ... | |
42 | 42 |
} |
43 | 43 |
|
44 | 44 |
/** |
45 |
* Returns a {@link BioCaseQuery} filled with the parameters defined in this wizard page
|
|
45 |
* Returns an {@link OccurenceQuery} filled with the parameters defined in this wizard page
|
|
46 | 46 |
* @return |
47 | 47 |
*/ |
48 |
public BioCaseQuery getQuery() { |
|
49 |
BioCaseQuery query = new BioCaseQuery(); |
|
50 |
query.accessionNumber = specimenSearchController.getAccessionNumber(); |
|
51 |
query.collector = specimenSearchController.getCollector(); |
|
52 |
query.collectorsNumber = specimenSearchController.getCollectorNumber(); |
|
53 |
query.country = specimenSearchController.getCountry(); |
|
54 |
// query.date = specimenSearchController.getDate(); |
|
55 |
query.herbarium = specimenSearchController.getHerbarium(); |
|
56 |
query.locality = specimenSearchController.getLocality(); |
|
57 |
query.taxonName = specimenSearchController.getTaxonName(); |
|
58 |
return query; |
|
48 |
public OccurenceQuery getQuery() { |
|
49 |
String accessionNumber = specimenSearchController.getAccessionNumber(); |
|
50 |
String collector = specimenSearchController.getCollector(); |
|
51 |
String collectorsNumber = specimenSearchController.getCollectorNumber(); |
|
52 |
String country = specimenSearchController.getCountry(); |
|
53 |
// date = specimenSearchController.getDate(); |
|
54 |
String herbarium = specimenSearchController.getHerbarium(); |
|
55 |
String locality = specimenSearchController.getLocality(); |
|
56 |
String taxonName = specimenSearchController.getTaxonName(); |
|
57 |
return new OccurenceQuery(taxonName, collector, collectorsNumber, accessionNumber, herbarium, country, locality, null); |
|
59 | 58 |
} |
60 | 59 |
|
61 | 60 |
} |
Also available in: Unified diff