3 * Copyright (C) 2007 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.
11 package eu
.etaxonomy
.taxeditor
.io
.wizard
;
14 import java
.io
.FileInputStream
;
15 import java
.io
.FileNotFoundException
;
18 import org
.apache
.log4j
.Logger
;
19 import org
.eclipse
.core
.runtime
.jobs
.Job
;
20 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
21 import org
.eclipse
.ui
.IWorkbench
;
23 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
24 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.SOURCE_TYPE
;
25 import eu
.etaxonomy
.cdm
.io
.specimen
.abcd206
.in
.Abcd206ImportConfigurator
;
26 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
27 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
28 import eu
.etaxonomy
.taxeditor
.store
.internal
.TaxeditorStorePlugin
;
31 * <p>AbcdImportWizard class.</p>
34 * @created Jun 16, 2010
37 public class AbcdImportWizard
extends AbstractImportWizard
<Abcd206ImportConfigurator
> {
39 private static final Logger logger
= Logger
.getLogger(AbcdImportWizard
.class);
41 private Abcd206ImportConfigurator configurator
;
42 private ImportFromFileDataSourceWizardPage dataSourcePage
;
43 private ClassificationChooserWizardPage classificationChooserWizardPage
;
46 * @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#getConfigurator()
50 public Abcd206ImportConfigurator
getConfigurator() {
55 * @see org.eclipse.jface.wizard.Wizard#performFinish()
59 public boolean performFinish() {
60 URI source
= dataSourcePage
.getUri();
61 configurator
.setDbSchemaValidation(DbSchemaValidation
.CREATE
);
63 if(classificationChooserWizardPage
.getClassification()!=null){
64 configurator
.setClassificationUuid(classificationChooserWizardPage
.getClassification().getUuid());
66 configurator
.setReportUri(classificationChooserWizardPage
.getReportUri());
68 if(CdmStore
.getCurrentSessionManager().isRemoting()) {
69 Job job
= CdmStore
.getImportManager().createIOServiceJob(configurator
, new File(source
), SOURCE_TYPE
.INPUTSTREAM
);
70 CdmStore
.getImportManager().run(job
);
73 configurator
.setSource(new FileInputStream(new File(source
)));
74 } catch (FileNotFoundException e
) {
75 MessagingUtils
.errorDialog("File not found.", this, "Import file was not found.", TaxeditorStorePlugin
.PLUGIN_ID
, e
, false);
76 logger
.error("File not found!", e
);
79 CdmStore
.getImportManager().run(configurator
);
86 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
90 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
91 super.init(workbench
, selection
);
92 configurator
= CdmStore
.getImportManager().AbcdConfigurator();
96 * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#addPages()
100 public void addPages() {
103 classificationChooserWizardPage
= ClassificationChooserWizardPage
.createPage();
104 dataSourcePage
= ImportFromFileDataSourceWizardPage
.XML();
105 addPage(classificationChooserWizardPage
);
106 addPage(dataSourcePage
);