Project

General

Profile

Download (40 KB) Statistics
| Branch: | Tag: | Revision:
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.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement;
30
import org.eclipse.jface.preference.IPreferenceStore;
31
import org.eclipse.jface.window.Window;
32
import org.eclipse.swt.widgets.Composite;
33
import org.eclipse.swt.widgets.Control;
34
import org.eclipse.swt.widgets.Shell;
35
import org.eclipse.ui.PlatformUI;
36

    
37
import eu.etaxonomy.cdm.api.application.ICdmRepository;
38
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeConfigurator;
39
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
40
import eu.etaxonomy.cdm.api.service.ITermService;
41
import eu.etaxonomy.cdm.api.service.config.FindTaxaAndNamesConfiguratorImpl;
42
import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator;
43
import eu.etaxonomy.cdm.common.CdmUtils;
44
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
45
import eu.etaxonomy.cdm.model.common.ICdmBase;
46
import eu.etaxonomy.cdm.model.common.IDefinedTerm;
47
import eu.etaxonomy.cdm.model.common.ISimpleTerm;
48
import eu.etaxonomy.cdm.model.common.Language;
49
import eu.etaxonomy.cdm.model.common.MarkerType;
50
import eu.etaxonomy.cdm.model.common.TermBase;
51
import eu.etaxonomy.cdm.model.description.FeatureTree;
52
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
53
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
54
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
55
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
56
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
57
import eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy;
58
import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
59
import eu.etaxonomy.cdm.strategy.match.MatchException;
60
import eu.etaxonomy.cdm.strategy.match.MatchMode;
61
import eu.etaxonomy.taxeditor.model.AbstractUtility;
62
import eu.etaxonomy.taxeditor.model.MessagingUtils;
63
import eu.etaxonomy.taxeditor.model.NomenclaturalCodeHelper;
64
import eu.etaxonomy.taxeditor.store.CdmStore;
65
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
66
import eu.etaxonomy.taxeditor.ui.dialog.DefaultLanguageDialog;
67

    
68
/**
69
 * <p>
70
 * PreferencesUtil class.
71
 * </p>
72
 *
73
 * @author p.ciardelli
74
 * @author n.hoffmann
75
 * @created 05.12.2008
76
 * @version 1.0
77
 */
78
public class PreferencesUtil implements IPreferenceKeys {
79

    
80
	/**
81
	 *
82
	 */
83
	public static final String PREFERRED_TERMS_CHANGE = "preferred_terms";
84

    
85
	public static final String P2_REPOSITORIES_DELIM = ",";
86
	public static final String P2_REPOSITORY_FIELDS_DELIM = ";";
87

    
88

    
89

    
90
	/**
91
	 * <p>
92
	 * getPreferenceStore
93
	 * </p>
94
	 *
95
	 * @return a {@link org.eclipse.jface.preference.IPreferenceStore} object.
96
	 */
97
	public static IPreferenceStore getPreferenceStore() {
98
		return TaxeditorStorePlugin.getDefault().getPreferenceStore();
99
	}
100

    
101
	/**
102
	 * <p>
103
	 * setPreferredNomenclaturalCode
104
	 * </p>
105
	 *
106
	 * @param preferredCode
107
	 *            a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
108
	 *            object.
109
	 */
110
	public static CdmPreference setPreferredNomenclaturalCode(
111
			NomenclaturalCode preferredCode, boolean local) {
112
	    if (local){
113
	        getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
114
                    getPreferenceKey(preferredCode));
115
	    }
116
	    else{
117
    		ICdmRepository controller;
118
    		controller = CdmStore.getCurrentApplicationConfiguration();
119
    		PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
120
    		CdmPreference preference = null;
121
    		if (controller == null){
122
    			return null;
123
    		}
124
    		if (preferredCode == null){
125
    			preference = controller.getPreferenceService().find(key);
126
    			if (preference == null){
127
    				return null;
128
    			} else{
129
    				int index = StringUtils.lastIndexOf(preference.getValue(), ".");
130
    				UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
131
    				preferredCode = NomenclaturalCode.getByUuid(uuid);
132

    
133
    				getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY,
134
    	                    getPreferenceKey(preferredCode));
135
    				getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY,preference.isAllowOverride());
136
    				return preference;
137
    			}
138
    		} else{
139
    			preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode, preferredCode.getKey());
140
    			controller.getPreferenceService().set(preference);
141

    
142
    		}
143
	    }
144
        return null;
145

    
146

    
147

    
148
	}
149

    
150
	public static NomenclaturalCode getPreferredNomenclaturalCode(){
151
	    if (getPreferenceStore().getBoolean(OVERRIDE_NOMENCLATURAL_CODE_KEY)) {
152
            return getPreferredNomenclaturalCode(true);
153
        } else{
154
            return getPreferredNomenclaturalCode(false);
155
        }
156
	}
157

    
158
	/**
159
	 * <p>
160
	 * getPreferredNomenclaturalCode
161
	 * </p>
162
	 *
163
	 * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
164
	 */
165
	public static NomenclaturalCode getPreferredNomenclaturalCode(boolean useLocal) {
166

    
167
		CdmPreference pref = null;
168
		if (!useLocal){
169
		    pref = getPreferenceFromDB(PreferencePredicate.NomenclaturalCode);
170
		}
171

    
172
	    String preferredCode;
173
	    if(pref == null){
174
	    	preferredCode = getPreferenceStore().getString(
175
					PREFERRED_NOMENCLATURAL_CODE_KEY);
176

    
177
	    }else{
178
	    	preferredCode = pref.getValue();
179
	    }
180

    
181
		for (NomenclaturalCode code : NomenclaturalCodeHelper.getAllCodes()) {
182
			if (getPreferenceKey(code).equals(preferredCode)) {
183
				return code;
184
			}
185
		}
186
		return null;
187
	}
