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.in.owl;
|
11
|
|
12
|
import java.io.File;
|
13
|
import java.net.URI;
|
14
|
|
15
|
import javax.inject.Inject;
|
16
|
|
17
|
import org.eclipse.core.runtime.jobs.Job;
|
18
|
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
19
|
import org.eclipse.e4.core.contexts.IEclipseContext;
|
20
|
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
21
|
|
22
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
23
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
|
24
|
import eu.etaxonomy.cdm.io.descriptive.owl.in.OwlImportConfigurator;
|
25
|
import eu.etaxonomy.taxeditor.io.e4.in.AbstractImportWizardE4;
|
26
|
import eu.etaxonomy.taxeditor.io.e4.in.ImportFromFileDataSourceWizardPage;
|
27
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
28
|
|
29
|
/**
|
30
|
*
|
31
|
* @author pplitzner
|
32
|
* @since Apr 25, 2019
|
33
|
*
|
34
|
*/
|
35
|
public class OwlImportWizard extends AbstractImportWizardE4<OwlImportConfigurator> {
|
36
|
|
37
|
private OwlImportConfigurator configurator;
|
38
|
private ImportFromFileDataSourceWizardPage dataSourcePage;
|
39
|
|
40
|
@Inject
|
41
|
public OwlImportWizard(IEclipseContext context, EPartService partService) {
|
42
|
super(context, partService);
|
43
|
}
|
44
|
|
45
|
@Override
|
46
|
public OwlImportConfigurator getConfigurator() {
|
47
|
return configurator;
|
48
|
}
|
49
|
|
50
|
/** {@inheritDoc} */
|
51
|
@Override
|
52
|
public boolean performFinish() {
|
53
|
URI source = dataSourcePage.getUri();
|
54
|
configurator.setSource(source);
|
55
|
configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
|
56
|
Job job = CdmStore.getImportManager().createIOServiceJob(configurator, new File(source), SOURCE_TYPE.URI);
|
57
|
CdmStore.getImportManager().run(job);
|
58
|
|
59
|
return true;
|
60
|
}
|
61
|
|
62
|
/** {@inheritDoc} */
|
63
|
@Override
|
64
|
public void init() {
|
65
|
configurator = CdmStore.getImportManager().OwlImportConfigurator();
|
66
|
}
|
67
|
|
68
|
@Override
|
69
|
protected void addConfiguratorPage() {
|
70
|
// OwlImportConfiguratorWizardPage configuratorWizardPage = ContextInjectionFactory.make(OwlImportConfiguratorWizardPage.class, context);//AbcdImportConfiguratorWizardPage.createPage(configurator);
|
71
|
// configuratorWizardPage.setConfigurator(configurator);
|
72
|
// addPage(configuratorWizardPage);
|
73
|
}
|
74
|
|
75
|
/** {@inheritDoc} */
|
76
|
@Override
|
77
|
public void addPages() {
|
78
|
dataSourcePage = ContextInjectionFactory.make(ImportFromFileDataSourceWizardPage.class, context);
|
79
|
dataSourcePage.setTitle("Choose File");
|
80
|
dataSourcePage.setDescription("Please choose an OWL file to import an ontology as a term tree.");
|
81
|
dataSourcePage.setExtensions(new String[]{"*.owl"});
|
82
|
|
83
|
addPage(dataSourcePage);
|
84
|
}
|
85
|
}
|