diff --git a/dspace-api/src/main/java/org/dspace/content/authority/ChoiceAuthority.java b/dspace-api/src/main/java/org/dspace/content/authority/ChoiceAuthority.java index 8e0885b951a8..5744e70bf33a 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/ChoiceAuthority.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/ChoiceAuthority.java @@ -31,6 +31,7 @@ public interface ChoiceAuthority * defaultSelected index in the Choices instance to the choice, if any, * that matches the value. * + * @param field being matched for * @param text user's value to match * @param collection database ID of Collection for context (owner of Item) * @param start choice at which to start, 0 is first. @@ -38,7 +39,7 @@ public interface ChoiceAuthority * @param locale explicit localization key if available, or null * @return a Choices object (never null). */ - public Choices getMatches(String text, int collection, int start, int limit, String locale); + public Choices getMatches(String field, String text, int collection, int start, int limit, String locale); /** * Get the single "best" match (if any) of a value in the authority @@ -49,12 +50,13 @@ public interface ChoiceAuthority * This call is typically used in non-interactive metadata ingest * where there is no interactive agent to choose from among options. * + * @param field being matched for * @param text user's value to match * @param collection database ID of Collection for context (owner of Item) * @param locale explicit localization key if available, or null * @return a Choices object (never null) with 1 or 0 values. */ - public Choices getBestMatch(String text, int collection, String locale); + public Choices getBestMatch(String field, String text, int collection, String locale); /** * Get the canonical user-visible "label" (i.e. short descriptive text) @@ -64,9 +66,10 @@ public interface ChoiceAuthority * This may get called many times while populating a Web page so it should * be implemented as efficiently as possible. * + * @param field being matched for * @param key authority key known to this authority. * @param locale explicit localization key if available, or null * @return descriptive label - should always return something, never null. */ - public String getLabel(String key, String locale); + public String getLabel(String field, String key, String locale); } diff --git a/dspace-api/src/main/java/org/dspace/content/authority/ChoiceAuthorityManager.java b/dspace-api/src/main/java/org/dspace/content/authority/ChoiceAuthorityManager.java index 69ffcd21cdd8..0fa1bed8718f 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/ChoiceAuthorityManager.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/ChoiceAuthorityManager.java @@ -153,7 +153,7 @@ private String config2fkey(String field) * Wrapper that calls getMatches method of the plugin corresponding to * the metadata field defined by schema,element,qualifier. * - * @see ChoiceAuthority#getMatches(String, int, int, int, String) + * @see ChoiceAuthority#getMatches(String, String, int, int, int, String) * @param schema schema of metadata field * @param element element of metadata field * @param qualifier qualifier of metadata field @@ -175,7 +175,7 @@ public Choices getMatches(String schema, String element, String qualifier, * Wrapper calls getMatches method of the plugin corresponding to * the metadata field defined by single field key. * - * @see ChoiceAuthority#getMatches(String, int, int, int, String) + * @see ChoiceAuthority#getMatches(String, String, int, int, int, String) * @param fieldKey single string identifying metadata field * @param query user's value to match * @param collection database ID of Collection for context (owner of Item) @@ -194,14 +194,14 @@ public Choices getMatches(String fieldKey, String query, int collection, "No choices plugin was configured for field \"" + fieldKey + "\"."); } - return ma.getMatches(query, collection, start, limit, locale); + return ma.getMatches(fieldKey, query, collection, start, limit, locale); } /** * Wrapper that calls getBestMatch method of the plugin corresponding to * the metadata field defined by single field key. * - * @see ChoiceAuthority#getBestMatch(String, int, String) + * @see ChoiceAuthority#getBestMatch(String, String, int, String) * @param fieldKey single string identifying metadata field * @param query user's value to match * @param collection database ID of Collection for context (owner of Item) @@ -218,7 +218,7 @@ public Choices getBestMatch(String fieldKey, String query, int collection, "No choices plugin was configured for field \"" + fieldKey + "\"."); } - return ma.getBestMatch(query, collection, locale); + return ma.getBestMatch(fieldKey, query, collection, locale); } /** @@ -242,7 +242,7 @@ public String getLabel(String fieldKey, String authKey, String locale) { throw new IllegalArgumentException("No choices plugin was configured for field \"" + fieldKey + "\"."); } - return ma.getLabel(authKey, locale); + return ma.getLabel(fieldKey, authKey, locale); } /** diff --git a/dspace-api/src/main/java/org/dspace/content/authority/DCInputAuthority.java b/dspace-api/src/main/java/org/dspace/content/authority/DCInputAuthority.java index deac35d29989..16524d3c40b6 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/DCInputAuthority.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/DCInputAuthority.java @@ -117,7 +117,7 @@ private void init() } - public Choices getMatches(String query, int collection, int start, int limit, String locale) + public Choices getMatches(String field, String query, int collection, int start, int limit, String locale) { init(); @@ -134,7 +134,7 @@ public Choices getMatches(String query, int collection, int start, int limit, St return new Choices(v, 0, v.length, Choices.CF_AMBIGUOUS, false, dflt); } - public Choices getBestMatch(String text, int collection, String locale) + public Choices getBestMatch(String field, String text, int collection, String locale) { init(); for (int i = 0; i < values.length; ++i) @@ -149,7 +149,7 @@ public Choices getBestMatch(String text, int collection, String locale) return new Choices(Choices.CF_NOTFOUND); } - public String getLabel(String key, String locale) + public String getLabel(String field, String key, String locale) { init(); return labels[Integer.parseInt(key)]; diff --git a/dspace-api/src/main/java/org/dspace/content/authority/DSpaceControlledVocabulary.java b/dspace-api/src/main/java/org/dspace/content/authority/DSpaceControlledVocabulary.java index a42c5f2427ed..37562cbc1c44 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/DSpaceControlledVocabulary.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/DSpaceControlledVocabulary.java @@ -154,7 +154,7 @@ private String buildString(Node node) } } - public Choices getMatches(String text, int collection, int start, int limit, String locale) + public Choices getMatches(String field, String text, int collection, int start, int limit, String locale) { init(); log.debug("Getting matches for '" + text + "'"); @@ -203,14 +203,14 @@ public Choices getMatches(String text, int collection, int start, int limit, Str return new Choices(choices, 0, choices.length, Choices.CF_AMBIGUOUS, false); } - public Choices getBestMatch(String text, int collection, String locale) + public Choices getBestMatch(String field, String text, int collection, String locale) { init(); log.debug("Getting best match for '" + text + "'"); - return getMatches(text, collection, 0, 2, locale); + return getMatches(field, text, collection, 0, 2, locale); } - public String getLabel(String key, String locale) + public String getLabel(String field, String key, String locale) { init(); String xpathExpression = String.format(idTemplate, key); @@ -222,4 +222,4 @@ public String getLabel(String key, String locale) return(""); } } -} \ No newline at end of file +} diff --git a/dspace-api/src/main/java/org/dspace/content/authority/LCNameAuthority.java b/dspace-api/src/main/java/org/dspace/content/authority/LCNameAuthority.java index 401eca86819f..879e600a9ee9 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/LCNameAuthority.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/LCNameAuthority.java @@ -83,16 +83,16 @@ public LCNameAuthority() } // punt! this is a poor implementation.. - public Choices getBestMatch(String text, int collection, String locale) + public Choices getBestMatch(String field, String text, int collection, String locale) { - return getMatches(text, collection, 0, 2, locale); + return getMatches(field, text, collection, 0, 2, locale); } /** * Match a proposed value against name authority records * Value is assumed to be in "Lastname, Firstname" format. */ - public Choices getMatches(String text, int collection, int start, int limit, String locale) + public Choices getMatches(String field, String text, int collection, int start, int limit, String locale) { Choices result = queryPerson(text, start, limit); if (result == null) @@ -105,7 +105,7 @@ public Choices getMatches(String text, int collection, int start, int limit, Str // punt; supposed to get the canonical display form of a metadata authority key // XXX FIXME implement this with a query on the authority key, cache results - public String getLabel(String key, String locale) + public String getLabel(String field, String key, String locale) { return key; } diff --git a/dspace-api/src/main/java/org/dspace/content/authority/SHERPARoMEOJournalTitle.java b/dspace-api/src/main/java/org/dspace/content/authority/SHERPARoMEOJournalTitle.java index ff3d1c5d6dd4..8b7cba9cce64 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/SHERPARoMEOJournalTitle.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/SHERPARoMEOJournalTitle.java @@ -52,4 +52,8 @@ public Choices getMatches(String text, int collection, int start, int limit, Str return result; } + @Override + public Choices getMatches(String field, String text, int collection, int start, int limit, String locale) { + return getMatches(text, collection, start, limit, locale); + } } diff --git a/dspace-api/src/main/java/org/dspace/content/authority/SHERPARoMEOProtocol.java b/dspace-api/src/main/java/org/dspace/content/authority/SHERPARoMEOProtocol.java index 4371d42978a7..1356e238a73d 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/SHERPARoMEOProtocol.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/SHERPARoMEOProtocol.java @@ -72,14 +72,14 @@ public SHERPARoMEOProtocol() // this implements the specific RoMEO API args and XML tag naming public abstract Choices getMatches(String text, int collection, int start, int limit, String locale); - public Choices getBestMatch(String text, int collection, String locale) + public Choices getBestMatch(String field, String text, int collection, String locale) { - return getMatches(text, collection, 0, 2, locale); + return getMatches(field, text, collection, 0, 2, locale); } // XXX FIXME just punt, returning value, never got around to // implementing a reverse query. - public String getLabel(String key, String locale) + public String getLabel(String field, String key, String locale) { return key; } diff --git a/dspace-api/src/main/java/org/dspace/content/authority/SHERPARoMEOPublisher.java b/dspace-api/src/main/java/org/dspace/content/authority/SHERPARoMEOPublisher.java index e11f239d983b..58e1fc316b68 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/SHERPARoMEOPublisher.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/SHERPARoMEOPublisher.java @@ -53,4 +53,9 @@ public Choices getMatches(String text, int collection, int start, int limit, Str } return result; } + + @Override + public Choices getMatches(String field, String text, int collection, int start, int limit, String locale) { + return getMatches(text, collection, start, limit, locale); + } } diff --git a/dspace-api/src/main/java/org/dspace/content/authority/SampleAuthority.java b/dspace-api/src/main/java/org/dspace/content/authority/SampleAuthority.java index d039bd447713..58a43a471663 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/SampleAuthority.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/SampleAuthority.java @@ -33,7 +33,7 @@ public class SampleAuthority implements ChoiceAuthority "Saturday" }; - public Choices getMatches(String query, int collection, int start, int limit, String locale) + public Choices getMatches(String field, String query, int collection, int start, int limit, String locale) { int dflt = -1; Choice v[] = new Choice[values.length]; @@ -48,7 +48,7 @@ public Choices getMatches(String query, int collection, int start, int limit, St return new Choices(v, 0, v.length, Choices.CF_AMBIGUOUS, false, dflt); } - public Choices getBestMatch(String text, int collection, String locale) + public Choices getBestMatch(String field, String text, int collection, String locale) { for (int i = 0; i < values.length; ++i) { @@ -62,7 +62,7 @@ public Choices getBestMatch(String text, int collection, String locale) return new Choices(Choices.CF_NOTFOUND); } - public String getLabel(String key, String locale) + public String getLabel(String field, String key, String locale) { return labels[Integer.parseInt(key)]; }