public abstract class DSpaceObject extends Object
| Modifier and Type | Field and Description |
|---|---|
protected MetadataField[] |
allMetadataFields |
protected org.dspace.content.DSpaceObject.MetadataCache |
metadataCache
The Dublin Core metadata - inner class for lazy loading
|
protected boolean |
modifiedMetadata
True if anything else was changed since last update()
(to drive event mechanism)
|
protected Context |
ourContext
Our context
|
| Modifier | Constructor and Description |
|---|---|
protected |
DSpaceObject()
Construct a DSpaceOBject with the given table row
|
protected |
DSpaceObject(Context context) |
| Modifier and Type | Method and Description |
|---|---|
void |
addDC(String element,
String qualifier,
String lang,
String value)
Deprecated.
|
void |
addDC(String element,
String qualifier,
String lang,
String[] values)
Deprecated.
|
protected void |
addDetails(String d)
Add a string to the cache of event details.
|
void |
addMetadata(String schema,
String element,
String qualifier,
String lang,
String value)
Add a single metadata field.
|
void |
addMetadata(String schema,
String element,
String qualifier,
String lang,
String[] values)
Add metadata fields.
|
void |
addMetadata(String schema,
String element,
String qualifier,
String lang,
String[] values,
String[] authorities,
int[] confidences)
Add metadata fields.
|
void |
addMetadata(String schema,
String element,
String qualifier,
String lang,
String value,
String authority,
int confidence)
Add a single metadata field.
|
void |
clearDC(String element,
String qualifier,
String lang)
Deprecated.
|
protected void |
clearDetails()
Reset the cache of event details.
|
void |
clearMetadata(String schema,
String element,
String qualifier,
String lang)
Clear metadata values.
|
static DSpaceObject |
find(Context context,
int type,
int id)
Generic find for when the precise type of a DSO is not known, just the
a pair of type number and database ID.
|
DSpaceObject |
getAdminObject(int action)
Return the dspace object where an ADMIN action right is sufficient to
grant the initial authorize check.
|
protected void |
getAuthoritiesAndConfidences(String fieldKey,
String[] values,
String[] authorities,
int[] confidences,
int i) |
Metadatum[] |
getDC(String element,
String qualifier,
String lang)
Deprecated.
|
protected String |
getDetails() |
static String[] |
getElements(String fieldName)
Splits "schema.element.qualifier.language" into an array.
|
static String[] |
getElementsFilled(String fieldName)
Splits "schema.element.qualifier.language" into an array.
|
abstract String |
getHandle()
Get the Handle of the object.
|
abstract int |
getID()
Get the internal ID (database primary key) of this object
|
String[] |
getIdentifiers(Context context)
Tries to lookup all Identifiers of this DSpaceObject.
|
protected String[] |
getMDValueByField(String field) |
protected String[] |
getMDValueByLegacyField(String field) |
protected List<Metadatum> |
getMetadata() |
String |
getMetadata(String value)
Get the value of a metadata field
|
List<Metadatum> |
getMetadata(String mdString,
String authority) |
Metadatum[] |
getMetadata(String schema,
String element,
String qualifier,
String lang)
Get metadata for the DSpace Object in a chosen schema.
|
List<Metadatum> |
getMetadata(String schema,
String element,
String qualifier,
String lang,
String authority) |
Metadatum[] |
getMetadataByMetadataString(String mdString)
Retrieve metadata field values from a given metadata string
of the form
|
protected MetadataField |
getMetadataField(Metadatum dcv) |
protected String |
getMetadataFirstValue(String schema,
String element,
String qualifier,
String language)
Retrieve first metadata field value
|
abstract String |
getName()
Get a proper name for the object.
|
DSpaceObject |
getParentObject()
Return the dspace object that "own" the current object in the hierarchy.
|
abstract int |
getType()
Get the type of this object, found in Constants
|
String |
getTypeText()
Provide the text name of the type of this DSpaceObject.
|
protected void |
removeMetadataFromDatabase()
Utility method to remove all descriptive metadata associated with the DSpaceObject from
the database (regardless of in-memory version)
|
void |
replaceMetadataValue(Metadatum oldValue,
Metadatum newValue) |
void |
resetIdentifiersCache() |
protected void |
setMetadataSingleValue(String schema,
String element,
String qualifier,
String language,
String value)
Set first metadata field value
|
abstract void |
update() |
abstract void |
updateLastModified() |
void |
updateMetadata() |
protected Context ourContext
protected boolean modifiedMetadata
protected org.dspace.content.DSpaceObject.MetadataCache metadataCache
protected transient MetadataField[] allMetadataFields
protected DSpaceObject()
SQLExceptionprotected DSpaceObject(Context context)
public void updateMetadata()
throws SQLException,
AuthorizeException
SQLExceptionAuthorizeExceptionprotected void clearDetails()
protected void addDetails(String d)
d - detail string to add.protected String getDetails()
public abstract int getType()
public String getTypeText()
public abstract int getID()
public abstract String getHandle()
nullnull if it doesn't have
onepublic abstract String getName()
null.
Name should be suitable for display in a user interface.null if it doesn't have
onepublic String[] getIdentifiers(Context context)
public void resetIdentifiersCache()
public static DSpaceObject find(Context context, int type, int id) throws SQLException
context - - the contexttype - - type numberid - - id within table of type'd objectsSQLException - only upon failure accessing the database.public DSpaceObject getAdminObject(int action) throws SQLException
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.
action - 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 thrownSQLExceptionIllegalArgumentException - if the ADMIN action is supplied as parameter of the method
callpublic DSpaceObject getParentObject() throws SQLException
SQLExceptionpublic abstract void update()
throws SQLException,
AuthorizeException
SQLExceptionAuthorizeExceptionpublic abstract void updateLastModified()
@Deprecated public Metadatum[] getDC(String element, String qualifier, String lang)
null value for qualifier
or lang only matches Dublin Core 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.getDC( "title", null, DSpaceObject.ANY );
Return all US English values of the "title" element, with any qualifier (including unqualified):
dspaceobject.getDC( "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.
element - the Dublin Core element. DSpaceObject.ANY matches any
element. null doesn't really make sense as all
DC 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 Metadatum[] getMetadata(String schema, String element, String qualifier, String lang)
MetadataSchema 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.
schema - 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 Metadatum[] getMetadataByMetadataString(String mdString)
mdString - The metadata string of the form
protected String getMetadataFirstValue(String schema, String element, String qualifier, String language)
protected void setMetadataSingleValue(String schema, String element, String qualifier, String language, String value)
public String getMetadata(String value)
value - the name of the metadata field to getIllegalArgumentException - if the requested metadata field doesn't existpublic List<Metadatum> getMetadata(String schema, String element, String qualifier, String lang, String authority)
public static String[] getElements(String fieldName)
public static String[] getElementsFilled(String fieldName)
@Deprecated public void addDC(String element, String qualifier, String lang, String[] values)
clearDC to remove values. The ordering of values
passed in is maintained.element - the Dublin Core elementqualifier - the Dublin Core 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).values - the values to add.@Deprecated public void addDC(String element, String qualifier, String lang, String value)
clearDC to remove values.element - the Dublin Core elementqualifier - the Dublin Core 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.public void addMetadata(String schema, String element, String qualifier, String lang, String[] values)
clearDC 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.
schema - 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.protected void getAuthoritiesAndConfidences(String fieldKey, String[] values, String[] authorities, int[] confidences, int i)
public void addMetadata(String schema, String element, String qualifier, String lang, String[] values, String[] authorities, int[] confidences)
clearDC to remove values. The ordering of values
passed in is maintained.schema - 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)public void addMetadata(String schema, String element, String qualifier, String lang, String value)
clearDC to remove values.schema - 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.public void addMetadata(String schema, String element, String qualifier, String lang, String value, String authority, int confidence)
clearDC to remove values.schema - 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)@Deprecated public void clearDC(String element, String qualifier, String lang)
getDC 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, idspaceobject.clearDC(DSpaceObject.ANY, DSpaceObject.ANY, DSpaceObject.ANY) will
remove all Dublin Core metadata associated with an DSpaceObject.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.public void clearMetadata(String schema, String element, String qualifier, String lang)
getDC 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.schema - 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.protected MetadataField getMetadataField(Metadatum dcv) throws SQLException, AuthorizeException
SQLExceptionAuthorizeExceptionprotected void removeMetadataFromDatabase()
throws SQLException
SQLExceptionCopyright © 2014 DuraSpace. All Rights Reserved.