Class: Sipity::Entity

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/sipity/entity.rb

Overview

A proxy for the entity (e.g. a repository Object) that is being processed via workflows.

Objects of this class (and their underlying database records) represent another object in the context of the workflow process. By using a proxy, we can avoid polluting the repository object’s data and behavior with things related to workflow processing. This means we can move an object into and through a workflow without making changes independently from curatorial considerations (e.g. metadata changes).

Keeping this object and interface separate also presents a clear seam for alternative solutions.

The Entity relates to repository objects via a GlobalID URI via #proxy_for_global_id. Since the repository objects aren’t assumed to be ActiveRecord or ActiveModel compatible, we use the URI-based system provided by GlobalID to ensure that this relationship functions independent of the modelling system used for the respository objects. #proxy_for is provided as a convenience method for retrieving the underlying repository object.

Each Entity holds a relationship to a Workflow, which is the active workflow on the object represented by the Entity. It also holds a reference to a WorkflowState, which is the current state of the object within the workflow.

workflow_id: 8, workflow_state_id: 20, created_at: “2017-07-07 13:39:42”, updated_at: “2017-07-07 13:39:42”>

Examples:

To get the Sipity::Entity for a work

work = GenericWork.first
Sipity::Entity(work)
=> #<Sipity::Entity id: 1, proxy_for_global_id: "gid://whatever/GenericWork/3x816m604",

See Also:

Instance Method Summary collapse

Instance Method Details

#proxy_forObject

Returns the thing this Entity represents.

Returns:

  • (Object)

    the thing this Entity represents.



60
61
62
# File 'app/models/sipity/entity.rb', line 60

def proxy_for
  @proxy_for ||= GlobalID::Locator.locate(proxy_for_global_id)
end

#workflow_state_nameObject



51
52
53
# File 'app/models/sipity/entity.rb', line 51

def workflow_state_name
  workflow_state&.name
end