1
|
/**
|
2
|
* Copyright (C) 2018 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.PreferencePredicate;
|
15
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
16
|
import eu.etaxonomy.taxeditor.preference.PublishEnum;
|
17
|
import eu.etaxonomy.taxeditor.preference.PublishFlagLocalPreference;
|
18
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
19
|
|
20
|
/**
|
21
|
* @author k.luther
|
22
|
* @since 23.03.2018
|
23
|
*
|
24
|
*/
|
25
|
public class PublishFlagPreference extends PublishFlagLocalPreference implements IE4AdminPreferencePage{
|
26
|
|
27
|
|
28
|
@Override
|
29
|
public void init() {
|
30
|
super.init();
|
31
|
|
32
|
|
33
|
}
|
34
|
|
35
|
|
36
|
|
37
|
@Override
|
38
|
public boolean performOk() {
|
39
|
if (pref == null){
|
40
|
return true;
|
41
|
}
|
42
|
String text = publishFlagBehaviour.getText();
|
43
|
for (PublishEnum display: PublishEnum.values()){
|
44
|
if (display.getLabel().equals(text)){
|
45
|
text = display.getKey();
|
46
|
break;
|
47
|
}
|
48
|
}
|
49
|
CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DefaultBehaviourForPublishFlag, text);
|
50
|
pref.setAllowOverride(allowOverride);
|
51
|
|
52
|
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
|
53
|
if (controller == null){
|
54
|
return false;
|
55
|
}
|
56
|
IPreferenceService service = controller.getPreferenceService();
|
57
|
service.set(pref);
|
58
|
PreferencesUtil.updateDBPreferences();
|
59
|
|
60
|
return true;
|
61
|
}
|
62
|
|
63
|
|
64
|
|
65
|
@Override
|
66
|
public void getValues() {
|
67
|
isAdminPreference = true;
|
68
|
pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DefaultBehaviourForPublishFlag);
|
69
|
if (pref == null){
|
70
|
pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DefaultBehaviourForPublishFlag, PreferencePredicate.DefaultBehaviourForPublishFlag.getDefaultValue().toString());
|
71
|
}
|
72
|
allowOverride = pref.isAllowOverride();
|
73
|
publishBehaviour = PublishEnum.valueOf(pref.getValue().toString());
|
74
|
}
|
75
|
|
76
|
|
77
|
|
78
|
|
79
|
}
|