Project

General

Profile

Download (25.3 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2019 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.ui.dialog.configurator;
10

    
11
import java.util.ArrayList;
12
import java.util.Arrays;
13
import java.util.Collections;
14
import java.util.Comparator;
15
import java.util.EnumSet;
16
import java.util.HashMap;
17
import java.util.List;
18
import java.util.Map;
19

    
20
import org.apache.commons.lang.StringUtils;
21
import org.eclipse.jface.layout.GridLayoutFactory;
22
import org.eclipse.jface.viewers.ArrayContentProvider;
23
import org.eclipse.jface.viewers.CheckStateChangedEvent;
24
import org.eclipse.jface.viewers.CheckboxTableViewer;
25
import org.eclipse.jface.viewers.ICheckStateListener;
26
import org.eclipse.jface.viewers.LabelProvider;
27
import org.eclipse.jface.wizard.WizardDialog;
28
import org.eclipse.jface.wizard.WizardPage;
29
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.events.SelectionAdapter;
31
import org.eclipse.swt.events.SelectionEvent;
32
import org.eclipse.swt.events.SelectionListener;
33
import org.eclipse.swt.layout.GridData;
34
import org.eclipse.swt.layout.GridLayout;
35
import org.eclipse.swt.widgets.Button;
36
import org.eclipse.swt.widgets.Combo;
37
import org.eclipse.swt.widgets.Composite;
38
import org.eclipse.swt.widgets.Event;
39
import org.eclipse.swt.widgets.Label;
40
import org.eclipse.swt.widgets.Listener;
41

    
42
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
43
import eu.etaxonomy.cdm.api.service.IClassificationService;
44
import eu.etaxonomy.cdm.api.service.ITermTreeService;
45
import eu.etaxonomy.cdm.api.service.description.AggregationMode;
46
import eu.etaxonomy.cdm.api.service.description.AggregationSourceMode;
47
import eu.etaxonomy.cdm.api.service.description.DistributionAggregationConfiguration;
48
import eu.etaxonomy.cdm.filter.LogicFilter;
49
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
50
import eu.etaxonomy.cdm.model.name.Rank;
51
import eu.etaxonomy.cdm.model.name.TaxonName;
52
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
53
import eu.etaxonomy.cdm.model.taxon.Classification;
54
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
55
import eu.etaxonomy.cdm.model.term.TermTree;
56
import eu.etaxonomy.cdm.model.term.TermType;
57
import eu.etaxonomy.taxeditor.l10n.Messages;
58
import eu.etaxonomy.taxeditor.store.CdmStore;
59
import eu.etaxonomy.taxeditor.store.StoreUtil;
60
import eu.etaxonomy.taxeditor.ui.combo.OriginalSourceTypeComparator;
61
import eu.etaxonomy.taxeditor.ui.dialog.SuperAreaSelectionWizard;
62

    
63
/**
64
 * @author k.luther
65
 * @since 15.11.2019
66
 */
67
public class DistributionAggregationWizardPage extends WizardPage implements Listener, SelectionListener{
68

    
69
    private DistributionAggregationConfiguration configurator;
70

    
71
    private Combo comboHigherRank;
72
    private Combo comboLowerRank;
73

    
74
    private Combo comboSourceModeChildParent;
75
    private Combo comboSourceModeSubAreaSuperArea;
76

    
77
    private CheckboxTableViewer aggregationModeViewer;
78

    
79
    private Button btnSelectSuperAreas;
80
    private Button buttonSuperArea;
81
    private Combo comboAreaLevel;
82
    private Combo comboStatusOrder;
83

    
84

    
85
    private Combo comboClassificationSelection;
86
    private List<Classification> classifications;
87
    private Classification selectedClassification;
88

    
89

    
90

    
91
    private Button checkUseSelectedTaxonNode;
92
    private Button checkUseSelectedClassification;
93
    private Button checkUseSelectedSubtree;
94

    
95

    
96
    private Button checkExportUnpublished;
97

    
98
    private TaxonNode subTreeNode;
99
    private CheckboxTableViewer sourceTypeViewer;
100
    Object[] checkedElements;
101
    Map<String, OriginalSourceType> typeMap = new HashMap();
102

    
103
    Comparator comparator = new Comparator<Rank>(){
104

    
105
        @Override
106
        public int compare(Rank o1, Rank o2) {
107
            return o2.compareTo(o1);
108
        }
109

    
110
    };
111

    
112

    
113
    /**
114
     * @param pageName
115
     */
116
    public DistributionAggregationWizardPage(DistributionAggregationConfiguration configurator) {
117
        super("Distribution aggregation configuration");
118
        this.configurator = configurator;
119

    
120
        this.setDescription("Configure the aggregation");
121

    
122
    }
123

    
124

    
125
    @Override
126
    public void createControl(Composite parent) {
127
        final Composite composite = new Composite(parent, SWT.NULL);
128

    
129
        String taxonStr = "";
130
        int count = configurator.getTaxonNodeFilter().getSubtreeFilter().size();
131

    
132
        for (LogicFilter<TaxonNode> filter: configurator.getTaxonNodeFilter().getSubtreeFilter()){
133
            subTreeNode = CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().load(filter.getUuid());
134
            count--;
135
            if (subTreeNode.hasTaxon()){
136
                taxonStr += subTreeNode.getTaxon().getName().getTitleCache();
137
                if (count>0){
138
                    taxonStr += ", ";
139
                }
140
            }
141
        }
142
        if (StringUtils.isNotBlank(taxonStr)){
143
            checkUseSelectedSubtree= new Button(composite,  SWT.RADIO);
144
            checkUseSelectedSubtree.setText("Aggregation for selected subtree(s) "+  taxonStr);
145
            checkUseSelectedSubtree.addListener(SWT.Selection, new Listener() {
146
                @Override
147
                public void handleEvent(Event e) {
148
                    Button b = (Button) e.widget;
149
                    GridData data = (GridData)  comboClassificationSelection.getLayoutData();
150
                    data.exclude = b.getSelection();
151
                    comboClassificationSelection.setEnabled(!data.exclude);
152

    
153
                    updateHigherRankCombo();
154
               }
155
            });
156

    
157
            checkUseSelectedTaxonNode= new Button(composite,  SWT.RADIO);
158
            checkUseSelectedTaxonNode.setText("Aggregation only for "+  taxonStr);
159
            checkUseSelectedTaxonNode.addListener(SWT.Selection, new Listener() {
160
                @Override
161
                public void handleEvent(Event e) {
162
                    Button b = (Button) e.widget;
163
                    GridData data = (GridData)  comboClassificationSelection.getLayoutData();
164
                    data.exclude = b.getSelection();
165
                    comboClassificationSelection.setEnabled(!data.exclude);
166
                    updateHigherRankCombo();
167
                }
168

    
169

    
170
            });
171
        }
172
        checkUseSelectedClassification= new Button(composite,  SWT.RADIO);
173
        checkUseSelectedClassification.setText("Aggregate selected classification");
174
        checkUseSelectedClassification.addListener(SWT.Selection, new Listener() {
175
           @Override
176
           public void handleEvent(Event e) {
177
               Button b = (Button) e.widget;
178
               GridData data = (GridData)  comboClassificationSelection.getLayoutData();
179
               data.exclude = b.getSelection();
180
               comboClassificationSelection.setEnabled(data.exclude);
181
               updateHigherRankCombo();
182
           }
183
        });
184

    
185
        GridLayoutFactory.fillDefaults();
186

    
187
        if (subTreeNode!= null){
188
            selectedClassification = subTreeNode.getClassification();
189
        }
190
        GridData gridDataClassificationCombo = new GridData();
191
        gridDataClassificationCombo = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
192
        gridDataClassificationCombo.horizontalIndent = 5;
193

    
194
        comboClassificationSelection = new Combo(composite, SWT.BORDER| SWT.READ_ONLY);
195
        comboClassificationSelection.setLayoutData(gridDataClassificationCombo);
196
        classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null);
197
        Collections.sort(classifications, new Comparator<Classification>() {
198

    
199
            @Override
200
            public int compare(Classification o1, Classification o2) {
201
                if (o1.equals(o2)){
202
                    return 0;
203
                }
204
                int result = o1.getTitleCache().compareTo(o2.getTitleCache());
205
                if (result == 0){
206
                    return o1.getUuid().compareTo(o2.getUuid());
207
                }
208
                return result;
209
            }
210
        });
211
        for(Classification tree : classifications){
212
            comboClassificationSelection.add(tree.getName().getText(), classifications.indexOf(tree));
213

    
214
        }
215

    
216
        comboClassificationSelection.select(classifications.indexOf(selectedClassification));
217
        comboClassificationSelection.addSelectionListener(this);
218

    
219
        if (StringUtils.isNotBlank(taxonStr)){
220
            checkUseSelectedSubtree.setSelection(true);
221
            comboClassificationSelection.setEnabled(false);
222
        }else{
223
            checkUseSelectedClassification.setSelection(true);
224
        }
225
        Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
226
        GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
227
        gridData.horizontalSpan = 2;
228
        gridData.verticalIndent = 5;
229
        separator.setLayoutData(gridData);
230

    
231
        GridLayout gridLayout = new GridLayout();
232
        gridLayout.numColumns = 1;
233

    
234
        composite.setLayout(gridLayout);
235
        final Composite control = new Composite(composite, SWT.NULL);
236
        GridLayout gridLayoutControl = new GridLayout();
237
        gridLayoutControl.numColumns = 2;
238
        control.setLayout(gridLayoutControl);
239
        control.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));
