performed javacscript:fix and worked on documentation
[taxeditor.git] / 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 configurator = CdmStore.getImportHandler().BerlinModelConfigurator();
41 }
42
43 /* (non-Javadoc)
44 * @see org.eclipse.jface.wizard.Wizard#performFinish()
45 */
46 /** {@inheritDoc} */
47 @Override
48 public boolean performFinish() {
49
50 ICdmDataSource dataSource =null;
51 if(dataSourcePage != null){
52 dataSource = dataSourcePage.getDataSource();
53 }else{
54 throw new IllegalStateException("Expected a datasource credentials page to exist");
55 }
56
57 Source source = new Source(Source.SQL_SERVER_2005,
58 dataSource.getServer(),
59 dataSource.getDatabase(),
60 dataSource.getPort());
61 source.setUserAndPwd(dataSource.getUsername(), dataSource.getPassword());
62
63 configurator.setSource(source);
64
65 CdmStore.getImportHandler().run(configurator);
66
67 return true;
68 }
69
70
71 /* (non-Javadoc)
72 * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#addPages()
73 */
74 /** {@inheritDoc} */
75 @Override
76 public void addPages() {
77 super.addPages();
78
79 dataSourcePage = new CdmDataSourceSQLServerWizardPage(null);
80 addPage(dataSourcePage);
81 }
82
83 /* (non-Javadoc)
84 * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#getConfigurator()
85 */
86 /** {@inheritDoc} */
87 @Override
88 public BerlinModelImportConfigurator getConfigurator() {
89 return configurator;
90 }
91 }