1
|
/**
|
2
|
* Copyright (C) 2007 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
|
|
10
|
package eu.etaxonomy.taxeditor.preference;
|
11
|
|
12
|
import java.io.File;
|
13
|
import java.io.FileInputStream;
|
14
|
import java.io.FileOutputStream;
|
15
|
import java.io.IOException;
|
16
|
import java.net.URI;
|
17
|
import java.net.URISyntaxException;
|
18
|
import java.util.ArrayList;
|
19
|
import java.util.Arrays;
|
20
|
import java.util.Collections;
|
21
|
import java.util.HashMap;
|
22
|
import java.util.List;
|
23
|
import java.util.Map;
|
24
|
import java.util.Properties;
|
25
|
import java.util.StringTokenizer;
|
26
|
import java.util.UUID;
|
27
|
|
28
|
import org.apache.commons.lang.StringUtils;
|
29
|
import org.apache.log4j.Logger;
|
30
|
import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement;
|
31
|
import org.eclipse.jface.preference.IPreferenceStore;
|
32
|
import org.eclipse.jface.window.Window;
|
33
|
import org.eclipse.swt.widgets.Composite;
|
34
|
import org.eclipse.swt.widgets.Control;
|
35
|
import org.eclipse.swt.widgets.Shell;
|
36
|
import org.eclipse.ui.PlatformUI;
|
37
|
|
38
|
import eu.etaxonomy.cdm.api.application.ICdmRepository;
|
39
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeConfigurator;
|
40
|
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
|
41
|
import eu.etaxonomy.cdm.api.service.ITermService;
|
42
|
import eu.etaxonomy.cdm.api.service.config.FindTaxaAndNamesConfiguratorImpl;
|
43
|
import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator;
|
44
|
import eu.etaxonomy.cdm.common.CdmUtils;
|
45
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
46
|
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
|
47
|
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
|
48
|
import eu.etaxonomy.cdm.model.common.ICdmBase;
|
49
|
import eu.etaxonomy.cdm.model.common.IDefinedTerm;
|
50
|
import eu.etaxonomy.cdm.model.common.ISimpleTerm;
|
51
|
import eu.etaxonomy.cdm.model.common.Language;
|
52
|
import eu.etaxonomy.cdm.model.common.MarkerType;
|
53
|
import eu.etaxonomy.cdm.model.common.TermBase;
|
54
|
import eu.etaxonomy.cdm.model.common.TermType;
|
55
|
import eu.etaxonomy.cdm.model.description.FeatureTree;
|
56
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
|
57
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
|
58
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
59
|
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
|
60
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
61
|
import eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy;
|
62
|
import eu.etaxonomy.cdm.strategy.match.FieldMatcher;
|
63
|
import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
|
64
|
import eu.etaxonomy.cdm.strategy.match.MatchException;
|
65
|
import eu.etaxonomy.cdm.strategy.match.MatchMode;
|
66
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
67
|
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
68
|
import eu.etaxonomy.taxeditor.model.NomenclaturalCodeHelper;
|
69
|
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSource;
|
70
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
71
|
import eu.etaxonomy.taxeditor.store.TermStore;
|
72
|
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
|
73
|
import eu.etaxonomy.taxeditor.ui.dialog.DefaultLanguageDialog;
|
74
|
|
75
|
/**
|
76
|
* <p>
|
77
|
* PreferencesUtil class.
|
78
|
* </p>
|
79
|
*
|
80
|
* @author p.ciardelli
|
81
|
* @author n.hoffmann
|
82
|
* @created 05.12.2008
|
83
|
* @version 1.0
|
84
|
*/
|
85
|
public class PreferencesUtil implements IPreferenceKeys {
|
86
|
|
87
|
/**
|
88
|
*
|
89
|
*/
|
90
|
public static final String PREFERRED_TERMS_CHANGE = "preferred_terms";
|
91
|
|
92
|
public static final String P2_REPOSITORIES_DELIM = ",";
|
93
|
public static final String P2_REPOSITORY_FIELDS_DELIM = ";";
|
94
|
|
95
|
private final static Logger logger = Logger.getLogger(PreferencesUtil.class);
|
96
|
|
97
|
|
98
|
|
99
|
/**
|
100
|
* <p>
|
101
|
* getPreferenceStore
|
102
|
* </p>
|
103
|
*
|
104
|
* @return a {@link org.eclipse.jface.preference.IPreferenceStore} object.
|
105
|
*/
|
106
|
public static IPreferenceStore getPreferenceStore() {
|
107
|
return TaxeditorStorePlugin.getDefault().getPreferenceStore();
|
108
|
}
|
109
|
|
110
|
private static String prefKey(String name) {
|
111
|
return name + "_"+ ((CdmRemoteSource)CdmStore.getActiveCdmSource()).toString();
|
112
|
}
|
113
|
|
114
|
/**
|
115
|
* <p>
|
116
|
* setStringValue
|
117
|
* </p>
|
118
|
*
|
119
|
*
|
120
|
**/
|
121
|
public static void setStringValue(String name, String value) {
|
122
|
getPreferenceStore().setValue(prefKey(name), value);
|
123
|
}
|
124
|
|
125
|
/**
|
126
|
* <p>
|
127
|
* setIntValue
|
128
|
* </p>
|
129
|
*
|
130
|
*
|
131
|
**/
|
132
|
public static void setIntValue(String name, int value) {
|
133
|
getPreferenceStore().setValue(prefKey(name), value);
|
134
|
}
|
135
|
|
136
|
/**
|
137
|
* <p>
|
138
|
* setBooleanValue
|
139
|
* </p>
|
140
|
*
|
141
|
*
|
142
|
**/
|
143
|
public static void setBooleanValue(String name, boolean value) {
|
144
|
getPreferenceStore().setValue(prefKey(name), value);
|
145
|
}
|
146
|
|
147
|
/**
|
148
|
* <p>
|
149
|
* setBooleanValue
|
150
|
* </p>
|
151
|
*
|
152
|
*
|
153
|
**/
|
154
|
public static void setDoubleValue(String name, double value) {
|
155
|
getPreferenceStore().setValue(prefKey(name), value);
|
156
|
}
|
157
|
|
158
|
/**
|
159
|
* <p>
|
160
|
* setFloatValue
|
161
|
* </p>
|
162
|
*
|
163
|
*
|
164
|
**/
|
165
|
public static void setFloatValue(String name, float value) {
|
166
|
getPreferenceStore().setValue(name + ((CdmRemoteSource)CdmStore.getActiveCdmSource()).toString(), value);
|
167
|
}
|
168
|
|
169
|
/**
|
170
|
* <p>
|
171
|
* setFloatValue
|
172
|
* </p>
|
173
|
*
|
174
|
*
|
175
|
**/
|
176
|
public static void setLongValue(String name, long value) {
|
177
|
getPreferenceStore().setValue(prefKey(name), value);
|
178
|
}
|
179
|
|
180
|
/**
|
181
|
* <p>
|
182
|
* setStringValue
|
183
|
* </p>
|
184
|
*
|
185
|
*
|
186
|
**/
|
187
|
public static String getStringValue(String name) {
|
188
|
|
189
|
String dbSpecific = prefKey(name);
|
190
|
if (getPreferenceStore().contains(dbSpecific)){
|
191
|
return getPreferenceStore().getString(dbSpecific);
|
192
|
}else{
|
193
|
return getPreferenceStore().
|
194
|
getString(name);
|
195
|
}
|
196
|
|
197
|
}
|
198
|
|
199
|
/**
|
200
|
* <p>
|
201
|
* setIntValue
|
202
|
* </p>
|
203
|
*
|
204
|
*
|
205
|
**/
|
206
|
public static int getIntValue(String name) {
|
207
|
String dbSpecific = prefKey(name);
|
208
|
if (getPreferenceStore().contains(dbSpecific)){
|
209
|
return getPreferenceStore().getInt(dbSpecific);
|
210
|
}else{
|
211
|
return getPreferenceStore().
|
212
|
getInt(name);
|
213
|
}
|
214
|
|
215
|
}
|
216
|
|
217
|
/**
|
218
|
* <p>
|
219
|
* setBooleanValue
|
220
|
* </p>
|
221
|
*
|
222
|
*
|
223
|
**/
|
224
|
public static boolean getBooleanValue(String name) {
|
225
|
if (CdmStore.isActive()){
|
226
|
String dbSpecific = prefKey(name);
|
227
|
if (getPreferenceStore().contains(dbSpecific)){
|
228
|
return getPreferenceStore().getBoolean(dbSpecific);
|
229
|
}else{
|
230
|
return getPreferenceStore().
|
231
|
getBoolean(name);
|
232
|
}
|
233
|
|
234
|
}else{
|
235
|
|
236
|
return getPreferenceStore().getBoolean(name);
|
237
|
}
|
238
|
|
239
|
}
|
240
|
|
241
|
/**
|
242
|
* <p>
|
243
|
* setBooleanValue
|
244
|
* </p>
|
245
|
*
|
246
|
*
|
247
|
**/
|
248
|
public static double getDoubleValue(String name) {
|
249
|
String dbSpecific = prefKey(name);
|
250
|
if (getPreferenceStore().contains(dbSpecific)){
|
251
|
return getPreferenceStore().getDouble(dbSpecific);
|
252
|
}else{
|
253
|
return getPreferenceStore().
|
254
|
getDouble(name);
|
255
|
}
|
256
|
|
257
|
}
|
258
|
|
259
|
/**
|
260
|
* <p>
|
261
|
* getFloatValue
|
262
|
* </p>
|
263
|
*
|
264
|
*
|
265
|
**/
|
266
|
public static float getFloatValue(String name) {
|
267
|
String dbSpecific = prefKey(name);
|
268
|
if (getPreferenceStore().contains(dbSpecific)){
|
269
|
return getPreferenceStore().getFloat(dbSpecific);
|
270
|
}else{
|
271
|
return getPreferenceStore().
|
272
|
getFloat(name);
|
273
|
}
|
274
|
|
275
|
}
|
276
|
|
277
|
/**
|
278
|
* <p>
|
279
|
* getLongValue
|
280
|
* </p>
|
281
|
*
|
282
|
*
|
283
|
**/
|
284
|
public static long getLongValue(String name) {
|
285
|
String dbSpecific = prefKey(name);
|
286
|
if (getPreferenceStore().contains(dbSpecific)){
|
287
|
return getPreferenceStore().getLong(dbSpecific);
|
288
|
}else{
|
289
|
return getPreferenceStore().
|
290
|
getLong(name);
|
291
|
}
|
292
|
}
|
293
|
|
294
|
|
295
|
/**
|
296
|
* <p>
|
297
|
* setPreferredNomenclaturalCode
|
298
|
* </p>
|
299
|
*
|
300
|
* @param preferredCode
|
301
|
* a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
|
302
|
* object.
|
303
|
*/
|
304
|
public static CdmPreference setPreferredNomenclaturalCode(
|
305
|
String preferenceKey, boolean local) {
|
306
|
if (local){
|
307
|
setStringValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
|
308
|
preferenceKey);
|
309
|
}
|
310
|
else{
|
311
|
ICdmRepository controller;
|
312
|
controller = CdmStore.getCurrentApplicationConfiguration();
|
313
|
if (controller == null){
|
314
|
return null;
|
315
|
}
|
316
|
PrefKey key = null;
|
317
|
try{
|
318
|
key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
|
319
|
}catch (Exception e){
|
320
|
System.out.println(e.getStackTrace());
|
321
|
}
|
322
|
CdmPreference preference = null;
|
323
|
|
324
|
if (preferenceKey == null){
|
325
|
preference = controller.getPreferenceService().find(key);
|
326
|
if (preference == null){
|
327
|
return null;
|
328
|
} else{
|
329
|
setStringValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
|
330
|
preference.getValue());
|
331
|
setBooleanValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY,preference.isAllowOverride());
|
332
|
return preference;
|
333
|
}
|
334
|
} else{
|
335
|
preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode, preferenceKey);
|
336
|
controller.getPreferenceService().set(preference);
|
337
|
|
338
|
}
|
339
|
}
|
340
|
return null;
|
341
|
|
342
|
|
343
|
|
344
|
}
|
345
|
|
346
|
public static NomenclaturalCode getPreferredNomenclaturalCode(){
|
347
|
if (getBooleanValue(OVERRIDE_NOMENCLATURAL_CODE_KEY)) {
|
348
|
return getPreferredNomenclaturalCode(true);
|
349
|
} else{
|
350
|
return getPreferredNomenclaturalCode(false);
|
351
|
}
|
352
|
}
|
353
|
|
354
|
/**
|
355
|
* <p>
|
356
|
* getPreferredNomenclaturalCode
|
357
|
* </p>
|
358
|
*
|
359
|
* @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
|
360
|
*/
|
361
|
public static NomenclaturalCode getPreferredNomenclaturalCode(boolean useLocal) {
|
362
|
|
363
|
CdmPreference pref = null;
|
364
|
if (!useLocal){
|
365
|
pref = getPreferenceFromDB(PreferencePredicate.NomenclaturalCode);
|
366
|
}
|
367
|
|
368
|
String preferredCode;
|
369
|
if(pref == null){
|
370
|
preferredCode = getStringValue(
|
371
|
PREFERRED_NOMENCLATURAL_CODE_KEY);
|
372
|
|
373
|
}else{
|
374
|
preferredCode = pref.getValue();
|
375
|
}
|
376
|
|
377
|
return getPreferredNomenclaturalCode(preferredCode);
|
378
|
|
379
|
}
|
380
|
|
381
|
/**
|
382
|
* <p>
|
383
|
* getPreferredNomenclaturalCode
|
384
|
* </p>
|
385
|
*
|
386
|
* @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
|
387
|
*/
|
388
|
public static NomenclaturalCode getPreferredNomenclaturalCode(String preferenceKeyNomenclaturalCode) {
|
389
|
|
390
|
for (NomenclaturalCode code : NomenclaturalCodeHelper.getAllCodes()) {
|
391
|
if (getPreferenceKey(code).equals(preferenceKeyNomenclaturalCode)) {
|
392
|
return code;
|
393
|
}
|
394
|
}
|
395
|
return null;
|
396
|
}
|
397
|
|
398
|
public static boolean isShowTaxonAssociations(){
|
399
|
if (getBooleanValue(SHOW_TAXON_ASSOCIATIONS_OVERRIDE) && getBooleanValue(SHOW_TAXON_ASSOCIATIONS_ALLOW_OVERRIDE)) {
|
400
|
return getBooleanValue(SHOW_TAXON_ASSOCIATIONS);
|
401
|
} else{
|
402
|
CdmPreference pref = getPreferenceFromDB(PreferencePredicate.ShowTaxonAssociations);
|
403
|
|
404
|
return pref!=null?Boolean.valueOf(pref.getValue()):false;
|
405
|
}
|
406
|
}
|
407
|
|
408
|
public static boolean isShowLifeForm(){
|
409
|
if (getBooleanValue(SHOW_LIFE_FORM_OVERRIDE) && getBooleanValue(SHOW_LIFE_FORM_ALLOW_OVERRIDE)) {
|
410
|
return getBooleanValue(SHOW_LIFE_FORM);
|
411
|
} else{
|
412
|
CdmPreference pref = getPreferenceFromDB(PreferencePredicate.ShowLifeForm);
|
413
|
|
414
|
return pref!=null?Boolean.valueOf(pref.getValue()):false;
|
415
|
}
|
416
|
}
|
417
|
|
418
|
public static boolean isDeterminationOnlyForFieldUnits(){
|
419
|
if (getBooleanValue(DETERMINATION_ONLY_FOR_FIELD_UNITS_OVERRIDE) && getBooleanValue(DETERMINATIONS_ONLY_FOR_FIELDUNITS_ALLOW_OVERRIDE)) {
|
420
|
return getBooleanValue(DETERMINATION_ONLY_FOR_FIELD_UNITS);
|
421
|
} else{
|
422
|
CdmPreference pref = getPreferenceFromDB(PreferencePredicate.DeterminationOnlyForFieldUnits);
|
423
|
|
424
|
return pref!=null?Boolean.valueOf(pref.getValue()):false;
|
425
|
}
|
426
|
}
|
427
|
|
428
|
public static boolean isCollectingAreaInGeneralSection(){
|
429
|
if (getBooleanValue(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION_OVERRIDE) && getBooleanValue(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION_ALLOW_OVERRIDE)) {
|
430
|
return getBooleanValue(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION);
|
431
|
} else{
|
432
|
CdmPreference pref = getPreferenceFromDB(PreferencePredicate.ShowCollectingAreasInGeneralSection);
|
433
|
|
434
|
return pref!=null?Boolean.valueOf(pref.getValue()):false;
|
435
|
}
|
436
|
}
|
437
|
|
438
|
public static boolean isShowSimpleDetailsView(){
|
439
|
if (getBooleanValue(OVERRIDE_NAME_DETAILS) && getBooleanValue(ALLOW_OVERRIDE_NAME_DETAILS)) {
|
440
|
return getBooleanValue(SHOW_SIMPLE_NAME_DETAILS_SECTION);
|
441
|
} else{
|
442
|
CdmPreference pref = getPreferenceFromDB(PreferencePredicate.NameDetailsView);
|
443
|
|
444
|
return pref!=null?Boolean.valueOf(pref.getValue()):false;
|
445
|
}
|
446
|
}
|
447
|
|
448
|
|
449
|
|
450
|
public static CdmPreference getPreferenceFromDB(PreferencePredicate predicate){
|
451
|
ICdmRepository controller;
|
452
|
CdmPreference pref = null;
|
453
|
|
454
|
try{
|
455
|
if(CdmStore.isActive()){
|
456
|
controller = CdmStore.getCurrentApplicationConfiguration();
|
457
|
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), predicate);
|
458
|
pref = controller.getPreferenceService().find(key);
|
459
|
}
|
460
|
}catch(Exception e){
|
461
|
e.printStackTrace();
|
462
|
}
|
463
|
|
464
|
return pref;
|
465
|
|
466
|
}
|
467
|
|
468
|
public static void setPreferenceToDB(CdmPreference preference){
|
469
|
ICdmRepository controller;
|
470
|
try{
|
471
|
if(CdmStore.isActive()){
|
472
|
controller = CdmStore.getCurrentApplicationConfiguration();
|
473
|
controller.getPreferenceService().set(preference);
|
474
|
}
|
475
|
}catch(Exception e){
|
476
|
e.printStackTrace();
|
477
|
}
|
478
|
|
479
|
}
|
480
|
|
481
|
|
482
|
|
483
|
public static String getPreferredDefaultLangugae(){
|
484
|
String preferredLanguage = getStringValue(DEFAULT_LANGUAGE_EDITOR);
|
485
|
if(StringUtils.isNotEmpty(preferredLanguage) && StringUtils.isNotBlank(preferredLanguage)){
|
486
|
return preferredLanguage;
|
487
|
}
|
488
|
return null;
|
489
|
}
|
490
|
|
491
|
public static boolean isShowMediaPreview(){
|
492
|
boolean isShowMediaPreview = getBooleanValue(SHOW_MEDIA_PREVIEW);
|
493
|
return isShowMediaPreview;
|
494
|
}
|
495
|
|
496
|
/**
|
497
|
* Get the match strategy for the given class that was stored in preferences
|
498
|
* or the default strategy if it was not stored in preferences
|
499
|
*
|
500
|
* @param clazz
|
501
|
* a {@link java.lang.Class} object.
|
502
|
* @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
|
503
|
*/
|
504
|
public static IMatchStrategy getMatchStrategy(Class<?> clazz) {
|
505
|
String className = clazz.getName();
|
506
|
if (getBooleanValue(MATCH_STRATEGY_PREFIX + className)) {
|
507
|
IMatchStrategy matchStrategy = getDefaultMatchStrategy(clazz);
|
508
|
|
509
|
//TODO CacheMatchers (or multiple field matchers in future) are missing here
|
510
|
for (FieldMatcher fieldMatcher : matchStrategy.getMatching().getFieldMatchers(false)) {
|
511
|
String fieldName = fieldMatcher.getPropertyName();
|
512
|
String matchModeName = getStringValue(
|
513
|
getMatchStrategyFieldName(className, fieldName));
|
514
|
MatchMode matchMode = MatchMode.valueOf(matchModeName);
|
515
|
try {
|
516
|
matchStrategy.setMatchMode(fieldName, matchMode);
|
517
|
} catch (MatchException e) {
|
518
|
MessagingUtils.error(PreferencesUtil.class, e);
|
519
|
throw new RuntimeException(e);
|
520
|
}
|
521
|
}
|
522
|
|
523
|
return matchStrategy;
|
524
|
}
|
525
|
return getDefaultMatchStrategy(clazz);
|
526
|
}
|
527
|
|
528
|
/**
|
529
|
* Stores a matchStrategy into the preference store.
|
530
|
*
|
531
|
* @param matchStrategy
|
532
|
* a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy}
|
533
|
* object.
|
534
|
*/
|
535
|
public static void setMatchStrategy(IMatchStrategy matchStrategy) {
|
536
|
String className = "ANY class"; //FIXME was: matchStrategy.getMatchClass().getName(); seems currently not in use
|
537
|
setBooleanValue(MATCH_STRATEGY_PREFIX + className, true);
|
538
|
|
539
|
List<FieldMatcher> fieldMatchers = matchStrategy.getMatching().getFieldMatchers(false);
|
540
|
|
541
|
for (FieldMatcher fieldMatcher : fieldMatchers) {
|
542
|
String fieldName = fieldMatcher.getPropertyName();
|
543
|
setStringValue(
|
544
|
getMatchStrategyFieldName(className, fieldName),
|
545
|
fieldMatcher.getMatchMode().name());
|
546
|
}
|
547
|
}
|
548
|
|
549
|
/**
|
550
|
* Helper method to create the preference property for a match field.
|
551
|
*
|
552
|
* @param className
|
553
|
* @param fieldName
|
554
|
* @return
|
555
|
*/
|
556
|
private static String getMatchStrategyFieldName(String className,
|
557
|
String fieldName) {
|
558
|
return MATCH_STRATEGY_PREFIX + className + "." + fieldName;
|
559
|
}
|
560
|
|
561
|
/**
|
562
|
* Returns the default match strategy for a given class.
|
563
|
*
|
564
|
* @param clazz
|
565
|
* a {@link java.lang.Class} object.
|
566
|
* @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
|
567
|
*/
|
568
|
public static IMatchStrategy getDefaultMatchStrategy(Class clazz) {
|
569
|
return DefaultMatchStrategy.NewInstance(clazz);
|
570
|
}
|
571
|
|
572
|
/**
|
573
|
* <p>
|
574
|
* getDateFormatPattern
|
575
|
* </p>
|
576
|
*
|
577
|
* @return a {@link java.lang.String} object.
|
578
|
*/
|
579
|
public static String getDateFormatPattern() {
|
580
|
// TODO make this configurable in properties
|
581
|
String pattern = "Y-M-d H:m";
|
582
|
return pattern;
|
583
|
}
|
584
|
|
585
|
/**
|
586
|
* <p>
|
587
|
* addTermToPreferredTerms
|
588
|
* </p>
|
589
|
*
|
590
|
* @param term
|
591
|
* a T object.
|
592
|
* @param <T>
|
593
|
* a T object.
|
594
|
*/
|
595
|
public static <T extends TermBase> void addTermToPreferredTerms(T term) {
|
596
|
|
597
|
// VocabularyEnum vocabulary =
|
598
|
// VocabularyEnum.getVocabularyEnum(term.getClass());
|
599
|
//
|
600
|
// getPreferenceStore().setValue(getPreferenceKey(term),
|
601
|
// VocabularyStore.getTermVocabulary(vocabulary).getTerms().contains(term));
|
602
|
//
|
603
|
// firePreferencesChanged(term.getClass());
|
604
|
}
|
605
|
|
606
|
/**
|
607
|
* Construct a unique key using the CdmBase object's uuid
|
608
|
*
|
609
|
* @param cdmBase
|
610
|
* @return
|
611
|
*/
|
612
|
private static String getPreferenceKey(ICdmBase cdmBase) {
|
613
|
cdmBase = HibernateProxyHelper.deproxy(cdmBase);
|
614
|
|
615
|
String key = cdmBase.getClass().getName().concat(".")
|
616
|
.concat(cdmBase.getUuid().toString());
|
617
|
if (key.contains("javassist")) {
|
618
|
MessagingUtils.info("proxy");
|
619
|
}
|
620
|
return key;
|
621
|
}
|
622
|
|
623
|
/**
|
624
|
* Construct a unique key using the CdmBase object's uuid
|
625
|
*
|
626
|
* @param cdmBase
|
627
|
* @return
|
628
|
*/
|
629
|
public static String getPreferenceKey(ISimpleTerm simpleTerm) {
|
630
|
simpleTerm = HibernateProxyHelper.deproxy(simpleTerm);
|
631
|
String key = simpleTerm.getClass().getName().concat(".")
|
632
|
.concat(simpleTerm.getUuid().toString());
|
633
|
if (key.contains("javassist")) {
|
634
|
MessagingUtils.warn(PreferencesUtil.class,
|
635
|
"Trying to persist a preference based on a proxy class.");
|
636
|
}
|
637
|
return key;
|
638
|
}
|
639
|
|
640
|
|
641
|
|
642
|
/**
|
643
|
* Construct a unique key using the CdmBase object's uuid
|
644
|
*
|
645
|
* @param cdmBase
|
646
|
* @return
|
647
|
*/
|
648
|
public static String getPreferenceKey(IDefinedTerm definedTerm) {
|
649
|
definedTerm = HibernateProxyHelper.deproxy(definedTerm);
|
650
|
String key = definedTerm.getClass().getName().concat(".")
|
651
|
.concat(definedTerm.getUuid().toString());
|
652
|
if (key.contains("javassist")) {
|
653
|
MessagingUtils.warn(PreferencesUtil.class,
|
654
|
"Trying to persist a preference based on a proxy class.");
|
655
|
}
|
656
|
return key;
|
657
|
}
|
658
|
|
659
|
/**
|
660
|
* Retrieves search preferences from the preference store
|
661
|
*
|
662
|
* @return an {@link ITaxonServiceConfigurator} to pass to search methods
|
663
|
*/
|
664
|
public static IFindTaxaAndNamesConfigurator getSearchConfigurator() {
|
665
|
IFindTaxaAndNamesConfigurator configurator = initializeSearchConfigurator();
|
666
|
|
667
|
configurator.setDoTaxa(getBooleanValue(
|
668
|
TAXON_SERVICE_CONFIGURATOR_TAXA));
|
669
|
configurator.setDoSynonyms(getBooleanValue(
|
670
|
TAXON_SERVICE_CONFIGURATOR_SYNONYMS));
|
671
|
configurator.setDoNamesWithoutTaxa(getBooleanValue(
|
672
|
TAXON_SERVICE_CONFIGURATOR_NAMES));
|
673
|
configurator.setDoTaxaByCommonNames(getBooleanValue(
|
674
|
TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES));
|
675
|
//configurator.setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.valueOf(getStringValue(TAXON_SERVICE_CONFIGURATOR_MATCH_MODE)));
|
676
|
|
677
|
return configurator;
|
678
|
}
|
679
|
|
680
|
/**
|
681
|
* create new preferences, setting all search options to true
|
682
|
*
|
683
|
* @return a
|
684
|
* {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
|
685
|
* object.
|
686
|
*/
|
687
|
public static IFindTaxaAndNamesConfigurator initializeSearchConfigurator() {
|
688
|
IFindTaxaAndNamesConfigurator configurator = FindTaxaAndNamesConfiguratorImpl.NewInstance();
|
689
|
|
690
|
configurator.setDoTaxa(true);
|
691
|
configurator.setDoSynonyms(true);
|
692
|
configurator.setDoNamesWithoutTaxa(true);
|
693
|
configurator.setDoTaxaByCommonNames(true);
|
694
|
|
695
|
configurator.setTaxonPropertyPath(Arrays.asList("$", "titleCache",
|
696
|
"name", "name.$", "relationsFromThisTaxon.$"));
|
697
|
|
698
|
configurator.setSynonymPropertyPath(Arrays.asList("$", "titleCache",
|
699
|
"name", "name.$", "synonyms.relatedTo.*"));
|
700
|
|
701
|
// DEFAULT VALUES
|
702
|
// match mode is a simple like, actually all other match modes are kind
|
703
|
// of bogus
|
704
|
configurator
|
705
|
.setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.ANYWHERE);
|
706
|
// we set page number and size here as this should always be unlimited
|
707
|
configurator.setPageNumber(0);
|
708
|
// TODO currently limit results to 10000
|
709
|
configurator.setPageSize(10000);
|
710
|
setSearchConfigurator(configurator) ;
|
711
|
return configurator;
|
712
|
}
|
713
|
|
714
|
/**
|
715
|
* Store search preferences
|
716
|
*
|
717
|
* @param configurator
|
718
|
* a
|
719
|
* {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
|
720
|
* object.
|
721
|
*/
|
722
|
public static void setSearchConfigurator(
|
723
|
IFindTaxaAndNamesConfigurator configurator) {
|
724
|
getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_TAXA,
|
725
|
configurator.isDoTaxa());
|
726
|
getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_SYNONYMS,
|
727
|
configurator.isDoSynonyms());
|
728
|
getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_NAMES,
|
729
|
configurator.isDoNamesWithoutTaxa());
|
730
|
getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES,
|
731
|
configurator.isDoTaxaByCommonNames());
|
732
|
}
|
733
|
|
734
|
/**
|
735
|
* <p>
|
736
|
* firePreferencesChanged
|
737
|
* </p>
|
738
|
*
|
739
|
* @param clazz
|
740
|
* a {@link java.lang.Class} object.
|
741
|
*/
|
742
|
public static void firePreferencesChanged(Class clazz) {
|
743
|
getPreferenceStore().firePropertyChangeEvent(PREFERRED_TERMS_CHANGE,
|
744
|
null, clazz);
|
745
|
}
|
746
|
|
747
|
public static String createPreferenceString(String property){
|
748
|
return prefKey(property);
|
749
|
|
750
|
}
|
751
|
|
752
|
/**
|
753
|
* Set default values for preferences
|
754
|
*/
|
755
|
public static void setDefaults() {
|
756
|
getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_TAXA, true);
|
757
|
getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_SYNONYMS,
|
758
|
true);
|
759
|
getPreferenceStore().setDefault(createPreferenceString(EDIT_MAP_SERVICE_ACCES_POINT),
|
760
|
"http://edit.africamuseum.be/edit_wp5/v1.2/rest_gen.php");
|
761
|
//FIXME : changed default for SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
|
762
|
getPreferenceStore().setDefault(createPreferenceString(SHOULD_CONNECT_AT_STARTUP), false);
|
763
|
getPreferenceStore().setDefault(createPreferenceString(OPENURL_ACCESS_POINT),
|
764
|
"http://www.biodiversitylibrary.org/openurl");
|
765
|
getPreferenceStore().setDefault(createPreferenceString(OPENURL_IMAGE_MAX_WIDTH), "1000");
|
766
|
getPreferenceStore().setDefault(createPreferenceString(OPENURL_IMAGE_MAX_HEIGHT), "1000");
|
767
|
//Distribution Editor:
|
768
|
getPreferenceStore().setDefault(createPreferenceString(DISTRIBUTION_AREA_PREFRENCES_ACTIVE), true);
|
769
|
getPreferenceStore().setDefault(createPreferenceString(CHECKLIST_AREA_DISPLAY), CHECKLIST_AREA_DISPLAY_TITLE);
|
770
|
getPreferenceStore().setDefault(createPreferenceString(CHECKLIST_SYMBOL), false);
|
771
|
|
772
|
|
773
|
//Name Details
|
774
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS), true);
|
775
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE), true);
|
776
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP), true);
|
777
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_HYBRID), true);
|
778
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_LSID), true);
|
779
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP), true);
|
780
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NAMECACHE), true);
|
781
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE), true);
|
782
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE), true);
|
783
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS), true);
|
784
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE), true);
|
785
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_RANK), true);
|
786
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION), true);
|
787
|
//Navigator preferences
|
788
|
getPreferenceStore().setDefault(createPreferenceString(SORT_NODES_NATURALLY), false);
|
789
|
getPreferenceStore().setDefault(createPreferenceString(SORT_NODES_ALPHABETICALLY), false);
|
790
|
getPreferenceStore().setDefault(createPreferenceString(SORT_TAXA_BY_RANK_AND_NAME), true);
|
791
|
//override db preferences
|
792
|
getPreferenceStore().setDefault(createPreferenceString(ABCD_IMPORT_OVERRIDE), false);
|
793
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_SPECIMEN_OVERRIDE), false);
|
794
|
getPreferenceStore().setDefault(createPreferenceString(OVERRIDE_NAME_DETAILS), false);
|
795
|
getPreferenceStore().setDefault(createPreferenceString(DISTRIBUTION_AREA_PREFRENCES_ACTIVE_OVERRIDE), false);
|
796
|
|
797
|
getPreferenceStore().setDefault(createPreferenceString(FILTER_COMMON_NAME_REFERENCES), false);
|
798
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_SPECIMEN), true);
|
799
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_TAXONNODE_WIZARD), true);
|
800
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_IN_SOURCE), true);
|
801
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_ID_IN_SOURCE), true);
|
802
|
getPreferenceStore().setDefault(createPreferenceString(DISABLE_MULTI_CLASSIFICATION), false);
|
803
|
getPreferenceStore().setDefault(createPreferenceString(DISABLE_SEC), false);
|
804
|
getPreferenceStore().setDefault(createPreferenceString(SHOW_SEC_DETAILS), true);
|
805
|
}
|
806
|
|
807
|
/**
|
808
|
* <p>
|
809
|
* checkNomenclaturalCode
|
810
|
* </p>
|
811
|
*/
|
812
|
public static void checkNomenclaturalCode() {
|
813
|
// First time Editor is opened, no nomenclatural code has been set
|
814
|
if (PreferencesUtil.getPreferredNomenclaturalCode(true) == null) {
|
815
|
PreferencesUtil.setPreferredNomenclaturalCode(getPreferenceKey(NomenclaturalCode.ICNAFP), true);
|
816
|
}
|
817
|
|
818
|
|
819
|
|
820
|
}
|
821
|
public static void setNomenclaturalCodePreferences(){
|
822
|
ICdmRepository controller;
|
823
|
controller = CdmStore.getCurrentApplicationConfiguration();
|
824
|
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
|
825
|
CdmPreference preference = null;
|
826
|
if (controller == null){
|
827
|
return ;
|
828
|
}
|
829
|
preference = controller.getPreferenceService().find(key);
|
830
|
if (preference == null){
|
831
|
return;
|
832
|
}
|
833
|
setBooleanValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY, preference.isAllowOverride());
|
834
|
|
835
|
int index = StringUtils.lastIndexOf(preference.getValue(), ".");
|
836
|
UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
|
837
|
NomenclaturalCode preferredCode = NomenclaturalCode.getByUuid(uuid);
|
838
|
|
839
|
setStringValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
|
840
|
getPreferenceKey(preferredCode));
|
841
|
|
842
|
}
|
843
|
|
844
|
public static void checkDefaultLanguage(){
|
845
|
if(PreferencesUtil.getPreferredDefaultLangugae() == null){
|
846
|
Shell shell = AbstractUtility.getShell();
|
847
|
int open = new DefaultLanguageDialog(shell).open();
|
848
|
if(open == Window.OK){
|
849
|
PlatformUI.getWorkbench().restart();
|
850
|
}
|
851
|
}else{
|
852
|
//TODO:In case of a reinstall, the config.ini will be overwritten
|
853
|
// here you create config.ini with the stored key from preferences
|
854
|
}
|
855
|
}
|
856
|
|
857
|
/**
|
858
|
* <p>
|
859
|
* getMapServiceAccessPoint
|
860
|
* </p>
|
861
|
*
|
862
|
* @return a {@link java.lang.String} object.
|
863
|
*/
|
864
|
public static String getMapServiceAccessPoint() {
|
865
|
return getStringValue(EDIT_MAP_SERVICE_ACCES_POINT);
|
866
|
}
|
867
|
|
868
|
/**
|
869
|
* <p>
|
870
|
* shouldConnectAtStartUp
|
871
|
* </p>
|
872
|
*
|
873
|
* @return a boolean.
|
874
|
*/
|
875
|
public static boolean shouldConnectAtStartUp() {
|
876
|
//FIXME : force SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
|
877
|
//return getBooleanValue(SHOULD_CONNECT_AT_STARTUP);
|
878
|
return false;
|
879
|
}
|
880
|
|
881
|
/**
|
882
|
* <p>
|
883
|
* getDefaultFeatureTreeForTextualDescription
|
884
|
* </p>
|
885
|
*
|
886
|
* @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
|
887
|
*/
|
888
|
public static FeatureTree getDefaultFeatureTreeForTextualDescription() {
|
889
|
String uuidString = getStringValue(
|
890
|
FEATURE_TREE_DEFAULT_TEXT);
|
891
|
return CdmUtils.isEmpty(uuidString) ? null : CdmStore.getService(
|
892
|
IFeatureTreeService.class).load(UUID.fromString(uuidString));
|
893
|
}
|
894
|
|
895
|
/**
|
896
|
* <p>
|
897
|
* getDefaultFeatureTreeForStructuredDescription
|
898
|
* </p>
|
899
|
*
|
900
|
* @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
|
901
|
*/
|
902
|
public static FeatureTree getDefaultFeatureTreeForStructuredDescription() {
|
903
|
String uuidString = getStringValue(
|
904
|
FEATURE_TREE_DEFAULT_STRUCTURE);
|
905
|
return CdmUtils.isEmpty(uuidString) ? null : CdmStore.getService(
|
906
|
IFeatureTreeService.class).load(UUID.fromString(uuidString));
|
907
|
}
|
908
|
|
909
|
/**
|
910
|
* <p>
|
911
|
* setSortRanksHierarchichally
|
912
|
* </p>
|
913
|
*
|
914
|
* @param selection
|
915
|
* a boolean.
|
916
|
*/
|
917
|
public static void setSortRanksHierarchichally(boolean selection) {
|
918
|
setBooleanValue(SORT_RANKS_HIERARCHICHALLY, selection);
|
919
|
}
|
920
|
|
921
|
/**
|
922
|
* <p>
|
923
|
* getSortRanksHierarchichally
|
924
|
* </p>
|
925
|
*
|
926
|
* @return a boolean.
|
927
|
*/
|
928
|
public static boolean getSortRanksHierarchichally() {
|
929
|
return getBooleanValue(SORT_RANKS_HIERARCHICHALLY);
|
930
|
}
|
931
|
|
932
|
public static boolean isMultilanguageTextEditingCapability() {
|
933
|
return getBooleanValue(
|
934
|
MULTILANGUAGE_TEXT_EDITING_CAPABILITY);
|
935
|
}
|
936
|
|
937
|
public static Language getGlobalLanguage() {
|
938
|
|
939
|
|
940
|
String languageUuidString = getStringValue(
|
941
|
GLOBAL_LANGUAGE_UUID);
|
942
|
|
943
|
if(!CdmStore.isActive()) {
|
944
|
MessagingUtils.noDataSourceWarningDialog(languageUuidString);
|
945
|
return null;
|
946
|
}
|
947
|
|
948
|
if (CdmUtils.isBlank(languageUuidString)) {
|
949
|
return Language.getDefaultLanguage();
|
950
|
}
|
951
|
|
952
|
UUID languageUuid = UUID.fromString(languageUuidString);
|
953
|
return (Language) CdmStore.getService(ITermService.class).load(
|
954
|
languageUuid);
|
955
|
}
|
956
|
|
957
|
public static void setGlobalLanguage(Language language) {
|
958
|
if(language != null) {
|
959
|
setStringValue(GLOBAL_LANGUAGE_UUID,language.getUuid().toString());
|
960
|
CdmStore.setDefaultLanguage(language);
|
961
|
}
|
962
|
|
963
|
}
|
964
|
|
965
|
/**
|
966
|
* @return
|
967
|
*/
|
968
|
public static Map<MarkerType, Boolean> getEditMarkerTypePreferences() {
|
969
|
List<MarkerType> markerTypes = CdmStore.getTermManager()
|
970
|
.getPreferredTerms(MarkerType.class);
|
971
|
|
972
|
Map<MarkerType, Boolean> result = new HashMap<MarkerType, Boolean>();
|
973
|
|
974
|
for (MarkerType markerType : markerTypes) {
|
975
|
String name = getMarkerTypeEditingPreferenceKey(markerType);
|
976
|
Boolean value = getBooleanValue(name);
|
977
|
|
978
|
result.put(markerType, value);
|
979
|
}
|
980
|
|
981
|
return result;
|
982
|
}
|
983
|
|
984
|
/**
|
985
|
* @param markerTypeEditingMap
|
986
|
*/
|
987
|
public static void setEditMarkerTypePreferences(
|
988
|
Map<MarkerType, Boolean> markerTypeEditingMap) {
|
989
|
for (MarkerType markerType : markerTypeEditingMap.keySet()) {
|
990
|
String name = getMarkerTypeEditingPreferenceKey(markerType);
|
991
|
setBooleanValue(name,
|
992
|
markerTypeEditingMap.get(markerType));
|
993
|
}
|
994
|
|
995
|
}
|
996
|
|
997
|
private static String getMarkerTypeEditingPreferenceKey(
|
998
|
MarkerType markerType) {
|
999
|
markerType = HibernateProxyHelper.deproxy(markerType);
|
1000
|
return markerType.getClass().getName() + EDIT_MARKER_TYPE_PREFIX;
|
1001
|
}
|
1002
|
|
1003
|
/**
|
1004
|
* <p>
|
1005
|
* setEditMarkerTypePreference
|
1006
|
* </p>
|
1007
|
*
|
1008
|
* @param input
|
1009
|
* a {@link org.eclipse.ui.IEditorInput} object.
|
1010
|
* @param markerType
|
1011
|
* a {@link eu.etaxonomy.cdm.model.common.MarkerType} object.
|
1012
|
* @param edit
|
1013
|
* a boolean.
|
1014
|
*/
|
1015
|
public static void setEditMarkerTypePreference(MarkerType markerType,
|
1016
|
boolean edit) {
|
1017
|
setBooleanValue(
|
1018
|
getMarkerTypeEditingPreferenceKey(markerType), edit);
|
1019
|
}
|
1020
|
|
1021
|
/**
|
1022
|
* @return
|
1023
|
*/
|
1024
|
public static DerivedUnitFacadeConfigurator getDerivedUnitConfigurator() {
|
1025
|
DerivedUnitFacadeConfigurator configurator = DerivedUnitFacadeConfigurator
|
1026
|
.NewInstance();
|
1027
|
configurator.setMoveDerivedUnitMediaToGallery(true);
|
1028
|
configurator.setMoveFieldObjectMediaToGallery(true);
|
1029
|
return configurator;
|
1030
|
}
|
1031
|
|
1032
|
/**
|
1033
|
* This method will write language properties to the config.ini located in the configuration folder
|
1034
|
* of the Taxonomic Ediitor. <b>This method is only used to set the default language for Taxonomic Editor.</b>
|
1035
|
*
|
1036
|
* @param setLanguage 0 is for german and 1 for english.
|
1037
|
* @throws IOException
|
1038
|
*/
|
1039
|
public void writePropertyToConfigFile(int setLanguage) throws IOException {
|
1040
|
File file = org.eclipse.core.runtime.preferences.ConfigurationScope.INSTANCE.getLocation().toFile();
|
1041
|
//give warning to user if the directory has no write access
|
1042
|
if(file == null){
|
1043
|
throw new IOException();
|
1044
|
}
|
1045
|
Properties properties = load(file.getAbsolutePath()+"/config.ini");
|
1046
|
switch(setLanguage){
|
1047
|
case 0:
|
1048
|
properties.setProperty("osgi.nl", "de");
|
1049
|
setStringValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "de");
|
1050
|
break;
|
1051
|
case 1:
|
1052
|
properties.setProperty("osgi.nl", "en");
|
1053
|
setStringValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "en");
|
1054
|
break;
|
1055
|
default:
|
1056
|
break;
|
1057
|
}
|
1058
|
save(file+"/config.ini", properties);
|
1059
|
}
|
1060
|
|
1061
|
/**
|
1062
|
* This method loads a property from a given file and returns it.
|
1063
|
*
|
1064
|
* @param filename
|
1065
|
* @return
|
1066
|
* @throws IOException
|
1067
|
*/
|
1068
|
private Properties load(String filename) throws IOException {
|
1069
|
FileInputStream in = new FileInputStream(filename);
|
1070
|
Properties prop = new Properties();
|
1071
|
prop.load(in);
|
1072
|
in.close();
|
1073
|
return prop;
|
1074
|
}
|
1075
|
|
1076
|
/**
|
1077
|
* This method saves a property to the specified file.
|
1078
|
*
|
1079
|
* @param filename
|
1080
|
* @param properties
|
1081
|
* @throws IOException
|
1082
|
*/
|
1083
|
private void save(String filename, Properties properties) throws IOException{
|
1084
|
FileOutputStream fos = new FileOutputStream(filename);
|
1085
|
properties.store(fos, "");
|
1086
|
fos.close();
|
1087
|
}
|
1088
|
|
1089
|
/**
|
1090
|
* Saves a list of P2 Metadata Repositories as string with specified delimiters
|
1091
|
*
|
1092
|
* @param p2Repos
|
1093
|
*/
|
1094
|
public static void setP2Repositories(List<MetadataRepositoryElement> p2Repos) {
|
1095
|
StringBuilder sb = new StringBuilder();
|
1096
|
for(MetadataRepositoryElement p2Repo : p2Repos) {
|
1097
|
sb.append(P2_REPOSITORIES_DELIM);
|
1098
|
if(p2Repo.getName() == null || p2Repo.getName().isEmpty()) {
|
1099
|
sb.append("-");
|
1100
|
} else {
|
1101
|
sb.append(p2Repo.getName());
|
1102
|
}
|
1103
|
sb.append(P2_REPOSITORY_FIELDS_DELIM);
|
1104
|
sb.append(p2Repo.getLocation().toString());
|
1105
|
sb.append(P2_REPOSITORY_FIELDS_DELIM);
|
1106
|
sb.append(String.valueOf(p2Repo.isEnabled()));
|
1107
|
}
|
1108
|
getPreferenceStore().setValue(P2_REPOSITORY_LIST, sb.toString());
|
1109
|
}
|
1110
|
|
1111
|
|
1112
|
/**
|
1113
|
* Retrieves a list of previously saved P2 repositories
|
1114
|
*
|
1115
|
* @return
|
1116
|
*/
|
1117
|
public static List<MetadataRepositoryElement> getP2Repositories() {
|
1118
|
List<MetadataRepositoryElement> p2Repos = new ArrayList<MetadataRepositoryElement>();
|
1119
|
String p2ReposPref = getStringValue(P2_REPOSITORY_LIST);
|
1120
|
if(p2ReposPref != null && !p2ReposPref.isEmpty()) {
|
1121
|
StringTokenizer p2ReposPrefST = new StringTokenizer(p2ReposPref,P2_REPOSITORIES_DELIM);
|
1122
|
|
1123
|
while(p2ReposPrefST.hasMoreTokens()) {
|
1124
|
String p2RepoStr = p2ReposPrefST.nextToken();
|
1125
|
StringTokenizer p2ReposStrST = new StringTokenizer(p2RepoStr,P2_REPOSITORY_FIELDS_DELIM);
|
1126
|
if(p2ReposStrST.countTokens()==3) {
|
1127
|
String nickname = p2ReposStrST.nextToken();
|
1128
|
URI uri = null;
|
1129
|
try {
|
1130
|
uri = new URI(p2ReposStrST.nextToken());
|
1131
|
} catch (URISyntaxException e) {
|
1132
|
continue;
|
1133
|
}
|
1134
|
boolean enabled = Boolean.parseBoolean(p2ReposStrST.nextToken());
|
1135
|
MetadataRepositoryElement mre = new MetadataRepositoryElement(null, uri, true);
|
1136
|
mre.setNickname(nickname);
|
1137
|
mre.setEnabled(enabled);
|
1138
|
p2Repos.add(mre);
|
1139
|
}
|
1140
|
}
|
1141
|
}
|
1142
|
|
1143
|
return p2Repos;
|
1144
|
}
|
1145
|
|
1146
|
/**
|
1147
|
* enables/disables nested composite. <br>
|
1148
|
*
|
1149
|
* @param ctrl - Composite to be en-/disabeld
|
1150
|
* @param enabled - boolean
|
1151
|
*/
|
1152
|
public static void recursiveSetEnabled(Control ctrl, boolean enabled) {
|
1153
|
if (ctrl instanceof Composite) {
|
1154
|
Composite comp = (Composite) ctrl;
|
1155
|
for (Control c : comp.getChildren()) {
|
1156
|
recursiveSetEnabled(c, enabled);
|
1157
|
}
|
1158
|
} else {
|
1159
|
ctrl.setEnabled(enabled);
|
1160
|
}
|
1161
|
}
|
1162
|
|
1163
|
/**
|
1164
|
* <p>
|
1165
|
* getSortRanksNaturally
|
1166
|
* </p>
|
1167
|
*
|
1168
|
* @return a boolean.
|
1169
|
*/
|
1170
|
public static boolean getSortNodesNaturally() {
|
1171
|
return getBooleanValue(SORT_NODES_NATURALLY);
|
1172
|
}
|
1173
|
|
1174
|
/**
|
1175
|
* <p>
|
1176
|
* setSortRanksNaturally
|
1177
|
* </p>
|
1178
|
*
|
1179
|
* @param selection
|
1180
|
* a boolean.
|
1181
|
*/
|
1182
|
public static void setSortNodesNaturally(boolean selection) {
|
1183
|
setBooleanValue(SORT_NODES_NATURALLY, selection);
|
1184
|
}
|
1185
|
|
1186
|
|
1187
|
/**
|
1188
|
* <p>
|
1189
|
* getSortRanksNaturally
|
1190
|
* </p>
|
1191
|
*
|
1192
|
* @return a boolean.
|
1193
|
*/
|
1194
|
public static boolean getSortNodesStrictlyAlphabetically() {
|
1195
|
return getBooleanValue(SORT_NODES_ALPHABETICALLY);
|
1196
|
}
|
1197
|
|
1198
|
/**
|
1199
|
* <p>
|
1200
|
* setSortRanksNaturally
|
1201
|
* </p>
|
1202
|
*
|
1203
|
* @param selection
|
1204
|
* a boolean.
|
1205
|
*/
|
1206
|
public static void setSortNodesStrictlyAlphabetically(boolean selection) {
|
1207
|
setBooleanValue(SORT_NODES_ALPHABETICALLY, selection);
|
1208
|
}
|
1209
|
|
1210
|
/**
|
1211
|
* <p>
|
1212
|
* setStoreNavigatorState
|
1213
|
* </p>
|
1214
|
*
|
1215
|
* @param selection
|
1216
|
* a boolean.
|
1217
|
*/
|
1218
|
public static boolean isStoreNavigatorState() {
|
1219
|
return getBooleanValue(RESTORE_NAVIGATOR_STATE);
|
1220
|
|
1221
|
}
|
1222
|
|
1223
|
/**
|
1224
|
* <p>
|
1225
|
* setStoreNavigatorState
|
1226
|
* </p>
|
1227
|
*
|
1228
|
* @param selection
|
1229
|
* a boolean.
|
1230
|
*/
|
1231
|
public static void setStoreNavigatorState(boolean selection) {
|
1232
|
setBooleanValue(RESTORE_NAVIGATOR_STATE, selection);
|
1233
|
|
1234
|
}
|
1235
|
|
1236
|
/**
|
1237
|
* @return
|
1238
|
*/
|
1239
|
public static boolean isShowUpWidgetIsDisposedMessages() {
|
1240
|
return getBooleanValue(IS_SHOW_UP_WIDGET_IS_DISPOSED);
|
1241
|
}
|
1242
|
public static void setShowUpWidgetIsDisposedMessages(boolean selection) {
|
1243
|
setBooleanValue(IS_SHOW_UP_WIDGET_IS_DISPOSED, selection);
|
1244
|
}
|
1245
|
|
1246
|
/**
|
1247
|
* @return
|
1248
|
*/
|
1249
|
public static boolean isShowIdInVocabularyInChecklistEditor() {
|
1250
|
String area_display = getStringValue(IPreferenceKeys.CHECKLIST_AREA_DISPLAY);
|
1251
|
if (area_display.equals(CHECKLIST_AREA_DISPLAY_ID_IN_VOCABULARY)) {
|
1252
|
return true;
|
1253
|
}else{
|
1254
|
return false;
|
1255
|
}
|
1256
|
}
|
1257
|
public static boolean isShowSymbol1InChecklistEditor() {
|
1258
|
String area_display = getStringValue(IPreferenceKeys.CHECKLIST_AREA_DISPLAY);
|
1259
|
if (area_display.equals(CHECKLIST_AREA_DISPLAY_SYMBOL1)) {
|
1260
|
return true;
|
1261
|
}else{
|
1262
|
return false;
|
1263
|
}
|
1264
|
}
|
1265
|
public static boolean isShowSymbol2InChecklistEditor() {
|
1266
|
String area_display = getStringValue(IPreferenceKeys.CHECKLIST_AREA_DISPLAY);
|
1267
|
if (area_display.equals(CHECKLIST_AREA_DISPLAY_SYMBOL2)) {
|
1268
|
return true;
|
1269
|
}else{
|
1270
|
return false;
|
1271
|
}
|
1272
|
}
|
1273
|
public static void setShowIdInVocabularyInChecklistEditor(String selection) {
|
1274
|
setStringValue(CHECKLIST_AREA_DISPLAY, selection);
|
1275
|
}
|
1276
|
|
1277
|
/**
|
1278
|
* @return
|
1279
|
*/
|
1280
|
public static boolean isShowSymbolInChecklistEditor() {
|
1281
|
return getBooleanValue(IPreferenceKeys.CHECKLIST_SYMBOL);
|
1282
|
}
|
1283
|
public static void setShowSymbolInChecklistEditor(boolean selection) {
|
1284
|
setBooleanValue(CHECKLIST_SYMBOL, selection);
|
1285
|
}
|
1286
|
|
1287
|
/**
|
1288
|
* @return
|
1289
|
*/
|
1290
|
public static boolean isShowRankInChecklistEditor() {
|
1291
|
return getBooleanValue(IPreferenceKeys.CHECKLIST_SHOW_RANK);
|
1292
|
}
|
1293
|
public static void setShowRankInChecklistEditor(boolean selection) {
|
1294
|
setBooleanValue(CHECKLIST_SHOW_RANK, selection);
|
1295
|
}
|
1296
|
|
1297
|
/**
|
1298
|
* @param object
|
1299
|
* @param b
|
1300
|
* @return
|
1301
|
*/
|
1302
|
public static NameDetailsConfigurator getPreferredNameDetailsConfiguration( boolean local) {
|
1303
|
NameDetailsConfigurator config = new NameDetailsConfigurator(true);
|
1304
|
|
1305
|
CdmPreference preference = null;
|
1306
|
|
1307
|
if (!local) {
|
1308
|
preference = getPreferenceFromDB(PreferencePredicate.NameDetailsView);
|
1309
|
if (preference == null){
|
1310
|
return null;
|
1311
|
}
|
1312
|
|
1313
|
setBooleanValue(ALLOW_OVERRIDE_NAME_DETAILS, preference.isAllowOverride());
|
1314
|
|
1315
|
//the preference value is build like this:
|
1316
|
//<section1>:true;<section2>:false....
|
1317
|
|
1318
|
String value = preference.getValue();
|
1319
|
String [] sections = value.split(";");
|
1320
|
Map<String, Boolean> sectionMap = new HashMap<String, Boolean>();
|
1321
|
String[] sectionValues;
|
1322
|
for (String sectionValue: sections){
|
1323
|
sectionValues = sectionValue.split(":");
|
1324
|
sectionMap.put(sectionValues[0], Boolean.valueOf(sectionValues[1]));
|
1325
|
}
|
1326
|
config.setAllowOverride(preference.isAllowOverride());
|
1327
|
config.setSimpleDetailsViewActivated(getValue(sectionMap, "simpleViewActivated"));
|
1328
|
|
1329
|
// getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON,
|
1330
|
// (getValue(sectionMap, "taxon")));
|
1331
|
config.setTaxonSectionActivated(getValue(sectionMap, "taxon"));
|
1332
|
|
1333
|
config.setSecDetailsActivated(getValue(sectionMap, "taxon.SecEnabled"));
|
1334
|
config.setSecEnabled(getValue(sectionMap, "taxon.SecDetails"));
|
1335
|
|
1336
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID,
|
1337
|
// (getValue(sectionMap, "lsid")));
|
1338
|
config.setLSIDActivated(getValue(sectionMap, "lsid"));
|
1339
|
|
1340
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
|
1341
|
// (getValue(sectionMap, "nc")));
|
1342
|
config.setNomenclaturalCodeActived(getValue(sectionMap, "nc"));
|
1343
|
|
1344
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
|
1345
|
// (getValue(sectionMap, "ap")));
|
1346
|
config.setAppendedPhraseActivated(getValue(sectionMap, "ap"));
|
1347
|
|
1348
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK,
|
1349
|
// (getValue(sectionMap, "rank")));
|
1350
|
config.setRankActivated(getValue(sectionMap, "rank"));
|
1351
|
|
1352
|
|
1353
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
|
1354
|
// (getValue(sectionMap, "atomisedEpithets")));
|
1355
|
config.setAtomisedEpithetsActivated(getValue(sectionMap, "atomisedEpithets"));
|
1356
|
|
1357
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
|
1358
|
// (getValue(sectionMap,"author")));
|
1359
|
config.setAuthorshipSectionActivated(getValue(sectionMap,"author"));
|
1360
|
|
1361
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
|
1362
|
// (getValue(sectionMap, "nomRef")));
|
1363
|
config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
|
1364
|
|
1365
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
|
1366
|
// (getValue(sectionMap, "nomStat")));
|
1367
|
config.setNomenclaturalStatusSectionActivated(getValue(sectionMap, "nomStat"));
|
1368
|
|
1369
|
|
1370
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
|
1371
|
// (getValue(sectionMap,"protologue")));
|
1372
|
config.setProtologueActivated(getValue(sectionMap,"protologue"));
|
1373
|
|
1374
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
|
1375
|
// (getValue(sectionMap,"typeDes")));
|
1376
|
config.setTypeDesignationSectionActivated(getValue(sectionMap,"typeDes"));
|
1377
|
|
1378
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
|
1379
|
// (getValue(sectionMap,"nameRelation")));
|
1380
|
config.setNameRelationsSectionActivated(getValue(sectionMap,"nameRelation"));
|
1381
|
|
1382
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_HYBRID,
|
1383
|
// (getValue(sectionMap, "hybrid")));
|
1384
|
config.setHybridActivated(getValue(sectionMap,"hybrid"));
|
1385
|
}else{
|
1386
|
config.setSimpleDetailsViewActivated(getBooleanValue(SHOW_SIMPLE_NAME_DETAILS_SECTION));
|
1387
|
config.setTaxonSectionActivated(getBooleanValue(SHOW_SIMPLE_NAME_DETAILS_TAXON));
|
1388
|
config.setSecDetailsActivated(getBooleanValue(SHOW_SEC_DETAILS));
|
1389
|
config.setSecEnabled(getBooleanValue(DISABLE_SEC));
|
1390
|
config.setLSIDActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_LSID));
|
1391
|
config.setNomenclaturalCodeActived(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE));
|
1392
|
config.setAppendedPhraseActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE));
|
1393
|
config.setRankActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_RANK));
|
1394
|
config.setAtomisedEpithetsActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS));
|
1395
|
config.setAuthorshipSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP));
|
1396
|
config.setNomenclaturalReferenceSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE));
|
1397
|
config.setNomenclaturalStatusSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS));
|
1398
|
config.setProtologueActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE));
|
1399
|
config.setTypeDesignationSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION));
|
1400
|
config.setNameRelationsSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP));
|
1401
|
config.setHybridActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_HYBRID));
|
1402
|
}
|
1403
|
return config;
|
1404
|
}
|
1405
|
|
1406
|
/**
|
1407
|
* @param object
|
1408
|
* @param b
|
1409
|
* @return
|
1410
|
*/
|
1411
|
public static void setPreferredNameDetailsConfiguration(NameDetailsConfigurator config, boolean local) {
|
1412
|
CdmPreference preference = null;
|
1413
|
|
1414
|
if (!local) {
|
1415
|
preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NameDetailsView, config.toString());
|
1416
|
|
1417
|
setPreferenceToDB(preference);
|
1418
|
}
|
1419
|
//also add to local preferences
|
1420
|
setBooleanValue(SHOW_SIMPLE_NAME_DETAILS_SECTION, config.isSimpleDetailsViewActivated());
|
1421
|
setBooleanValue(SHOW_SIMPLE_NAME_DETAILS_TAXON, config.isTaxonSectionActivated());
|
1422
|
setBooleanValue(SHOW_SEC_DETAILS, config.isSecDetailsActivated());
|
1423
|
setBooleanValue(DISABLE_SEC, config.isSecEnabled());
|
1424
|
setBooleanValue(SHOW_NAME_DETAILS_SECTION_LSID, config.isLSIDActivated());
|
1425
|
setBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, config.isNomenclaturalCodeActived());
|
1426
|
setBooleanValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE, config.isAppendedPhraseActivated());
|
1427
|
setBooleanValue(SHOW_NAME_DETAILS_SECTION_RANK, config.isRankActivated());
|
1428
|
setBooleanValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, config.isAtomisedEpithetsActivated());
|
1429
|
setBooleanValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, config.isAuthorshipSectionActivated());
|
1430
|
setBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, config.isNomenclaturalReferenceSectionActivated());
|
1431
|
setBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, config.isNomenclaturalStatusSectionActivated());
|
1432
|
setBooleanValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, config.isProtologueActivated());
|
1433
|
setBooleanValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, config.isTypeDesignationSectionActivated());
|
1434
|
setBooleanValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, config.isNameRelationsSectionActivated());
|
1435
|
setBooleanValue(SHOW_NAME_DETAILS_SECTION_HYBRID, config.isHybridActivated());
|
1436
|
|
1437
|
}
|
1438
|
|
1439
|
private static Boolean getValue(Map<String, Boolean> sectionMap, String string) {
|
1440
|
if (sectionMap.containsKey(string)){
|
1441
|
return sectionMap.get(string);
|
1442
|
}else{
|
1443
|
return true;
|
1444
|
}
|
1445
|
|
1446
|
}
|
1447
|
|
1448
|
|
1449
|
|
1450
|
/**
|
1451
|
* <p>
|
1452
|
* setAbcdConfigurator
|
1453
|
* </p>
|
1454
|
*
|
1455
|
* @param preferredConfiguration
|
1456
|
* a {@link eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator}
|
1457
|
* object.
|
1458
|
*/
|
1459
|
public static Abcd206ImportConfigurator getAbcdImportConfigurationPreference() {
|
1460
|
|
1461
|
Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
|
1462
|
ICdmRepository controller;
|
1463
|
controller = CdmStore.getCurrentApplicationConfiguration();
|
1464
|
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AbcdImportConfig);
|
1465
|
CdmPreference preference = null;
|
1466
|
if (controller == null){
|
1467
|
return null;
|
1468
|
}
|
1469
|
preference = controller.getPreferenceService().find(key);
|
1470
|
boolean allowOverride = true;
|
1471
|
if (preference != null && !preference.isAllowOverride()){
|
1472
|
allowOverride = false;
|
1473
|
}
|
1474
|
if (getBooleanValue(IPreferenceKeys.ABCD_IMPORT_OVERRIDE) && allowOverride){
|
1475
|
|
1476
|
config.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS));
|
1477
|
|
1478
|
config.setAddMediaAsMediaSpecimen(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN));
|
1479
|
|
1480
|
config.setAllowReuseOtherClassifications(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS));
|
1481
|
config.setDeduplicateClassifications(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS));
|
1482
|
config.setDeduplicateReferences(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES));
|
1483
|
|
1484
|
config.setGetSiblings(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS));
|
1485
|
config.setIgnoreAuthorship(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP));
|
1486
|
config.setIgnoreImportOfExistingSpecimen(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN));
|
1487
|
config.setMapUnitIdToAccessionNumber(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER));
|
1488
|
config.setMapUnitIdToBarcode(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE));
|
1489
|
config.setMapUnitIdToCatalogNumber(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER));
|
1490
|
config.setMoveNewTaxaToDefaultClassification(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION));
|
1491
|
config.setOverwriteExistingSpecimens(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN));
|
1492
|
config.setReuseExistingDescriptiveGroups(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS));
|
1493
|
config.setReuseExistingMetaData(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA));
|
1494
|
config.setReuseExistingTaxaWhenPossible(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE));
|
1495
|
config.setNomenclaturalCode(NomenclaturalCode.getByKey(getStringValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE)));
|
1496
|
return config;
|
1497
|
|
1498
|
}
|
1499
|
|
1500
|
if (preference == null){
|
1501
|
return config;
|
1502
|
} else{
|
1503
|
String configString = preference.getValue();
|
1504
|
String[] configArray = configString.split(";");
|
1505
|
|
1506
|
for (String configItem: configArray){
|
1507
|
String[] keyValue = configItem.split(":");
|
1508
|
String keyString = keyValue[0];
|
1509
|
String valueString = keyValue[1];
|
1510
|
if (keyString.equals("ignoreImportOfExistingSpecimen")){
|
1511
|
config.setIgnoreImportOfExistingSpecimen(Boolean.valueOf(valueString));
|
1512
|
}else if (keyString.equals("addIndividualsAssociationsSuchAsSpecimenAndObservations")){
|
1513
|
config.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(Boolean.valueOf(valueString));
|
1514
|
}else if (keyString.equals("reuseExistingTaxaWhenPossible")){
|
1515
|
config.setReuseExistingTaxaWhenPossible(Boolean.valueOf(valueString));
|
1516
|
}else if (keyString.equals("ignoreAuthorship")){
|
1517
|
config.setIgnoreAuthorship(Boolean.valueOf(valueString));
|
1518
|
}else if (keyString.equals("addMediaAsMediaSpecimen")){
|
1519
|
config.setAddMediaAsMediaSpecimen(Boolean.valueOf(valueString));
|
1520
|
}else if (keyString.equals("reuseExistingMetaData")){
|
1521
|
config.setReuseExistingMetaData(Boolean.valueOf(valueString));
|
1522
|
}else if (keyString.equals("reuseExistingDescriptiveGroups")){
|
1523
|
config.setReuseExistingDescriptiveGroups(Boolean.valueOf(valueString));
|
1524
|
}else if (keyString.equals("allowReuseOtherClassifications")){
|
1525
|
config.setAllowReuseOtherClassifications(Boolean.valueOf(valueString));
|
1526
|
}else if (keyString.equals("deduplicateReferences")){
|
1527
|
config.setDeduplicateReferences(Boolean.valueOf(valueString));
|
1528
|
}else if (keyString.equals("deduplicateClassifications")){
|
1529
|
config.setDeduplicateClassifications(Boolean.valueOf(valueString));
|
1530
|
}else if (keyString.equals("moveNewTaxaToDefaultClassification")){
|
1531
|
config.setMoveNewTaxaToDefaultClassification(Boolean.valueOf(valueString));
|
1532
|
}else if (keyString.equals("mapUnitIdToCatalogNumber")){
|
1533
|
config.setMapUnitIdToCatalogNumber(Boolean.valueOf(valueString));
|
1534
|
}else if (keyString.equals("mapUnitIdToAccessionNumber")){
|
1535
|
config.setMapUnitIdToAccessionNumber(Boolean.valueOf(valueString));
|
1536
|
}else if (keyString.equals("mapUnitIdToBarcode")){
|
1537
|
config.setMapUnitIdToBarcode(Boolean.valueOf(valueString));
|
1538
|
}else if (keyString.equals("overwriteExistingSpecimens")){
|
1539
|
config.setOverwriteExistingSpecimens(Boolean.valueOf(valueString));
|
1540
|
}else if (keyString.equals("nomenclaturalCode")){
|
1541
|
config.setNomenclaturalCode(NomenclaturalCode.fromString(valueString));
|
1542
|
}else{
|
1543
|
logger.debug("This key of the abcd configurator needs to be added to the transformer: " + keyString);
|
1544
|
}
|
1545
|
|
1546
|
}
|
1547
|
}
|
1548
|
return config;
|
1549
|
}
|
1550
|
|
1551
|
|
1552
|
public static void updateAbcdImportConfigurationPreference() {
|
1553
|
|
1554
|
Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
|
1555
|
ICdmRepository controller;
|
1556
|
controller = CdmStore.getCurrentApplicationConfiguration();
|
1557
|
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AbcdImportConfig);
|
1558
|
CdmPreference preference = null;
|
1559
|
if (controller == null){
|
1560
|
return ;
|
1561
|
}
|
1562
|
preference = controller.getPreferenceService().find(key);
|
1563
|
boolean allowOverride = true;
|
1564
|
if (preference != null && !preference.isAllowOverride()){
|
1565
|
allowOverride = false;
|
1566
|
}
|
1567
|
if (!getBooleanValue(IPreferenceKeys.ABCD_IMPORT_OVERRIDE) || !allowOverride){
|
1568
|
|
1569
|
setBooleanValue(ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS, config.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
|
1570
|
setBooleanValue(ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN, config.isAddMediaAsMediaSpecimen());
|
1571
|
|
1572
|
setBooleanValue(ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS, config.isAllowReuseOtherClassifications());
|
1573
|
setBooleanValue(ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS, config.isDeduplicateClassifications());
|
1574
|
setBooleanValue(ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES, config.isDeduplicateReferences());
|
1575
|
|
1576
|
setBooleanValue(ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS, config.isGetSiblings());
|
1577
|
setBooleanValue(ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP, config.isIgnoreAuthorship());
|
1578
|
setBooleanValue(ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN, config.isIgnoreImportOfExistingSpecimen());
|
1579
|
setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER, config.isMapUnitIdToAccessionNumber());
|
1580
|
setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE, config.isMapUnitIdToBarcode());
|
1581
|
setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER, config.isMapUnitIdToCatalogNumber());
|
1582
|
setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION, config.isMoveNewTaxaToDefaultClassification());
|
1583
|
setBooleanValue(ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN, config.isOverwriteExistingSpecimens());
|
1584
|
setBooleanValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS, config.isReuseExistingDescriptiveGroups());
|
1585
|
setBooleanValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA, config.isReuseExistingMetaData());
|
1586
|
setBooleanValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE, config.isReuseExistingTaxaWhenPossible());
|
1587
|
if (config.getNomenclaturalCode() != null){
|
1588
|
setStringValue(ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE, config.getNomenclaturalCode().getKey());
|
1589
|
}
|
1590
|
}
|
1591
|
}
|
1592
|
|
1593
|
|
1594
|
/**
|
1595
|
*
|
1596
|
*/
|
1597
|
public NameDetailsConfigurator createLocalNameDetailsViewConfig(boolean local) {
|
1598
|
NameDetailsConfigurator config = new NameDetailsConfigurator(true);
|
1599
|
if (local){
|
1600
|
config.setSimpleDetailsViewActivated(getBooleanValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION));
|
1601
|
config.setAppendedPhraseActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE));
|
1602
|
config.setAtomisedEpithetsActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS));
|
1603
|
config.setAuthorshipSectionActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP));
|
1604
|
config.setLSIDActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID));
|
1605
|
config.setNameApprobiationActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION));
|
1606
|
config.setNameCacheActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_CACHE));
|
1607
|
config.setNameRelationsSectionActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP));
|
1608
|
config.setNomenclaturalCodeActived(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE));
|
1609
|
config.setNomenclaturalStatusSectionActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS));
|
1610
|
config.setNomenclaturalReferenceSectionActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE));
|
1611
|
config.setProtologueActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE));
|
1612
|
config.setRankActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK));
|
1613
|
config.setTaxonSectionActivated(getBooleanValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON));
|
1614
|
config.setTypeDesignationSectionActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION));
|
1615
|
config.setHybridActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID));
|
1616
|
}else{
|
1617
|
|
1618
|
}
|
1619
|
|
1620
|
return config;
|
1621
|
}
|
1622
|
|
1623
|
|
1624
|
public static void saveConfigToPrefernceStore(NameDetailsConfigurator config) {
|
1625
|
setBooleanValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION,
|
1626
|
config.isSimpleDetailsViewActivated());
|
1627
|
setBooleanValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON, config.isTaxonSectionActivated());
|
1628
|
setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID, config.isLSIDActivated());
|
1629
|
setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
|
1630
|
config.isNomenclaturalCodeActived());
|
1631
|
setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE,
|
1632
|
config.isNameCacheActivated());
|
1633
|
setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
|
1634
|
config.isAppendedPhraseActivated());
|
1635
|
setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK, config.isRankActivated());
|
1636
|
setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
|
1637
|
config.isAtomisedEpithetsActivated());
|
1638
|
setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE,
|
1639
|
config.isAuthorCacheActivated());
|
1640
|
setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
|
1641
|
config.isAuthorshipSectionActivated());
|
1642
|
setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
|
1643
|
config.isNomenclaturalReferenceSectionActivated());
|
1644
|
setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
|
1645
|
config.isNomenclaturalStatusSectionActivated());
|
1646
|
setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
|
1647
|
config.isProtologueActivated());
|
1648
|
setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
|
1649
|
config.isTypeDesignationSectionActivated());
|
1650
|
setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
|
1651
|
config.isNameRelationsSectionActivated());
|
1652
|
setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID,
|
1653
|
config.isHybridActivated());
|
1654
|
|
1655
|
}
|
1656
|
|
1657
|
/**
|
1658
|
* @return
|
1659
|
*/
|
1660
|
public static boolean isSortTaxaByRankAndName() {
|
1661
|
|
1662
|
return getBooleanValue(IPreferenceKeys.SORT_TAXA_BY_RANK_AND_NAME);
|
1663
|
}
|
1664
|
|
1665
|
/**
|
1666
|
* @return
|
1667
|
*/
|
1668
|
public static boolean isSortNamedAreaByOrderInVocabulary() {
|
1669
|
|
1670
|
return getBooleanValue(IPreferenceKeys.SORT_NAMED_AREA_BY_VOCABULARY_ORDER);
|
1671
|
}
|
1672
|
|
1673
|
public static void setSortNamedAreasByOrderInVocabulary(boolean isSortByVocabularyOrder) {
|
1674
|
setBooleanValue(IPreferenceKeys.SORT_NAMED_AREA_BY_VOCABULARY_ORDER, isSortByVocabularyOrder);
|
1675
|
|
1676
|
}
|
1677
|
|
1678
|
/**
|
1679
|
* <p>
|
1680
|
* setPreferredNamedAreasForDistributionEditor
|
1681
|
* </p>
|
1682
|
*
|
1683
|
* @param saveCheckedElements
|
1684
|
* @param saveGrayedElements
|
1685
|
*/
|
1686
|
public static void setLastSelectedReference(
|
1687
|
List<String> lastSelectedReferences) {
|
1688
|
|
1689
|
setStringValue(PreferencesUtil.LAST_SELECTED_REFERENCES, lastSelectedReferences.toString());
|
1690
|
}
|
1691
|
|
1692
|
/**
|
1693
|
* <p>
|
1694
|
* setPreferredNamedAreasForDistributionEditor
|
1695
|
* </p>
|
1696
|
*
|
1697
|
* @param saveCheckedElements
|
1698
|
* @param saveGrayedElements
|
1699
|
*/
|
1700
|
public static List<String> getLastSelectedReferences() {
|
1701
|
|
1702
|
//IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
|
1703
|
String lastSelected = getStringValue(PreferencesUtil.LAST_SELECTED_REFERENCES);
|
1704
|
List<String> result = new ArrayList<>();
|
1705
|
if (!StringUtils.isBlank(lastSelected)){
|
1706
|
Collections.addAll(result, lastSelected.substring(1,lastSelected.length()-1).split(", "));
|
1707
|
}
|
1708
|
return result;
|
1709
|
}
|
1710
|
|
1711
|
|
1712
|
/**
|
1713
|
* <p>
|
1714
|
* setPreferredNamedAreasForDistributionEditor
|
1715
|
* </p>
|
1716
|
*
|
1717
|
* @param saveCheckedElements
|
1718
|
* @param saveGrayedElements
|
1719
|
*/
|
1720
|
public static void setPreferredNamedAreasForDistributionEditor(
|
1721
|
String saveCheckedElements, String saveGrayedElements, boolean local) {
|
1722
|
if (local){
|
1723
|
setStringValue(PreferencesUtil.DISTRIBUTION_AREA_OCCURENCE_STATUS, saveCheckedElements);
|
1724
|
setStringValue(PreferencesUtil.DISTRIBUTION_AREA_OCCURENCE_STATUS_GRAYED, saveGrayedElements);
|
1725
|
|
1726
|
}
|
1727
|
else{
|
1728
|
CdmPreference preference = null;
|
1729
|
|
1730
|
if (saveCheckedElements == null){
|
1731
|
preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaTerms);
|
1732
|
|
1733
|
if (preference == null){
|
1734
|
return ;
|
1735
|
} else{
|
1736
|
setStringValue(DISTRIBUTION_AREA_OCCURENCE_STATUS,
|
1737
|
saveCheckedElements);
|
1738
|
preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
|
1739
|
setPreferenceToDB(preference);
|
1740
|
|
1741
|
}
|
1742
|
} else{
|
1743
|
preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
|
1744
|
setPreferenceToDB(preference);
|
1745
|
setStringValue(DISTRIBUTION_AREA_OCCURENCE_STATUS,
|
1746
|
saveCheckedElements);
|
1747
|
|
1748
|
}
|
1749
|
}
|
1750
|
|
1751
|
}
|
1752
|
|
1753
|
/**
|
1754
|
* @param saveCheckedElements
|
1755
|
* @param saveCheckedElements2
|
1756
|
* @param b
|
1757
|
*/
|
1758
|
public static void setPreferredVocabulariesForDistributionEditor(String saveCheckedElements,
|
1759
|
boolean local) {
|
1760
|
if (local){
|
1761
|
setStringValue(PreferencesUtil.DISTRIBUTION_VOCABULARIES, saveCheckedElements);
|
1762
|
}
|
1763
|
else{
|
1764
|
ICdmRepository controller;
|
1765
|
CdmPreference preference = null;
|
1766
|
|
1767
|
if (saveCheckedElements == null){
|
1768
|
preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
|
1769
|
|
1770
|
if (preference == null){
|
1771
|
return ;
|
1772
|
} else{
|
1773
|
setStringValue(DISTRIBUTION_VOCABULARIES,
|
1774
|
saveCheckedElements);
|
1775
|
preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaVocabularies, saveCheckedElements);
|
1776
|
setPreferenceToDB(preference);
|
1777
|
}
|
1778
|
} else{
|
1779
|
preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaVocabularies, saveCheckedElements);
|
1780
|
setPreferenceToDB(preference);
|
1781
|
setStringValue(DISTRIBUTION_VOCABULARIES,
|
1782
|
saveCheckedElements);
|
1783
|
|
1784
|
}
|
1785
|
}
|
1786
|
}
|
1787
|
|
1788
|
|
1789
|
|
1790
|
|
1791
|
/**
|
1792
|
* @param saveCheckedElements
|
1793
|
* @param saveCheckedElements2
|
1794
|
* @param b
|
1795
|
*/
|
1796
|
public static String getPreferredVocabulariesForDistributionEditor(boolean local) {
|
1797
|
if (local){
|
1798
|
|
1799
|
String pref = getStringValue(DISTRIBUTION_VOCABULARIES);
|
1800
|
return pref;
|
1801
|
}
|
1802
|
else{
|
1803
|
CdmPreference preference = null;
|
1804
|
preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
|
1805
|
if (preference == null){
|
1806
|
return null;
|
1807
|
} else{
|
1808
|
return preference.getValue();
|
1809
|
}
|
1810
|
|
1811
|
}
|
1812
|
|
1813
|
|
1814
|
|
1815
|
}
|
1816
|
|
1817
|
public static boolean getFilterCommonNameReferences(){
|
1818
|
return getBooleanValue(PreferencesUtil.FILTER_COMMON_NAME_REFERENCES);
|
1819
|
}
|
1820
|
|
1821
|
/**
|
1822
|
*
|
1823
|
*/
|
1824
|
public static void updateDBPreferences() {
|
1825
|
CdmPreference preference = null;
|
1826
|
IPreferenceStore prefStore = getPreferenceStore();
|
1827
|
|
1828
|
//ABCD Configurator
|
1829
|
|
1830
|
updateAbcdImportConfigurationPreference();
|
1831
|
|
1832
|
preference = getPreferenceFromDB(PreferencePredicate.ShowImportExportMenu);
|
1833
|
if (preference != null){
|
1834
|
if(!getBooleanValue(SHOW_IO_MENU) || !preference.isAllowOverride()){
|
1835
|
setBooleanValue(SHOW_IO_MENU, Boolean.valueOf(preference.getValue()));
|
1836
|
}
|
1837
|
}else{
|
1838
|
setBooleanValue(SHOW_IO_MENU, true);
|
1839
|
}
|
1840
|
|
1841
|
preference = getPreferenceFromDB(PreferencePredicate.ShowMediaView);
|
1842
|
if (preference != null){
|
1843
|
if(!getBooleanValue(SHOW_MEDIA) || !preference.isAllowOverride()){
|
1844
|
setBooleanValue(SHOW_MEDIA, Boolean.valueOf(preference.getValue()));
|
1845
|
}
|
1846
|
}else{
|
1847
|
setBooleanValue(SHOW_MEDIA, true);
|
1848
|
}
|
1849
|
|
1850
|
preference = getPreferenceFromDB(PreferencePredicate.ShowChecklistPerspective);
|
1851
|
if (preference != null){
|
1852
|
if(!getBooleanValue(SHOW_CHECKLIST_PERSPECTIVE) || !preference.isAllowOverride()){
|
1853
|
setBooleanValue(SHOW_CHECKLIST_PERSPECTIVE, Boolean.valueOf(preference.getValue()));
|
1854
|
}
|
1855
|
}else{
|
1856
|
setBooleanValue(SHOW_CHECKLIST_PERSPECTIVE, false);
|
1857
|
}
|
1858
|
|
1859
|
//Specimen Details
|
1860
|
preference = getPreferenceFromDB(PreferencePredicate.ShowSpecimen);
|
1861
|
if (preference != null){
|
1862
|
if(!getBooleanValue(SHOW_SPECIMEN) || !preference.isAllowOverride()){
|
1863
|
setBooleanValue(SHOW_SPECIMEN, Boolean.valueOf(preference.getValue()));
|
1864
|
}
|
1865
|
}else{
|
1866
|
setBooleanValue(SHOW_SPECIMEN, true);
|
1867
|
}
|
1868
|
|
1869
|
preference = getPreferenceFromDB(PreferencePredicate.ShowTaxonAssociations);
|
1870
|
if (preference != null){
|
1871
|
if(!getBooleanValue(SHOW_TAXON_ASSOCIATIONS_OVERRIDE) || !preference.isAllowOverride()){
|
1872
|
setBooleanValue(SHOW_TAXON_ASSOCIATIONS, Boolean.valueOf(preference.getValue()));
|
1873
|
}
|
1874
|
}
|
1875
|
preference = getPreferenceFromDB(PreferencePredicate.ShowCollectingAreasInGeneralSection);
|
1876
|
if (preference != null){
|
1877
|
if(!getBooleanValue(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION_OVERRIDE) || !preference.isAllowOverride()){
|
1878
|
setBooleanValue(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION, Boolean.valueOf(preference.getValue()));
|
1879
|
}
|
1880
|
}
|
1881
|
preference = getPreferenceFromDB(PreferencePredicate.ShowLifeForm);
|
1882
|
if (preference != null){
|
1883
|
if(!getBooleanValue(SHOW_LIFE_FORM_OVERRIDE) || !preference.isAllowOverride()){
|
1884
|
setBooleanValue(SHOW_LIFE_FORM, Boolean.valueOf(preference.getValue()));
|
1885
|
}
|
1886
|
}
|
1887
|
preference = getPreferenceFromDB(PreferencePredicate.DeterminationOnlyForFieldUnits);
|
1888
|
if (preference != null){
|
1889
|
if(!getBooleanValue(DETERMINATION_ONLY_FOR_FIELD_UNITS_OVERRIDE) || !preference.isAllowOverride()){
|
1890
|
setBooleanValue(DETERMINATION_ONLY_FOR_FIELD_UNITS, Boolean.valueOf(preference.getValue()));
|
1891
|
}
|
1892
|
}
|
1893
|
|
1894
|
|
1895
|
//Name Details
|
1896
|
NameDetailsConfigurator config = getPreferredNameDetailsConfiguration(false);
|
1897
|
if (config != null ){
|
1898
|
if (!getBooleanValue(OVERRIDE_NAME_DETAILS) || !getBooleanValue(ALLOW_OVERRIDE_NAME_DETAILS)){
|
1899
|
setPreferredNameDetailsConfiguration(config, false);
|
1900
|
}
|
1901
|
}
|
1902
|
|
1903
|
//Distribution Editor
|
1904
|
preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
|
1905
|
if (preference != null){
|
1906
|
if (!getBooleanValue(DISTRIBUTION_VOCABULARIES_OVERRIDE) || !preference.isAllowOverride()){
|
1907
|
setStringValue(DISTRIBUTION_VOCABULARIES, preference.getValue());
|
1908
|
setBooleanValue(DISTRIBUTION_VOCABULARIES_ALLOW_OVERRIDE, preference.isAllowOverride());
|
1909
|
}
|
1910
|
}else{
|
1911
|
setBooleanValue(DISTRIBUTION_VOCABULARIES_ALLOW_OVERRIDE,true);
|
1912
|
setStringValue(DISTRIBUTION_VOCABULARIES, "");
|
1913
|
}
|
1914
|
|
1915
|
preference = getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
|
1916
|
if (preference != null){
|
1917
|
if (!getBooleanValue(DISTRIBUTION_AREA_PREFRENCES_ACTIVE_OVERRIDE) || !preference.isAllowOverride()){
|
1918
|
setBooleanValue(DISTRIBUTION_AREA_PREFRENCES_ACTIVE, Boolean.valueOf(preference.getValue()));
|
1919
|
}
|
1920
|
}
|
1921
|
|
1922
|
preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionStatus);
|
1923
|
if (preference != null){
|
1924
|
if (!getBooleanValue(DISTRIBUTION_STATUS_OVERRIDE) || !preference.isAllowOverride()){
|
1925
|
//get terms for the uuids... and add them to the termManager as preferred terms
|
1926
|
ITermService termService = CdmStore.getService(ITermService.class);
|
1927
|
String[] uuidArray = preference.getValue().split(";");
|
1928
|
List<UUID> uuidList = new ArrayList();
|
1929
|
for (String uuidString:uuidArray){
|
1930
|
try {
|
1931
|
uuidList.add(UUID.fromString(uuidString));
|
1932
|
} catch (Exception e) {
|
1933
|
logger.warn("Preference loading failed", e);
|
1934
|
}
|
1935
|
}
|
1936
|
|
1937
|
List<DefinedTermBase> definedTermBases = termService.load(uuidList, null);
|
1938
|
CdmStore.getTermManager().setPreferredTerms(definedTermBases, TermStore.getTerms(TermType.PresenceAbsenceTerm, null));
|
1939
|
}
|
1940
|
}
|
1941
|
|
1942
|
preference = getPreferenceFromDB(PreferencePredicate.CommonNameAreaVocabularies);
|
1943
|
if (preference != null){
|
1944
|
if (!getBooleanValue(COMMON_NAME_AREA_VOCABULARIES) || !preference.isAllowOverride()){
|
1945
|
setStringValue(COMMON_NAME_AREA_VOCABULARIES, preference.getValue());
|
1946
|
setBooleanValue(COMMON_NAME_AREA_VOCABULARIES_ALLOW_OVERRIDE, preference.isAllowOverride());
|
1947
|
}
|
1948
|
}else{
|
1949
|
setStringValue(COMMON_NAME_AREA_VOCABULARIES, "");
|
1950
|
setBooleanValue(COMMON_NAME_AREA_VOCABULARIES_ALLOW_OVERRIDE, true);
|
1951
|
}
|
1952
|
|
1953
|
preference = getPreferenceFromDB(PreferencePredicate.CommonNameReferencesWithMarker);
|
1954
|
if (preference != null){
|
1955
|
if (!getBooleanValue(FILTER_COMMON_NAME_REFERENCES) || !preference.isAllowOverride()){
|
1956
|
setBooleanValue(FILTER_COMMON_NAME_REFERENCES, Boolean.valueOf(preference.getValue()));
|
1957
|
}
|
1958
|
}else{
|
1959
|
setBooleanValue(FILTER_COMMON_NAME_REFERENCES, false);
|
1960
|
}
|
1961
|
|
1962
|
|
1963
|
preference = getPreferenceFromDB(PreferencePredicate.ShowTaxonNodeWizard);
|
1964
|
if (preference != null){
|
1965
|
if (!getBooleanValue(SHOW_TAXONNODE_WIZARD) || !preference.isAllowOverride()){
|
1966
|
setBooleanValue(SHOW_TAXONNODE_WIZARD, Boolean.valueOf(preference.getValue()));
|
1967
|
}
|
1968
|
}else{
|
1969
|
setBooleanValue(SHOW_TAXONNODE_WIZARD, true);
|
1970
|
}
|
1971
|
|
1972
|
preference = getPreferenceFromDB(PreferencePredicate.ShowIdInSource);
|
1973
|
if (preference != null){
|
1974
|
if (!getBooleanValue(SHOW_ID_IN_SOURCE) || !preference.isAllowOverride()){
|
1975
|
setBooleanValue(SHOW_ID_IN_SOURCE, Boolean.valueOf(preference.getValue()));
|
1976
|
}
|
1977
|
}else{
|
1978
|
setBooleanValue(SHOW_ID_IN_SOURCE, true);
|
1979
|
}
|
1980
|
|
1981
|
preference = getPreferenceFromDB(PreferencePredicate.ShowNameInSource);
|
1982
|
if (preference != null){
|
1983
|
if (!getBooleanValue(SHOW_NAME_IN_SOURCE) || !preference.isAllowOverride()){
|
1984
|
setBooleanValue(SHOW_NAME_IN_SOURCE, Boolean.valueOf(preference.getValue()));
|
1985
|
}
|
1986
|
}else{
|
1987
|
setBooleanValue(SHOW_NAME_IN_SOURCE, true);
|
1988
|
}
|
1989
|
|
1990
|
preference = getPreferenceFromDB(PreferencePredicate.DisableMultiClassification);
|
1991
|
if (preference != null){
|
1992
|
if (!getBooleanValue(DISABLE_MULTI_CLASSIFICATION) || !preference.isAllowOverride()){
|
1993
|
setBooleanValue(DISABLE_MULTI_CLASSIFICATION, Boolean.valueOf(preference.getValue()));
|
1994
|
}
|
1995
|
}else{
|
1996
|
setBooleanValue(DISABLE_MULTI_CLASSIFICATION, false);
|
1997
|
}
|
1998
|
|
1999
|
}
|
2000
|
|
2001
|
|
2002
|
|
2003
|
|
2004
|
|
2005
|
|
2006
|
|
2007
|
}
|