240

    
241
        Label higherRankLabel = new Label(control, SWT.NULL);
242
        higherRankLabel.setText("Highest rank");
243

    
244
        comboHigherRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
245
        updateHigherRankCombo();
246
        comboHigherRank.addListener(SWT.Selection, this);
247

    
248

    
249
        Label lowerRankLabel = new Label(control, SWT.NULL);
250
        lowerRankLabel.setText("Lowest rank");
251
        comboLowerRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
252
        updateLowerRankCombo();
253
        comboLowerRank.addListener(SWT.Selection, this);
254

    
255
        separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
256
        gridData = new GridData(GridData.FILL_HORIZONTAL);
257
        gridData.horizontalSpan = 2;
258
        gridData.verticalIndent = 5;
259
        separator.setLayoutData(gridData);
260

    
261
        Label aggregationModeLabel = new Label(control, SWT.NULL);
262
        aggregationModeLabel.setText("Aggregation mode");
263
        aggregationModeLabel.setToolTipText("Selecting none deletes all existing aggregated distributions");
264
        aggregationModeViewer =  CheckboxTableViewer.newCheckList(control, SWT.BORDER | SWT.SINGLE);
265
        aggregationModeViewer.setContentProvider(new ArrayContentProvider());
266
        aggregationModeViewer.setLabelProvider(new LabelProvider(){
267
            @Override
268
            public String getText(Object element){
269
                if (element instanceof AggregationMode){
270
                    if (((AggregationMode)element).equals(AggregationMode.ToParent)){
271
                        return "From child to parent taxon";
272
                    }
273
                    if (((AggregationMode)element).equals(AggregationMode.WithinTaxon)){
274
                        return "From sub area to super area";
275
                    }
276
                }
277
                return null;
278
            }
279

    
280
        });
