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
;
26 import java
.util
.StringTokenizer
;
27 import java
.util
.UUID
;
29 import org
.apache
.commons
.lang
.StringUtils
;
30 import org
.apache
.log4j
.Logger
;
31 import org
.eclipse
.equinox
.internal
.p2
.ui
.model
.MetadataRepositoryElement
;
32 import org
.eclipse
.jface
.preference
.IPreferenceStore
;
33 import org
.eclipse
.jface
.window
.Window
;
34 import org
.eclipse
.swt
.widgets
.Composite
;
35 import org
.eclipse
.swt
.widgets
.Control
;
36 import org
.eclipse
.swt
.widgets
.Shell
;
37 import org
.eclipse
.ui
.PlatformUI
;
39 import eu
.etaxonomy
.cdm
.api
.application
.ICdmRepository
;
40 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacadeConfigurator
;
41 import eu
.etaxonomy
.cdm
.api
.service
.IFeatureTreeService
;
42 import eu
.etaxonomy
.cdm
.api
.service
.ITermService
;
43 import eu
.etaxonomy
.cdm
.api
.service
.config
.FindTaxaAndNamesConfiguratorImpl
;
44 import eu
.etaxonomy
.cdm
.api
.service
.config
.IFindTaxaAndNamesConfigurator
;
45 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
46 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
47 import eu
.etaxonomy
.cdm
.io
.specimen
.abcd206
.in
.Abcd206ImportConfigurator
;
48 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
49 import eu
.etaxonomy
.cdm
.model
.common
.ICdmBase
;
50 import eu
.etaxonomy
.cdm
.model
.common
.IDefinedTerm
;
51 import eu
.etaxonomy
.cdm
.model
.common
.ISimpleTerm
;
52 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
53 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
54 import eu
.etaxonomy
.cdm
.model
.common
.TermBase
;
55 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
56 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
57 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmPreference
;
58 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmPreference
.PrefKey
;
59 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferencePredicate
;
60 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferenceSubject
;
61 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
62 import eu
.etaxonomy
.cdm
.strategy
.match
.DefaultMatchStrategy
;
63 import eu
.etaxonomy
.cdm
.strategy
.match
.IMatchStrategy
;
64 import eu
.etaxonomy
.cdm
.strategy
.match
.MatchException
;
65 import eu
.etaxonomy
.cdm
.strategy
.match
.MatchMode
;
66 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
67 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
68 import eu
.etaxonomy
.taxeditor
.model
.NomenclaturalCodeHelper
;
69 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
70 import eu
.etaxonomy
.taxeditor
.store
.TermStore
;
71 import eu
.etaxonomy
.taxeditor
.store
.internal
.TaxeditorStorePlugin
;
72 import eu
.etaxonomy
.taxeditor
.ui
.dialog
.DefaultLanguageDialog
;
76 * PreferencesUtil class.
84 public class PreferencesUtil
implements IPreferenceKeys
{
89 public static final String PREFERRED_TERMS_CHANGE
= "preferred_terms";
91 public static final String P2_REPOSITORIES_DELIM
= ",";
92 public static final String P2_REPOSITORY_FIELDS_DELIM
= ";";
94 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();
111 * setPreferredNomenclaturalCode
114 * @param preferredCode
115 * a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
118 public static CdmPreference
setPreferredNomenclaturalCode(
119 String preferenceKey
, boolean local
) {
121 getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY
,
125 ICdmRepository controller
;
126 controller
= CdmStore
.getCurrentApplicationConfiguration();
127 if (controller
== null){
132 key
= CdmPreference
.NewKey(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.NomenclaturalCode
);
133 }catch (Exception e
){
134 System
.out
.println(e
.getStackTrace());
136 CdmPreference preference
= null;
138 if (preferenceKey
== null){
139 preference
= controller
.getPreferenceService().find(key
);
140 if (preference
== null){
143 getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY
,
145 getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY
,preference
.isAllowOverride());
149 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.NomenclaturalCode
, preferenceKey
);
150 controller
.getPreferenceService().set(preference
);
160 public static NomenclaturalCode
getPreferredNomenclaturalCode(){
161 if (getPreferenceStore().getBoolean(OVERRIDE_NOMENCLATURAL_CODE_KEY
)) {
162 return getPreferredNomenclaturalCode(true);
164 return getPreferredNomenclaturalCode(false);
170 * getPreferredNomenclaturalCode
173 * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
175 public static NomenclaturalCode
getPreferredNomenclaturalCode(boolean useLocal
) {
177 CdmPreference pref
= null;
179 pref
= getPreferenceFromDB(PreferencePredicate
.NomenclaturalCode
);
182 String preferredCode
;
184 preferredCode
= getPreferenceStore().getString(
185 PREFERRED_NOMENCLATURAL_CODE_KEY
);
188 preferredCode
= pref
.getValue();
191 return getPreferredNomenclaturalCode(preferredCode
);
197 * getPreferredNomenclaturalCode
200 * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
202 public static NomenclaturalCode
getPreferredNomenclaturalCode(String preferenceKeyNomenclaturalCode
) {
204 for (NomenclaturalCode code
: NomenclaturalCodeHelper
.getAllCodes()) {
205 if (getPreferenceKey(code
).equals(preferenceKeyNomenclaturalCode
)) {
212 public static boolean isShowTaxonAssociations(){
213 if (getPreferenceStore().getBoolean(SHOW_TAXON_ASSOCIATIONS_OVERRIDE
) && getPreferenceStore().getBoolean(SHOW_TAXON_ASSOCIATIONS_ALLOW_OVERRIDE
)) {
214 return getPreferenceStore().getBoolean(SHOW_TAXON_ASSOCIATIONS
);
216 CdmPreference pref
= getPreferenceFromDB(PreferencePredicate
.ShowTaxonAssociations
);
218 return pref
!=null?Boolean
.valueOf(pref
.getValue()):false;
222 public static boolean isShowLifeForm(){
223 if (getPreferenceStore().getBoolean(SHOW_LIFE_FORM_OVERRIDE
) && getPreferenceStore().getBoolean(SHOW_LIFE_FORM_ALLOW_OVERRIDE
)) {
224 return getPreferenceStore().getBoolean(SHOW_LIFE_FORM
);
226 CdmPreference pref
= getPreferenceFromDB(PreferencePredicate
.ShowLifeForm
);
228 return pref
!=null?Boolean
.valueOf(pref
.getValue()):false;
232 public static boolean isDeterminationOnlyForFieldUnits(){
233 if (getPreferenceStore().getBoolean(DETERMINATION_ONLY_FOR_FIELD_UNITS_OVERRIDE
) && getPreferenceStore().getBoolean(DETERMINATIONS_ONLY_FOR_FIELDUNITS_ALLOW_OVERRIDE
)) {
234 return getPreferenceStore().getBoolean(DETERMINATION_ONLY_FOR_FIELD_UNITS
);
236 CdmPreference pref
= getPreferenceFromDB(PreferencePredicate
.DeterminationOnlyForFieldUnits
);
238 return pref
!=null?Boolean
.valueOf(pref
.getValue()):false;
242 public static boolean isCollectingAreaInGeneralSection(){
243 if (getPreferenceStore().getBoolean(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION_OVERRIDE
) && getPreferenceStore().getBoolean(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION_ALLOW_OVERRIDE
)) {
244 return getPreferenceStore().getBoolean(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION
);
246 CdmPreference pref
= getPreferenceFromDB(PreferencePredicate
.ShowCollectingAreasInGeneralSection
);
248 return pref
!=null?Boolean
.valueOf(pref
.getValue()):false;
252 public static boolean isShowSimpleDetailsView(){
253 if (getPreferenceStore().getBoolean(OVERRIDE_NAME_DETAILS
) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_NAME_DETAILS
)) {
254 return getPreferenceStore().getBoolean(SHOW_SIMPLE_NAME_DETAILS_SECTION
);
256 CdmPreference pref
= getPreferenceFromDB(PreferencePredicate
.NameDetailsView
);
258 return pref
!=null?Boolean
.valueOf(pref
.getValue()):false;
264 public static CdmPreference
getPreferenceFromDB(PreferencePredicate predicate
){
265 ICdmRepository controller
;
266 CdmPreference pref
= null;
269 if(CdmStore
.isActive()){
270 controller
= CdmStore
.getCurrentApplicationConfiguration();
271 PrefKey key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), predicate
);
272 pref
= controller
.getPreferenceService().find(key
);
282 public static void setPreferenceToDB(CdmPreference preference
){
283 ICdmRepository controller
;
285 if(CdmStore
.isActive()){
286 controller
= CdmStore
.getCurrentApplicationConfiguration();
287 controller
.getPreferenceService().set(preference
);
297 public static String
getPreferredDefaultLangugae(){
298 String preferredLanguage
= getPreferenceStore().getString(DEFAULT_LANGUAGE_EDITOR
);
299 if(StringUtils
.isNotEmpty(preferredLanguage
) && StringUtils
.isNotBlank(preferredLanguage
)){
300 return preferredLanguage
;
305 public static boolean isShowMediaPreview(){
306 boolean isShowMediaPreview
= getPreferenceStore().getBoolean(SHOW_MEDIA_PREVIEW
);
307 return isShowMediaPreview
;
311 * Get the match strategy for the given class that was stored in preferences
312 * or the default strategy if it was not stored in preferences
315 * a {@link java.lang.Class} object.
316 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
318 public static IMatchStrategy
getMatchStrategy(Class clazz
) {
319 String className
= clazz
.getName();
320 if (getPreferenceStore().getBoolean(MATCH_STRATEGY_PREFIX
+ className
)) {
321 IMatchStrategy matchStrategy
= getDefaultMatchStrategy(clazz
);
323 for (String fieldName
: matchStrategy
.getMatchFieldPropertyNames()) {
324 String matchModeName
= getPreferenceStore().getString(
325 getMatchStrategyFieldName(className
, fieldName
));
326 MatchMode matchMode
= MatchMode
.valueOf(matchModeName
);
328 matchStrategy
.setMatchMode(fieldName
, matchMode
);
329 } catch (MatchException e
) {
330 MessagingUtils
.error(PreferencesUtil
.class, e
);
331 throw new RuntimeException(e
);
335 return matchStrategy
;
337 return getDefaultMatchStrategy(clazz
);
341 * Stores a matchStrategy into the preference store.
343 * @param matchStrategy
344 * a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy}
347 public static void setMatchStrategy(IMatchStrategy matchStrategy
) {
348 String className
= matchStrategy
.getMatchClass().getName();
349 getPreferenceStore().setValue(MATCH_STRATEGY_PREFIX
+ className
, true);
351 Set
<String
> matchFields
= matchStrategy
.getMatchFieldPropertyNames();
353 for (String fieldName
: matchFields
) {
354 getPreferenceStore().setValue(
355 getMatchStrategyFieldName(className
, fieldName
),
356 matchStrategy
.getMatchMode(fieldName
).name());
361 * Helper method to create the preference property for a match field.
367 private static String
getMatchStrategyFieldName(String className
,
369 return MATCH_STRATEGY_PREFIX
+ className
+ "." + fieldName
;
373 * Returns the default match strategy for a given class.
376 * a {@link java.lang.Class} object.
377 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
379 public static IMatchStrategy
getDefaultMatchStrategy(Class clazz
) {
380 return DefaultMatchStrategy
.NewInstance(clazz
);
385 * getDateFormatPattern
388 * @return a {@link java.lang.String} object.
390 public static String
getDateFormatPattern() {
391 // TODO make this configurable in properties
392 String pattern
= "Y-M-d H:m";
398 * addTermToPreferredTerms
406 public static <T
extends TermBase
> void addTermToPreferredTerms(T term
) {
408 // VocabularyEnum vocabulary =
409 // VocabularyEnum.getVocabularyEnum(term.getClass());
411 // getPreferenceStore().setValue(getPreferenceKey(term),
412 // VocabularyStore.getTermVocabulary(vocabulary).getTerms().contains(term));
414 // firePreferencesChanged(term.getClass());
418 * Construct a unique key using the CdmBase object's uuid
423 private static String
getPreferenceKey(ICdmBase cdmBase
) {
424 cdmBase
= HibernateProxyHelper
.deproxy(cdmBase
);
426 String key
= cdmBase
.getClass().getName().concat(".")
427 .concat(cdmBase
.getUuid().toString());
428 if (key
.contains("javassist")) {
429 MessagingUtils
.info("proxy");
435 * Construct a unique key using the CdmBase object's uuid
440 public static String
getPreferenceKey(ISimpleTerm simpleTerm
) {
441 simpleTerm
= HibernateProxyHelper
.deproxy(simpleTerm
);
442 String key
= simpleTerm
.getClass().getName().concat(".")
443 .concat(simpleTerm
.getUuid().toString());
444 if (key
.contains("javassist")) {
445 MessagingUtils
.warn(PreferencesUtil
.class,
446 "Trying to persist a preference based on a proxy class.");
454 * Construct a unique key using the CdmBase object's uuid
459 public static String
getPreferenceKey(IDefinedTerm definedTerm
) {
460 definedTerm
= HibernateProxyHelper
.deproxy(definedTerm
);
461 String key
= definedTerm
.getClass().getName().concat(".")
462 .concat(definedTerm
.getUuid().toString());
463 if (key
.contains("javassist")) {
464 MessagingUtils
.warn(PreferencesUtil
.class,
465 "Trying to persist a preference based on a proxy class.");
471 * Retrieves search preferences from the preference store
473 * @return an {@link ITaxonServiceConfigurator} to pass to search methods
475 public static IFindTaxaAndNamesConfigurator
getSearchConfigurator() {
476 IFindTaxaAndNamesConfigurator configurator
= initializeSearchConfigurator();
478 configurator
.setDoTaxa(getPreferenceStore().getBoolean(
479 TAXON_SERVICE_CONFIGURATOR_TAXA
));
480 configurator
.setDoSynonyms(getPreferenceStore().getBoolean(
481 TAXON_SERVICE_CONFIGURATOR_SYNONYMS
));
482 configurator
.setDoNamesWithoutTaxa(getPreferenceStore().getBoolean(
483 TAXON_SERVICE_CONFIGURATOR_NAMES
));
484 configurator
.setDoTaxaByCommonNames(getPreferenceStore().getBoolean(
485 TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES
));
486 //configurator.setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.valueOf(getPreferenceStore().getString(TAXON_SERVICE_CONFIGURATOR_MATCH_MODE)));
492 * create new preferences, setting all search options to true
495 * {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
498 public static IFindTaxaAndNamesConfigurator
initializeSearchConfigurator() {
499 IFindTaxaAndNamesConfigurator configurator
= FindTaxaAndNamesConfiguratorImpl
.NewInstance();
501 configurator
.setDoTaxa(true);
502 configurator
.setDoSynonyms(true);
503 configurator
.setDoNamesWithoutTaxa(true);
504 configurator
.setDoTaxaByCommonNames(true);
506 configurator
.setTaxonPropertyPath(Arrays
.asList("$", "titleCache",
507 "name", "name.$", "relationsFromThisTaxon.$"));
509 configurator
.setSynonymPropertyPath(Arrays
.asList("$", "titleCache",
510 "name", "name.$", "synonyms.relatedTo.*"));
513 // match mode is a simple like, actually all other match modes are kind
516 .setMatchMode(eu
.etaxonomy
.cdm
.persistence
.query
.MatchMode
.ANYWHERE
);
517 // we set page number and size here as this should always be unlimited
518 configurator
.setPageNumber(0);
519 // TODO currently limit results to 10000
520 configurator
.setPageSize(10000);
526 * Store search preferences
528 * @param configurator
530 * {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
533 public static void setSearchConfigurator(
534 IFindTaxaAndNamesConfigurator configurator
) {
535 getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_TAXA
,
536 configurator
.isDoTaxa());
537 getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_SYNONYMS
,
538 configurator
.isDoSynonyms());
539 getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_NAMES
,
540 configurator
.isDoNamesWithoutTaxa());
541 getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES
,
542 configurator
.isDoTaxaByCommonNames());
547 * firePreferencesChanged
551 * a {@link java.lang.Class} object.
553 public static void firePreferencesChanged(Class clazz
) {
554 getPreferenceStore().firePropertyChangeEvent(PREFERRED_TERMS_CHANGE
,
559 * Set default values for preferences
561 public static void setDefaults() {
562 getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_TAXA
, true);
563 getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_SYNONYMS
,
565 getPreferenceStore().setDefault(EDIT_MAP_SERVICE_ACCES_POINT
,
566 "http://edit.africamuseum.be/edit_wp5/v1.2/rest_gen.php");
567 //FIXME : changed default for SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
568 getPreferenceStore().setDefault(SHOULD_CONNECT_AT_STARTUP
, false);
569 getPreferenceStore().setDefault(OPENURL_ACCESS_POINT
,
570 "http://www.biodiversitylibrary.org/openurl");
571 getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_WIDTH
, "1000");
572 getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_HEIGHT
, "1000");
573 //Distribution Editor:
574 getPreferenceStore().setDefault(DISTRIBUTION_AREA_PREFRENCES_ACTIVE
, true);
575 getPreferenceStore().setDefault(CHECKLIST_AREA_DISPLAY
, CHECKLIST_AREA_DISPLAY_TITLE
);
576 getPreferenceStore().setDefault(CHECKLIST_SYMBOL
, false);
580 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
, true);
581 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE
, true);
582 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
, true);
583 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_HYBRID
, true);
584 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_LSID
, true);
585 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
, true);
586 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NAMECACHE
, true);
587 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
, true);
588 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
, true);
589 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
, true);
590 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
, true);
591 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_RANK
, true);
592 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
, true);
593 //Navigator preferences
594 getPreferenceStore().setDefault(SORT_NODES_NATURALLY
, false);
595 getPreferenceStore().setDefault(SORT_NODES_ALPHABETICALLY
, false);
596 getPreferenceStore().setDefault(SORT_TAXA_BY_RANK_AND_NAME
, true);
597 //override db preferences
598 getPreferenceStore().setDefault(ABCD_IMPORT_OVERRIDE
, false);
599 getPreferenceStore().setDefault(SHOW_SPECIMEN_OVERRIDE
, false);
600 getPreferenceStore().setDefault(OVERRIDE_NAME_DETAILS
, false);
601 getPreferenceStore().setDefault(DISTRIBUTION_AREA_PREFRENCES_ACTIVE_OVERRIDE
, false);
603 getPreferenceStore().setDefault(FILTER_COMMON_NAME_REFERENCES
, false);
604 getPreferenceStore().setDefault(SHOW_SPECIMEN
, true);
605 getPreferenceStore().setDefault(SHOW_TAXONNODE_WIZARD
, true);
606 getPreferenceStore().setDefault(SHOW_NAME_IN_SOURCE
, true);
607 getPreferenceStore().setDefault(SHOW_ID_IN_SOURCE
, true);
608 getPreferenceStore().setDefault(DISABLE_MULTI_CLASSIFICATION
, false);
609 getPreferenceStore().setDefault(DISABLE_SEC
, false);
610 getPreferenceStore().setDefault(SHOW_SEC_DETAILS
, true);
615 * checkNomenclaturalCode
618 public static void checkNomenclaturalCode() {
619 // First time Editor is opened, no nomenclatural code has been set
620 if (PreferencesUtil
.getPreferredNomenclaturalCode(true) == null) {
621 PreferencesUtil
.setPreferredNomenclaturalCode(getPreferenceKey(NomenclaturalCode
.ICNAFP
), true);
627 public static void setNomenclaturalCodePreferences(){
628 ICdmRepository controller
;
629 controller
= CdmStore
.getCurrentApplicationConfiguration();
630 PrefKey key
= CdmPreference
.NewKey(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.NomenclaturalCode
);
631 CdmPreference preference
= null;
632 if (controller
== null){
635 preference
= controller
.getPreferenceService().find(key
);
636 if (preference
== null){
639 getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY
, preference
.isAllowOverride());
641 int index
= StringUtils
.lastIndexOf(preference
.getValue(), ".");
642 UUID uuid
= UUID
.fromString(preference
.getValue().substring(index
+1, preference
.getValue().length()));
643 NomenclaturalCode preferredCode
= NomenclaturalCode
.getByUuid(uuid
);
645 getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY
,
646 getPreferenceKey(preferredCode
));
650 public static void checkDefaultLanguage(){
651 if(PreferencesUtil
.getPreferredDefaultLangugae() == null){
652 Shell shell
= AbstractUtility
.getShell();
653 int open
= new DefaultLanguageDialog(shell
).open();
654 if(open
== Window
.OK
){
655 PlatformUI
.getWorkbench().restart();
658 //TODO:In case of a reinstall, the config.ini will be overwritten
659 // here you create config.ini with the stored key from preferences
665 * getMapServiceAccessPoint
668 * @return a {@link java.lang.String} object.
670 public static String
getMapServiceAccessPoint() {
671 return getPreferenceStore().getString(EDIT_MAP_SERVICE_ACCES_POINT
);
676 * shouldConnectAtStartUp
681 public static boolean shouldConnectAtStartUp() {
682 //FIXME : force SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
683 //return getPreferenceStore().getBoolean(SHOULD_CONNECT_AT_STARTUP);
689 * getDefaultFeatureTreeForTextualDescription
692 * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
694 public static FeatureTree
getDefaultFeatureTreeForTextualDescription() {
695 String uuidString
= getPreferenceStore().getString(
696 FEATURE_TREE_DEFAULT_TEXT
);
697 return CdmUtils
.isEmpty(uuidString
) ?
null : CdmStore
.getService(
698 IFeatureTreeService
.class).load(UUID
.fromString(uuidString
));
703 * getDefaultFeatureTreeForStructuredDescription
706 * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
708 public static FeatureTree
getDefaultFeatureTreeForStructuredDescription() {
709 String uuidString
= getPreferenceStore().getString(
710 FEATURE_TREE_DEFAULT_STRUCTURE
);
711 return CdmUtils
.isEmpty(uuidString
) ?
null : CdmStore
.getService(
712 IFeatureTreeService
.class).load(UUID
.fromString(uuidString
));
717 * setSortRanksHierarchichally
723 public static void setSortRanksHierarchichally(boolean selection
) {
724 getPreferenceStore().setValue(SORT_RANKS_HIERARCHICHALLY
, selection
);
729 * getSortRanksHierarchichally
734 public static boolean getSortRanksHierarchichally() {
735 return getPreferenceStore().getBoolean(SORT_RANKS_HIERARCHICHALLY
);
738 public static boolean isMultilanguageTextEditingCapability() {
739 return getPreferenceStore().getBoolean(
740 MULTILANGUAGE_TEXT_EDITING_CAPABILITY
);
743 public static Language
getGlobalLanguage() {
746 String languageUuidString
= getPreferenceStore().getString(
747 GLOBAL_LANGUAGE_UUID
);
749 if(!CdmStore
.isActive()) {
750 MessagingUtils
.noDataSourceWarningDialog(languageUuidString
);
754 if (CdmUtils
.isBlank(languageUuidString
)) {
755 return Language
.getDefaultLanguage();
758 UUID languageUuid
= UUID
.fromString(languageUuidString
);
759 return (Language
) CdmStore
.getService(ITermService
.class).load(
763 public static void setGlobalLanguage(Language language
) {
764 if(language
!= null) {
765 getPreferenceStore().setValue(GLOBAL_LANGUAGE_UUID
,language
.getUuid().toString());
766 CdmStore
.setDefaultLanguage(language
);
774 public static Map
<MarkerType
, Boolean
> getEditMarkerTypePreferences() {
775 List
<MarkerType
> markerTypes
= CdmStore
.getTermManager()
776 .getPreferredTerms(MarkerType
.class);
778 Map
<MarkerType
, Boolean
> result
= new HashMap
<MarkerType
, Boolean
>();
780 for (MarkerType markerType
: markerTypes
) {
781 String name
= getMarkerTypeEditingPreferenceKey(markerType
);
782 Boolean value
= getPreferenceStore().getBoolean(name
);
784 result
.put(markerType
, value
);
791 * @param markerTypeEditingMap
793 public static void setEditMarkerTypePreferences(
794 Map
<MarkerType
, Boolean
> markerTypeEditingMap
) {
795 for (MarkerType markerType
: markerTypeEditingMap
.keySet()) {
796 String name
= getMarkerTypeEditingPreferenceKey(markerType
);
797 getPreferenceStore().setValue(name
,
798 markerTypeEditingMap
.get(markerType
));
803 private static String
getMarkerTypeEditingPreferenceKey(
804 MarkerType markerType
) {
805 markerType
= HibernateProxyHelper
.deproxy(markerType
);
806 return markerType
.getClass().getName() + EDIT_MARKER_TYPE_PREFIX
;
811 * setEditMarkerTypePreference
815 * a {@link org.eclipse.ui.IEditorInput} object.
817 * a {@link eu.etaxonomy.cdm.model.common.MarkerType} object.
821 public static void setEditMarkerTypePreference(MarkerType markerType
,
823 getPreferenceStore().setValue(
824 getMarkerTypeEditingPreferenceKey(markerType
), edit
);
830 public static DerivedUnitFacadeConfigurator
getDerivedUnitConfigurator() {
831 DerivedUnitFacadeConfigurator configurator
= DerivedUnitFacadeConfigurator
833 configurator
.setMoveDerivedUnitMediaToGallery(true);
834 configurator
.setMoveFieldObjectMediaToGallery(true);
839 * This method will write language properties to the config.ini located in the configuration folder
840 * of the Taxonomic Ediitor. <b>This method is only used to set the default language for Taxonomic Editor.</b>
842 * @param setLanguage 0 is for german and 1 for english.
843 * @throws IOException
845 public void writePropertyToConfigFile(int setLanguage
) throws IOException
{
846 File file
= org
.eclipse
.core
.runtime
.preferences
.ConfigurationScope
.INSTANCE
.getLocation().toFile();
847 //give warning to user if the directory has no write access
849 throw new IOException();
851 Properties properties
= load(file
.getAbsolutePath()+"/config.ini");
854 properties
.setProperty("osgi.nl", "de");
855 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.DEFAULT_LANGUAGE_EDITOR
, "de");
858 properties
.setProperty("osgi.nl", "en");
859 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.DEFAULT_LANGUAGE_EDITOR
, "en");
864 save(file
+"/config.ini", properties
);
868 * This method loads a property from a given file and returns it.
872 * @throws IOException
874 private Properties
load(String filename
) throws IOException
{
875 FileInputStream in
= new FileInputStream(filename
);
876 Properties prop
= new Properties();
883 * This method saves a property to the specified file.
887 * @throws IOException
889 private void save(String filename
, Properties properties
) throws IOException
{
890 FileOutputStream fos
= new FileOutputStream(filename
);
891 properties
.store(fos
, "");
896 * Saves a list of P2 Metadata Repositories as string with specified delimiters
900 public static void setP2Repositories(List
<MetadataRepositoryElement
> p2Repos
) {
901 StringBuilder sb
= new StringBuilder();
902 for(MetadataRepositoryElement p2Repo
: p2Repos
) {
903 sb
.append(P2_REPOSITORIES_DELIM
);
904 if(p2Repo
.getName() == null || p2Repo
.getName().isEmpty()) {
907 sb
.append(p2Repo
.getName());
909 sb
.append(P2_REPOSITORY_FIELDS_DELIM
);
910 sb
.append(p2Repo
.getLocation().toString());
911 sb
.append(P2_REPOSITORY_FIELDS_DELIM
);
912 sb
.append(String
.valueOf(p2Repo
.isEnabled()));
914 getPreferenceStore().setValue(P2_REPOSITORY_LIST
, sb
.toString());
919 * Retrieves a list of previously saved P2 repositories
923 public static List
<MetadataRepositoryElement
> getP2Repositories() {
924 List
<MetadataRepositoryElement
> p2Repos
= new ArrayList
<MetadataRepositoryElement
>();
925 String p2ReposPref
= getPreferenceStore().getString(P2_REPOSITORY_LIST
);
926 if(p2ReposPref
!= null && !p2ReposPref
.isEmpty()) {
927 StringTokenizer p2ReposPrefST
= new StringTokenizer(p2ReposPref
,P2_REPOSITORIES_DELIM
);
929 while(p2ReposPrefST
.hasMoreTokens()) {
930 String p2RepoStr
= p2ReposPrefST
.nextToken();
931 StringTokenizer p2ReposStrST
= new StringTokenizer(p2RepoStr
,P2_REPOSITORY_FIELDS_DELIM
);
932 if(p2ReposStrST
.countTokens()==3) {
933 String nickname
= p2ReposStrST
.nextToken();
936 uri
= new URI(p2ReposStrST
.nextToken());
937 } catch (URISyntaxException e
) {
940 boolean enabled
= Boolean
.parseBoolean(p2ReposStrST
.nextToken());
941 MetadataRepositoryElement mre
= new MetadataRepositoryElement(null, uri
, true);
942 mre
.setNickname(nickname
);
943 mre
.setEnabled(enabled
);
953 * enables/disables nested composite. <br>
955 * @param ctrl - Composite to be en-/disabeld
956 * @param enabled - boolean
958 public static void recursiveSetEnabled(Control ctrl
, boolean enabled
) {
959 if (ctrl
instanceof Composite
) {
960 Composite comp
= (Composite
) ctrl
;
961 for (Control c
: comp
.getChildren()) {
962 recursiveSetEnabled(c
, enabled
);
965 ctrl
.setEnabled(enabled
);
971 * getSortRanksNaturally
976 public static boolean getSortNodesNaturally() {
977 return getPreferenceStore().getBoolean(SORT_NODES_NATURALLY
);
982 * setSortRanksNaturally
988 public static void setSortNodesNaturally(boolean selection
) {
989 getPreferenceStore().setValue(SORT_NODES_NATURALLY
, selection
);
995 * getSortRanksNaturally
1000 public static boolean getSortNodesStrictlyAlphabetically() {
1001 return getPreferenceStore().getBoolean(SORT_NODES_ALPHABETICALLY
);
1006 * setSortRanksNaturally
1012 public static void setSortNodesStrictlyAlphabetically(boolean selection
) {
1013 getPreferenceStore().setValue(SORT_NODES_ALPHABETICALLY
, selection
);
1018 * setStoreNavigatorState
1024 public static boolean isStoreNavigatorState() {
1025 return getPreferenceStore().getBoolean(RESTORE_NAVIGATOR_STATE
);
1031 * setStoreNavigatorState
1037 public static void setStoreNavigatorState(boolean selection
) {
1038 getPreferenceStore().setValue(RESTORE_NAVIGATOR_STATE
, selection
);
1045 public static boolean isShowUpWidgetIsDisposedMessages() {
1046 return getPreferenceStore().getBoolean(IS_SHOW_UP_WIDGET_IS_DISPOSED
);
1048 public static void setShowUpWidgetIsDisposedMessages(boolean selection
) {
1049 getPreferenceStore().setValue(IS_SHOW_UP_WIDGET_IS_DISPOSED
, selection
);
1055 public static boolean isShowIdInVocabularyInChecklistEditor() {
1056 String area_display
= getPreferenceStore().getString(IPreferenceKeys
.CHECKLIST_AREA_DISPLAY
);
1057 if (area_display
.equals(CHECKLIST_AREA_DISPLAY_ID_IN_VOCABULARY
)) {
1063 public static boolean isShowSymbol1InChecklistEditor() {
1064 String area_display
= getPreferenceStore().getString(IPreferenceKeys
.CHECKLIST_AREA_DISPLAY
);
1065 if (area_display
.equals(CHECKLIST_AREA_DISPLAY_SYMBOL1
)) {
1071 public static boolean isShowSymbol2InChecklistEditor() {
1072 String area_display
= getPreferenceStore().getString(IPreferenceKeys
.CHECKLIST_AREA_DISPLAY
);
1073 if (area_display
.equals(CHECKLIST_AREA_DISPLAY_SYMBOL2
)) {
1079 public static void setShowIdInVocabularyInChecklistEditor(String selection
) {
1080 getPreferenceStore().setValue(CHECKLIST_AREA_DISPLAY
, selection
);
1086 public static boolean isShowSymbolInChecklistEditor() {
1087 return getPreferenceStore().getBoolean(IPreferenceKeys
.CHECKLIST_SYMBOL
);
1089 public static void setShowSymbolInChecklistEditor(boolean selection
) {
1090 getPreferenceStore().setValue(CHECKLIST_SYMBOL
, selection
);
1096 public static boolean isShowRankInChecklistEditor() {
1097 return getPreferenceStore().getBoolean(IPreferenceKeys
.CHECKLIST_SHOW_RANK
);
1099 public static void setShowRankInChecklistEditor(boolean selection
) {
1100 getPreferenceStore().setValue(CHECKLIST_SHOW_RANK
, selection
);
1108 public static NameDetailsConfigurator
getPreferredNameDetailsConfiguration( boolean local
) {
1109 NameDetailsConfigurator config
= new NameDetailsConfigurator(true);
1111 CdmPreference preference
= null;
1114 preference
= getPreferenceFromDB(PreferencePredicate
.NameDetailsView
);
1115 if (preference
== null){
1119 getPreferenceStore().setValue(ALLOW_OVERRIDE_NAME_DETAILS
, preference
.isAllowOverride());
1121 //the preference value is build like this:
1122 //<section1>:true;<section2>:false....
1124 String value
= preference
.getValue();
1125 String
[] sections
= value
.split(";");
1126 Map
<String
, Boolean
> sectionMap
= new HashMap
<String
, Boolean
>();
1127 String
[] sectionValues
;
1128 for (String sectionValue
: sections
){
1129 sectionValues
= sectionValue
.split(":");
1130 sectionMap
.put(sectionValues
[0], Boolean
.valueOf(sectionValues
[1]));
1132 config
.setAllowOverride(preference
.isAllowOverride());
1133 config
.setSimpleDetailsViewActivated(getValue(sectionMap
, "simpleViewActivated"));
1135 // getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON,
1136 // (getValue(sectionMap, "taxon")));
1137 config
.setTaxonSectionActivated(getValue(sectionMap
, "taxon"));
1139 config
.setSecDetailsActivated(getValue(sectionMap
, "taxon.SecEnabled"));
1140 config
.setSecEnabled(getValue(sectionMap
, "taxon.SecDetails"));
1142 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID,
1143 // (getValue(sectionMap, "lsid")));
1144 config
.setLSIDActivated(getValue(sectionMap
, "lsid"));
1146 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
1147 // (getValue(sectionMap, "nc")));
1148 config
.setNomenclaturalCodeActived(getValue(sectionMap
, "nc"));
1150 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
1151 // (getValue(sectionMap, "ap")));
1152 config
.setAppendedPhraseActivated(getValue(sectionMap
, "ap"));
1154 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK,
1155 // (getValue(sectionMap, "rank")));
1156 config
.setRankActivated(getValue(sectionMap
, "rank"));
1159 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
1160 // (getValue(sectionMap, "atomisedEpithets")));
1161 config
.setAtomisedEpithetsActivated(getValue(sectionMap
, "atomisedEpithets"));
1163 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
1164 // (getValue(sectionMap,"author")));
1165 config
.setAuthorshipSectionActivated(getValue(sectionMap
,"author"));
1167 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
1168 // (getValue(sectionMap, "nomRef")));
1169 config
.setNomenclaturalReferenceSectionActivated(sectionMap
.get("nomRef"));
1171 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
1172 // (getValue(sectionMap, "nomStat")));
1173 config
.setNomenclaturalStatusSectionActivated(getValue(sectionMap
, "nomStat"));
1176 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
1177 // (getValue(sectionMap,"protologue")));
1178 config
.setProtologueActivated(getValue(sectionMap
,"protologue"));
1180 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
1181 // (getValue(sectionMap,"typeDes")));
1182 config
.setTypeDesignationSectionActivated(getValue(sectionMap
,"typeDes"));
1184 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
1185 // (getValue(sectionMap,"nameRelation")));
1186 config
.setNameRelationsSectionActivated(getValue(sectionMap
,"nameRelation"));
1188 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_HYBRID,
1189 // (getValue(sectionMap, "hybrid")));
1190 config
.setHybridActivated(getValue(sectionMap
,"hybrid"));
1192 config
.setSimpleDetailsViewActivated(getPreferenceStore().getBoolean(SHOW_SIMPLE_NAME_DETAILS_SECTION
));
1193 config
.setTaxonSectionActivated(getPreferenceStore().getBoolean(SHOW_SIMPLE_NAME_DETAILS_TAXON
));
1194 config
.setSecDetailsActivated(getPreferenceStore().getBoolean(SHOW_SEC_DETAILS
));
1195 config
.setSecEnabled(getPreferenceStore().getBoolean(DISABLE_SEC
));
1196 config
.setLSIDActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_LSID
));
1197 config
.setNomenclaturalCodeActived(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
));
1198 config
.setAppendedPhraseActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE
));
1199 config
.setRankActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_RANK
));
1200 config
.setAtomisedEpithetsActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
));
1201 config
.setAuthorshipSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
));
1202 config
.setNomenclaturalReferenceSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
));
1203 config
.setNomenclaturalStatusSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
));
1204 config
.setProtologueActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
));
1205 config
.setTypeDesignationSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
));
1206 config
.setNameRelationsSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
));
1207 config
.setHybridActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_HYBRID
));
1217 public static void setPreferredNameDetailsConfiguration(NameDetailsConfigurator config
, boolean local
) {
1218 CdmPreference preference
= null;
1221 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.NameDetailsView
, config
.toString());
1223 setPreferenceToDB(preference
);
1225 //also add to local preferences
1226 getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_SECTION
, config
.isSimpleDetailsViewActivated());
1227 getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON
, config
.isTaxonSectionActivated());
1228 getPreferenceStore().setValue(SHOW_SEC_DETAILS
, config
.isSecDetailsActivated());
1229 getPreferenceStore().setValue(DISABLE_SEC
, config
.isSecEnabled());
1230 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID
, config
.isLSIDActivated());
1231 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
, config
.isNomenclaturalCodeActived());
1232 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE
, config
.isAppendedPhraseActivated());
1233 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK
, config
.isRankActivated());
1234 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
, config
.isAtomisedEpithetsActivated());
1235 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
, config
.isAuthorshipSectionActivated());
1236 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
, config
.isNomenclaturalReferenceSectionActivated());
1237 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
, config
.isNomenclaturalStatusSectionActivated());
1238 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
, config
.isProtologueActivated());
1239 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
, config
.isTypeDesignationSectionActivated());
1240 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
, config
.isNameRelationsSectionActivated());
1241 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_HYBRID
, config
.isHybridActivated());
1245 private static Boolean
getValue(Map
<String
, Boolean
> sectionMap
, String string
) {
1246 if (sectionMap
.containsKey(string
)){
1247 return sectionMap
.get(string
);
1258 * setAbcdConfigurator
1261 * @param preferredConfiguration
1262 * a {@link eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator}
1265 public static Abcd206ImportConfigurator
getAbcdImportConfigurationPreference() {
1267 Abcd206ImportConfigurator config
= Abcd206ImportConfigurator
.NewInstance(null,null);
1268 ICdmRepository controller
;
1269 controller
= CdmStore
.getCurrentApplicationConfiguration();
1270 PrefKey key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.AbcdImportConfig
);
1271 CdmPreference preference
= null;
1272 if (controller
== null){
1275 preference
= controller
.getPreferenceService().find(key
);
1276 boolean allowOverride
= true;
1277 if (preference
!= null && !preference
.isAllowOverride()){
1278 allowOverride
= false;
1280 if (PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_OVERRIDE
) && allowOverride
){
1282 config
.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS
));
1284 config
.setAddMediaAsMediaSpecimen(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN
));
1286 config
.setAllowReuseOtherClassifications(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS
));
1287 config
.setDeduplicateClassifications(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS
));
1288 config
.setDeduplicateReferences(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES
));
1290 config
.setGetSiblings(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS
));
1291 config
.setIgnoreAuthorship(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP
));
1292 config
.setIgnoreImportOfExistingSpecimen(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN
));
1293 config
.setMapUnitIdToAccessionNumber(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER
));
1294 config
.setMapUnitIdToBarcode(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE
));
1295 config
.setMapUnitIdToCatalogNumber(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER
));
1296 config
.setMoveNewTaxaToDefaultClassification(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION
));
1297 config
.setOverwriteExistingSpecimens(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN
));
1298 config
.setReuseExistingDescriptiveGroups(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS
));
1299 config
.setReuseExistingMetaData(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA
));
1300 config
.setReuseExistingTaxaWhenPossible(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE
));
1301 config
.setNomenclaturalCode(NomenclaturalCode
.getByKey(PreferencesUtil
.getPreferenceStore().getString(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE
)));
1306 if (preference
== null){
1309 String configString
= preference
.getValue();
1310 String
[] configArray
= configString
.split(";");
1312 for (String configItem
: configArray
){
1313 String
[] keyValue
= configItem
.split(":");
1314 String keyString
= keyValue
[0];
1315 String valueString
= keyValue
[1];
1316 if (keyString
.equals("ignoreImportOfExistingSpecimen")){
1317 config
.setIgnoreImportOfExistingSpecimen(Boolean
.valueOf(valueString
));
1318 }else if (keyString
.equals("addIndividualsAssociationsSuchAsSpecimenAndObservations")){
1319 config
.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(Boolean
.valueOf(valueString
));
1320 }else if (keyString
.equals("reuseExistingTaxaWhenPossible")){
1321 config
.setReuseExistingTaxaWhenPossible(Boolean
.valueOf(valueString
));
1322 }else if (keyString
.equals("ignoreAuthorship")){
1323 config
.setIgnoreAuthorship(Boolean
.valueOf(valueString
));
1324 }else if (keyString
.equals("addMediaAsMediaSpecimen")){
1325 config
.setAddMediaAsMediaSpecimen(Boolean
.valueOf(valueString
));
1326 }else if (keyString
.equals("reuseExistingMetaData")){
1327 config
.setReuseExistingMetaData(Boolean
.valueOf(valueString
));
1328 }else if (keyString
.equals("reuseExistingDescriptiveGroups")){
1329 config
.setReuseExistingDescriptiveGroups(Boolean
.valueOf(valueString
));
1330 }else if (keyString
.equals("allowReuseOtherClassifications")){
1331 config
.setAllowReuseOtherClassifications(Boolean
.valueOf(valueString
));
1332 }else if (keyString
.equals("deduplicateReferences")){
1333 config
.setDeduplicateReferences(Boolean
.valueOf(valueString
));
1334 }else if (keyString
.equals("deduplicateClassifications")){
1335 config
.setDeduplicateClassifications(Boolean
.valueOf(valueString
));
1336 }else if (keyString
.equals("moveNewTaxaToDefaultClassification")){
1337 config
.setMoveNewTaxaToDefaultClassification(Boolean
.valueOf(valueString
));
1338 }else if (keyString
.equals("mapUnitIdToCatalogNumber")){
1339 config
.setMapUnitIdToCatalogNumber(Boolean
.valueOf(valueString
));
1340 }else if (keyString
.equals("mapUnitIdToAccessionNumber")){
1341 config
.setMapUnitIdToAccessionNumber(Boolean
.valueOf(valueString
));
1342 }else if (keyString
.equals("mapUnitIdToBarcode")){
1343 config
.setMapUnitIdToBarcode(Boolean
.valueOf(valueString
));
1344 }else if (keyString
.equals("overwriteExistingSpecimens")){
1345 config
.setOverwriteExistingSpecimens(Boolean
.valueOf(valueString
));
1346 }else if (keyString
.equals("nomenclaturalCode")){
1347 config
.setNomenclaturalCode(NomenclaturalCode
.fromString(valueString
));
1349 logger
.debug("This key of the abcd configurator needs to be added to the transformer: " + keyString
);
1358 public static void updateAbcdImportConfigurationPreference() {
1360 Abcd206ImportConfigurator config
= Abcd206ImportConfigurator
.NewInstance(null,null);
1361 ICdmRepository controller
;
1362 controller
= CdmStore
.getCurrentApplicationConfiguration();
1363 PrefKey key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.AbcdImportConfig
);
1364 CdmPreference preference
= null;
1365 if (controller
== null){
1368 preference
= controller
.getPreferenceService().find(key
);
1369 boolean allowOverride
= true;
1370 if (preference
!= null && !preference
.isAllowOverride()){
1371 allowOverride
= false;
1373 if (!PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_OVERRIDE
) || !allowOverride
){
1375 getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS
, config
.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
1376 getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN
, config
.isAddMediaAsMediaSpecimen());
1378 getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS
, config
.isAllowReuseOtherClassifications());
1379 getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS
, config
.isDeduplicateClassifications());
1380 getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES
, config
.isDeduplicateReferences());
1382 getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS
, config
.isGetSiblings());
1383 getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP
, config
.isIgnoreAuthorship());
1384 getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN
, config
.isIgnoreImportOfExistingSpecimen());
1385 getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER
, config
.isMapUnitIdToAccessionNumber());
1386 getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE
, config
.isMapUnitIdToBarcode());
1387 getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER
, config
.isMapUnitIdToCatalogNumber());
1388 getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION
, config
.isMoveNewTaxaToDefaultClassification());
1389 getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN
, config
.isOverwriteExistingSpecimens());
1390 getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS
, config
.isReuseExistingDescriptiveGroups());
1391 getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA
, config
.isReuseExistingMetaData());
1392 getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE
, config
.isReuseExistingTaxaWhenPossible());
1393 if (config
.getNomenclaturalCode() != null){
1394 getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE
, config
.getNomenclaturalCode().getKey());
1403 public NameDetailsConfigurator
createLocalNameDetailsViewConfig(boolean local
) {
1404 NameDetailsConfigurator config
= new NameDetailsConfigurator(true);
1406 config
.setSimpleDetailsViewActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_SIMPLE_NAME_DETAILS_SECTION
));
1407 config
.setAppendedPhraseActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE
));
1408 config
.setAtomisedEpithetsActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
));
1409 config
.setAuthorshipSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
));
1410 config
.setLSIDActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_LSID
));
1411 config
.setNameApprobiationActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION
));
1412 config
.setNameCacheActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_CACHE
));
1413 config
.setNameRelationsSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
));
1414 config
.setNomenclaturalCodeActived(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
));
1415 config
.setNomenclaturalStatusSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
));
1416 config
.setNomenclaturalReferenceSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
));
1417 config
.setProtologueActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
));
1418 config
.setRankActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_RANK
));
1419 config
.setTaxonSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_SIMPLE_NAME_DETAILS_TAXON
));
1420 config
.setTypeDesignationSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
));
1421 config
.setHybridActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_HYBRID
));
1430 public static void saveConfigToPrefernceStore(NameDetailsConfigurator config
) {
1431 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_SIMPLE_NAME_DETAILS_SECTION
,
1432 config
.isSimpleDetailsViewActivated());
1433 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_SIMPLE_NAME_DETAILS_TAXON
, config
.isTaxonSectionActivated());
1434 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_LSID
, config
.isLSIDActivated());
1435 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
,
1436 config
.isNomenclaturalCodeActived());
1437 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NAMECACHE
,
1438 config
.isNameCacheActivated());
1439 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE
,
1440 config
.isAppendedPhraseActivated());
1441 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_RANK
, config
.isRankActivated());
1442 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
,
1443 config
.isAtomisedEpithetsActivated());
1444 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE
,
1445 config
.isAuthorCacheActivated());
1446 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
,
1447 config
.isAuthorshipSectionActivated());
1448 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
,
1449 config
.isNomenclaturalReferenceSectionActivated());
1450 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
,
1451 config
.isNomenclaturalStatusSectionActivated());
1452 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
,
1453 config
.isProtologueActivated());
1454 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
,
1455 config
.isTypeDesignationSectionActivated());
1456 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
,
1457 config
.isNameRelationsSectionActivated());
1458 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_HYBRID
,
1459 config
.isHybridActivated());
1466 public static boolean isSortTaxaByRankAndName() {
1468 return getPreferenceStore().getBoolean(IPreferenceKeys
.SORT_TAXA_BY_RANK_AND_NAME
);
1474 public static boolean isSortNamedAreaByOrderInVocabulary() {
1476 return getPreferenceStore().getBoolean(IPreferenceKeys
.SORT_NAMED_AREA_BY_VOCABULARY_ORDER
);
1479 public static void setSortNamedAreasByOrderInVocabulary(boolean isSortByVocabularyOrder
) {
1480 getPreferenceStore().setValue(IPreferenceKeys
.SORT_NAMED_AREA_BY_VOCABULARY_ORDER
, isSortByVocabularyOrder
);
1486 * setPreferredNamedAreasForDistributionEditor
1489 * @param saveCheckedElements
1490 * @param saveGrayedElements
1492 public static void setLastSelectedReference(
1493 List
<String
> lastSelectedReferences
) {
1495 IPreferenceStore preferenceStore
= PreferencesUtil
.getPreferenceStore();
1496 preferenceStore
.setValue(PreferencesUtil
.LAST_SELECTED_REFERENCES
, lastSelectedReferences
.toString());
1501 * setPreferredNamedAreasForDistributionEditor
1504 * @param saveCheckedElements
1505 * @param saveGrayedElements
1507 public static List
<String
> getLastSelectedReferences() {
1509 IPreferenceStore preferenceStore
= PreferencesUtil
.getPreferenceStore();
1510 String lastSelected
= preferenceStore
.getString(PreferencesUtil
.LAST_SELECTED_REFERENCES
);
1511 List
<String
> result
= new ArrayList
<>();
1512 if (!StringUtils
.isBlank(lastSelected
)){
1513 Collections
.addAll(result
, lastSelected
.substring(1,lastSelected
.length()-1).split(", "));
1521 * setPreferredNamedAreasForDistributionEditor
1524 * @param saveCheckedElements
1525 * @param saveGrayedElements
1527 public static void setPreferredNamedAreasForDistributionEditor(
1528 String saveCheckedElements
, String saveGrayedElements
, boolean local
) {
1530 IPreferenceStore preferenceStore
= PreferencesUtil
.getPreferenceStore();
1531 preferenceStore
.setValue(PreferencesUtil
.DISTRIBUTION_AREA_OCCURENCE_STATUS
, saveCheckedElements
);
1532 preferenceStore
.setValue(PreferencesUtil
.DISTRIBUTION_AREA_OCCURENCE_STATUS_GRAYED
, saveGrayedElements
);
1536 CdmPreference preference
= null;
1538 if (saveCheckedElements
== null){
1539 preference
= getPreferenceFromDB(PreferencePredicate
.AvailableDistributionAreaTerms
);
1541 if (preference
== null){
1544 getPreferenceStore().setValue(DISTRIBUTION_AREA_OCCURENCE_STATUS
,
1545 saveCheckedElements
);
1546 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.AvailableDistributionAreaTerms
, saveCheckedElements
);
1547 setPreferenceToDB(preference
);
1551 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.AvailableDistributionAreaTerms
, saveCheckedElements
);
1552 setPreferenceToDB(preference
);
1553 getPreferenceStore().setValue(DISTRIBUTION_AREA_OCCURENCE_STATUS
,
1554 saveCheckedElements
);
1562 * @param saveCheckedElements
1563 * @param saveCheckedElements2
1566 public static void setPreferredVocabulariesForDistributionEditor(String saveCheckedElements
,
1569 IPreferenceStore preferenceStore
= PreferencesUtil
.getPreferenceStore();
1570 preferenceStore
.setValue(PreferencesUtil
.DISTRIBUTION_VOCABULARIES
, saveCheckedElements
);
1573 ICdmRepository controller
;
1574 CdmPreference preference
= null;
1576 if (saveCheckedElements
== null){
1577 preference
= getPreferenceFromDB(PreferencePredicate
.AvailableDistributionAreaVocabularies
);
1579 if (preference
== null){
1582 getPreferenceStore().setValue(DISTRIBUTION_VOCABULARIES
,
1583 saveCheckedElements
);
1584 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.AvailableDistributionAreaVocabularies
, saveCheckedElements
);
1585 setPreferenceToDB(preference
);
1588 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.AvailableDistributionAreaVocabularies
, saveCheckedElements
);
1589 setPreferenceToDB(preference
);
1590 getPreferenceStore().setValue(DISTRIBUTION_VOCABULARIES
,
1591 saveCheckedElements
);
1601 * @param saveCheckedElements
1602 * @param saveCheckedElements2
1605 public static String
getPreferredVocabulariesForDistributionEditor(boolean local
) {
1607 IPreferenceStore preferenceStore
= PreferencesUtil
.getPreferenceStore();
1608 String pref
= preferenceStore
.getString(DISTRIBUTION_VOCABULARIES
);
1612 CdmPreference preference
= null;
1613 preference
= getPreferenceFromDB(PreferencePredicate
.AvailableDistributionAreaVocabularies
);
1614 if (preference
== null){
1617 return preference
.getValue();
1626 public static boolean getFilterCommonNameReferences(){
1627 return getPreferenceStore().getBoolean(PreferencesUtil
.FILTER_COMMON_NAME_REFERENCES
);
1633 public static void updateDBPreferences() {
1634 CdmPreference preference
= null;
1635 IPreferenceStore prefStore
= getPreferenceStore();
1639 updateAbcdImportConfigurationPreference();
1641 preference
= getPreferenceFromDB(PreferencePredicate
.ShowImportExportMenu
);
1642 if (preference
!= null){
1643 if(!prefStore
.getBoolean(SHOW_IO_MENU
) || !preference
.isAllowOverride()){
1644 prefStore
.setValue(SHOW_IO_MENU
, preference
.getValue());
1647 prefStore
.setValue(SHOW_IO_MENU
, true);
1650 preference
= getPreferenceFromDB(PreferencePredicate
.ShowMediaView
);
1651 if (preference
!= null){
1652 if(!prefStore
.getBoolean(SHOW_MEDIA
) || !preference
.isAllowOverride()){
1653 prefStore
.setValue(SHOW_MEDIA
, preference
.getValue());
1656 prefStore
.setValue(SHOW_MEDIA
, true);
1659 preference
= getPreferenceFromDB(PreferencePredicate
.ShowChecklistPerspective
);
1660 if (preference
!= null){
1661 if(!prefStore
.getBoolean(SHOW_CHECKLIST_PERSPECTIVE
) || !preference
.isAllowOverride()){
1662 prefStore
.setValue(SHOW_CHECKLIST_PERSPECTIVE
, preference
.getValue());
1665 prefStore
.setValue(SHOW_CHECKLIST_PERSPECTIVE
, false);
1669 preference
= getPreferenceFromDB(PreferencePredicate
.ShowSpecimen
);
1670 if (preference
!= null){
1671 if(!prefStore
.getBoolean(SHOW_SPECIMEN
) || !preference
.isAllowOverride()){
1672 prefStore
.setValue(SHOW_SPECIMEN
, preference
.getValue());
1675 prefStore
.setValue(SHOW_SPECIMEN
, true);
1678 preference
= getPreferenceFromDB(PreferencePredicate
.ShowTaxonAssociations
);
1679 if (preference
!= null){
1680 if(!prefStore
.getBoolean(SHOW_TAXON_ASSOCIATIONS_OVERRIDE
) || !preference
.isAllowOverride()){
1681 prefStore
.setValue(SHOW_TAXON_ASSOCIATIONS
, preference
.getValue());
1684 preference
= getPreferenceFromDB(PreferencePredicate
.ShowCollectingAreasInGeneralSection
);
1685 if (preference
!= null){
1686 if(!prefStore
.getBoolean(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION_OVERRIDE
) || !preference
.isAllowOverride()){
1687 prefStore
.setValue(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION
, preference
.getValue());
1690 preference
= getPreferenceFromDB(PreferencePredicate
.ShowLifeForm
);
1691 if (preference
!= null){
1692 if(!prefStore
.getBoolean(SHOW_LIFE_FORM_OVERRIDE
) || !preference
.isAllowOverride()){
1693 prefStore
.setValue(SHOW_LIFE_FORM
, preference
.getValue());
1696 preference
= getPreferenceFromDB(PreferencePredicate
.DeterminationOnlyForFieldUnits
);
1697 if (preference
!= null){
1698 if(!prefStore
.getBoolean(DETERMINATION_ONLY_FOR_FIELD_UNITS_OVERRIDE
) || !preference
.isAllowOverride()){
1699 prefStore
.setValue(DETERMINATION_ONLY_FOR_FIELD_UNITS
, preference
.getValue());
1705 NameDetailsConfigurator config
= getPreferredNameDetailsConfiguration(false);
1706 if (config
!= null ){
1707 if (!prefStore
.getBoolean(OVERRIDE_NAME_DETAILS
) || !prefStore
.getBoolean(ALLOW_OVERRIDE_NAME_DETAILS
)){
1708 setPreferredNameDetailsConfiguration(config
, false);
1712 //Distribution Editor
1713 preference
= getPreferenceFromDB(PreferencePredicate
.AvailableDistributionAreaVocabularies
);
1714 if (preference
!= null){
1715 if (!prefStore
.getBoolean(DISTRIBUTION_VOCABULARIES_OVERRIDE
) || !preference
.isAllowOverride()){
1716 prefStore
.setValue(DISTRIBUTION_VOCABULARIES
, preference
.getValue());
1717 prefStore
.setValue(DISTRIBUTION_VOCABULARIES_ALLOW_OVERRIDE
, preference
.getValue());
1720 prefStore
.setValue(DISTRIBUTION_VOCABULARIES_ALLOW_OVERRIDE
,true);
1721 prefStore
.setToDefault(DISTRIBUTION_VOCABULARIES
);
1724 preference
= getPreferenceFromDB(PreferencePredicate
.DistributionEditorActivated
);
1725 if (preference
!= null){
1726 if (!prefStore
.getBoolean(DISTRIBUTION_AREA_PREFRENCES_ACTIVE_OVERRIDE
) || !preference
.isAllowOverride()){
1727 prefStore
.setValue(DISTRIBUTION_AREA_PREFRENCES_ACTIVE
, preference
.getValue());
1731 preference
= getPreferenceFromDB(PreferencePredicate
.AvailableDistributionStatus
);
1732 if (preference
!= null){
1733 if (!prefStore
.getBoolean(DISTRIBUTION_STATUS_OVERRIDE
) || !preference
.isAllowOverride()){
1734 //get terms for the uuids... and add them to the termManager as preferred terms
1735 ITermService termService
= CdmStore
.getService(ITermService
.class);
1736 String
[] uuidArray
= preference
.getValue().split(";");
1737 List
<UUID
> uuidList
= new ArrayList();
1738 for (String uuidString
:uuidArray
){
1739 uuidList
.add(UUID
.fromString(uuidString
));
1742 List
<DefinedTermBase
> definedTermBases
= termService
.load(uuidList
, null);
1743 CdmStore
.getTermManager().setPreferredTerms(definedTermBases
, TermStore
.getTerms(TermType
.PresenceAbsenceTerm
, null));
1747 preference
= getPreferenceFromDB(PreferencePredicate
.CommonNameAreaVocabularies
);
1748 if (preference
!= null){
1749 if (!prefStore
.getBoolean(COMMON_NAME_AREA_VOCABULARIES
) || !preference
.isAllowOverride()){
1750 prefStore
.setValue(COMMON_NAME_AREA_VOCABULARIES
, preference
.getValue());
1751 prefStore
.setValue(COMMON_NAME_AREA_VOCABULARIES_ALLOW_OVERRIDE
, preference
.isAllowOverride());
1754 prefStore
.setToDefault(COMMON_NAME_AREA_VOCABULARIES
);
1755 prefStore
.setValue(COMMON_NAME_AREA_VOCABULARIES_ALLOW_OVERRIDE
, true);
1758 preference
= getPreferenceFromDB(PreferencePredicate
.CommonNameReferencesWithMarker
);
1759 if (preference
!= null){
1760 if (!prefStore
.getBoolean(FILTER_COMMON_NAME_REFERENCES
) || !preference
.isAllowOverride()){
1761 prefStore
.setValue(FILTER_COMMON_NAME_REFERENCES
, preference
.getValue());
1764 prefStore
.setValue(FILTER_COMMON_NAME_REFERENCES
, false);
1768 preference
= getPreferenceFromDB(PreferencePredicate
.ShowTaxonNodeWizard
);
1769 if (preference
!= null){
1770 if (!prefStore
.getBoolean(SHOW_TAXONNODE_WIZARD
) || !preference
.isAllowOverride()){
1771 prefStore
.setValue(SHOW_TAXONNODE_WIZARD
, preference
.getValue());
1774 prefStore
.setValue(SHOW_TAXONNODE_WIZARD
, true);
1777 preference
= getPreferenceFromDB(PreferencePredicate
.ShowIdInSource
);
1778 if (preference
!= null){
1779 if (!prefStore
.getBoolean(SHOW_ID_IN_SOURCE
) || !preference
.isAllowOverride()){
1780 prefStore
.setValue(SHOW_ID_IN_SOURCE
, preference
.getValue());
1783 prefStore
.setValue(SHOW_ID_IN_SOURCE
, true);
1786 preference
= getPreferenceFromDB(PreferencePredicate
.ShowNameInSource
);
1787 if (preference
!= null){
1788 if (!prefStore
.getBoolean(SHOW_NAME_IN_SOURCE
) || !preference
.isAllowOverride()){
1789 prefStore
.setValue(SHOW_NAME_IN_SOURCE
, preference
.getValue());
1792 prefStore
.setValue(SHOW_NAME_IN_SOURCE
, true);
1795 preference
= getPreferenceFromDB(PreferencePredicate
.DisableMultiClassification
);
1796 if (preference
!= null){
1797 if (!prefStore
.getBoolean(DISABLE_MULTI_CLASSIFICATION
) || !preference
.isAllowOverride()){
1798 prefStore
.setValue(DISABLE_MULTI_CLASSIFICATION
, preference
.getValue());
1801 prefStore
.setValue(DISABLE_MULTI_CLASSIFICATION
, false);