1
|
/**
|
2
|
* Copyright (C) 2018 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.databaseAdmin.preferencePage;
|
10
|
|
11
|
import org.eclipse.swt.SWT;
|
12
|
import org.eclipse.swt.events.SelectionAdapter;
|
13
|
import org.eclipse.swt.events.SelectionEvent;
|
14
|
import org.eclipse.swt.events.SelectionListener;
|
15
|
import org.eclipse.swt.layout.GridData;
|
16
|
import org.eclipse.swt.layout.GridLayout;
|
17
|
import org.eclipse.swt.widgets.Button;
|
18
|
import org.eclipse.swt.widgets.Combo;
|
19
|
import org.eclipse.swt.widgets.Composite;
|
20
|
import org.eclipse.swt.widgets.Control;
|
21
|
|
22
|
import eu.etaxonomy.cdm.api.application.ICdmRepository;
|
23
|
import eu.etaxonomy.cdm.api.service.IPreferenceService;
|
24
|
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
|
25
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
|
26
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
27
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
28
|
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
|
29
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
30
|
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
|
31
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
32
|
|
33
|
/**
|
34
|
* @author k.luther
|
35
|
* @since 23.03.2018
|
36
|
*
|
37
|
*/
|
38
|
public class AbcdImportPreference extends CdmPreferencePage implements IE4AdminPreferencePage, SelectionListener {
|
39
|
|
40
|
private Abcd206ImportConfigurator configurator;
|
41
|
|
42
|
private Combo nomenclaturalCodeSelectionCombo;
|
43
|
|
44
|
/**
|
45
|
* {@inheritDoc}
|
46
|
*/
|
47
|
@Override
|
48
|
protected Control createContents(Composite parent) {
|
49
|
final Composite composite = new Composite(parent, SWT.NULL);
|
50
|
|
51
|
GridLayout gridLayout = new GridLayout();
|
52
|
composite.setLayout(gridLayout);
|
53
|
|
54
|
configurator = PreferencesUtil.getAbcdImportConfigurationPreference(false);
|
55
|
|
56
|
Button checkBoxMediaSpecimen = new Button(composite, SWT.CHECK);
|
57
|
checkBoxMediaSpecimen.setSelection(configurator.isAddMediaAsMediaSpecimen());
|
58
|
checkBoxMediaSpecimen.setText("Import media as media specimen");
|
59
|
checkBoxMediaSpecimen
|
60
|
.setToolTipText("Any media attached to a ABCD unit will be imported as a sub derivative of the specimen created from this unit");
|
61
|
checkBoxMediaSpecimen.addSelectionListener(new SelectionAdapter() {
|
62
|
@Override
|
63
|
public void widgetSelected(SelectionEvent e) {
|
64
|
configurator.setAddMediaAsMediaSpecimen(!configurator.isAddMediaAsMediaSpecimen());
|
65
|
}
|
66
|
});
|
67
|
|
68
|
Button checkBoxIgnoreExisting = new Button(composite, SWT.CHECK);
|
69
|
checkBoxIgnoreExisting.setSelection(configurator.isIgnoreImportOfExistingSpecimen());
|
70
|
checkBoxIgnoreExisting.setText("Do not import existing specimens");
|
71
|
checkBoxIgnoreExisting
|
72
|
.setToolTipText("Specimens that have previously been imported will be ignored in this import");
|
73
|
checkBoxIgnoreExisting.addSelectionListener(new SelectionAdapter() {
|
74
|
@Override
|
75
|
public void widgetSelected(SelectionEvent e) {
|
76
|
configurator.setIgnoreImportOfExistingSpecimen(!configurator.isIgnoreImportOfExistingSpecimen());
|
77
|
}
|
78
|
});
|
79
|
|
80
|
Button checkBoxIgnoreAuthorship = new Button(composite, SWT.CHECK);
|
81
|
checkBoxIgnoreAuthorship.setSelection(configurator.isIgnoreAuthorship());
|
82
|
checkBoxIgnoreAuthorship.setText("Ignore Authorship for name matching");
|
83
|
checkBoxIgnoreAuthorship
|
84
|
.setToolTipText("Name matching with existing names will be done without "
|
85
|
+ "the authorship part of the name");
|
86
|
checkBoxIgnoreAuthorship.addSelectionListener(new SelectionAdapter() {
|
87
|
@Override
|
88
|
public void widgetSelected(SelectionEvent e) {
|
89
|
configurator.setIgnoreAuthorship(!configurator.isIgnoreAuthorship());
|
90
|
}
|
91
|
});
|
92
|
|
93
|
Button checkBoxMapUnitIdToCatalogNumber = new Button(composite, SWT.CHECK);
|
94
|
checkBoxMapUnitIdToCatalogNumber.setSelection(configurator.isMapUnitIdToCatalogNumber());
|
95
|
checkBoxMapUnitIdToCatalogNumber.setText("Map UnitID to catalog number");
|
96
|
checkBoxMapUnitIdToCatalogNumber
|
97
|
.setToolTipText("The UnitID of every ABCD unit will be mapped the catalog number "
|
98
|
+ "of the specimen");
|
99
|
checkBoxMapUnitIdToCatalogNumber.addSelectionListener(new SelectionAdapter() {
|
100
|
@Override
|
101
|
public void widgetSelected(SelectionEvent e) {
|
102
|
configurator.setMapUnitIdToCatalogNumber(!configurator.isMapUnitIdToCatalogNumber());
|
103
|
}
|
104
|
});
|
105
|
//TODO: only one of the mappings can be checked!
|
106
|
Button checkBoxMapUnitIdToAccessionNumber = new Button(composite, SWT.CHECK);
|
107
|
checkBoxMapUnitIdToAccessionNumber.setSelection(configurator.isMapUnitIdToAccessionNumber());
|
108
|
checkBoxMapUnitIdToAccessionNumber.setText("Map UnitID to accession number");
|
109
|
checkBoxMapUnitIdToAccessionNumber
|
110
|
.setToolTipText("The UnitID of every ABCD unit will be mapped the accession number "
|
111
|
+ "of the specimen");
|
112
|
checkBoxMapUnitIdToAccessionNumber.addSelectionListener(new SelectionAdapter() {
|
113
|
@Override
|
114
|
public void widgetSelected(SelectionEvent e) {
|
115
|
configurator.setMapUnitIdToAccessionNumber(!configurator.isMapUnitIdToAccessionNumber());
|
116
|
}
|
117
|
});
|
118
|
|
119
|
Button checkBoxMapUnitIdToBarcode = new Button(composite, SWT.CHECK);
|
120
|
checkBoxMapUnitIdToBarcode.setSelection(configurator.isMapUnitIdToBarcode());
|
121
|
checkBoxMapUnitIdToBarcode.setText("Map UnitID to barcode");
|
122
|
checkBoxMapUnitIdToBarcode
|
123
|
.setToolTipText("The UnitID of every ABCD unit will be mapped the barcode "
|
124
|
+ "of the specimen");
|
125
|
checkBoxMapUnitIdToBarcode.addSelectionListener(new SelectionAdapter() {
|
126
|
@Override
|
127
|
public void widgetSelected(SelectionEvent e) {
|
128
|
configurator.setMapUnitIdToBarcode(!configurator.isMapUnitIdToBarcode());
|
129
|
}
|
130
|
});
|
131
|
|
132
|
Button checkBoxRemoveCountry = new Button(composite, SWT.CHECK);
|
133
|
checkBoxRemoveCountry.setSelection(configurator.isRemoveCountryFromLocalityText());
|
134
|
checkBoxRemoveCountry.setText("Remove country from locality text");
|
135
|
checkBoxRemoveCountry
|
136
|
.setToolTipText("If the locality text contains information about the "
|
137
|
+ "country which is additionally stored in other ABCD "
|
138
|
+ "elements then it is removed from the locality text");
|
139
|
checkBoxRemoveCountry.addSelectionListener(new SelectionAdapter() {
|
140
|
@Override
|
141
|
public void widgetSelected(SelectionEvent e) {
|
142
|
configurator.setRemoveCountryFromLocalityText(!configurator.isRemoveCountryFromLocalityText());
|
143
|
}
|
144
|
});
|
145
|
|
146
|
Button checkBoxMoveToDefaultClassification = new Button(composite, SWT.CHECK);
|
147
|
checkBoxMoveToDefaultClassification.setSelection(configurator.isMoveNewTaxaToDefaultClassification());
|
148
|
checkBoxMoveToDefaultClassification.setText("Create new classification for new taxa");
|
149
|
checkBoxMoveToDefaultClassification
|
150
|
.setToolTipText("For taxa that do not exist in the data base "
|
151
|
+ "a new classification will be created");
|
152
|
checkBoxMoveToDefaultClassification.addSelectionListener(new SelectionAdapter() {
|
153
|
@Override
|
154
|
public void widgetSelected(SelectionEvent e) {
|
155
|
configurator.setMoveNewTaxaToDefaultClassification(!configurator.isMoveNewTaxaToDefaultClassification());
|
156
|
}
|
157
|
});
|
158
|
|
159
|
Button checkBoxImportSiblings = new Button(composite, SWT.CHECK);
|
160
|
checkBoxImportSiblings.setSelection(configurator.isGetSiblings());
|
161
|
checkBoxImportSiblings.setText("Import all children of cultures or tissue samples");
|
162
|
checkBoxImportSiblings
|
163
|
.setToolTipText("For a tissue sample or culture all children will be searched and imported");
|
164
|
checkBoxImportSiblings.addSelectionListener(new SelectionAdapter() {
|
165
|
@Override
|
166
|
public void widgetSelected(SelectionEvent e) {
|
167
|
configurator.setGetSiblings(checkBoxImportSiblings.getSelection());
|
168
|
}
|
169
|
});
|
170
|
|
171
|
Button checkBoxAddIndividualsAssociations = new Button(composite, SWT.CHECK);
|
172
|
checkBoxAddIndividualsAssociations.setSelection(configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
|
173
|
checkBoxAddIndividualsAssociations.setText("Create an Individual Association for each Specimen");
|
174
|
checkBoxAddIndividualsAssociations
|
175
|
.setToolTipText("For each specimen associated to a taxon an indiviadual association to this taxon is created");
|
176
|
checkBoxAddIndividualsAssociations.addSelectionListener(new SelectionAdapter() {
|
177
|
@Override
|
178
|
public void widgetSelected(SelectionEvent e) {
|
179
|
configurator.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(!configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
|
180
|
}
|
181
|
});
|
182
|
|
183
|
Button checkBoxReuseDescriptiveGroups = new Button(composite, SWT.CHECK);
|
184
|
checkBoxReuseDescriptiveGroups.setSelection(configurator.isReuseExistingDescriptiveGroups());
|
185
|
checkBoxReuseDescriptiveGroups.setText("Reuse existing descriptive group");
|
186
|
checkBoxReuseDescriptiveGroups
|
187
|
.setToolTipText("Reuse one of the existing descriptive groups or create a new one for every import");
|
188
|
checkBoxReuseDescriptiveGroups.addSelectionListener(new SelectionAdapter() {
|
189
|
@Override
|
190
|
public void widgetSelected(SelectionEvent e) {
|
191
|
configurator.setReuseExistingDescriptiveGroups(!configurator.isReuseExistingDescriptiveGroups());
|
192
|
}
|
193
|
});
|
194
|
|
195
|
Button checkBoxReuseExistingTaxa = new Button(composite, SWT.CHECK);
|
196
|
checkBoxReuseExistingTaxa.setSelection(configurator.isReuseExistingTaxaWhenPossible());
|
197
|
checkBoxReuseExistingTaxa.setText("Reuse existing taxa when possible");
|
198
|
checkBoxReuseExistingTaxa
|
199
|
.setToolTipText("Reuse existing taxa when the name matches the identified name of the specimen");
|
200
|
checkBoxReuseExistingTaxa.addSelectionListener(new SelectionAdapter() {
|
201
|
@Override
|
202
|
public void widgetSelected(SelectionEvent e) {
|
203
|
configurator.setReuseExistingDescriptiveGroups(!configurator.isReuseExistingDescriptiveGroups());
|
204
|
}
|
205
|
});
|
206
|
|
207
|
GridData gridData = new GridData();
|
208
|
gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
|
209
|
gridData.horizontalIndent = 5;
|
210
|
// classificationSelection.setLayoutData(gridData);
|
211
|
|
212
|
nomenclaturalCodeSelectionCombo = new Combo(composite, SWT.BORDER| SWT.READ_ONLY);
|
213
|
nomenclaturalCodeSelectionCombo.setLayoutData(gridData);
|
214
|
for(NomenclaturalCode code: NomenclaturalCode.values()){
|
215
|
nomenclaturalCodeSelectionCombo.add(code.getKey());
|
216
|
}
|
217
|
int index = 0;
|
218
|
if (configurator.getNomenclaturalCode() != null){
|
219
|
for (String label : nomenclaturalCodeSelectionCombo.getItems()){
|
220
|
if (label.equals(configurator.getNomenclaturalCode().getKey())){
|
221
|
nomenclaturalCodeSelectionCombo.select(index);
|
222
|
}
|
223
|
index++;
|
224
|
}
|
225
|
}
|
226
|
|
227
|
// TODO remember last selection
|
228
|
nomenclaturalCodeSelectionCombo.addSelectionListener(this);
|
229
|
return composite;
|
230
|
}
|
231
|
|
232
|
@Override
|
233
|
public void widgetSelected(SelectionEvent e) {
|
234
|
this.configurator.setNomenclaturalCode(NomenclaturalCode.getByKey(nomenclaturalCodeSelectionCombo.getText()));
|
235
|
|
236
|
}
|
237
|
|
238
|
@Override
|
239
|
public boolean performOk() {
|
240
|
if (configurator != null){
|
241
|
String configString = configurator.toString();
|
242
|
|
243
|
CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.AbcdImportConfig, configString);
|
244
|
pref.setAllowOverride(true);
|
245
|
|
246
|
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
|
247
|
if (controller == null){
|
248
|
return false;
|
249
|
}
|
250
|
IPreferenceService service = controller.getPreferenceService();
|
251
|
service.set(pref);
|
252
|
}
|
253
|
return true;
|
254
|
}
|
255
|
|
256
|
/**
|
257
|
* {@inheritDoc}
|
258
|
*/
|
259
|
@Override
|
260
|
public void widgetDefaultSelected(SelectionEvent e) {
|
261
|
// TODO Auto-generated method stub
|
262
|
|
263
|
}
|
264
|
|
265
|
public void createAbcdImportConfig() {
|
266
|
this.configurator.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS));
|
267
|
this.configurator.setAddMediaAsMediaSpecimen(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN));
|
268
|
this.configurator.setAllowReuseOtherClassifications(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS));
|
269
|
//this.abcdImportConfigurator.setClassificationUuid(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_CLASSIFICATION_UUID));
|
270
|
this.configurator.setDeduplicateClassifications(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS));
|
271
|
this.configurator.setDeduplicateReferences(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES));
|
272
|
// this.abcdImportConfigurator.setDefaultAuthor(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEFAULT_AUTHOR));
|
273
|
this.configurator.setGetSiblings(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS));
|
274
|
this.configurator.setIgnoreAuthorship(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP));
|
275
|
this.configurator.setIgnoreImportOfExistingSpecimen(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN));
|
276
|
this.configurator.setMapUnitIdToAccessionNumber(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER));
|
277
|
this.configurator.setMapUnitIdToBarcode(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE));
|
278
|
this.configurator.setMapUnitIdToCatalogNumber(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER));
|
279
|
this.configurator.setMoveNewTaxaToDefaultClassification(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION));
|
280
|
this.configurator.setReuseExistingDescriptiveGroups(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS));
|
281
|
this.configurator.setReuseExistingTaxaWhenPossible(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE));
|
282
|
this.configurator.setNomenclaturalCode(PreferencesUtil.getPreferredNomenclaturalCode(doGetPreferenceStore().getString(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE)));
|
283
|
|
284
|
}
|
285
|
|
286
|
}
|