281
        List<AggregationMode> aggregationModeList = new ArrayList<>();
282
        for (AggregationMode mode: AggregationMode.values()){
283
            aggregationModeList.add(mode);
284
        }
285

    
286
        aggregationModeViewer.setInput(aggregationModeList);
287

    
288
        aggregationModeViewer.addCheckStateListener(new ICheckStateListener(){
289
            @Override
290
            public void checkStateChanged(    CheckStateChangedEvent event){
291
                Object[] checked =aggregationModeViewer.getCheckedElements();
292
                boolean areachecked = false;
293
                boolean toParentChecked = false;
294
                for (int i = 0; i<checked.length;i++){
295
                    if (checked[i] instanceof AggregationMode){
296
                        if (((AggregationMode)checked[i]).equals(AggregationMode.WithinTaxon)){
297
                            areachecked = true;
298
                        }
299
                        if (((AggregationMode)checked[i]).equals(AggregationMode.ToParent)){
300
                            toParentChecked = true;
301
                        }
302
                    }
303
                }
304
                comboAreaLevel.setEnabled(areachecked);
305
                buttonSuperArea.setEnabled(areachecked);
306
                comboSourceModeSubAreaSuperArea.setEnabled(areachecked);
307
                comboSourceModeChildParent.setEnabled(toParentChecked);
308
                AggregationSourceMode areaMode = (AggregationSourceMode)comboSourceModeSubAreaSuperArea.getData(comboSourceModeSubAreaSuperArea.getText());
309
                AggregationSourceMode taxonMode = (AggregationSourceMode)comboSourceModeChildParent.getData(comboSourceModeChildParent.getText());
310
                sourceTypeViewer.getTable().setEnabled(((areachecked && (areaMode.equals(AggregationSourceMode.ALL) || areaMode.equals(AggregationSourceMode.ALL_SAMEVALUE) ) )|| toParentChecked && (taxonMode.equals(AggregationSourceMode.ALL) || taxonMode.equals(AggregationSourceMode.ALL_SAMEVALUE) )) );
311
                getWizard().getContainer().updateButtons();
312
              }
313
        });
