3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.io
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
15 import org
.eclipse
.ui
.IWorkbench
;
17 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
18 import eu
.etaxonomy
.cdm
.io
.berlinModel
.in
.BerlinModelImportConfigurator
;
19 import eu
.etaxonomy
.cdm
.io
.common
.Source
;
20 import eu
.etaxonomy
.taxeditor
.datasource
.CdmDataSourceRepository
;
21 import eu
.etaxonomy
.taxeditor
.datasource
.wizard
.CdmDataSourceSQLServerWizardPage
;
22 import eu
.etaxonomy
.taxeditor
.datasource
.wizard
.CdmDataSourceTypeSelectionWizardPage
;
23 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
30 public class BerlinModelImportWizard
extends AbstractImportWizard
<BerlinModelImportConfigurator
> {
31 private static final Logger logger
= Logger
32 .getLogger(BerlinModelImportWizard
.class);
34 CdmDataSourceSQLServerWizardPage dataSourcePage
;
36 BerlinModelImportConfigurator configurator
;
39 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
41 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
42 configurator
= BerlinModelImportConfigurator
.NewInstance(null, null);
46 * @see org.eclipse.jface.wizard.Wizard#performFinish()
49 public boolean performFinish() {
51 ICdmDataSource dataSource
=null;
52 if(dataSourcePage
!= null){
53 dataSource
= dataSourcePage
.getDataSource();
55 throw new IllegalStateException("Expected a datasource credentials page to exist");
58 // save the new dataSource to repository
59 // CdmDataSourceRepository.getDefault().save(dataSourceName, dataSource);
61 Source source
= new Source(Source
.SQL_SERVER_2005
,
62 dataSource
.getServer(),
63 dataSource
.getDatabase(),
64 dataSource
.getPort());
65 source
.setUserAndPwd(dataSource
.getUsername(), dataSource
.getPassword());
68 configurator
.setSource(source
);
70 // should be obsolete because we want to pass application context but is not at the moment (throws NPE when not given)
71 configurator
.setDestination(CdmDataSourceRepository
.getDefault().getCurrentDataSource());
73 configurator
.setCdmAppController(CdmStore
.getApplicationController());
75 return doImportInternal(configurator
);
79 * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#getConfigurator()
82 public BerlinModelImportConfigurator
getConfigurator() {
87 * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#addPages()
90 public void addPages() {
93 dataSourcePage
= new CdmDataSourceSQLServerWizardPage(null);
94 addPage(dataSourcePage
);