3 * Copyright (C) 2013 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.view
.dataimport
;
12 import org
.apache
.log4j
.Logger
;
13 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
14 import org
.eclipse
.core
.runtime
.IStatus
;
15 import org
.eclipse
.core
.runtime
.Status
;
16 import org
.eclipse
.core
.runtime
.jobs
.Job
;
17 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
18 import org
.eclipse
.jface
.wizard
.Wizard
;
19 import org
.eclipse
.swt
.widgets
.Display
;
20 import org
.eclipse
.ui
.IImportWizard
;
21 import org
.eclipse
.ui
.IWorkbench
;
23 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
24 import eu
.etaxonomy
.cdm
.ext
.occurrence
.OccurenceQuery
;
25 import eu
.etaxonomy
.cdm
.io
.specimen
.abcd206
.in
.Abcd206ImportConfigurator
;
26 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
29 * Wizard for querying specimen provider.
34 public class SpecimenSearchWizard
extends Wizard
implements IImportWizard
{
35 private static final Logger logger
= Logger
.getLogger(SpecimenSearchWizard
.class);
37 private OccurenceQuery query
= null;
38 private SpecimenProviderSelectionWizardPage providerSelectionPage
;
39 private SpecimenSearchWizardPage searchPage
;
42 * Creates a new SpecimenSearchWizard
44 public SpecimenSearchWizard() {
45 //default constructor needed for RCP extension points
47 //check if connected to a data source. If not this will open an error dialog
48 CdmStore
.getCurrentApplicationConfiguration();
49 this.setWindowTitle("Search Specimens");
54 * @see org.eclipse.jface.wizard.Wizard#performFinish()
57 public boolean performFinish() {
58 searchPage
.getController().saveLastSate();
59 providerSelectionPage
.getController().saveLastState();
61 DataImportView
<?
> dataImportView
= null;
62 query
= searchPage
.getQuery();
63 Abcd206ImportConfigurator configurator
= CdmStore
.getImportManager().AbcdConfigurator();
64 configurator
.setOccurenceQuery(query
);
65 configurator
.setSourceUri(providerSelectionPage
.getEndPoint());
66 configurator
.setDbSchemaValidation(DbSchemaValidation
.CREATE
);
67 if(CdmStore
.getCurrentSessionManager().isRemoting()) {
68 //Job job = CdmStore.getImportManager().createIOServiceJob(configurator, new File(source), SOURCE_TYPE.INPUTSTREAM);
69 //CdmStore.getImportManager().run(job);
71 CdmStore
.getImportManager().run(configurator
);
74 // switch (providerSelectionPage.getQueryType()) {
76 // SpecimenImportView specimenImportView = (SpecimenImportView) TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage()
77 // .showView(SpecimenImportView.ID, "query_"+query.toString().replaceAll(",", ""),IWorkbenchPage.VIEW_ACTIVATE);
78 // specimenImportView.setEndpoint(providerSelectionPage.getEndPoint());
79 // dataImportView = specimenImportView;
82 // dataImportView = (GbifResponseImportView) TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage()
83 // .showView(GbifResponseImportView.ID, "query_"+query.toString().replaceAll(",", ""),IWorkbenchPage.VIEW_ACTIVATE);
86 // } catch ( PartInitException e ) {
87 // logger.error("Could not open import view for query: " + query.toString(), e);
89 // if(dataImportView!=null){
90 // dataImportView.setQuery(query);
91 //// dataImportView.query();
92 //// Display.getDefault().asyncExec(new Runnable() {
95 //// public void run() {
96 //// CdmStore.getContextManager().notifyContextRefresh();
99 Job queryJob
= new QueryJob("Query specimen provider", dataImportView
);
106 * @see org.eclipse.jface.wizard.Wizard#addPages()
109 public void addPages() {
110 addPage(providerSelectionPage
);
115 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
118 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
119 providerSelectionPage
= new SpecimenProviderSelectionWizardPage("Select specimen provider");
120 searchPage
= new SpecimenSearchWizardPage("Specimen Search");
123 private class QueryJob
extends Job
{
125 private final DataImportView
<?
> view
;
130 public QueryJob(String name
, DataImportView
<?
> view
) {
136 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
139 protected IStatus
run(IProgressMonitor monitor
) {
140 view
.getConversationHolder().bind();
142 Display
.getDefault().asyncExec(new Runnable() {
146 CdmStore
.getContextManager().notifyContextRefresh();
149 return Status
.OK_STATUS
;