T - class typepublic abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> extends Object implements DSpaceObjectService<T>
| Modifier and Type | Field and Description |
|---|---|
protected ChoiceAuthorityService |
choiceAuthorityService |
protected HandleService |
handleService |
protected MetadataAuthorityService |
metadataAuthorityService |
protected MetadataFieldService |
metadataFieldService |
protected MetadataValueService |
metadataValueService |
| Constructor and Description |
|---|
DSpaceObjectServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
addMetadata(Context context,
T dso,
MetadataField metadataField,
String language,
List<String> values) |
void |
addMetadata(Context context,
T dso,
MetadataField metadataField,
String lang,
List<String> values,
List<String> authorities,
List<Integer> confidences)
Add metadata fields.
|
void |
addMetadata(Context context,
T dso,
MetadataField metadataField,
String language,
String value) |
void |
addMetadata(Context context,
T dso,
MetadataField metadataField,
String language,
String value,
String authority,
int confidence) |
void |
addMetadata(Context context,
T dso,
String schema,
String element,
String qualifier,
String lang,
List<String> values)
Add metadata fields.
|
void |
addMetadata(Context context,
T dso,
String schema,
String element,
String qualifier,
String lang,
List<String> values,
List<String> authorities,
List<Integer> confidences)
Add metadata fields.
|
void |
addMetadata(Context context,
T dso,
String schema,
String element,
String qualifier,
String lang,
String value)
Add a single metadata field.
|
void |
addMetadata(Context context,
T dso,
String schema,
String element,
String qualifier,
String lang,
String value,
String authority,
int confidence)
Add a single metadata field.
|
void |
clearMetadata(Context context,
T dso,
String schema,
String element,
String qualifier,
String lang)
Clear metadata values.
|
DSpaceObject |
getAdminObject(Context context,
T dso,
int action)
Return the dspace object where an ADMIN action right is sufficient to
grant the initial authorize check.
|
protected void |
getAuthoritiesAndConfidences(String fieldKey,
Collection collection,
List<String> values,
List<String> authorities,
List<Integer> confidences,
int i) |
protected String[] |
getElements(String fieldName)
Splits "schema.element.qualifier.language" into an array.
|
protected String[] |
getElementsFilled(String fieldName)
Splits "schema.element.qualifier.language" into an array.
|
ArrayList<String> |
getIdentifiers(Context context,
T dso)
Tries to lookup all Identifiers of this DSpaceObject.
|
protected String[] |
getMDValueByField(String field) |
protected String[] |
getMDValueByLegacyField(String field) |
String |
getMetadata(T dso,
String value)
Get the value of a metadata field
|
List<MetadataValue> |
getMetadata(T dso,
String mdString,
String authority) |
List<MetadataValue> |
getMetadata(T dso,
String schema,
String element,
String qualifier,
String lang)
Get metadata for the DSpace Object in a chosen schema.
|
List<MetadataValue> |
getMetadata(T dso,
String schema,
String element,
String qualifier,
String lang,
String authority) |
List<MetadataValue> |
getMetadataByMetadataString(T dso,
String mdString)
Retrieve metadata field values from a given metadata string
of the form
<schema prefix>.<element>[.<qualifier>|.*] |
String |
getMetadataFirstValue(T dso,
String schema,
String element,
String qualifier,
String language)
Retrieve first metadata field value
|
protected int |
getMetadataValuePlace(Map<MetadataField,Integer> fieldToLastPlace,
MetadataValue metadataValue)
Retrieve the place of the metadata value
|
String |
getName(T dso)
Get a proper name for the object.
|
DSpaceObject |
getParentObject(Context context,
T dso)
Return the dspace object that "own" the current object in the hierarchy.
|
String |
getTypeText(T dso)
Provide the text name of the type of this DSpaceObject.
|
protected boolean |
match(String schema,
String element,
String qualifier,
String language,
MetadataValue metadataValue)
Utility method for pattern-matching metadata elements.
|
void |
removeMetadataValues(Context context,
T dso,
List<MetadataValue> values) |
void |
setMetadataSingleValue(Context context,
T dso,
String schema,
String element,
String qualifier,
String language,
String value)
Set first metadata field value
|
void |
update(Context context,
T dso) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdelete, find, getSupportsTypeConstant, updateLastModified@Autowired(required=true) protected ChoiceAuthorityService choiceAuthorityService
@Autowired(required=true) protected HandleService handleService
@Autowired(required=true) protected MetadataValueService metadataValueService
@Autowired(required=true) protected MetadataFieldService metadataFieldService
@Autowired(required=true) protected MetadataAuthorityService metadataAuthorityService
public String getName(T dso)
DSpaceObjectServicenull.
Name should be suitable for display in a user interface.getName in interface DSpaceObjectService<T extends DSpaceObject>dso - DSpaceObjectnull if it doesn't have
onepublic ArrayList<String> getIdentifiers(Context context, T dso)
DSpaceObjectServicegetIdentifiers in interface DSpaceObjectService<T extends DSpaceObject>context - DSpace contextdso - DSpaceObjectpublic DSpaceObject getParentObject(Context context, T dso) throws SQLException
DSpaceObjectServicegetParentObject in interface DSpaceObjectService<T extends DSpaceObject>context - DSpace contextdso - DSpaceObjectSQLException - if database errorpublic DSpaceObject getAdminObject(Context context, T dso, int action) throws SQLException
DSpaceObjectServiceDefault behaviour is ADMIN right on the object grant right on all other action on the object itself. Subclass should override this method as needed.
getAdminObject in interface DSpaceObjectService<T extends DSpaceObject>context - DSpace contextdso - DSpaceObjectaction - ID of action being attempted, from
org.dspace.core.Constants. The ADMIN action is
not a valid parameter for this method, an
IllegalArgumentException should be thrownSQLException - if database errorpublic String getTypeText(T dso)
DSpaceObjectServicegetTypeText in interface DSpaceObjectService<T extends DSpaceObject>dso - DSpaceObjectpublic List<MetadataValue> getMetadata(T dso, String schema, String element, String qualifier, String lang)
DSpaceObjectServiceMetadataSchema for more information about schemas.
Passing in a null value for qualifier
or lang only matches metadata fields where that
qualifier or languages is actually null.
Passing in DSpaceObject.ANY
retrieves all metadata fields with any value for the qualifier or
language, including null
Examples:
Return values of the unqualified "title" field, in any language. Qualified title fields (e.g. "title.uniform") are NOT returned:
dspaceobject.getMetadataByMetadataString("dc", "title", null, DSpaceObject.ANY );
Return all US English values of the "title" element, with any qualifier (including unqualified):
dspaceobject.getMetadataByMetadataString("dc, "title", DSpaceObject.ANY, "en_US" );
The ordering of values of a particular element/qualifier/language combination is significant. When retrieving with wildcards, values of a particular element/qualifier/language combinations will be adjacent, but the overall ordering of the combinations is indeterminate.
getMetadata in interface DSpaceObjectService<T extends DSpaceObject>dso - DSpaceObjectschema - the schema for the metadata field. Must match
the name of an existing metadata schema.element - the element name. DSpaceObject.ANY matches any
element. null doesn't really make sense as all
metadata must have an element.qualifier - the qualifier. null means unqualified, and
DSpaceObject.ANY means any qualifier (including
unqualified.)lang - the ISO639 language code, optionally followed by an underscore
and the ISO3166 country code. null means only
values with no language are returned, and
DSpaceObject.ANY means values with any country code or
no country code are returned.public List<MetadataValue> getMetadataByMetadataString(T dso, String mdString)
DSpaceObjectService<schema prefix>.<element>[.<qualifier>|.*]getMetadataByMetadataString in interface DSpaceObjectService<T extends DSpaceObject>dso - DSpaceObjectmdString - The metadata string of the form
<schema prefix>.<element>[.<qualifier>|.*]public String getMetadata(T dso, String value)
DSpaceObjectServicegetMetadata in interface DSpaceObjectService<T extends DSpaceObject>dso - DSpaceObjectvalue - the name of the metadata field to getpublic List<MetadataValue> getMetadata(T dso, String mdString, String authority)
getMetadata in interface DSpaceObjectService<T extends DSpaceObject>public List<MetadataValue> getMetadata(T dso, String schema, String element, String qualifier, String lang, String authority)
getMetadata in interface DSpaceObjectService<T extends DSpaceObject>public void addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, List<String> values) throws SQLException
DSpaceObjectServiceclearDC to remove values. The ordering of values
passed in is maintained.
If metadata authority control is available, try to get authority values. The authority confidence depends on whether authority is required or not.
addMetadata in interface DSpaceObjectService<T extends DSpaceObject>context - DSpace contextdso - DSpaceObjectschema - the schema for the metadata field. Must match
the name of an existing metadata schema.element - the metadata element namequalifier - the metadata qualifier name, or null for
unqualifiedlang - the ISO639 language code, optionally followed by an underscore
and the ISO3166 country code. null means the
value has no language (for example, a date).values - the values to add.SQLException - if database errorpublic void addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, List<String> values, List<String> authorities, List<Integer> confidences) throws SQLException
DSpaceObjectServiceclearDC to remove values. The ordering of values
passed in is maintained.addMetadata in interface DSpaceObjectService<T extends DSpaceObject>context - DSpace contextdso - DSpaceObjectschema - the schema for the metadata field. Must match
the name of an existing metadata schema.element - the metadata element namequalifier - the metadata qualifier name, or null for
unqualifiedlang - the ISO639 language code, optionally followed by an underscore
and the ISO3166 country code. null means the
value has no language (for example, a date).values - the values to add.authorities - the external authority key for this value (or null)confidences - the authority confidence (default 0)SQLException - if database errorpublic void addMetadata(Context context, T dso, MetadataField metadataField, String lang, List<String> values, List<String> authorities, List<Integer> confidences) throws SQLException
DSpaceObjectServiceclearDC to remove values. The ordering of values
passed in is maintained.addMetadata in interface DSpaceObjectService<T extends DSpaceObject>context - DSpace contextdso - DSpaceObjectmetadataField - the metadata field to which the value is to be setlang - the ISO639 language code, optionally followed by an underscore
and the ISO3166 country code. null means the
value has no language (for example, a date).values - the values to add.authorities - the external authority key for this value (or null)confidences - the authority confidence (default 0)SQLException - if database errorpublic void addMetadata(Context context, T dso, MetadataField metadataField, String language, String value, String authority, int confidence) throws SQLException
addMetadata in interface DSpaceObjectService<T extends DSpaceObject>SQLExceptionpublic void addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, String value) throws SQLException
DSpaceObjectServiceclearDC to remove values.addMetadata in interface DSpaceObjectService<T extends DSpaceObject>context - DSpace contextdso - DSpaceObjectschema - the schema for the metadata field. Must match
the name of an existing metadata schema.element - the metadata element namequalifier - the metadata qualifier, or null for
unqualifiedlang - the ISO639 language code, optionally followed by an underscore
and the ISO3166 country code. null means the
value has no language (for example, a date).value - the value to add.SQLException - if database errorpublic void addMetadata(Context context, T dso, MetadataField metadataField, String language, String value) throws SQLException
addMetadata in interface DSpaceObjectService<T extends DSpaceObject>SQLExceptionpublic void addMetadata(Context context, T dso, MetadataField metadataField, String language, List<String> values) throws SQLException
addMetadata in interface DSpaceObjectService<T extends DSpaceObject>SQLExceptionpublic void addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, String value, String authority, int confidence) throws SQLException
DSpaceObjectServiceclearDC to remove values.addMetadata in interface DSpaceObjectService<T extends DSpaceObject>context - DSpace contextdso - DSpaceObjectschema - the schema for the metadata field. Must match
the name of an existing metadata schema.element - the metadata element namequalifier - the metadata qualifier, or null for
unqualifiedlang - the ISO639 language code, optionally followed by an underscore
and the ISO3166 country code. null means the
value has no language (for example, a date).value - the value to add.authority - the external authority key for this value (or null)confidence - the authority confidence (default 0)SQLException - if database errorpublic void clearMetadata(Context context, T dso, String schema, String element, String qualifier, String lang) throws SQLException
DSpaceObjectServicegetDC above,
passing in null only matches fields where the qualifier or
language is actually null.Item.ANY will
match any element, qualifier or language, including null.
Thus, dspaceobject.clearDC(Item.ANY, Item.ANY, Item.ANY) will
remove all Dublin Core metadata associated with an DSpaceObject.clearMetadata in interface DSpaceObjectService<T extends DSpaceObject>context - DSpace contextdso - DSpaceObjectschema - the schema for the metadata field. Must match
the name of an existing metadata schema.element - the Dublin Core element to remove, or Item.ANYqualifier - the qualifier. null means unqualified, and
Item.ANY means any qualifier (including
unqualified.)lang - the ISO639 language code, optionally followed by an underscore
and the ISO3166 country code. null means only
values with no language are removed, and Item.ANY
means values with any country code or no country code are
removed.SQLException - if database errorpublic void removeMetadataValues(Context context, T dso, List<MetadataValue> values) throws SQLException
removeMetadataValues in interface DSpaceObjectService<T extends DSpaceObject>SQLExceptionpublic String getMetadataFirstValue(T dso, String schema, String element, String qualifier, String language)
getMetadataFirstValue in interface DSpaceObjectService<T extends DSpaceObject>dso - language - element - schema - qualifier - public void setMetadataSingleValue(Context context, T dso, String schema, String element, String qualifier, String language, String value) throws SQLException
setMetadataSingleValue in interface DSpaceObjectService<T extends DSpaceObject>context - DSpace contextdso - DSpaceObjectschema - the schema for the metadata field. Must match
the name of an existing metadata schema.element - the Dublin Core element to remove, or Item.ANYqualifier - the qualifier. null means unqualified, and
Item.ANY means any qualifier (including
unqualified.)language - the ISO639 language code, optionally followed by an underscore
and the ISO3166 country code. null means only
values with no language are removed, and Item.ANY
means values with any country code or no country code are
removed.value - metadata valueSQLException - if database errorprotected boolean match(String schema, String element, String qualifier, String language, MetadataValue metadataValue)
true if the given schema,
element, qualifier and language match the schema, element,
qualifier and language of the DCValue object passed
in. Any or all of the element, qualifier and language passed
in can be the Item.ANY wildcard.schema - the schema for the metadata field. Must match
the name of an existing metadata schema.element - the element to match, or Item.ANYqualifier - the qualifier to match, or Item.ANYlanguage - the language to match, or Item.ANYmetadataValue - the Dublin Core valuetrue if there is a matchprotected void getAuthoritiesAndConfidences(String fieldKey, Collection collection, List<String> values, List<String> authorities, List<Integer> confidences, int i)
protected String[] getElements(String fieldName)
The returned array will always have length greater than or equal to 4
Values in the returned array can be empty or null.
fieldName - field nameprotected String[] getElementsFilled(String fieldName)
The returned array will always have length greater than or equal to 4
When @param fill is true, elements that would be empty or null are replaced by Item.ANY
fieldName - field namepublic void update(Context context, T dso) throws SQLException, AuthorizeException
update in interface DSpaceObjectService<T extends DSpaceObject>SQLExceptionAuthorizeExceptionprotected int getMetadataValuePlace(Map<MetadataField,Integer> fieldToLastPlace, MetadataValue metadataValue)
fieldToLastPlace - the map containing the latest place of each metadata fieldmetadataValue - the metadata value that needs to get a placeCopyright © 2016 DuraSpace. All rights reserved.