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
.ICdmBase
;
49 import eu
.etaxonomy
.cdm
.model
.common
.IDefinedTerm
;
50 import eu
.etaxonomy
.cdm
.model
.common
.ISimpleTerm
;
51 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
52 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
53 import eu
.etaxonomy
.cdm
.model
.common
.TermBase
;
54 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
55 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmPreference
;
56 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmPreference
.PrefKey
;
57 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferencePredicate
;
58 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferenceSubject
;
59 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
60 import eu
.etaxonomy
.cdm
.strategy
.match
.DefaultMatchStrategy
;
61 import eu
.etaxonomy
.cdm
.strategy
.match
.IMatchStrategy
;
62 import eu
.etaxonomy
.cdm
.strategy
.match
.MatchException
;
63 import eu
.etaxonomy
.cdm
.strategy
.match
.MatchMode
;
64 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
65 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
66 import eu
.etaxonomy
.taxeditor
.model
.NomenclaturalCodeHelper
;
67 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
68 import eu
.etaxonomy
.taxeditor
.store
.internal
.TaxeditorStorePlugin
;
69 import eu
.etaxonomy
.taxeditor
.ui
.dialog
.DefaultLanguageDialog
;
73 * PreferencesUtil class.
81 public class PreferencesUtil
implements IPreferenceKeys
{
86 public static final String PREFERRED_TERMS_CHANGE
= "preferred_terms";
88 public static final String P2_REPOSITORIES_DELIM
= ",";
89 public static final String P2_REPOSITORY_FIELDS_DELIM
= ";";
91 private final static Logger logger
= Logger
.getLogger(PreferencesUtil
.class);
100 * @return a {@link org.eclipse.jface.preference.IPreferenceStore} object.
102 public static IPreferenceStore
getPreferenceStore() {
103 return TaxeditorStorePlugin
.getDefault().getPreferenceStore();
108 * setPreferredNomenclaturalCode
111 * @param preferredCode
112 * a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
115 public static CdmPreference
setPreferredNomenclaturalCode(
116 String preferenceKey
, boolean local
) {
118 getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY
,
122 ICdmRepository controller
;
123 controller
= CdmStore
.getCurrentApplicationConfiguration();
126 key
= CdmPreference
.NewKey(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.NomenclaturalCode
);
127 }catch (Exception e
){
128 System
.out
.println(e
.getStackTrace());
130 CdmPreference preference
= null;
131 if (controller
== null){
134 if (preferenceKey
== null){
135 preference
= controller
.getPreferenceService().find(key
);
136 if (preference
== null){
139 // int index = StringUtils.lastIndexOf(preference.getValue(), ".");
140 // UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
141 // preferredCode = NomenclaturalCode.getByUuid(uuid);
143 getPreferenceStore().setValue(CDM_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(OVERRIDE_SPECIMEN_PREF
) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_SPECIMEN_PREF
)) {
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(OVERRIDE_SPECIMEN_PREF
) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_SPECIMEN_PREF
)) {
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(OVERRIDE_SPECIMEN_PREF
) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_SPECIMEN_PREF
)) {
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(OVERRIDE_SPECIMEN_PREF
) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_SPECIMEN_PREF
)) {
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
.NewDatabaseInstance(), 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
= new FindTaxaAndNamesConfiguratorImpl();
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 getPreferenceStore().setDefault(IPreferenceKeys
.DISTRIBUTION_AREA_PREFRENCES_ACTIVE
, false);
574 getPreferenceStore().setDefault(CHECKLIST_ID_IN_VOCABULARY
, true);
575 getPreferenceStore().setDefault(CHECKLIST_SYMBOL
, false);
576 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
, true);
577 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE
, true);
578 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
, true);
579 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_HYBRID
, true);
580 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_LSID
, true);
581 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
, true);
582 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NAMECACHE
, true);
583 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
, true);
584 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
, true);
585 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
, true);
586 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
, true);
587 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_RANK
, true);
588 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
, true);
589 getPreferenceStore().setDefault(SORT_NODES_NATURALLY
, false);
590 getPreferenceStore().setDefault(SORT_NODES_ALPHABETICALLY
, false);
591 getPreferenceStore().setDefault(SORT_TAXA_BY_RANK_AND_NAME
, true);
597 * checkNomenclaturalCode
600 public static void checkNomenclaturalCode() {
601 // First time Editor is opened, no nomenclatural code has been set
604 if (PreferencesUtil
.getPreferredNomenclaturalCode(true) == null) {
605 PreferencesUtil
.setPreferredNomenclaturalCode(getPreferenceKey(NomenclaturalCode
.ICNAFP
), true);
611 public static void setNomenclaturalCodePreferences(){
612 ICdmRepository controller
;
613 controller
= CdmStore
.getCurrentApplicationConfiguration();
614 PrefKey key
= CdmPreference
.NewKey(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.NomenclaturalCode
);
615 CdmPreference preference
= null;
616 if (controller
== null){
619 preference
= controller
.getPreferenceService().find(key
);
620 if (preference
== null){
623 getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY
, preference
.isAllowOverride());
625 int index
= StringUtils
.lastIndexOf(preference
.getValue(), ".");
626 UUID uuid
= UUID
.fromString(preference
.getValue().substring(index
+1, preference
.getValue().length()));
627 NomenclaturalCode preferredCode
= NomenclaturalCode
.getByUuid(uuid
);
629 getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY
,
630 getPreferenceKey(preferredCode
));
632 if (!preference
.isAllowOverride()){
633 getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY
,
634 getPreferenceKey(preferredCode
));
638 public static void checkDefaultLanguage(){
639 if(PreferencesUtil
.getPreferredDefaultLangugae() == null){
640 Shell shell
= AbstractUtility
.getShell();
641 int open
= new DefaultLanguageDialog(shell
).open();
642 if(open
== Window
.OK
){
643 PlatformUI
.getWorkbench().restart();
646 //TODO:In case of a reinstall, the config.ini will be overwritten
647 // here you create config.ini with the stored key from preferences
653 * getMapServiceAccessPoint
656 * @return a {@link java.lang.String} object.
658 public static String
getMapServiceAccessPoint() {
659 return getPreferenceStore().getString(EDIT_MAP_SERVICE_ACCES_POINT
);
664 * shouldConnectAtStartUp
669 public static boolean shouldConnectAtStartUp() {
670 //FIXME : force SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
671 //return getPreferenceStore().getBoolean(SHOULD_CONNECT_AT_STARTUP);
677 * getDefaultFeatureTreeForTextualDescription
680 * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
682 public static FeatureTree
getDefaultFeatureTreeForTextualDescription() {
683 String uuidString
= getPreferenceStore().getString(
684 FEATURE_TREE_DEFAULT_TEXT
);
685 return CdmUtils
.isEmpty(uuidString
) ?
null : CdmStore
.getService(
686 IFeatureTreeService
.class).load(UUID
.fromString(uuidString
));
691 * getDefaultFeatureTreeForStructuredDescription
694 * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
696 public static FeatureTree
getDefaultFeatureTreeForStructuredDescription() {
697 String uuidString
= getPreferenceStore().getString(
698 FEATURE_TREE_DEFAULT_STRUCTURE
);
699 return CdmUtils
.isEmpty(uuidString
) ?
null : CdmStore
.getService(
700 IFeatureTreeService
.class).load(UUID
.fromString(uuidString
));
705 * setSortRanksHierarchichally
711 public static void setSortRanksHierarchichally(boolean selection
) {
712 getPreferenceStore().setValue(SORT_RANKS_HIERARCHICHALLY
, selection
);
717 * getSortRanksHierarchichally
722 public static boolean getSortRanksHierarchichally() {
723 return getPreferenceStore().getBoolean(SORT_RANKS_HIERARCHICHALLY
);
726 public static boolean isMultilanguageTextEditingCapability() {
727 return getPreferenceStore().getBoolean(
728 MULTILANGUAGE_TEXT_EDITING_CAPABILITY
);
731 public static Language
getGlobalLanguage() {
734 String languageUuidString
= getPreferenceStore().getString(
735 GLOBAL_LANGUAGE_UUID
);
737 if(!CdmStore
.isActive()) {
738 MessagingUtils
.noDataSourceWarningDialog(languageUuidString
);
742 if (CdmUtils
.isBlank(languageUuidString
)) {
743 return Language
.getDefaultLanguage();
746 UUID languageUuid
= UUID
.fromString(languageUuidString
);
747 return (Language
) CdmStore
.getService(ITermService
.class).load(
751 public static void setGlobalLanguage(Language language
) {
752 if(language
!= null) {
753 getPreferenceStore().setValue(GLOBAL_LANGUAGE_UUID
,language
.getUuid().toString());
754 CdmStore
.setDefaultLanguage(language
);
762 public static Map
<MarkerType
, Boolean
> getEditMarkerTypePreferences() {
763 List
<MarkerType
> markerTypes
= CdmStore
.getTermManager()
764 .getPreferredTerms(MarkerType
.class);
766 Map
<MarkerType
, Boolean
> result
= new HashMap
<MarkerType
, Boolean
>();
768 for (MarkerType markerType
: markerTypes
) {
769 String name
= getMarkerTypeEditingPreferenceKey(markerType
);
770 Boolean value
= getPreferenceStore().getBoolean(name
);
772 result
.put(markerType
, value
);
779 * @param markerTypeEditingMap
781 public static void setEditMarkerTypePreferences(
782 Map
<MarkerType
, Boolean
> markerTypeEditingMap
) {
783 for (MarkerType markerType
: markerTypeEditingMap
.keySet()) {
784 String name
= getMarkerTypeEditingPreferenceKey(markerType
);
785 getPreferenceStore().setValue(name
,
786 markerTypeEditingMap
.get(markerType
));
791 private static String
getMarkerTypeEditingPreferenceKey(
792 MarkerType markerType
) {
793 markerType
= HibernateProxyHelper
.deproxy(markerType
);
794 return markerType
.getClass().getName() + EDIT_MARKER_TYPE_PREFIX
;
799 * setEditMarkerTypePreference
803 * a {@link org.eclipse.ui.IEditorInput} object.
805 * a {@link eu.etaxonomy.cdm.model.common.MarkerType} object.
809 public static void setEditMarkerTypePreference(MarkerType markerType
,
811 getPreferenceStore().setValue(
812 getMarkerTypeEditingPreferenceKey(markerType
), edit
);
818 public static DerivedUnitFacadeConfigurator
getDerivedUnitConfigurator() {
819 DerivedUnitFacadeConfigurator configurator
= DerivedUnitFacadeConfigurator
821 configurator
.setMoveDerivedUnitMediaToGallery(true);
822 configurator
.setMoveFieldObjectMediaToGallery(true);
827 * This method will write language properties to the config.ini located in the configuration folder
828 * of the Taxonomic Ediitor. <b>This method is only used to set the default language for Taxonomic Editor.</b>
830 * @param setLanguage 0 is for german and 1 for english.
831 * @throws IOException
833 public void writePropertyToConfigFile(int setLanguage
) throws IOException
{
834 File file
= org
.eclipse
.core
.runtime
.preferences
.ConfigurationScope
.INSTANCE
.getLocation().toFile();
835 //give warning to user if the directory has no write access
837 throw new IOException();
839 Properties properties
= load(file
.getAbsolutePath()+"/config.ini");
842 properties
.setProperty("osgi.nl", "de");
843 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.DEFAULT_LANGUAGE_EDITOR
, "de");
846 properties
.setProperty("osgi.nl", "en");
847 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.DEFAULT_LANGUAGE_EDITOR
, "en");
852 save(file
+"/config.ini", properties
);
856 * This method loads a property from a given file and returns it.
860 * @throws IOException
862 private Properties
load(String filename
) throws IOException
{
863 FileInputStream in
= new FileInputStream(filename
);
864 Properties prop
= new Properties();
871 * This method saves a property to the specified file.
875 * @throws IOException
877 private void save(String filename
, Properties properties
) throws IOException
{
878 FileOutputStream fos
= new FileOutputStream(filename
);
879 properties
.store(fos
, "");
884 * Saves a list of P2 Metadata Repositories as string with specified delimiters
888 public static void setP2Repositories(List
<MetadataRepositoryElement
> p2Repos
) {
889 StringBuilder sb
= new StringBuilder();
890 for(MetadataRepositoryElement p2Repo
: p2Repos
) {
891 sb
.append(P2_REPOSITORIES_DELIM
);
892 if(p2Repo
.getName() == null || p2Repo
.getName().isEmpty()) {
895 sb
.append(p2Repo
.getName());
897 sb
.append(P2_REPOSITORY_FIELDS_DELIM
);
898 sb
.append(p2Repo
.getLocation().toString());
899 sb
.append(P2_REPOSITORY_FIELDS_DELIM
);
900 sb
.append(String
.valueOf(p2Repo
.isEnabled()));
902 getPreferenceStore().setValue(P2_REPOSITORY_LIST
, sb
.toString());
907 * Retrieves a list of previously saved P2 repositories
911 public static List
<MetadataRepositoryElement
> getP2Repositories() {
912 List
<MetadataRepositoryElement
> p2Repos
= new ArrayList
<MetadataRepositoryElement
>();
913 String p2ReposPref
= getPreferenceStore().getString(P2_REPOSITORY_LIST
);
914 if(p2ReposPref
!= null && !p2ReposPref
.isEmpty()) {
915 StringTokenizer p2ReposPrefST
= new StringTokenizer(p2ReposPref
,P2_REPOSITORIES_DELIM
);
917 while(p2ReposPrefST
.hasMoreTokens()) {
918 String p2RepoStr
= p2ReposPrefST
.nextToken();
919 StringTokenizer p2ReposStrST
= new StringTokenizer(p2RepoStr
,P2_REPOSITORY_FIELDS_DELIM
);
920 if(p2ReposStrST
.countTokens()==3) {
921 String nickname
= p2ReposStrST
.nextToken();
924 uri
= new URI(p2ReposStrST
.nextToken());
925 } catch (URISyntaxException e
) {
928 boolean enabled
= Boolean
.parseBoolean(p2ReposStrST
.nextToken());
929 MetadataRepositoryElement mre
= new MetadataRepositoryElement(null, uri
, true);
930 mre
.setNickname(nickname
);
931 mre
.setEnabled(enabled
);
941 * enables/disables nested composite. <br>
943 * @param ctrl - Composite to be en-/disabeld
944 * @param enabled - boolean
946 public static void recursiveSetEnabled(Control ctrl
, boolean enabled
) {
947 if (ctrl
instanceof Composite
) {
948 Composite comp
= (Composite
) ctrl
;
949 for (Control c
: comp
.getChildren()) {
950 recursiveSetEnabled(c
, enabled
);
953 ctrl
.setEnabled(enabled
);
959 * getSortRanksNaturally
964 public static boolean getSortNodesNaturally() {
965 return getPreferenceStore().getBoolean(SORT_NODES_NATURALLY
);
970 * setSortRanksNaturally
976 public static void setSortNodesNaturally(boolean selection
) {
977 getPreferenceStore().setValue(SORT_NODES_NATURALLY
, selection
);
983 * getSortRanksNaturally
988 public static boolean getSortNodesStrictlyAlphabetically() {
989 return getPreferenceStore().getBoolean(SORT_NODES_ALPHABETICALLY
);
994 * setSortRanksNaturally
1000 public static void setSortNodesStrictlyAlphabetically(boolean selection
) {
1001 getPreferenceStore().setValue(SORT_NODES_ALPHABETICALLY
, selection
);
1006 * setStoreNavigatorState
1012 public static boolean isStoreNavigatorState() {
1013 return getPreferenceStore().getBoolean(RESTORE_NAVIGATOR_STATE
);
1019 * setStoreNavigatorState
1025 public static void setStoreNavigatorState(boolean selection
) {
1026 getPreferenceStore().setValue(RESTORE_NAVIGATOR_STATE
, selection
);
1033 public static boolean isShowUpWidgetIsDisposedMessages() {
1034 return getPreferenceStore().getBoolean(IS_SHOW_UP_WIDGET_IS_DISPOSED
);
1036 public static void setShowUpWidgetIsDisposedMessages(boolean selection
) {
1037 getPreferenceStore().setValue(IS_SHOW_UP_WIDGET_IS_DISPOSED
, selection
);
1043 public static boolean isShowIdInVocabularyInChecklistEditor() {
1044 return getPreferenceStore().getBoolean(IPreferenceKeys
.CHECKLIST_ID_IN_VOCABULARY
);
1046 public static void setShowIdInVocabularyInChecklistEditor(boolean selection
) {
1047 getPreferenceStore().setValue(CHECKLIST_ID_IN_VOCABULARY
, selection
);
1053 public static boolean isShowSymbolInChecklistEditor() {
1054 return getPreferenceStore().getBoolean(IPreferenceKeys
.CHECKLIST_SYMBOL
);
1056 public static void setShowSymbolInChecklistEditor(boolean selection
) {
1057 getPreferenceStore().setValue(CHECKLIST_SYMBOL
, selection
);
1063 public static boolean isShowRankInChecklistEditor() {
1064 return getPreferenceStore().getBoolean(IPreferenceKeys
.CHECKLIST_SHOW_RANK
);
1066 public static void setShowRankInChecklistEditor(boolean selection
) {
1067 getPreferenceStore().setValue(CHECKLIST_SHOW_RANK
, selection
);
1075 public static NameDetailsConfigurator
setPreferredNameDetailsConfiguration( boolean local
) {
1076 NameDetailsConfigurator config
= new NameDetailsConfigurator(true);
1078 CdmPreference preference
= null;
1081 preference
= getPreferenceFromDB(PreferencePredicate
.NameDetailsView
);
1082 if (preference
== null){
1086 getPreferenceStore().setValue(ALLOW_OVERRIDE_NAME_DETAILS
, preference
.isAllowOverride());
1088 //the preference value is build like this:
1089 //<section1>:true;<section2>:false....
1091 String value
= preference
.getValue();
1092 String
[] sections
= value
.split(";");
1093 Map
<String
, Boolean
> sectionMap
= new HashMap
<String
, Boolean
>();
1094 String
[] sectionValues
;
1095 for (String sectionValue
: sections
){
1096 sectionValues
= sectionValue
.split(":");
1097 sectionMap
.put(sectionValues
[0], Boolean
.valueOf(sectionValues
[1]));
1099 config
.setAllowOverride(preference
.isAllowOverride());
1100 config
.setSimpleDetailsViewActivated(getValue(sectionMap
, "simpleViewActivated"));
1102 // getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON,
1103 // (getValue(sectionMap, "taxon")));
1104 config
.setTaxonSectionActivated(getValue(sectionMap
, "taxon"));
1106 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID,
1107 // (getValue(sectionMap, "lsid")));
1108 config
.setLSIDActivated(getValue(sectionMap
, "lsid"));
1110 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
1111 // (getValue(sectionMap, "nc")));
1112 config
.setNomenclaturalCodeActived(getValue(sectionMap
, "nc"));
1114 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
1115 // (getValue(sectionMap, "ap")));
1116 config
.setAppendedPhraseActivated(getValue(sectionMap
, "ap"));
1118 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK,
1119 // (getValue(sectionMap, "rank")));
1120 config
.setRankActivated(getValue(sectionMap
, "rank"));
1123 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
1124 // (getValue(sectionMap, "atomisedEpithets")));
1125 config
.setAtomisedEpithetsActivated(getValue(sectionMap
, "atomisedEpithets"));
1127 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
1128 // (getValue(sectionMap,"author")));
1129 config
.setAuthorshipSectionActivated(getValue(sectionMap
,"author"));
1131 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
1132 // (getValue(sectionMap, "nomRef")));
1133 config
.setNomenclaturalReferenceSectionActivated(sectionMap
.get("nomRef"));
1135 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
1136 // (getValue(sectionMap, "nomStat")));
1137 config
.setNomenclaturalStatusSectionActivated(getValue(sectionMap
, "nomStat"));
1140 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
1141 // (getValue(sectionMap,"protologue")));
1142 config
.setProtologueActivated(getValue(sectionMap
,"protologue"));
1144 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
1145 // (getValue(sectionMap,"typeDes")));
1146 config
.setTypeDesignationSectionActivated(getValue(sectionMap
,"typeDes"));
1148 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
1149 // (getValue(sectionMap,"nameRelation")));
1150 config
.setNameRelationsSectionActivated(getValue(sectionMap
,"nameRelation"));
1152 // getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_HYBRID,
1153 // (getValue(sectionMap, "hybrid")));
1154 config
.setHybridActivated(getValue(sectionMap
,"hybrid"));
1156 config
.setSimpleDetailsViewActivated(getPreferenceStore().getBoolean(SHOW_SIMPLE_NAME_DETAILS_SECTION
));
1157 config
.setTaxonSectionActivated(getPreferenceStore().getBoolean(SHOW_SIMPLE_NAME_DETAILS_TAXON
));
1158 config
.setLSIDActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_LSID
));
1159 config
.setNomenclaturalCodeActived(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
));
1160 config
.setAppendedPhraseActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE
));
1161 config
.setRankActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_RANK
));
1162 config
.setAtomisedEpithetsActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
));
1163 config
.setAuthorshipSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
));
1164 config
.setNomenclaturalReferenceSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
));
1165 config
.setNomenclaturalStatusSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
));
1166 config
.setProtologueActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
));
1167 config
.setTypeDesignationSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
));
1168 config
.setNameRelationsSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
));
1169 config
.setHybridActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_HYBRID
));
1174 private static Boolean
getValue(Map
<String
, Boolean
> sectionMap
, String string
) {
1175 if (sectionMap
.containsKey(string
)){
1176 return sectionMap
.get(string
);
1187 * setAbcdConfigurator
1190 * @param preferredConfiguration
1191 * a {@link eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator}
1194 public static Abcd206ImportConfigurator
getAbcdImportConfigurationPreference(boolean useLocal
) {
1196 Abcd206ImportConfigurator config
= Abcd206ImportConfigurator
.NewInstance(null,null);
1199 config
.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS
));
1201 config
.setAddMediaAsMediaSpecimen(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN
));
1203 config
.setAllowReuseOtherClassifications(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS
));
1204 config
.setDeduplicateClassifications(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS
));
1205 config
.setDeduplicateReferences(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES
));
1207 config
.setGetSiblings(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS
));
1208 config
.setIgnoreAuthorship(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP
));
1209 config
.setIgnoreImportOfExistingSpecimen(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN
));
1210 config
.setMapUnitIdToAccessionNumber(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER
));
1211 config
.setMapUnitIdToBarcode(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE
));
1212 config
.setMapUnitIdToCatalogNumber(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER
));
1213 config
.setMoveNewTaxaToDefaultClassification(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION
));
1214 config
.setOverwriteExistingSpecimens(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN
));
1215 config
.setReuseExistingDescriptiveGroups(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS
));
1216 config
.setReuseExistingMetaData(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA
));
1217 config
.setReuseExistingTaxaWhenPossible(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE
));
1218 config
.setNomenclaturalCode(NomenclaturalCode
.getByKey(PreferencesUtil
.getPreferenceStore().getString(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE
)));
1222 ICdmRepository controller
;
1223 controller
= CdmStore
.getCurrentApplicationConfiguration();
1224 PrefKey key
= CdmPreference
.NewKey(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.AbcdImportConfig
);
1225 CdmPreference preference
= null;
1226 if (controller
== null){
1229 preference
= controller
.getPreferenceService().find(key
);
1230 if (preference
== null){
1233 String configString
= preference
.getValue();
1234 String
[] configArray
= configString
.split(";");
1236 for (String configItem
: configArray
){
1237 String
[] keyValue
= configItem
.split(":");
1238 String keyString
= keyValue
[0];
1239 String valueString
= keyValue
[1];
1240 if (keyString
.equals("ignoreImportOfExistingSpecimen")){
1241 config
.setIgnoreImportOfExistingSpecimen(Boolean
.valueOf(valueString
));
1242 }else if (keyString
.equals("addIndividualsAssociationsSuchAsSpecimenAndObservations")){
1243 config
.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(Boolean
.valueOf(valueString
));
1244 }else if (keyString
.equals("reuseExistingTaxaWhenPossible")){
1245 config
.setReuseExistingTaxaWhenPossible(Boolean
.valueOf(valueString
));
1246 }else if (keyString
.equals("ignoreAuthorship")){
1247 config
.setIgnoreAuthorship(Boolean
.valueOf(valueString
));
1248 }else if (keyString
.equals("addMediaAsMediaSpecimen")){
1249 config
.setAddMediaAsMediaSpecimen(Boolean
.valueOf(valueString
));
1250 }else if (keyString
.equals("reuseExistingMetaData")){
1251 config
.setReuseExistingMetaData(Boolean
.valueOf(valueString
));
1252 }else if (keyString
.equals("reuseExistingDescriptiveGroups")){
1253 config
.setReuseExistingDescriptiveGroups(Boolean
.valueOf(valueString
));
1254 }else if (keyString
.equals("allowReuseOtherClassifications")){
1255 config
.setAllowReuseOtherClassifications(Boolean
.valueOf(valueString
));
1256 }else if (keyString
.equals("deduplicateReferences")){
1257 config
.setDeduplicateReferences(Boolean
.valueOf(valueString
));
1258 }else if (keyString
.equals("deduplicateClassifications")){
1259 config
.setDeduplicateClassifications(Boolean
.valueOf(valueString
));
1260 }else if (keyString
.equals("moveNewTaxaToDefaultClassification")){
1261 config
.setMoveNewTaxaToDefaultClassification(Boolean
.valueOf(valueString
));
1262 }else if (keyString
.equals("mapUnitIdToCatalogNumber")){
1263 config
.setMapUnitIdToCatalogNumber(Boolean
.valueOf(valueString
));
1264 }else if (keyString
.equals("mapUnitIdToAccessionNumber")){
1265 config
.setMapUnitIdToAccessionNumber(Boolean
.valueOf(valueString
));
1266 }else if (keyString
.equals("mapUnitIdToBarcode")){
1267 config
.setMapUnitIdToBarcode(Boolean
.valueOf(valueString
));
1268 }else if (keyString
.equals("overwriteExistingSpecimens")){
1269 config
.setOverwriteExistingSpecimens(Boolean
.valueOf(valueString
));
1270 }else if (keyString
.equals("nomenclaturalCode")){
1271 config
.setNomenclaturalCode(NomenclaturalCode
.fromString(valueString
));
1273 logger
.debug("This key of the abcd configurator needs to be added to the transformer: " + keyString
);
1287 public NameDetailsConfigurator
createLocalNameDetailsViewConfig(boolean local
) {
1288 NameDetailsConfigurator config
= new NameDetailsConfigurator(true);
1290 config
.setSimpleDetailsViewActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_SIMPLE_NAME_DETAILS_SECTION
));
1291 config
.setAppendedPhraseActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE
));
1292 config
.setAtomisedEpithetsActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
));
1293 config
.setAuthorshipSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
));
1294 config
.setLSIDActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_LSID
));
1295 config
.setNameApprobiationActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION
));
1296 config
.setNameCacheActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_CACHE
));
1297 config
.setNameRelationsSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
));
1298 config
.setNomenclaturalCodeActived(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
));
1299 config
.setNomenclaturalStatusSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
));
1300 config
.setNomenclaturalReferenceSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
));
1301 config
.setProtologueActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
));
1302 config
.setRankActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_RANK
));
1303 config
.setTaxonSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_SIMPLE_NAME_DETAILS_TAXON
));
1304 config
.setTypeDesignationSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
));
1305 config
.setHybridActivated(getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_HYBRID
));
1314 public static void saveConfigToPrefernceStore(NameDetailsConfigurator config
) {
1315 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_SIMPLE_NAME_DETAILS_SECTION
,
1316 config
.isSimpleDetailsViewActivated());
1317 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_SIMPLE_NAME_DETAILS_TAXON
, config
.isTaxonSectionActivated());
1318 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_LSID
, config
.isLSIDActivated());
1319 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE
,
1320 config
.isNomenclaturalCodeActived());
1321 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NAMECACHE
,
1322 config
.isNameCacheActivated());
1323 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE
,
1324 config
.isAppendedPhraseActivated());
1325 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_RANK
, config
.isRankActivated());
1326 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS
,
1327 config
.isAtomisedEpithetsActivated());
1328 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE
,
1329 config
.isAuthorCacheActivated());
1330 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP
,
1331 config
.isAuthorshipSectionActivated());
1332 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE
,
1333 config
.isNomenclaturalReferenceSectionActivated());
1334 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS
,
1335 config
.isNomenclaturalStatusSectionActivated());
1336 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE
,
1337 config
.isProtologueActivated());
1338 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION
,
1339 config
.isTypeDesignationSectionActivated());
1340 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP
,
1341 config
.isNameRelationsSectionActivated());
1342 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_NAME_DETAILS_SECTION_HYBRID
,
1343 config
.isHybridActivated());
1350 public static boolean isSortTaxaByRankAndName() {
1352 return getPreferenceStore().getBoolean(IPreferenceKeys
.SORT_TAXA_BY_RANK_AND_NAME
);
1358 public static boolean isSortNamedAreaByOrderInVocabulary() {
1360 return getPreferenceStore().getBoolean(IPreferenceKeys
.SORT_NAMED_AREA_BY_VOCABULARY_ORDER
);
1363 public static void setSortNamedAreasByOrderInVocabulary(boolean isSortByVocabularyOrder
) {
1364 getPreferenceStore().setValue(IPreferenceKeys
.SORT_NAMED_AREA_BY_VOCABULARY_ORDER
, isSortByVocabularyOrder
);
1370 * setPreferredNamedAreasForDistributionEditor
1373 * @param saveCheckedElements
1374 * @param saveGrayedElements
1376 public static void setLastSelectedReference(
1377 List
<String
> lastSelectedReferences
) {
1379 IPreferenceStore preferenceStore
= PreferencesUtil
.getPreferenceStore();
1380 preferenceStore
.setValue(PreferencesUtil
.LAST_SELECTED_REFERENCES
, lastSelectedReferences
.toString());
1385 * setPreferredNamedAreasForDistributionEditor
1388 * @param saveCheckedElements
1389 * @param saveGrayedElements
1391 public static List
<String
> getLastSelectedReferences() {
1393 IPreferenceStore preferenceStore
= PreferencesUtil
.getPreferenceStore();
1394 String lastSelected
= preferenceStore
.getString(PreferencesUtil
.LAST_SELECTED_REFERENCES
);
1395 List
<String
> result
= new ArrayList
<>();
1396 if (!StringUtils
.isBlank(lastSelected
)){
1397 Collections
.addAll(result
, lastSelected
.substring(1,lastSelected
.length()-1).split(", "));
1405 * setPreferredNamedAreasForDistributionEditor
1408 * @param saveCheckedElements
1409 * @param saveGrayedElements
1411 public static void setPreferredNamedAreasForDistributionEditor(
1412 String saveCheckedElements
, String saveGrayedElements
, boolean local
) {
1414 IPreferenceStore preferenceStore
= PreferencesUtil
.getPreferenceStore();
1415 preferenceStore
.setValue(PreferencesUtil
.DISTRIBUTION_AREA_OCCURENCE_STATUS
, saveCheckedElements
);
1416 preferenceStore
.setValue(PreferencesUtil
.DISTRIBUTION_AREA_OCCURENCE_STATUS_GRAYED
, saveGrayedElements
);
1420 // ICdmRepository controller;
1422 // PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaTerms);
1423 CdmPreference preference
= null;
1425 if (saveCheckedElements
== null){
1426 preference
= getPreferenceFromDB(PreferencePredicate
.AvailableDistributionAreaTerms
);
1428 if (preference
== null){
1431 getPreferenceStore().setValue(DISTRIBUTION_AREA_OCCURENCE_STATUS
,
1432 saveCheckedElements
);
1433 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.AvailableDistributionAreaTerms
, saveCheckedElements
);
1434 setPreferenceToDB(preference
);
1438 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.AvailableDistributionAreaTerms
, saveCheckedElements
);
1439 setPreferenceToDB(preference
);
1440 getPreferenceStore().setValue(DISTRIBUTION_AREA_OCCURENCE_STATUS
,
1441 saveCheckedElements
);
1449 * @param saveCheckedElements
1450 * @param saveCheckedElements2
1453 public static void setPreferredVocabulariesForDistributionEditor(String saveCheckedElements
,
1456 IPreferenceStore preferenceStore
= PreferencesUtil
.getPreferenceStore();
1457 preferenceStore
.setValue(PreferencesUtil
.DISTRIBUTION_VOCABULARIES
, saveCheckedElements
);
1462 ICdmRepository controller
;
1463 CdmPreference preference
= null;
1465 if (saveCheckedElements
== null){
1466 preference
= getPreferenceFromDB(PreferencePredicate
.AvailableDistributionAreaVocabularies
);
1468 if (preference
== null){
1471 getPreferenceStore().setValue(DISTRIBUTION_VOCABULARIES
,
1472 saveCheckedElements
);
1473 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.AvailableDistributionAreaVocabularies
, saveCheckedElements
);
1474 setPreferenceToDB(preference
);
1479 preference
= CdmPreference
.NewInstance(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.AvailableDistributionAreaVocabularies
, saveCheckedElements
);
1480 setPreferenceToDB(preference
);
1481 getPreferenceStore().setValue(DISTRIBUTION_AREA_OCCURENCE_STATUS
,
1482 saveCheckedElements
);