DSpace.API.Item (dspace_ex v0.1.0-alpha2)

Copy Markdown View Source

Functions for working with DSpace Items.

An Item represents a discrete record. It has metadata, files ("Bitstreams") and file bundles, permissions and policies (who can view, edit, or manage the item), and relations to Collections (an Item must belong to at least one Collection). Items can represent different entity types (Publication, Person, Project, etc.).

In DSpace-speak, draft state data associated with an item is called a "workspace item" and modelled as a separate entity from the underlying main item. The same goes for workflow state data, which is called a "workflow item" and also modelled as a separate entity from the main item.

Summary

Functions

Fetches the access status of an item

Creates a new item in the archive.

Creates a new draft item, starting a submission.

Creates a new file bundle in an item.

Creates a "workspace item".

Deletes an item.

Deletes a draft item from the workspace.

Deletes a "workspace item".

Fetches a single item by UUID.

Fetches the draft associated with an item.

Fetches a draft by its workspace ID.

Fetches the workflow data associated with a given item UUID.

Fetches a "workflow item" by its ID.

Fetches the "workspace item" associated with an item.

Finds items using Discovery search.

Hides an item from discovery, making it no longer findable via search.

List items from the repository.

Lists the file bundles of an item.

Lists "workflow items", optionally filtered by submitter.

Fetches stored metrics of an item.

Fetches the parent collection of an item.

Fetches all persistent identifiers associated with an item.

Mints and queues a DOI for registration for a given item.

Replaces an existing item.

Submits one or more draft items.

Updates an existing item.

Updates a draft in the workspace.

Updates a "workspace item".

Withdraws an item from the archive, making it no longer publicly accessible.

Functions

access_status(uuid)

@spec access_status(binary()) :: DSpace.API.Operation.JSON.t()

Fetches the access status of an item

create(item, options \\ [])

@spec create(
  map(),
  keyword()
) :: DSpace.API.Operation.JSON.t()

Creates a new item in the archive.

This operation requires administrator privileges.

Options

  • :parent - Required. UUID of the collection that will own this item

create_draft(options)

@spec create_draft(keyword()) :: DSpace.API.Operation.JSON.t()

Creates a new draft item, starting a submission.

In DSpace-speak, draft state data associated with an item is called a "workspace item" and modelled as a separate entity from the main item. Executing this operation will return that data structure.

Options

  • :parent - Required. UUID of the collection that will own this item.

create_file_bundle(uuid, bundle \\ %{})

@spec create_file_bundle(binary(), map()) :: DSpace.API.Operation.JSON.t()

Creates a new file bundle in an item.

Executing this operation will return an error if a bundle with the same name already exists in the item.

Parameters

  • uuid - UUID of the item
  • bundle - bundle attributes as a map. Supports "name" (defaults to "ORIGINAL") and "metadata".

create_in_workspace(options)

@spec create_in_workspace(keyword()) :: DSpace.API.Operation.JSON.t()

Creates a "workspace item".

Alias, prefer create_draft/1.

delete(uuid, options \\ [])

@spec delete(
  binary(),
  keyword()
) :: DSpace.API.Operation.JSON.t()

Deletes an item.

Options

  • :copy_virtual_metadata - Turn virtual metadata to actual metadata in related items
    • nil - no virtual metadata is expanded (default)
    • :all - all relationships are verified and virtual metadata is migrated
    • :configured - behavior retrieved from configuration
    • "relationship_type_id" - only specific relationship type IDs are migrated

delete_draft(ws_id)

@spec delete_draft(pos_integer()) :: DSpace.API.Operation.JSON.t()

Deletes a draft item from the workspace.

Note: The ws_id param is the workspace ID, not the Item's UUID.

delete_from_workflow(wf_id, options \\ [])

@spec delete_from_workflow(
  pos_integer(),
  keyword()
) :: DSpace.API.Operation.JSON.t()

Deletes a workflow item.

By default, this sends the item back to the submitter's "workspace". With the :expunge option, it permanently destroys the workflow item and its associated item.

Options

  • :expunge - If true, permanently deletes the item instead of returning it to the
  • submitter's workspace (defaults to false)

delete_from_workspace(ws_id)

@spec delete_from_workspace(pos_integer()) :: DSpace.API.Operation.JSON.t()

Deletes a "workspace item".

Alias, prefer delete_draft/1.

fetch(uuid, options \\ [])

@spec fetch(
  binary(),
  keyword()
) :: DSpace.API.Operation.JSON.t()

Fetches a single item by UUID.

fetch_draft(uuid)

@spec fetch_draft(binary()) :: DSpace.API.Operation.JSON.t()

Fetches the draft associated with an item.

In DSpace-speak, draft state data associated with an item is called a "workspace item" and modelled as a separate entity from the main item. Executing this operation will return that data structure.

fetch_draft_by_id(ws_id)

@spec fetch_draft_by_id(pos_integer()) :: DSpace.API.Operation.JSON.t()

Fetches a draft by its workspace ID.

Note: The ID of the item in the workspace is an integer and different from the Item's UUID. If you want to fetch a draft via Item UUID, see fetch_draft/1.

