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