188

    
189

    
190
    private static CdmPreference getPreferenceFromDB(PreferencePredicate predicate){
191
        ICdmRepository controller;
192
        CdmPreference pref = null;
193

    
194
        try{
195
            controller = CdmStore.getCurrentApplicationConfiguration();
196
            PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), predicate);
197
            pref = controller.getPreferenceService().find(key);
198
        }catch(Exception e){
199
            e.printStackTrace();
200
        }
201

    
202
        return pref;
203

    
204
    }
205

    
206

    
207
	public static String getPreferredDefaultLangugae(){
208
	    String preferredLanguage = getPreferenceStore().getString(DEFAULT_LANGUAGE_EDITOR);
209
	    if(StringUtils.isNotEmpty(preferredLanguage) && StringUtils.isNotBlank(preferredLanguage)){
210
	        return preferredLanguage;
211
	    }
212
	    return null;
213
	}
214

    
215
	/**
216
	 * Get the match strategy for the given class that was stored in preferences
217
	 * or the default strategy if it was not stored in preferences
218
	 *
219
	 * @param clazz
220
	 *            a {@link java.lang.Class} object.
221
	 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
222
	 */
223
	public static IMatchStrategy getMatchStrategy(Class clazz) {
224
		String className = clazz.getName();
225
		if (getPreferenceStore().getBoolean(MATCH_STRATEGY_PREFIX + className)) {
226
			IMatchStrategy matchStrategy = getDefaultMatchStrategy(clazz);
227

    
228
			for (String fieldName : matchStrategy.getMatchFieldPropertyNames()) {
229
				String matchModeName = getPreferenceStore().getString(
230
						getMatchStrategyFieldName(className, fieldName));
231
				MatchMode matchMode = MatchMode.valueOf(matchModeName);
232
				try {
233
					matchStrategy.setMatchMode(fieldName, matchMode);
234
				} catch (MatchException e) {
235
					MessagingUtils.error(PreferencesUtil.class, e);
236
					throw new RuntimeException(e);
237
				}
238
			}
239

    
240
			return matchStrategy;
241
		}
242
		return getDefaultMatchStrategy(clazz);
243
	}
244

    
245
	/**
246
	 * Stores a matchStrategy into the preference store.
247
	 *
248
	 * @param matchStrategy
249
	 *            a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy}
250
	 *            object.
251
	 */
252
	public static void setMatchStrategy(IMatchStrategy matchStrategy) {
253
		String className = matchStrategy.getMatchClass().getName();
254
		getPreferenceStore().setValue(MATCH_STRATEGY_PREFIX + className, true);
255

    
256
		Set<String> matchFields = matchStrategy.getMatchFieldPropertyNames();
257

    
258
		for (String fieldName : matchFields) {
259
			getPreferenceStore().setValue(
260
					getMatchStrategyFieldName(className, fieldName),
261
					matchStrategy.getMatchMode(fieldName).name());
262
		}
263
	}
264

    
265
	/**
266
	 * Helper method to create the preference property for a match field.
267
	 *
268
	 * @param className
269
	 * @param fieldName
270
	 * @return
271
	 */
272
	private static String getMatchStrategyFieldName(String className,
273
			String fieldName) {
274
		return MATCH_STRATEGY_PREFIX + className + "." + fieldName;
275
	}
276

    
277
	/**
278
	 * Returns the default match strategy for a given class.
279
	 *
280
	 * @param clazz
281
	 *            a {@link java.lang.Class} object.
282
	 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
283
	 */
284
	public static IMatchStrategy getDefaultMatchStrategy(Class clazz) {
285
		return DefaultMatchStrategy.NewInstance(clazz);
286
	}
287

    
288
	/**
289
	 * <p>
290
	 * getDateFormatPattern
291
	 * </p>
292
	 *
293
	 * @return a {@link java.lang.String} object.
294
	 */
295
	public static String getDateFormatPattern() {
296
		// TODO make this configurable in properties
297
		String pattern = "Y-M-d H:m";
298
		return pattern;
299
	}
300

    
301
	/**
302
	 * <p>
303
	 * addTermToPreferredTerms
304
	 * </p>
305
	 *
306
	 * @param term
307
	 *            a T object.
308
	 * @param <T>
309
	 *            a T object.
310
	 */
311
	public static <T extends TermBase> void addTermToPreferredTerms(T term) {
312

    
313
		// VocabularyEnum vocabulary =
314
		// VocabularyEnum.getVocabularyEnum(term.getClass());
315
		//
316
		// getPreferenceStore().setValue(getPreferenceKey(term),
317
		// VocabularyStore.getTermVocabulary(vocabulary).getTerms().contains(term));
318
		//
319
		// firePreferencesChanged(term.getClass());
320
	}
321

    
322
	/**
323
	 * Construct a unique key using the CdmBase object's uuid
324
	 *
325
	 * @param cdmBase
326
	 * @return
327
	 */
328
	private static String getPreferenceKey(ICdmBase cdmBase) {
329
		cdmBase = HibernateProxyHelper.deproxy(cdmBase);
330

    
331
		String key = cdmBase.getClass().getName().concat(".")
332
				.concat(cdmBase.getUuid().toString());
333
		if (key.contains("javassist")) {
334
			MessagingUtils.info("proxy");
335
		}
336
		return key;
337
	}
