Project

General

Profile

« Previous | Next » 

Revision 43527305

Added by Cherian Mathew over 8 years ago

#5130 Extend import wizards to import data via remoting and Add tests for the same

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/TcsImportWizard.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
10 10

  
11 11
package eu.etaxonomy.taxeditor.io.wizard;
12 12

  
13
import java.io.File;
13 14
import java.net.URI;
14 15

  
16
import org.eclipse.core.runtime.jobs.Job;
15 17
import org.eclipse.jface.viewers.IStructuredSelection;
16 18
import org.eclipse.ui.IWorkbench;
17 19

  
18 20
import eu.etaxonomy.cdm.database.DbSchemaValidation;
21
import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
19 22
import eu.etaxonomy.cdm.io.tcsxml.in.TcsXmlImportConfigurator;
20 23
import eu.etaxonomy.taxeditor.store.CdmStore;
21 24

  
......
26 29
 * @created 15.06.2009
27 30
 * @version 1.0
28 31
 */
29
public class TcsImportWizard extends AbstractImportWizard<TcsXmlImportConfigurator>{
30
	
32
public class TcsImportWizard extends AbstractImportWizard<TcsXmlImportConfigurator> {
33

  
31 34
	private TcsXmlImportConfigurator configurator;
32 35

  
33 36
	private ImportFromFileDataSourceWizardPage dataSourcePage;
......
38 41
	/** {@inheritDoc} */
39 42
	@Override
40 43
	public boolean performFinish() {
41
		URI source = dataSourcePage.getUri();
42
		configurator.setSource(source);
43
		configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
44
		
45
		CdmStore.getImportManager().run(configurator);
46
		
47
		return true;
44
	    URI source = dataSourcePage.getUri();
45
	    configurator.setSource(source);
46
	    configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
47

  
48
	    if(CdmStore.getCurrentSessionManager().isRemoting()) {
49
	        Job job = CdmStore.getImportManager().createIOServiceJob(configurator, new File(source), SOURCE_TYPE.URI);
50
	        CdmStore.getImportManager().run(job);
51
	    } else {
52
	        CdmStore.getImportManager().run(configurator);
53
	    }
54

  
55
	    return true;
48 56
	}
49 57

  
50 58
	/* (non-Javadoc)
51 59
	 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
52 60
	 */
53 61
	/** {@inheritDoc} */
54
	public void init(IWorkbench workbench, IStructuredSelection selection) {
62
	@Override
63
    public void init(IWorkbench workbench, IStructuredSelection selection) {
55 64
		super.init(workbench, selection);
56 65
		configurator = CdmStore.getImportManager().TcsConfigurator();
57 66
	}
......
72 81
	@Override
73 82
	public void addPages() {
74 83
		super.addPages();
75
		
84

  
76 85
		dataSourcePage = ImportFromFileDataSourceWizardPage.XML();
77 86
		addPage(dataSourcePage);
78 87
	}

Also available in: Unified diff