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.dwca;
|
11
|
|
12
|
import java.io.File;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import javax.inject.Inject;
|
16
|
import javax.inject.Named;
|
17
|
|
18
|
import org.eclipse.e4.core.contexts.IEclipseContext;
|
19
|
import org.eclipse.e4.core.di.annotations.Optional;
|
20
|
import org.eclipse.e4.ui.services.IServiceConstants;
|
21
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
22
|
import org.eclipse.jface.viewers.TreeSelection;
|
23
|
|
24
|
import eu.etaxonomy.cdm.filter.TaxonNodeFilter;
|
25
|
import eu.etaxonomy.cdm.io.dwca.out.DwcaTaxExportConfigurator;
|
26
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
27
|
import eu.etaxonomy.taxeditor.io.e4.out.AbstractExportWizardE4;
|
28
|
import eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage;
|
29
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
30
|
|
31
|
/**
|
32
|
*
|
33
|
* @author pplitzner
|
34
|
* @since Oct 6, 2017
|
35
|
*
|
36
|
*/
|
37
|
public class DarwinCoreArchiveExportWizardE4 extends
|
38
|
AbstractExportWizardE4<DwcaTaxExportConfigurator> {
|
39
|
|
40
|
private DwcaTaxExportConfigurator configurator;
|
41
|
private ExportToFileDestinationWizardPage page;
|
42
|
|
43
|
@Inject
|
44
|
public DarwinCoreArchiveExportWizardE4(IEclipseContext context,
|
45
|
@Optional@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection) {
|
46
|
super(context, selection);
|
47
|
}
|
48
|
|
49
|
@Override
|
50
|
public void init() {
|
51
|
configurator = DwcaTaxExportConfigurator.NewInstance(null, null, null);
|
52
|
if (selection instanceof TreeSelection && !selection.isEmpty()){
|
53
|
TaxonNode node = (TaxonNode)selection.getFirstElement();
|
54
|
if (node.getParent() == null){
|
55
|
configurator.setTaxonNodeFilter(TaxonNodeFilter.NewClassificationInstance(node.getClassification().getUuid()));
|
56
|
}else{
|
57
|
configurator.setTaxonNodeFilter(TaxonNodeFilter.NewSubtreeInstance(node.getUuid()));
|
58
|
}
|
59
|
|
60
|
}
|
61
|
}
|
62
|
|
63
|
@Override
|
64
|
public DwcaTaxExportConfigurator getConfigurator() {
|
65
|
return configurator;
|
66
|
}
|
67
|
|
68
|
@Override
|
69
|
public boolean performFinish() {
|
70
|
String urlString = page.getFolderText() + File.separator
|
71
|
+ page.getExportFileName();
|
72
|
|
73
|
if (!page.getCheckUseSelectedTaxonNode()){
|
74
|
configurator.getTaxonNodeFilter().reset();
|
75
|
if (!page.getCheckUseAllClassifications()){
|
76
|
configurator.getTaxonNodeFilter().orClassification(page.getSelectedClassificationUUID());
|
77
|
}else{
|
78
|
for (UUID classificationUuid: page.getAllClassificationUuids()){
|
79
|
configurator.getTaxonNodeFilter().orClassification(classificationUuid);
|
80
|
}
|
81
|
|
82
|
}
|
83
|
}
|
84
|
|
85
|
|
86
|
CdmStore.getExportManager().runMoniteredOperation(configurator, urlString);
|
87
|
return true;
|
88
|
}
|
89
|
|
90
|
@Override
|
91
|
public void addPages() {
|
92
|
page = ExportToFileDestinationWizardPage.Dwca(configurator);
|
93
|
addPage(page);
|
94
|
super.addPages();
|
95
|
}
|
96
|
}
|