-// $Id$
-/**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-
-package eu.etaxonomy.taxeditor.io.wizard;
-
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbench;
-
-import eu.etaxonomy.cdm.database.ICdmDataSource;
-import eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportConfigurator;
-import eu.etaxonomy.cdm.io.common.Source;
-import eu.etaxonomy.taxeditor.datasource.wizard.CdmDataSourceSQLServerWizardPage;
-import eu.etaxonomy.taxeditor.store.CdmStore;
-
-/**
- * <p>BerlinModelImportWizard class.</p>
- *
- * @author n.hoffmann
- * @created 24.06.2009
- * @version 1.0
- */
-public class BerlinModelImportWizard extends AbstractImportWizard<BerlinModelImportConfigurator> {
-
- CdmDataSourceSQLServerWizardPage dataSourcePage;
-
- BerlinModelImportConfigurator configurator;
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
- */
- /** {@inheritDoc} */
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- super.init(workbench, selection);
- configurator = CdmStore.getImportManager().BerlinModelConfigurator();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.Wizard#performFinish()
- */
- /** {@inheritDoc} */
- @Override
- public boolean performFinish() {
-
- ICdmDataSource dataSource =null;
- if(dataSourcePage != null){
- dataSource = dataSourcePage.getDataSource();
- }else{
- throw new IllegalStateException("Expected a datasource credentials page to exist");
- }
-
- Source source = new Source(Source.SQL_SERVER_2005,
- dataSource.getServer(),
- dataSource.getDatabase(),
- dataSource.getPort());
- source.setUserAndPwd(dataSource.getUsername(), dataSource.getPassword());
-
- configurator.setSource(source);
-
- CdmStore.getImportManager().run(configurator);
-
- return true;
- }
-
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#addPages()
- */
- /** {@inheritDoc} */
- @Override
- public void addPages() {
- super.addPages();
-
- dataSourcePage = new CdmDataSourceSQLServerWizardPage(null);
- addPage(dataSourcePage);
- }
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#getConfigurator()
- */
- /** {@inheritDoc} */
- @Override
- public BerlinModelImportConfigurator getConfigurator() {
- return configurator;
- }
-}