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
.store
.CdmStore
;
29 public class BerlinModelImportWizard
extends AbstractImportWizard
<BerlinModelImportConfigurator
> {
30 private static final Logger logger
= Logger
31 .getLogger(BerlinModelImportWizard
.class);
33 CdmDataSourceSQLServerWizardPage dataSourcePage
;
35 BerlinModelImportConfigurator configurator
;
38 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
40 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
41 configurator
= BerlinModelImportConfigurator
.NewInstance(null, null);
45 * @see org.eclipse.jface.wizard.Wizard#performFinish()
48 public boolean performFinish() {
50 ICdmDataSource dataSource
=null;
51 if(dataSourcePage
!= null){
52 dataSource
= dataSourcePage
.getDataSource();
54 throw new IllegalStateException("Expected a datasource credentials page to exist");
57 // save the new dataSource to repository
58 // CdmDataSourceRepository.getDefault().save(dataSourceName, dataSource);
60 Source source
= new Source(Source
.SQL_SERVER_2005
,
61 dataSource
.getServer(),
62 dataSource
.getDatabase(),
63 dataSource
.getPort());
64 source
.setUserAndPwd(dataSource
.getUsername(), dataSource
.getPassword());
67 configurator
.setSource(source
);
69 // should be obsolete because we want to pass application context but is not at the moment (throws NPE when not given)
70 configurator
.setDestination(CdmDataSourceRepository
.getDefault().getCurrentDataSource());
72 configurator
.setCdmAppController(CdmStore
.getApplicationController());
74 return doImportInternal(configurator
);
78 * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#getConfigurator()
81 public BerlinModelImportConfigurator
getConfigurator() {
86 * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#addPages()
89 public void addPages() {
92 dataSourcePage
= new CdmDataSourceSQLServerWizardPage(null);
93 addPage(dataSourcePage
);