Project

General

Profile

Download (2.87 KB) Statistics
| Branch: | Tag: | Revision:
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 java.io.File;
14
import java.io.FileInputStream;
15
import java.io.FileNotFoundException;
16
import java.net.URI;
17

    
18
import org.apache.log4j.Logger;
19
import org.eclipse.jface.viewers.IStructuredSelection;
20
import org.eclipse.ui.IWorkbench;
21

    
22
import eu.etaxonomy.cdm.database.DbSchemaValidation;
23
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
24
import eu.etaxonomy.taxeditor.store.CdmStore;
25

    
26
/**
27
 * <p>AbcdImportWizard class.</p>
28
 *
29
 * @author n.hoffmann
30
 * @created Jun 16, 2010
31
 * @version 1.0
32
 */
33
public class AbcdImportWizard extends AbstractImportWizard<Abcd206ImportConfigurator> {
34

    
35
    private static final Logger logger = Logger.getLogger(AbcdImportWizard.class);
36

    
37
	private Abcd206ImportConfigurator configurator;
38
	private ImportFromFileDataSourceWizardPage dataSourcePage;
39
	private ClassificationChooserWizardPage classificationChooserWizardPage;
40

    
41
	/* (non-Javadoc)
42
	 * @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#getConfigurator()
43
	 */
44
	/** {@inheritDoc} */
45
	@Override
46
	public Abcd206ImportConfigurator getConfigurator() {
47
		return configurator;
48
	}
49

    
50
	/* (non-Javadoc)
51
	 * @see org.eclipse.jface.wizard.Wizard#performFinish()
52
	 */
53
	/** {@inheritDoc} */
54
	@Override
55
	public boolean performFinish() {
56
		URI source = dataSourcePage.getUri();
57
		try {
58
            configurator.setSource(new FileInputStream(new File(source)));
59
        } catch (FileNotFoundException e) {
60
            logger.error("File not found!", e);
61
            return false;
62
        }
63
		configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
64

    
65
		if(classificationChooserWizardPage.getClassification()!=null){
66
		    configurator.setClassificationUuid(classificationChooserWizardPage.getClassification().getUuid());
67
		}
68
		configurator.setReportUri(classificationChooserWizardPage.getReportUri());
69

    
70
		CdmStore.getImportManager().run(configurator);
71
		return true;
72

    
73
	}
74

    
75
	/* (non-Javadoc)
76
	 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
77
	 */
78
	/** {@inheritDoc} */
79
	@Override
80
    public void init(IWorkbench workbench, IStructuredSelection selection) {
81
		super.init(workbench, selection);
82
		configurator =  CdmStore.getImportManager().AbcdConfigurator();
83
	}
84

    
85
	/* (non-Javadoc)
86
	 * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#addPages()
87
	 */
88
	/** {@inheritDoc} */
89
	@Override
90
	public void addPages() {
91
		super.addPages();
92

    
93
		classificationChooserWizardPage = ClassificationChooserWizardPage.createPage();
94
		dataSourcePage = ImportFromFileDataSourceWizardPage.XML();
95
		addPage(classificationChooserWizardPage);
96
		addPage(dataSourcePage);
97
	}
98
}
(1-1/22)