Merge branch 'release/4.7.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / preference / PreferencesUtil.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.taxeditor.preference;
11
12 import java.io.File;
13 import java.io.FileInputStream;
14 import java.io.FileOutputStream;
15 import java.io.IOException;
16 import java.net.URI;
17 import java.net.URISyntaxException;
18 import java.util.ArrayList;
19 import java.util.Arrays;
20 import java.util.HashMap;
21 import java.util.List;
22 import java.util.Map;
23 import java.util.Properties;
24 import java.util.Set;
25 import java.util.StringTokenizer;
26 import java.util.UUID;
27
28 import org.apache.commons.lang.StringUtils;
29 import org.apache.log4j.Logger;
30 import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement;
31 import org.eclipse.jface.preference.IPreferenceStore;
32 import org.eclipse.jface.window.Window;
33 import org.eclipse.swt.widgets.Composite;
34 import org.eclipse.swt.widgets.Control;
35 import org.eclipse.swt.widgets.Shell;
36 import org.eclipse.ui.PlatformUI;
37
38 import eu.etaxonomy.cdm.api.application.ICdmRepository;
39 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeConfigurator;
40 import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
41 import eu.etaxonomy.cdm.api.service.ITermService;
42 import eu.etaxonomy.cdm.api.service.config.FindTaxaAndNamesConfiguratorImpl;
43 import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator;
44 import eu.etaxonomy.cdm.common.CdmUtils;
45 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
46 import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
47 import eu.etaxonomy.cdm.model.common.ICdmBase;
48 import eu.etaxonomy.cdm.model.common.IDefinedTerm;
49 import eu.etaxonomy.cdm.model.common.ISimpleTerm;
50 import eu.etaxonomy.cdm.model.common.Language;
51 import eu.etaxonomy.cdm.model.common.MarkerType;
52 import eu.etaxonomy.cdm.model.common.TermBase;
53 import eu.etaxonomy.cdm.model.description.FeatureTree;
54 import eu.etaxonomy.cdm.model.metadata.CdmPreference;
55 import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
56 import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
57 import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
58 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
59 import eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy;
60 import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
61 import eu.etaxonomy.cdm.strategy.match.MatchException;
62 import eu.etaxonomy.cdm.strategy.match.MatchMode;
63 import eu.etaxonomy.taxeditor.model.AbstractUtility;
64 import eu.etaxonomy.taxeditor.model.MessagingUtils;
65 import eu.etaxonomy.taxeditor.model.NomenclaturalCodeHelper;
66 import eu.etaxonomy.taxeditor.store.CdmStore;
67 import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
68 import eu.etaxonomy.taxeditor.ui.dialog.DefaultLanguageDialog;
69
70 /**
71 * <p>
72 * PreferencesUtil class.
73 * </p>
74 *
75 * @author p.ciardelli
76 * @author n.hoffmann
77 * @created 05.12.2008
78 * @version 1.0
79 */
80 public class PreferencesUtil implements IPreferenceKeys {
81
82 /**
83 *
84 */
85 public static final String PREFERRED_TERMS_CHANGE = "preferred_terms";
86
87 public static final String P2_REPOSITORIES_DELIM = ",";
88 public static final String P2_REPOSITORY_FIELDS_DELIM = ";";
89
90 private final static Logger logger = Logger.getLogger(PreferencesUtil.class);
91
92 /**
93 * <p>
94 * getPreferenceStore
95 * </p>
96 *
97 * @return a {@link org.eclipse.jface.preference.IPreferenceStore} object.
98 */
99 public static IPreferenceStore getPreferenceStore() {
100 return TaxeditorStorePlugin.getDefault().getPreferenceStore();
101 }
102
103 /**
104 * <p>
105 * setPreferredNomenclaturalCode
106 * </p>
107 *
108 * @param preferredCode
109 * a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
110 * object.
111 */
112 public static CdmPreference setPreferredNomenclaturalCode(
113 NomenclaturalCode preferredCode, boolean local) {
114 if (local){
115 getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
116 getPreferenceKey(preferredCode));
117 }
118 else{
119 ICdmRepository controller;
120 controller = CdmStore.getCurrentApplicationConfiguration();
121 PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
122 CdmPreference preference = null;
123 if (controller == null){
124 return null;
125 }
126 if (preferredCode == null){
127 preference = controller.getPreferenceService().find(key);
128 if (preference == null){
129 return null;
130 } else{
131 int index = StringUtils.lastIndexOf(preference.getValue(), ".");
132 UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
133 preferredCode = NomenclaturalCode.getByUuid(uuid);
134
135 getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY,
136 getPreferenceKey(preferredCode));
137 getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY,preference.isAllowOverride());
138 return preference;
139 }
140 } else{
141 preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode, preferredCode.getKey());
142 controller.getPreferenceService().set(preference);
143
144 }
145 }
146 return null;
147
148
149
150 }
151
152 public static NomenclaturalCode getPreferredNomenclaturalCode(){
153 if (getPreferenceStore().getBoolean(OVERRIDE_NOMENCLATURAL_CODE_KEY)) {
154 return getPreferredNomenclaturalCode(true);
155 } else{
156 return getPreferredNomenclaturalCode(false);
157 }
158 }
159
160 /**
161 * <p>
162 * getPreferredNomenclaturalCode
163 * </p>
164 *
165 * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
166 */
167 public static NomenclaturalCode getPreferredNomenclaturalCode(boolean useLocal) {
168
169 CdmPreference pref = null;
170 if (!useLocal){
171 pref = getPreferenceFromDB(PreferencePredicate.NomenclaturalCode);
172 }
173
174 String preferredCode;
175 if(pref == null){
176 preferredCode = getPreferenceStore().getString(
177 PREFERRED_NOMENCLATURAL_CODE_KEY);
178
179 }else{
180 preferredCode = pref.getValue();
181 }
182
183 for (NomenclaturalCode code : NomenclaturalCodeHelper.getAllCodes()) {
184 if (getPreferenceKey(code).equals(preferredCode)) {
185 return code;
186 }
187 }
188 return null;
189 }
190
191
192 private static CdmPreference getPreferenceFromDB(PreferencePredicate predicate){
193 ICdmRepository controller;
194 CdmPreference pref = null;
195
196 try{
197 controller = CdmStore.getCurrentApplicationConfiguration();
198 PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), predicate);
199 pref = controller.getPreferenceService().find(key);
200 }catch(Exception e){
201 e.printStackTrace();
202 }
203
204 return pref;
205
206 }
207
208
209 public static String getPreferredDefaultLangugae(){
210 String preferredLanguage = getPreferenceStore().getString(DEFAULT_LANGUAGE_EDITOR);
211 if(StringUtils.isNotEmpty(preferredLanguage) && StringUtils.isNotBlank(preferredLanguage)){
212 return preferredLanguage;
213 }
214 return null;
215 }
216
217 /**
218 * Get the match strategy for the given class that was stored in preferences
219 * or the default strategy if it was not stored in preferences
220 *
221 * @param clazz
222 * a {@link java.lang.Class} object.
223 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
224 */
225 public static IMatchStrategy getMatchStrategy(Class clazz) {
226 String className = clazz.getName();
227 if (getPreferenceStore().getBoolean(MATCH_STRATEGY_PREFIX + className)) {
228 IMatchStrategy matchStrategy = getDefaultMatchStrategy(clazz);
229
230 for (String fieldName : matchStrategy.getMatchFieldPropertyNames()) {
231 String matchModeName = getPreferenceStore().getString(
232 getMatchStrategyFieldName(className, fieldName));
233 MatchMode matchMode = MatchMode.valueOf(matchModeName);
234 try {
235 matchStrategy.setMatchMode(fieldName, matchMode);
236 } catch (MatchException e) {
237 MessagingUtils.error(PreferencesUtil.class, e);
238 throw new RuntimeException(e);
239 }
240 }
241
242 return matchStrategy;
243 }
244 return getDefaultMatchStrategy(clazz);
245 }
246
247 /**
248 * Stores a matchStrategy into the preference store.
249 *
250 * @param matchStrategy
251 * a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy}
252 * object.
253 */
254 public static void setMatchStrategy(IMatchStrategy matchStrategy) {
255 String className = matchStrategy.getMatchClass().getName();
256 getPreferenceStore().setValue(MATCH_STRATEGY_PREFIX + className, true);
257
258 Set<String> matchFields = matchStrategy.getMatchFieldPropertyNames();
259
260 for (String fieldName : matchFields) {
261 getPreferenceStore().setValue(
262 getMatchStrategyFieldName(className, fieldName),
263 matchStrategy.getMatchMode(fieldName).name());
264 }
265 }
266
267 /**
268 * Helper method to create the preference property for a match field.
269 *
270 * @param className
271 * @param fieldName
272 * @return
273 */
274 private static String getMatchStrategyFieldName(String className,
275 String fieldName) {
276 return MATCH_STRATEGY_PREFIX + className + "." + fieldName;
277 }
278
279 /**
280 * Returns the default match strategy for a given class.
281 *
282 * @param clazz
283 * a {@link java.lang.Class} object.
284 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
285 */
286 public static IMatchStrategy getDefaultMatchStrategy(Class clazz) {
287 return DefaultMatchStrategy.NewInstance(clazz);
288 }
289
290 /**
291 * <p>
292 * getDateFormatPattern
293 * </p>
294 *
295 * @return a {@link java.lang.String} object.
296 */
297 public static String getDateFormatPattern() {
298 // TODO make this configurable in properties
299 String pattern = "Y-M-d H:m";
300 return pattern;
301 }
302
303 /**
304 * <p>
305 * addTermToPreferredTerms
306 * </p>
307 *
308 * @param term
309 * a T object.
310 * @param <T>
311 * a T object.
312 */
313 public static <T extends TermBase> void addTermToPreferredTerms(T term) {
314
315 // VocabularyEnum vocabulary =
316 // VocabularyEnum.getVocabularyEnum(term.getClass());
317 //
318 // getPreferenceStore().setValue(getPreferenceKey(term),
319 // VocabularyStore.getTermVocabulary(vocabulary).getTerms().contains(term));
320 //
321 // firePreferencesChanged(term.getClass());
322 }
323
324 /**
325 * Construct a unique key using the CdmBase object's uuid
326 *
327 * @param cdmBase
328 * @return
329 */
330 private static String getPreferenceKey(ICdmBase cdmBase) {
331 cdmBase = HibernateProxyHelper.deproxy(cdmBase);
332
333 String key = cdmBase.getClass().getName().concat(".")
334 .concat(cdmBase.getUuid().toString());
335 if (key.contains("javassist")) {
336 MessagingUtils.info("proxy");
337 }
338 return key;
339 }
340
341 /**
342 * Construct a unique key using the CdmBase object's uuid
343 *
344 * @param cdmBase
345 * @return
346 */
347 public static String getPreferenceKey(ISimpleTerm simpleTerm) {
348 simpleTerm = HibernateProxyHelper.deproxy(simpleTerm);
349 String key = simpleTerm.getClass().getName().concat(".")
350 .concat(simpleTerm.getUuid().toString());
351 if (key.contains("javassist")) {
352 MessagingUtils.warn(PreferencesUtil.class,
353 "Trying to persist a preference based on a proxy class.");
354 }
355 return key;
356 }
357
358
359
360 /**
361 * Construct a unique key using the CdmBase object's uuid
362 *
363 * @param cdmBase
364 * @return
365 */
366 public static String getPreferenceKey(IDefinedTerm definedTerm) {
367 definedTerm = HibernateProxyHelper.deproxy(definedTerm);
368 String key = definedTerm.getClass().getName().concat(".")
369 .concat(definedTerm.getUuid().toString());
370 if (key.contains("javassist")) {
371 MessagingUtils.warn(PreferencesUtil.class,
372 "Trying to persist a preference based on a proxy class.");
373 }
374 return key;
375 }
376
377 /**
378 * Retrieves search preferences from the preference store
379 *
380 * @return an {@link ITaxonServiceConfigurator} to pass to search methods
381 */
382 public static IFindTaxaAndNamesConfigurator getSearchConfigurator() {
383 IFindTaxaAndNamesConfigurator configurator = initializeSearchConfigurator();
384
385 configurator.setDoTaxa(getPreferenceStore().getBoolean(
386 TAXON_SERVICE_CONFIGURATOR_TAXA));
387 configurator.setDoSynonyms(getPreferenceStore().getBoolean(
388 TAXON_SERVICE_CONFIGURATOR_SYNONYMS));
389 configurator.setDoNamesWithoutTaxa(getPreferenceStore().getBoolean(
390 TAXON_SERVICE_CONFIGURATOR_NAMES));
391 configurator.setDoTaxaByCommonNames(getPreferenceStore().getBoolean(
392 TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES));
393 //configurator.setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.valueOf(getPreferenceStore().getString(TAXON_SERVICE_CONFIGURATOR_MATCH_MODE)));
394
395 return configurator;
396 }
397
398 /**
399 * create new preferences, setting all search options to true
400 *
401 * @return a
402 * {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
403 * object.
404 */
405 public static IFindTaxaAndNamesConfigurator initializeSearchConfigurator() {
406 IFindTaxaAndNamesConfigurator configurator = new FindTaxaAndNamesConfiguratorImpl();
407
408 configurator.setDoTaxa(true);
409 configurator.setDoSynonyms(true);
410 configurator.setDoNamesWithoutTaxa(true);
411 configurator.setDoTaxaByCommonNames(true);
412
413 configurator.setTaxonPropertyPath(Arrays.asList("$", "titleCache",
414 "name", "name.$", "relationsFromThisTaxon.$"));
415
416 configurator.setSynonymPropertyPath(Arrays.asList("$", "titleCache",
417 "name", "name.$", "synonymRelations.relatedTo.*"));
418
419 // DEFAULT VALUES
420 // match mode is a simple like, actually all other match modes are kind
421 // of bogus
422 configurator
423 .setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.ANYWHERE);
424 // we set page number and size here as this should always be unlimited
425 configurator.setPageNumber(0);
426 // TODO currently limit results to 10000
427 configurator.setPageSize(10000);
428
429 return configurator;
430 }
431
432 /**
433 * Store search preferences
434 *
435 * @param configurator
436 * a
437 * {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
438 * object.
439 */
440 public static void setSearchConfigurator(
441 IFindTaxaAndNamesConfigurator configurator) {
442 getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_TAXA,
443 configurator.isDoTaxa());
444 getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_SYNONYMS,
445 configurator.isDoSynonyms());
446 getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_NAMES,
447 configurator.isDoNamesWithoutTaxa());
448 getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES,
449 configurator.isDoTaxaByCommonNames());
450 }
451
452 /**
453 * <p>
454 * firePreferencesChanged
455 * </p>
456 *
457 * @param clazz
458 * a {@link java.lang.Class} object.
459 */
460 public static void firePreferencesChanged(Class clazz) {
461 getPreferenceStore().firePropertyChangeEvent(PREFERRED_TERMS_CHANGE,
462 null, clazz);
463 }
464
465 /**
466 * Set default values for preferences
467 */
468 public static void setDefaults() {
469 getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_TAXA, true);
470 getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_SYNONYMS,
471 true);
472 getPreferenceStore().setDefault(EDIT_MAP_SERVICE_ACCES_POINT,
473 "http://edit.africamuseum.be/edit_wp5/v1.2/rest_gen.php");
474 //FIXME : changed default for SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
475 getPreferenceStore().setDefault(SHOULD_CONNECT_AT_STARTUP, false);
476 getPreferenceStore().setDefault(OPENURL_ACCESS_POINT,
477 "http://www.biodiversitylibrary.org/openurl");
478 getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_WIDTH, "1000");
479 getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_HEIGHT, "1000");
480 getPreferenceStore().setDefault(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE, false);
481 getPreferenceStore().setDefault(CHECKLIST_ID_IN_VOCABULARY, true);
482 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, true);
483 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE, true);
484 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, true);
485 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_HYBRID, true);
486 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_LSID, true);
487 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, true);
488 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NAMECACHE, true);
489 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, true);
490 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, true);
491 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, true);
492 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, true);
493 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_RANK, true);
494 getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, true);
495 getPreferenceStore().setDefault(SORT_NODES_NATURALLY, false);
496 getPreferenceStore().setDefault(SORT_NODES_ALPHABETICALLY, false);
497
498 }
499
500 /**
501 * <p>
502 * checkNomenclaturalCode
503 * </p>
504 */
505 public static void checkNomenclaturalCode() {
506 // First time Editor is opened, no nomenclatural code has been set
507
508
509 if (PreferencesUtil.getPreferredNomenclaturalCode(true) == null) {
510 PreferencesUtil.setPreferredNomenclaturalCode(NomenclaturalCode.ICNAFP, true);
511 }
512
513
514
515 }
516 public static void setNomenclaturalCodePreferences(){
517 ICdmRepository controller;
518 controller = CdmStore.getCurrentApplicationConfiguration();
519 PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
520 CdmPreference preference = null;
521 if (controller == null){
522 return ;
523 }
524 preference = controller.getPreferenceService().find(key);
525 if (preference == null){
526 return;
527 }
528 getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY, preference.isAllowOverride());
529
530 int index = StringUtils.lastIndexOf(preference.getValue(), ".");
531 UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
532 NomenclaturalCode preferredCode = NomenclaturalCode.getByUuid(uuid);
533
534 getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY,
535 getPreferenceKey(preferredCode));
536
537 if (!preference.isAllowOverride()){
538 getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
539 getPreferenceKey(preferredCode));
540 }
541 }
542
543 public static void checkDefaultLanguage(){
544 if(PreferencesUtil.getPreferredDefaultLangugae() == null){
545 Shell shell = AbstractUtility.getShell();
546 int open = new DefaultLanguageDialog(shell).open();
547 if(open == Window.OK){
548 PlatformUI.getWorkbench().restart();
549 }
550 }else{
551 //TODO:In case of a reinstall, the config.ini will be overwritten
552 // here you create config.ini with the stored key from preferences
553 }
554 }
555
556 /**
557 * <p>
558 * getMapServiceAccessPoint
559 * </p>
560 *
561 * @return a {@link java.lang.String} object.
562 */
563 public static String getMapServiceAccessPoint() {
564 return getPreferenceStore().getString(EDIT_MAP_SERVICE_ACCES_POINT);
565 }
566
567 /**
568 * <p>
569 * shouldConnectAtStartUp
570 * </p>
571 *
572 * @return a boolean.
573 */
574 public static boolean shouldConnectAtStartUp() {
575 //FIXME : force SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
576 //return getPreferenceStore().getBoolean(SHOULD_CONNECT_AT_STARTUP);
577 return false;
578 }
579
580 /**
581 * <p>
582 * getDefaultFeatureTreeForTextualDescription
583 * </p>
584 *
585 * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
586 */
587 public static FeatureTree getDefaultFeatureTreeForTextualDescription() {
588 String uuidString = getPreferenceStore().getString(
589 FEATURE_TREE_DEFAULT_TEXT);
590 return CdmUtils.isEmpty(uuidString) ? null : CdmStore.getService(
591 IFeatureTreeService.class).load(UUID.fromString(uuidString));
592 }
593
594 /**
595 * <p>
596 * getDefaultFeatureTreeForStructuredDescription
597 * </p>
598 *
599 * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
600 */
601 public static FeatureTree getDefaultFeatureTreeForStructuredDescription() {
602 String uuidString = getPreferenceStore().getString(
603 FEATURE_TREE_DEFAULT_STRUCTURE);
604 return CdmUtils.isEmpty(uuidString) ? null : CdmStore.getService(
605 IFeatureTreeService.class).load(UUID.fromString(uuidString));
606 }
607
608 /**
609 * <p>
610 * setSortRanksHierarchichally
611 * </p>
612 *
613 * @param selection
614 * a boolean.
615 */
616 public static void setSortRanksHierarchichally(boolean selection) {
617 getPreferenceStore().setValue(SORT_RANKS_HIERARCHICHALLY, selection);
618 }
619
620 /**
621 * <p>
622 * getSortRanksHierarchichally
623 * </p>
624 *
625 * @return a boolean.
626 */
627 public static boolean getSortRanksHierarchichally() {
628 return getPreferenceStore().getBoolean(SORT_RANKS_HIERARCHICHALLY);
629 }
630
631 public static boolean isMultilanguageTextEditingCapability() {
632 return getPreferenceStore().getBoolean(
633 MULTILANGUAGE_TEXT_EDITING_CAPABILITY);
634 }
635
636 public static Language getGlobalLanguage() {
637
638
639 String languageUuidString = getPreferenceStore().getString(
640 GLOBAL_LANGUAGE_UUID);
641
642 if(!CdmStore.isActive()) {
643 MessagingUtils.noDataSourceWarningDialog(languageUuidString);
644 return null;
645 }
646
647 if (CdmUtils.isBlank(languageUuidString)) {
648 return Language.getDefaultLanguage();
649 }
650
651 UUID languageUuid = UUID.fromString(languageUuidString);
652 return (Language) CdmStore.getService(ITermService.class).load(
653 languageUuid);
654 }
655
656 public static void setGlobalLanguage(Language language) {
657 if(language != null) {
658 getPreferenceStore().setValue(GLOBAL_LANGUAGE_UUID,language.getUuid().toString());
659 CdmStore.setDefaultLanguage(language);
660 }
661
662 }
663
664 /**
665 * @return
666 */
667 public static Map<MarkerType, Boolean> getEditMarkerTypePreferences() {
668 List<MarkerType> markerTypes = CdmStore.getTermManager()
669 .getPreferredTerms(MarkerType.class);
670
671 Map<MarkerType, Boolean> result = new HashMap<MarkerType, Boolean>();
672
673 for (MarkerType markerType : markerTypes) {
674 String name = getMarkerTypeEditingPreferenceKey(markerType);
675 Boolean value = getPreferenceStore().getBoolean(name);
676
677 result.put(markerType, value);
678 }
679
680 return result;
681 }
682
683 /**
684 * @param markerTypeEditingMap
685 */
686 public static void setEditMarkerTypePreferences(
687 Map<MarkerType, Boolean> markerTypeEditingMap) {
688 for (MarkerType markerType : markerTypeEditingMap.keySet()) {
689 String name = getMarkerTypeEditingPreferenceKey(markerType);
690 getPreferenceStore().setValue(name,
691 markerTypeEditingMap.get(markerType));
692 }
693
694 }
695
696 private static String getMarkerTypeEditingPreferenceKey(
697 MarkerType markerType) {
698 markerType = HibernateProxyHelper.deproxy(markerType);
699 return markerType.getClass().getName() + EDIT_MARKER_TYPE_PREFIX;
700 }
701
702 /**
703 * <p>
704 * setEditMarkerTypePreference
705 * </p>
706 *
707 * @param input
708 * a {@link org.eclipse.ui.IEditorInput} object.
709 * @param markerType
710 * a {@link eu.etaxonomy.cdm.model.common.MarkerType} object.
711 * @param edit
712 * a boolean.
713 */
714 public static void setEditMarkerTypePreference(MarkerType markerType,
715 boolean edit) {
716 getPreferenceStore().setValue(
717 getMarkerTypeEditingPreferenceKey(markerType), edit);
718 }
719
720 /**
721 * @return
722 */
723 public static DerivedUnitFacadeConfigurator getDerivedUnitConfigurator() {
724 DerivedUnitFacadeConfigurator configurator = DerivedUnitFacadeConfigurator
725 .NewInstance();
726 configurator.setMoveDerivedUnitMediaToGallery(true);
727 configurator.setMoveFieldObjectMediaToGallery(true);
728 return configurator;
729 }
730
731 /**
732 * This method will write language properties to the config.ini located in the configuration folder
733 * of the Taxonomic Ediitor. <b>This method is only used to set the default language for Taxonomic Editor.</b>
734 *
735 * @param setLanguage 0 is for german and 1 for english.
736 * @throws IOException
737 */
738 public void writePropertyToConfigFile(int setLanguage) throws IOException {
739 File file = org.eclipse.core.runtime.preferences.ConfigurationScope.INSTANCE.getLocation().toFile();
740 //give warning to user if the directory has no write access
741 if(file == null){
742 throw new IOException();
743 }
744 Properties properties = load(file.getAbsolutePath()+"/config.ini");
745 switch(setLanguage){
746 case 0:
747 properties.setProperty("osgi.nl", "de");
748 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "de");
749 break;
750 case 1:
751 properties.setProperty("osgi.nl", "en");
752 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "en");
753 break;
754 default:
755 break;
756 }
757 save(file+"/config.ini", properties);
758 }
759
760 /**
761 * This method loads a property from a given file and returns it.
762 *
763 * @param filename
764 * @return
765 * @throws IOException
766 */
767 private Properties load(String filename) throws IOException {
768 FileInputStream in = new FileInputStream(filename);
769 Properties prop = new Properties();
770 prop.load(in);
771 in.close();
772 return prop;
773 }
774
775 /**
776 * This method saves a property to the specified file.
777 *
778 * @param filename
779 * @param properties
780 * @throws IOException
781 */
782 private void save(String filename, Properties properties) throws IOException{
783 FileOutputStream fos = new FileOutputStream(filename);
784 properties.store(fos, "");
785 fos.close();
786 }
787
788 /**
789 * Saves a list of P2 Metadata Repositories as string with specified delimiters
790 *
791 * @param p2Repos
792 */
793 public static void setP2Repositories(List<MetadataRepositoryElement> p2Repos) {
794 StringBuilder sb = new StringBuilder();
795 for(MetadataRepositoryElement p2Repo : p2Repos) {
796 sb.append(P2_REPOSITORIES_DELIM);
797 if(p2Repo.getName() == null || p2Repo.getName().isEmpty()) {
798 sb.append("-");
799 } else {
800 sb.append(p2Repo.getName());
801 }
802 sb.append(P2_REPOSITORY_FIELDS_DELIM);
803 sb.append(p2Repo.getLocation().toString());
804 sb.append(P2_REPOSITORY_FIELDS_DELIM);
805 sb.append(String.valueOf(p2Repo.isEnabled()));
806 }
807 getPreferenceStore().setValue(P2_REPOSITORY_LIST, sb.toString());
808 }
809
810
811 /**
812 * Retrieves a list of previously saved P2 repositories
813 *
814 * @return
815 */
816 public static List<MetadataRepositoryElement> getP2Repositories() {
817 List<MetadataRepositoryElement> p2Repos = new ArrayList<MetadataRepositoryElement>();
818 String p2ReposPref = getPreferenceStore().getString(P2_REPOSITORY_LIST);
819 if(p2ReposPref != null && !p2ReposPref.isEmpty()) {
820 StringTokenizer p2ReposPrefST = new StringTokenizer(p2ReposPref,P2_REPOSITORIES_DELIM);
821
822 while(p2ReposPrefST.hasMoreTokens()) {
823 String p2RepoStr = p2ReposPrefST.nextToken();
824 StringTokenizer p2ReposStrST = new StringTokenizer(p2RepoStr,P2_REPOSITORY_FIELDS_DELIM);
825 if(p2ReposStrST.countTokens()==3) {
826 String nickname = p2ReposStrST.nextToken();
827 URI uri = null;
828 try {
829 uri = new URI(p2ReposStrST.nextToken());
830 } catch (URISyntaxException e) {
831 continue;
832 }
833 boolean enabled = Boolean.parseBoolean(p2ReposStrST.nextToken());
834 MetadataRepositoryElement mre = new MetadataRepositoryElement(null, uri, true);
835 mre.setNickname(nickname);
836 mre.setEnabled(enabled);
837 p2Repos.add(mre);
838 }
839 }
840 }
841
842 return p2Repos;
843 }
844
845 /**
846 * enables/disables nested composite. <br>
847 *
848 * @param ctrl - Composite to be en-/disabeld
849 * @param enabled - boolean
850 */
851 public static void recursiveSetEnabled(Control ctrl, boolean enabled) {
852 if (ctrl instanceof Composite) {
853 Composite comp = (Composite) ctrl;
854 for (Control c : comp.getChildren()) {
855 recursiveSetEnabled(c, enabled);
856 }
857 } else {
858 ctrl.setEnabled(enabled);
859 }
860 }
861
862 /**
863 * <p>
864 * getSortRanksNaturally
865 * </p>
866 *
867 * @return a boolean.
868 */
869 public static boolean getSortNodesNaturally() {
870 return getPreferenceStore().getBoolean(SORT_NODES_NATURALLY);
871 }
872
873 /**
874 * <p>
875 * setSortRanksNaturally
876 * </p>
877 *
878 * @param selection
879 * a boolean.
880 */
881 public static void setSortNodesNaturally(boolean selection) {
882 getPreferenceStore().setValue(SORT_NODES_NATURALLY, selection);
883 }
884
885
886 /**
887 * <p>
888 * getSortRanksNaturally
889 * </p>
890 *
891 * @return a boolean.
892 */
893 public static boolean getSortNodesStrictlyAlphabetically() {
894 return getPreferenceStore().getBoolean(SORT_NODES_ALPHABETICALLY);
895 }
896
897 /**
898 * <p>
899 * setSortRanksNaturally
900 * </p>
901 *
902 * @param selection
903 * a boolean.
904 */
905 public static void setSortNodesStrictlyAlphabetically(boolean selection) {
906 getPreferenceStore().setValue(SORT_NODES_ALPHABETICALLY, selection);
907 }
908
909 /**
910 * <p>
911 * setStoreNavigatorState
912 * </p>
913 *
914 * @param selection
915 * a boolean.
916 */
917 public static boolean isStoreNavigatorState() {
918 return getPreferenceStore().getBoolean(RESTORE_NAVIGATOR_STATE);
919
920 }
921
922 /**
923 * <p>
924 * setStoreNavigatorState
925 * </p>
926 *
927 * @param selection
928 * a boolean.
929 */
930 public static void setStoreNavigatorState(boolean selection) {
931 getPreferenceStore().setValue(RESTORE_NAVIGATOR_STATE, selection);
932
933 }
934
935 /**
936 * @return
937 */
938 public static boolean isShowUpWidgetIsDisposedMessages() {
939 return getPreferenceStore().getBoolean(IS_SHOW_UP_WIDGET_IS_DISPOSED);
940 }
941 public static void setShowUpWidgetIsDisposedMessages(boolean selection) {
942 getPreferenceStore().setValue(IS_SHOW_UP_WIDGET_IS_DISPOSED, selection);
943 }
944
945 /**
946 * @return
947 */
948 public static boolean isShowIdInVocabularyInChecklistEditor() {
949 return getPreferenceStore().getBoolean(IPreferenceKeys.CHECKLIST_ID_IN_VOCABULARY);
950 }
951 public static void setShowIdInVocabularyInChecklistEditor(boolean selection) {
952 getPreferenceStore().setValue(CHECKLIST_ID_IN_VOCABULARY, selection);
953 }
954
955 /**
956 * @return
957 */
958 public static boolean isShowRankInChecklistEditor() {
959 return getPreferenceStore().getBoolean(IPreferenceKeys.CHECKLIST_SHOW_RANK);
960 }
961 public static void setShowRankInChecklistEditor(boolean selection) {
962 getPreferenceStore().setValue(CHECKLIST_SHOW_RANK, selection);
963 }
964
965 /**
966 * @param object
967 * @param b
968 * @return
969 */
970 public static NameDetailsConfigurator setPreferredNameDetailsConfiguration( boolean local) {
971 NameDetailsConfigurator config = new NameDetailsConfigurator(true);
972
973 CdmPreference preference = null;
974
975 if (!local) {
976 preference = getPreferenceFromDB(PreferencePredicate.NameDetailsView);
977 }
978 if (preference == null){
979 return null;
980 }
981
982 getPreferenceStore().setValue(ALLOW_OVERRIDE_NAMEDETAILS, preference.isAllowOverride());
983
984 //the preference value is build like this:
985 //<section1>:true;<section2>:false....
986
987 String value = preference.getValue();
988 String [] sections = value.split(";");
989 Map<String, Boolean> sectionMap = new HashMap<String, Boolean>();
990 String[] sectionValues;
991 for (String sectionValue: sections){
992 sectionValues = sectionValue.split(":");
993 sectionMap.put(sectionValues[0], Boolean.valueOf(sectionValues[1]));
994 }
995
996
997
998 getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON,
999 (sectionMap.get("taxon")));
1000 config.setTaxonSectionActivated(sectionMap.get("taxon"));
1001
1002 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID,
1003 (sectionMap.get("lsid")));
1004 config.setLSIDActivated(sectionMap.get("lsid"));
1005
1006 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
1007 (sectionMap.get("nc")));
1008 config.setNomenclaturalCodeActived(sectionMap.get("nc"));
1009
1010 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
1011 (sectionMap.get("ap")));
1012 config.setAppendedPhraseActivated(sectionMap.get("ap"));
1013
1014 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK,
1015 (sectionMap.get("rank")));
1016 config.setRankActivated(sectionMap.get("rank"));
1017
1018
1019 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
1020 (sectionMap.get("atomisedEpithets")));
1021 config.setAtomisedEpithetsActivated(sectionMap.get("atomisedEpithets"));
1022
1023 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
1024 (sectionMap.get("author")));
1025 config.setAuthorshipSectionActivated(sectionMap.get("author"));
1026
1027 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
1028 (sectionMap.get("nomRef")));
1029 config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
1030
1031 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
1032 (sectionMap.get("nomStat")));
1033 config.setNomenclaturalStatusSectionActivated(sectionMap.get("nomStat"));
1034
1035
1036 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
1037 (sectionMap.get("protologue")));
1038 config.setProtologueActivated(sectionMap.get("protologue"));
1039
1040 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
1041 (sectionMap.get("typeDes")));
1042 config.setTypeDesignationSectionActivated(sectionMap.get("typeDes"));
1043
1044 getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
1045 (sectionMap.get("nameRelation")));
1046 config.setNameRelationsSectionActivated(sectionMap.get("nameRelation"));
1047
1048 return config;
1049 }
1050
1051 public static boolean getIsDeterminiationOnlyForFieldUnit(boolean local){
1052 CdmPreference preference = null;
1053
1054 if (!local) {
1055 preference = getPreferenceFromDB(PreferencePredicate.DeterminationOnlyForFieldUnits);
1056 }
1057 if (preference == null){
1058 return getPreferenceStore().getBoolean(DETERMINATION_ONLY_FOR_FIELD_UNITS);
1059 }
1060 return Boolean.valueOf(preference.getValue());
1061 }
1062
1063 public static boolean getIsShowCollectingAreasInGeneralSection(boolean local){
1064 CdmPreference preference = null;
1065
1066 if (!local) {
1067 preference = getPreferenceFromDB(PreferencePredicate.ShowCollectingAreasInGeneralSection);
1068 }
1069 if (preference == null){
1070 return getPreferenceStore().getBoolean(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION);
1071 }
1072 return Boolean.valueOf(preference.getValue());
1073 }
1074
1075 public static boolean getIsShowTaxonAssociations(boolean local){
1076 CdmPreference preference = null;
1077
1078 if (!local) {
1079 preference = getPreferenceFromDB(PreferencePredicate.ShowTaxonAssociations);
1080 }
1081 if (preference == null){
1082 return getPreferenceStore().getBoolean(SHOW_TAXON_ASSOCIATIONS);
1083 }
1084 return Boolean.valueOf(preference.getValue());
1085 }
1086
1087 // public static boolean getBioCaseProvider(boolean local){
1088 // CdmPreference preference = null;
1089 //
1090 // if (!local) {
1091 // preference = getPreferenceFromDB(PreferencePredicate.BioCaseProvider);
1092 // }
1093 // if (preference == null){
1094 // return getPreferenceStore().getBoolean(SHOW_TAXON_ASSOCIATIONS);
1095 // }
1096 // return Boolean.valueOf(preference.getValue());
1097 // }
1098
1099
1100 /**
1101 * <p>
1102 * setAbcdConfigurator
1103 * </p>
1104 *
1105 * @param preferredConfiguration
1106 * a {@link eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator}
1107 * object.
1108 */
1109 public static Abcd206ImportConfigurator getAbcdImportConfigurationPreference(boolean useLocal) {
1110
1111 Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
1112
1113 if (useLocal){
1114 config.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS));
1115
1116 config.setAddMediaAsMediaSpecimen(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN));
1117
1118 config.setAllowReuseOtherClassifications(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS));
1119 config.setDeduplicateClassifications(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS));
1120 config.setDeduplicateReferences(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES));
1121
1122 config.setGetSiblings(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS));
1123 config.setIgnoreAuthorship(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP));
1124 config.setIgnoreImportOfExistingSpecimen(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN));
1125 config.setMapUnitIdToAccessionNumber(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER));
1126 config.setMapUnitIdToBarcode(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE));
1127 config.setMapUnitIdToCatalogNumber(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER));
1128 config.setMoveNewTaxaToDefaultClassification(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION));
1129 config.setOverwriteExistingSpecimens(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN));
1130 config.setReuseExistingDescriptiveGroups(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS));
1131 config.setReuseExistingMetaData(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA));
1132 config.setReuseExistingTaxaWhenPossible(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE));
1133 return config;
1134
1135 }
1136 ICdmRepository controller;
1137 controller = CdmStore.getCurrentApplicationConfiguration();
1138 PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AbcdImportConfig);
1139 CdmPreference preference = null;
1140 if (controller == null){
1141 return null;
1142 }
1143 preference = controller.getPreferenceService().find(key);
1144 if (preference == null){
1145 return config;
1146 } else{
1147 String configString = preference.getValue();
1148 String[] configArray = configString.split(";");
1149
1150 for (String configItem: configArray){
1151 String[] keyValue = configItem.split(":");
1152 String keyString = keyValue[0];
1153 String valueString = keyValue[1];
1154 if (keyString.equals("ignoreImportOfExistingSpecimen")){
1155 config.setIgnoreImportOfExistingSpecimen(Boolean.valueOf(valueString));
1156 }else if (keyString.equals("addIndividualsAssociationsSuchAsSpecimenAndObservations")){
1157 config.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(Boolean.valueOf(valueString));
1158 }else if (keyString.equals("reuseExistingTaxaWhenPossible")){
1159 config.setReuseExistingTaxaWhenPossible(Boolean.valueOf(valueString));
1160 }else if (keyString.equals("ignoreAuthorship")){
1161 config.setIgnoreAuthorship(Boolean.valueOf(valueString));
1162 }else if (keyString.equals("addMediaAsMediaSpecimen")){
1163 config.setAddMediaAsMediaSpecimen(Boolean.valueOf(valueString));
1164 }else if (keyString.equals("reuseExistingMetaData")){
1165 config.setReuseExistingMetaData(Boolean.valueOf(valueString));
1166 }else if (keyString.equals("reuseExistingDescriptiveGroups")){
1167 config.setReuseExistingDescriptiveGroups(Boolean.valueOf(valueString));
1168 }else if (keyString.equals("allowReuseOtherClassifications")){
1169 config.setAllowReuseOtherClassifications(Boolean.valueOf(valueString));
1170 }else if (keyString.equals("deduplicateReferences")){
1171 config.setDeduplicateReferences(Boolean.valueOf(valueString));
1172 }else if (keyString.equals("deduplicateClassifications")){
1173 config.setDeduplicateClassifications(Boolean.valueOf(valueString));
1174 }else if (keyString.equals("moveNewTaxaToDefaultClassification")){
1175 config.setMoveNewTaxaToDefaultClassification(Boolean.valueOf(valueString));
1176 }else if (keyString.equals("mapUnitIdToCatalogNumber")){
1177 config.setMapUnitIdToCatalogNumber(Boolean.valueOf(valueString));
1178 }else if (keyString.equals("mapUnitIdToAccessionNumber")){
1179 config.setMapUnitIdToAccessionNumber(Boolean.valueOf(valueString));
1180 }else if (keyString.equals("mapUnitIdToBarcode")){
1181 config.setMapUnitIdToBarcode(Boolean.valueOf(valueString));
1182 }else if (keyString.equals("overwriteExistingSpecimens")){
1183 config.setOverwriteExistingSpecimens(Boolean.valueOf(valueString));
1184 }else{
1185 logger.debug("This key of the abcd configurator needs to be added to the transformer: " + keyString);
1186 }
1187
1188 }
1189 }
1190 return config;
1191
1192
1193
1194 }
1195
1196
1197
1198
1199
1200 }