Project

General

Profile

« Previous | Next » 

Revision 1e333358

Added by Patrick Plitzner over 6 years ago

ref #7005 Migrate RIS import

View differences:

eu.etaxonomy.taxeditor.store/fragment.e4xmi
109 109
    <elements xsi:type="commands:Command" xmi:id="_QbHeEKmQEeeDJPU_cUTI2g" elementId="eu.etaxonomy.taxeditor.store.command.importAbcd" commandName="%wizard.name.3"/>
110 110
    <elements xsi:type="commands:Command" xmi:id="_tpPnUKmfEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.command.importExcelDistribution" commandName="%wizard.name.23"/>
111 111
    <elements xsi:type="commands:Command" xmi:id="_qAEkYKmjEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.command.importExcelTaxa" commandName="%wizard.name.2"/>
112
    <elements xsi:type="commands:Command" xmi:id="_tBCr8KmsEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.command.imnportRisReference" commandName="%wizard.name.24"/>
112 113
  </fragments>
113 114
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_swGH0GhvEee3K4uKJljEYg" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application">
114 115
    <elements xsi:type="commands:Handler" xmi:id="_rVEdIGcjEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" command="_fNBtQGcjEee0qLTtA2ZpVQ"/>
......
120 121
    <elements xsi:type="commands:Handler" xmi:id="_2yHUgKmYEeeDJPU_cUTI2g" elementId="eu.etaxonomy.taxeditor.io.e4.abcd.OpenAbcdImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.abcd.OpenAbcdImportWizard" command="_QbHeEKmQEeeDJPU_cUTI2g"/>
121 122
    <elements xsi:type="commands:Handler" xmi:id="_6slh0KmfEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.excel.distribution.OpenExcelDistributionImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.excel.distribution.OpenExcelDistributionImportWizard" command="_tpPnUKmfEeeTAPHmaMLwQQ"/>
122 123
    <elements xsi:type="commands:Handler" xmi:id="_wvx9oKmjEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.excel.taxa.OpenExcelTaxaImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.excel.taxa.OpenExcelTaxaImportWizard" command="_qAEkYKmjEeeTAPHmaMLwQQ"/>
124
    <elements xsi:type="commands:Handler" xmi:id="_96ANIKmsEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.ris.OpenRisImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.ris.OpenRisImportWizard" command="_tBCr8KmsEeeTAPHmaMLwQQ"/>
123 125
  </fragments>
124 126
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_qT4hgIfTEeecZ4F2Y9Z0Og" featurename="children" parentElementId="eu.etaxonomy.taxeditor.workbench.menu.window" positionInList="before:eu.etaxonomy.taxeditor.application.windowMenu.last">
125 127
    <elements xsi:type="menu:Menu" xmi:id="_LT3P8IfcEeecZ4F2Y9Z0Og" elementId="eu.etaxonomy.taxeditor.store.menu.termeditor" label="Term Editor">
......
143 145
        <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_wnmZYKmgEeeTAPHmaMLwQQ" coreExpressionId="isShowExperimentalFeatures"/>
144 146
      </children>
145 147
      <children xsi:type="menu:HandledMenuItem" xmi:id="_0z1o8KmjEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.exceldistribution" label="%wizard.name.2" command="_qAEkYKmjEeeTAPHmaMLwQQ"/>
148
      <children xsi:type="menu:HandledMenuItem" xmi:id="_pQNeoKmsEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.risReference" label="%wizard.name.24" command="_qAEkYKmjEeeTAPHmaMLwQQ"/>
146 149
    </elements>
147 150
  </fragments>
148 151
</fragment:ModelFragments>
eu.etaxonomy.taxeditor.store/plugin.xml
440 440
            id="eu.etaxonomy.taxeditor.io.import.endnote"
441 441
            name="%wizard.name.1">
442 442
      </wizard>-->
443
       <wizard
444
            category="eu.etaxonomy.taxeditor.import.category.cdm"
445
            class="eu.etaxonomy.taxeditor.io.wizard.RISImportWizard"
446
            id="eu.etaxonomy.taxeditor.io.import.risImport"
447
            name="%wizard.name.24">
448
          
449
      </wizard>
450 443
      <wizard
451 444
            category="eu.etaxonomy.taxeditor.import.category.cdm"
452 445
            class="eu.etaxonomy.taxeditor.io.wizard.SddImportWizard"
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/ris/OpenRisImportWizard.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9
package eu.etaxonomy.taxeditor.io.e4.ris;
10

  
11
import eu.etaxonomy.taxeditor.io.e4.AbstractImportWizardE4;
12
import eu.etaxonomy.taxeditor.io.e4.AbstractOpenImportWizard;
13

  
14
/**
15
 * @author pplitzner
16
 * @since Oct 5, 2017
17
 *
18
 */
