Merge branch 'hotfix/5.45.1'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / io / e4 / in / abcd / AbcdImportWizardE4.java
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 package eu.etaxonomy.taxeditor.io.e4.in.abcd;
10
11 import javax.inject.Inject;
12
13 import org.eclipse.e4.core.contexts.ContextInjectionFactory;
14 import org.eclipse.e4.core.contexts.IEclipseContext;
15 import org.eclipse.e4.ui.workbench.modeling.EPartService;
16
17 import eu.etaxonomy.cdm.common.URI;
18 import eu.etaxonomy.cdm.database.DbSchemaValidation;
19 import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
20 import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
21 import eu.etaxonomy.taxeditor.io.e4.in.AbstractImportWizard;
22 import eu.etaxonomy.taxeditor.io.e4.in.ImportFromFileDataSourceWithReferenceWizardPage;
23 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
24 import eu.etaxonomy.taxeditor.store.CdmStore;
25
26 /**
27 * @author pplitzner
28 * @since Oct 5, 2017
29 */
30 public class AbcdImportWizardE4 extends AbstractImportWizard<Abcd206ImportConfigurator> {
31
32 private Abcd206ImportConfigurator configurator;
33 private ImportFromFileDataSourceWithReferenceWizardPage dataSourcePage;
34 private ClassificationChooserWizardPageE4 classificationChooserWizardPage;
35
36 @Inject
37 public AbcdImportWizardE4(IEclipseContext context, EPartService partService) {
38 super(context, partService);
39 }
40
41 @Override
42 public Abcd206ImportConfigurator getConfigurator() {
43 return configurator;
44 }
45
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, source.toFile(), SOURCE_TYPE.INPUTSTREAM);
56
57 return true;
58 }
59
60 @Override
61 public void init() {
62 configurator = PreferencesUtil.getLocalAbcdImportConfigurator(false);
63 }
64
65 @Override
66 protected void addConfiguratorPage() {
67 AbcdImportConfiguratorWizardPage configuratorWizardPage = AbcdImportConfiguratorWizardPage.createFileImportPage(configurator);//AbcdImportConfiguratorWizardPage.createPage(configurator);
68 //configuratorWizardPage.setConfigurator(configurator);
69 addPage(configuratorWizardPage);
70 }
71
72 @Override
73 public void addPages() {
74
75 classificationChooserWizardPage = ContextInjectionFactory.make(ClassificationChooserWizardPageE4.class, context);
76
77 dataSourcePage = ContextInjectionFactory.make(ImportFromFileDataSourceWithReferenceWizardPage.class, context);
78
79 addPage(classificationChooserWizardPage);
80 addPage(dataSourcePage);
81 addConfiguratorPage();
82 //super.addPages();
83 }
84 }