1
|
/**
|
2
|
* Copyright (C) 2019 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
|
package eu.etaxonomy.taxeditor.databaseAdmin.preferencePage;
|
10
|
|
11
|
import eu.etaxonomy.cdm.api.application.ICdmRepository;
|
12
|
import eu.etaxonomy.cdm.api.service.IPreferenceService;
|
13
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
|
14
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
|
15
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
16
|
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
|
17
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
18
|
import eu.etaxonomy.taxeditor.preference.NomenclaturalCodePreferences;
|
19
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
20
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
21
|
|
22
|
/**
|
23
|
* @author k.luther
|
24
|
* @since 19.08.2019
|
25
|
*/
|
26
|
public class NomenclaturalCodeAdminPreferencePage extends NomenclaturalCodePreferences {
|
27
|
|
28
|
|
29
|
@Override
|
30
|
public boolean performOk() {
|
31
|
if (!isApply()){
|
32
|
return true;
|
33
|
}
|
34
|
CdmPreference pref = null;
|
35
|
if (actualCode != null){
|
36
|
pref = CdmPreference.NewDatabaseInstance(PreferencePredicate.NomenclaturalCode, actualCode.toString());
|
37
|
pref.setAllowOverride(allowOverride);
|
38
|
}
|
39
|
|
40
|
PreferencesUtil.setPreferredNomenclaturalCode(pref);
|
41
|
|
42
|
return true;
|
43
|
}
|
44
|
|
45
|
@Override
|
46
|
protected void getValues(){
|
47
|
isAdminPreference = true;
|
48
|
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
|
49
|
if (controller != null){
|
50
|
IPreferenceService service = controller.getPreferenceService();
|
51
|
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
|
52
|
pref = service.find(key);
|
53
|
if (pref != null){
|
54
|
allowOverride = pref.isAllowOverride();
|
55
|
actualCode = NomenclaturalCode.fromString(pref.getValue());
|
56
|
|
57
|
}else{
|
58
|
actualCode = null;
|
59
|
allowOverride = true;
|
60
|
}
|
61
|
|
62
|
}
|
63
|
|
64
|
|
65
|
}
|
66
|
}
|