1
|
/**
|
2
|
* Copyright (C) 2009 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.cdm.api.service;
|
10
|
|
11
|
import java.util.List;
|
12
|
|
13
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
14
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
|
15
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
|
16
|
import eu.etaxonomy.cdm.model.metadata.IPreferencePredicate;
|
17
|
import eu.etaxonomy.cdm.model.metadata.PreferenceResolver;
|
18
|
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
|
19
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
20
|
|
21
|
/**
|
22
|
* Service API for CDM Preferences.
|
23
|
*
|
24
|
* STATE: UNDER CONSTRUCTION
|
25
|
*
|
26
|
* @author a.mueller
|
27
|
* @since 03.06.2016
|
28
|
*/
|
29
|
public interface IPreferenceService {
|
30
|
|
31
|
|
32
|
|
33
|
|
34
|
// ********************* GETTING **********************/
|
35
|
|
36
|
|
37
|
/**
|
38
|
* Return the number of all existing cdm preferences
|
39
|
* @return
|
40
|
*/
|
41
|
public long count();
|
42
|
|
43
|
/**
|
44
|
* Returns all CDM preferences.
|
45
|
* @return
|
46
|
*/
|
47
|
public List<CdmPreference> list();
|
48
|
|
49
|
/**
|
50
|
* Returns all matching preferences for the given predicate. Use
|
51
|
* {@link #find(PrefKey)} to find the best matching preference
|
52
|
* or use {@link PreferenceResolver} to resolve the best matching
|
53
|
* preference on client side.
|
54
|
* @param predicate
|
55
|
* @return
|
56
|
*/
|
57
|
public List<CdmPreference> list(IPreferencePredicate<?> predicate);
|
58
|
|
59
|
/**
|
60
|
* Retrieve all matching values for the given preference key.
|
61
|
* @param subject the {@link PreferenceSubject} represented as string
|
62
|
* @param predicate the predicate to retrieve
|
63
|
* @return
|
64
|
*/
|
65
|
public List<CdmPreference> list(String subject, String predicate);
|
66
|
|
67
|
|
68
|
/**
|
69
|
* Retrieve the best matching value for the given preference key.
|
70
|
* @param key the key defining the data to retrieve
|
71
|
* @return
|
72
|
*/
|
73
|
public CdmPreference find(PrefKey key);
|
74
|
|
75
|
/**
|
76
|
* Retrieve the preference that has a key exactly matching the given key.
|
77
|
* @param key
|
78
|
* @return
|
79
|
*/
|
80
|
public CdmPreference findExact(PrefKey key);
|
81
|
|
82
|
|
83
|
// Can not yet be created as we allow only PreferencePredicate for predicate key creation now.
|
84
|
// /**
|
85
|
// * Retrieve the best matching value for the given preference key.
|
86
|
// * @param subject
|
87
|
// * @param predicate
|
88
|
// * @return
|
89
|
// */
|
90
|
// public Object find(String subject, String predicate);
|
91
|
|
92
|
// Can not yet be created as we allow only PreferencePredicate for predicate key creation now.
|
93
|
// /**
|
94
|
// * Retrieve the database wide preference for the given predicate.
|
95
|
// * @param key
|
96
|
// * @return
|
97
|
// */
|
98
|
// public CdmPreference findDatabase(String predicate);
|
99
|
|
100
|
/**
|
101
|
* Retrieve the database wide preference for the given predicate.
|
102
|
* @param predicate
|
103
|
* @return
|
104
|
*/
|
105
|
public CdmPreference findDatabase(IPreferencePredicate<?> predicate);
|
106
|
|
107
|
/**
|
108
|
* Retrieve the vaadin wide preference for the given predicate.
|
109
|
* @param predicate
|
110
|
* @return
|
111
|
*/
|
112
|
public CdmPreference findVaadin(IPreferencePredicate<?> predicate);
|
113
|
|
114
|
|
115
|
/**
|
116
|
* Retrieve the TaxEditor wide preference for the given predicate.
|
117
|
* @param predicate
|
118
|
* @return
|
119
|
*/
|
120
|
public CdmPreference findTaxEditor(IPreferencePredicate<?> predicate);
|
121
|
|
122
|
/**
|
123
|
* Returns the best matching preference that matches the given
|
124
|
* predicate and the taxon node filter. Only DB preferences and
|
125
|
* preferences defined on a TaxonNode are considered.
|
126
|
* @param taxonNode
|
127
|
* @param predicate
|
128
|
* @return
|
129
|
*/
|
130
|
public CdmPreference find(TaxonNode taxonNode, String predicate);
|
131
|
|
132
|
public CdmPreference find(TaxonNode taxonNode, IPreferencePredicate<?> predicate);
|
133
|
|
134
|
/**
|
135
|
* Returns the best matching preference that matches the given
|
136
|
* predicate and the filter. Only DB preferences and preferences
|
137
|
* defined on a TaxonNode are considered.
|
138
|
*
|
139
|
* NOTE: This is not yet implemented!
|
140
|
*
|
141
|
* @param taxonNode
|
142
|
* @param predicate
|
143
|
* @return
|
144
|
*/
|
145
|
public CdmPreference find(CdmBase taxonNodeRelatedCdmBase, String predicate);
|
146
|
|
147
|
|
148
|
|
149
|
|
150
|
//******************* SETTING **********************/
|
151
|
|
152
|
|
153
|
/**
|
154
|
* Write the value for the preference's key
|
155
|
* @param preference
|
156
|
*/
|
157
|
public void set(CdmPreference preference);
|
158
|
|
159
|
|
160
|
/**
|
161
|
* @param preference
|
162
|
*/
|
163
|
void remove(PrefKey preference);
|
164
|
|
165
|
|
166
|
|
167
|
//we need to decide if we want to keep this method
|
168
|
// //returns old value
|
169
|
// String setCdmPrefs(CdmBase cdmBase, String predicate, String value );
|
170
|
//
|
171
|
//// String setEditorPrefs();
|
172
|
|
173
|
|
174
|
|
175
|
|
176
|
}
|