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.store.CdmStore;
|
25
|
|
26
|
/**
|
27
|
* <p>AbcdImportWizard class.</p>
|
28
|
*
|
29
|
* @author n.hoffmann
|
30
|
* @created Jun 16, 2010
|
31
|
* @version 1.0
|
32
|
*/
|
33
|
public class AbcdImportWizard extends AbstractImportWizard<Abcd206ImportConfigurator> {
|
34
|
|
35
|
private static final Logger logger = Logger.getLogger(AbcdImportWizard.class);
|
36
|
|
37
|
private Abcd206ImportConfigurator configurator;
|
38
|
private ImportFromFileDataSourceWizardPage dataSourcePage;
|
39
|
|
40
|
/* (non-Javadoc)
|
41
|
* @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#getConfigurator()
|
42
|
*/
|
43
|
/** {@inheritDoc} */
|
44
|
@Override
|
45
|
public Abcd206ImportConfigurator getConfigurator() {
|
46
|
return configurator;
|
47
|
}
|
48
|
|
49
|
/* (non-Javadoc)
|
50
|
* @see org.eclipse.jface.wizard.Wizard#performFinish()
|
51
|
*/
|
52
|
/** {@inheritDoc} */
|
53
|
@Override
|
54
|
public boolean performFinish() {
|
55
|
URI source = dataSourcePage.getUri();
|
56
|
try {
|
57
|
configurator.setSource(new FileInputStream(new File(source)));
|
58
|
} catch (FileNotFoundException e) {
|
59
|
logger.error("File not found!", e);
|
60
|
return false;
|
61
|
}
|
62
|
configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
|
63
|
|
64
|
CdmStore.getImportManager().run(configurator);
|
65
|
return true;
|
66
|
|
67
|
}
|
68
|
|
69
|
/* (non-Javadoc)
|
70
|
* @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
|
71
|
*/
|
72
|
/** {@inheritDoc} */
|
73
|
@Override
|
74
|
public void init(IWorkbench workbench, IStructuredSelection selection) {
|
75
|
super.init(workbench, selection);
|
76
|
configurator = CdmStore.getImportManager().AbcdConfigurator();
|
77
|
}
|
78
|
|
79
|
/* (non-Javadoc)
|
80
|
* @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#addPages()
|
81
|
*/
|
82
|
/** {@inheritDoc} */
|
83
|
@Override
|
84
|
public void addPages() {
|
85
|
super.addPages();
|
86
|
|
87
|
dataSourcePage = ImportFromFileDataSourceWizardPage.XML();
|
88
|
addPage(dataSourcePage);
|
89
|
}
|
90
|
}
|