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