338

    
339
	/**
340
	 * Construct a unique key using the CdmBase object's uuid
341
	 *
342
	 * @param cdmBase
343
	 * @return
344
	 */
345
	public static String getPreferenceKey(ISimpleTerm simpleTerm) {
346
		simpleTerm = HibernateProxyHelper.deproxy(simpleTerm);
347
		String key = simpleTerm.getClass().getName().concat(".")
348
				.concat(simpleTerm.getUuid().toString());
349
		if (key.contains("javassist")) {
350
			MessagingUtils.warn(PreferencesUtil.class,
351
					"Trying to persist a preference based on a proxy class.");
352
		}
353
		return key;
354
	}
355

    
356

    
357

    
358
	/**
359
	 * Construct a unique key using the CdmBase object's uuid
360
	 *
361
	 * @param cdmBase
362
	 * @return
363
	 */
364
	public static String getPreferenceKey(IDefinedTerm definedTerm) {
365
		definedTerm = HibernateProxyHelper.deproxy(definedTerm);
366
		String key = definedTerm.getClass().getName().concat(".")
367
				.concat(definedTerm.getUuid().toString());
368
		if (key.contains("javassist")) {
369
			MessagingUtils.warn(PreferencesUtil.class,
370
					"Trying to persist a preference based on a proxy class.");
371
		}
372
		return key;
373
	}
374

    
375
	/**
376
	 * Retrieves search preferences from the preference store
377
	 *
378
	 * @return an {@link ITaxonServiceConfigurator} to pass to search methods
379
	 */
380
	public static IFindTaxaAndNamesConfigurator getSearchConfigurator() {
381
		IFindTaxaAndNamesConfigurator configurator = initializeSearchConfigurator();
382

    
383
		configurator.setDoTaxa(getPreferenceStore().getBoolean(
384
				TAXON_SERVICE_CONFIGURATOR_TAXA));
385
		configurator.setDoSynonyms(getPreferenceStore().getBoolean(
386
				TAXON_SERVICE_CONFIGURATOR_SYNONYMS));
387
		configurator.setDoNamesWithoutTaxa(getPreferenceStore().getBoolean(
388
				TAXON_SERVICE_CONFIGURATOR_NAMES));
389
		configurator.setDoTaxaByCommonNames(getPreferenceStore().getBoolean(
390
				TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES));
391
		//configurator.setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.valueOf(getPreferenceStore().getString(TAXON_SERVICE_CONFIGURATOR_MATCH_MODE)));
392

    
393
		return configurator;
394
	}
395

    
396
	/**
397
	 * create new preferences, setting all search options to true
398
	 *
399
	 * @return a
400
	 *         {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
401
	 *         object.
402
	 */
403
	public static IFindTaxaAndNamesConfigurator initializeSearchConfigurator() {
404
		IFindTaxaAndNamesConfigurator configurator = new FindTaxaAndNamesConfiguratorImpl();
405

    
406
		configurator.setDoTaxa(true);
407
		configurator.setDoSynonyms(true);
408
		configurator.setDoNamesWithoutTaxa(true);
409
		configurator.setDoTaxaByCommonNames(true);
410

    
411
		configurator.setTaxonPropertyPath(Arrays.asList("$", "titleCache",
412
				"name", "name.$", "relationsFromThisTaxon.$"));
413

    
414
		configurator.setSynonymPropertyPath(Arrays.asList("$", "titleCache",
415
				"name", "name.$", "synonymRelations.relatedTo.*"));
416

    
417
		// DEFAULT VALUES
418
		// match mode is a simple like, actually all other match modes are kind
419
		// of bogus
420
		configurator
421
				.setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.ANYWHERE);
422
		// we set page number and size here as this should always be unlimited
423
		configurator.setPageNumber(0);
424
		// TODO currently limit results to 10000
425
		configurator.setPageSize(10000);
426

    
427
		return configurator;
428
	}
429

    
430
	/**
431
	 * Store search preferences
432
	 *
433
	 * @param configurator
434
	 *            a
435
	 *            {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
436
	 *            object.
437
	 */
438
	public static void setSearchConfigurator(
439
			IFindTaxaAndNamesConfigurator configurator) {
440
		getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_TAXA,
441
				configurator.isDoTaxa());
442
		getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_SYNONYMS,
443
				configurator.isDoSynonyms());
444
		getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_NAMES,
445
				configurator.isDoNamesWithoutTaxa());
446
		getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES,
447
				configurator.isDoTaxaByCommonNames());
448
	}
449

    
450
	/**
451
	 * <p>
452
	 * firePreferencesChanged
453
	 * </p>
454
	 *
455
	 * @param clazz
456
	 *            a {@link java.lang.Class} object.
457
	 */
458
	public static void firePreferencesChanged(Class clazz) {
459
		getPreferenceStore().firePropertyChangeEvent(PREFERRED_TERMS_CHANGE,
460
				null, clazz);
461
	}
462

    
463
	/**
464
	 * Set default values for preferences
465
	 */
466
	public static void setDefaults() {
467
		getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_TAXA, true);
468
		getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_SYNONYMS,
469
				true);
470
		getPreferenceStore().setDefault(EDIT_MAP_SERVICE_ACCES_POINT,
471
				"http://edit.africamuseum.be/edit_wp5/v1.2/rest_gen.php");
472
		//FIXME : changed default for SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
