1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
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.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.io.wizard;
|
12
|
|
13
|
import java.io.File;
|
14
|
import java.io.FileInputStream;
|
15
|
import java.io.FileNotFoundException;
|
16
|
import java.net.URI;
|
17
|
|
18
|
import org.apache.log4j.Logger;
|
19
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
20
|
import org.eclipse.ui.IWorkbench;
|
21
|
|
22
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
23
|
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
|
24
|
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
25
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
26
|
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
|
27
|
|
28
|
/**
|
29
|
* <p>AbcdImportWizard class.</p>
|
30
|
*
|
31
|
* @author n.hoffmann
|
32
|
* @created Jun 16, 2010
|
33
|
* @version 1.0
|
34
|
*/
|
35
|
public class AbcdImportWizard extends AbstractImportWizard<Abcd206ImportConfigurator> {
|
36
|
|
37
|
private static final Logger logger = Logger.getLogger(AbcdImportWizard.class);
|
38
|
|
39
|
private Abcd206ImportConfigurator configurator;
|
40
|
private ImportFromFileDataSourceWizardPage dataSourcePage;
|
41
|
private ClassificationChooserWizardPage classificationChooserWizardPage;
|
42
|
|
43
|
/* (non-Javadoc)
|
44
|
* @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#getConfigurator()
|
45
|
*/
|
46
|
/** {@inheritDoc} */
|
47
|
@Override
|
48
|
public Abcd206ImportConfigurator getConfigurator() {
|
49
|
return configurator;
|
50
|
}
|
51
|
|
52
|
/* (non-Javadoc)
|
53
|
* @see org.eclipse.jface.wizard.Wizard#performFinish()
|
54
|
*/
|
55
|
/** {@inheritDoc} */
|
56
|
@Override
|
57
|
public boolean performFinish() {
|
58
|
URI source = dataSourcePage.getUri();
|
59
|
try {
|
60
|
configurator.setSource(new FileInputStream(new File(source)));
|
61
|
} catch (FileNotFoundException e) {
|
62
|
MessagingUtils.errorDialog("File not found.", this, "Import file was not found.", TaxeditorStorePlugin.PLUGIN_ID, e, false);
|
63
|
logger.error("File not found!", e);
|
64
|
return false;
|
65
|
}
|
66
|
configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
|
67
|
|
68
|
if(classificationChooserWizardPage.getClassification()!=null){
|
69
|
configurator.setClassificationUuid(classificationChooserWizardPage.getClassification().getUuid());
|
70
|
}
|
71
|
configurator.setReportUri(classificationChooserWizardPage.getReportUri());
|
72
|
|
73
|
CdmStore.getImportManager().run(configurator);
|
74
|
return true;
|
75
|
|
76
|
}
|
77
|
|
78
|
/* (non-Javadoc)
|
79
|
* @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
|
80
|
*/
|
81
|
/** {@inheritDoc} */
|
82
|
@Override
|
83
|
public void init(IWorkbench workbench, IStructuredSelection selection) {
|
84
|
super.init(workbench, selection);
|
85
|
configurator = CdmStore.getImportManager().AbcdConfigurator();
|
86
|
}
|
87
|
|
88
|
/* (non-Javadoc)
|
89
|
* @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#addPages()
|
90
|
*/
|
91
|
/** {@inheritDoc} */
|
92
|
@Override
|
93
|
public void addPages() {
|
94
|
super.addPages();
|
95
|
|
96
|
classificationChooserWizardPage = ClassificationChooserWizardPage.createPage();
|
97
|
dataSourcePage = ImportFromFileDataSourceWizardPage.XML();
|
98
|
addPage(classificationChooserWizardPage);
|
99
|
addPage(dataSourcePage);
|
100
|
}
|
101
|
}
|