314
        Label areaLevelLabel = new Label(control, SWT.NULL);
315
        areaLevelLabel.setText("Area Level");
316
        areaLevelLabel.setToolTipText("Selecting the area level to which the distribution should be aggregated");
317
        comboAreaLevel = new Combo(control,  SWT.BORDER | SWT.READ_ONLY);
318
        List<NamedAreaLevel> namedAreaLevels = CdmStore.getTermManager().getAllTerms(TermType.NamedAreaLevel, null);
319
        for (NamedAreaLevel level: namedAreaLevels) {
320
            comboAreaLevel.add(level.getLabel());
321
            comboAreaLevel.setData(level.getLabel(), level);
322
        }
323
        comboAreaLevel.addSelectionListener(this);
324
        comboAreaLevel.setEnabled(false);
325
        GridData gridData2 = new GridData();
326
        gridData2.horizontalSpan = 2;
327
        gridData2.horizontalAlignment = SWT.LEFT;
328

    
329
        buttonSuperArea = new Button(control, SWT.PUSH );
330
        buttonSuperArea.setLayoutData(gridData2);
331
        buttonSuperArea.setEnabled(false);
332
        buttonSuperArea.setText("Select Super Areas");
333
        buttonSuperArea.setToolTipText("If area aggregation is selected, the super areas can be selected. If none are selected the top level areas are used.");
334
        buttonSuperArea.addSelectionListener(new SelectionAdapter() {
335
            @Override
336
            public void widgetSelected(SelectionEvent event) {
337
                SuperAreaSelectionWizard availableDistributionWizard = new SuperAreaSelectionWizard(configurator, (NamedAreaLevel)comboAreaLevel.getData(comboAreaLevel.getText()));
338
                WizardDialog dialog = new WizardDialog(StoreUtil.getShell(),
339
                        availableDistributionWizard);
340
                int open = dialog.open();
341
            }
342
        });
343

    
344

    
345

    
346

    
347
        Label sourceModeLabel = new Label(control, SWT.NULL);
348

    
349
        sourceModeLabel.setText("Source mode child/parent");
350
        sourceModeLabel.setToolTipText("Defines the source mode if aggregation from child to parent taxon is selected.");
351
        comboSourceModeChildParent = new Combo(control,  SWT.BORDER| SWT.READ_ONLY);
352
        comboSourceModeChildParent.setText(Messages.DistributionAggregationConfiguration_AggregationMode);