473
		getPreferenceStore().setDefault(SHOULD_CONNECT_AT_STARTUP, false);
474
		getPreferenceStore().setDefault(OPENURL_ACCESS_POINT,
475
				"http://www.biodiversitylibrary.org/openurl");
476
		getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_WIDTH, "1000");
477
		getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_HEIGHT, "1000");
478
		getPreferenceStore().setDefault(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE, false);
479
		getPreferenceStore().setDefault(CHECKLIST_ID_IN_VOCABULARY, true);
480
		getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, true);
481
		getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE, true);
482
		getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, true);
483
		getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_HYBRID, true);
484
		getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_LSID, true);
485
		getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, true);
486
		getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NAMECACHE, true);
487
		getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, true);
488
		getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, true);
489
		getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, true);
490
		getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, true);
491
		getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_RANK, true);
492
		getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, true);
493
		getPreferenceStore().setDefault(SORT_NODES_NATURALLY, false);
494
		getPreferenceStore().setDefault(SORT_NODES_ALPHABETICALLY, false);
495

    
496
	}
497

    
498
	/**
499
	 * <p>
500
	 * checkNomenclaturalCode
501
	 * </p>
502
	 */
503
	public static void checkNomenclaturalCode() {
504
		// First time Editor is opened, no nomenclatural code has been set
505

    
506

    
507
		if (PreferencesUtil.getPreferredNomenclaturalCode(true) == null) {
508
			PreferencesUtil.setPreferredNomenclaturalCode(NomenclaturalCode.ICNAFP, true);
509
		}
510

    
511

    
512

    
513
	}
514
	public static void setNomenclaturalCodePreferences(){
515
	    ICdmRepository controller;
516
        controller = CdmStore.getCurrentApplicationConfiguration();
517
        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
518
        CdmPreference preference = null;
519
        if (controller == null){
520
            return ;
521
        }
522
        preference = controller.getPreferenceService().find(key);
523
        if (preference == null){
524
            return;
525
        }
526
        getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY, preference.isAllowOverride());
527

    
528
        int index = StringUtils.lastIndexOf(preference.getValue(), ".");
529
        UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
530
        NomenclaturalCode preferredCode = NomenclaturalCode.getByUuid(uuid);
531

    
532
        getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY,
533
                getPreferenceKey(preferredCode));
534

    
535
        if (!preference.isAllowOverride()){
536
            getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
537
                    getPreferenceKey(preferredCode));
538
        }
539
	}
540

    
541
	public static void checkDefaultLanguage(){
542
	    if(PreferencesUtil.getPreferredDefaultLangugae() == null){
543
	       Shell shell = AbstractUtility.getShell();
544
	       int open = new DefaultLanguageDialog(shell).open();
545
	       if(open == Window.OK){
546
	           PlatformUI.getWorkbench().restart();
547
	       }
548
	    }else{
549
	        //TODO:In case of a reinstall, the config.ini will be overwritten
550
	        //     here you create config.ini with the stored key from preferences
551
	    }
552
	}
553

    
554
	/**
555
	 * <p>
556
	 * getMapServiceAccessPoint
557
	 * </p>
558
	 *
559
	 * @return a {@link java.lang.String} object.
560
	 */
561
	public static String getMapServiceAccessPoint() {
562
		return getPreferenceStore().getString(EDIT_MAP_SERVICE_ACCES_POINT);
563
	}
564

    
565
	/**
566
	 * <p>
567
	 * shouldConnectAtStartUp
568
	 * </p>
569
	 *
570
	 * @return a boolean.
571
	 */
572
	public static boolean shouldConnectAtStartUp() {
573
		//FIXME :  force SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
574
		//return getPreferenceStore().getBoolean(SHOULD_CONNECT_AT_STARTUP);
575
		return false;
576
	}
577

    
578
	/**
579
	 * <p>
580
	 * getDefaultFeatureTreeForTextualDescription
581
	 * </p>
582
	 *
583
	 * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
584
	 */
585
	public static FeatureTree getDefaultFeatureTreeForTextualDescription() {
586
		String uuidString = getPreferenceStore().getString(
587
				FEATURE_TREE_DEFAULT_TEXT);
588
		return CdmUtils.isEmpty(uuidString) ? null : CdmStore.getService(
589
				IFeatureTreeService.class).load(UUID.fromString(uuidString));
590
	}
591

    
592
	/**
593
	 * <p>
594
	 * getDefaultFeatureTreeForStructuredDescription
595
	 * </p>
596
	 *
597
	 * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
598
	 */
599
	public static FeatureTree getDefaultFeatureTreeForStructuredDescription() {
600
		String uuidString = getPreferenceStore().getString(
601
				FEATURE_TREE_DEFAULT_STRUCTURE);
602
		return CdmUtils.isEmpty(uuidString) ? null : CdmStore.getService(
603
				IFeatureTreeService.class).load(UUID.fromString(uuidString));
604
	}
605

    
606
	/**
607
	 * <p>
608
	 * setSortRanksHierarchichally
609
	 * </p>
610
	 *
611
	 * @param selection
612
	 *            a boolean.
613
	 */
614
	public static void setSortRanksHierarchichally(boolean selection) {
615
		getPreferenceStore().setValue(SORT_RANKS_HIERARCHICHALLY, selection);
616
	}
617

    
618
	/**
619
	 * <p>
620
	 * getSortRanksHierarchichally
621
	 * </p>
622
	 *
623
	 * @return a boolean.
624
	 */