19
public class OpenRisImportWizard extends AbstractOpenImportWizard {
20

  
21
    /**
22
     * {@inheritDoc}
23
     */
24
    @Override
25
    protected Class<? extends AbstractImportWizardE4> getImportWizardClass() {
26
        return RISImportWizardE4.class;
27
    }
28

  
29
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/ris/RISImportWizardE4.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9
package eu.etaxonomy.taxeditor.io.e4.ris;
10

  
11
import java.io.File;
12
import java.io.FileInputStream;
13
import java.io.FileNotFoundException;
14
import java.io.IOException;
15
import java.net.URI;
16
import java.util.ArrayList;
17
import java.util.List;
18

  
19
import javax.inject.Inject;
20

  
21
import org.apache.commons.io.IOUtils;
22
import org.apache.log4j.Logger;
23
import org.eclipse.core.runtime.jobs.Job;
24
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
25
import org.eclipse.e4.core.contexts.IEclipseContext;
26
import org.eclipse.e4.ui.workbench.modeling.EPartService;
27

  
28
import eu.etaxonomy.cdm.database.DbSchemaValidation;
29
import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
30
import eu.etaxonomy.cdm.io.reference.ris.in.RisReferenceImportConfigurator;
31
import eu.etaxonomy.taxeditor.io.e4.AbstractImportWizardE4;
32
import eu.etaxonomy.taxeditor.io.e4.GenericConfiguratorWizardPageE4;
33
import eu.etaxonomy.taxeditor.io.e4.ImportFromFileDataSourceWizardPageE4;
34
import eu.etaxonomy.taxeditor.io.wizard.ExcelDistributionUpdateWizard;
35
import eu.etaxonomy.taxeditor.store.CdmStore;
36

  
37
/**
38
 * @author k.luther
39
 * @date 12.05.2017
40
 *
41
 */
42
public class RISImportWizardE4 extends AbstractImportWizardE4<RisReferenceImportConfigurator>{
43

  
44
    private RisReferenceImportConfigurator configurator;
45

  
46
    private ImportFromFileDataSourceWizardPageE4 dataSourcePage;
47

  
48
    private static final Logger logger = Logger.getLogger(ExcelDistributionUpdateWizard.class);
49

  
50
    @Inject
51
    public RISImportWizardE4(IEclipseContext context, EPartService partService) {
52
        super(context, partService, null);
53
    }
54

  
55
    /** {@inheritDoc} */
56
    @Override
57
    public RisReferenceImportConfigurator getConfigurator() {
58
        return configurator;
59
    }
60

  
61
    /** {@inheritDoc} */
62
    @Override
63
    public boolean performFinish() {
64
        URI source = dataSourcePage.getUri();
65
        configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
66
        File file = new File(source);
67
       FileInputStream fis;
68

  
69
        try {
70
            fis = new FileInputStream(file);
71
            byte[] data;
72
            data = IOUtils.toByteArray(fis);
73
            configurator.setStream(data);
74
//TODO: workaround, needs to be changed to source as byte array
75
            Job job = CdmStore.getImportManager().createIOServiceJob(configurator, data, SOURCE_TYPE.INPUTSTREAM);
76
            CdmStore.getImportManager().run(job);
77
        } catch (FileNotFoundException e) {
78
            logger.error("Error while reading file" + source.toString());
79
        } catch (IOException e){
80

  
81
        }
82

  
83
        return true;
84
    }
85

  
86
    /** {@inheritDoc} */
87
    @Override
88
    public void init() {
89
        configurator = RisReferenceImportConfigurator.NewInstance();
90

  
91
    }
92

  
93
    /** {@inheritDoc} */
94
    @Override
95
    public void addPages() {
96
        addDataSourcePage();
97
    }
98
    @Override
99
    protected void addConfiguratorPage(){
100
        List<String> ignoreMethods = new ArrayList<>();
101
        ignoreMethods.add("setIgnoreNull");
102
        ignoreMethods.add("setInteractWithUser");
103
        ignoreMethods.add("setUseClassification");
104
        pageConfiguration = ContextInjectionFactory.make(GenericConfiguratorWizardPageE4.class, context);
105
        pageConfiguration.initImport(getConfigurator(), ignoreMethods, "Ris Import");
106
        addPage(pageConfiguration);
107
    }
108

  
109
    private void addDataSourcePage(){
110
        dataSourcePage = ContextInjectionFactory.make(ImportFromFileDataSourceWizardPageE4.class, context);
111
        dataSourcePage.setTitle("Choose Ris File");
112
        dataSourcePage.setDescription("Please choose an xls file in the Distribution Update format.");
113
        dataSourcePage.setExtensions(new String[]{"*.txt"});
114
        addPage(dataSourcePage);
115
    }
116

  
117
}

Also available in: Unified diff