2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.cdm
.api
.service
;
11 import java
.util
.List
;
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
;
22 * Service API for CDM Preferences.
24 * STATE: UNDER CONSTRUCTION
29 public interface IPreferenceService
{
34 // ********************* GETTING **********************/
38 * Return the number of all existing cdm preferences
44 * Returns all CDM preferences.
47 public List
<CdmPreference
> list();
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.
57 public List
<CdmPreference
> list(IPreferencePredicate
<?
> predicate
);
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
65 public List
<CdmPreference
> list(String subject
, String predicate
);
69 * Retrieve the best matching value for the given preference key.
70 * @param key the key defining the data to retrieve
73 public CdmPreference
find(PrefKey key
);
76 * Retrieve the preference that has a key exactly matching the given key.
80 public CdmPreference
findExact(PrefKey key
);
83 // Can not yet be created as we allow only PreferencePredicate for predicate key creation now.
85 // * Retrieve the best matching value for the given preference key.
90 // public Object find(String subject, String predicate);
92 // Can not yet be created as we allow only PreferencePredicate for predicate key creation now.
94 // * Retrieve the database wide preference for the given predicate.
98 // public CdmPreference findDatabase(String predicate);
101 * Retrieve the database wide preference for the given predicate.
105 public CdmPreference
findDatabase(IPreferencePredicate
<?
> predicate
);
108 * Retrieve the vaadin wide preference for the given predicate.
112 public CdmPreference
findVaadin(IPreferencePredicate
<?
> predicate
);
116 * Retrieve the TaxEditor wide preference for the given predicate.
120 public CdmPreference
findTaxEditor(IPreferencePredicate
<?
> predicate
);
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.
130 public CdmPreference
find(TaxonNode taxonNode
, String predicate
);
132 public CdmPreference
find(TaxonNode taxonNode
, IPreferencePredicate
<?
> predicate
);
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.
139 * NOTE: This is not yet implemented!
145 public CdmPreference
find(CdmBase taxonNodeRelatedCdmBase
, String predicate
);
150 //******************* SETTING **********************/
154 * Write the value for the preference's key
157 public void set(CdmPreference preference
);
163 void remove(PrefKey preference
);
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 );
171 //// String setEditorPrefs();