Revision 42580bdf
Added by Patrick Plitzner over 9 years ago
- updated SpecimenImportWizard
- refactored BioCase querying to be a separate job
eu.etaxonomy.taxeditor.bulkeditor/plugin.xml | ||
---|---|---|
389 | 389 |
class="eu.etaxonomy.taxeditor.dataimport.wizard.SpecimenSearchWizard" |
390 | 390 |
id="eu.etaxonomy.taxeditor.dataimport.wizard.SpecimenSearchWizard" |
391 | 391 |
name="Query BioCASE"> |
392 |
<description> |
|
393 |
Query BioCaseProvider |
|
394 |
</description> |
|
392 | 395 |
</wizard> |
393 | 396 |
</extension> |
394 | 397 |
<!-- start set marker --> |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/DerivedUnitEditorInput.java | ||
---|---|---|
12 | 12 |
import java.io.IOException; |
13 | 13 |
import java.io.InputStream; |
14 | 14 |
import java.net.URISyntaxException; |
15 |
import java.util.Collections; |
|
16 | 15 |
import java.util.List; |
17 | 16 |
|
18 | 17 |
import org.apache.http.client.ClientProtocolException; |
19 | 18 |
import org.apache.log4j.Logger; |
19 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
20 |
import org.eclipse.core.runtime.IStatus; |
|
21 |
import org.eclipse.core.runtime.Status; |
|
22 |
import org.eclipse.core.runtime.jobs.Job; |
|
20 | 23 |
import org.eclipse.jface.resource.ImageDescriptor; |
24 |
import org.eclipse.swt.widgets.Display; |
|
21 | 25 |
import org.eclipse.ui.IEditorInput; |
22 | 26 |
import org.eclipse.ui.IPersistableElement; |
23 | 27 |
|
24 |
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration; |
|
25 | 28 |
import eu.etaxonomy.cdm.ext.biocase.BioCaseQuery; |
26 | 29 |
import eu.etaxonomy.cdm.ext.biocase.BioCaseQueryServiceWrapper; |
27 | 30 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
... | ... | |
41 | 44 |
|
42 | 45 |
private final BioCaseQuery query; |
43 | 46 |
|
47 |
private List<SpecimenOrObservationBase> results; |
|
48 |
|
|
44 | 49 |
/** |
45 | 50 |
* @param results |
46 | 51 |
*/ |
47 | 52 |
public DerivedUnitEditorInput(BioCaseQuery query) { |
48 | 53 |
this.query = query; |
54 |
Display.getCurrent().asyncExec(new Runnable() { |
|
55 |
|
|
56 |
@Override |
|
57 |
public void run() { |
|
58 |
String errorMessage = "Could not execute query " + DerivedUnitEditorInput.this.query; |
|
59 |
try { |
|
60 |
InputStream resultStream = new BioCaseQueryServiceWrapper().query(DerivedUnitEditorInput.this.query); |
|
61 |
Abcd206ImportConfigurator configurator = Abcd206ImportConfigurator.NewInstance(resultStream, null, false); |
|
62 |
TransientCdmRepository repo = |
|
63 |
new TransientCdmRepository(CdmStore.getCurrentApplicationConfiguration()); |
|
64 |
configurator.setCdmAppController(repo); |
|
65 |
|
|
66 |
CdmDefaultImport<Abcd206ImportConfigurator> importer = new CdmDefaultImport<Abcd206ImportConfigurator>(); |
|
67 |
importer.invoke(configurator); |
|
68 |
results = repo.getUnits(); |
|
69 |
// Abcd206Import abcd206Import = new Abcd206Import(); |
|
70 |
// Abcd206ImportState state = new Abcd206ImportState(configurator); |
|
71 |
// abcd206Import.invoke(state); |
|
72 |
// state.countTrees(); |
|
73 |
} catch (ClientProtocolException e) { |
|
74 |
logger.error(errorMessage, e); |
|
75 |
} catch (IOException e) { |
|
76 |
logger.error(errorMessage, e); |
|
77 |
} catch (URISyntaxException e) { |
|
78 |
logger.error(errorMessage, e); |
|
79 |
} |
|
80 |
// return new BioCaseQueryServiceWrapper().dummyData(); |
|
81 |
} |
|
82 |
}); |
|
83 |
} |
|
84 |
|
|
85 |
public void query(){ |
|
86 |
Job queryJob = new Job("Query Biocase") { |
|
87 |
|
|
88 |
@Override |
|
89 |
protected IStatus run(IProgressMonitor monitor) { |
|
90 |
String errorMessage = "Could not execute query " + DerivedUnitEditorInput.this.query; |
|
91 |
try { |
|
92 |
InputStream resultStream = new BioCaseQueryServiceWrapper().query(DerivedUnitEditorInput.this.query); |
|
93 |
Abcd206ImportConfigurator configurator = Abcd206ImportConfigurator.NewInstance(resultStream, null, false); |
|
94 |
TransientCdmRepository repo = |
|
95 |
new TransientCdmRepository(CdmStore.getCurrentApplicationConfiguration()); |
|
96 |
configurator.setCdmAppController(repo); |
|
97 |
|
|
98 |
CdmDefaultImport<Abcd206ImportConfigurator> importer = new CdmDefaultImport<Abcd206ImportConfigurator>(); |
|
99 |
importer.invoke(configurator); |
|
100 |
results = repo.getUnits(); |
|
101 |
// Abcd206Import abcd206Import = new Abcd206Import(); |
|
102 |
// Abcd206ImportState state = new Abcd206ImportState(configurator); |
|
103 |
// abcd206Import.invoke(state); |
|
104 |
// state.countTrees(); |
|
105 |
} catch (ClientProtocolException e) { |
|
106 |
logger.error(errorMessage, e); |
|
107 |
} catch (IOException e) { |
|
108 |
logger.error(errorMessage, e); |
|
109 |
} catch (URISyntaxException e) { |
|
110 |
logger.error(errorMessage, e); |
|
111 |
} |
|
112 |
|
|
113 |
Display.getDefault().asyncExec(new Runnable() { |
|
114 |
|
|
115 |
@Override |
|
116 |
public void run() { |
|
117 |
CdmStore.getContextManager().notifyContextRefresh(); |
|
118 |
} |
|
119 |
}); |
|
120 |
|
|
121 |
return Status.OK_STATUS; |
|
122 |
} |
|
123 |
}; |
|
49 | 124 |
} |
50 | 125 |
|
51 | 126 |
/* (non-Javadoc) |
... | ... | |
102 | 177 |
* @return the results |
103 | 178 |
*/ |
104 | 179 |
public List<SpecimenOrObservationBase> getResults() { |
105 |
String errorMessage = "Could not execute query " + query; |
|
106 |
List<SpecimenOrObservationBase> results = Collections.EMPTY_LIST; |
|
107 |
try { |
|
108 |
InputStream resultStream = new BioCaseQueryServiceWrapper().query(query); |
|
109 |
Abcd206ImportConfigurator configurator = Abcd206ImportConfigurator.NewInstance(resultStream, null, false); |
|
110 |
TransientCdmRepository repo = |
|
111 |
new TransientCdmRepository((ICdmApplicationConfiguration)CdmStore.getCurrentApplicationConfiguration()); |
|
112 |
configurator.setCdmAppController(repo); |
|
113 |
|
|
114 |
CdmDefaultImport<Abcd206ImportConfigurator> importer = new CdmDefaultImport<Abcd206ImportConfigurator>(); |
|
115 |
importer.invoke(configurator); |
|
116 |
results = repo.getUnits(); |
|
117 |
// Abcd206Import abcd206Import = new Abcd206Import(); |
|
118 |
// Abcd206ImportState state = new Abcd206ImportState(configurator); |
|
119 |
// abcd206Import.invoke(state); |
|
120 |
// state.countTrees(); |
|
121 |
} catch (ClientProtocolException e) { |
|
122 |
logger.error(errorMessage, e); |
|
123 |
} catch (IOException e) { |
|
124 |
logger.error(errorMessage, e); |
|
125 |
} catch (URISyntaxException e) { |
|
126 |
logger.error(errorMessage, e); |
|
127 |
} |
|
128 |
// return new BioCaseQueryServiceWrapper().dummyData(); |
|
129 | 180 |
return results; |
130 | 181 |
} |
131 | 182 |
|
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/wizard/SpecimenSearchWizard.java | ||
---|---|---|
44 | 44 |
|
45 | 45 |
//check if connected to a data source. If not this will open an error dialog |
46 | 46 |
CdmStore.getCurrentApplicationConfiguration(); |
47 |
this.setWindowTitle("Search Specimens"); |
|
47 | 48 |
} |
48 | 49 |
|
49 | 50 |
|
... | ... | |
57 | 58 |
try { |
58 | 59 |
query = searchPage.getQuery(); |
59 | 60 |
DerivedUnitEditorInput input = new DerivedUnitEditorInput(query); |
61 |
input.query(); |
|
60 | 62 |
page.openEditor(input, DataImportEditor.ID, true); |
61 | 63 |
} catch ( PartInitException e ) { |
62 | 64 |
//Put your exception handler here if you wish to |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/wizard/SpecimenSearchWizardPage.java | ||
---|---|---|
28 | 28 |
|
29 | 29 |
protected SpecimenSearchWizardPage(String pageName) { |
30 | 30 |
super(pageName); |
31 |
setDescription("Specify search parameters for external search query."); |
|
32 |
setTitle("Search Specimens"); |
|
31 | 33 |
} |
32 | 34 |
|
33 | 35 |
/* (non-Javadoc) |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/specimenSearch/SpecimenSearchComposite.java | ||
---|---|---|
25 | 25 |
*/ |
26 | 26 |
public class SpecimenSearchComposite extends Composite { |
27 | 27 |
private final FormToolkit formToolkit = new FormToolkit(Display.getDefault()); |
28 |
private Text textTaxonName; |
|
29 |
private Text textCollector; |
|
30 |
private Text textCollectorNumber; |
|
31 |
private Text textAccessionNumber; |
|
32 |
private Text textLocality; |
|
33 |
private Text textHerbarium; |
|
34 |
private Text textCountry; |
|
28 |
private final Text textTaxonName;
|
|
29 |
private final Text textCollector;
|
|
30 |
private final Text textCollectorNumber;
|
|
31 |
private final Text textAccessionNumber;
|
|
32 |
private final Text textLocality;
|
|
33 |
private final Text textHerbarium;
|
|
34 |
private final Text textCountry;
|
|
35 | 35 |
|
36 | 36 |
/** |
37 | 37 |
* Create the composite. |
38 | 38 |
* @param parent |
39 |
* @param style |
|
39 |
* @setBackgroundMode(SWT.INHERIT_DEFAULT); |
|
40 |
param style |
|
40 | 41 |
*/ |
41 | 42 |
public SpecimenSearchComposite(Composite parent, int style) { |
42 | 43 |
super(parent, style); |
43 |
setBackgroundMode(SWT.INHERIT_DEFAULT); |
|
44 | 44 |
{ |
45 | 45 |
TableWrapLayout tableWrapLayout = new TableWrapLayout(); |
46 | 46 |
tableWrapLayout.numColumns = 2; |
47 | 47 |
setLayout(tableWrapLayout); |
48 | 48 |
} |
49 | 49 |
|
50 |
Label lblTaxonName = formToolkit.createLabel(this, "Taxon Name", SWT.NONE); |
|
50 |
Label lblTaxonName = new Label(this, SWT.NONE); |
|
51 |
lblTaxonName.setText("Taxon Name"); |
|
51 | 52 |
|
52 |
textTaxonName = new Text(this, SWT.BORDER);
|
|
53 |
textTaxonName = new Text(this, SWT.NONE);
|
|
53 | 54 |
textTaxonName.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1)); |
54 |
formToolkit.adapt(textTaxonName, true, true); |
|
55 | 55 |
|
56 | 56 |
Label lblCollectors = new Label(this, SWT.NONE); |
57 |
formToolkit.adapt(lblCollectors, true, true); |
|
58 | 57 |
lblCollectors.setText("Collector(s)"); |
59 | 58 |
|
60 |
textCollector = new Text(this, SWT.BORDER);
|
|
59 |
textCollector = new Text(this, SWT.NONE);
|
|
61 | 60 |
textCollector.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1)); |
62 | 61 |
formToolkit.adapt(textCollector, true, true); |
63 | 62 |
|
64 | 63 |
Label lblCollectorsNumber = new Label(this, SWT.NONE); |
65 |
formToolkit.adapt(lblCollectorsNumber, true, true); |
|
66 | 64 |
lblCollectorsNumber.setText("Collector(s) Number"); |
67 | 65 |
|
68 |
textCollectorNumber = new Text(this, SWT.BORDER);
|
|
66 |
textCollectorNumber = new Text(this, SWT.NONE);
|
|
69 | 67 |
textCollectorNumber.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1)); |
70 | 68 |
formToolkit.adapt(textCollectorNumber, true, true); |
71 | 69 |
|
72 | 70 |
Label lblAccessionNumber = new Label(this, SWT.NONE); |
73 |
formToolkit.adapt(lblAccessionNumber, true, true); |
|
74 | 71 |
lblAccessionNumber.setText("Accession Number"); |
75 | 72 |
|
76 |
textAccessionNumber = new Text(this, SWT.BORDER);
|
|
73 |
textAccessionNumber = new Text(this, SWT.NONE);
|
|
77 | 74 |
textAccessionNumber.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1)); |
78 | 75 |
formToolkit.adapt(textAccessionNumber, true, true); |
79 | 76 |
|
80 | 77 |
Label lblHerbarium = new Label(this, SWT.NONE); |
81 |
formToolkit.adapt(lblHerbarium, true, true); |
|
82 | 78 |
lblHerbarium.setText("Herbarium"); |
83 | 79 |
|
84 | 80 |
textHerbarium = new Text(this, SWT.NONE); |
85 | 81 |
textHerbarium.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1)); |
86 | 82 |
|
87 | 83 |
Label lblCountry = new Label(this, SWT.NONE); |
88 |
formToolkit.adapt(lblCountry, true, true); |
|
89 | 84 |
lblCountry.setText("Country"); |
90 | 85 |
|
91 | 86 |
textCountry = new Text(this, SWT.NONE); |
92 | 87 |
textCountry.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1)); |
93 | 88 |
|
94 | 89 |
Label lblLocality = new Label(this, SWT.NONE); |
95 |
formToolkit.adapt(lblLocality, true, true); |
|
96 | 90 |
lblLocality.setText("Locality"); |
97 | 91 |
|
98 |
textLocality = new Text(this, SWT.BORDER);
|
|
92 |
textLocality = new Text(this, SWT.NONE);
|
|
99 | 93 |
textLocality.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1)); |
100 | 94 |
formToolkit.adapt(textLocality, true, true); |
101 | 95 |
|
102 | 96 |
Label lblCollectionDate = new Label(this, SWT.NONE); |
103 |
formToolkit.adapt(lblCollectionDate, true, true); |
|
104 | 97 |
lblCollectionDate.setText("Collection Date"); |
105 | 98 |
new Label(this, SWT.NONE); |
106 | 99 |
|
Also available in: Unified diff