public class Item extends DSpaceObject
This class holds in memory the item Dublin Core metadata, the bundles in the
item, and the bitstreams in those bundles. When modifying the item, if you
modify the Dublin Core or the "in archive" flag, you must call
update for the changes to be written to the database.
Creating, adding or removing bundles or bitstreams has immediate effect in
the database.
| Modifier and Type | Field and Description |
|---|---|
static String |
ANY
Wild card for Dublin Core metadata qualifiers/languages
|
| Modifier and Type | Method and Description |
|---|---|
void |
addBundle(Bundle b)
Add an existing bundle to this item.
|
void |
addDC(String element,
String qualifier,
String lang,
String value)
Deprecated.
|
void |
addDC(String element,
String qualifier,
String lang,
String[] values)
Deprecated.
|
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 |
adjustBundleBitstreamPolicies(Collection c) |
void |
adjustItemPolicies(Collection c) |
boolean |
canEdit()
return TRUE if context's user can edit item, false otherwise
|
void |
clearDC(String element,
String qualifier,
String lang)
Deprecated.
|
void |
clearMetadata(String schema,
String element,
String qualifier,
String lang)
Clear metadata values.
|
Bundle |
createBundle(String name)
Create a bundle in this item, with immediate effect
|
Bitstream |
createSingleBitstream(InputStream is)
Convenience method, calls createSingleBitstream() with name "ORIGINAL"
|
Bitstream |
createSingleBitstream(InputStream is,
String name)
Create a single bitstream in a new bundle.
|
void |
decache()
Remove item and all its sub-structure from the context cache.
|
boolean |
equals(Object obj)
Return
true if other is the same Item as
this object, false otherwise |
static Item |
find(Context context,
int id)
Get an item from the database.
|
static ItemIterator |
findAll(Context context)
Get all the items in the archive.
|
static ItemIterator |
findAllUnfiltered(Context context)
Get all "final" items in the archive, both archived ("in archive" flag) or
withdrawn items are included.
|
static ItemIterator |
findByAuthorityValue(Context context,
String schema,
String element,
String qualifier,
String value)
Find all the items in the archive with a given authority key value
in the indicated metadata field.
|
static ItemIterator |
findByMetadataField(Context context,
String schema,
String element,
String qualifier,
String value)
Returns an iterator of Items possessing the passed metadata field, or only
those matching the passed value, if value is not Item.ANY
|
static ItemIterator |
findBySubmitter(Context context,
EPerson eperson)
Find all the items in the archive by a given submitter.
|
DSpaceObject |
getAdminObject(int action)
Return the dspace object where an ADMIN action right is sufficient to
grant the initial authorize check.
|
Bundle[] |
getBundles()
Get the bundles in this item.
|
Bundle[] |
getBundles(String name)
Get the bundles matching a bundle name (name corresponds roughly to type)
|
Collection[] |
getCollections()
Get the collections this item is in.
|
Collection[] |
getCollectionsNotLinked()
Get the collections this item is not in.
|
Community[] |
getCommunities()
Get the communities this item is in.
|
DCValue[] |
getDC(String element,
String qualifier,
String lang)
Deprecated.
|
String |
getHandle()
Get the Handle of the object.
|
int |
getID()
Get the internal ID of this item.
|
Date |
getLastModified()
Get the date the item was last modified, or the current date if
last_modified is null
|
DCValue[] |
getMetadata(String mdString)
Retrieve metadata field values from a given metadata string
of the form
|
DCValue[] |
getMetadata(String schema,
String element,
String qualifier,
String lang)
Get metadata for the item in a chosen schema.
|
String |
getName()
Get a proper name for the object.
|
Bitstream[] |
getNonInternalBitstreams()
Get all non-internal bitstreams in the item.
|
Collection |
getOwningCollection()
Get the owning Collection for the item
|
DSpaceObject |
getParentObject()
Return the dspace object that "own" the current object in the hierarchy.
|
EPerson |
getSubmitter()
Get the e-person that originally submitted this item
|
int |
getType()
return type found in Constants
|
int |
hashCode() |
boolean |
hasUploadedFiles()
Check the bundle ORIGINAL to see if there are any uploaded files
|
void |
inheritCollectionDefaultPolicies(Collection c)
remove all policies on an item and its contents, and replace them with
the DEFAULT_ITEM_READ and DEFAULT_BITSTREAM_READ policies belonging to
the collection.
|
boolean |
isArchived()
Find out if the item is part of the main archive
|
boolean |
isDiscoverable()
Find out if the item is discoverable
|
boolean |
isIn(Collection collection)
See whether this Item is contained by a given Collection.
|
boolean |
isOwningCollection(Collection c)
Return true if this Collection 'owns' this item
|
boolean |
isWithdrawn()
Find out if the item has been withdrawn
|
void |
move(Collection from,
Collection to)
Moves the item from one collection to another one
|
void |
move(Collection from,
Collection to,
boolean inheritDefaultPolicies)
Moves the item from one collection to another one
|
void |
reinstate()
Reinstate a withdrawn item
|
void |
removeBundle(Bundle b)
Remove a bundle.
|
void |
removeDSpaceLicense()
Remove just the DSpace license from an item This is useful to update the
current DSpace license, in case the user must accept the DSpace license
again (either the item was rejected, or resumed after saving)
|
void |
removeGroupPolicies(Group g)
remove all of the policies for item's bitstreams and bundles that belong
to a given Group
|
void |
removeLicenses()
Remove all licenses from an item - it was rejected
|
void |
replaceAllBitstreamPolicies(List<ResourcePolicy> newpolicies)
remove all of the policies for item's bitstreams and bundles and replace
them with a new list of policies
|
void |
replaceAllItemPolicies(List<ResourcePolicy> newpolicies)
remove all of the policies for item and replace them with a new list of
policies
|
void |
setArchived(boolean isArchived)
Set the "is_archived" flag.
|
void |
setDiscoverable(boolean discoverable)
Set the "discoverable" flag.
|
void |
setOwningCollection(Collection c)
Set the owning Collection for the item
|
void |
setSubmitter(EPerson sub)
Set the e-person that originally submitted this item.
|
void |
update()
Update the item "in archive" flag and Dublin Core metadata in the
database
|
void |
updateLastModified()
Method that updates the last modified date of the item
|
void |
withdraw()
Withdraw the item from the archive.
|
addDetails, clearDetails, find, getDetails, getTypeTextpublic static final String ANY
public static Item find(Context context, int id) throws SQLException
context - DSpace context objectid - Internal ID of the itemSQLExceptionpublic static ItemIterator findAll(Context context) throws SQLException
context - DSpace context objectSQLExceptionpublic static ItemIterator findAllUnfiltered(Context context) throws SQLException
context - DSpace context objectSQLExceptionpublic static ItemIterator findBySubmitter(Context context, EPerson eperson) throws SQLException
context - DSpace context objecteperson - the submitterSQLExceptionpublic int getID()
getID in class DSpaceObjectpublic String getHandle()
DSpaceObjectnullgetHandle in class DSpaceObjectnull if it doesn't have
oneDSpaceObject.getHandle()public boolean isArchived()
public boolean isWithdrawn()
public boolean isDiscoverable()
public Date getLastModified()
public void updateLastModified()
updateLastModified in class DSpaceObjectpublic void setArchived(boolean isArchived)
WorkflowItem.archive() should set this.isArchived - new value for the flagpublic void setDiscoverable(boolean discoverable)
discoverable - new value for the flagpublic void setOwningCollection(Collection c)
c - Collectionpublic Collection getOwningCollection() throws SQLException
SQLException@Deprecated public DCValue[] 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 Item.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:
item.getDC( "title", null, Item.ANY );
Return all US English values of the "title" element, with any qualifier (including unqualified):
item.getDC( "title", Item.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. Item.ANY matches any
element. null doesn't really make sense as all
DC must have an element.qualifier - 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 returned, and
Item.ANY means values with any country code or
no country code are returned.public DCValue[] 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 Item.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:
item.getMetadata("dc", "title", null, Item.ANY );
Return all US English values of the "title" element, with any qualifier (including unqualified):
item.getMetadata("dc, "title", Item.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. Item.ANY matches any
element. null doesn't really make sense as all
metadata must have an element.qualifier - 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 returned, and
Item.ANY means values with any country code or
no country code are returned.public DCValue[] getMetadata(String mdString)
mdString - The metadata string of the form
@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.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, item.clearDC(Item.ANY, Item.ANY, Item.ANY) will
remove all Dublin Core metadata associated with an item.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, item.clearDC(Item.ANY, Item.ANY, Item.ANY) will
remove all Dublin Core metadata associated with an item.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.public EPerson getSubmitter() throws SQLException
SQLExceptionpublic void setSubmitter(EPerson sub)
update must be called to write the change to the
database.sub - the submitterpublic boolean isIn(Collection collection) throws SQLException
collection - collection contains this Item.SQLExceptionpublic Collection[] getCollections() throws SQLException
SQLExceptionpublic Community[] getCommunities() throws SQLException
SQLExceptionpublic Bundle[] getBundles() throws SQLException
SQLExceptionpublic Bundle[] getBundles(String name) throws SQLException
name - name of bundle (ORIGINAL/TEXT/THUMBNAIL)SQLExceptionpublic Bundle createBundle(String name) throws SQLException, AuthorizeException
name - bundle name (ORIGINAL/TEXT/THUMBNAIL)SQLExceptionAuthorizeExceptionpublic void addBundle(Bundle b) throws SQLException, AuthorizeException
b - the bundle to addSQLExceptionAuthorizeExceptionpublic void removeBundle(Bundle b) throws SQLException, AuthorizeException, IOException
b - the bundle to removeSQLExceptionAuthorizeExceptionIOExceptionpublic Bitstream createSingleBitstream(InputStream is, String name) throws AuthorizeException, IOException, SQLException
is - the stream to create the new bitstream fromname - is the name of the bundle (ORIGINAL, TEXT, THUMBNAIL)AuthorizeExceptionIOExceptionSQLExceptionpublic Bitstream createSingleBitstream(InputStream is) throws AuthorizeException, IOException, SQLException
is - InputStreamAuthorizeExceptionIOExceptionSQLExceptionpublic Bitstream[] getNonInternalBitstreams() throws SQLException
SQLExceptionpublic void removeDSpaceLicense()
throws SQLException,
AuthorizeException,
IOException
This method is used by the org.dspace.submit.step.LicenseStep class
public void removeLicenses()
throws SQLException,
AuthorizeException,
IOException
public void update()
throws SQLException,
AuthorizeException
update in class DSpaceObjectSQLExceptionAuthorizeExceptionpublic void withdraw()
throws SQLException,
AuthorizeException,
IOException
public void reinstate()
throws SQLException,
AuthorizeException,
IOException
public void decache()
throws SQLException
SQLExceptionpublic boolean equals(Object obj)
true if other is the same Item as
this object, false otherwisepublic boolean isOwningCollection(Collection c)
c - Collectionpublic int getType()
getType in class DSpaceObjectpublic void replaceAllItemPolicies(List<ResourcePolicy> newpolicies) throws SQLException, AuthorizeException
newpolicies - -
this will be all of the new policies for the item and its
contentsSQLExceptionAuthorizeExceptionpublic void replaceAllBitstreamPolicies(List<ResourcePolicy> newpolicies) throws SQLException, AuthorizeException
newpolicies - -
this will be all of the new policies for the bundle and
bitstream contentsSQLExceptionAuthorizeExceptionpublic void removeGroupPolicies(Group g) throws SQLException
g - Group referenced by policies that needs to be removedSQLExceptionpublic void inheritCollectionDefaultPolicies(Collection c) throws SQLException, AuthorizeException
c - CollectionSQLException - if an SQL error or if no default policies found. It's a bit
draconian, but default policies must be enforced.AuthorizeExceptionpublic void adjustBundleBitstreamPolicies(Collection c) throws SQLException, AuthorizeException
SQLExceptionAuthorizeExceptionpublic void adjustItemPolicies(Collection c) throws SQLException, AuthorizeException
SQLExceptionAuthorizeExceptionpublic void move(Collection from, Collection to) throws SQLException, AuthorizeException, IOException
public void move(Collection from, Collection to, boolean inheritDefaultPolicies) throws SQLException, AuthorizeException, IOException
public boolean hasUploadedFiles()
throws SQLException
SQLExceptionpublic Collection[] getCollectionsNotLinked() throws SQLException
SQLExceptionpublic boolean canEdit()
throws SQLException
SQLExceptionpublic String getName()
DSpaceObjectnull.
Name should be suitable for display in a user interface.getName in class DSpaceObjectnull if it doesn't have
onepublic static ItemIterator findByMetadataField(Context context, String schema, String element, String qualifier, String value) throws SQLException, AuthorizeException, IOException
context - DSpace context objectschema - metadata field schemaelement - metadata field elementqualifier - metadata field qualifiervalue - field value or Item.ANY to match any valueSQLException, - AuthorizeException, IOExceptionSQLExceptionAuthorizeExceptionIOExceptionpublic DSpaceObject getAdminObject(int action) throws SQLException
DSpaceObjectDefault 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 class 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 thrownSQLExceptionpublic DSpaceObject getParentObject() throws SQLException
DSpaceObjectgetParentObject in class DSpaceObjectSQLExceptionpublic static ItemIterator findByAuthorityValue(Context context, String schema, String element, String qualifier, String value) throws SQLException, AuthorizeException, IOException
context - DSpace context objectschema - metadata field schemaelement - metadata field elementqualifier - metadata field qualifiervalue - the value of authority key to look forSQLException, - AuthorizeException, IOExceptionSQLExceptionAuthorizeExceptionIOExceptionCopyright © 2015 DuraSpace. All Rights Reserved.