Revision f3e1e1fa
Added by Katja Luther about 7 years ago
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle.properties | ||
---|---|---|
175 | 175 |
command.name.INSPECT_ACTIVE_SESSIONS = Inspect Active Session |
176 | 176 |
viewCommandMapping.viewerName.CLASSIFICATION_WIZARD = Classification Wizard |
177 | 177 |
viewCommandMapping.viewerName.TAXON_NODE_WIZARD = Taxon node Wizard |
178 |
command.label.CHANGE_PASSWORD = Change password |
|
178 |
command.label.CHANGE_PASSWORD = Change password |
|
179 |
wizard.name.22 = Output Model |
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle_de.properties | ||
---|---|---|
176 | 176 |
command.name.INSPECT_ACTIVE_SESSIONS = Aktive Session untersuchen |
177 | 177 |
viewCommandMapping.viewerName.CLASSIFICATION_WIZARD = Klassifikations-Wizard |
178 | 178 |
viewCommandMapping.viewerName.TAXON_NODE_WIZARD = Taxonknoten-Wizard |
179 |
command.label.CHANGE_PASSWORD = Kennwort ?ndern |
|
179 |
command.label.CHANGE_PASSWORD = Kennwort ?ndern |
|
180 |
wizard.name.22 = Output Model |
eu.etaxonomy.taxeditor.store/plugin.xml | ||
---|---|---|
958 | 958 |
id="eu.etaxonomy.taxeditor.io.export.csv_print" |
959 | 959 |
name="%wizard.name.20"> |
960 | 960 |
</wizard> |
961 |
<wizard |
|
962 |
category="eu.etaxonomy.taxeditor.export.category.cdm" |
|
963 |
class="eu.etaxonomy.taxeditor.io.wizard.OutputModelExportWizard" |
|
964 |
id="eu.etaxonomy.taxeditor.io.export.output_model" |
|
965 |
name="%wizard.name.22"> |
|
966 |
</wizard> |
|
961 | 967 |
</extension> |
962 | 968 |
<extension |
963 | 969 |
point="org.eclipse.ui.newWizards"> |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/ExportManager.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import java.io.File; |
13 | 13 |
import java.io.FileOutputStream; |
14 |
import java.util.Map; |
|
15 |
import java.util.Set; |
|
14 | 16 |
|
15 | 17 |
import org.apache.log4j.Logger; |
16 | 18 |
import org.eclipse.core.runtime.Assert; |
... | ... | |
27 | 29 |
import eu.etaxonomy.cdm.io.common.CdmDefaultExport; |
28 | 30 |
import eu.etaxonomy.cdm.io.common.ExportDataWrapper; |
29 | 31 |
import eu.etaxonomy.cdm.io.common.ExportResult; |
32 |
import eu.etaxonomy.cdm.io.common.ExportResultType; |
|
30 | 33 |
import eu.etaxonomy.cdm.io.common.IExportConfigurator; |
31 | 34 |
import eu.etaxonomy.cdm.io.common.IIoConfigurator; |
32 | 35 |
import eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator; |
36 |
import eu.etaxonomy.cdm.io.outputmodel.OutputModelConfigurator; |
|
33 | 37 |
import eu.etaxonomy.cdm.io.sdd.out.SDDExportConfigurator; |
34 | 38 |
import eu.etaxonomy.cdm.io.service.IIOService; |
35 | 39 |
import eu.etaxonomy.taxeditor.model.CdmProgressMonitorAdapter; |
... | ... | |
182 | 186 |
ExportResult result = ioService.export(configurator); |
183 | 187 |
ExportDataWrapper data = result.getExportData(); |
184 | 188 |
try{ |
185 |
byte[] exportData = (byte[])data.getExportData(); |
|
186 |
if(exportData != null){ |
|
187 |
FileOutputStream stream = new FileOutputStream(exportFile); |
|
188 |
stream.write(exportData); |
|
189 |
stream.close(); |
|
190 |
} |
|
189 |
if (result.getExportData().getType().equals(ExportResultType.BYTE_ARRAY)){ |
|
190 |
byte[] exportData = (byte[])data.getExportData(); |
|
191 |
if(exportData != null){ |
|
192 |
FileOutputStream stream = new FileOutputStream(exportFile); |
|
193 |
stream.write(exportData); |
|
194 |
stream.close(); |
|
195 |
} |
|
196 |
// } else if (result.getExportData().getType().equals(ExportResultType.MAP_BYTE_ARRAY)){ |
|
197 |
// Map<String, byte[]> resultMap = (Map<String, byte[]>)data.getExportData(); |
|
198 |
// Set<String> keySet = resultMap.keySet(); |
|
199 |
// for (String key: keySet){ |
|
200 |
// byte[] fileData = resultMap.get(key); |
|
201 |
// File file = new File(urlString) |
|
202 |
// FileOutputStream stream = new FileOutputStream(key); |
|
203 |
// stream.write(fileData); |
|
204 |
// stream.close(); |
|
205 |
// } |
|
206 |
|
|
207 |
}else{ |
|
208 |
logger.error("This kind of result data is not supported yet." + result.getExportData().getType().toString()); |
|
209 |
} |
|
191 | 210 |
} catch(Exception e){ |
192 | 211 |
logger.error(e.getStackTrace()); |
193 | 212 |
} |
... | ... | |
249 | 268 |
return (SDDExportConfigurator) getConfigurator(TYPE.Sdd); |
250 | 269 |
} |
251 | 270 |
|
271 |
/** |
|
272 |
* @param configurator |
|
273 |
* @param urlString |
|
274 |
* @return |
|
275 |
*/ |
|
276 |
public Job createIOServiceJob(OutputModelConfigurator configurator, String urlString) { |
|
277 |
Assert.isNotNull(configurator, "Configuration may not be null"); |
|
278 |
|
|
279 |
// final Display display = Display.getCurrent(); |
|
280 |
|
|
281 |
Job job = new Job("Export: " + configurator.getClass().getSimpleName()) { //$NON-NLS-1$ |
|
282 |
@Override |
|
283 |
protected IStatus run(IProgressMonitor monitor) { |
|
284 |
monitor.beginTask("Exporting database. This will take some time.", IProgressMonitor.UNKNOWN); |
|
285 |
try { |
|
286 |
IIOService ioService = CdmApplicationState.getIOService(); |
|
287 |
|
|
288 |
ExportResult result = ioService.export(configurator); |
|
289 |
ExportDataWrapper data = result.getExportData(); |
|
290 |
try{ |
|
291 |
if (result.getExportData().getType().equals(ExportResultType.BYTE_ARRAY)){ |
|
292 |
byte[] exportData = (byte[])data.getExportData(); |
|
293 |
if(exportData != null){ |
|
294 |
File file = new File(urlString); |
|
295 |
FileOutputStream stream = new FileOutputStream(file); |
|
296 |
stream.write(exportData); |
|
297 |
stream.close(); |
|
298 |
} |
|
299 |
} else if (result.getExportData().getType().equals(ExportResultType.MAP_BYTE_ARRAY)){ |
|
300 |
Map<String, byte[]> resultMap = (Map<String, byte[]>)data.getExportData(); |
|
301 |
Set<String> keySet = resultMap.keySet(); |
|
302 |
for (String key: keySet){ |
|
303 |
byte[] fileData = resultMap.get(key); |
|
304 |
String fileEnding =""; |
|
305 |
if (configurator instanceof OutputModelConfigurator){ |
|
306 |
fileEnding = ".csv"; |
|
307 |
} |
|
308 |
File file = new File(urlString+File.separator + key + fileEnding); |
|
309 |
FileOutputStream stream = new FileOutputStream(file); |
|
310 |
stream.write(fileData); |
|
311 |
stream.close(); |
|
312 |
} |
|
313 |
|
|
314 |
}else{ |
|
315 |
logger.error("This kind of result data is not supported yet." + result.getExportData().getType().toString()); |
|
316 |
} |
|
317 |
} catch(Exception e){ |
|
318 |
logger.error(e.getStackTrace()); |
|
319 |
} |
|
320 |
|
|
321 |
|
|
322 |
|
|
323 |
|
|
324 |
} catch (Exception e) { |
|
325 |
MessagingUtils.errorDialog("Error exporting data", |
|
326 |
this, |
|
327 |
e.getMessage(), |
|
328 |
TaxeditorStorePlugin.PLUGIN_ID, |
|
329 |
e, |
|
330 |
true); |
|
331 |
} |
|
332 |
return Status.OK_STATUS; |
|
333 |
} |
|
334 |
}; |
|
335 |
return job; |
|
336 |
} |
|
337 |
|
|
252 | 338 |
|
253 | 339 |
|
254 | 340 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java | ||
---|---|---|
61 | 61 |
public static final String SDD_EXPORT = "SDD_EXPORT"; |
62 | 62 |
|
63 | 63 |
public static final String DWCA_EXPORT = "DWCA_EXPORT"; |
64 |
|
|
64 |
public static final String OUTPUT_MODEL_EXPORT = "OUTPUT_MODEL_EXPORT"; |
|
65 | 65 |
public static final String CSV_EXPORT = "CSV_EXPORT"; |
66 | 66 |
public static final String CSV_NAME_EXPORT = "CSV_NAME_EXPORT"; |
67 | 67 |
|
... | ... | |
81 | 81 |
|
82 | 82 |
private static boolean csvPrintExport = false; |
83 | 83 |
|
84 |
private static boolean outputModelExport = false; |
|
85 |
|
|
84 | 86 |
private DirectoryDialog folderDialog; |
85 | 87 |
private Text text_exportFileName; |
86 | 88 |
|
... | ... | |
176 | 178 |
ZIP); |
177 | 179 |
} |
178 | 180 |
|
181 |
/** |
|
182 |
* @return |
|
183 |
*/ |
|
184 |
public static ExportToFileDestinationWizardPage OutputModel() { |
|
185 |
outputModelExport = true; |
|
186 |
return new ExportToFileDestinationWizardPage( |
|
187 |
OUTPUT_MODEL_EXPORT, |
|
188 |
"output model", |
|
189 |
"Output Model Export", |
|
190 |
"Export the contents of the currently selected database into the output model format.", |
|
191 |
CSV); |
|
192 |
} |
|
179 | 193 |
|
180 | 194 |
|
181 | 195 |
/** |
... | ... | |
255 | 269 |
} |
256 | 270 |
|
257 | 271 |
|
258 |
if(csvExport || csvPrintExport){ |
|
272 |
if(csvExport || csvPrintExport || outputModelExport){
|
|
259 | 273 |
Label comboBoxLabel = new Label(composite, SWT.NONE); |
260 | 274 |
comboBoxLabel.setText("Classification"); |
261 | 275 |
|
... | ... | |
263 | 277 |
classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, |
264 | 278 |
true, false, 2, 1)); |
265 | 279 |
} |
266 |
|
|
267 |
|
|
268 |
|
|
269 |
|
|
270 |
Label fileLabel = new Label(composite, SWT.NONE); |
|
271 |
fileLabel.setText("File"); |
|
272 |
|
|
273 |
text_exportFileName = new Text(composite, SWT.BORDER); |
|
274 |
text_exportFileName.setText(generateFilename()); |
|
275 |
text_exportFileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, |
|
276 |
true, false, 2, 1)); |
|
280 |
if (!outputModelExport){ |
|
281 |
Label fileLabel = new Label(composite, SWT.NONE); |
|
282 |
fileLabel.setText("File"); |
|
283 |
text_exportFileName = new Text(composite, SWT.BORDER); |
|
284 |
text_exportFileName.setText(generateFilename()); |
|
285 |
text_exportFileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, |
|
286 |
true, false, 2, 1)); |
|
287 |
} |
|
277 | 288 |
|
278 | 289 |
Label folderLabel = new Label(composite, SWT.NONE); |
279 | 290 |
folderLabel.setText("Folder"); |
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 |
} |
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/session/CdmEntitySessionAwareTest.java | ||
---|---|---|
32 | 32 |
import eu.etaxonomy.cdm.api.service.ITermService; |
33 | 33 |
import eu.etaxonomy.cdm.api.service.IUserService; |
34 | 34 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
35 |
import eu.etaxonomy.cdm.api.service.pager.Pager; |
|
36 | 35 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
37 | 36 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
38 | 37 |
import eu.etaxonomy.cdm.model.agent.Person; |
... | ... | |
175 | 174 |
} |
176 | 175 |
|
177 | 176 |
@Test |
178 |
@Ignore
|
|
177 |
@Ignore |
|
179 | 178 |
public void addGrandChildPolytomousKeyNode() { |
180 | 179 |
|
181 | 180 |
PolytomousKey pKey = CdmBase.deproxy(polytomousKeyService.find(polytomousKeyUuid),PolytomousKey.class); |
... | ... | |
467 | 466 |
} |
468 | 467 |
} |
469 | 468 |
termService.delete(updateTerms); |
470 |
|
|
469 |
|
|
471 | 470 |
// if(termService.findByRepresentationText("UpdateTest", Feature.class, null, null) != null) { |
472 | 471 |
// Pager<Feature> terms = termService.findByRepresentationText("UpdateTest", Feature.class, null, null); |
473 | 472 |
// if (!terms.getRecords().isEmpty()){ |
... | ... | |
487 | 486 |
vocNameFeature.addTerm(newTerm); |
488 | 487 |
|
489 | 488 |
List<MergeResult<TermVocabulary>> mergeResults = vocabularyService.merge(vocs, true); |
490 |
|
|
489 |
|
|
491 | 490 |
for(MergeResult<TermVocabulary> result : mergeResults){ |
492 | 491 |
TermVocabulary voc = result.getMergedEntity(); |
493 | 492 |
if(voc.getUuid().equals(vocNameFeatureUuid)) { |
Also available in: Unified diff
ref #6314: adaption to changes in exports