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