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.commons.lang3.StringUtils;
|
16
|
import org.apache.log4j.Logger;
|
17
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
18
|
import org.eclipse.ui.IWorkbench;
|
19
|
|
20
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
21
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
|
22
|
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
|
23
|
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
|
24
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
25
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
26
|
|
27
|
/**
|
28
|
* @author n.hoffmann
|
29
|
* @created Jun 16, 2010
|
30
|
*/
|
31
|
public class AbcdImportWizard extends AbstractImportWizard<Abcd206ImportConfigurator> {
|
32
|
|
33
|
@SuppressWarnings("unused")
|
34
|
private static final Logger logger = Logger.getLogger(AbcdImportWizard.class);
|
35
|
|
36
|
private Abcd206ImportConfigurator configurator;
|
37
|
private AbcdSourceSelectionPage dataSourcePage;
|
38
|
private ClassificationChooserWizardPage classificationChooserWizardPage;
|
39
|
|
40
|
/** {@inheritDoc} */
|
41
|
@Override
|
42
|
public Abcd206ImportConfigurator getConfigurator() {
|
43
|
return configurator;
|
44
|
}
|
45
|
|
46
|
/** {@inheritDoc} */
|
47
|
@Override
|
48
|
public boolean performFinish() {
|
49
|
URI source = dataSourcePage.getUri();
|
50
|
configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
|
51
|
|
52
|
if(classificationChooserWizardPage.getClassification()!=null){
|
53
|
configurator.setClassificationUuid(classificationChooserWizardPage.getClassification().getUuid());
|
54
|
}
|
55
|
|
56
|
CdmStore.getImportManager().runMoniteredOperation(configurator, new File(source), SOURCE_TYPE.INPUTSTREAM);
|
57
|
|
58
|
return true;
|
59
|
|
60
|
}
|
61
|
|
62
|
@Override
|
63
|
public void init(IWorkbench workbench, IStructuredSelection selection) {
|
64
|
super.init(workbench, selection);
|
65
|
String configString = PreferencesUtil.getStringValue(IPreferenceKeys.LAST_USED_ABCD_CONFIG);
|
66
|
if (StringUtils.isBlank(configString)){
|
67
|
configurator = PreferencesUtil.getLocalAbcdImportConfigurator(false);
|
68
|
}else{
|
69
|
configurator = Abcd206ImportConfigurator.NewInstance(null, null);
|
70
|
PreferencesUtil.extractAbcdConfiguratorFromPreferenceString(configurator, configString);
|
71
|
}
|
72
|
}
|
73
|
|
74
|
@Override
|
75
|
protected void addConfiguratorPage() {
|
76
|
AbcdImportConfiguratorWizardPage configuratorWizardPage = AbcdImportConfiguratorWizardPage.createPage(configurator);
|
77
|
addPage(configuratorWizardPage);
|
78
|
}
|
79
|
|
80
|
/** {@inheritDoc} */
|
81
|
@Override
|
82
|
public void addPages() {
|
83
|
super.addPages();
|
84
|
|
85
|
classificationChooserWizardPage = ClassificationChooserWizardPage.createPage();
|
86
|
|
87
|
dataSourcePage = ImportFromFileDataSourceWizardPage.XML();
|
88
|
|
89
|
addPage(classificationChooserWizardPage);
|
90
|
addPage(dataSourcePage);
|
91
|
}
|
92
|
}
|