had to rename the packages to make them compliant with buckminster
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / io / wizard / BerlinModelImportWizard.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.eclipse.jface.viewers.IStructuredSelection;
14 import org.eclipse.ui.IWorkbench;
15
16 import eu.etaxonomy.cdm.database.ICdmDataSource;
17 import eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportConfigurator;
18 import eu.etaxonomy.cdm.io.common.Source;
19 import eu.etaxonomy.taxeditor.datasource.wizard.CdmDataSourceSQLServerWizardPage;
20 import eu.etaxonomy.taxeditor.store.CdmStore;
21
22 /**
23 * <p>BerlinModelImportWizard class.</p>
24 *
25 * @author n.hoffmann
26 * @created 24.06.2009
27 * @version 1.0
28 */
29 public class BerlinModelImportWizard extends AbstractImportWizard<BerlinModelImportConfigurator> {
30
31 CdmDataSourceSQLServerWizardPage dataSourcePage;
32
33 BerlinModelImportConfigurator configurator;
34
35 /* (non-Javadoc)
36 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
37 */
38 /** {@inheritDoc} */
39 public void init(IWorkbench workbench, IStructuredSelection selection) {
40 super.init(workbench, selection);
41 configurator = CdmStore.getImportManager().BerlinModelConfigurator();
42 }
43
44 /* (non-Javadoc)
45 * @see org.eclipse.jface.wizard.Wizard#performFinish()
46 */
47 /** {@inheritDoc} */
48 @Override
49 public boolean performFinish() {
50
51 ICdmDataSource dataSource =null;
52 if(dataSourcePage != null){
53 dataSource = dataSourcePage.getDataSource();
54 }else{
55 throw new IllegalStateException("Expected a datasource credentials page to exist");
56 }
57
58 Source source = new Source(Source.SQL_SERVER_2005,
59 dataSource.getServer(),
60 dataSource.getDatabase(),
61 dataSource.getPort());
62 source.setUserAndPwd(dataSource.getUsername(), dataSource.getPassword());
63
64 configurator.setSource(source);
65
66 CdmStore.getImportManager().run(configurator);
67
68 return true;
69 }
70
71
72 /* (non-Javadoc)
73 * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#addPages()
74 */
75 /** {@inheritDoc} */
76 @Override
77 public void addPages() {
78 super.addPages();
79
80 dataSourcePage = new CdmDataSourceSQLServerWizardPage(null);
81 addPage(dataSourcePage);
82 }
83
84 /* (non-Javadoc)
85 * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#getConfigurator()
86 */
87 /** {@inheritDoc} */
88 @Override
89 public BerlinModelImportConfigurator getConfigurator() {
90 return configurator;
91 }
92 }