625
	public static boolean getSortRanksHierarchichally() {
626
		return getPreferenceStore().getBoolean(SORT_RANKS_HIERARCHICHALLY);
627
	}
628

    
629
	public static boolean isMultilanguageTextEditingCapability() {
630
		return getPreferenceStore().getBoolean(
631
				MULTILANGUAGE_TEXT_EDITING_CAPABILITY);
632
	}
633

    
634
	public static Language getGlobalLanguage() {
635

    
636

    
637
		String languageUuidString = getPreferenceStore().getString(
638
				GLOBAL_LANGUAGE_UUID);
639

    
640
		if(!CdmStore.isActive()) {
641
            MessagingUtils.noDataSourceWarningDialog(languageUuidString);
642
            return null;
643
        }
644

    
645
		if (CdmUtils.isBlank(languageUuidString)) {
646
			return Language.getDefaultLanguage();
647
		}
648

    
649
		UUID languageUuid = UUID.fromString(languageUuidString);
650
		return (Language) CdmStore.getService(ITermService.class).load(
651
				languageUuid);
652
	}
653

    
654
	public static void setGlobalLanguage(Language language) {
655
	    if(language != null) {
656
	        getPreferenceStore().setValue(GLOBAL_LANGUAGE_UUID,language.getUuid().toString());
657
	        CdmStore.setDefaultLanguage(language);
658
	    }
659

    
660
	}
661

    
662
	/**
663
	 * @return
664
	 */
665
	public static Map<MarkerType, Boolean> getEditMarkerTypePreferences() {
666
		List<MarkerType> markerTypes = CdmStore.getTermManager()
667
				.getPreferredTerms(MarkerType.class);
668

    
669
		Map<MarkerType, Boolean> result = new HashMap<MarkerType, Boolean>();
670

    
671
		for (MarkerType markerType : markerTypes) {
672
			String name = getMarkerTypeEditingPreferenceKey(markerType);
673
			Boolean value = getPreferenceStore().getBoolean(name);
674

    
675
			result.put(markerType, value);
676
		}
677

    
678
		return result;
679
	}
680

    
681
	/**
682
	 * @param markerTypeEditingMap
683
	 */
684
	public static void setEditMarkerTypePreferences(
685
			Map<MarkerType, Boolean> markerTypeEditingMap) {
686
		for (MarkerType markerType : markerTypeEditingMap.keySet()) {
687
			String name = getMarkerTypeEditingPreferenceKey(markerType);
688
			getPreferenceStore().setValue(name,
689
					markerTypeEditingMap.get(markerType));
690
		}
691

    
692
	}
693

    
694
	private static String getMarkerTypeEditingPreferenceKey(
695
			MarkerType markerType) {
696
		markerType = HibernateProxyHelper.deproxy(markerType);
697
		return markerType.getClass().getName() + EDIT_MARKER_TYPE_PREFIX;
698
	}
699

    
700
	/**
701
	 * <p>
702
	 * setEditMarkerTypePreference
703
	 * </p>
704
	 *
705
	 * @param input
706
	 *            a {@link org.eclipse.ui.IEditorInput} object.
707
	 * @param markerType
708
	 *            a {@link eu.etaxonomy.cdm.model.common.MarkerType} object.
709
	 * @param edit
710
	 *            a boolean.
711
	 */
712
	public static void setEditMarkerTypePreference(MarkerType markerType,
713
			boolean edit) {
714
		getPreferenceStore().setValue(
715
				getMarkerTypeEditingPreferenceKey(markerType), edit);
716
	}
717

    
718
	/**
719
	 * @return
720
	 */
721
	public static DerivedUnitFacadeConfigurator getDerivedUnitConfigurator() {
722
		DerivedUnitFacadeConfigurator configurator = DerivedUnitFacadeConfigurator
723
				.NewInstance();
724
		configurator.setMoveDerivedUnitMediaToGallery(true);
725
		configurator.setMoveFieldObjectMediaToGallery(true);
726
		return configurator;
727
	}
728

    
729
	/**
730
	 * This method will write language properties to the config.ini located in the configuration folder
731
	 * of the Taxonomic Ediitor. <b>This method is only used to set the default language for Taxonomic Editor.</b>
732
	 *
733
	 * @param setLanguage 0 is for german and 1 for english.
734
	 * @throws IOException
735
	 */
736
    public void writePropertyToConfigFile(int setLanguage) throws IOException {
737
        File file = org.eclipse.core.runtime.preferences.ConfigurationScope.INSTANCE.getLocation().toFile();
738
        //give warning to user if the directory has no write access
739
        if(file == null){
740
            throw new IOException();
741
        }
742
        Properties properties = load(file.getAbsolutePath()+"/config.ini");
743
        switch(setLanguage){
744
        case 0:
745
            properties.setProperty("osgi.nl", "de");
746
            PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "de");
747
            break;
748
        case 1:
749
            properties.setProperty("osgi.nl", "en");
750
            PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "en");
751
            break;
752
        default:
753
            break;
754
        }
755
        save(file+"/config.ini", properties);
756
    }
757

    
758
    /**
759
     * This method loads a property from a given file and returns it.
760
     *
761
     * @param filename
762
     * @return
763
     * @throws IOException
764
     */
765
    private Properties load(String filename) throws IOException {
766
        FileInputStream in = new FileInputStream(filename);
767
        Properties prop = new Properties();
768
        prop.load(in);
769
        in.close();
770
        return prop;
771
    }
772

    
773
    /**
774
     * This method saves a property to the specified file.
775
     *
776
     * @param filename
777
     * @param properties
778
     * @throws IOException
779
     */
