1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.io.wizard;
|
11
|
|
12
|
import java.io.File;
|
13
|
import java.net.URI;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
17
|
import org.eclipse.ui.IWorkbench;
|
18
|
|
19
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
20
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
|
21
|
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
|
22
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
23
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
24
|
|
25
|
/**
|
26
|
*
|
27
|
* @author n.hoffmann
|
28
|
* @created Jun 16, 2010
|
29
|
* @version 1.0
|
30
|
*/
|
31
|
public class AbcdImportWizard extends AbstractImportWizard<Abcd206ImportConfigurator> {
|
32
|
|
33
|
private static final Logger logger = Logger.getLogger(AbcdImportWizard.class);
|
34
|
|
35
|
private Abcd206ImportConfigurator configurator;
|
36
|
private AbcdSourceSelectionPage dataSourcePage;
|
37
|
private ClassificationChooserWizardPage classificationChooserWizardPage;
|
38
|
|
39
|
/** {@inheritDoc} */
|
40
|
@Override
|
41
|
public Abcd206ImportConfigurator getConfigurator() {
|
42
|
return configurator;
|
43
|
}
|
44
|
|
45
|
/** {@inheritDoc} */
|
46
|
@Override
|
47
|
public boolean performFinish() {
|
48
|
URI source = dataSourcePage.getUri();
|
49
|
configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
|
50
|
|
51
|
if(classificationChooserWizardPage.getClassification()!=null){
|
52
|
configurator.setClassificationUuid(classificationChooserWizardPage.getClassification().getUuid());
|
53
|
}
|
54
|
|
55
|
CdmStore.getImportManager().runMoniteredOperation(configurator, new File(source), SOURCE_TYPE.INPUTSTREAM);
|
56
|
|
57
|
return true;
|
58
|
|
59
|
}
|
60
|
|
61
|
/** {@inheritDoc} */
|
62
|
@Override
|
63
|
public void init(IWorkbench workbench, IStructuredSelection selection) {
|
64
|
super.init(workbench, selection);
|
65
|
configurator = PreferencesUtil.getLocalAbcdImportConfigurator();
|
66
|
}
|
67
|
|
68
|
@Override
|
69
|
protected void addConfiguratorPage() {
|
70
|
AbcdImportConfiguratorWizardPage configuratorWizardPage = AbcdImportConfiguratorWizardPage.createPage(configurator);
|
71
|
addPage(configuratorWizardPage);
|
72
|
}
|
73
|
|
74
|
/** {@inheritDoc} */
|
75
|
@Override
|
76
|
public void addPages() {
|
77
|
super.addPages();
|
78
|
|
79
|
classificationChooserWizardPage = ClassificationChooserWizardPage.createPage();
|
80
|
|
81
|
dataSourcePage = ImportFromFileDataSourceWizardPage.XML();
|
82
|
|
83
|
addPage(classificationChooserWizardPage);
|
84
|
addPage(dataSourcePage);
|
85
|
}
|
86
|
}
|