Project

General

Profile

Download (2.48 KB) Statistics
| Branch: | Tag: | Revision:
1 2d9a13f7 n.hoffmann
/**
2
* Copyright (C) 2007 EDIT
3 f6a8dc56 Patric Plitzner
* European Distributed Institute of Taxonomy
4 2d9a13f7 n.hoffmann
* http://www.e-taxonomy.eu
5 f6a8dc56 Patric Plitzner
*
6 2d9a13f7 n.hoffmann
* 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 f6a8dc56 Patric Plitzner
import java.io.File;
13 eed8805d Andreas Kohlbecker
import java.net.URI;
14
15 f6a8dc56 Patric Plitzner
import org.apache.log4j.Logger;
16 2d9a13f7 n.hoffmann
import org.eclipse.jface.viewers.IStructuredSelection;
17
import org.eclipse.ui.IWorkbench;
18
19
import eu.etaxonomy.cdm.database.DbSchemaValidation;
20 43527305 Cherian Mathew
import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
21 2d9a13f7 n.hoffmann
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
22 da948591 Katja Luther
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
23 2d9a13f7 n.hoffmann
import eu.etaxonomy.taxeditor.store.CdmStore;
24
25
/**
26 3be6ef3e n.hoffmann
 *
27 2d9a13f7 n.hoffmann
 * @author n.hoffmann
28
 * @created Jun 16, 2010
29
 * @version 1.0
30
 */
31
public class AbcdImportWizard extends AbstractImportWizard<Abcd206ImportConfigurator> {
32
33 f6a8dc56 Patric Plitzner
    private static final Logger logger = Logger.getLogger(AbcdImportWizard.class);
34
35 2d9a13f7 n.hoffmann
	private Abcd206ImportConfigurator configurator;
36 7563a18e Katja Luther
	private AbcdSourceSelectionPage dataSourcePage;
37 976b9268 Patric Plitzner
	private ClassificationChooserWizardPage classificationChooserWizardPage;
38 f6a8dc56 Patric Plitzner
39 3be6ef3e n.hoffmann
	/** {@inheritDoc} */
40 2d9a13f7 n.hoffmann
	@Override
41
	public Abcd206ImportConfigurator getConfigurator() {
42
		return configurator;
43
	}
44
45 3be6ef3e n.hoffmann
	/** {@inheritDoc} */
46 2d9a13f7 n.hoffmann
	@Override
47
	public boolean performFinish() {
48 43527305 Cherian Mathew
	    URI source = dataSourcePage.getUri();
49
	    configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
50 f6a8dc56 Patric Plitzner
51 43527305 Cherian Mathew
	    if(classificationChooserWizardPage.getClassification()!=null){
52
	        configurator.setClassificationUuid(classificationChooserWizardPage.getClassification().getUuid());
53
	    }
54 976b9268 Patric Plitzner
55 d85cfdf3 Katja Luther
	    CdmStore.getImportManager().runMoniteredOperation(configurator, new File(source), SOURCE_TYPE.INPUTSTREAM);
56 da948591 Katja Luther
57 43527305 Cherian Mathew
	    return true;
58 f6a8dc56 Patric Plitzner
59 2d9a13f7 n.hoffmann
	}
60
61 3be6ef3e n.hoffmann
	/** {@inheritDoc} */
62 f6a8dc56 Patric Plitzner
	@Override
63
    public void init(IWorkbench workbench, IStructuredSelection selection) {
64 32563c64 n.hoffmann
		super.init(workbench, selection);
65 da948591 Katja Luther
		configurator =  PreferencesUtil.getAbcdImportConfigurationPreference(true);
66 2d9a13f7 n.hoffmann
	}
67 da948591 Katja Luther
68 3c066c3d Patrick Plitzner
	@Override
69
	protected void addConfiguratorPage() {
70
		AbcdImportConfiguratorWizardPage configuratorWizardPage = AbcdImportConfiguratorWizardPage.createPage(configurator);
71
		addPage(configuratorWizardPage);
72
	}
73 f6a8dc56 Patric Plitzner
74 3be6ef3e n.hoffmann
	/** {@inheritDoc} */
75 2d9a13f7 n.hoffmann
	@Override
76
	public void addPages() {
77
		super.addPages();
78 f6a8dc56 Patric Plitzner
79 976b9268 Patric Plitzner
		classificationChooserWizardPage = ClassificationChooserWizardPage.createPage();
80 7563a18e Katja Luther
81 2d9a13f7 n.hoffmann
		dataSourcePage = ImportFromFileDataSourceWizardPage.XML();
82 7563a18e Katja Luther
83 976b9268 Patric Plitzner
		addPage(classificationChooserWizardPage);
84 2d9a13f7 n.hoffmann
		addPage(dataSourcePage);
85
	}
86
}