780
    private void save(String filename, Properties properties) throws IOException{
781
        FileOutputStream fos =  new FileOutputStream(filename);
782
        properties.store(fos, "");
783
        fos.close();
784
    }
785

    
786
    /**
787
     * Saves a list of P2 Metadata Repositories as string with specified delimiters
788
     *
789
     * @param p2Repos
790
     */
791
    public static void setP2Repositories(List<MetadataRepositoryElement> p2Repos) {
792
        StringBuilder sb = new StringBuilder();
793
        for(MetadataRepositoryElement p2Repo : p2Repos) {
794
            sb.append(P2_REPOSITORIES_DELIM);
795
            if(p2Repo.getName() == null || p2Repo.getName().isEmpty()) {
796
                sb.append("-");
797
            } else {
798
                sb.append(p2Repo.getName());
799
            }
800
            sb.append(P2_REPOSITORY_FIELDS_DELIM);
801
            sb.append(p2Repo.getLocation().toString());
802
            sb.append(P2_REPOSITORY_FIELDS_DELIM);
803
            sb.append(String.valueOf(p2Repo.isEnabled()));
804
        }
805
        getPreferenceStore().setValue(P2_REPOSITORY_LIST, sb.toString());
806
    }
807

    
808

    
809
    /**
810
     * Retrieves a list of previously saved P2 repositories
811
     *
812
     * @return
813
     */
814
    public static List<MetadataRepositoryElement> getP2Repositories() {
815
        List<MetadataRepositoryElement> p2Repos = new ArrayList<MetadataRepositoryElement>();
816
        String p2ReposPref =  getPreferenceStore().getString(P2_REPOSITORY_LIST);
817
        if(p2ReposPref != null && !p2ReposPref.isEmpty()) {
818
            StringTokenizer p2ReposPrefST = new StringTokenizer(p2ReposPref,P2_REPOSITORIES_DELIM);
819

    
820
            while(p2ReposPrefST.hasMoreTokens()) {
821
                String p2RepoStr = p2ReposPrefST.nextToken();
822
                StringTokenizer p2ReposStrST = new StringTokenizer(p2RepoStr,P2_REPOSITORY_FIELDS_DELIM);
823
                if(p2ReposStrST.countTokens()==3) {
824
                    String nickname = p2ReposStrST.nextToken();
825
                    URI uri = null;
826
                    try {
827
                        uri = new URI(p2ReposStrST.nextToken());
828
                    } catch (URISyntaxException e) {
829
                        continue;
830
                    }
831
                    boolean enabled = Boolean.parseBoolean(p2ReposStrST.nextToken());
832
                    MetadataRepositoryElement mre = new MetadataRepositoryElement(null, uri, true);
833
                    mre.setNickname(nickname);
834
                    mre.setEnabled(enabled);
835
                    p2Repos.add(mre);
836
                }
837
            }
838
        }
839

    
840
        return p2Repos;
841
    }
842

    
843
    /**
844
     * enables/disables nested composite. <br>
845
     *
846
     * @param ctrl - Composite to be en-/disabeld
847
     * @param enabled - boolean
848
     */
849
    public static void recursiveSetEnabled(Control ctrl, boolean enabled) {
850
        if (ctrl instanceof Composite) {
851
            Composite comp = (Composite) ctrl;
852
            for (Control c : comp.getChildren()) {
853
                recursiveSetEnabled(c, enabled);
854
            }
855
        } else {
856
            ctrl.setEnabled(enabled);
857
        }
858
    }
859

    
860
    /**
861
	 * <p>
862
	 * getSortRanksNaturally
863
	 * </p>
864
    	 *
865
    	 * @return a boolean.
866
	 */
867
	public static boolean getSortNodesNaturally() {
868
		return getPreferenceStore().getBoolean(SORT_NODES_NATURALLY);
869
	}
870

    
871
	/**
872
	 * <p>
873
	 * setSortRanksNaturally
874
	 * </p>
875
	 *
876
	 * @param selection
877
	 *            a boolean.
878
	 */
879
	public static void setSortNodesNaturally(boolean selection) {
880
		getPreferenceStore().setValue(SORT_NODES_NATURALLY, selection);
881
	}
882

    
883

    
884
	/**
885
	 * <p>
886
	 * getSortRanksNaturally
887
	 * </p>
888
	 *
889
	 * @return a boolean.
890
	 */
891
	public static boolean getSortNodesStrictlyAlphabetically() {
892
		return getPreferenceStore().getBoolean(SORT_NODES_ALPHABETICALLY);
893
	}
894

    
895
	/**
896
	 * <p>
897
	 * setSortRanksNaturally
898
	 * </p>
899
	 *
900
	 * @param selection
901
	 *            a boolean.
902
	 */
903
	public static void setSortNodesStrictlyAlphabetically(boolean selection) {
904
		getPreferenceStore().setValue(SORT_NODES_ALPHABETICALLY, selection);
905
	}
906

    
907
	/**
908
	 * <p>
909
	 * setStoreNavigatorState
910
	 * </p>
911
	 *
912
	 * @param selection
913
	 *            a boolean.
914
	 */
915
	public static boolean isStoreNavigatorState() {
916
		return getPreferenceStore().getBoolean(RESTORE_NAVIGATOR_STATE);
917

    
918
	}
919

    
920
	/**
921
	 * <p>
922
	 * setStoreNavigatorState
923
	 * </p>
924
	 *
925
	 * @param selection
926
	 *            a boolean.
927
	 */