fetch_workflow(item_uuid)

@spec fetch_workflow(binary()) :: DSpace.API.Operation.JSON.t()

Fetches the workflow data associated with a given item UUID.

In DSpace-speak, workflow state data associated with an item is called a "workflow item" and modelled as a separate entity from the main item. There is at most one "workflow item" per item.

fetch_workflow_by_id(wf_id)

@spec fetch_workflow_by_id(pos_integer()) :: DSpace.API.Operation.JSON.t()

Fetches a "workflow item" by its ID.

Note: The "workflow item" ID is an integer and different from the Item's UUID. To find a workflow item via Item UUID, see fetch_workflow/1.

fetch_workspace(uuid)

@spec fetch_workspace(binary()) :: DSpace.API.Operation.JSON.t()

Fetches the "workspace item" associated with an item.

Alias, prefer fetch_draft/1.

find(options \\ [])

Finds items using Discovery search.

This operation can be streamed.

Parameters

Examples

# Find all items
iex> Item.find()
%DSpace.API.Operation.JSON{path: "/api/discover/search/objects", ...}

# Find all items with filters
iex> Item.find(filters: [%{filter: "author", operator: "contains", value: "Smith"}])
%DSpace.API.Operation.JSON{...}

# Simple item search with text query
iex> Item.find(query: "elixir programming")
%DSpace.API.Operation.JSON{path: "/api/discover/search/objects", ...}

# Search with additional filters
iex> Item.find(query: "research", filters: [%{filter: "author", operator: "contains", value: "Armstrong"}])
%DSpace.API.Operation.JSON{...}

# Search within a specific collection
iex> Item.find(query: "data", scope: "collection-uuid")
%DSpace.API.Operation.JSON{...}

hide(uuid)

@spec hide(binary()) :: DSpace.API.Operation.JSON.t()

Hides an item from discovery, making it no longer findable via search.

This is a convenience wrapper around update/3 that sets the discoverable flag to false.

list(options \\ [])

List items from the repository.

Note: Unless you pass a list of specific item UUIDs, this operation requires administrator privileges as it uses the direct database access endpoint. To fetch all items publicly, use find/1 instead. Passing a list of item UUIDs will only work with the CRIS fork of DSpace.

Due to "API limitations", the core endpoint currently only returns published items.

This operation can be streamed.

Options

  • :id - Specific item UUIDs as a list
  • :page - Page number (0-based, defaults to 0)
  • :size - Number of items per page (usually defaults to 20)

list_file_bundles(uuid, options \\ [])

@spec list_file_bundles(
  binary(),
  keyword()
) :: DSpace.API.Operation.JSON.t()

Lists the file bundles of an item.

This operation can be streamed.

list_in_workflow(options \\ [])

@spec list_in_workflow(keyword()) :: DSpace.API.Operation.JSON.t()

Lists "workflow items", optionally filtered by submitter.

This operation can be streamed.

Options

  • :submitter - UUID of the submitter (eperson) to filter by; must be a non-empty binary
  • :page - Page number (0-based)
  • :size - Items per page

metrics(uuid)

@spec metrics(binary()) :: DSpace.API.Operation.JSON.t()

Fetches stored metrics of an item.

This operation can be streamed.

parent(uuid)

@spec parent(binary()) :: DSpace.API.Operation.JSON.t()

Fetches the parent collection of an item.

pids(uuid)

@spec pids(binary()) :: DSpace.API.Operation.JSON.t()

Fetches all persistent identifiers associated with an item.

register_doi(uuid)

@spec register_doi(binary()) :: DSpace.API.Operation.JSON.t()

Mints and queues a DOI for registration for a given item.

replace(uuid, item, options \\ [])

@spec replace(binary(), map(), keyword()) :: DSpace.API.Operation.JSON.t()

Replaces an existing item.

submit(ws_id, options \\ [])

Submits one or more draft items.

This is the bridge from what in DSpace is called "workspace" to "workflow". Call this when an item is ready for editorial review or archiving. Accepts either a single workspace item ID or a list of IDs.

If no editorial workflow is configured for the collection, the item is published immediately and :archived is returned instead of a "workflow item" map.

update(uuid, updates, options \\ [])

@spec update(binary(), list(), keyword()) :: DSpace.API.Operation.JSON.t()

Updates an existing item.

update_draft(ws_id, patch_operations)

@spec update_draft(pos_integer(), list()) :: DSpace.API.Operation.JSON.t()

Updates a draft in the workspace.

Note: The ws_id param is the workspace ID, not the Item's UUID.

update_in_workspace(ws_id, patch_operations)

@spec update_in_workspace(pos_integer(), list()) :: DSpace.API.Operation.JSON.t()

Updates a "workspace item".

Alias, prefer update_draft/2.

withdraw(uuid)

@spec withdraw(binary()) :: DSpace.API.Operation.JSON.t()

Withdraws an item from the archive, making it no longer publicly accessible.

This is a convenience wrapper around update/3 that sets the withdrawn flag to true.