2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.preference
;
13 import java
.io
.FileInputStream
;
14 import java
.io
.FileOutputStream
;
15 import java
.io
.IOException
;
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
;
24 import java
.util
.Properties
;
25 import java
.util
.StringTokenizer
;
26 import java
.util
.UUID
;
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
;
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
.name
.NomenclaturalCode
;
60 import eu
.etaxonomy
.cdm
.strategy
.match
.DefaultMatchStrategy
;
61 import eu
.etaxonomy
.cdm
.strategy
.match
.FieldMatcher
;
62 import eu
.etaxonomy
.cdm
.strategy
.match
.IMatchStrategy
;
63 import eu
.etaxonomy
.cdm
.strategy
.match
.MatchException
;
64 import eu
.etaxonomy
.cdm
.strategy
.match
.MatchMode
;
65 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
66 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
67 import eu
.etaxonomy
.taxeditor
.model
.NomenclaturalCodeHelper
;
68 import eu
.etaxonomy
.taxeditor
.remoting
.source
.CdmRemoteSource
;
69 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
70 import eu
.etaxonomy
.taxeditor
.store
.internal
.TaxeditorStorePlugin
;
71 import eu
.etaxonomy
.taxeditor
.ui
.dialog
.DefaultLanguageDialog
;
75 * PreferencesUtil class.
82 public class PreferencesUtil
implements IPreferenceKeys
{
87 public static final String PREFERRED_TERMS_CHANGE
= "preferred_terms";
89 public static final String P2_REPOSITORIES_DELIM
= ",";
90 public static final String P2_REPOSITORY_FIELDS_DELIM
= ";";
92 private final static Logger logger
= Logger
.getLogger(PreferencesUtil
.class);
103 * @return a {@link org.eclipse.jface.preference.IPreferenceStore} object.
105 public static IPreferenceStore
getPreferenceStore() {
106 return TaxeditorStorePlugin
.getDefault().getPreferenceStore();
109 private static String
prefKey(String name
) {
110 return name
+ "_"+ ((CdmRemoteSource
)CdmStore
.getActiveCdmSource()).toString();
113 static String
prefOverrideKey(String name
) {
114 return name
+ "_OVERRIDE_"+ ((CdmRemoteSource
)CdmStore
.getActiveCdmSource()).toString();
124 public static void setStringValue(String name
, String value
) {
125 getPreferenceStore().setValue(prefKey(name
), value
);
135 public static void setIntValue(String name
, int value
) {
136 getPreferenceStore().setValue(prefKey(name
), value
);
146 public static void setBooleanValue(String name
, boolean value
) {
147 getPreferenceStore().setValue(prefKey(name
), value
);
157 public static void setDoubleValue(String name
, double value
) {
158 getPreferenceStore().setValue(prefKey(name
), value
);
168 public static void setFloatValue(String name
, float value
) {
169 getPreferenceStore().setValue(name
+ ((CdmRemoteSource
)CdmStore
.getActiveCdmSource()).toString(), value
);
179 public static void setLongValue(String name
, long value
) {
180 getPreferenceStore().setValue(prefKey(name
), value
);
190 public static String
getStringValue(String name
) {
191 String prefValue
= getDBPreferenceValue(name
);
192 if (prefValue
== null){
193 String dbSpecific
= prefKey(name
);
194 if (getPreferenceStore().contains(dbSpecific
)){
195 prefValue
= getPreferenceStore().getString(dbSpecific
);
197 prefValue
= getPreferenceStore().
205 private static String
getDBPreferenceValue(String name
) {
206 CdmPreferenceCache cache
= CdmPreferenceCache
.instance();
207 if (cache
.get(name
) != null){
208 CdmPreference pref
= cache
.get(name
);
209 if (!pref
.isAllowOverride() || !getBooleanValue(prefOverrideKey(name
))){
210 return pref
.getValue();
223 public static int getIntValue(String name
) {
224 String prefValue
= getDBPreferenceValue(name
);
225 Integer result
= null;
227 result
= Integer
.parseInt(prefValue
);
228 }catch(NumberFormatException e
){
229 logger
.debug("Preference value of " + name
+ " is not a number");
232 String dbSpecific
= prefKey(name
);
233 if (getPreferenceStore().contains(dbSpecific
)){
234 result
= getPreferenceStore().getInt(dbSpecific
);
236 result
= getPreferenceStore().
252 public static boolean getBooleanValue(String name
) {
253 if (CdmStore
.isActive()){
254 String prefValue
= getDBPreferenceValue(name
);
255 if (prefValue
== null){
256 String dbSpecific
= prefKey(name
);
257 if (getPreferenceStore().contains(dbSpecific
)){
258 return getPreferenceStore().getBoolean(dbSpecific
);
260 return getPreferenceStore().
264 return Boolean
.valueOf(prefValue
);
268 return getPreferenceStore().getBoolean(name
);
280 public static double getDoubleValue(String name
) {
281 String prefValue
= getDBPreferenceValue(name
);
282 Double result
= null;
284 result
= Double
.parseDouble(prefValue
);
285 }catch(NumberFormatException e
){
286 logger
.debug("Preference value of " + name
+ " is not a number");
289 String dbSpecific
= prefKey(name
);
290 if (getPreferenceStore().contains(dbSpecific
)){
291 result
= getPreferenceStore().getDouble(dbSpecific
);
293 result
= getPreferenceStore().
308 public static float getFloatValue(String name
) {
309 String prefValue
= getDBPreferenceValue(name
);
312 result
= Float
.parseFloat(prefValue
);
313 }catch(NumberFormatException e
){
314 logger
.debug("Preference value of " + name
+ " is not a number");
317 String dbSpecific
= prefKey(name
);
318 if (getPreferenceStore().contains(dbSpecific
)){
319 result
= getPreferenceStore().getFloat(dbSpecific
);
321 result
= getPreferenceStore().
336 public static long getLongValue(String name
) {
337 String prefValue
= getDBPreferenceValue(name
);
340 result
= Long
.parseLong(prefValue
);
341 }catch(NumberFormatException e
){
342 logger
.debug("Preference value of " + name
+ " is not a number");
345 String dbSpecific
= prefKey(name
);
346 if (getPreferenceStore().contains(dbSpecific
)){
347 result
= getPreferenceStore().getLong(dbSpecific
);
349 result
= getPreferenceStore().
359 * setPreferredNomenclaturalCode
362 * @param preferredCode
363 * a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
366 public static CdmPreference
setPreferredNomenclaturalCode(
367 String preferenceValue
, boolean local
) {
369 setStringValue(PREFERRED_NOMENCLATURAL_CODE_KEY
,
373 ICdmRepository controller
;
374 controller
= CdmStore
.getCurrentApplicationConfiguration();
375 if (controller
== null){
380 key
= CdmPreference
.NewKey(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.NomenclaturalCode
);
381 }catch (Exception e
){
382 System
.out
.println(e
.getStackTrace());
384 CdmPreference preference
= null;
386 if (preferenceValue
== null){
387 preference
= controller
.getPreferenceService().find(key
);
388 if (preference
== null){
391 setStringValue(PREFERRED_NOMENCLATURAL_CODE_KEY
,
392 preference
.getValue());
397 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.NomenclaturalCode
, preferenceValue
);
398 controller
.getPreferenceService().set(preference
);
410 * setPreferredNomenclaturalCode
413 * @param preferredCode
414 * a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
417 public static void setPreferredNomenclaturalCode(
418 CdmPreference preference
) {
420 ICdmRepository controller
;
421 controller
= CdmStore
.getCurrentApplicationConfiguration();
422 if (controller
== null){
427 key
= CdmPreference
.NewKey(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.NomenclaturalCode
);
428 }catch (Exception e
){
429 System
.out
.println(e
.getStackTrace());
432 controller
.getPreferenceService().set(preference
);
437 public static NomenclaturalCode
getPreferredNomenclaturalCode(){
438 if (getBooleanValue(prefOverrideKey(PreferencePredicate
.NomenclaturalCode
.getKey()))) {
439 return getPreferredNomenclaturalCode(true);
441 return getPreferredNomenclaturalCode(false);
447 * getPreferredNomenclaturalCode
450 * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
452 public static NomenclaturalCode
getPreferredNomenclaturalCode(boolean useLocal
) {
454 CdmPreference pref
= null;
456 pref
= getPreferenceFromDB(PreferencePredicate
.NomenclaturalCode
);
459 String preferredCode
;
461 preferredCode
= getStringValue(
462 PREFERRED_NOMENCLATURAL_CODE_KEY
);
465 preferredCode
= pref
.getValue();
468 return getPreferredNomenclaturalCode(preferredCode
);
474 * getPreferredNomenclaturalCode
477 * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
479 public static NomenclaturalCode
getPreferredNomenclaturalCode(String preferenceKeyNomenclaturalCode
) {
481 for (NomenclaturalCode code
: NomenclaturalCodeHelper
.getAllCodes()) {
482 if (getPreferenceKey(code
).equals(preferenceKeyNomenclaturalCode
)) {
489 public static boolean isShowTaxonAssociations(){
490 boolean result
= getBooleanValue(EditorPreferencePredicate
.ShowTaxonAssociations
.getKey());
494 public static boolean isShowLifeForm(){
495 boolean result
= getBooleanValue(EditorPreferencePredicate
.ShowLifeForm
.getKey());
499 public static boolean isDeterminationOnlyForFieldUnits(){
500 boolean result
= getBooleanValue(EditorPreferencePredicate
.DeterminationOnlyForFieldUnits
.getKey());
504 public static boolean isCollectingAreaInGeneralSection(){
505 boolean result
= getBooleanValue(EditorPreferencePredicate
.ShowCollectingAreasInGeneralSection
.getKey());
509 public static CdmPreference
getPreferenceFromDB(IPreferencePredicate predicate
){
510 ICdmRepository controller
;
511 CdmPreference pref
= null;
514 if(CdmStore
.isActive()){
515 controller
= CdmStore
.getCurrentApplicationConfiguration();
516 PrefKey key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), predicate
);
517 pref
= controller
.getPreferenceService().find(key
);
527 public static void setPreferenceToDB(CdmPreference preference
){
528 ICdmRepository controller
;
530 if(CdmStore
.isActive()){
531 controller
= CdmStore
.getCurrentApplicationConfiguration();
532 controller
.getPreferenceService().set(preference
);
542 public static String
getPreferredDefaultLangugae(){
543 String preferredLanguage
= getStringValue(DEFAULT_LANGUAGE_EDITOR
);
544 if(StringUtils
.isNotEmpty(preferredLanguage
) && StringUtils
.isNotBlank(preferredLanguage
)){
545 return preferredLanguage
;
550 public static boolean isShowMediaPreview(){
551 boolean isShowMediaPreview
= getBooleanValue(SHOW_MEDIA_PREVIEW
);
552 return isShowMediaPreview
;
556 * Get the match strategy for the given class that was stored in preferences
557 * or the default strategy if it was not stored in preferences
560 * a {@link java.lang.Class} object.
561 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
563 public static IMatchStrategy
getMatchStrategy(Class
<?
> clazz
) {
564 String className
= clazz
.getName();
565 if (getBooleanValue(MATCH_STRATEGY_PREFIX
+ className
)) {
566 IMatchStrategy matchStrategy
= getDefaultMatchStrategy(clazz
);
568 //TODO CacheMatchers (or multiple field matchers in future) are missing here
569 for (FieldMatcher fieldMatcher
: matchStrategy
.getMatching().getFieldMatchers(false)) {
570 String fieldName
= fieldMatcher
.getPropertyName();
571 String matchModeName
= getStringValue(
572 getMatchStrategyFieldName(className
, fieldName
));
573 MatchMode matchMode
= MatchMode
.valueOf(matchModeName
);
575 matchStrategy
.setMatchMode(fieldName
, matchMode
);
576 } catch (MatchException e
) {
577 MessagingUtils
.error(PreferencesUtil
.class, e
);
578 throw new RuntimeException(e
);
582 return matchStrategy
;
584 return getDefaultMatchStrategy(clazz
);
588 * Stores a matchStrategy into the preference store.
590 * @param matchStrategy
591 * a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy}
594 public static void setMatchStrategy(IMatchStrategy matchStrategy
) {
595 String className
= "ANY class"; //FIXME was: matchStrategy.getMatchClass().getName(); seems currently not in use
596 setBooleanValue(MATCH_STRATEGY_PREFIX
+ className
, true);
598 List
<FieldMatcher
> fieldMatchers
= matchStrategy
.getMatching().getFieldMatchers(false);
600 for (FieldMatcher fieldMatcher
: fieldMatchers
) {
601 String fieldName
= fieldMatcher
.getPropertyName();
603 getMatchStrategyFieldName(className
, fieldName
),
604 fieldMatcher
.getMatchMode().name());
609 * Helper method to create the preference property for a match field.
615 private static String
getMatchStrategyFieldName(String className
,
617 return MATCH_STRATEGY_PREFIX
+ className
+ "." + fieldName
;
621 * Returns the default match strategy for a given class.
624 * a {@link java.lang.Class} object.
625 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
627 public static IMatchStrategy
getDefaultMatchStrategy(Class clazz
) {
628 return DefaultMatchStrategy
.NewInstance(clazz
);
633 * getDateFormatPattern
636 * @return a {@link java.lang.String} object.
638 public static String
getDateFormatPattern() {
639 // TODO make this configurable in properties
640 String pattern
= "Y-M-d H:m";
646 * addTermToPreferredTerms
654 public static <T
extends TermBase
> void addTermToPreferredTerms(T term
) {
656 // VocabularyEnum vocabulary =
657 // VocabularyEnum.getVocabularyEnum(term.getClass());
659 // getPreferenceStore().setValue(getPreferenceKey(term),
660 // VocabularyStore.getTermVocabulary(vocabulary).getTerms().contains(term));
662 // firePreferencesChanged(term.getClass());
666 * Construct a unique key using the CdmBase object's uuid
671 private static String
getPreferenceKey(ICdmBase cdmBase
) {
672 cdmBase
= HibernateProxyHelper
.deproxy(cdmBase
);
674 String key
= cdmBase
.getClass().getName().concat(".")
675 .concat(cdmBase
.getUuid().toString());
676 if (key
.contains("javassist")) {
677 MessagingUtils
.info("proxy");
683 * Construct a unique key using the CdmBase object's uuid
688 public static String
getPreferenceKey(ISimpleTerm simpleTerm
) {
689 simpleTerm
= HibernateProxyHelper
.deproxy(simpleTerm
);
690 String key
= simpleTerm
.getClass().getName().concat(".")
691 .concat(simpleTerm
.getUuid().toString());
692 if (key
.contains("javassist")) {
693 MessagingUtils
.warn(PreferencesUtil
.class,
694 "Trying to persist a preference based on a proxy class.");
702 * Construct a unique key using the CdmBase object's uuid
707 public static String
getPreferenceKey(IDefinedTerm definedTerm
) {
708 definedTerm
= HibernateProxyHelper
.deproxy(definedTerm
);
709 String key
= definedTerm
.getClass().getName().concat(".")
710 .concat(definedTerm
.getUuid().toString());
711 if (key
.contains("javassist")) {
712 MessagingUtils
.warn(PreferencesUtil
.class,
713 "Trying to persist a preference based on a proxy class.");
719 * Retrieves search preferences from the preference store
721 * @return an {@link ITaxonServiceConfigurator} to pass to search methods
723 public static IFindTaxaAndNamesConfigurator
getSearchConfigurator() {
724 IFindTaxaAndNamesConfigurator configurator
= initializeSearchConfigurator();
726 configurator
.setDoTaxa(getBooleanValue(
727 TAXON_SERVICE_CONFIGURATOR_TAXA
));
728 configurator
.setDoSynonyms(getBooleanValue(
729 TAXON_SERVICE_CONFIGURATOR_SYNONYMS
));
730 configurator
.setDoNamesWithoutTaxa(getBooleanValue(
731 TAXON_SERVICE_CONFIGURATOR_NAMES
));
732 configurator
.setDoTaxaByCommonNames(getBooleanValue(
733 TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES
));
734 //configurator.setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.valueOf(getStringValue(TAXON_SERVICE_CONFIGURATOR_MATCH_MODE)));
740 * create new preferences, setting all search options to true
743 * {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
746 public static IFindTaxaAndNamesConfigurator
initializeSearchConfigurator() {
747 IFindTaxaAndNamesConfigurator configurator
= FindTaxaAndNamesConfiguratorImpl
.NewInstance();
749 configurator
.setDoTaxa(true);
750 configurator
.setDoSynonyms(true);
751 configurator
.setDoNamesWithoutTaxa(true);
752 configurator
.setDoTaxaByCommonNames(true);
754 configurator
.setTaxonPropertyPath(Arrays
.asList("$", "titleCache",
755 "name", "name.$", "relationsFromThisTaxon.$"));
757 configurator
.setSynonymPropertyPath(Arrays
.asList("$", "titleCache",
758 "name", "name.$", "synonyms.relatedTo.*"));
761 // match mode is a simple like, actually all other match modes are kind
764 .setMatchMode(eu
.etaxonomy
.cdm
.persistence
.query
.MatchMode
.ANYWHERE
);
765 // we set page number and size here as this should always be unlimited
766 configurator
.setPageNumber(0);
767 // TODO currently limit results to 10000
768 configurator
.setPageSize(10000);
769 setSearchConfigurator(configurator
) ;
774 * Store search preferences
776 * @param configurator
778 * {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
781 public static void setSearchConfigurator(
782 IFindTaxaAndNamesConfigurator configurator
) {
783 getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_TAXA
,
784 configurator
.isDoTaxa());
785 getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_SYNONYMS
,
786 configurator
.isDoSynonyms());
787 getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_NAMES
,
788 configurator
.isDoNamesWithoutTaxa());
789 getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES
,
790 configurator
.isDoTaxaByCommonNames());
795 * firePreferencesChanged
799 * a {@link java.lang.Class} object.
801 public static void firePreferencesChanged(Class clazz
) {
802 getPreferenceStore().firePropertyChangeEvent(PREFERRED_TERMS_CHANGE
,
806 public static String
createPreferenceString(String property
){
807 return prefKey(property
);
810 public static String
createOverridePreferenceString(String property
){
811 return prefOverrideKey(property
);
816 * Set default values for preferences
818 public static void setDefaults() {
819 getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_TAXA
, true);
820 getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_SYNONYMS
,
822 getPreferenceStore().setDefault(createPreferenceString(EDIT_MAP_SERVICE_ACCES_POINT
),
823 "http://edit.africamuseum.be/edit_wp5/v1.2/rest_gen.php");
824 //FIXME : changed default for SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
825 getPreferenceStore().setDefault(createPreferenceString(SHOULD_CONNECT_AT_STARTUP
), false);
826 getPreferenceStore().setDefault(createPreferenceString(OPENURL_ACCESS_POINT
),
827 "http://www.biodiversitylibrary.org/openurl");
828 getPreferenceStore().setDefault(createPreferenceString(OPENURL_IMAGE_MAX_WIDTH
), "1000");
829 getPreferenceStore().setDefault(createPreferenceString(OPENURL_IMAGE_MAX_HEIGHT
), "1000");
830 //Distribution Editor:
831 getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate
.DistributionEditorActivated
.getKey()), Boolean
.valueOf(EditorPreferencePredicate
.DistributionEditorActivated
.getDefaultValue().toString()));
832 getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate
.DisplayOfAreasInDistributionEditor
.getKey()), EditorPreferencePredicate
.DisplayOfAreasInDistributionEditor
.getDefaultValue().toString());
833 getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate
.DisplayOfStatus
.getKey()), EditorPreferencePredicate
.DisplayOfStatus
.getDefaultValue().toString());
837 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
), true);
838 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE
), true);
839 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
), true);
840 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_HYBRID
), true);
841 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_LSID
), true);
842 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
), true);
843 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NAMECACHE
), true);
844 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
), true);
845 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
), true);
846 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
), true);
847 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
), true);
848 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_RANK
), true);
849 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
), true);
850 //Navigator preferences
851 getPreferenceStore().setDefault(createPreferenceString(SORT_NODES
), NavigatorOrderEnum
.RankAndNameOrder
.getKey());
853 getPreferenceStore().setDefault(createPreferenceString(SORT_TAXA_BY_RANK_AND_NAME
), true);
854 //override db preferences
855 getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(EditorPreferencePredicate
.AbcdImportConfig
.getKey())), false);
856 getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(EditorPreferencePredicate
.ShowSpecimen
.getKey())), false);
857 getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(EditorPreferencePredicate
.NameDetailsView
.getKey())), false);
858 getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(EditorPreferencePredicate
.DistributionEditorActivated
.getKey())), false);
860 getPreferenceStore().setDefault(createPreferenceString(FILTER_COMMON_NAME_REFERENCES
), false);
861 getPreferenceStore().setDefault(createPreferenceString(SHOW_SPECIMEN
), true);
862 getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate
.ShowTaxonNodeWizard
.getKey()), Boolean
.valueOf(EditorPreferencePredicate
.ShowTaxonNodeWizard
.getDefaultValue().toString()));
863 getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate
.ShowNamespaceInSource
.getKey()), Boolean
.valueOf(EditorPreferencePredicate
.ShowNamespaceInSource
.getDefaultValue().toString()));
864 getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate
.ShowIdInSource
.getKey()), Boolean
.valueOf(EditorPreferencePredicate
.ShowIdInSource
.getDefaultValue().toString()));
865 getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate
.DisableMultiClassification
.getKey()), Boolean
.valueOf(EditorPreferencePredicate
.DisableMultiClassification
.getDefaultValue().toString()));
866 getPreferenceStore().setDefault(createPreferenceString(DISABLE_SEC
), false);
867 getPreferenceStore().setDefault(createPreferenceString(SHOW_SEC_DETAILS
), true);
872 * checkNomenclaturalCode
875 public static void checkNomenclaturalCode() {
876 // First time Editor is opened, no nomenclatural code has been set
877 if (PreferencesUtil
.getPreferredNomenclaturalCode(true) == null) {
878 PreferencesUtil
.setPreferredNomenclaturalCode(getPreferenceKey(NomenclaturalCode
.ICNAFP
), true);
884 public static void setNomenclaturalCodePreferences(){
885 ICdmRepository controller
;
886 controller
= CdmStore
.getCurrentApplicationConfiguration();
887 PrefKey key
= CdmPreference
.NewKey(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.NomenclaturalCode
);
888 CdmPreference preference
= null;
889 if (controller
== null){
892 preference
= controller
.getPreferenceService().find(key
);
893 if (preference
== null){
896 // setBooleanValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY, preference.isAllowOverride());
898 int index
= StringUtils
.lastIndexOf(preference
.getValue(), ".");
899 UUID uuid
= UUID
.fromString(preference
.getValue().substring(index
+1, preference
.getValue().length()));
900 NomenclaturalCode preferredCode
= NomenclaturalCode
.getByUuid(uuid
);
902 setStringValue(PREFERRED_NOMENCLATURAL_CODE_KEY
,
903 getPreferenceKey(preferredCode
));
907 public static void checkDefaultLanguage(){
908 if(PreferencesUtil
.getPreferredDefaultLangugae() == null){
909 Shell shell
= AbstractUtility
.getShell();
910 int open
= new DefaultLanguageDialog(shell
).open();
911 if(open
== Window
.OK
){
912 PlatformUI
.getWorkbench().restart();
915 //TODO:In case of a reinstall, the config.ini will be overwritten
916 // here you create config.ini with the stored key from preferences
922 * getMapServiceAccessPoint
925 * @return a {@link java.lang.String} object.
927 public static String
getMapServiceAccessPoint() {
928 return getStringValue(EDIT_MAP_SERVICE_ACCES_POINT
);
933 * shouldConnectAtStartUp
938 public static boolean shouldConnectAtStartUp() {
939 //FIXME : force SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
940 //return getBooleanValue(SHOULD_CONNECT_AT_STARTUP);
946 * getDefaultFeatureTreeForTextualDescription
949 * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
951 public static FeatureTree
getDefaultFeatureTreeForTextualDescription() {
952 String uuidString
= getStringValue(
953 FEATURE_TREE_DEFAULT_TEXT
);
954 return CdmUtils
.isEmpty(uuidString
) ?
null : CdmStore
.getService(
955 IFeatureTreeService
.class).load(UUID
.fromString(uuidString
));
960 * getDefaultFeatureTreeForStructuredDescription
963 * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
965 public static FeatureTree
getDefaultFeatureTreeForStructuredDescription() {
966 String uuidString
= getStringValue(
967 FEATURE_TREE_DEFAULT_STRUCTURE
);
968 return CdmUtils
.isEmpty(uuidString
) ?
null : CdmStore
.getService(
969 IFeatureTreeService
.class).load(UUID
.fromString(uuidString
));
974 * setSortRanksHierarchichally
980 public static void setSortRanksHierarchichally(boolean selection
) {
981 setBooleanValue(SORT_RANKS_HIERARCHICHALLY
, selection
);
986 * getSortRanksHierarchichally
991 public static boolean getSortRanksHierarchichally() {
992 return getBooleanValue(SORT_RANKS_HIERARCHICHALLY
);
995 public static boolean isMultilanguageTextEditingCapability() {
996 return getBooleanValue(
997 MULTILANGUAGE_TEXT_EDITING_CAPABILITY
);
1000 public static Language
getGlobalLanguage() {
1003 String languageUuidString
= getStringValue(
1004 GLOBAL_LANGUAGE_UUID
);
1006 if(!CdmStore
.isActive()) {
1007 MessagingUtils
.noDataSourceWarningDialog(languageUuidString
);
1011 if (CdmUtils
.isBlank(languageUuidString
)) {
1012 return Language
.getDefaultLanguage();
1015 UUID languageUuid
= UUID
.fromString(languageUuidString
);
1016 return (Language
) CdmStore
.getService(ITermService
.class).load(
1020 public static void setGlobalLanguage(Language language
) {
1021 if(language
!= null) {
1022 setStringValue(GLOBAL_LANGUAGE_UUID
,language
.getUuid().toString());
1023 CdmStore
.setDefaultLanguage(language
);
1031 public static Map
<MarkerType
, Boolean
> getEditMarkerTypePreferences() {
1032 List
<MarkerType
> markerTypes
= CdmStore
.getTermManager()
1033 .getPreferredTerms(MarkerType
.class);
1035 Map
<MarkerType
, Boolean
> result
= new HashMap
<MarkerType
, Boolean
>();
1037 for (MarkerType markerType
: markerTypes
) {
1038 String name
= getMarkerTypeEditingPreferenceKey(markerType
);
1039 Boolean value
= getBooleanValue(name
);
1041 result
.put(markerType
, value
);
1048 * @param markerTypeEditingMap
1050 public static void setEditMarkerTypePreferences(
1051 Map
<MarkerType
, Boolean
> markerTypeEditingMap
) {
1052 for (MarkerType markerType
: markerTypeEditingMap
.keySet()) {
1053 String name
= getMarkerTypeEditingPreferenceKey(markerType
);
1054 setBooleanValue(name
,
1055 markerTypeEditingMap
.get(markerType
));
1060 private static String
getMarkerTypeEditingPreferenceKey(
1061 MarkerType markerType
) {
1062 markerType
= HibernateProxyHelper
.deproxy(markerType
);
1063 return markerType
.getClass().getName() + EDIT_MARKER_TYPE_PREFIX
;
1068 * setEditMarkerTypePreference
1072 * a {@link org.eclipse.ui.IEditorInput} object.
1074 * a {@link eu.etaxonomy.cdm.model.common.MarkerType} object.
1078 public static void setEditMarkerTypePreference(MarkerType markerType
,
1081 getMarkerTypeEditingPreferenceKey(markerType
), edit
);
1087 public static DerivedUnitFacadeConfigurator
getDerivedUnitConfigurator() {
1088 DerivedUnitFacadeConfigurator configurator
= DerivedUnitFacadeConfigurator
1090 configurator
.setMoveDerivedUnitMediaToGallery(true);
1091 configurator
.setMoveFieldObjectMediaToGallery(true);
1092 return configurator
;
1096 * This method will write language properties to the config.ini located in the configuration folder
1097 * of the Taxonomic Ediitor. <b>This method is only used to set the default language for Taxonomic Editor.</b>
1099 * @param setLanguage 0 is for german and 1 for english.
1100 * @throws IOException
1102 public void writePropertyToConfigFile(int setLanguage
) throws IOException
{
1103 File file
= org
.eclipse
.core
.runtime
.preferences
.ConfigurationScope
.INSTANCE
.getLocation().toFile();
1104 //give warning to user if the directory has no write access
1106 throw new IOException();
1108 Properties properties
= load(file
.getAbsolutePath()+"/config.ini");
1109 switch(setLanguage
){
1111 properties
.setProperty("osgi.nl", "de");
1112 setStringValue(IPreferenceKeys
.DEFAULT_LANGUAGE_EDITOR
, "de");
1115 properties
.setProperty("osgi.nl", "en");
1116 setStringValue(IPreferenceKeys
.DEFAULT_LANGUAGE_EDITOR
, "en");
1121 save(file
+"/config.ini", properties
);
1125 * This method loads a property from a given file and returns it.
1129 * @throws IOException
1131 private Properties
load(String filename
) throws IOException
{
1132 FileInputStream in
= new FileInputStream(filename
);
1133 Properties prop
= new Properties();
1140 * This method saves a property to the specified file.
1144 * @throws IOException
1146 private void save(String filename
, Properties properties
) throws IOException
{
1147 FileOutputStream fos
= new FileOutputStream(filename
);
1148 properties
.store(fos
, "");
1153 * Saves a list of P2 Metadata Repositories as string with specified delimiters
1157 public static void setP2Repositories(List
<MetadataRepositoryElement
> p2Repos
) {
1158 StringBuilder sb
= new StringBuilder();
1159 for(MetadataRepositoryElement p2Repo
: p2Repos
) {
1160 sb
.append(P2_REPOSITORIES_DELIM
);
1161 if(p2Repo
.getName() == null || p2Repo
.getName().isEmpty()) {
1164 sb
.append(p2Repo
.getName());
1166 sb
.append(P2_REPOSITORY_FIELDS_DELIM
);
1167 sb
.append(p2Repo
.getLocation().toString());
1168 sb
.append(P2_REPOSITORY_FIELDS_DELIM
);
1169 sb
.append(String
.valueOf(p2Repo
.isEnabled()));
1171 getPreferenceStore().setValue(P2_REPOSITORY_LIST
, sb
.toString());
1176 * Retrieves a list of previously saved P2 repositories
1180 public static List
<MetadataRepositoryElement
> getP2Repositories() {
1181 List
<MetadataRepositoryElement
> p2Repos
= new ArrayList
<MetadataRepositoryElement
>();
1182 String p2ReposPref
= getStringValue(P2_REPOSITORY_LIST
);
1183 if(p2ReposPref
!= null && !p2ReposPref
.isEmpty()) {
1184 StringTokenizer p2ReposPrefST
= new StringTokenizer(p2ReposPref
,P2_REPOSITORIES_DELIM
);
1186 while(p2ReposPrefST
.hasMoreTokens()) {
1187 String p2RepoStr
= p2ReposPrefST
.nextToken();
1188 StringTokenizer p2ReposStrST
= new StringTokenizer(p2RepoStr
,P2_REPOSITORY_FIELDS_DELIM
);
1189 if(p2ReposStrST
.countTokens()==3) {
1190 String nickname
= p2ReposStrST
.nextToken();
1193 uri
= new URI(p2ReposStrST
.nextToken());
1194 } catch (URISyntaxException e
) {
1197 boolean enabled
= Boolean
.parseBoolean(p2ReposStrST
.nextToken());
1198 MetadataRepositoryElement mre
= new MetadataRepositoryElement(null, uri
, true);
1199 mre
.setNickname(nickname
);
1200 mre
.setEnabled(enabled
);
1210 * enables/disables nested composite. <br>
1212 * @param ctrl - Composite to be en-/disabeld
1213 * @param enabled - boolean
1215 public static void recursiveSetEnabled(Control ctrl
, boolean enabled
) {
1216 if (ctrl
instanceof Composite
) {
1217 Composite comp
= (Composite
) ctrl
;
1218 for (Control c
: comp
.getChildren()) {
1219 recursiveSetEnabled(c
, enabled
);
1222 ctrl
.setEnabled(enabled
);
1230 * @param orderActivated
1232 public static void setSortNodes(NavigatorOrderEnum nodesOrder
) {
1233 setStringValue(SORT_NODES
, nodesOrder
.key
);
1238 * @param orderActivated
1240 public static NavigatorOrderEnum
getSortNodes() {
1241 return NavigatorOrderEnum
.valueOf(getStringValue(SORT_NODES
));
1246 * @param orderActivated
1248 public static boolean isNodesSortedNaturally() {
1249 NavigatorOrderEnum value
= NavigatorOrderEnum
.valueOf(getStringValue(SORT_NODES
));
1250 return value
.equals(NavigatorOrderEnum
.NaturalOrder
);
1255 * @param orderActivated
1257 public static boolean isNodesSortedByName() {
1258 NavigatorOrderEnum value
= NavigatorOrderEnum
.valueOf(getStringValue(SORT_NODES
));
1259 return value
.equals(NavigatorOrderEnum
.AlphabeticalOrder
);
1264 * @param orderActivated
1266 public static boolean isNodesSortedByNameAndRank() {
1267 NavigatorOrderEnum value
= NavigatorOrderEnum
.valueOf(getStringValue(SORT_NODES
));
1268 return value
.equals(NavigatorOrderEnum
.RankAndNameOrder
);
1273 * setStoreNavigatorState
1279 public static boolean isStoreNavigatorState() {
1280 return getBooleanValue(RESTORE_NAVIGATOR_STATE
);
1286 * setStoreNavigatorState
1292 public static void setStoreNavigatorState(boolean selection
) {
1293 setBooleanValue(RESTORE_NAVIGATOR_STATE
, selection
);
1300 public static boolean isShowUpWidgetIsDisposedMessages() {
1301 return getBooleanValue(IS_SHOW_UP_WIDGET_IS_DISPOSED
);
1303 public static void setShowUpWidgetIsDisposedMessages(boolean selection
) {
1304 setBooleanValue(IS_SHOW_UP_WIDGET_IS_DISPOSED
, selection
);
1310 public static boolean isShowIdInVocabularyInChecklistEditor() {
1311 String area_display
= getStringValue(EditorPreferencePredicate
.DisplayOfAreasInDistributionEditor
.getKey());
1312 if (area_display
.equals(TermDisplayEnum
.IdInVocabulary
.getKey())) {
1318 public static boolean isShowSymbol1InChecklistEditor() {
1319 String area_display
= getStringValue(EditorPreferencePredicate
.DisplayOfAreasInDistributionEditor
.getKey());
1320 if (area_display
.equals(TermDisplayEnum
.Symbol1
.getKey())) {
1326 public static boolean isShowSymbol2InChecklistEditor() {
1327 String area_display
= getStringValue(EditorPreferencePredicate
.DisplayOfAreasInDistributionEditor
.getKey());
1328 if (area_display
.equals(TermDisplayEnum
.Symbol2
.getKey())) {
1334 public static void setAreaDisplayInChecklistEditor(String selection
) {
1335 setStringValue(EditorPreferencePredicate
.DisplayOfAreasInDistributionEditor
.getKey(), selection
);
1338 public static void setOwnDescriptionForChecklistEditor(boolean selection
) {
1339 setBooleanValue(EditorPreferencePredicate
.OwnDescriptionForDistributionEditor
.getKey(), selection
);
1342 public static boolean isOwnDescriptionForChecklistEditor() {
1343 return getBooleanValue(EditorPreferencePredicate
.OwnDescriptionForDistributionEditor
.getKey());
1349 public static String
displayStatusInChecklistEditor() {
1350 return getStringValue(EditorPreferencePredicate
.DisplayOfStatus
.getKey());
1352 public static void setDisplayStatusInChecklistEditor(String selection
) {
1353 setStringValue(EditorPreferencePredicate
.DisplayOfStatus
.getKey(), selection
);
1359 public static boolean isShowRankInChecklistEditor() {
1360 return getBooleanValue(EditorPreferencePredicate
.ShowRankInDistributionEditor
.getKey());
1362 public static void setShowRankInChecklistEditor(boolean selection
) {
1363 setBooleanValue(EditorPreferencePredicate
.ShowRankInDistributionEditor
.getKey(), selection
);
1371 public static NameDetailsConfigurator
getPreferredNameDetailsConfiguration( boolean local
) {
1372 NameDetailsConfigurator config
= new NameDetailsConfigurator(true);
1373 CdmPreferenceCache cache
= CdmPreferenceCache
.instance();
1374 CdmPreference preference
= null;
1377 preference
= cache
.get(EditorPreferencePredicate
.NameDetailsView
.getKey());
1378 if (preference
== null){
1382 setBooleanValue(ALLOW_OVERRIDE_NAME_DETAILS
, preference
.isAllowOverride());
1384 //the preference value is build like this:
1385 //<section1>:true;<section2>:false....
1387 String value
= preference
.getValue();
1388 String
[] sections
= value
.split(";");
1389 Map
<String
, Boolean
> sectionMap
= new HashMap
<String
, Boolean
>();
1390 String
[] sectionValues
;
1391 for (String sectionValue
: sections
){
1392 sectionValues
= sectionValue
.split(":");
1393 sectionMap
.put(sectionValues
[0], Boolean
.valueOf(sectionValues
[1]));
1395 config
.setAllowOverride(preference
.isAllowOverride());
1396 config
.setSimpleDetailsViewActivated(getValue(sectionMap
, "simpleViewActivated"));
1398 // getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON,
1399 // (getValue(sectionMap, "taxon")));
1400 config
.setTaxonSectionActivated(getValue(sectionMap
, "taxon"));
1402 config
.setSecDetailsActivated(getValue(sectionMap
, "taxon.SecEnabled"));
1403 config
.setSecEnabled(getValue(sectionMap
, "taxon.SecDetails"));
1405 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID,
1406 // (getValue(sectionMap, "lsid")));
1407 config
.setLSIDActivated(getValue(sectionMap
, "lsid"));
1409 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
1410 // (getValue(sectionMap, "nc")));
1411 config
.setNomenclaturalCodeActived(getValue(sectionMap
, "nc"));
1413 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
1414 // (getValue(sectionMap, "ap")));
1415 config
.setAppendedPhraseActivated(getValue(sectionMap
, "ap"));
1417 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK,
1418 // (getValue(sectionMap, "rank")));
1419 config
.setRankActivated(getValue(sectionMap
, "rank"));
1422 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
1423 // (getValue(sectionMap, "atomisedEpithets")));
1424 config
.setAtomisedEpithetsActivated(getValue(sectionMap
, "atomisedEpithets"));
1426 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
1427 // (getValue(sectionMap,"author")));
1428 config
.setAuthorshipSectionActivated(getValue(sectionMap
,"author"));
1430 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
1431 // (getValue(sectionMap, "nomRef")));
1432 config
.setNomenclaturalReferenceSectionActivated(sectionMap
.get("nomRef"));
1434 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
1435 // (getValue(sectionMap, "nomStat")));
1436 config
.setNomenclaturalStatusSectionActivated(getValue(sectionMap
, "nomStat"));
1439 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
1440 // (getValue(sectionMap,"protologue")));
1441 config
.setProtologueActivated(getValue(sectionMap
,"protologue"));
1443 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
1444 // (getValue(sectionMap,"typeDes")));
1445 config
.setTypeDesignationSectionActivated(getValue(sectionMap
,"typeDes"));
1447 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
1448 // (getValue(sectionMap,"nameRelation")));
1449 config
.setNameRelationsSectionActivated(getValue(sectionMap
,"nameRelation"));
1451 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_HYBRID,
1452 // (getValue(sectionMap, "hybrid")));
1453 config
.setHybridActivated(getValue(sectionMap
,"hybrid"));
1455 config
.setSimpleDetailsViewActivated(getBooleanValue(SHOW_SIMPLE_NAME_DETAILS_SECTION
));
1456 config
.setTaxonSectionActivated(getBooleanValue(SHOW_SIMPLE_NAME_DETAILS_TAXON
));
1457 config
.setSecDetailsActivated(getBooleanValue(SHOW_SEC_DETAILS
));
1458 config
.setSecEnabled(getBooleanValue(DISABLE_SEC
));
1459 config
.setLSIDActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_LSID
));
1460 config
.setNomenclaturalCodeActived(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
));
1461 config
.setAppendedPhraseActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE
));
1462 config
.setRankActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_RANK
));
1463 config
.setAtomisedEpithetsActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
));
1464 config
.setAuthorshipSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
));
1465 config
.setNomenclaturalReferenceSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
));
1466 config
.setNomenclaturalStatusSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
));
1467 config
.setProtologueActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
));
1468 config
.setTypeDesignationSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
));
1469 config
.setNameRelationsSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
));
1470 config
.setHybridActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_HYBRID
));
1480 public static void setPreferredNameDetailsConfiguration(NameDetailsConfigurator config
, boolean local
) {
1481 CdmPreference preference
= null;
1484 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewDatabaseInstance(), EditorPreferencePredicate
.NameDetailsView
, config
.toString());
1486 setPreferenceToDB(preference
);
1488 //also add to local preferences
1489 setBooleanValue(SHOW_SIMPLE_NAME_DETAILS_SECTION
, config
.isSimpleDetailsViewActivated());
1490 setBooleanValue(SHOW_SIMPLE_NAME_DETAILS_TAXON
, config
.isTaxonSectionActivated());
1491 setBooleanValue(SHOW_SEC_DETAILS
, config
.isSecDetailsActivated());
1492 setBooleanValue(DISABLE_SEC
, config
.isSecEnabled());
1493 setBooleanValue(SHOW_NAME_DETAILS_SECTION_LSID
, config
.isLSIDActivated());
1494 setBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
, config
.isNomenclaturalCodeActived());
1495 setBooleanValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE
, config
.isAppendedPhraseActivated());
1496 setBooleanValue(SHOW_NAME_DETAILS_SECTION_RANK
, config
.isRankActivated());
1497 setBooleanValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
, config
.isAtomisedEpithetsActivated());
1498 setBooleanValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
, config
.isAuthorshipSectionActivated());
1499 setBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
, config
.isNomenclaturalReferenceSectionActivated());
1500 setBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
, config
.isNomenclaturalStatusSectionActivated());
1501 setBooleanValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
, config
.isProtologueActivated());
1502 setBooleanValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
, config
.isTypeDesignationSectionActivated());
1503 setBooleanValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
, config
.isNameRelationsSectionActivated());
1504 setBooleanValue(SHOW_NAME_DETAILS_SECTION_HYBRID
, config
.isHybridActivated());
1508 private static Boolean
getValue(Map
<String
, Boolean
> sectionMap
, String string
) {
1509 if (sectionMap
.containsKey(string
)){
1510 return sectionMap
.get(string
);
1521 * setAbcdConfigurator
1524 * @param preferredConfiguration
1525 * a {@link eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator}
1528 public static Abcd206ImportConfigurator
getDBAbcdImportConfigurationPreference() {
1530 Abcd206ImportConfigurator config
= Abcd206ImportConfigurator
.NewInstance(null,null);
1531 ICdmRepository controller
;
1532 controller
= CdmStore
.getCurrentApplicationConfiguration();
1533 PrefKey key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), EditorPreferencePredicate
.AbcdImportConfig
);
1534 CdmPreference preference
= null;
1535 if (controller
== null){
1538 preference
= controller
.getPreferenceService().find(key
);
1539 if (preference
== null){
1542 String configString
= preference
.getValue();
1543 String
[] configArray
= configString
.split(";");
1545 for (String configItem
: configArray
){
1546 String
[] keyValue
= configItem
.split(":");
1547 String keyString
= keyValue
[0];
1548 String valueString
= null;
1549 if (keyValue
.length
>1){
1550 valueString
= keyValue
[1];
1552 if (keyString
.equals("ignoreImportOfExistingSpecimen")){
1553 config
.setIgnoreImportOfExistingSpecimen(Boolean
.valueOf(valueString
));
1554 }else if (keyString
.equals("addIndividualsAssociationsSuchAsSpecimenAndObservations")){
1555 config
.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(Boolean
.valueOf(valueString
));
1556 }else if (keyString
.equals("reuseExistingTaxaWhenPossible")){
1557 config
.setReuseExistingTaxaWhenPossible(Boolean
.valueOf(valueString
));
1558 }else if (keyString
.equals("ignoreAuthorship")){
1559 config
.setIgnoreAuthorship(Boolean
.valueOf(valueString
));
1560 }else if (keyString
.equals("addMediaAsMediaSpecimen")){
1561 config
.setAddMediaAsMediaSpecimen(Boolean
.valueOf(valueString
));
1562 }else if (keyString
.equals("reuseExistingMetaData")){
1563 config
.setReuseExistingMetaData(Boolean
.valueOf(valueString
));
1564 }else if (keyString
.equals("reuseExistingDescriptiveGroups")){
1565 config
.setReuseExistingDescriptiveGroups(Boolean
.valueOf(valueString
));
1566 }else if (keyString
.equals("allowReuseOtherClassifications")){
1567 config
.setAllowReuseOtherClassifications(Boolean
.valueOf(valueString
));
1568 }else if (keyString
.equals("deduplicateReferences")){
1569 config
.setDeduplicateReferences(Boolean
.valueOf(valueString
));
1570 }else if (keyString
.equals("deduplicateClassifications")){
1571 config
.setDeduplicateClassifications(Boolean
.valueOf(valueString
));
1572 }else if (keyString
.equals("moveNewTaxaToDefaultClassification")){
1573 config
.setMoveNewTaxaToDefaultClassification(Boolean
.valueOf(valueString
));
1574 }else if (keyString
.equals("mapUnitIdToCatalogNumber")){
1575 config
.setMapUnitIdToCatalogNumber(Boolean
.valueOf(valueString
));
1576 }else if (keyString
.equals("mapUnitIdToAccessionNumber")){
1577 config
.setMapUnitIdToAccessionNumber(Boolean
.valueOf(valueString
));
1578 }else if (keyString
.equals("mapUnitIdToBarcode")){
1579 config
.setMapUnitIdToBarcode(Boolean
.valueOf(valueString
));
1580 }else if (keyString
.equals("overwriteExistingSpecimens")){
1581 config
.setOverwriteExistingSpecimens(Boolean
.valueOf(valueString
));
1582 }else if (keyString
.equals("nomenclaturalCode")){
1583 config
.setNomenclaturalCode(NomenclaturalCode
.fromString(valueString
));
1585 logger
.debug("This key of the abcd configurator needs to be added to the transformer: " + keyString
);
1593 public static Abcd206ImportConfigurator
getLocalAbcdImportConfigurator(){
1594 Abcd206ImportConfigurator config
= Abcd206ImportConfigurator
.NewInstance(null,null);
1596 config
.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS
));
1598 config
.setAddMediaAsMediaSpecimen(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN
));
1600 config
.setAllowReuseOtherClassifications(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS
));
1601 config
.setDeduplicateClassifications(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS
));
1602 config
.setDeduplicateReferences(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES
));
1603 config
.setRemoveCountryFromLocalityText(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REMOVE_COUNTRY_FROM_LOCALITY_TEXT
));
1604 config
.setGetSiblings(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS
));
1605 config
.setIgnoreAuthorship(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP
));
1606 config
.setIgnoreImportOfExistingSpecimen(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN
));
1607 config
.setMapUnitIdToAccessionNumber(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER
));
1608 config
.setMapUnitIdToBarcode(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE
));
1609 config
.setMapUnitIdToCatalogNumber(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER
));
1610 config
.setMoveNewTaxaToDefaultClassification(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION
));
1611 config
.setOverwriteExistingSpecimens(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN
));
1612 config
.setReuseExistingDescriptiveGroups(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS
));
1613 config
.setReuseExistingMetaData(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA
));
1614 config
.setReuseExistingTaxaWhenPossible(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE
));
1615 config
.setNomenclaturalCode(NomenclaturalCode
.getByKey(getStringValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE
)));
1622 public static void updateAbcdImportConfigurationPreference() {
1623 CdmPreferenceCache cache
= CdmPreferenceCache
.instance();
1624 CdmPreference pref
= cache
.get(EditorPreferencePredicate
.AbcdImportConfig
.getKey());
1626 if (!getBooleanValue(prefOverrideKey(EditorPreferencePredicate
.AbcdImportConfig
.getKey())) || !pref
.isAllowOverride()){
1627 resetToDBPreferenceAbcdCOnfigurator();
1632 public static void resetToDBPreferenceAbcdCOnfigurator(){
1633 Abcd206ImportConfigurator config
= getDBAbcdImportConfigurationPreference();
1634 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS
, config
.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
1635 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN
, config
.isAddMediaAsMediaSpecimen());
1637 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS
, config
.isAllowReuseOtherClassifications());
1638 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS
, config
.isDeduplicateClassifications());
1639 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES
, config
.isDeduplicateReferences());
1641 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS
, config
.isGetSiblings());
1642 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP
, config
.isIgnoreAuthorship());
1643 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN
, config
.isIgnoreImportOfExistingSpecimen());
1644 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER
, config
.isMapUnitIdToAccessionNumber());
1645 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE
, config
.isMapUnitIdToBarcode());
1646 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER
, config
.isMapUnitIdToCatalogNumber());
1647 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION
, config
.isMoveNewTaxaToDefaultClassification());
1648 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN
, config
.isOverwriteExistingSpecimens());
1649 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS
, config
.isReuseExistingDescriptiveGroups());
1650 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA
, config
.isReuseExistingMetaData());
1651 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE
, config
.isReuseExistingTaxaWhenPossible());
1652 if (config
.getNomenclaturalCode() != null){
1653 setStringValue(ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE
, config
.getNomenclaturalCode().getKey());
1661 public NameDetailsConfigurator
createLocalNameDetailsViewConfig(boolean local
) {
1662 NameDetailsConfigurator config
= new NameDetailsConfigurator(true);
1664 config
.setSimpleDetailsViewActivated(getBooleanValue(IPreferenceKeys
.SHOW_SIMPLE_NAME_DETAILS_SECTION
));
1665 config
.setAppendedPhraseActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE
));
1666 config
.setAtomisedEpithetsActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
));
1667 config
.setAuthorshipSectionActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
));
1668 config
.setLSIDActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_LSID
));
1669 config
.setNameApprobiationActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION
));
1670 config
.setNameCacheActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_CACHE
));
1671 config
.setNameRelationsSectionActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
));
1672 config
.setNomenclaturalCodeActived(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
));
1673 config
.setNomenclaturalStatusSectionActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
));
1674 config
.setNomenclaturalReferenceSectionActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
));
1675 config
.setProtologueActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
));
1676 config
.setRankActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_RANK
));
1677 config
.setTaxonSectionActivated(getBooleanValue(IPreferenceKeys
.SHOW_SIMPLE_NAME_DETAILS_TAXON
));
1678 config
.setTypeDesignationSectionActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
));
1679 config
.setHybridActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_HYBRID
));
1688 public static void saveConfigToPrefernceStore(NameDetailsConfigurator config
) {
1689 setBooleanValue(IPreferenceKeys
.SHOW_SIMPLE_NAME_DETAILS_SECTION
,
1690 config
.isSimpleDetailsViewActivated());
1691 setBooleanValue(IPreferenceKeys
.SHOW_SIMPLE_NAME_DETAILS_TAXON
, config
.isTaxonSectionActivated());
1692 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_LSID
, config
.isLSIDActivated());
1693 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
,
1694 config
.isNomenclaturalCodeActived());
1695 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NAMECACHE
,
1696 config
.isNameCacheActivated());
1697 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE
,
1698 config
.isAppendedPhraseActivated());
1699 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_RANK
, config
.isRankActivated());
1700 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
,
1701 config
.isAtomisedEpithetsActivated());
1702 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE
,
1703 config
.isAuthorCacheActivated());
1704 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
,
1705 config
.isAuthorshipSectionActivated());
1706 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
,
1707 config
.isNomenclaturalReferenceSectionActivated());
1708 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
,
1709 config
.isNomenclaturalStatusSectionActivated());
1710 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
,
1711 config
.isProtologueActivated());
1712 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
,
1713 config
.isTypeDesignationSectionActivated());
1714 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
,
1715 config
.isNameRelationsSectionActivated());
1716 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_HYBRID
,
1717 config
.isHybridActivated());
1724 public static boolean isSortTaxaByRankAndName() {
1726 return getBooleanValue(IPreferenceKeys
.SORT_TAXA_BY_RANK_AND_NAME
);
1732 public static boolean isSortNamedAreaByOrderInVocabulary() {
1734 return getBooleanValue(EditorPreferencePredicate
.AreasSortedByIdInVocabulary
.getKey());
1737 public static void setSortNamedAreasByOrderInVocabulary(boolean isSortByVocabularyOrder
) {
1738 setBooleanValue(EditorPreferencePredicate
.AreasSortedByIdInVocabulary
.getKey(), isSortByVocabularyOrder
);
1744 * setPreferredNamedAreasForDistributionEditor
1747 * @param saveCheckedElements
1748 * @param saveGrayedElements
1750 public static void setLastSelectedReference(
1751 List
<String
> lastSelectedReferences
) {
1753 setStringValue(PreferencesUtil
.LAST_SELECTED_REFERENCES
, lastSelectedReferences
.toString());
1758 * setPreferredNamedAreasForDistributionEditor
1761 * @param saveCheckedElements
1762 * @param saveGrayedElements
1764 public static List
<String
> getLastSelectedReferences() {
1766 //IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
1767 String lastSelected
= getStringValue(PreferencesUtil
.LAST_SELECTED_REFERENCES
);
1768 List
<String
> result
= new ArrayList
<>();
1769 if (!StringUtils
.isBlank(lastSelected
)){
1770 Collections
.addAll(result
, lastSelected
.substring(1,lastSelected
.length()-1).split(", "));
1778 * setPreferredNamedAreasForDistributionEditor
1781 * @param saveCheckedElements
1782 * @param saveGrayedElements
1784 public static void setPreferredNamedAreasForDistributionEditor(
1785 String saveCheckedElements
, String saveGrayedElements
, boolean local
) {
1787 setStringValue(PreferencePredicate
.AvailableDistributionAreaTerms
.getKey(), saveCheckedElements
);
1791 CdmPreference preference
= null;
1793 if (saveCheckedElements
== null){
1794 preference
= getPreferenceFromDB(PreferencePredicate
.AvailableDistributionAreaTerms
);
1796 if (preference
== null){
1799 setStringValue(PreferencePredicate
.AvailableDistributionAreaTerms
.getKey(),
1800 saveCheckedElements
);
1801 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.AvailableDistributionAreaTerms
, saveCheckedElements
);
1802 setPreferenceToDB(preference
);
1806 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.AvailableDistributionAreaTerms
, saveCheckedElements
);
1807 setPreferenceToDB(preference
);
1808 setStringValue(PreferencePredicate
.AvailableDistributionAreaTerms
.getKey(),
1809 saveCheckedElements
);
1817 * @param saveCheckedElements
1818 * @param saveCheckedElements2
1821 public static void setPreferredVocabulariesForDistributionEditor(String saveCheckedElements
,
1824 setStringValue(PreferencePredicate
.AvailableDistributionAreaVocabularies
.getKey(), saveCheckedElements
);
1827 ICdmRepository controller
;
1828 CdmPreference preference
= null;
1830 if (saveCheckedElements
== null){
1831 preference
= getPreferenceFromDB(PreferencePredicate
.AvailableDistributionAreaVocabularies
);
1833 if (preference
== null){
1836 setStringValue(PreferencePredicate
.AvailableDistributionAreaVocabularies
.getKey(),
1837 saveCheckedElements
);
1838 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.AvailableDistributionAreaVocabularies
, saveCheckedElements
);
1839 setPreferenceToDB(preference
);
1842 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.AvailableDistributionAreaVocabularies
, saveCheckedElements
);
1843 setPreferenceToDB(preference
);
1844 setStringValue(PreferencePredicate
.AvailableDistributionAreaVocabularies
.getKey(),
1845 saveCheckedElements
);
1855 * @param saveCheckedElements
1856 * @param saveCheckedElements2
1859 public static String
getPreferredVocabulariesForDistributionEditor(boolean local
) {
1862 String pref
= getStringValue(PreferencePredicate
.AvailableDistributionAreaVocabularies
.getKey());
1866 CdmPreference preference
= null;
1867 preference
= getPreferenceFromDB(PreferencePredicate
.AvailableDistributionAreaVocabularies
);
1868 if (preference
== null){
1871 return preference
.getValue();
1880 public static boolean getFilterCommonNameReferences(){
1881 return getBooleanValue(PreferencesUtil
.FILTER_COMMON_NAME_REFERENCES
);
1887 public static void updateDBPreferences() {
1888 CdmPreference preference
= null;
1889 CdmPreferenceCache cache
= CdmPreferenceCache
.instance();
1890 cache
.getAllTaxEditorDBPreferences();
1894 updateAbcdImportConfigurationPreference();
1897 NameDetailsConfigurator config
= getPreferredNameDetailsConfiguration(false);
1898 if (config
!= null ){
1899 if (!getBooleanValue(OVERRIDE_NAME_DETAILS
) || !getBooleanValue(ALLOW_OVERRIDE_NAME_DETAILS
)){
1900 setPreferredNameDetailsConfiguration(config
, false);