928
	public static void setStoreNavigatorState(boolean selection) {
929
		getPreferenceStore().setValue(RESTORE_NAVIGATOR_STATE, selection);
930

    
931
	}
932

    
933
    /**
934
     * @return
935
     */
936
    public static boolean isShowUpWidgetIsDisposedMessages() {
937
       return getPreferenceStore().getBoolean(IS_SHOW_UP_WIDGET_IS_DISPOSED);
938
    }
939
    public static void setShowUpWidgetIsDisposedMessages(boolean selection) {
940
        getPreferenceStore().setValue(IS_SHOW_UP_WIDGET_IS_DISPOSED, selection);
941
    }
942

    
943
    /**
944
     * @return
945
     */
946
    public static boolean isShowIdInVocabularyInChecklistEditor() {
947
       return getPreferenceStore().getBoolean(IPreferenceKeys.CHECKLIST_ID_IN_VOCABULARY);
948
    }
949
    public static void setShowIdInVocabularyInChecklistEditor(boolean selection) {
950
        getPreferenceStore().setValue(CHECKLIST_ID_IN_VOCABULARY, selection);
951
    }
952

    
953
    /**
954
     * @return
955
     */
956
    public static boolean isShowRankInChecklistEditor() {
957
        return getPreferenceStore().getBoolean(IPreferenceKeys.CHECKLIST_SHOW_RANK);
958
    }
959
    public static void setShowRankInChecklistEditor(boolean selection) {
960
        getPreferenceStore().setValue(CHECKLIST_SHOW_RANK, selection);
961
    }
962

    
963
    /**
964
     * @param object
965
     * @param b
966
     * @return
967
     */
968
    public static NameDetailsConfigurator setPreferredNameDetailsConfiguration( boolean local) {
969
        NameDetailsConfigurator config = new NameDetailsConfigurator(true);
970

    
971
        CdmPreference preference = null;
972

    
973
        if (!local) {
974
            preference = getPreferenceFromDB(PreferencePredicate.NameDetailsView);
975
        }
976
        if (preference == null){
977
            return null;
978
        }
979

    
980
        getPreferenceStore().setValue(ALLOW_OVERRIDE_NAMEDETAILS, preference.isAllowOverride());
981

    
982
        //the preference value is build like this:
983
        //<section1>:true;<section2>:false....
984

    
985
        String value = preference.getValue();
986
        String [] sections = value.split(";");
987
        Map<String, Boolean> sectionMap = new HashMap<String, Boolean>();
988
        String[] sectionValues;
989
        for (String sectionValue: sections){
990
            sectionValues = sectionValue.split(":");
991
            sectionMap.put(sectionValues[0], Boolean.valueOf(sectionValues[1]));
992
        }
993

    
994

    
995

    
996
        getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON,
997
                (sectionMap.get("taxon")));
998
        config.setTaxonSectionActivated(sectionMap.get("taxon"));
999

    
1000
        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID,
1001
                (sectionMap.get("lsid")));
1002
        config.setLSIDActivated(sectionMap.get("lsid"));
1003

    
1004
        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
1005
                (sectionMap.get("nc")));
1006
        config.setNomenclaturalCodeActived(sectionMap.get("nc"));
1007

    
1008
        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
1009
                (sectionMap.get("ap")));
1010
        config.setAppendedPhraseActivated(sectionMap.get("ap"));
1011

    
1012
        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK,
1013
                (sectionMap.get("rank")));
1014
        config.setRankActivated(sectionMap.get("rank"));
1015

    
1016

    
1017
        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
1018
                (sectionMap.get("atomisedEpithets")));
1019
        config.setAtomisedEpithetsActivated(sectionMap.get("atomisedEpithets"));
1020

    
1021
        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
1022
                (sectionMap.get("author")));
1023
        config.setAuthorshipSectionActivated(sectionMap.get("author"));
1024

    
1025
        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
1026
                (sectionMap.get("nomRef")));
1027
        config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
1028

    
1029
        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
1030
                (sectionMap.get("nomStat")));
1031
        config.setNomenclaturalStatusSectionActivated(sectionMap.get("nomStat"));
1032

    
1033

    
1034
        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
1035
                (sectionMap.get("protologue")));
1036
        config.setProtologueActivated(sectionMap.get("protologue"));
1037

    
1038
        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
1039
                (sectionMap.get("typeDes")));
1040
        config.setTypeDesignationSectionActivated(sectionMap.get("typeDes"));
1041

    
1042
        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
1043
                (sectionMap.get("nameRelation")));
1044
        config.setNameRelationsSectionActivated(sectionMap.get("nameRelation"));
1045

    
1046
        return config;
1047
    }
1048

    
1049
    public static boolean getIsDeterminiationOnlyForFieldUnit(boolean local){
1050
        CdmPreference preference = null;
1051

    
1052
        if (!local) {
1053
            preference = getPreferenceFromDB(PreferencePredicate.DeterminationOnlyForFieldUnits);
1054
        }
1055
        if (preference == null){
1056
            return getPreferenceStore().getBoolean(DETERMINATION_ONLY_FOR_FIELD_UNITS);
1057
        }
1058
        return Boolean.valueOf(preference.getValue());
1059
    }
1060

    
1061
    public static boolean getIsShowCollectingAreasInGeneralSection(boolean local){
1062
        CdmPreference preference = null;
1063

    
1064
        if (!local) {
1065
            preference = getPreferenceFromDB(PreferencePredicate.ShowCollectingAreasInGeneralSection);
1066
        }
1067
        if (preference == null){
1068
            return getPreferenceStore().getBoolean(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION);
1069
        }
1070
        return Boolean.valueOf(preference.getValue());
1071
    }
