Project

General

Profile

Revision fd907381

IDfd907381ca720580c224fb3aa19b8c4d45c24ae7
Parent 59e7cc59
Child 025d7862

Added by Patrick Plitzner about 3 years ago

ref #7008 Migrate CSV export

View differences:

eu.etaxonomy.taxeditor.store/fragment.e4xmi
113 113
    <elements xsi:type="commands:Command" xmi:id="_bLGTMKmuEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.command.importSdd" commandName="%wizard.name.4"/>
114 114
    <elements xsi:type="commands:Command" xmi:id="_2JV9IKnAEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.command.importExcelSpecimen" commandName="%wizard.name.5"/>
115 115
    <elements xsi:type="commands:Command" xmi:id="_OQ9n8KnCEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.command.importTcs" commandName="%wizard.name"/>
116
    <elements xsi:type="commands:Command" xmi:id="_L0xNEKqYEeeXcJGhyhlrKA" elementId="eu.etaxonomy.taxeditor.store.command.exportCsv" commandName="%wizard.name.18"/>
116 117
  </fragments>
117 118
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_swGH0GhvEee3K4uKJljEYg" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application">
118 119
    <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"/>
......
128 129
    <elements xsi:type="commands:Handler" xmi:id="_do2IAKmuEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.sdd.OpenSddImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.in.sdd.OpenSddImportWizard" command="_bLGTMKmuEeeTAPHmaMLwQQ"/>
129 130
    <elements xsi:type="commands:Handler" xmi:id="_6BmBEKnAEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.excel.specimen.OpenExcelSpecimenImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.in.excel.specimen.OpenExcelSpecimenImportWizard" command="_2JV9IKnAEeeTAPHmaMLwQQ"/>
130 131
    <elements xsi:type="commands:Handler" xmi:id="_Q8Z6gKnCEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.tcs.TcsImportWizardE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.in.tcs.TcsImportWizardE4" command="_OQ9n8KnCEeeTAPHmaMLwQQ"/>
132
    <elements xsi:type="commands:Handler" xmi:id="_SciLQKqYEeeXcJGhyhlrKA" elementId="eu.etaxonomy.taxeditor.io.e4.out.csv.OpenCsvExportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.out.csv.OpenCsvExportWizard" command="_L0xNEKqYEeeXcJGhyhlrKA"/>
131 133
  </fragments>
132 134
  <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">
133 135
    <elements xsi:type="menu:Menu" xmi:id="_LT3P8IfcEeecZ4F2Y9Z0Og" elementId="eu.etaxonomy.taxeditor.store.menu.termeditor" label="Term Editor">
......
156 158
      <children xsi:type="menu:HandledMenuItem" xmi:id="_hXY2UKmuEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.importSdd" label="%wizard.name.4" command="_bLGTMKmuEeeTAPHmaMLwQQ"/>
157 159
      <children xsi:type="menu:HandledMenuItem" xmi:id="_X2Xb8KnCEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.importTcs" label="%wizard.name" command="_OQ9n8KnCEeeTAPHmaMLwQQ"/>
158 160
    </elements>
161
    <elements xsi:type="menu:Menu" xmi:id="_z6EugKqXEeeXcJGhyhlrKA" elementId="eu.etaxonomy.taxeditor.store.menu.export" label="Export (E4)">
162
      <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_3eyLYKqXEeeXcJGhyhlrKA" coreExpressionId="isCdmStoreConnected"/>
163
      <children xsi:type="menu:HandledMenuItem" xmi:id="_V3eBEKqYEeeXcJGhyhlrKA" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.wizardname18" label="%wizard.name.18" command="_L0xNEKqYEeeXcJGhyhlrKA"/>
164
    </elements>
159 165
  </fragments>
160 166
</fragment:ModelFragments>
eu.etaxonomy.taxeditor.store/plugin.xml
215 215
      </wizard>
216 216
      <wizard
217 217
            category="eu.etaxonomy.taxeditor.export.category.cdm"
218
            class="eu.etaxonomy.taxeditor.io.wizard.CsvExportWizard"
219
            id="eu.etaxonomy.taxeditor.io.export.csv"
220
            name="%wizard.name.18">
221
      </wizard>
222
      <wizard
223
            category="eu.etaxonomy.taxeditor.export.category.cdm"
224 218
            class="eu.etaxonomy.taxeditor.io.wizard.CsvNameExportWizard"
225 219
            id="eu.etaxonomy.taxeditor.io.export.csv_name"
226 220
            name="%wizard.name.19">
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/AbstractExportWizardE4.java
1
/**
2
* Copyright (C) 2007 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

  
10
package eu.etaxonomy.taxeditor.io.e4.out;
11

  
12
import org.eclipse.jface.wizard.Wizard;
13

  
14
import eu.etaxonomy.cdm.io.common.IIoConfigurator;
15
import eu.etaxonomy.taxeditor.io.wizard.GenericConfiguratorWizardPage;
16

  
17
/**
18
 *
19
 * @author pplitzner
20
 * @since Oct 6, 2017
21
 *
22
 * @param <CONFIG>
23
 */
