2 * Copyright (C) 2017 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.io
.wizard
;
12 import java
.io
.FileInputStream
;
13 import java
.io
.FileNotFoundException
;
14 import java
.io
.IOException
;
16 import java
.util
.ArrayList
;
17 import java
.util
.List
;
19 import org
.apache
.commons
.io
.IOUtils
;
20 import org
.apache
.log4j
.Logger
;
21 import org
.eclipse
.core
.runtime
.jobs
.Job
;
22 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
23 import org
.eclipse
.ui
.IWorkbench
;
25 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
26 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.SOURCE_TYPE
;
27 import eu
.etaxonomy
.cdm
.io
.reference
.ris
.in
.RisReferenceImportConfigurator
;
28 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
35 public class RISImportWizard
extends AbstractImportWizard
<RisReferenceImportConfigurator
>{
36 private RisReferenceImportConfigurator configurator
;
38 private ImportFromFileDataSourceWizardPage dataSourcePage
;
40 private static final Logger logger
= Logger
.getLogger(ExcelDistributionUpdateWizard
.class);
43 * @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#getConfigurator()
47 public RisReferenceImportConfigurator
getConfigurator() {
52 * @see org.eclipse.jface.wizard.Wizard#performFinish()
56 public boolean performFinish() {
57 URI source
= dataSourcePage
.getUri();
58 // configurator.setSource(source);
60 // configurator = RisReferenceImportConfigurator.NewInstance(source, null);
61 // } catch (MalformedURLException e1) {
62 // // TODO Auto-generated catch block
63 // e1.printStackTrace();
64 // } catch (IOException e1) {
65 // // TODO Auto-generated catch block
66 // e1.printStackTrace();
68 configurator
.setDbSchemaValidation(DbSchemaValidation
.CREATE
);
69 File file
= new File(source
);
73 fis
= new FileInputStream(file
);
75 data
= IOUtils
.toByteArray(fis
);
76 configurator
.setStream(data
);
77 //TODO: workaround, needs to be changed to source as byte array
78 Job job
= CdmStore
.getImportManager().createIOServiceJob(configurator
, data
, SOURCE_TYPE
.INPUTSTREAM
);
79 CdmStore
.getImportManager().run(job
);
80 } catch (FileNotFoundException e
) {
81 logger
.error("Error while reading file" + source
.toString());
82 } catch (IOException e
){
86 //CdmStore.getImportManager().runMoniteredOperation(configurator, new File(source), SOURCE_TYPE.INPUTSTREAM);
93 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
97 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
98 super.init(workbench
, selection
);
99 configurator
= RisReferenceImportConfigurator
.NewInstance();
104 * @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#addPages()
108 public void addPages() {
109 //addConfiguratorPage();
115 protected void addConfiguratorPage(){
116 List
<String
> ignoreMethods
= new ArrayList
<>();
117 ignoreMethods
.add("setIgnoreNull");
118 ignoreMethods
.add("setInteractWithUser");
119 ignoreMethods
.add("setUseClassification");
120 pageConfiguration
= GenericConfiguratorWizardPage
.Import(CONFIGURATION_PAGE
, getConfigurator(), ignoreMethods
, "Ris Import");
121 addPage(pageConfiguration
);
124 private void addDataSourcePage(){
125 dataSourcePage
= new ImportFromFileDataSourceWizardPage("Choose Ris File",
126 "Please choose an xls file in the Distribution Update format.", new String
[]{"*.txt"});
127 addPage(dataSourcePage
);