1072

    
1073
    public static boolean getIsShowTaxonAssociations(boolean local){
1074
        CdmPreference preference = null;
1075

    
1076
        if (!local) {
1077
            preference = getPreferenceFromDB(PreferencePredicate.ShowTaxonAssociations);
1078
        }
1079
        if (preference == null){
1080
            return getPreferenceStore().getBoolean(SHOW_TAXON_ASSOCIATIONS);
1081
        }
1082
        return Boolean.valueOf(preference.getValue());
1083
    }
1084

    
1085
//    public static boolean getBioCaseProvider(boolean local){
1086
//        CdmPreference preference = null;
1087
//
1088
//        if (!local) {
1089
//            preference = getPreferenceFromDB(PreferencePredicate.BioCaseProvider);
1090
//        }
1091
//        if (preference == null){
1092
//            return getPreferenceStore().getBoolean(SHOW_TAXON_ASSOCIATIONS);
1093
//        }
1094
//        return Boolean.valueOf(preference.getValue());
1095
//    }
1096

    
1097

    
1098
    /**
1099
     * <p>
1100
     * setAbcdConfigurator
1101
     * </p>
1102
     *
1103
     * @param preferredConfiguration
1104
     *            a {@link eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator}
1105
     *            object.
1106
     */
1107
//    public static CdmPreference setAbcdImportConfigurationPreference(
1108
//            Abcd206ImportConfigurator preferredConfiguration, boolean local) {
1109
//        if (local){
1110
//            /*
1111
//             *
1112
//    public static final String ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS = "eu.etaxonomy.taxeditor.abcd_import_configurator.doSiblings";
1113
//    public static final String ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN= "eu.etaxonomy.taxeditor.abcd_import_configurator.ignoreImportOfExistingSpecimen";
1114
//    public static final String ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE= "eu.etaxonomy.taxeditor.abcd_import_configurator.reuseExistingTaxaWhenPossible";
1115
//    public static final String ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP= "eu.etaxonomy.taxeditor.abcd_import_configurator.ignoreAuthorship";
1116
//    public static final String ABCD_IMPORT_CONFIGURATOR_REMOVE_COUNTRY_FROM_LOCALITY_TEXT= "eu.etaxonomy.taxeditor.abcd_import_configurator.removeCountryFromLocalityText";
1117
//    public static final String ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN= "eu.etaxonomy.taxeditor.abcd_import_configurator.addMediaAsMediaSpecimen";
1118
//    public static final String ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA= "eu.etaxonomy.taxeditor.abcd_import_configurator.reuseExistingMetaData";
1119
//    public static final String ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS= "eu.etaxonomy.taxeditor.abcd_import_configurator.addIndividualsAssociationsSuchAsSpecimenAndObservations";
1120
//    public static final String ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS= "eu.etaxonomy.taxeditor.abcd_import_configurator.reuseExistingDescriptiveGroups";
1121
//    public static final String ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS= "eu.etaxonomy.taxeditor.abcd_import_configurator.allowReuseOtherClassifications";
1122
//    public static final String ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES= "eu.etaxonomy.taxeditor.abcd_import_configurator.deduplicateReferences";
1123
//    public static final String ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS= "eu.etaxonomy.taxeditor.abcd_import_configurator.deduplicateClassifications";
1124
//    public static final String ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION= "eu.etaxonomy.taxeditor.abcd_import_configurator.moveNewTaxaToDefaultClassification";
1125
//    public static final String ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER= "eu.etaxonomy.taxeditor.abcd_import_configurator.mapUnitIdToCatalogNumber";
1126
//    public static final String ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER= "eu.etaxonomy.taxeditor.abcd_import_configurator.mapUnitIdToAccessionNumber";
1127
//    public static final String ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE= "eu.etaxonomy.taxeditor.abcd_import_configurator.mapUnitIdToBarcode";
1128
//    public static final String ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN= "eu.etaxonomy.taxeditor.abcd_import_configurator.overwriteExistingSpecimens";
1129
//
1130
//             */
1131
//
1132
//            getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_SOURCE_URI,
1133
//                    getPreferenceKey(preferredConfiguration.getSourceUri()));
1134
//        }
1135
//        else{
1136
//            ICdmRepository controller;
1137
//            controller = CdmStore.getCurrentApplicationConfiguration();
1138
//            PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
1139
//            CdmPreference preference = null;
1140
//            if (controller == null){
1141
//                return null;
1142
//            }
1143
//            if (preferredCode == null){
1144
//                preference = controller.getPreferenceService().find(key);
1145
//                if (preference == null){
1146
//                    return null;
1147
//                } else{
1148
//                    int index = StringUtils.lastIndexOf(preference.getValue(), ".");
1149
//                    UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
1150
//                    preferredCode = NomenclaturalCode.getByUuid(uuid);
1151
//
1152
//                    getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY,
1153
//                            getPreferenceKey(preferredCode));
1154
//                    getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY,preference.isAllowOverride());
1155
//                    return preference;
1156
//                }
1157
//            } else{
1158
//                preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode, preferredCode.getKey());
1159
//                controller.getPreferenceService().set(preference);
1160
//
1161
//            }
1162
//        }
1163
//        return null;
1164
//
1165
//
1166
//
1167
//    }
1168

    
1169

    
1170

    
1171

    
1172

    
1173
}
(21-21/26)