353

    
354
        for (AggregationSourceMode mode :AggregationSourceMode.values()){
355
            comboSourceModeChildParent.add(mode.toString());
356
            comboSourceModeChildParent.setData(mode.toString(), mode);
357

    
358
        }
359

    
360
        comboSourceModeChildParent.addSelectionListener(this);
361
        comboSourceModeChildParent.setEnabled(false);
362
        comboSourceModeChildParent.select(0);
363

    
364
        Label sourceModeLabelSuperArea = new Label(control, SWT.NULL);
365
        sourceModeLabelSuperArea.setText("Source mode sub area/super area");
366
        sourceModeLabelSuperArea.setToolTipText("Defines the source mode if aggregation from sub area to super area is selected.");
367
        comboSourceModeSubAreaSuperArea = new Combo(control,  SWT.BORDER| SWT.READ_ONLY);
368
        comboSourceModeSubAreaSuperArea.setText(Messages.DistributionAggregationConfiguration_AggregationMode);
369

    
370
        for (AggregationSourceMode mode :AggregationSourceMode.values()){
371
            comboSourceModeSubAreaSuperArea.add(mode.toString());
372
            comboSourceModeSubAreaSuperArea.setData(mode.toString(), mode);
373
        }
374

    
375
        comboSourceModeSubAreaSuperArea.addSelectionListener(this);
376
        comboSourceModeSubAreaSuperArea.setEnabled(false);
377
        comboSourceModeSubAreaSuperArea.select(0);
378

    
379
        Label sourceTypeLabel = new Label(control, SWT.NULL);
380
        sourceTypeLabel.setText("Source type");
381
        sourceTypeLabel.setToolTipText("Type of sources that should be aggregated");
382
        sourceTypeViewer = CheckboxTableViewer.newCheckList(control, SWT.BORDER | SWT.SINGLE);
383
        sourceTypeViewer.setContentProvider(new ArrayContentProvider());
384

    
385

    
386
        sourceTypeViewer.addCheckStateListener(new ICheckStateListener(){
387
            @Override
388
            public void checkStateChanged(    CheckStateChangedEvent event){
389
                checkedElements=sourceTypeViewer.getCheckedElements();
390
                getWizard().getContainer().updateButtons();
391
              }
392
        });
393

    
394
        List<String> typeStrings = new ArrayList<>();
395
        OriginalSourceType[] typeArray = OriginalSourceType.values();
396
        Arrays.sort(typeArray, new OriginalSourceTypeComparator(null));
397
        Arrays.stream(typeArray).forEach(p ->typeMap.put(p.getMessage(), p));
398
        Arrays.stream(typeArray).forEach(p ->typeStrings.add(p.getMessage()));
399
        typeStrings.remove(OriginalSourceType.NomenclaturalReference.getMessage());
400
        sourceTypeViewer.setInput(typeStrings);
401
        sourceTypeViewer.setChecked(OriginalSourceType.PrimaryMediaSource.getMessage(), true);
402
        sourceTypeViewer.setChecked(OriginalSourceType.PrimaryTaxonomicSource.getMessage(), true);
403
        sourceTypeViewer.getTable().setEnabled(false);
404

    
405
        //aggregation mode
406

    
407

    
408

    
409
        Label selectStatusLabel = new Label(control, SWT.NULL);
410
        selectStatusLabel.setText("Status order");
411
        comboStatusOrder = new Combo(control, SWT.PUSH );
412
        comboStatusOrder.add("Default - by Presence Absence Term vocabulary");
413
        comboStatusOrder.setData("Default - by Presence Absence Term vocabulary", null);
414
        for (TermTree tree: CdmStore.getService(ITermTreeService.class).list(TermType.PresenceAbsenceTerm, null, 0, null,null)){
415
            comboStatusOrder.add(tree.getTitleCache());
416
            comboStatusOrder.setData(tree.getTitleCache(), tree);
417
        }
418

    
419
        comboStatusOrder.addSelectionListener(this);
420
        comboStatusOrder.select(0);
421

    
422
        checkExportUnpublished = new Button(composite,  SWT.CHECK);
423
        checkExportUnpublished.setText("Export unpublished taxa");
