ed36a971b215222379811ffec4a5bacd82309bc1
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / io / wizard / SddImportWizard.java
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 org.apache.log4j.Logger;
14 import org.eclipse.jface.viewers.IStructuredSelection;
15 import org.eclipse.ui.IWorkbench;
16
17 import eu.etaxonomy.cdm.database.DbSchemaValidation;
18 import eu.etaxonomy.cdm.io.sdd.in.SDDImportConfigurator;
19 import eu.etaxonomy.taxeditor.store.CdmStore;
20
21 /**
22 * @author n.hoffmann
23 * @created Jun 16, 2010
24 * @version 1.0
25 */
26 public class SddImportWizard extends AbstractImportWizard<SDDImportConfigurator> {
27 private static final Logger logger = Logger
28 .getLogger(SddImportWizard.class);
29
30 private SDDImportConfigurator configurator;
31
32 private ImportFromFileDataSourceWizardPage dataSourcePage;
33
34 /* (non-Javadoc)
35 * @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#getConfigurator()
36 */
37 @Override
38 public SDDImportConfigurator getConfigurator() {
39 return configurator;
40 }
41
42 /*
43 * (non-Javadoc)
44 * @see org.eclipse.jface.wizard.Wizard#addPage(org.eclipse.jface.wizard.IWizardPage)
45 */
46 @Override
47 public void addPages() {
48 super.addPages();
49
50 dataSourcePage = new ImportFromFileDataSourceWizardPage("Choose File",
51 "Please choose an XML file in the SDD format.", new String[]{"*.xml", "*.sdd"});
52 addPage(dataSourcePage);
53 }
54
55 /* (non-Javadoc)
56 * @see org.eclipse.jface.wizard.Wizard#performFinish()
57 */
58 @Override
59 public boolean performFinish() {
60 // TODO this is a quick copy from JAXB import. It might not work at all.
61
62 String file = dataSourcePage.getFile();
63
64 // Imports are expecting a string that can be used to instantiate a URL instance
65 // TODO consolidate import and exports regarding what may be passed in as source
66 // will construct a url string for now
67
68 file = "file://" + file;
69
70 configurator.setSource(file);
71 configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
72
73 CdmStore.getImportHandler().run(configurator);
74
75 return true;
76 }
77
78 /* (non-Javadoc)
79 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
80 */
81 public void init(IWorkbench workbench, IStructuredSelection selection) {
82 configurator = CdmStore.getImportHandler().SddConfigurator();
83 }
84 }