*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/ \r
+*/\r
package eu.etaxonomy.cdm.api.service;\r
\r
+import java.util.List;\r
+\r
+import eu.etaxonomy.cdm.model.common.CdmBase;\r
import eu.etaxonomy.cdm.model.metadata.CdmPreference;\r
+import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;\r
+import eu.etaxonomy.cdm.model.metadata.IPreferencePredicate;\r
+import eu.etaxonomy.cdm.model.metadata.PreferenceResolver;\r
+import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
\r
/**\r
+ * Service API for CDM Preferences.\r
+ *\r
+ * STATE: UNDER CONSTRUCTION\r
+ *\r
* @author a.mueller\r
- * @created 2013-09-09\r
+ * @since 03.06.2016\r
*/\r
public interface IPreferenceService {\r
\r
- /**\r
- * Retrieve the best matching value for the given preference key.\r
- * @param key\r
- * @return\r
- */\r
- public CdmPreference get(CdmPreference.PrefKey key);\r
-\r
- /**\r
- * Write the value for the preference's key\r
- * @param preference\r
- */\r
- public void set(CdmPreference preference);\r
- \r
- /**\r
- * Return the number of all existing cdm preferences\r
- * @return\r
- */\r
- public int count();\r
-\r
-}
\ No newline at end of file
+\r
+\r
+\r
+ // ********************* GETTING **********************/\r
+\r
+\r
+ /**\r
+ * Return the number of all existing cdm preferences\r
+ * @return\r
+ */\r
+ public long count();\r
+\r
+ /**\r
+ * Returns all CDM preferences.\r
+ * @return\r
+ */\r
+ public List<CdmPreference> list();\r
+\r
+ /**\r
+ * Returns all matching preferences for the given predicate. Use\r
+ * {@link #find(PrefKey)} to find the best matching preference\r
+ * or use {@link PreferenceResolver} to resolve the best matching\r
+ * preference on client side.\r
+ * @param predicate\r
+ * @return\r
+ */\r
+ public List<CdmPreference> list(IPreferencePredicate<?> predicate);\r
+\r
+ /**\r
+ * Retrieve all matching values for the given preference key.\r
+ * @param subject the {@link PreferenceSubject} represented as string\r
+ * @param predicate the predicate to retrieve\r
+ * @return\r
+ */\r
+ public List<CdmPreference> list(String subject, String predicate);\r
+\r
+\r
+ /**\r
+ * Retrieve the best matching value for the given preference key.\r
+ * @param key the key defining the data to retrieve\r
+ * @return\r
+ */\r
+ public CdmPreference find(PrefKey key);\r
+\r
+ /**\r
+ * Retrieve the preference that has a key exactly matching the given key.\r
+ * @param key\r
+ * @return\r
+ */\r
+ public CdmPreference findExact(PrefKey key);\r
+\r
+\r
+ // Can not yet be created as we allow only PreferencePredicate for predicate key creation now.\r
+// /**\r
+// * Retrieve the best matching value for the given preference key.\r
+// * @param subject\r
+// * @param predicate\r
+// * @return\r
+// */\r
+// public Object find(String subject, String predicate);\r
+\r
+// Can not yet be created as we allow only PreferencePredicate for predicate key creation now.\r
+// /**\r
+// * Retrieve the database wide preference for the given predicate.\r
+// * @param key\r
+// * @return\r
+// */\r
+// public CdmPreference findDatabase(String predicate);\r
+\r
+ /**\r
+ * Retrieve the database wide preference for the given predicate.\r
+ * @param predicate\r
+ * @return\r
+ */\r
+ public CdmPreference findDatabase(IPreferencePredicate<?> predicate);\r
+\r
+ /**\r
+ * Retrieve the vaadin wide preference for the given predicate.\r
+ * @param predicate\r
+ * @return\r
+ */\r
+ public CdmPreference findVaadin(IPreferencePredicate<?> predicate);\r
+\r
+\r
+ /**\r
+ * Retrieve the TaxEditor wide preference for the given predicate.\r
+ * @param predicate\r
+ * @return\r
+ */\r
+ public CdmPreference findTaxEditor(IPreferencePredicate<?> predicate);\r
+\r
+ /**\r
+ * Returns the best matching preference that matches the given\r
+ * predicate and the taxon node filter. Only DB preferences and\r
+ * preferences defined on a TaxonNode are considered.\r
+ * @param taxonNode\r
+ * @param predicate\r
+ * @return\r
+ */\r
+ public CdmPreference find(TaxonNode taxonNode, String predicate);\r
+\r
+ public CdmPreference find(TaxonNode taxonNode, IPreferencePredicate<?> predicate);\r
+\r
+ /**\r
+ * Returns the best matching preference that matches the given\r
+ * predicate and the filter. Only DB preferences and preferences\r
+ * defined on a TaxonNode are considered.\r
+ *\r
+ * NOTE: This is not yet implemented!\r
+ *\r
+ * @param taxonNode\r
+ * @param predicate\r
+ * @return\r
+ */\r
+ public CdmPreference find(CdmBase taxonNodeRelatedCdmBase, String predicate);\r
+\r
+\r
+\r
+\r
+ //******************* SETTING **********************/\r
+\r
+\r
+ /**\r
+ * Write the value for the preference's key\r
+ * @param preference\r
+ */\r
+ public void set(CdmPreference preference);\r
+\r
+\r
+ /**\r
+ * @param preference\r
+ */\r
+ void remove(PrefKey preference);\r
+\r
+\r
+\r
+ //we need to decide if we want to keep this method\r
+// //returns old value\r
+// String setCdmPrefs(CdmBase cdmBase, String predicate, String value );\r
+//\r
+//// String setEditorPrefs();\r
+\r
+\r
+\r
+\r
+}