424

    
425
        GridLayoutFactory.fillDefaults();
426

    
427

    
428

    
429
        setControl(composite);
430

    
431
    }
432

    
433

    
434

    
435

    
436

    
437

    
438
    @Override
439
    public void widgetSelected(SelectionEvent e) {
440

    
441
        if (e.getSource().equals(comboSourceModeChildParent) || e.getSource().equals(comboSourceModeSubAreaSuperArea)){
442
            AggregationSourceMode modeChild = (AggregationSourceMode)comboSourceModeChildParent.getData(comboSourceModeChildParent.getText());
443
            AggregationSourceMode modeArea = (AggregationSourceMode)comboSourceModeSubAreaSuperArea.getData(comboSourceModeSubAreaSuperArea.getText());
444
            if ((comboSourceModeChildParent.isEnabled() && (modeChild != null && modeChild.equals(AggregationSourceMode.ALL) || modeChild.equals(AggregationSourceMode.ALL_SAMEVALUE))) ||(comboSourceModeSubAreaSuperArea.isEnabled() && (modeArea != null && modeArea.equals(AggregationSourceMode.ALL) || modeArea.equals(AggregationSourceMode.ALL_SAMEVALUE)))){
445
                sourceTypeViewer.getTable().setEnabled(true);
446
            }else{
447
                sourceTypeViewer.getTable().setEnabled(false);
448
            }
449

    
450
        }
451

    
452
        if (e.getSource().equals(comboAreaLevel)){
453
            buttonSuperArea.setEnabled(StringUtils.isNotBlank(comboAreaLevel.getText()));
454
        }
455

    
456

    
457
    }
458

    
459

    
460
    @Override
461
    public void widgetDefaultSelected(SelectionEvent e) {
462
        // TODO Auto-generated method stub
463

    
464
    }
465

    
466

    
467
    @Override
468
    public void handleEvent(Event event) {
469
        if (event.widget.equals(comboHigherRank)){
470
            updateLowerRankCombo();
471
        }
472
        if (event.widget.equals(selectedClassification)){
473
            updateHigherRankCombo();
474
            updateLowerRankCombo();
475
        }
476
        if (event.widget.equals(this.checkUseSelectedClassification)){
477
            updateHigherRankCombo();
478
            updateLowerRankCombo();
479
        }
480
        if (event.widget.equals(this.checkUseSelectedSubtree)){
481
            updateHigherRankCombo();
482
            updateLowerRankCombo();
483
        }
484
        if (event.widget.equals(this.checkUseSelectedTaxonNode)){
485
            updateHigherRankCombo();
486
            updateLowerRankCombo();
487
        }
488

    
489
    }
490

    
491
    private void updateHigherRankCombo() {
492
        comboHigherRank.removeAll();
493
        List<Rank> rankList = new ArrayList<>();
494
        TaxonName name = null;
495
        if (subTreeNode != null){
496
            if (subTreeNode.getTaxon() != null){
497
                name = subTreeNode.getTaxon().getName();
498
            }
499
        }
500
        comboHigherRank.add("");
501
        if (name != null){
502
            for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
503
                if (useClassification() || (name != null && name.getRank().isHigher(rank))){
504
                    rankList.add(rank);
505
                }
506
            }
507
        }else{
508
            for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
509
                rankList.add(rank);
510
            }
511
        }
512

    
513
        rankList.sort(comparator);
514
        for (Rank rank: rankList){
515
            comboHigherRank.add(rank.getLabel());
516
            comboHigherRank.setData(rank.getLabel(), rank);
517
        }
518

    
519

    
520
    }
