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.net.URI;
|
15
|
|
16
|
import org.eclipse.core.runtime.jobs.Job;
|
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.tcsxml.in.TcsXmlImportConfigurator;
|
23
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
24
|
|
25
|
/**
|
26
|
* <p>TcsImportWizard class.</p>
|
27
|
*
|
28
|
* @author n.hoffmann
|
29
|
* @created 15.06.2009
|
30
|
* @version 1.0
|
31
|
*/
|
32
|
public class TcsImportWizard extends AbstractImportWizard<TcsXmlImportConfigurator> {
|
33
|
|
34
|
private TcsXmlImportConfigurator configurator;
|
35
|
|
36
|
private ImportFromFileDataSourceWizardPage dataSourcePage;
|
37
|
|
38
|
/* (non-Javadoc)
|
39
|
* @see org.eclipse.jface.wizard.Wizard#performFinish()
|
40
|
*/
|
41
|
/** {@inheritDoc} */
|
42
|
@Override
|
43
|
public boolean performFinish() {
|
44
|
URI source = dataSourcePage.getUri();
|
45
|
configurator.setSource(source);
|
46
|
configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
|
47
|
|
48
|
if(CdmStore.getCurrentSessionManager().isRemoting()) {
|
49
|
Job job = CdmStore.getImportManager().createIOServiceJob(configurator, new File(source), SOURCE_TYPE.URI);
|
50
|
CdmStore.getImportManager().run(job);
|
51
|
} else {
|
52
|
CdmStore.getImportManager().run(configurator);
|
53
|
}
|
54
|
|
55
|
return true;
|
56
|
}
|
57
|
|
58
|
/* (non-Javadoc)
|
59
|
* @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
|
60
|
*/
|
61
|
/** {@inheritDoc} */
|
62
|
@Override
|
63
|
public void init(IWorkbench workbench, IStructuredSelection selection) {
|
64
|
super.init(workbench, selection);
|
65
|
configurator = CdmStore.getImportManager().TcsConfigurator();
|
66
|
}
|
67
|
|
68
|
/* (non-Javadoc)
|
69
|
* @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#getConfigurator()
|
70
|
*/
|
71
|
/** {@inheritDoc} */
|
72
|
@Override
|
73
|
public TcsXmlImportConfigurator getConfigurator() {
|
74
|
return configurator;
|
75
|
}
|
76
|
|
77
|
/* (non-Javadoc)
|
78
|
* @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#addPages()
|
79
|
*/
|
80
|
/** {@inheritDoc} */
|
81
|
@Override
|
82
|
public void addPages() {
|
83
|
super.addPages();
|
84
|
|
85
|
dataSourcePage = ImportFromFileDataSourceWizardPage.XML();
|
86
|
addPage(dataSourcePage);
|
87
|
}
|
88
|
}
|