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