Revision f6b1d0ad
Added by Katja Luther almost 7 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/ExportManager.java | ||
---|---|---|
45 | 45 |
import eu.etaxonomy.cdm.io.common.IIoConfigurator; |
46 | 46 |
|
47 | 47 |
import eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator; |
48 |
import eu.etaxonomy.cdm.io.outputmodel.OutputModelConfigurator;
|
|
48 |
import eu.etaxonomy.cdm.io.cdmLight.CdmLightExportConfigurator;
|
|
49 | 49 |
import eu.etaxonomy.cdm.io.sdd.out.SDDExportConfigurator; |
50 | 50 |
import eu.etaxonomy.cdm.io.service.IIOService; |
51 | 51 |
import eu.etaxonomy.taxeditor.model.CdmProgressMonitorAdapter; |
... | ... | |
286 | 286 |
* @param urlString |
287 | 287 |
* @return |
288 | 288 |
*/ |
289 |
public Job createIOServiceJob(OutputModelConfigurator configurator, String urlString) {
|
|
289 |
public Job createIOServiceJob(CdmLightExportConfigurator configurator, String urlString) {
|
|
290 | 290 |
Assert.isNotNull(configurator, "Configuration may not be null"); |
291 | 291 |
final Display display = Display.getDefault(); |
292 | 292 |
|
... | ... | |
325 | 325 |
for (String key: keySet){ |
326 | 326 |
byte[] fileData = resultMap.get(key); |
327 | 327 |
String fileEnding =""; |
328 |
if (configurator instanceof OutputModelConfigurator){
|
|
328 |
if (configurator instanceof CdmLightExportConfigurator){
|
|
329 | 329 |
fileEnding = ".csv"; |
330 | 330 |
} |
331 | 331 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/CdmLightExportWizard.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.wizard; |
|
10 |
|
|
11 |
import java.io.File; |
|
12 |
import java.util.HashSet; |
|
13 |
import java.util.List; |
|
14 |
import java.util.UUID; |
|
15 |
|
|
16 |
import org.eclipse.core.runtime.jobs.Job; |
|
17 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
18 |
import org.eclipse.swt.widgets.Combo; |
|
19 |
import org.eclipse.ui.IWorkbench; |
|
20 |
import org.eclipse.ui.progress.IProgressConstants; |
|
21 |
|
|
22 |
import eu.etaxonomy.cdm.io.cdmLight.CdmLightExportConfigurator; |
|
23 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
|
24 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
25 |
|
|
26 |
/** |
|
27 |
* @author k.luther |
|
28 |
* @date 21.03.2017 |
|
29 |
* |
|
30 |
*/ |
|
31 |
public class CdmLightExportWizard extends |
|
32 |
AbstractExportWizard<CdmLightExportConfigurator> { |
|
33 |
|
|
34 |
private CdmLightExportConfigurator 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 |
* (non-Javadoc) |
|
40 |
* |
|
41 |
* @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, |
|
42 |
* org.eclipse.jface.viewers.IStructuredSelection) |
|
43 |
*/ |
|
44 |
@Override |
|
45 |
public void init(IWorkbench workbench, IStructuredSelection selection) { |
|
46 |
configurator = new CdmLightExportConfigurator(null); |
|
47 |
} |
|
48 |
|
|
49 |
/* |
|
50 |
* (non-Javadoc) |
|
51 |
* |
|
52 |
* @see |
|
53 |
* eu.etaxonomy.taxeditor.io.wizard.AbstractExportWizard#getConfigurator() |
|
54 |
*/ |
|
55 |
@Override |
|
56 |
public CdmLightExportConfigurator getConfigurator() { |
|
57 |
return configurator; |
|
58 |
} |
|
59 |
|
|
60 |
/* |
|
61 |
* (non-Javadoc) |
|
62 |
* |
|
63 |
* @see org.eclipse.jface.wizard.Wizard#performFinish() |
|
64 |
*/ |
|
65 |
@Override |
|
66 |
public boolean performFinish() { |
|
67 |
String urlString = page.getFolderText() + File.separator; |
|
68 |
//+ page.getExportFileName(); |
|
69 |
|
|
70 |
final Combo combo = page.getCombo(); |
|
71 |
final List<Classification> listClassifications = CdmStore.getCurrentApplicationConfiguration().getClassificationService().listClassifications(null, null, null, null); |
|
72 |
if(combo != null){ |
|
73 |
int selectionIndex = combo.getSelectionIndex(); |
|
74 |
HashSet<UUID> set = new HashSet<UUID>(); |
|
75 |
if(selectionIndex == -1){ |
|
76 |
for(Classification c:listClassifications){ |
|
77 |
set.add(c.getUuid()); |
|
78 |
} |
|
79 |
}else{ |
|
80 |
for(Classification c:listClassifications){ |
|
81 |
if(c.getTitleCache().equalsIgnoreCase(combo.getItem(selectionIndex))){ |
|
82 |
set.add(c.getUuid()); |
|
83 |
} |
|
84 |
} |
|
85 |
configurator.setClassificationUuids(set); |
|
86 |
|
|
87 |
} |
|
88 |
} |
|
89 |
|
|
90 |
// create job |
|
91 |
Job job = CdmStore.getExportManager().createIOServiceJob(configurator, urlString); |
|
92 |
// configure the job |
|
93 |
job.setProperty(IProgressConstants.KEEP_PROPERTY, true); |
|
94 |
job.setUser(true); |
|
95 |
// schedule job |
|
96 |
job.schedule(); |
|
97 |
|
|
98 |
return true; |
|
99 |
} |
|
100 |
|
|
101 |
/* |
|
102 |
* (non-Javadoc) |
|
103 |
* |
|
104 |
* @see eu.etaxonomy.taxeditor.io.wizard.AbstractExportWizard#addPages() |
|
105 |
*/ |
|
106 |
@Override |
|
107 |
public void addPages() { |
|
108 |
//TODO create page with drop down menu for export for single classification. |
|
109 |
// super.addPages(); |
|
110 |
|
|
111 |
|
|
112 |
//standard page |
|
113 |
page = ExportToFileDestinationWizardPage.OutputModel(); |
|
114 |
|
|
115 |
addPage(page); |
|
116 |
} |
|
117 |
|
|
118 |
|
|
119 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/OutputModelExportWizard.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.wizard; |
|
10 |
|
|
11 |
import java.io.File; |
|
12 |
import java.util.HashSet; |
|
13 |
import java.util.List; |
|
14 |
import java.util.UUID; |
|
15 |
|
|
16 |
import org.eclipse.core.runtime.jobs.Job; |
|
17 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
18 |
import org.eclipse.swt.widgets.Combo; |
|
19 |
import org.eclipse.ui.IWorkbench; |
|
20 |
import org.eclipse.ui.progress.IProgressConstants; |
|
21 |
|
|
22 |
import eu.etaxonomy.cdm.io.outputmodel.OutputModelConfigurator; |
|
23 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
|
24 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
25 |
|
|
26 |
/** |
|
27 |
* @author k.luther |
|
28 |
* @date 21.03.2017 |
|
29 |
* |
|
30 |
*/ |
|
31 |
public class OutputModelExportWizard extends |
|
32 |
AbstractExportWizard<OutputModelConfigurator> { |
|
33 |
|
|
34 |
private OutputModelConfigurator 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 |
* (non-Javadoc) |
|
40 |
* |
|
41 |
* @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, |
|
42 |
* org.eclipse.jface.viewers.IStructuredSelection) |
|
43 |
*/ |
|
44 |
@Override |
|
45 |
public void init(IWorkbench workbench, IStructuredSelection selection) { |
|
46 |
configurator = new OutputModelConfigurator(null); |
|
47 |
} |
|
48 |
|
|
49 |
/* |
|
50 |
* (non-Javadoc) |
|
51 |
* |
|
52 |
* @see |
|
53 |
* eu.etaxonomy.taxeditor.io.wizard.AbstractExportWizard#getConfigurator() |
|
54 |
*/ |
|
55 |
@Override |
|
56 |
public OutputModelConfigurator getConfigurator() { |
|
57 |
return configurator; |
|
58 |
} |
|
59 |
|
|
60 |
/* |
|
61 |
* (non-Javadoc) |
|
62 |
* |
|
63 |
* @see org.eclipse.jface.wizard.Wizard#performFinish() |
|
64 |
*/ |
|
65 |
@Override |
|
66 |
public boolean performFinish() { |
|
67 |
String urlString = page.getFolderText() + File.separator; |
|
68 |
//+ page.getExportFileName(); |
|
69 |
|
|
70 |
final Combo combo = page.getCombo(); |
|
71 |
final List<Classification> listClassifications = CdmStore.getCurrentApplicationConfiguration().getClassificationService().listClassifications(null, null, null, null); |
|
72 |
if(combo != null){ |
|
73 |
int selectionIndex = combo.getSelectionIndex(); |
|
74 |
HashSet<UUID> set = new HashSet<UUID>(); |
|
75 |
if(selectionIndex == -1){ |
|
76 |
for(Classification c:listClassifications){ |
|
77 |
set.add(c.getUuid()); |
|
78 |
} |
|
79 |
}else{ |
|
80 |
for(Classification c:listClassifications){ |
|
81 |
if(c.getTitleCache().equalsIgnoreCase(combo.getItem(selectionIndex))){ |
|
82 |
set.add(c.getUuid()); |
|
83 |
} |
|
84 |
} |
|
85 |
configurator.setClassificationUuids(set); |
|
86 |
|
|
87 |
} |
|
88 |
} |
|
89 |
|
|
90 |
// create job |
|
91 |
Job job = CdmStore.getExportManager().createIOServiceJob(configurator, urlString); |
|
92 |
// configure the job |
|
93 |
job.setProperty(IProgressConstants.KEEP_PROPERTY, true); |
|
94 |
job.setUser(true); |
|
95 |
// schedule job |
|
96 |
job.schedule(); |
|
97 |
|
|
98 |
return true; |
|
99 |
} |
|
100 |
|
|
101 |
/* |
|
102 |
* (non-Javadoc) |
|
103 |
* |
|
104 |
* @see eu.etaxonomy.taxeditor.io.wizard.AbstractExportWizard#addPages() |
|
105 |
*/ |
|
106 |
@Override |
|
107 |
public void addPages() { |
|
108 |
//TODO create page with drop down menu for export for single classification. |
|
109 |
// super.addPages(); |
|
110 |
|
|
111 |
|
|
112 |
//standard page |
|
113 |
page = ExportToFileDestinationWizardPage.OutputModel(); |
|
114 |
|
|
115 |
addPage(page); |
|
116 |
} |
|
117 |
|
|
118 |
|
|
119 |
} |
Also available in: Unified diff
rename outputmodel -> cdmLight