mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
[DS-839] Adding Field to Choice Authority to allow Authorities to be able to know of the field being authority controlled.
git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@6138 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
@@ -153,7 +153,7 @@ public final class ChoiceAuthorityManager
|
||||
* 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 final class ChoiceAuthorityManager
|
||||
* 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 final class ChoiceAuthorityManager
|
||||
"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 final class ChoiceAuthorityManager
|
||||
"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 final class ChoiceAuthorityManager
|
||||
{
|
||||
throw new IllegalArgumentException("No choices plugin was configured for field \"" + fieldKey + "\".");
|
||||
}
|
||||
return ma.getLabel(authKey, locale);
|
||||
return ma.getLabel(fieldKey, authKey, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -117,7 +117,7 @@ public class DCInputAuthority extends SelfNamedPlugin implements ChoiceAuthority
|
||||
}
|
||||
|
||||
|
||||
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 class DCInputAuthority extends SelfNamedPlugin implements ChoiceAuthority
|
||||
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 class DCInputAuthority extends SelfNamedPlugin implements ChoiceAuthority
|
||||
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)];
|
||||
|
@@ -154,7 +154,7 @@ public class DSpaceControlledVocabulary extends SelfNamedPlugin implements Choic
|
||||
}
|
||||
}
|
||||
|
||||
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 class DSpaceControlledVocabulary extends SelfNamedPlugin implements Choic
|
||||
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 class DSpaceControlledVocabulary extends SelfNamedPlugin implements Choic
|
||||
return("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -83,16 +83,16 @@ public class LCNameAuthority implements ChoiceAuthority
|
||||
}
|
||||
|
||||
// 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 class LCNameAuthority implements ChoiceAuthority
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
@@ -52,4 +52,8 @@ public class SHERPARoMEOJournalTitle extends SHERPARoMEOProtocol
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -72,14 +72,14 @@ public abstract class SHERPARoMEOProtocol implements ChoiceAuthority
|
||||
// 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;
|
||||
}
|
||||
|
@@ -53,4 +53,9 @@ public class SHERPARoMEOPublisher extends SHERPARoMEOProtocol
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -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 class SampleAuthority implements ChoiceAuthority
|
||||
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 class SampleAuthority implements ChoiceAuthority
|
||||
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)];
|
||||
}
|
||||
|
Reference in New Issue
Block a user