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
.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
;
76 * PreferencesUtil class.
83 public class PreferencesUtil
implements IPreferenceKeys
{
88 public static final String PREFERRED_TERMS_CHANGE
= "preferred_terms";
90 public static final String P2_REPOSITORIES_DELIM
= ",";
91 public static final String P2_REPOSITORY_FIELDS_DELIM
= ";";
93 private final static Logger logger
= Logger
.getLogger(PreferencesUtil
.class);
104 * @return a {@link org.eclipse.jface.preference.IPreferenceStore} object.
106 public static IPreferenceStore
getPreferenceStore() {
107 return TaxeditorStorePlugin
.getDefault().getPreferenceStore();
110 private static String
prefKey(String name
) {
111 return name
+ "_"+ ((CdmRemoteSource
)CdmStore
.getActiveCdmSource()).toString();
114 public static String
prefOverrideKey(String name
) {
115 return name
+ "_OVERRIDE_"+ ((CdmRemoteSource
)CdmStore
.getActiveCdmSource()).toString();
125 public static void setStringValue(String name
, String value
) {
126 getPreferenceStore().setValue(prefKey(name
), value
);
136 public static void setIntValue(String name
, int value
) {
137 getPreferenceStore().setValue(prefKey(name
), value
);
147 public static void setBooleanValue(String name
, boolean value
) {
148 getPreferenceStore().setValue(prefKey(name
), value
);
158 public static void setDoubleValue(String name
, double value
) {
159 getPreferenceStore().setValue(prefKey(name
), value
);
169 public static void setFloatValue(String name
, float value
) {
170 getPreferenceStore().setValue(name
+ ((CdmRemoteSource
)CdmStore
.getActiveCdmSource()).toString(), value
);
180 public static void setLongValue(String name
, long value
) {
181 getPreferenceStore().setValue(prefKey(name
), value
);
191 public static String
getStringValue(String name
, boolean local
) {
193 String prefValue
= getDBPreferenceValue(name
);
194 if (prefValue
== null || local
){
195 String dbSpecific
= prefKey(name
);
196 if (getPreferenceStore().contains(dbSpecific
)){
197 prefValue
= getPreferenceStore().getString(dbSpecific
);
199 prefValue
= getPreferenceStore().
207 public static String
getStringValue(String name
){
208 return getStringValue(name
, false);
211 private static String
getDBPreferenceValue(String name
) {
212 CdmPreferenceCache cache
= CdmPreferenceCache
.instance();
213 if (cache
.get(name
) != null){
214 CdmPreference pref
= cache
.get(name
);
215 if (!pref
.isAllowOverride() || !getBooleanValue(prefOverrideKey(name
))){
216 return pref
.getValue();
229 public static int getIntValue(String name
) {
230 String prefValue
= getDBPreferenceValue(name
);
231 Integer result
= null;
233 result
= Integer
.parseInt(prefValue
);
234 }catch(NumberFormatException e
){
235 logger
.debug("Preference value of " + name
+ " is not a number");
238 String dbSpecific
= prefKey(name
);
239 if (getPreferenceStore().contains(dbSpecific
)){
240 result
= getPreferenceStore().getInt(dbSpecific
);
242 result
= getPreferenceStore().
258 public static boolean getBooleanValue(String name
) {
259 if (CdmStore
.isActive()){
260 String prefValue
= getDBPreferenceValue(name
);
261 if (prefValue
== null){
262 String dbSpecific
= prefKey(name
);
263 if (getPreferenceStore().contains(dbSpecific
)){
264 return getPreferenceStore().getBoolean(dbSpecific
);
266 return getPreferenceStore().
270 return Boolean
.valueOf(prefValue
);
274 return getPreferenceStore().getBoolean(name
);
286 public static double getDoubleValue(String name
) {
287 String prefValue
= getDBPreferenceValue(name
);
288 Double result
= null;
290 result
= Double
.parseDouble(prefValue
);
291 }catch(NumberFormatException e
){
292 logger
.debug("Preference value of " + name
+ " is not a number");
295 String dbSpecific
= prefKey(name
);
296 if (getPreferenceStore().contains(dbSpecific
)){
297 result
= getPreferenceStore().getDouble(dbSpecific
);
299 result
= getPreferenceStore().
314 public static float getFloatValue(String name
) {
315 String prefValue
= getDBPreferenceValue(name
);
318 result
= Float
.parseFloat(prefValue
);
319 }catch(NumberFormatException e
){
320 logger
.debug("Preference value of " + name
+ " is not a number");
323 String dbSpecific
= prefKey(name
);
324 if (getPreferenceStore().contains(dbSpecific
)){
325 result
= getPreferenceStore().getFloat(dbSpecific
);
327 result
= getPreferenceStore().
342 public static long getLongValue(String name
) {
343 String prefValue
= getDBPreferenceValue(name
);
346 result
= Long
.parseLong(prefValue
);
347 }catch(NumberFormatException e
){
348 logger
.debug("Preference value of " + name
+ " is not a number");
351 String dbSpecific
= prefKey(name
);
352 if (getPreferenceStore().contains(dbSpecific
)){
353 result
= getPreferenceStore().getLong(dbSpecific
);
355 result
= getPreferenceStore().
365 * setPreferredNomenclaturalCode
368 * @param preferredCode
369 * a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
372 public static CdmPreference
setPreferredNomenclaturalCode(
373 String preferenceValue
, boolean local
) {
375 setStringValue(PREFERRED_NOMENCLATURAL_CODE_KEY
,
379 ICdmRepository controller
;
380 controller
= CdmStore
.getCurrentApplicationConfiguration();
381 if (controller
== null){
386 key
= CdmPreference
.NewKey(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.NomenclaturalCode
);
387 }catch (Exception e
){
388 System
.out
.println(e
.getStackTrace());
390 CdmPreference preference
= null;
392 if (preferenceValue
== null){
393 preference
= controller
.getPreferenceService().find(key
);
394 if (preference
== null){
397 setStringValue(PREFERRED_NOMENCLATURAL_CODE_KEY
,
398 preference
.getValue());
403 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.NomenclaturalCode
, preferenceValue
);
404 controller
.getPreferenceService().set(preference
);
416 * setPreferredNomenclaturalCode
419 * @param preferredCode
420 * a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
423 public static void setPreferredNomenclaturalCode(
424 CdmPreference preference
) {
426 ICdmRepository controller
;
427 controller
= CdmStore
.getCurrentApplicationConfiguration();
428 if (controller
== null){
433 key
= CdmPreference
.NewKey(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.NomenclaturalCode
);
434 }catch (Exception e
){
435 System
.out
.println(e
.getStackTrace());
438 controller
.getPreferenceService().set(preference
);
443 public static NomenclaturalCode
getPreferredNomenclaturalCode(){
444 if (getBooleanValue(prefOverrideKey(PreferencePredicate
.NomenclaturalCode
.getKey()))) {
445 return getPreferredNomenclaturalCode(true);
447 return getPreferredNomenclaturalCode(false);
453 * getPreferredNomenclaturalCode
456 * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
458 public static NomenclaturalCode
getPreferredNomenclaturalCode(boolean useLocal
) {
460 CdmPreference pref
= null;
462 pref
= getPreferenceFromDB(PreferencePredicate
.NomenclaturalCode
);
465 String preferredCode
;
467 preferredCode
= getStringValue(
468 PREFERRED_NOMENCLATURAL_CODE_KEY
, true);
471 preferredCode
= pref
.getValue();
474 return getPreferredNomenclaturalCode(preferredCode
);
480 * getPreferredNomenclaturalCode
483 * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
485 public static NomenclaturalCode
getPreferredNomenclaturalCode(String preferenceKeyNomenclaturalCode
) {
487 for (NomenclaturalCode code
: NomenclaturalCodeHelper
.getAllCodes()) {
488 if (getPreferenceKey(code
).equals(preferenceKeyNomenclaturalCode
)) {
495 public static boolean isShowTaxonAssociations(){
496 boolean result
= getBooleanValue(EditorPreferencePredicate
.ShowTaxonAssociations
.getKey());
500 public static boolean isShowLifeForm(){
501 boolean result
= getBooleanValue(EditorPreferencePredicate
.ShowLifeForm
.getKey());
505 public static boolean isDeterminationOnlyForFieldUnits(){
506 boolean result
= getBooleanValue(EditorPreferencePredicate
.DeterminationOnlyForFieldUnits
.getKey());
510 public static boolean isCollectingAreaInGeneralSection(){
511 boolean result
= getBooleanValue(EditorPreferencePredicate
.ShowCollectingAreasInGeneralSection
.getKey());
515 public static CdmPreference
getPreferenceFromDB(IPreferencePredicate predicate
){
516 ICdmRepository controller
;
517 CdmPreference pref
= null;
520 if(CdmStore
.isActive()){
521 controller
= CdmStore
.getCurrentApplicationConfiguration();
522 PrefKey key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), predicate
);
523 pref
= controller
.getPreferenceService().find(key
);
533 public static void setPreferenceToDB(CdmPreference preference
){
534 ICdmRepository controller
;
536 if(CdmStore
.isActive()){
537 controller
= CdmStore
.getCurrentApplicationConfiguration();
538 controller
.getPreferenceService().set(preference
);
548 public static String
getPreferredDefaultLangugae(){
549 String preferredLanguage
= getStringValue(DEFAULT_LANGUAGE_EDITOR
);
550 if(StringUtils
.isNotEmpty(preferredLanguage
) && StringUtils
.isNotBlank(preferredLanguage
)){
551 return preferredLanguage
;
556 public static boolean isShowMediaPreview(){
557 boolean isShowMediaPreview
= getBooleanValue(SHOW_MEDIA_PREVIEW
);
558 return isShowMediaPreview
;
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
566 * a {@link java.lang.Class} object.
567 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
569 public static IMatchStrategy
getMatchStrategy(Class
<?
> clazz
) {
570 String className
= clazz
.getName();
571 if (getBooleanValue(MATCH_STRATEGY_PREFIX
+ className
)) {
572 IMatchStrategy matchStrategy
= getDefaultMatchStrategy(clazz
);
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
);
581 matchStrategy
.setMatchMode(fieldName
, matchMode
);
582 } catch (MatchException e
) {
583 MessagingUtils
.error(PreferencesUtil
.class, e
);
584 throw new RuntimeException(e
);
588 return matchStrategy
;
590 return getDefaultMatchStrategy(clazz
);
594 * Stores a matchStrategy into the preference store.
596 * @param matchStrategy
597 * a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy}
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);
604 List
<FieldMatcher
> fieldMatchers
= matchStrategy
.getMatching().getFieldMatchers(false);
606 for (FieldMatcher fieldMatcher
: fieldMatchers
) {
607 String fieldName
= fieldMatcher
.getPropertyName();
609 getMatchStrategyFieldName(className
, fieldName
),
610 fieldMatcher
.getMatchMode().name());
615 * Helper method to create the preference property for a match field.
621 private static String
getMatchStrategyFieldName(String className
,
623 return MATCH_STRATEGY_PREFIX
+ className
+ "." + fieldName
;
627 * Returns the default match strategy for a given class.
630 * a {@link java.lang.Class} object.
631 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
633 public static IMatchStrategy
getDefaultMatchStrategy(Class clazz
) {
634 return DefaultMatchStrategy
.NewInstance(clazz
);
639 * getDateFormatPattern
642 * @return a {@link java.lang.String} object.
644 public static String
getDateFormatPattern() {
645 // TODO make this configurable in properties
646 String pattern
= "Y-M-d H:m";
652 * addTermToPreferredTerms
660 public static <T
extends TermBase
> void addTermToPreferredTerms(T term
) {
662 // VocabularyEnum vocabulary =
663 // VocabularyEnum.getVocabularyEnum(term.getClass());
665 // getPreferenceStore().setValue(getPreferenceKey(term),
666 // VocabularyStore.getTermVocabulary(vocabulary).getTerms().contains(term));
668 // firePreferencesChanged(term.getClass());
672 * Construct a unique key using the CdmBase object's uuid
677 private static String
getPreferenceKey(ICdmBase cdmBase
) {
678 cdmBase
= HibernateProxyHelper
.deproxy(cdmBase
);
680 String key
= cdmBase
.getClass().getName().concat(".")
681 .concat(cdmBase
.getUuid().toString());
682 if (key
.contains("javassist")) {
683 MessagingUtils
.info("proxy");
689 * Construct a unique key using the CdmBase object's uuid
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.");
708 * Construct a unique key using the CdmBase object's uuid
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.");
725 * Retrieves search preferences from the preference store
727 * @return an {@link ITaxonServiceConfigurator} to pass to search methods
729 public static IFindTaxaAndNamesConfigurator
getSearchConfigurator() {
730 IFindTaxaAndNamesConfigurator configurator
= initializeSearchConfigurator();
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)));
746 * create new preferences, setting all search options to true
749 * {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
752 public static IFindTaxaAndNamesConfigurator
initializeSearchConfigurator() {
753 IFindTaxaAndNamesConfigurator configurator
= FindTaxaAndNamesConfiguratorImpl
.NewInstance();
755 configurator
.setDoTaxa(true);
756 configurator
.setDoSynonyms(true);
757 configurator
.setDoNamesWithoutTaxa(true);
758 configurator
.setDoTaxaByCommonNames(true);
760 configurator
.setTaxonPropertyPath(Arrays
.asList("$", "titleCache",
761 "name", "name.$", "relationsFromThisTaxon.$"));
763 configurator
.setSynonymPropertyPath(Arrays
.asList("$", "titleCache",
764 "name", "name.$", "synonyms.relatedTo.*"));
767 // match mode is a simple like, actually all other match modes are kind
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
) ;
780 * Store search preferences
782 * @param configurator
784 * {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
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());
801 * firePreferencesChanged
805 * a {@link java.lang.Class} object.
807 public static void firePreferencesChanged(Class clazz
) {
808 getPreferenceStore().firePropertyChangeEvent(PREFERRED_TERMS_CHANGE
,
812 public static String
createPreferenceString(String property
){
813 return prefKey(property
);
816 public static String
createOverridePreferenceString(String property
){
817 return prefOverrideKey(property
);
822 * Set default values for preferences
824 public static void setDefaults() {
825 getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_TAXA
, true);
826 getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_SYNONYMS
,
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(EditorPreferencePredicate
.DistributionEditorActivated
.getKey()), Boolean
.valueOf(EditorPreferencePredicate
.DistributionEditorActivated
.getDefaultValue().toString()));
838 getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate
.DisplayOfAreasInDistributionEditor
.getKey()), EditorPreferencePredicate
.DisplayOfAreasInDistributionEditor
.getDefaultValue().toString());
839 getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate
.DisplayOfStatus
.getKey()), EditorPreferencePredicate
.DisplayOfStatus
.getDefaultValue().toString());
843 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
), true);
844 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE
), true);
845 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
), true);
846 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_HYBRID
), true);
847 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_LSID
), true);
848 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
), true);
849 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NAMECACHE
), true);
850 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
), true);
851 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
), true);
852 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
), true);
853 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
), true);
854 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_RANK
), true);
855 getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
), true);
856 //Navigator preferences
857 getPreferenceStore().setDefault(createPreferenceString(SORT_NODES
), NavigatorOrderEnum
.RankAndNameOrder
.getKey());
859 getPreferenceStore().setDefault(createPreferenceString(SORT_TAXA_BY_RANK_AND_NAME
), true);
860 //override db preferences
861 getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(EditorPreferencePredicate
.AbcdImportConfig
.getKey())), false);
862 getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(EditorPreferencePredicate
.ShowSpecimen
.getKey())), false);
863 getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(EditorPreferencePredicate
.NameDetailsView
.getKey())), false);
864 getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(EditorPreferencePredicate
.DistributionEditorActivated
.getKey())), false);
866 getPreferenceStore().setDefault(createPreferenceString(FILTER_COMMON_NAME_REFERENCES
), false);
867 getPreferenceStore().setDefault(createPreferenceString(SHOW_SPECIMEN
), true);
868 getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate
.ShowTaxonNodeWizard
.getKey()), Boolean
.valueOf(EditorPreferencePredicate
.ShowTaxonNodeWizard
.getDefaultValue().toString()));
869 getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate
.ShowNamespaceInSource
.getKey()), Boolean
.valueOf(EditorPreferencePredicate
.ShowNamespaceInSource
.getDefaultValue().toString()));
870 getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate
.ShowIdInSource
.getKey()), Boolean
.valueOf(EditorPreferencePredicate
.ShowIdInSource
.getDefaultValue().toString()));
871 getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate
.DisableMultiClassification
.getKey()), Boolean
.valueOf(EditorPreferencePredicate
.DisableMultiClassification
.getDefaultValue().toString()));
872 getPreferenceStore().setDefault(createPreferenceString(DISABLE_SEC
), false);
873 getPreferenceStore().setDefault(createPreferenceString(SHOW_SEC_DETAILS
), true);
878 * checkNomenclaturalCode
881 public static void checkNomenclaturalCode() {
882 // First time Editor is opened, no nomenclatural code has been set
883 if (PreferencesUtil
.getPreferredNomenclaturalCode(true) == null) {
884 PreferencesUtil
.setPreferredNomenclaturalCode(getPreferenceKey(NomenclaturalCode
.ICNAFP
), true);
890 public static void setNomenclaturalCodePreferences(){
891 ICdmRepository controller
;
892 controller
= CdmStore
.getCurrentApplicationConfiguration();
893 PrefKey key
= CdmPreference
.NewKey(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.NomenclaturalCode
);
894 CdmPreference preference
= null;
895 if (controller
== null){
898 preference
= controller
.getPreferenceService().find(key
);
899 if (preference
== null){
902 // setBooleanValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY, preference.isAllowOverride());
904 int index
= StringUtils
.lastIndexOf(preference
.getValue(), ".");
905 UUID uuid
= UUID
.fromString(preference
.getValue().substring(index
+1, preference
.getValue().length()));
906 NomenclaturalCode preferredCode
= NomenclaturalCode
.getByUuid(uuid
);
908 setStringValue(PREFERRED_NOMENCLATURAL_CODE_KEY
,
909 getPreferenceKey(preferredCode
));
913 public static void checkDefaultLanguage(){
914 if(PreferencesUtil
.getPreferredDefaultLangugae() == null){
915 Shell shell
= AbstractUtility
.getShell();
916 int open
= new DefaultLanguageDialog(shell
).open();
917 if(open
== Window
.OK
){
918 PlatformUI
.getWorkbench().restart();
921 //TODO:In case of a reinstall, the config.ini will be overwritten
922 // here you create config.ini with the stored key from preferences
928 * getMapServiceAccessPoint
931 * @return a {@link java.lang.String} object.
933 public static String
getMapServiceAccessPoint() {
934 return getStringValue(EDIT_MAP_SERVICE_ACCES_POINT
);
939 * shouldConnectAtStartUp
944 public static boolean shouldConnectAtStartUp() {
945 //FIXME : force SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
946 //return getBooleanValue(SHOULD_CONNECT_AT_STARTUP);
952 * getDefaultFeatureTreeForTextualDescription
955 * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
957 public static FeatureTree
getDefaultFeatureTreeForTextualDescription() {
958 String uuidString
= getStringValue(
959 FEATURE_TREE_DEFAULT_TEXT
);
960 if (StringUtils
.isBlank(uuidString
)) {
963 FeatureTree tree
= CdmStore
.getService(
964 IFeatureTreeService
.class).load(UUID
.fromString(uuidString
));
965 if (tree
.getId() == 0) {
973 * getDefaultFeatureTreeForStructuredDescription
976 * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
978 public static FeatureTree
getDefaultFeatureTreeForStructuredDescription() {
979 String uuidString
= getStringValue(
980 FEATURE_TREE_DEFAULT_STRUCTURE
);
981 return CdmUtils
.isEmpty(uuidString
) ?
null : CdmStore
.getService(
982 IFeatureTreeService
.class).load(UUID
.fromString(uuidString
));
987 * setSortRanksHierarchichally
993 public static void setSortRanksHierarchichally(boolean selection
) {
994 setBooleanValue(SORT_RANKS_HIERARCHICHALLY
, selection
);
999 * getSortRanksHierarchichally
1002 * @return a boolean.
1004 public static boolean getSortRanksHierarchichally() {
1005 return getBooleanValue(SORT_RANKS_HIERARCHICHALLY
);
1008 public static boolean isMultilanguageTextEditingCapability() {
1009 return getBooleanValue(
1010 MULTILANGUAGE_TEXT_EDITING_CAPABILITY
);
1013 public static Language
getGlobalLanguage() {
1016 String languageUuidString
= getStringValue(
1017 GLOBAL_LANGUAGE_UUID
);
1019 if(!CdmStore
.isActive()) {
1020 MessagingUtils
.noDataSourceWarningDialog(languageUuidString
);
1024 if (CdmUtils
.isBlank(languageUuidString
)) {
1025 return Language
.getDefaultLanguage();
1028 UUID languageUuid
= UUID
.fromString(languageUuidString
);
1029 return (Language
) CdmStore
.getService(ITermService
.class).load(
1033 public static void setGlobalLanguage(Language language
) {
1034 if(language
!= null) {
1035 setStringValue(GLOBAL_LANGUAGE_UUID
,language
.getUuid().toString());
1036 CdmStore
.setDefaultLanguage(language
);
1044 public static Map
<MarkerType
, Boolean
> getEditMarkerTypePreferences() {
1045 List
<MarkerType
> markerTypes
= CdmStore
.getTermManager()
1046 .getPreferredTerms(MarkerType
.class);
1048 Map
<MarkerType
, Boolean
> result
= new HashMap
<MarkerType
, Boolean
>();
1050 for (MarkerType markerType
: markerTypes
) {
1051 String name
= getMarkerTypeEditingPreferenceKey(markerType
);
1052 Boolean value
= getBooleanValue(name
);
1054 result
.put(markerType
, value
);
1061 * @param markerTypeEditingMap
1063 public static void setEditMarkerTypePreferences(
1064 Map
<MarkerType
, Boolean
> markerTypeEditingMap
) {
1065 for (MarkerType markerType
: markerTypeEditingMap
.keySet()) {
1066 String name
= getMarkerTypeEditingPreferenceKey(markerType
);
1067 setBooleanValue(name
,
1068 markerTypeEditingMap
.get(markerType
));
1073 private static String
getMarkerTypeEditingPreferenceKey(
1074 MarkerType markerType
) {
1075 markerType
= HibernateProxyHelper
.deproxy(markerType
);
1076 return markerType
.getClass().getName() + EDIT_MARKER_TYPE_PREFIX
;
1081 * setEditMarkerTypePreference
1085 * a {@link org.eclipse.ui.IEditorInput} object.
1087 * a {@link eu.etaxonomy.cdm.model.common.MarkerType} object.
1091 public static void setEditMarkerTypePreference(MarkerType markerType
,
1094 getMarkerTypeEditingPreferenceKey(markerType
), edit
);
1100 public static DerivedUnitFacadeConfigurator
getDerivedUnitConfigurator() {
1101 DerivedUnitFacadeConfigurator configurator
= DerivedUnitFacadeConfigurator
1103 configurator
.setMoveDerivedUnitMediaToGallery(true);
1104 configurator
.setMoveFieldObjectMediaToGallery(true);
1105 return configurator
;
1109 * This method will write language properties to the config.ini located in the configuration folder
1110 * of the Taxonomic Ediitor. <b>This method is only used to set the default language for Taxonomic Editor.</b>
1112 * @param setLanguage 0 is for german and 1 for english.
1113 * @throws IOException
1115 public void writePropertyToConfigFile(int setLanguage
) throws IOException
{
1116 File file
= org
.eclipse
.core
.runtime
.preferences
.ConfigurationScope
.INSTANCE
.getLocation().toFile();
1117 //give warning to user if the directory has no write access
1119 throw new IOException();
1121 Properties properties
= load(file
.getAbsolutePath()+"/config.ini");
1122 switch(setLanguage
){
1124 properties
.setProperty("osgi.nl", "de");
1125 setStringValue(IPreferenceKeys
.DEFAULT_LANGUAGE_EDITOR
, "de");
1128 properties
.setProperty("osgi.nl", "en");
1129 setStringValue(IPreferenceKeys
.DEFAULT_LANGUAGE_EDITOR
, "en");
1134 save(file
+"/config.ini", properties
);
1138 * This method loads a property from a given file and returns it.
1142 * @throws IOException
1144 private Properties
load(String filename
) throws IOException
{
1145 FileInputStream in
= new FileInputStream(filename
);
1146 Properties prop
= new Properties();
1153 * This method saves a property to the specified file.
1157 * @throws IOException
1159 private void save(String filename
, Properties properties
) throws IOException
{
1160 FileOutputStream fos
= new FileOutputStream(filename
);
1161 properties
.store(fos
, "");
1166 * Saves a list of P2 Metadata Repositories as string with specified delimiters
1170 public static void setP2Repositories(List
<MetadataRepositoryElement
> p2Repos
) {
1171 StringBuilder sb
= new StringBuilder();
1172 for(MetadataRepositoryElement p2Repo
: p2Repos
) {
1173 sb
.append(P2_REPOSITORIES_DELIM
);
1174 if(p2Repo
.getName() == null || p2Repo
.getName().isEmpty()) {
1177 sb
.append(p2Repo
.getName());
1179 sb
.append(P2_REPOSITORY_FIELDS_DELIM
);
1180 sb
.append(p2Repo
.getLocation().toString());
1181 sb
.append(P2_REPOSITORY_FIELDS_DELIM
);
1182 sb
.append(String
.valueOf(p2Repo
.isEnabled()));
1184 getPreferenceStore().setValue(P2_REPOSITORY_LIST
, sb
.toString());
1189 * Retrieves a list of previously saved P2 repositories
1193 public static List
<MetadataRepositoryElement
> getP2Repositories() {
1194 List
<MetadataRepositoryElement
> p2Repos
= new ArrayList
<MetadataRepositoryElement
>();
1195 String p2ReposPref
= getStringValue(P2_REPOSITORY_LIST
);
1196 if(p2ReposPref
!= null && !p2ReposPref
.isEmpty()) {
1197 StringTokenizer p2ReposPrefST
= new StringTokenizer(p2ReposPref
,P2_REPOSITORIES_DELIM
);
1199 while(p2ReposPrefST
.hasMoreTokens()) {
1200 String p2RepoStr
= p2ReposPrefST
.nextToken();
1201 StringTokenizer p2ReposStrST
= new StringTokenizer(p2RepoStr
,P2_REPOSITORY_FIELDS_DELIM
);
1202 if(p2ReposStrST
.countTokens()==3) {
1203 String nickname
= p2ReposStrST
.nextToken();
1206 uri
= new URI(p2ReposStrST
.nextToken());
1207 } catch (URISyntaxException e
) {
1210 boolean enabled
= Boolean
.parseBoolean(p2ReposStrST
.nextToken());
1211 MetadataRepositoryElement mre
= new MetadataRepositoryElement(null, uri
, true);
1212 mre
.setNickname(nickname
);
1213 mre
.setEnabled(enabled
);
1223 * enables/disables nested composite. <br>
1225 * @param ctrl - Composite to be en-/disabeld
1226 * @param enabled - boolean
1228 public static void recursiveSetEnabled(Control ctrl
, boolean enabled
) {
1229 if (ctrl
instanceof Composite
) {
1230 Composite comp
= (Composite
) ctrl
;
1231 for (Control c
: comp
.getChildren()) {
1232 recursiveSetEnabled(c
, enabled
);
1235 ctrl
.setEnabled(enabled
);
1243 * @param orderActivated
1245 public static void setSortNodes(NavigatorOrderEnum nodesOrder
) {
1246 setStringValue(SORT_NODES
, nodesOrder
.key
);
1251 * @param orderActivated
1253 public static NavigatorOrderEnum
getSortNodes() {
1254 return NavigatorOrderEnum
.valueOf(getStringValue(SORT_NODES
));
1259 * @param orderActivated
1261 public static boolean isNodesSortedNaturally() {
1262 NavigatorOrderEnum value
= NavigatorOrderEnum
.valueOf(getStringValue(SORT_NODES
));
1263 return value
.equals(NavigatorOrderEnum
.NaturalOrder
);
1268 * @param orderActivated
1270 public static boolean isNodesSortedByName() {
1271 NavigatorOrderEnum value
= NavigatorOrderEnum
.valueOf(getStringValue(SORT_NODES
));
1272 return value
.equals(NavigatorOrderEnum
.AlphabeticalOrder
);
1277 * @param orderActivated
1279 public static boolean isNodesSortedByNameAndRank() {
1280 NavigatorOrderEnum value
= NavigatorOrderEnum
.valueOf(getStringValue(SORT_NODES
));
1281 return value
.equals(NavigatorOrderEnum
.RankAndNameOrder
);
1286 * setStoreNavigatorState
1292 public static boolean isStoreNavigatorState() {
1293 return getBooleanValue(RESTORE_NAVIGATOR_STATE
);
1299 * setStoreNavigatorState
1305 public static void setStoreNavigatorState(boolean selection
) {
1306 setBooleanValue(RESTORE_NAVIGATOR_STATE
, selection
);
1313 public static boolean isShowUpWidgetIsDisposedMessages() {
1314 return getBooleanValue(IS_SHOW_UP_WIDGET_IS_DISPOSED
);
1316 public static void setShowUpWidgetIsDisposedMessages(boolean selection
) {
1317 setBooleanValue(IS_SHOW_UP_WIDGET_IS_DISPOSED
, selection
);
1323 public static boolean isShowIdInVocabularyInChecklistEditor() {
1324 String area_display
= getStringValue(EditorPreferencePredicate
.DisplayOfAreasInDistributionEditor
.getKey());
1325 if (area_display
.equals(TermDisplayEnum
.IdInVocabulary
.getKey())) {
1331 public static boolean isShowSymbol1InChecklistEditor() {
1332 String area_display
= getStringValue(EditorPreferencePredicate
.DisplayOfAreasInDistributionEditor
.getKey());
1333 if (area_display
.equals(TermDisplayEnum
.Symbol1
.getKey())) {
1339 public static boolean isShowSymbol2InChecklistEditor() {
1340 String area_display
= getStringValue(EditorPreferencePredicate
.DisplayOfAreasInDistributionEditor
.getKey());
1341 if (area_display
.equals(TermDisplayEnum
.Symbol2
.getKey())) {
1347 public static void setAreaDisplayInChecklistEditor(String selection
) {
1348 setStringValue(EditorPreferencePredicate
.DisplayOfAreasInDistributionEditor
.getKey(), selection
);
1351 public static void setOwnDescriptionForChecklistEditor(boolean selection
) {
1352 setBooleanValue(EditorPreferencePredicate
.OwnDescriptionForDistributionEditor
.getKey(), selection
);
1355 public static boolean isOwnDescriptionForChecklistEditor() {
1356 return getBooleanValue(EditorPreferencePredicate
.OwnDescriptionForDistributionEditor
.getKey());
1362 public static String
displayStatusInChecklistEditor() {
1363 return getStringValue(EditorPreferencePredicate
.DisplayOfStatus
.getKey());
1365 public static void setDisplayStatusInChecklistEditor(String selection
) {
1366 setStringValue(EditorPreferencePredicate
.DisplayOfStatus
.getKey(), selection
);
1372 public static boolean isShowRankInChecklistEditor() {
1373 return getBooleanValue(EditorPreferencePredicate
.ShowRankInDistributionEditor
.getKey());
1375 public static void setShowRankInChecklistEditor(boolean selection
) {
1376 setBooleanValue(EditorPreferencePredicate
.ShowRankInDistributionEditor
.getKey(), selection
);
1384 public static NameDetailsConfigurator
getPreferredNameDetailsConfiguration( boolean local
) {
1385 NameDetailsConfigurator config
= new NameDetailsConfigurator(true);
1386 CdmPreferenceCache cache
= CdmPreferenceCache
.instance();
1387 CdmPreference preference
= null;
1390 preference
= cache
.get(EditorPreferencePredicate
.NameDetailsView
.getKey());
1391 if (preference
== null){
1395 setBooleanValue(ALLOW_OVERRIDE_NAME_DETAILS
, preference
.isAllowOverride());
1397 //the preference value is build like this:
1398 //<section1>:true;<section2>:false....
1400 String value
= preference
.getValue();
1401 String
[] sections
= value
.split(";");
1402 Map
<String
, Boolean
> sectionMap
= new HashMap
<String
, Boolean
>();
1403 String
[] sectionValues
;
1404 for (String sectionValue
: sections
){
1405 sectionValues
= sectionValue
.split(":");
1406 sectionMap
.put(sectionValues
[0], Boolean
.valueOf(sectionValues
[1]));
1408 config
.setAllowOverride(preference
.isAllowOverride());
1409 config
.setSimpleDetailsViewActivated(getValue(sectionMap
, "simpleViewActivated"));
1411 // getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON,
1412 // (getValue(sectionMap, "taxon")));
1413 config
.setTaxonSectionActivated(getValue(sectionMap
, "taxon"));
1415 config
.setSecDetailsActivated(getValue(sectionMap
, "taxon.SecEnabled"));
1416 config
.setSecEnabled(getValue(sectionMap
, "taxon.SecDetails"));
1418 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID,
1419 // (getValue(sectionMap, "lsid")));
1420 config
.setLSIDActivated(getValue(sectionMap
, "lsid"));
1422 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
1423 // (getValue(sectionMap, "nc")));
1424 config
.setNomenclaturalCodeActived(getValue(sectionMap
, "nc"));
1426 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
1427 // (getValue(sectionMap, "ap")));
1428 config
.setAppendedPhraseActivated(getValue(sectionMap
, "ap"));
1430 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK,
1431 // (getValue(sectionMap, "rank")));
1432 config
.setRankActivated(getValue(sectionMap
, "rank"));
1435 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
1436 // (getValue(sectionMap, "atomisedEpithets")));
1437 config
.setAtomisedEpithetsActivated(getValue(sectionMap
, "atomisedEpithets"));
1439 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
1440 // (getValue(sectionMap,"author")));
1441 config
.setAuthorshipSectionActivated(getValue(sectionMap
,"author"));
1443 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
1444 // (getValue(sectionMap, "nomRef")));
1445 config
.setNomenclaturalReferenceSectionActivated(sectionMap
.get("nomRef"));
1447 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
1448 // (getValue(sectionMap, "nomStat")));
1449 config
.setNomenclaturalStatusSectionActivated(getValue(sectionMap
, "nomStat"));
1452 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
1453 // (getValue(sectionMap,"protologue")));
1454 config
.setProtologueActivated(getValue(sectionMap
,"protologue"));
1456 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
1457 // (getValue(sectionMap,"typeDes")));
1458 config
.setTypeDesignationSectionActivated(getValue(sectionMap
,"typeDes"));
1460 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
1461 // (getValue(sectionMap,"nameRelation")));
1462 config
.setNameRelationsSectionActivated(getValue(sectionMap
,"nameRelation"));
1464 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_HYBRID,
1465 // (getValue(sectionMap, "hybrid")));
1466 config
.setHybridActivated(getValue(sectionMap
,"hybrid"));
1468 config
.setSimpleDetailsViewActivated(getBooleanValue(SHOW_SIMPLE_NAME_DETAILS_SECTION
));
1469 config
.setTaxonSectionActivated(getBooleanValue(SHOW_SIMPLE_NAME_DETAILS_TAXON
));
1470 config
.setSecDetailsActivated(getBooleanValue(SHOW_SEC_DETAILS
));
1471 config
.setSecEnabled(getBooleanValue(DISABLE_SEC
));
1472 config
.setLSIDActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_LSID
));
1473 config
.setNomenclaturalCodeActived(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
));
1474 config
.setAppendedPhraseActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE
));
1475 config
.setRankActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_RANK
));
1476 config
.setAtomisedEpithetsActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
));
1477 config
.setAuthorshipSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
));
1478 config
.setNomenclaturalReferenceSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
));
1479 config
.setNomenclaturalStatusSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
));
1480 config
.setProtologueActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
));
1481 config
.setTypeDesignationSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
));
1482 config
.setNameRelationsSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
));
1483 config
.setHybridActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_HYBRID
));
1493 public static void setPreferredNameDetailsConfiguration(NameDetailsConfigurator config
, boolean local
) {
1494 CdmPreference preference
= null;
1497 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewDatabaseInstance(), EditorPreferencePredicate
.NameDetailsView
, config
.toString());
1499 setPreferenceToDB(preference
);
1501 //also add to local preferences
1502 setBooleanValue(SHOW_SIMPLE_NAME_DETAILS_SECTION
, config
.isSimpleDetailsViewActivated());
1503 setBooleanValue(SHOW_SIMPLE_NAME_DETAILS_TAXON
, config
.isTaxonSectionActivated());
1504 setBooleanValue(SHOW_SEC_DETAILS
, config
.isSecDetailsActivated());
1505 setBooleanValue(DISABLE_SEC
, config
.isSecEnabled());
1506 setBooleanValue(SHOW_NAME_DETAILS_SECTION_LSID
, config
.isLSIDActivated());
1507 setBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
, config
.isNomenclaturalCodeActived());
1508 setBooleanValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE
, config
.isAppendedPhraseActivated());
1509 setBooleanValue(SHOW_NAME_DETAILS_SECTION_RANK
, config
.isRankActivated());
1510 setBooleanValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
, config
.isAtomisedEpithetsActivated());
1511 setBooleanValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
, config
.isAuthorshipSectionActivated());
1512 setBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
, config
.isNomenclaturalReferenceSectionActivated());
1513 setBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
, config
.isNomenclaturalStatusSectionActivated());
1514 setBooleanValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
, config
.isProtologueActivated());
1515 setBooleanValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
, config
.isTypeDesignationSectionActivated());
1516 setBooleanValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
, config
.isNameRelationsSectionActivated());
1517 setBooleanValue(SHOW_NAME_DETAILS_SECTION_HYBRID
, config
.isHybridActivated());
1521 private static Boolean
getValue(Map
<String
, Boolean
> sectionMap
, String string
) {
1522 if (sectionMap
.containsKey(string
)){
1523 return sectionMap
.get(string
);
1534 * setAbcdConfigurator
1537 * @param preferredConfiguration
1538 * a {@link eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator}
1541 public static Abcd206ImportConfigurator
getDBAbcdImportConfigurationPreference() {
1543 Abcd206ImportConfigurator config
= Abcd206ImportConfigurator
.NewInstance(null,null);
1544 ICdmRepository controller
;
1545 controller
= CdmStore
.getCurrentApplicationConfiguration();
1546 PrefKey key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), EditorPreferencePredicate
.AbcdImportConfig
);
1547 CdmPreference preference
= null;
1548 if (controller
== null){
1551 preference
= controller
.getPreferenceService().find(key
);
1552 if (preference
== null){
1555 String configString
= preference
.getValue();
1556 String
[] configArray
= configString
.split(";");
1558 for (String configItem
: configArray
){
1559 String
[] keyValue
= configItem
.split(":");
1560 String keyString
= keyValue
[0];
1561 String valueString
= null;
1562 if (keyValue
.length
>1){
1563 valueString
= keyValue
[1];
1565 if (keyString
.equals("ignoreImportOfExistingSpecimen")){
1566 config
.setIgnoreImportOfExistingSpecimen(Boolean
.valueOf(valueString
));
1567 }else if (keyString
.equals("addIndividualsAssociationsSuchAsSpecimenAndObservations")){
1568 config
.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(Boolean
.valueOf(valueString
));
1569 }else if (keyString
.equals("reuseExistingTaxaWhenPossible")){
1570 config
.setReuseExistingTaxaWhenPossible(Boolean
.valueOf(valueString
));
1571 }else if (keyString
.equals("ignoreAuthorship")){
1572 config
.setIgnoreAuthorship(Boolean
.valueOf(valueString
));
1573 }else if (keyString
.equals("addMediaAsMediaSpecimen")){
1574 config
.setAddMediaAsMediaSpecimen(Boolean
.valueOf(valueString
));
1575 }else if (keyString
.equals("reuseExistingMetaData")){
1576 config
.setReuseExistingMetaData(Boolean
.valueOf(valueString
));
1577 }else if (keyString
.equals("reuseExistingDescriptiveGroups")){
1578 config
.setReuseExistingDescriptiveGroups(Boolean
.valueOf(valueString
));
1579 }else if (keyString
.equals("allowReuseOtherClassifications")){
1580 config
.setAllowReuseOtherClassifications(Boolean
.valueOf(valueString
));
1581 }else if (keyString
.equals("deduplicateReferences")){
1582 config
.setDeduplicateReferences(Boolean
.valueOf(valueString
));
1583 }else if (keyString
.equals("deduplicateClassifications")){
1584 config
.setDeduplicateClassifications(Boolean
.valueOf(valueString
));
1585 }else if (keyString
.equals("moveNewTaxaToDefaultClassification")){
1586 config
.setMoveNewTaxaToDefaultClassification(Boolean
.valueOf(valueString
));
1587 }else if (keyString
.equals("mapUnitIdToCatalogNumber")){
1588 config
.setMapUnitIdToCatalogNumber(Boolean
.valueOf(valueString
));
1589 }else if (keyString
.equals("mapUnitIdToAccessionNumber")){
1590 config
.setMapUnitIdToAccessionNumber(Boolean
.valueOf(valueString
));
1591 }else if (keyString
.equals("mapUnitIdToBarcode")){
1592 config
.setMapUnitIdToBarcode(Boolean
.valueOf(valueString
));
1593 }else if (keyString
.equals("overwriteExistingSpecimens")){
1594 config
.setOverwriteExistingSpecimens(Boolean
.valueOf(valueString
));
1595 }else if (keyString
.equals("nomenclaturalCode")){
1596 config
.setNomenclaturalCode(NomenclaturalCode
.fromString(valueString
));
1598 logger
.debug("This key of the abcd configurator needs to be added to the transformer: " + keyString
);
1606 public static Abcd206ImportConfigurator
getLocalAbcdImportConfigurator(){
1607 Abcd206ImportConfigurator config
= Abcd206ImportConfigurator
.NewInstance(null,null);
1609 config
.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS
));
1611 config
.setAddMediaAsMediaSpecimen(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN
));
1613 config
.setAllowReuseOtherClassifications(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS
));
1614 config
.setDeduplicateClassifications(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS
));
1615 config
.setDeduplicateReferences(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES
));
1616 config
.setRemoveCountryFromLocalityText(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REMOVE_COUNTRY_FROM_LOCALITY_TEXT
));
1617 config
.setGetSiblings(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS
));
1618 config
.setIgnoreAuthorship(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP
));
1619 config
.setIgnoreImportOfExistingSpecimen(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN
));
1620 config
.setMapUnitIdToAccessionNumber(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER
));
1621 config
.setMapUnitIdToBarcode(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE
));
1622 config
.setMapUnitIdToCatalogNumber(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER
));
1623 config
.setMoveNewTaxaToDefaultClassification(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION
));
1624 config
.setOverwriteExistingSpecimens(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN
));
1625 config
.setReuseExistingDescriptiveGroups(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS
));
1626 config
.setReuseExistingMetaData(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA
));
1627 config
.setReuseExistingTaxaWhenPossible(getBooleanValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE
));
1628 config
.setNomenclaturalCode(NomenclaturalCode
.getByKey(getStringValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE
)));
1635 public static void updateAbcdImportConfigurationPreference() {
1636 CdmPreferenceCache cache
= CdmPreferenceCache
.instance();
1637 CdmPreference pref
= cache
.get(EditorPreferencePredicate
.AbcdImportConfig
.getKey());
1639 if (!getBooleanValue(prefOverrideKey(EditorPreferencePredicate
.AbcdImportConfig
.getKey())) || !pref
.isAllowOverride()){
1640 resetToDBPreferenceAbcdCOnfigurator();
1645 public static void resetToDBPreferenceAbcdCOnfigurator(){
1646 Abcd206ImportConfigurator config
= getDBAbcdImportConfigurationPreference();
1647 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS
, config
.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
1648 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN
, config
.isAddMediaAsMediaSpecimen());
1650 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS
, config
.isAllowReuseOtherClassifications());
1651 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS
, config
.isDeduplicateClassifications());
1652 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES
, config
.isDeduplicateReferences());
1654 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS
, config
.isGetSiblings());
1655 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP
, config
.isIgnoreAuthorship());
1656 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN
, config
.isIgnoreImportOfExistingSpecimen());
1657 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER
, config
.isMapUnitIdToAccessionNumber());
1658 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE
, config
.isMapUnitIdToBarcode());
1659 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER
, config
.isMapUnitIdToCatalogNumber());
1660 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION
, config
.isMoveNewTaxaToDefaultClassification());
1661 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN
, config
.isOverwriteExistingSpecimens());
1662 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS
, config
.isReuseExistingDescriptiveGroups());
1663 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA
, config
.isReuseExistingMetaData());
1664 setBooleanValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE
, config
.isReuseExistingTaxaWhenPossible());
1665 if (config
.getNomenclaturalCode() != null){
1666 setStringValue(ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE
, config
.getNomenclaturalCode().getKey());
1674 public NameDetailsConfigurator
createLocalNameDetailsViewConfig(boolean local
) {
1675 NameDetailsConfigurator config
= new NameDetailsConfigurator(true);
1677 config
.setSimpleDetailsViewActivated(getBooleanValue(IPreferenceKeys
.SHOW_SIMPLE_NAME_DETAILS_SECTION
));
1678 config
.setAppendedPhraseActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE
));
1679 config
.setAtomisedEpithetsActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
));
1680 config
.setAuthorshipSectionActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
));
1681 config
.setLSIDActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_LSID
));
1682 config
.setNameApprobiationActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION
));
1683 config
.setNameCacheActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_CACHE
));
1684 config
.setNameRelationsSectionActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
));
1685 config
.setNomenclaturalCodeActived(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
));
1686 config
.setNomenclaturalStatusSectionActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
));
1687 config
.setNomenclaturalReferenceSectionActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
));
1688 config
.setProtologueActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
));
1689 config
.setRankActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_RANK
));
1690 config
.setTaxonSectionActivated(getBooleanValue(IPreferenceKeys
.SHOW_SIMPLE_NAME_DETAILS_TAXON
));
1691 config
.setTypeDesignationSectionActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
));
1692 config
.setHybridActivated(getBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_HYBRID
));
1701 public static void saveConfigToPrefernceStore(NameDetailsConfigurator config
) {
1702 setBooleanValue(IPreferenceKeys
.SHOW_SIMPLE_NAME_DETAILS_SECTION
,
1703 config
.isSimpleDetailsViewActivated());
1704 setBooleanValue(IPreferenceKeys
.SHOW_SIMPLE_NAME_DETAILS_TAXON
, config
.isTaxonSectionActivated());
1705 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_LSID
, config
.isLSIDActivated());
1706 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
,
1707 config
.isNomenclaturalCodeActived());
1708 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NAMECACHE
,
1709 config
.isNameCacheActivated());
1710 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE
,
1711 config
.isAppendedPhraseActivated());
1712 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_RANK
, config
.isRankActivated());
1713 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
,
1714 config
.isAtomisedEpithetsActivated());
1715 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE
,
1716 config
.isAuthorCacheActivated());
1717 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
,
1718 config
.isAuthorshipSectionActivated());
1719 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
,
1720 config
.isNomenclaturalReferenceSectionActivated());
1721 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
,
1722 config
.isNomenclaturalStatusSectionActivated());
1723 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
,
1724 config
.isProtologueActivated());
1725 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
,
1726 config
.isTypeDesignationSectionActivated());
1727 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
,
1728 config
.isNameRelationsSectionActivated());
1729 setBooleanValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_HYBRID
,
1730 config
.isHybridActivated());
1737 public static boolean isSortTaxaByRankAndName() {
1739 return getBooleanValue(IPreferenceKeys
.SORT_TAXA_BY_RANK_AND_NAME
);
1745 public static boolean isSortNamedAreaByOrderInVocabulary() {
1747 return getBooleanValue(EditorPreferencePredicate
.AreasSortedByIdInVocabulary
.getKey());
1750 public static void setSortNamedAreasByOrderInVocabulary(boolean isSortByVocabularyOrder
) {
1751 setBooleanValue(EditorPreferencePredicate
.AreasSortedByIdInVocabulary
.getKey(), isSortByVocabularyOrder
);
1757 * setPreferredNamedAreasForDistributionEditor
1760 * @param saveCheckedElements
1761 * @param saveGrayedElements
1763 public static void setLastSelectedReference(
1764 List
<String
> lastSelectedReferences
) {
1766 setStringValue(PreferencesUtil
.LAST_SELECTED_REFERENCES
, lastSelectedReferences
.toString());
1771 * setPreferredNamedAreasForDistributionEditor
1774 * @param saveCheckedElements
1775 * @param saveGrayedElements
1777 public static List
<String
> getLastSelectedReferences() {
1779 //IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
1780 String lastSelected
= getStringValue(PreferencesUtil
.LAST_SELECTED_REFERENCES
);
1781 List
<String
> result
= new ArrayList
<>();
1782 if (!StringUtils
.isBlank(lastSelected
)){
1783 Collections
.addAll(result
, lastSelected
.substring(1,lastSelected
.length()-1).split(", "));
1791 * setPreferredNamedAreasForDistributionEditor
1794 * @param saveCheckedElements
1795 * @param saveGrayedElements
1797 public static void setPreferredNamedAreasForDistributionEditor(
1798 String saveCheckedElements
, String saveGrayedElements
, boolean local
) {
1800 setStringValue(EditorPreferencePredicate
.AvailableDistributionAreaTerms
.getKey(), saveCheckedElements
);
1804 CdmPreference preference
= null;
1806 if (saveCheckedElements
== null){
1807 preference
= getPreferenceFromDB(EditorPreferencePredicate
.AvailableDistributionAreaTerms
);
1809 if (preference
== null){
1812 setStringValue(EditorPreferencePredicate
.AvailableDistributionAreaTerms
.getKey(),
1813 saveCheckedElements
);
1814 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewTaxEditorInstance(), EditorPreferencePredicate
.AvailableDistributionAreaTerms
, saveCheckedElements
);
1815 setPreferenceToDB(preference
);
1819 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewTaxEditorInstance(), EditorPreferencePredicate
.AvailableDistributionAreaTerms
, saveCheckedElements
);
1820 setPreferenceToDB(preference
);
1821 setStringValue(EditorPreferencePredicate
.AvailableDistributionAreaTerms
.getKey(),
1822 saveCheckedElements
);
1830 * @param saveCheckedElements
1831 * @param saveCheckedElements2
1834 public static void setPreferredVocabulariesForDistributionEditor(String saveCheckedElements
,
1835 boolean local
, boolean isOverride
) {
1837 setStringValue(PreferencePredicate
.AvailableDistributionAreaVocabularies
.getKey(), saveCheckedElements
);
1838 setBooleanValue(prefOverrideKey(PreferencePredicate
.AvailableDistributionAreaVocabularies
.getKey()), isOverride
);
1841 ICdmRepository controller
;
1842 CdmPreference preference
= null;
1844 if (saveCheckedElements
== null){
1845 preference
= getPreferenceFromDB(PreferencePredicate
.AvailableDistributionAreaVocabularies
);
1847 if (preference
== null){
1850 setStringValue(PreferencePredicate
.AvailableDistributionAreaVocabularies
.getKey(),
1851 saveCheckedElements
);
1852 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.AvailableDistributionAreaVocabularies
, saveCheckedElements
);
1853 preference
.setAllowOverride(isOverride
);
1854 setPreferenceToDB(preference
);
1857 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.AvailableDistributionAreaVocabularies
, saveCheckedElements
);
1858 preference
.setAllowOverride(isOverride
);
1859 setPreferenceToDB(preference
);
1860 setStringValue(PreferencePredicate
.AvailableDistributionAreaVocabularies
.getKey(),
1861 saveCheckedElements
);
1871 * @param saveCheckedElements
1872 * @param saveCheckedElements2
1875 public static String
getPreferredVocabulariesForDistributionEditor(boolean local
) {
1878 String pref
= getStringValue(PreferencePredicate
.AvailableDistributionAreaVocabularies
.getKey(), local
);
1882 CdmPreference preference
= null;
1883 preference
= getPreferenceFromDB(PreferencePredicate
.AvailableDistributionAreaVocabularies
);
1884 if (preference
== null){
1887 return preference
.getValue();
1896 public static boolean getFilterCommonNameReferences(){
1897 return getBooleanValue(PreferencesUtil
.FILTER_COMMON_NAME_REFERENCES
);
1903 public static void updateDBPreferences() {
1904 CdmPreference preference
= null;
1905 CdmPreferenceCache cache
= CdmPreferenceCache
.instance();
1906 cache
.getAllTaxEditorDBPreferences();
1910 updateAbcdImportConfigurationPreference();
1913 NameDetailsConfigurator config
= getPreferredNameDetailsConfiguration(false);
1914 if (config
!= null ){
1915 if (!getBooleanValue(OVERRIDE_NAME_DETAILS
) || !getBooleanValue(ALLOW_OVERRIDE_NAME_DETAILS
)){
1916 setPreferredNameDetailsConfiguration(config
, false);