2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.io
.wizard
;
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
;
18 import java
.util
.UUID
;
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
;
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
;
65 * ExportToFileDestinationWizardPage class.
70 public class ExportToFileDestinationWizardPage
extends WizardPage
implements SelectionListener
{
72 /** Constant <code>DATE_FORMAT_NOW="yyyyMMddHHmm"</code> */
73 public static final String DATE_FORMAT_NOW
= "yyyyMMddHHmm";
75 /** Constant <code>JAXB_EXPORT="JAXB_EXPORT"</code> */
76 public static final String JAXB_EXPORT
= "JAXB_EXPORT";
78 /** Constant <code>TCS_EXPORT="TCS_EXPORT"</code> */
79 public static final String TCS_EXPORT
= "TCS_EXPORT";
81 /** Constant <code>SDD_EXPORT="SDD_EXPORT"</code> */
82 public static final String SDD_EXPORT
= "SDD_EXPORT";
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";
95 public static final String CSV
= "csv";
97 public static final String ZIP
= "zip";
99 private boolean csvExport
= false;
101 private boolean csvNameExport
= false;
103 private boolean csvPrintExport
= false;
105 private boolean cdmLightExport
= false;
107 private boolean colDPExport
= false;
108 private boolean dwcaExport
= false;
109 private boolean wfoBackboneExport
= false;
110 private boolean wfoContentExport
= false;
112 private DirectoryDialog folderDialog
;
113 private Text text_exportFileName
;
115 private Text text_folder
;
117 private final String type
;
119 private final String extension
;
121 private Combo classificationSelectionCombo
;
123 private List
<Classification
> classifications
;
125 private Classification selectedClassification
;
127 private ExportConfiguratorBase
<?
, ?
, ?
> configurator
;
128 private Button checkUseSelectedTaxonNode
;
130 private Button checkUseSelectedClassification
;
131 private Button checkUseAllClassification
;
133 private Button checkExportUnpublished
;
134 private Button checkExportFactualData
;
135 private Button checkExportUnpublishedFactualData
;
137 private Combo orderSelectionCombo
;
139 private Text text_familyString
;
141 private Text text_baseUrl
;
143 protected ExportToFileDestinationWizardPage(String pageName
, String type
, String title
, String description
,
144 String extension
, ExportConfiguratorBase
<?
, ?
, ?
> configurator
) {
146 this.configurator
= configurator
;
152 case CSV_NAME_EXPORT
:
153 csvNameExport
= true;
155 case CDM_LIGHT_EXPORT
:
156 cdmLightExport
= true;
161 case CSV_PRINT_EXPORT
:
162 csvPrintExport
= true;
167 case WFO_BACKBONE_EXPORT
:
168 wfoBackboneExport
= true;
170 case WFO_CONTENT_EXPORT
:
171 wfoContentExport
= true;
174 throw new RuntimeException("Export type not yet handeled: " + type
);
176 this.extension
= extension
;
177 this.setTitle(title
);
178 this.setDescription(description
);
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
);
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
);
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
);
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
);
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."
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."
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.",
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.",
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.",
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.",
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.",
243 public void createControl(Composite parent
) {
245 setPageComplete(false);
247 Composite composite
= new Composite(parent
, SWT
.NONE
);
248 GridLayout gridLayout
= new GridLayout();
250 gridLayout
.numColumns
= 2;
251 TaxonNode node
= null;
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
);
267 if (cdmLightExport
|| colDPExport
) {
268 emptyLabel
= new Label(composite
, SWT
.NONE
);
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
);
278 @SuppressWarnings("unused")
279 Label nope
= new Label(composite
, SWT
.NONE
);
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
);
286 if (classifications
== null && !wfoBackboneExport
&& !wfoContentExport
) {
287 classifications
= CdmStore
.getService(IClassificationService
.class).list(null, null, null, null, null);
288 Collections
.sort(classifications
, (o1
, o2
) -> {
292 int result
= o1
.getTitleCache().compareTo(o2
.getTitleCache());
294 return o1
.getUuid().compareTo(o2
.getUuid());
298 if (!configurator
.getTaxonNodeFilter().getClassificationFilter().isEmpty()) {
299 selectedClassification
= CdmStore
.getService(IClassificationService
.class)
300 .load(configurator
.getTaxonNodeFilter().getClassificationFilter().get(0).getUuid());
303 selectedClassification
= classifications
.iterator().next();
307 if (csvExport
|| csvPrintExport
|| cdmLightExport
|| csvNameExport
|| dwcaExport
|| colDPExport
|| wfoBackboneExport
|| wfoContentExport
) {
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();
314 GridData gridDataNode
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false);
315 gridDataNode
.horizontalSpan
= 2;
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
);
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
);
330 if (node
.hasTaxon()) {
331 taxonStr
+= node
.getTaxon().getName().getTitleCache();
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
);
347 checkUseSelectedTaxonNode
.setSelection(true);
349 Composite wfoComp
= new Composite(selectNodeOrClassification
, SWT
.NONE
);
350 grid
= new GridLayout();
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
);
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
);
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);
371 text_familyString
.setLayoutData(gridFamily
);
373 if (!wfoContentExport
) {
374 Label baseUrlString
= new Label(wfoComp
, SWT
.NONE
);
375 baseUrlString
.setText("Base url");
376 text_baseUrl
= new Text(wfoComp
, SWT
.BORDER
);
378 GridData gridDataBaseUrl
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false);
380 text_baseUrl
.setLayoutData(gridDataBaseUrl
);
381 text_baseUrl
.setToolTipText("The base url without /cdm_dataportal/taxon/{uuid} e.g. https://portal.cybertaxonomy.org/salvador");
387 }else if (wfoBackboneExport
|| wfoContentExport
) {
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
));
398 if (cdmLightExport
|| dwcaExport
|| colDPExport
) {
400 checkUseAllClassification
= new Button(selectNodeOrClassification
, SWT
.RADIO
);
401 checkUseAllClassification
.setText("Export all classifications");
402 checkUseAllClassification
.addListener(SWT
.Selection
, new Listener() {
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
);
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
);
423 if (node
!= null && !wfoBackboneExport
) {
424 selectedClassification
= node
.getClassification();
426 if (!(wfoBackboneExport
|| wfoContentExport
)) {
427 createClassificationSelectionCombo(selectNodeOrClassification
);
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
);
436 Composite comp
= new Composite(composite
, SWT
.NONE
);
438 GridData gridData
= new GridData();
439 gridData
= new GridData(GridData
.BEGINNING
, GridData
.CENTER
, true, false);
440 gridData
.horizontalSpan
= 2;
441 comp
.setLayoutData(gridData
);
443 Label label
= new Label(comp
, SWT
.NONE
);
444 label
.setText("Sorting of taxa");
446 orderSelectionCombo
= new Combo(comp
, SWT
.BORDER
| SWT
.READ_ONLY
);
448 GridLayoutFactory
.fillDefaults().applyTo(comp
);
449 for (NavigatorOrderEnum display
: NavigatorOrderEnum
.values()) {
450 orderSelectionCombo
.add(display
.getLabel());
454 if (PreferencesUtil
.getStringValue(PreferencePredicate
.TaxonNodeOrder
.getKey()) != null) {
455 NavigatorOrderEnum orderInNavigator
= NavigatorOrderEnum
456 .valueOf(PreferencesUtil
.getStringValue(PreferencePredicate
.TaxonNodeOrder
.getKey()));
458 for (String itemLabel
: orderSelectionCombo
.getItems()) {
459 if (itemLabel
.equalsIgnoreCase(orderInNavigator
.getLabel())) {
460 orderSelectionCombo
.select(index
);
461 setComparatorToConfig();
468 orderSelectionCombo
.addSelectionListener(new SelectionListener() {
471 public void widgetSelected(SelectionEvent e
) {
472 setComparatorToConfig();
476 public void widgetDefaultSelected(SelectionEvent e
) {
477 // TODO Auto-generated method stub
482 if (classificationSelectionCombo
!= null) {
483 if (checkUseSelectedTaxonNode
!= null) {
484 if (checkUseSelectedTaxonNode
.getSelection()) {
485 classificationSelectionCombo
.setEnabled(false);
488 classificationSelectionCombo
.setEnabled(true);
489 classificationSelectionCombo
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 2, 1));
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
);
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
);
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);
514 Button button
= new Button(composite
, SWT
.PUSH
);
515 button
.setText("Browse...");
517 button
.addSelectionListener(new SelectionAdapter() {
519 public void widgetSelected(SelectionEvent e
) {
520 super.widgetSelected(e
);
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);
530 if (!cdmLightExport
&& !(wfoBackboneExport
|| wfoContentExport
)) {
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));
539 // make the composite the wizard pages control
540 setControl(composite
);
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();
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());
566 ((CdmLightExportConfigurator
) configurator
)
567 .setTaxonNodeComparator(new TaxonNodeDtoByRankAndNameComparator());
571 protected String
generateFilename() {
572 StringBuffer buffer
= new StringBuffer();
574 Calendar cal
= Calendar
.getInstance();
575 SimpleDateFormat sdf
= new SimpleDateFormat(DATE_FORMAT_NOW
);
576 buffer
.append(sdf
.format(cal
.getTime()));
579 buffer
.append(type
+ "_");
581 String source
= ((ICdmRemoteSource
) CdmStore
.getActiveCdmSource()).toString();
582 source
= source
.substring(source
.indexOf("/") + 1);
583 buffer
.append(source
);
586 buffer
.append(extension
);
588 return buffer
.toString();
591 public String
getExportFileName() {
592 return text_exportFileName
.getText();
595 public String
getFamilyString() {
596 return text_familyString
.getText();
599 public String
getFolderText() {
600 return text_folder
.getText();
603 public String
get_baseUrl() {
604 return text_baseUrl
.getText();
607 public Text
getFolderComposite() {
611 public boolean isExportUnpublishedData() {
612 return checkExportUnpublished
.getSelection();
615 public boolean isExportFactualData() {
616 return checkExportFactualData
.getSelection();
619 public boolean isExportUnpublishedFactualData() {
620 return checkExportUnpublishedFactualData
.getSelection();
623 private void createClassificationSelectionCombo(Composite parent
) {
625 GridData gridData
= new GridData();
626 gridData
= new GridData(GridData
.BEGINNING
, GridData
.CENTER
, true, false);
627 gridData
.horizontalIndent
= 5;
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
));
635 classificationSelectionCombo
.select(classifications
.indexOf(selectedClassification
));
637 // TODO remember last selection
638 classificationSelectionCombo
.addSelectionListener(this);
642 public Combo
getCombo() {
643 return classificationSelectionCombo
;
647 public void widgetSelected(SelectionEvent e
) {
648 selectedClassification
= classifications
.get(classificationSelectionCombo
.getSelectionIndex());
651 public Classification
getSelectedClassification() {
652 return selectedClassification
;
656 public void widgetDefaultSelected(SelectionEvent e
) {
660 public UUID
getSelectedClassificationUUID() {
661 return selectedClassification
.getUuid();
664 public boolean getCheckUseSelectedTaxonNode() {
665 if (checkUseSelectedTaxonNode
== null) {
668 return checkUseSelectedTaxonNode
.getSelection();
671 public boolean getCheckUseAllClassifications() {
672 if (checkUseAllClassification
== null) {
675 return checkUseAllClassification
.getSelection();
678 public Set
<UUID
> getAllClassificationUuids() {
679 Set
<UUID
> allClassificationUuids
= new HashSet
<>();
680 for (Classification classification
: this.classifications
) {
681 allClassificationUuids
.add(classification
.getUuid());
683 return allClassificationUuids
;
687 public boolean canFlipToNextPage() {
688 return getFolderText() != null && !(wfoBackboneExport
&& configurator
.getTaxonNodeFilter().getSubtreeFilter().isEmpty());