521

    
522

    
523
   private void updateLowerRankCombo() {
524
       comboLowerRank.removeAll();
525
       TaxonName name = null;
526
       List<Rank> rankList = new ArrayList<>();
527
       if (subTreeNode != null){
528
           if (subTreeNode.getTaxon() != null){
529
               name = subTreeNode.getTaxon().getName();
530
           }
531
       }
532
       comboLowerRank.add("");
533
       for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
534
           if (subTreeNode == null && (comboHigherRank.getText() == null || (comboHigherRank.getData(comboHigherRank.getText()) != null && ((Rank)comboHigherRank.getData(comboHigherRank.getText())).isHigher(rank)))){
535
               rankList.add(rank);
536
           }else if (name == null || name.getRank().isHigher(rank)) {
537
               if(StringUtils.isBlank(comboHigherRank.getText()) || comboHigherRank.getData(comboHigherRank.getText()) != null && ((Rank)comboHigherRank.getData(comboHigherRank.getText())).isHigher(rank)){
538
               // the rank is lower than higher rank and lower than the rank of the subtree name
539
                   rankList.add(rank);
540
               }
541
           }
542
       }
543
       rankList.sort(comparator);
544
       for (Rank rank: rankList){
545
           comboLowerRank.add(rank.getLabel());
546
           comboLowerRank.setData(rank.getLabel(), rank);
547
       }
548

    
549
   }
550

    
551
   public Rank getHigherRank(){
552
       if (StringUtils.isNotBlank(comboHigherRank.getText())){
553
           return (Rank)comboHigherRank.getData(comboHigherRank.getText());
554
       }
555
       return null;
556
   }
557

    
558
   public Rank getLowerRank(){
559
       if (StringUtils.isNotBlank(comboLowerRank.getText())){
560
           return (Rank)comboLowerRank.getData(comboLowerRank.getText());
561
       }
562
       return null;
563
   }
564

    
565

    
566
   public AggregationSourceMode getSourceModeChildParent(){
567
       if (StringUtils.isNotBlank(comboSourceModeChildParent.getText())){
568
           return (AggregationSourceMode)comboSourceModeChildParent.getData(comboSourceModeChildParent.getText());
569
       }
570
       return null;
571
   }
572

    
573
   public AggregationSourceMode getSourceModeSuperAreaSubArea(){
574
       if (StringUtils.isNotBlank(comboSourceModeSubAreaSuperArea.getText())){
575
           return (AggregationSourceMode)comboSourceModeSubAreaSuperArea.getData(comboSourceModeSubAreaSuperArea.getText());
576

    
577
       }
578
       return null;
579
   }
580

    
581
   public TermTree getStatusOrder(){
582
       if (StringUtils.isNotBlank(comboStatusOrder.getText())){
583
           return (TermTree)comboStatusOrder.getData(comboStatusOrder.getText());
584
       }
585
       return null;
586
   }
587

    
588
   public boolean useClassification(){
589
       return checkUseSelectedClassification.getSelection();
590
   }
591

    
592
   public boolean useSubtree(){
593
       return checkUseSelectedSubtree.getSelection();
594
   }
595

    
596
   public boolean useTaxonNode(){
597
       return checkUseSelectedTaxonNode.getSelection();
598
   }
599

    
600
   public boolean useUnpublishedData(){
601
       return checkExportUnpublished.getSelection();
602
   }
603

    
604
   public EnumSet<OriginalSourceType> getSourceTypes(){
605
       List<OriginalSourceType> list = new ArrayList<>();
606
       for (Object o: sourceTypeViewer.getCheckedElements()){
607
           String string = null;
608
           if (o instanceof String){
609
               string = (String)o;
610
           }
611
           if (string != null){
612
               list.add(typeMap.get(string));
613
           }
614
       }
615

    
616
       return EnumSet.copyOf(list);
617
   }
618

    
619
   public List<AggregationMode> getAggregationMode(){
620

    
621
       List<AggregationMode> result = new ArrayList<>();
622
       for (Object o: aggregationModeViewer.getCheckedElements()){
623
           if (o instanceof AggregationMode){
624
               result.add((AggregationMode)o);
625
           }
626
       }
627
       return result;
628
   }
629

    
630

    
631
    public Classification getSelectedClassification() {
632
        return selectedClassification;
633
    }
634

    
635

    
636
    public TaxonNode getSubTreeNode() {
637
        return subTreeNode;
638
    }
639
}
(3-3/7)