Class WikiUserAttributeValuesService

java.lang.Object
fr.paris.lutece.plugins.wiki.service.user.WikiUserAttributeValuesService

public final class WikiUserAttributeValuesService extends Object
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 Type
    Method
    Description
    static String
    canonicalValue(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 int
    Returns how many combinations are known.
    static List<String>
    Returns the searchable attribute names the last directory read covered.
    static void
    Reads the directory for every mapped attribute and replaces the known combinations.
    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.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 for
      strQuery - what the user typed, may be null or empty
      mapContext - the values held by the other attribute fields, may be null
      nLimit - how many values to return at most
      Returns:
      the matching values, sorted, empty when the attribute is unknown or holds no value
    • getAttributeNames

      public static List<String> getAttributeNames()
      Returns the searchable attribute names the last directory read covered.
      Returns:
      the attribute names, in mapping order
    • canonicalValue

      public static String canonicalValue(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. 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 name
      strValue - 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