Merge branch 'hotfix/5.45.1'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / io / wizard / ExportToFileDestinationWizardPage.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The content 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.text.SimpleDateFormat;
12 import java.util.ArrayList;
13 import java.util.Calendar;
14 import java.util.Collections;
15 import java.util.HashSet;
16 import java.util.List;
17 import java.util.Set;
18 import java.util.UUID;
19
20 import org.eclipse.jface.layout.GridLayoutFactory;
21 import org.eclipse.jface.wizard.WizardPage;
22 import org.eclipse.swt.SWT;
23 import org.eclipse.swt.events.SelectionAdapter;
24 import org.eclipse.swt.events.SelectionEvent;
25 import org.eclipse.swt.events.SelectionListener;
26 import org.eclipse.swt.layout.GridData;
27 import org.eclipse.swt.layout.GridLayout;
28 import org.eclipse.swt.widgets.Button;
29 import org.eclipse.swt.widgets.Combo;
30 import org.eclipse.swt.widgets.Composite;
31 import org.eclipse.swt.widgets.DirectoryDialog;
32 import org.eclipse.swt.widgets.Display;
33 import org.eclipse.swt.widgets.Event;
34 import org.eclipse.swt.widgets.Label;
35 import org.eclipse.swt.widgets.Listener;
36 import org.eclipse.swt.widgets.Text;
37
38 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
39 import eu.etaxonomy.cdm.api.service.IClassificationService;
40 import eu.etaxonomy.cdm.filter.LogicFilter;
41 import eu.etaxonomy.cdm.io.cdmLight.CdmLightExportConfigurator;
42 import eu.etaxonomy.cdm.io.coldp.ColDpExportConfigurator;
43 import eu.etaxonomy.cdm.io.common.ExportConfiguratorBase;
44 import eu.etaxonomy.cdm.io.csv.caryophyllales.out.CsvNameExportConfigurator;
45 import eu.etaxonomy.cdm.io.csv.redlist.demo.CsvDemoExportConfigurator;
46 import eu.etaxonomy.cdm.io.dwca.out.DwcaTaxExportConfigurator;
47 import eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator;
48 import eu.etaxonomy.cdm.io.sdd.out.SDDExportConfigurator;
49 import eu.etaxonomy.cdm.io.tcsxml.out.TcsXmlExportConfigurator;
50 import eu.etaxonomy.cdm.io.wfo.out.WfoBackboneExportConfigurator;
51 import eu.etaxonomy.cdm.io.wfo.out.WfoContentExportConfigurator;
52 import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
53 import eu.etaxonomy.cdm.model.name.Rank;
54 import eu.etaxonomy.cdm.model.taxon.Classification;
55 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
56 import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByNameComparator;
57 import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByRankAndNameComparator;
58 import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoNaturalComparator;
59 import eu.etaxonomy.taxeditor.preference.NavigatorOrderEnum;
60 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
61 import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource;
62 import eu.etaxonomy.taxeditor.store.CdmStore;
63
64 /**
65 * ExportToFileDestinationWizardPage class.
66 *
67 * @author n.hoffmann
68 * @created 15.06.2009
69 */
70 public class ExportToFileDestinationWizardPage extends WizardPage implements SelectionListener {
71
72 /** Constant <code>DATE_FORMAT_NOW="yyyyMMddHHmm"</code> */
73 public static final String DATE_FORMAT_NOW = "yyyyMMddHHmm";
74
75 /** Constant <code>JAXB_EXPORT="JAXB_EXPORT"</code> */
76 public static final String JAXB_EXPORT = "JAXB_EXPORT";
77
78 /** Constant <code>TCS_EXPORT="TCS_EXPORT"</code> */
79 public static final String TCS_EXPORT = "TCS_EXPORT";
80
81 /** Constant <code>SDD_EXPORT="SDD_EXPORT"</code> */
82 public static final String SDD_EXPORT = "SDD_EXPORT";
83
84 public static final String DWCA_EXPORT = "DWCA_EXPORT";
85 public static final String WFO_BACKBONE_EXPORT = "WFO_BACKBONE_EXPORT";
86 public static final String WFO_CONTENT_EXPORT = "WFO_CONTENT_EXPORT";
87 public static final String CDM_LIGHT_EXPORT = "CDM_LIGHT(CSV)";
88 public static final String COL_DP_EXPORT = "COL DP";
89 public static final String CSV_EXPORT = "CSV_EXPORT";
90 public static final String CSV_NAME_EXPORT = "CSV_NAME_EXPORT";
91 private static final String CSV_PRINT_EXPORT = "CSV_PRINT_EXPORT";
92 private static final String EXPORT_FOLDER = "EXPORT_FOLDER";
93 public static final String XML = "xml";
94
95 public static final String CSV = "csv";
96
97 public static final String ZIP = "zip";
98
99 private boolean csvExport = false;
100
101 private boolean csvNameExport = false;
102
103 private boolean csvPrintExport = false;
104
105 private boolean cdmLightExport = false;
106
107 private boolean colDPExport = false;
108 private boolean dwcaExport = false;
109 private boolean wfoBackboneExport = false;
110 private boolean wfoContentExport = false;
111
112 private DirectoryDialog folderDialog;
113 private Text text_exportFileName;
114
115 private Text text_folder;
116
117 private final String type;
118
119 private final String extension;
120
121 private Combo classificationSelectionCombo;
122
123 private List<Classification> classifications;
124
125 private Classification selectedClassification;
126
127 private ExportConfiguratorBase<?, ?, ?> configurator;
128 private Button checkUseSelectedTaxonNode;
129
130 private Button checkUseSelectedClassification;
131 private Button checkUseAllClassification;
132
133 private Button checkExportUnpublished;
134 private Button checkExportFactualData;
135 private Button checkExportUnpublishedFactualData;
136
137 private Combo orderSelectionCombo;
138
139 private Text text_familyString;
140
141 private Text text_baseUrl;
142
143 protected ExportToFileDestinationWizardPage(String pageName, String type, String title, String description,
144 String extension, ExportConfiguratorBase<?, ?, ?> configurator) {
145 super(pageName);
146 this.configurator = configurator;
147 this.type = type;
148 switch (type) {
149 case CSV_EXPORT:
150 csvExport = true;
151 break;
152 case CSV_NAME_EXPORT:
153 csvNameExport = true;
154 break;
155 case CDM_LIGHT_EXPORT:
156 cdmLightExport = true;
157 break;
158 case COL_DP_EXPORT:
159 colDPExport = true;
160 break;
161 case CSV_PRINT_EXPORT:
162 csvPrintExport = true;
163 break;
164 case DWCA_EXPORT:
165 dwcaExport = true;
166 break;
167 case WFO_BACKBONE_EXPORT:
168 wfoBackboneExport = true;
169 break;
170 case WFO_CONTENT_EXPORT:
171 wfoContentExport = true;
172 break;
173 default:
174 throw new RuntimeException("Export type not yet handeled: " + type);
175 }
176 this.extension = extension;
177 this.setTitle(title);
178 this.setDescription(description);
179 }
180
181 public static ExportToFileDestinationWizardPage Jaxb(JaxbExportConfigurator configurator) {
182 return new ExportToFileDestinationWizardPage(JAXB_EXPORT, "jaxb", "JAXB Export",
183 "Exports the content of the currently selected database into the cdm jaxb format.", XML, configurator);
184 }
185
186 public static ExportToFileDestinationWizardPage Tcs(TcsXmlExportConfigurator config) {
187 return new ExportToFileDestinationWizardPage(TCS_EXPORT, "tcs", "Tcs Export",
188 "Export the content of the currently selected database into TCS format.", XML, config);
189 }
190
191 public static ExportToFileDestinationWizardPage Sdd(SDDExportConfigurator config) {
192 return new ExportToFileDestinationWizardPage(SDD_EXPORT, "sdd", "Sdd Export",
193 "Export the content of the currently selected database into SDD format.", XML, config);
194 }
195
196 public static ExportToFileDestinationWizardPage Dwca(DwcaTaxExportConfigurator config) {
197 return new ExportToFileDestinationWizardPage(DWCA_EXPORT, DWCA_EXPORT, "DwC-Archive Export",
198 "Export the content of the currently selected database into Darwin Core Archive format.", ZIP, config);
199 }
200
201 public static ExportToFileDestinationWizardPage WFO(WfoBackboneExportConfigurator config) {
202 return new ExportToFileDestinationWizardPage(WFO_BACKBONE_EXPORT, WFO_BACKBONE_EXPORT, "WFO Backbone Export",
203 "Export the content of the currently selected database into WFO Backbone format."
204 , CSV, config);
205 }
206 public static ExportToFileDestinationWizardPage WFO_Content(WfoContentExportConfigurator config) {
207 return new ExportToFileDestinationWizardPage(WFO_CONTENT_EXPORT, WFO_CONTENT_EXPORT, "WFO Content Export",
208 "Export the content of the currently selected database into WFO Content format."
209 , CSV, config);
210 }
211
212 public static ExportToFileDestinationWizardPage CdmLight(CdmLightExportConfigurator config) {
213 return new ExportToFileDestinationWizardPage(CDM_LIGHT_EXPORT, CDM_LIGHT_EXPORT, "CDM Light Export (csv)",
214 "Export the content of the currently selected database into the CDM light (csv) format.",
215 CSV, config);
216 }
217
218 public static ExportToFileDestinationWizardPage ColDp(ColDpExportConfigurator config) {
219 return new ExportToFileDestinationWizardPage(COL_DP_EXPORT, COL_DP_EXPORT, "Col DP Export (zip)",
220 "Export the content of the currently selected database into the Catalogue of Life Data Package (Col DP) format.",
221 ZIP, config);
222 }
223
224 public static ExportToFileDestinationWizardPage Csv(CsvDemoExportConfigurator config) {
225 return new ExportToFileDestinationWizardPage(CSV_EXPORT, CSV_EXPORT, "CSV Export",
226 "Export the content of the currently selected database into Comma Separated Value format.",
227 CSV, config);
228 }
229
230 public static ExportToFileDestinationWizardPage CsvNames(CsvNameExportConfigurator config) {
231 return new ExportToFileDestinationWizardPage(CSV_NAME_EXPORT, CSV_NAME_EXPORT, "CSV Name Export",
232 "Export the names of the currently selected database into Semicolon Separated Value format.",
233 CSV, config);
234 }
235
236 public static ExportToFileDestinationWizardPage CsvPrint(CsvNameExportConfigurator config) {
237 return new ExportToFileDestinationWizardPage(CSV_PRINT_EXPORT, CSV_NAME_EXPORT, "CSV Print Export",
238 "Export the content of the currently selected database into Semicolon Separated Value format.",
239 CSV, config);
240 }
241
242 @Override
243 public void createControl(Composite parent) {
244
245 setPageComplete(false);
246
247 Composite composite = new Composite(parent, SWT.NONE);
248 GridLayout gridLayout = new GridLayout();
249
250 gridLayout.numColumns = 2;
251 TaxonNode node = null;
252
253 composite.setLayout(gridLayout);
254 if (cdmLightExport || dwcaExport || colDPExport) {
255 checkExportUnpublished = new Button(composite, SWT.CHECK);
256 checkExportUnpublished.setText("Export unpublished taxa");
257 Label emptyLabel = new Label(composite, SWT.NONE);
258 checkExportFactualData = new Button(composite, SWT.CHECK);
259 checkExportFactualData.setText("Export factual data");
260 checkExportFactualData.setSelection(true);
261 checkExportFactualData.addListener(SWT.Selection, e -> {
262 Button b = (Button) e.widget;
263 GridData data = (GridData) checkExportUnpublishedFactualData.getLayoutData();
264 data.exclude = b.getSelection();
265 checkExportUnpublishedFactualData.setEnabled(data.exclude);
266 });
267 if (cdmLightExport || colDPExport) {
268 emptyLabel = new Label(composite, SWT.NONE);
269
270 checkExportUnpublishedFactualData = new Button(composite, SWT.CHECK);
271 checkExportUnpublishedFactualData.setText("Export unpublished factual data");
272 checkExportUnpublishedFactualData.setSelection(false);
273 GridData gridData = new GridData();
274 gridData.horizontalIndent = 20;
275 checkExportUnpublishedFactualData.setLayoutData(gridData);
276 }
277
278 @SuppressWarnings("unused")
279 Label nope = new Label(composite, SWT.NONE);
280
281 Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
282 GridData gridDataSep = new GridData(GridData.FILL_HORIZONTAL);
283 gridDataSep.horizontalSpan = 2;
284 separator.setLayoutData(gridDataSep);
285 }
286 if (classifications == null && !wfoBackboneExport && !wfoContentExport) {
287 classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null);
288 Collections.sort(classifications, (o1, o2) -> {
289 if (o1.equals(o2)) {
290 return 0;
291 }
292 int result = o1.getTitleCache().compareTo(o2.getTitleCache());
293 if (result == 0) {
294 return o1.getUuid().compareTo(o2.getUuid());
295 }
296 return result;
297 });
298 if (!configurator.getTaxonNodeFilter().getClassificationFilter().isEmpty()) {
299 selectedClassification = CdmStore.getService(IClassificationService.class)
300 .load(configurator.getTaxonNodeFilter().getClassificationFilter().get(0).getUuid());
301 } else {
302
303 selectedClassification = classifications.iterator().next();
304 }
305 }
306
307 if (csvExport || csvPrintExport || cdmLightExport || csvNameExport || dwcaExport || colDPExport || wfoBackboneExport || wfoContentExport) {
308
309 // Label comboBoxLabel = new Label(composite, SWT.NONE);
310 // comboBoxLabel.setText("Classification");
311 Composite selectNodeOrClassification = new Composite(composite, SWT.NONE);
312 GridLayout grid = new GridLayout();
313 grid.numColumns = 1;
314 GridData gridDataNode = new GridData(SWT.FILL, SWT.FILL, true, false);
315 gridDataNode.horizontalSpan = 2;
316
317 selectNodeOrClassification.setLayout(grid);
318 selectNodeOrClassification.setLayoutData(gridDataNode);
319 if ((cdmLightExport || dwcaExport || colDPExport || wfoBackboneExport || wfoContentExport) && !configurator.getTaxonNodeFilter().getSubtreeFilter().isEmpty()) {
320 if (!(wfoBackboneExport || wfoContentExport)) {
321 checkUseSelectedTaxonNode = new Button(selectNodeOrClassification, SWT.RADIO);
322 }
323 String taxonStr = "";
324 int count = configurator.getTaxonNodeFilter().getSubtreeFilter().size();
325 List<TaxonNode> selectedNodes = new ArrayList<>();
326 for (LogicFilter<TaxonNode> filter : configurator.getTaxonNodeFilter().getSubtreeFilter()) {
327 node = CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().load(filter.getUuid());
328 selectedNodes.add(node);
329 count--;
330 if (node.hasTaxon()) {
331 taxonStr += node.getTaxon().getName().getTitleCache();
332 if (count > 0) {
333 taxonStr += ", ";
334 }
335 }
336 }
337 if (!wfoBackboneExport && !wfoContentExport) {
338 checkUseSelectedTaxonNode.setText("Export all selected subtree(s) (" + taxonStr + ")");
339 checkUseSelectedTaxonNode.addListener(SWT.Selection, e -> {
340 Button b = (Button) e.widget;
341 GridData data = (GridData) classificationSelectionCombo.getLayoutData();
342 data.exclude = b.getSelection();
343 if (classificationSelectionCombo != null) {
344 classificationSelectionCombo.setEnabled(!data.exclude);
345 }
346 });
347 checkUseSelectedTaxonNode.setSelection(true);
348 }else {
349 Composite wfoComp = new Composite(selectNodeOrClassification, SWT.NONE);
350 grid = new GridLayout();
351 grid.numColumns = 2;
352 GridData gridDataWfo = new GridData(SWT.FILL, SWT.FILL, true, false);
353 gridDataWfo.grabExcessHorizontalSpace=true;
354 // gridDataWfo.horizontalSpan=2;
355 wfoComp.setLayout(grid);
356 wfoComp.setLayoutData(gridDataWfo);
357
358 Label label = new Label(wfoComp, SWT.NONE);
359 label.setText("Export all selected subtree(s) (" + taxonStr + ")");
360 GridData gridData = new GridData();
361 gridData.horizontalSpan = 3;
362 gridData.grabExcessHorizontalSpace = true;
363 label.setLayoutData(gridData);
364
365 Label familyString = new Label(wfoComp, SWT.NONE);
366 familyString.setText("Family");
367 text_familyString = new Text(wfoComp, SWT.BORDER);
368 text_familyString.setText(generateFamilyName(selectedNodes));
369 GridData gridFamily = new GridData(SWT.FILL, SWT.FILL, true, false);
370
371 text_familyString.setLayoutData(gridFamily);
372
373 if (!wfoContentExport) {
374 Label baseUrlString = new Label(wfoComp, SWT.NONE);
375 baseUrlString.setText("Base url");
376 text_baseUrl = new Text(wfoComp, SWT.BORDER);
377
378 GridData gridDataBaseUrl = new GridData(SWT.FILL, SWT.FILL, true, false);
379
380 text_baseUrl.setLayoutData(gridDataBaseUrl);
381 text_baseUrl.setToolTipText("The base url without /cdm_dataportal/taxon/{uuid} e.g. https://portal.cybertaxonomy.org/salvador");
382 }
383
384
385
386 }
387 }else if (wfoBackboneExport || wfoContentExport) {
388
389 Label label = new Label(composite, SWT.NONE);
390 label.setText("WFO Backbone export is only available for subtrees, not for classifications");
391 GridData gridData = new GridData();
392 gridData.horizontalSpan = 2;
393 gridData.grabExcessHorizontalSpace = true;
394 label.setLayoutData(gridData);
395 label.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
396 }
397
398 if (cdmLightExport || dwcaExport || colDPExport ) {
399 if (dwcaExport) {
400 checkUseAllClassification = new Button(selectNodeOrClassification, SWT.RADIO);
401 checkUseAllClassification.setText("Export all classifications");
402 checkUseAllClassification.addListener(SWT.Selection, new Listener() {
403 @Override
404 public void handleEvent(Event e) {
405 Button b = (Button) e.widget;
406 GridData data = (GridData) classificationSelectionCombo.getLayoutData();
407 data.exclude = b.getSelection();
408 classificationSelectionCombo.setEnabled(!data.exclude);
409
410 }
411 });
412 }
413 checkUseSelectedClassification = new Button(selectNodeOrClassification, SWT.RADIO);
414 checkUseSelectedClassification.setText("Export selected classification");
415 checkUseSelectedClassification.addListener(SWT.Selection, e -> {
416 Button b = (Button) e.widget;
417 GridData data = (GridData) classificationSelectionCombo.getLayoutData();
418 data.exclude = b.getSelection();
419 classificationSelectionCombo.setEnabled(data.exclude);
420 });
421 }
422
423 if (node != null && !wfoBackboneExport) {
424 selectedClassification = node.getClassification();
425 }
426 if (!(wfoBackboneExport || wfoContentExport)) {
427 createClassificationSelectionCombo(selectNodeOrClassification);
428 }
429 if (cdmLightExport) {
430 Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
431 GridData gridDataSep = new GridData();
432 gridDataSep = new GridData(GridData.BEGINNING, GridData.CENTER, true, true);
433 gridDataSep.horizontalSpan = 2;
434 separator.setLayoutData(gridDataSep);
435
436 Composite comp = new Composite(composite, SWT.NONE);
437
438 GridData gridData = new GridData();
439 gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
440 gridData.horizontalSpan = 2;
441 comp.setLayoutData(gridData);
442
443 Label label = new Label(comp, SWT.NONE);
444 label.setText("Sorting of taxa");
445
446 orderSelectionCombo = new Combo(comp, SWT.BORDER | SWT.READ_ONLY);
447
448 GridLayoutFactory.fillDefaults().applyTo(comp);
449 for (NavigatorOrderEnum display : NavigatorOrderEnum.values()) {
450 orderSelectionCombo.add(display.getLabel());
451 }
452
453 int index = 0;
454 if (PreferencesUtil.getStringValue(PreferencePredicate.TaxonNodeOrder.getKey()) != null) {
455 NavigatorOrderEnum orderInNavigator = NavigatorOrderEnum
456 .valueOf(PreferencesUtil.getStringValue(PreferencePredicate.TaxonNodeOrder.getKey()));
457
458 for (String itemLabel : orderSelectionCombo.getItems()) {
459 if (itemLabel.equalsIgnoreCase(orderInNavigator.getLabel())) {
460 orderSelectionCombo.select(index);
461 setComparatorToConfig();
462 break;
463 }
464 index++;
465 }
466 }
467
468 orderSelectionCombo.addSelectionListener(new SelectionListener() {
469
470 @Override
471 public void widgetSelected(SelectionEvent e) {
472 setComparatorToConfig();
473 }
474
475 @Override
476 public void widgetDefaultSelected(SelectionEvent e) {
477 // TODO Auto-generated method stub
478 }
479 });
480 }
481
482 if (classificationSelectionCombo != null) {
483 if (checkUseSelectedTaxonNode != null) {
484 if (checkUseSelectedTaxonNode.getSelection()) {
485 classificationSelectionCombo.setEnabled(false);
486 }
487 } else {
488 classificationSelectionCombo.setEnabled(true);
489 classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
490 }
491 }
492 Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
493 GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
494 gridData.horizontalSpan = 2;
495 separator.setLayoutData(gridData);
496
497 }
498
499 Label folderLabel = new Label(composite, SWT.NONE);
500 folderLabel.setText("Select Folder for exported files");
501 folderLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
502 folderDialog = new DirectoryDialog(parent.getShell());
503 String exportFolder = PreferencesUtil.getStringValue(EXPORT_FOLDER, true);
504 folderDialog.setFilterPath(exportFolder);
505
506 text_folder = new Text(composite, SWT.BORDER);
507 text_folder.setEditable(false);
508 text_folder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
509 if (exportFolder != null) {
510 text_folder.setText(exportFolder);
511 setPageComplete(true);
512 }
513
514 Button button = new Button(composite, SWT.PUSH);
515 button.setText("Browse...");
516
517 button.addSelectionListener(new SelectionAdapter() {
518 @Override
519 public void widgetSelected(SelectionEvent e) {
520 super.widgetSelected(e);
521
522 String path = folderDialog.open();
523 if (path != null) { // a folder was selected
524 text_folder.setText(path);
525 PreferencesUtil.setStringValue(EXPORT_FOLDER, path);
526 setPageComplete(true);
527 }
528 }
529 });
530 if (!cdmLightExport && !(wfoBackboneExport || wfoContentExport)) {
531
532 Label fileLabel = new Label(composite, SWT.NONE);
533 fileLabel.setText("Filename");
534 text_exportFileName = new Text(composite, SWT.BORDER);
535 text_exportFileName.setText(generateFilename());
536 text_exportFileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
537 }
538
539 // make the composite the wizard pages control
540 setControl(composite);
541 }
542
543 private String generateFamilyName(List<TaxonNode> nodes) {
544 if (nodes.size() == 1){
545 TaxonNode node = nodes.get(0);
546 if (node.getNullSafeRank() != null) {
547 if(node.getTaxon().getName().getRank().getOrderIndex() >= Rank.FAMILY().getOrderIndex()) {
548 TaxonNode familyNode = node.getAncestorOfRank(Rank.FAMILY());
549 if (familyNode != null && familyNode.getTaxon() != null && familyNode.getTaxon().getName() != null) {
550 return familyNode.getTaxon().getName().getNameCache();
551 }
552
553 }
554 }
555
556 }
557 return "";
558 }
559
560 protected void setComparatorToConfig() {
561 if (orderSelectionCombo.getText().equals(NavigatorOrderEnum.NaturalOrder.getLabel())) {
562 ((CdmLightExportConfigurator) configurator).setTaxonNodeComparator(new TaxonNodeDtoNaturalComparator());
563 } else if (orderSelectionCombo.getText().equals(NavigatorOrderEnum.AlphabeticalOrder.getLabel())) {
564 ((CdmLightExportConfigurator) configurator).setTaxonNodeComparator(new TaxonNodeDtoByNameComparator());
565 } else {
566 ((CdmLightExportConfigurator) configurator)
567 .setTaxonNodeComparator(new TaxonNodeDtoByRankAndNameComparator());
568 }
569 }
570
571 protected String generateFilename() {
572 StringBuffer buffer = new StringBuffer();
573
574 Calendar cal = Calendar.getInstance();
575 SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
576 buffer.append(sdf.format(cal.getTime()));
577
578 buffer.append("-");
579 buffer.append(type + "_");
580
581 String source = ((ICdmRemoteSource) CdmStore.getActiveCdmSource()).toString();
582 source = source.substring(source.indexOf("/") + 1);
583 buffer.append(source);
584
585 buffer.append(".");
586 buffer.append(extension);
587
588 return buffer.toString();
589 }
590
591 public String getExportFileName() {
592 return text_exportFileName.getText();
593 }
594
595 public String getFamilyString() {
596 return text_familyString.getText();
597 }
598
599 public String getFolderText() {
600 return text_folder.getText();
601 }
602
603 public String get_baseUrl() {
604 return text_baseUrl.getText();
605 }
606
607 public Text getFolderComposite() {
608 return text_folder;
609 }
610
611 public boolean isExportUnpublishedData() {
612 return checkExportUnpublished.getSelection();
613 }
614
615 public boolean isExportFactualData() {
616 return checkExportFactualData.getSelection();
617 }
618
619 public boolean isExportUnpublishedFactualData() {
620 return checkExportUnpublishedFactualData.getSelection();
621 }
622
623 private void createClassificationSelectionCombo(Composite parent) {
624
625 GridData gridData = new GridData();
626 gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
627 gridData.horizontalIndent = 5;
628
629 classificationSelectionCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
630 classificationSelectionCombo.setLayoutData(gridData);
631 for (Classification tree : classifications) {
632 classificationSelectionCombo.add(tree.getTitleCache(), classifications.indexOf(tree));
633 }
634
635 classificationSelectionCombo.select(classifications.indexOf(selectedClassification));
636
637 // TODO remember last selection
638 classificationSelectionCombo.addSelectionListener(this);
639
640 }
641
642 public Combo getCombo() {
643 return classificationSelectionCombo;
644 }
645
646 @Override
647 public void widgetSelected(SelectionEvent e) {
648 selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex());
649 }
650
651 public Classification getSelectedClassification() {
652 return selectedClassification;
653 }
654
655 @Override
656 public void widgetDefaultSelected(SelectionEvent e) {
657 // not needed here
658 }
659
660 public UUID getSelectedClassificationUUID() {
661 return selectedClassification.getUuid();
662 }
663
664 public boolean getCheckUseSelectedTaxonNode() {
665 if (checkUseSelectedTaxonNode == null) {
666 return false;
667 }
668 return checkUseSelectedTaxonNode.getSelection();
669 }
670
671 public boolean getCheckUseAllClassifications() {
672 if (checkUseAllClassification == null) {
673 return false;
674 }
675 return checkUseAllClassification.getSelection();
676 }
677
678 public Set<UUID> getAllClassificationUuids() {
679 Set<UUID> allClassificationUuids = new HashSet<>();
680 for (Classification classification : this.classifications) {
681 allClassificationUuids.add(classification.getUuid());
682 }
683 return allClassificationUuids;
684 }
685
686 @Override
687 public boolean canFlipToNextPage() {
688 return getFolderText() != null && !(wfoBackboneExport && configurator.getTaxonNodeFilter().getSubtreeFilter().isEmpty());
689 }
690 }