Interface DSpaceObjectService<T extends DSpaceObject>
- Type Parameters:
T- class type
- All Known Subinterfaces:
BitstreamService,BundleService,CollectionService,CommunityService,EPersonService,GroupService,ItemService,SiteService
- All Known Implementing Classes:
BitstreamServiceImpl,BundleServiceImpl,CollectionServiceImpl,CommunityServiceImpl,DSpaceObjectServiceImpl,EPersonServiceImpl,GroupServiceImpl,ItemServiceImpl,SiteServiceImpl
DSpaceObjects are required to have.- Author:
- kevinvandevelde at atmire.com
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MetadataFieldNamestatic final MetadataFieldNamestatic final MetadataFieldNamestatic final MetadataFieldNamestatic final MetadataFieldNamestatic final MetadataFieldNamestatic final MetadataFieldNamestatic final MetadataFieldNamestatic final MetadataFieldName -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAndShiftRightMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, String value, String authority, int confidence, int index) Add a single metadata field.addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, String value) Add a single metadata field.addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, String value, String authority, int confidence) Add a single metadata field.addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, String value, String authority, int confidence, int place) Add a single metadata value at the given place position.addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, List<String> values) Add metadata fields.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.addMetadata(Context context, T dso, MetadataField metadataField, String language, String value) Add a metadatafield.addMetadata(Context context, T dso, MetadataField metadataField, String language, String value, String authority, int confidence) Shortcut foraddMetadata(Context, DSpaceObject, MetadataField, String, List, List, List)when a single value need to be addedaddMetadata(Context context, T dso, MetadataField metadataField, String language, List<String> values) Add a metadatafields.addMetadata(Context context, T dso, MetadataField metadataField, String lang, List<String> values, List<String> authorities, List<Integer> confidences) Add metadata fields.voidClear metadata values.voidGeneric find for when the precise type of an Entity is not knowngetAdminObject(Context context, T dso, int action) Return the dspace object where an ADMIN action right is sufficient to grant the initial authorize check.getIdentifiers(Context context, T dso) Tries to lookup all Identifiers of this DSpaceObject.getMetadata(T dSpaceObject, String value) Get the value of a metadata fieldgetMetadata(T dSpaceObject, String mdString, String authority) Get the value(s) of a metadata field.Get metadata for the DSpace Object in a chosen schema.getMetadata(T dSpaceObject, String schema, String element, String qualifier, String lang, String authority) Get the value(s) of a metadata field.getMetadataByMetadataString(T dSpaceObject, String mdString) Retrieve metadata field values from a given metadata string of the form<schema prefix>.<element>[.<qualifier>|.*]Get the first value of a metadata field.getMetadataFirstValue(T dso, MetadataFieldName field, String language) Get the first value of a metadata field.Get a proper name for the object.getParentObject(Context context, T dso) Return the dspace object that "own" the current object in the hierarchy.intReturns the Constants which this service supportsgetTypeText(T dso) Provide the text name of the type of this DSpaceObject.voidmoveMetadata(Context context, T dso, String schema, String element, String qualifier, int from, int to) voidremoveMetadataValues(Context context, T dso, List<MetadataValue> values) voidreplaceMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, String value, String authority, int confidence, int index) voidsetMetadataModified(T dso) Trigger the modifiedMetadata variable in DSpaceObjectvoidsetMetadataSingleValue(Context context, T dso, String schema, String element, String qualifier, String language, String value) Set first metadata field valuevoidsetMetadataSingleValue(Context context, T dso, MetadataFieldName field, String language, String value) Set first metadata field valuevoidvoidupdateLastModified(Context context, T dso)
-
Field Details
-
MD_INTRODUCTORY_TEXT
-
MD_SHORT_DESCRIPTION
-
MD_SIDEBAR_TEXT
-
MD_COPYRIGHT_TEXT
-
MD_NAME
-
MD_PROVENANCE_DESCRIPTION
-
MD_LICENSE
-
MD_USER_FORMAT_DESCRIPTION
-
MD_SOURCE
-
-
Method Details
-
find
Generic find for when the precise type of an Entity is not known- Parameters:
context- - the contextuuid- - uuid within table of typed dspace objects- Returns:
- the dspace object found, or null if it does not exist.
- Throws:
SQLException- only upon failure accessing the database.
-
getName
Get a proper name for the object. This may returnnull. Name should be suitable for display in a user interface.- Parameters:
dso- DSpaceObject- Returns:
- Name for the object, or
nullif it doesn't have one
-
getIdentifiers
Tries to lookup all Identifiers of this DSpaceObject.- Parameters:
context- DSpace contextdso- DSpaceObject- Returns:
- An array containing all found identifiers or an array with a length of 0.
-
getParentObject
Return the dspace object that "own" the current object in the hierarchy. Note that this method has a meaning slightly different from the getAdminObject because it is independent of the action but it is in a way related to it. It defines the "first" dspace object OTHER then the current one, where allowed ADMIN actions imply allowed ADMIN actions on the object self.- Parameters:
context- DSpace contextdso- DSpaceObject- Returns:
- the dspace object that "own" the current object in the hierarchy
- Throws:
SQLException- if database error
-
getAdminObject
Return the dspace object where an ADMIN action right is sufficient to grant the initial authorize check.Default behaviour is ADMIN right on the object grant right on all other action on the object itself. Subclass should override this method as needed.
- Parameters:
context- DSpace contextdso- DSpaceObjectaction- ID of action being attempted, fromorg.dspace.core.Constants. The ADMIN action is not a valid parameter for this method, an IllegalArgumentException should be thrown- Returns:
- the dspace object, if any, where an ADMIN action is sufficient to grant the original action
- Throws:
SQLException- if database errorIllegalArgumentException- if the ADMIN action is supplied as parameter of the method call
-
getTypeText
Provide the text name of the type of this DSpaceObject. It is most likely all uppercase.- Parameters:
dso- DSpaceObject- Returns:
- Object type as text
-
getMetadata
List<MetadataValue> getMetadata(T dSpaceObject, String schema, String element, String qualifier, String lang) Get metadata for the DSpace Object in a chosen schema. SeeMetadataSchemafor more information about schemas. Passing in anullvalue forqualifierorlangonly matches metadata fields where that qualifier or languages is actuallynull. Passing inDSpaceObject.ANYretrieves all metadata fields with any value for the qualifier or language, includingnullExamples:
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.
- Parameters:
dSpaceObject- DSpaceObjectschema- the schema for the metadata field. Must match thenameof an existing metadata schema.element- the element name.DSpaceObject.ANYmatches any element.nulldoesn't really make sense as all metadata must have an element.qualifier- the qualifier.nullmeans unqualified, andDSpaceObject.ANYmeans any qualifier (including unqualified.)lang- the ISO639 language code, optionally followed by an underscore and the ISO3166 country code.nullmeans only values with no language are returned, andDSpaceObject.ANYmeans values with any country code or no country code are returned.- Returns:
- metadata fields that match the parameters
-
getMetadataByMetadataString
Retrieve metadata field values from a given metadata string of the form<schema prefix>.<element>[.<qualifier>|.*]- Parameters:
dSpaceObject- DSpaceObjectmdString- The metadata string of the form<schema prefix>.<element>[.<qualifier>|.*]- Returns:
- metadata fields that match the parameters
-
getMetadata
Get the value of a metadata field- Parameters:
dSpaceObject- DSpaceObjectvalue- the name of the metadata field to get- Returns:
- the value of the metadata field (or null if the column is an SQL NULL)
- Throws:
IllegalArgumentException- if the requested metadata field doesn't exist
-
getMetadata
Get the value(s) of a metadata field.- Parameters:
dSpaceObject- the object whose metadata are sought.mdString- the name of the field:schema.element.qualifier.authority- name of the authority which controls these values, or Item.ANY, or null.- Returns:
- all matching metadata values, or null if none.
-
getMetadata
List<MetadataValue> getMetadata(T dSpaceObject, String schema, String element, String qualifier, String lang, String authority) Get the value(s) of a metadata field.- Parameters:
dSpaceObject- the object whose metadata are sought.schema- name of the schema which defines the field.element- the field's element name.qualifier- the field's qualifier name, or null.lang- the language of the requested field value(s), null if explicitly no language, ororg.dspace.content.Item.ANYto match all languages.authority- name of the authority which controls these values, or Item.ANY, or null.- Returns:
- value(s) of the indicated field for the given DSO, or null.
-
addMetadata
List<MetadataValue> addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, List<String> values) throws SQLException Add metadata fields. These are appended to existing values. UseclearMetadatato 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.
- Parameters:
context- DSpace contextdso- DSpaceObjectschema- the schema for the metadata field. Must match thenameof an existing metadata schema.element- the metadata element namequalifier- the metadata qualifier name, ornullfor unqualifiedlang- the ISO639 language code, optionally followed by an underscore and the ISO3166 country code.nullmeans the value has no language (for example, a date).values- the values to add.- Returns:
- the list of MetadataValues added to the object
- Throws:
SQLException- if database error
-
addMetadata
List<MetadataValue> addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, List<String> values, List<String> authorities, List<Integer> confidences) throws SQLException Add metadata fields. These are appended to existing values. UseclearMetadatato remove values. The ordering of values passed in is maintained.- Parameters:
context- DSpace contextdso- DSpaceObjectschema- the schema for the metadata field. Must match thenameof an existing metadata schema.element- the metadata element namequalifier- the metadata qualifier name, ornullfor unqualifiedlang- the ISO639 language code, optionally followed by an underscore and the ISO3166 country code.nullmeans 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)- Returns:
- the list of MetadataValues added to the object
- Throws:
SQLException- if database error
-
addMetadata
List<MetadataValue> addMetadata(Context context, T dso, MetadataField metadataField, String lang, List<String> values, List<String> authorities, List<Integer> confidences) throws SQLException Add metadata fields. These are appended to existing values. UseclearMetadatato remove values. The ordering of values passed in is maintained.- Parameters:
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.nullmeans 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)- Returns:
- the list of MetadataValues added to the object
- Throws:
SQLException- if database error
-
addMetadata
MetadataValue addMetadata(Context context, T dso, MetadataField metadataField, String language, String value, String authority, int confidence) throws SQLException Shortcut foraddMetadata(Context, DSpaceObject, MetadataField, String, List, List, List)when a single value need to be added- Parameters:
context- DSpace contextdso- DSpaceObjectmetadataField- the metadata field to which the value is to be setlanguage- the ISO639 language code, optionally followed by an underscore and the ISO3166 country code.nullmeans 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)- Returns:
- the MetadataValue added ot the object
- Throws:
SQLException
-
addMetadata
MetadataValue addMetadata(Context context, T dso, MetadataField metadataField, String language, String value) throws SQLException Add a metadatafield. These are appended to existing values. UseclearMetadatato remove values.- Parameters:
context- DSpace contextdso- DSpaceObjectmetadataField- the metadata field to which the value is to be setlanguage- the ISO639 language code, optionally followed by an underscore and the ISO3166 country code.nullmeans the value has no language (for example, a date).value- the value to add.- Returns:
- the MetadataValue added ot the object
- Throws:
SQLException- if database error
-
addMetadata
List<MetadataValue> addMetadata(Context context, T dso, MetadataField metadataField, String language, List<String> values) throws SQLException Add a metadatafields. These are appended to existing values. UseclearMetadatato remove values.- Parameters:
context- DSpace contextdso- DSpaceObjectmetadataField- the metadata field to which the value is to be setlanguage- the ISO639 language code, optionally followed by an underscore and the ISO3166 country code.nullmeans the value has no language (for example, a date).values- the values to add.- Returns:
- the list of MetadataValues added to the object
- Throws:
SQLException- if database error
-
addMetadata
MetadataValue addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, String value) throws SQLException Add a single metadata field. This is appended to existing values. UseclearMetadatato remove values.- Parameters:
context- DSpace contextdso- DSpaceObjectschema- the schema for the metadata field. Must match thenameof an existing metadata schema.element- the metadata element namequalifier- the metadata qualifier, ornullfor unqualifiedlang- the ISO639 language code, optionally followed by an underscore and the ISO3166 country code.nullmeans the value has no language (for example, a date).value- the value to add.- Returns:
- the MetadataValue added ot the object
- Throws:
SQLException- if database error
-
addMetadata
MetadataValue addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, String value, String authority, int confidence, int place) throws SQLException Add a single metadata value at the given place position.- Parameters:
context- DSpace contextdso- DSpaceObjectschema- the schema for the metadata field. Must match thenameof an existing metadata schema.element- the metadata element namequalifier- the metadata qualifier, ornullfor unqualifiedlang- the ISO639 language code, optionally followed by an underscore and the ISO3166 country code.nullmeans 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)place- the metadata position- Returns:
- the MetadataValue added ot the object
- Throws:
SQLException- if database error
-
addMetadata
MetadataValue addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, String value, String authority, int confidence) throws SQLException Add a single metadata field. This is appended to existing values. UseclearMetadatato remove values.- Parameters:
context- DSpace contextdso- DSpaceObjectschema- the schema for the metadata field. Must match thenameof an existing metadata schema.element- the metadata element namequalifier- the metadata qualifier, ornullfor unqualifiedlang- the ISO639 language code, optionally followed by an underscore and the ISO3166 country code.nullmeans 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)- Returns:
- the MetadataValue added ot the object
- Throws:
SQLException- if database error
-
clearMetadata
void clearMetadata(Context context, T dso, String schema, String element, String qualifier, String lang) throws SQLException Clear metadata values. As withgetDCabove, passing innullonly matches fields where the qualifier orr language is actuallynull.Item.ANYwill match any element, qualifier or language, includingnull. Thus,dspaceobject.clearMetadata(Item.ANY, Item.ANY, Item.ANY)will remove all Dublin Core metadata associated with an DSpaceObject.- Parameters:
context- DSpace contextdso- DSpaceObjectschema- the schema for the metadata field. Must match thenameof an existing metadata schema.element- the Dublin Core element to remove, orItem.ANYqualifier- the qualifier.nullmeans unqualified, andItem.ANYmeans any qualifier (including unqualified.)lang- the ISO639 language code, optionally followed by an underscore and the ISO3166 country code.nullmeans only values with no language are removed, andItem.ANYmeans values with any country code or no country code are removed.- Throws:
SQLException- if database error
-
removeMetadataValues
- Throws:
SQLException
-
getMetadataFirstValue
String getMetadataFirstValue(T dso, String schema, String element, String qualifier, String language) Get the first value of a metadata field.- Parameters:
dso- the object whose metadata are sought.schema- name of the schema which defines the field.element- element name of the field.qualifier- qualifier name of the field, or null.language- select only values in this language.- Returns:
- first value of the field, or null if none.
-
getMetadataFirstValue
Get the first value of a metadata field.- Parameters:
dso- the object whose metadata are sought.field- {schema, element, qualifier} for the desired field.language- select only values in this language.- Returns:
- first value of the field, or null if none.
-
setMetadataSingleValue
void setMetadataSingleValue(Context context, T dso, String schema, String element, String qualifier, String language, String value) throws SQLException Set first metadata field value- Parameters:
context- DSpace contextdso- DSpaceObjectschema- the schema for the metadata field. Must match thenameof an existing metadata schema.element- the Dublin Core element to remove, orItem.ANYqualifier- the qualifier.nullmeans unqualified, andItem.ANYmeans any qualifier (including unqualified.)language- the ISO639 language code, optionally followed by an underscore and the ISO3166 country code.nullmeans only values with no language are removed, andItem.ANYmeans values with any country code or no country code are removed.value- metadata value- Throws:
SQLException- if database error
-
setMetadataSingleValue
void setMetadataSingleValue(Context context, T dso, MetadataFieldName field, String language, String value) throws SQLException Set first metadata field value- Parameters:
context- DSpace contextdso- DSpaceObjectfield- {schema, element, qualifier} for the desired field.language- the ISO639 language code, optionally followed by an underscore and the ISO3166 country code.nullmeans only values with no language are removed, andItem.ANYmeans values with any country code or no country code are removed.value- metadata value- Throws:
SQLException- if database error
-
updateLastModified
- Throws:
SQLExceptionAuthorizeException
-
update
- Throws:
SQLExceptionAuthorizeException
-
delete
-
addAndShiftRightMetadata
void addAndShiftRightMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, String value, String authority, int confidence, int index) throws SQLException Add a single metadata field. Whether it's appended or prepended depends on index parameter. UseclearMetadatato remove values.- Parameters:
context- DSpace contextdso- DSpaceObjectschema- the schema for the metadata field. Must match thenameof an existing metadata schema.element- the metadata element namequalifier- the metadata qualifier, ornullfor unqualifiedlang- the ISO639 language code, optionally followed by an underscore and the ISO3166 country code.nullmeans 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)index- the index at which this metadata is added (0: first place, -1 for last)- Throws:
SQLException- if database error
-
replaceMetadata
void replaceMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, String value, String authority, int confidence, int index) throws SQLException - Throws:
SQLException
-
moveMetadata
void moveMetadata(Context context, T dso, String schema, String element, String qualifier, int from, int to) throws SQLException - Throws:
SQLException
-
getSupportsTypeConstant
int getSupportsTypeConstant()Returns the Constants which this service supports- Returns:
- a org.dspace.core.Constants that represents a IndexableObject type
-
setMetadataModified
Trigger the modifiedMetadata variable in DSpaceObject- Parameters:
dso- DSpaceObject whose metadata has been modified
-