Class WikiUserAttributeValuesService
java.lang.Object
fr.paris.lutece.plugins.wiki.service.user.WikiUserAttributeValuesService
Holds the value combinations the searchable provider attributes take in the user directory, and
answers the suggestion requests of the permission panel from them.
Combinations are kept, not plain value lists, because they let one field narrow another: the
offices suggested are those that coexist with the direction already chosen, whatever the depth of
the organisation tree. Directory values are messy — abbreviations, accents, spelling variants — so
suggesting the values that really exist is what makes those fields usable at all.
The whole set stays on the server and is filtered per request, so a page never carries it: the
directory holds thousands of combinations once every level is mapped, and shipping them all would
weigh megabytes. The directory itself is read by a daemon, never on a request: walking it costs
seconds. The result is mirrored in the datastore so a restart does not leave the suggestions empty
until the next daemon run.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringcanonicalValue(String strAttributeName, String strValue) Returns the value as the directory writes it, matching case and accents loosely: the directory itself compares that way, so refusing "dsin" when it holds "DSIN" would be stricter than the source of truth.static intReturns how many combinations are known.Returns the searchable attribute names the last directory read covered.static voidrefresh()Reads the directory for every mapped attribute and replaces the known combinations.Returns the values an attribute takes among the combinations still possible, given the values already chosen for other attributes, and matching what the user typed.
-
Method Details
-
suggest
public static List<String> suggest(String strAttributeName, String strQuery, Map<String, String> mapContext, int nLimit) Returns the values an attribute takes among the combinations still possible, given the values already chosen for other attributes, and matching what the user typed. Matching ignores case and accents, and looks anywhere in the value: directory labels are abbreviated and accented in ways a user cannot reproduce. A context value the directory does not know is ignored rather than narrowing everything away, so a field holding free text never empties the other lists.- Parameters:
strAttributeName- the attribute to suggest values forstrQuery- what the user typed, may be null or emptymapContext- the values held by the other attribute fields, may be nullnLimit- how many values to return at most- Returns:
- the matching values, sorted, empty when the attribute is unknown or holds no value
-
getAttributeNames
Returns the searchable attribute names the last directory read covered.- Returns:
- the attribute names, in mapping order
-
canonicalValue
Returns the value as the directory writes it, matching case and accents loosely: the directory itself compares that way, so refusing "dsin" when it holds "DSIN" would be stricter than the source of truth. Storing the directory spelling keeps one form in the database rather than as many as there are ways to type it.- Parameters:
strAttributeName- the attribute namestrValue- the value as it was typed- Returns:
- the directory spelling, null when the directory holds no such value
-
refresh
public static void refresh()Reads the directory for every mapped attribute and replaces the known combinations. Called by the daemon. An empty read is treated as a directory failure and leaves the previous combinations in place: losing every suggestion is worse than serving slightly stale ones. -
countCombinations
public static int countCombinations()Returns how many combinations are known. Meant for daemon logs.- Returns:
- the combination count
-