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.e4.abcd;
|
11
|
|
12
|
import java.io.File;
|
13
|
import java.net.URI;
|
14
|
|
15
|
import javax.inject.Inject;
|
16
|
|
17
|
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
18
|
import org.eclipse.e4.core.contexts.IEclipseContext;
|
19
|
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
20
|
|
21
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
22
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
|
23
|
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
|
24
|
import eu.etaxonomy.taxeditor.io.e4.AbstractImportWizardE4;
|
25
|
import eu.etaxonomy.taxeditor.io.e4.ImportFromFileDataSourceWizardPageE4;
|
26
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
27
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
28
|
|
29
|
/**
|
30
|
*
|
31
|
* @author pplitzner
|
32
|
* @since Oct 5, 2017
|
33
|
*
|
34
|
*/
|
35
|
public class AbcdImportWizardE4 extends AbstractImportWizardE4<Abcd206ImportConfigurator> {
|
36
|
|
37
|
private Abcd206ImportConfigurator configurator;
|
38
|
private ImportFromFileDataSourceWizardPageE4 dataSourcePage;
|
39
|
private ClassificationChooserWizardPageE4 classificationChooserWizardPage;
|
40
|
|
41
|
@Inject
|
42
|
public AbcdImportWizardE4(IEclipseContext context, EPartService partService) {
|
43
|
super(context, partService);
|
44
|
}
|
45
|
|
46
|
/** {@inheritDoc} */
|
47
|
@Override
|
48
|
public Abcd206ImportConfigurator getConfigurator() {
|
49
|
return configurator;
|
50
|
}
|
51
|
|
52
|
/** {@inheritDoc} */
|
53
|
@Override
|
54
|
public boolean performFinish() {
|
55
|
URI source = dataSourcePage.getUri();
|
56
|
configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
|
57
|
|
58
|
if(classificationChooserWizardPage.getClassification()!=null){
|
59
|
configurator.setClassificationUuid(classificationChooserWizardPage.getClassification().getUuid());
|
60
|
}
|
61
|
|
62
|
CdmStore.getImportManager().runMoniteredOperation(configurator, new File(source), SOURCE_TYPE.INPUTSTREAM);
|
63
|
|
64
|
return true;
|
65
|
|
66
|
}
|
67
|
|
68
|
/** {@inheritDoc} */
|
69
|
@Override
|
70
|
public void init() {
|
71
|
configurator = PreferencesUtil.getAbcdImportConfigurationPreference(true);
|
72
|
}
|
73
|
|
74
|
@Override
|
75
|
protected void addConfiguratorPage() {
|
76
|
AbcdImportConfiguratorWizardPageE4 configuratorWizardPage = ContextInjectionFactory.make(AbcdImportConfiguratorWizardPageE4.class, context);//AbcdImportConfiguratorWizardPage.createPage(configurator);
|
77
|
configuratorWizardPage.setConfigurator(configurator);
|
78
|
addPage(configuratorWizardPage);
|
79
|
}
|
80
|
|
81
|
/** {@inheritDoc} */
|
82
|
@Override
|
83
|
public void addPages() {
|
84
|
super.addPages();
|
85
|
|
86
|
classificationChooserWizardPage = ContextInjectionFactory.make(ClassificationChooserWizardPageE4.class, context);
|
87
|
|
88
|
dataSourcePage = ContextInjectionFactory.make(ImportFromFileDataSourceWizardPageE4.class, context);//.XML();
|
89
|
|
90
|
addPage(classificationChooserWizardPage);
|
91
|
addPage(dataSourcePage);
|
92
|
}
|
93
|
}
|