24
public abstract class AbstractExportWizardE4<CONFIG extends IIoConfigurator> extends Wizard {
25

  
26
	protected final String CONFIGURATION_PAGE = "CONFIGURATION_PAGE";
27

  
28
	private GenericConfiguratorWizardPage pageConfiguration;
29

  
30
	/** {@inheritDoc} */
31
	@Override
32
	public void addPages() {
33
		super.addPages();
34

  
35
		pageConfiguration = GenericConfiguratorWizardPage.Export(CONFIGURATION_PAGE, getConfigurator(), null);
36
		this.addPage(pageConfiguration);
37
	}
38

  
39
	public abstract void init();
40

  
41
	public abstract CONFIG getConfigurator();
42
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/AbstractOpenExportWizard.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.out;
10

  
11
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
12
import org.eclipse.e4.core.contexts.IEclipseContext;
13
import org.eclipse.e4.core.di.annotations.Execute;
14
import org.eclipse.jface.wizard.WizardDialog;
15
import org.eclipse.swt.widgets.Shell;
16

  
17
/**
18
 * @author pplitzner
19
 * @since Oct 5, 2017
20
 *
21
 */
22
public abstract class AbstractOpenExportWizard {
23
    @Execute
24
    public void execute(IEclipseContext ctx, Shell s)
25
    {
26
        AbstractExportWizardE4 wizard = ContextInjectionFactory.make(getExportWizardClass(), ctx);
27
        wizard.init();
28
        WizardDialog dialog = new WizardDialog(s, wizard);
29
        dialog.open();
30
    }
31

  
32
    protected abstract Class<? extends AbstractExportWizardE4> getExportWizardClass();
33

  
34
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/csv/CsvExportWizardE4.java
1
/**
2
 * Copyright (C) 2007 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

  
10
package eu.etaxonomy.taxeditor.io.e4.out.csv;
11

  
12
import java.io.File;
13
import java.util.HashSet;
14
import java.util.List;
15
import java.util.UUID;
16

  
17
import org.eclipse.core.runtime.jobs.Job;
18
import org.eclipse.swt.widgets.Combo;
19
import org.eclipse.ui.progress.IProgressConstants;
20

  
21
import eu.etaxonomy.cdm.io.csv.redlist.demo.CsvDemoExportConfigurator;
22
import eu.etaxonomy.cdm.model.taxon.Classification;
23
import eu.etaxonomy.taxeditor.io.e4.out.AbstractExportWizardE4;
24
import eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage;
25
import eu.etaxonomy.taxeditor.store.CdmStore;
26

  
27
/**
28
 * @author a.oppermann
29
 * @created Nov. 11, 2014
30
 * @version 1.0
31
 */
32
public class CsvExportWizardE4 extends AbstractExportWizardE4<CsvDemoExportConfigurator> {
33

  
34
	private CsvDemoExportConfigurator configurator;
35
	private ExportToFileDestinationWizardPage page;
36

  
37
	private final String description = "Export the contents of the currently selected database into Comma Separated Value format.";
38

  
39
	@Override
40
	public void init() {
41
		configurator = CsvDemoExportConfigurator.NewInstance(null, null);
42
	}
43

  
44
	@Override
45
	public CsvDemoExportConfigurator getConfigurator() {
46
		return configurator;
47
	}
48

  
49
	@Override
50
	public boolean performFinish() {
51
		String urlString = page.getFolderText() + File.separator
52
				+ page.getExportFileName();
53

  
54
		final Combo combo = page.getCombo();
55
		final List<Classification> listClassifications = CdmStore.getCurrentApplicationConfiguration().getClassificationService().listClassifications(null, null, null, null);
56
		if(combo != null){
57
		    int selectionIndex = combo.getSelectionIndex();
58
		    HashSet<UUID> set = new HashSet<UUID>();
59
		    if(selectionIndex == -1){
60
		        for(Classification c:listClassifications){
61
		            set.add(c.getUuid());
62
		        }
63
		    }else{
64
		        for(Classification c:listClassifications){
65
		            if(c.getTitleCache().equalsIgnoreCase(combo.getItem(selectionIndex))){
66
		                set.add(c.getUuid());
67
		            }
68
		        }
69
		        configurator.setClassificationUuids(set);
70
		        configurator.setDoTaxa(true);
71
		        configurator.setHasHeaderLines(true);
72
		        configurator.setClassification(true);
73
		        configurator.setTaxonName(true);
74
		        configurator.setAuthor(true);
75
		        configurator.setRank(true);
76
		        configurator.setLastChange(true);
77
		    }
78
		}
79

  
80
	    // create job
81
	    Job job = CdmStore.getExportManager().createIOServiceJob(configurator, new File(urlString));
82
	    // configure the job
83
	    job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
84
	    job.setUser(true);
85
	    // schedule job
86
	    job.schedule();
87

  
88
		return true;
89
	}
90

  
91
	@Override
92
	public void addPages() {
93
	    //TODO create page with drop down menu for export for single classification.
94
//		super.addPages();
95

  
96

  
97
		//standard page
98
		page =  ExportToFileDestinationWizardPage.Csv(configurator);
99

  
100
		addPage(page);
101
	}
102
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/csv/OpenCsvExportWizard.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.out.csv;
10

  
11
import eu.etaxonomy.taxeditor.io.e4.out.AbstractExportWizardE4;
12
import eu.etaxonomy.taxeditor.io.e4.out.AbstractOpenExportWizard;
13

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

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

  
29
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)