Module: Sipity
- Defined in:
- app/models/sipity.rb,
app/models/sipity/role.rb,
app/models/sipity/agent.rb,
app/models/sipity/entity.rb,
app/models/sipity/method.rb,
app/models/sipity/comment.rb,
app/models/sipity/workflow.rb,
app/models/sipity/notification.rb,
app/models/sipity/workflow_role.rb,
app/models/sipity/workflow_state.rb,
app/models/sipity/workflow_action.rb,
app/models/sipity/notifiable_context.rb,
app/models/sipity/workflow_state_action.rb,
app/models/sipity/notification_recipient.rb,
app/models/sipity/workflow_responsibility.rb,
app/models/sipity/entity_specific_responsibility.rb,
app/models/sipity/workflow_state_action_permission.rb
Overview
Sipity is a workflow/state engine.
This module and the classes namespaced within it provide a domain model and implementation for managing the movement of repository objects through a defined workflow. The workflows themselves are configured using JSON documents and loaded into the database/domain model as Workflow. Each workflow can be understood as finite sets of WorkflowState, WorkflowAction (transitions from state to state), and Role authorized to carry out each action.
Any uniquely identifiable object can be managed by a Workflow. Normally Hyrax uses workflows to handle the deposit process and maintenance lifecycle of repository objects at the level of the Work (within the Hydra Works model). Objects are represented within the Sipity engine’s domain model by a Entity. Each object has at most one Entity, is governed by one Workflow, and in one WorkflowState at any given time.
Some use cases for Sipity workflows include:
-
Simple unmediated deposit with on-deposit notifications and actions;
-
Mediated deposit with one or more review steps;
-
Publication workflows requiring multiple levels of editorial approval and/or peer review;
-
Preservation processes involving post-deposit selection of objects for replication to external preservation platforms and/or required action in case of failed fixity checks;
-
Electronic Thesis & Dissertation submission processes involving (e.g.) student deposit, committee and/or departmental approval, centralized/ graduate school review, and a final graduation step.
Defined Under Namespace
Classes: Agent, Comment, ConversionError, Entity, EntitySpecificResponsibility, Method, NotifiableContext, Notification, NotificationRecipient, NullComment, Role, StateError, Workflow, WorkflowAction, WorkflowResponsibility, WorkflowRole, WorkflowState, WorkflowStateAction, WorkflowStateActionPermission
Class Method Summary collapse
-
.Agent(input, &block) ⇒ Sipity::Agent
Cast a given input (e.g. a
::User
or Hyrax::Group to a Agent). -
.Entity(input, &block) ⇒ Sipity::Entity
Cast an object to an Entity.
-
.handle_conversion(input, result, method_name) ⇒ Object
Provides compatibility with the old ‘PowerConverter` conventions.
-
.Role(input, &block) ⇒ Object
Cast an object to an Role.
-
.WorkflowAction(input, workflow, &block) ⇒ Object
Cast an object to a WorkflowAction in a given workflow.
-
.WorkflowId(input, &block) ⇒ Object
Cast an object to a Workflow id rubocop:disable Metrics/MethodLength.
-
.WorkflowState(input, workflow, &block) ⇒ Object
Cast an object to a WorkflowState in a given workflow.
Class Method Details
.Agent(input, &block) ⇒ Sipity::Agent
Cast a given input (e.g. a ::User
or Hyrax::Group to a Agent).
42 43 44 45 46 47 48 49 |
# File 'app/models/sipity.rb', line 42 def Agent(input, &block) # rubocop:disable Naming/MethodName result = case input when Sipity::Agent input end handle_conversion(input, result, :to_sipity_agent, &block) end |
.Entity(input, &block) ⇒ Sipity::Entity
Cast an object to an Entity
rubocop:disable Naming/MethodName, Metrics/CyclomaticComplexity, Metrics/MethodLength
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/models/sipity.rb', line 59 def Entity(input, &block) # rubocop:disable Metrics/AbcSize Hyrax.logger.debug("Trying to make an Entity for #{input.inspect}") result = case input when Sipity::Entity input when URI::GID, GlobalID Hyrax.logger.debug("Entity() got a GID, searching by proxy") Entity.find_by(proxy_for_global_id: input.to_s) when SolrDocument Hyrax.logger.debug("Entity() got a SolrDocument, retrying on #{input.to_model}") Entity(input.to_model) when Draper::Decorator Hyrax.logger.debug("Entity() got a Decorator, retrying on #{input.model}") Entity(input.model) when Sipity::Comment Hyrax.logger.debug("Entity() got a Comment, retrying on #{input.entity}") Entity(input.entity) when Valkyrie::Resource Hyrax.logger.debug("Entity() got a Resource, retrying on #{Hyrax::GlobalID(input)}") Entity(Hyrax::GlobalID(input)) else Hyrax.logger.debug("Entity() got something else, testing #to_global_id") Entity(input.to_global_id) if input.respond_to?(:to_global_id) end Hyrax.logger.debug("Entity(): attempting conversion on #{result}") handle_conversion(input, result, :to_sipity_entity, &block) rescue URI::GID::MissingModelIdError Entity(nil) end |
.handle_conversion(input, result, method_name) ⇒ Object
Provides compatibility with the old ‘PowerConverter` conventions
172 173 174 175 176 177 178 |
# File 'app/models/sipity.rb', line 172 def handle_conversion(input, result, method_name) result ||= input.try(method_name) return result unless result.nil? return yield if block_given? raise ConversionError.new(input) # rubocop:disable Style/RaiseArgs end |
.Role(input, &block) ⇒ Object
Cast an object to an Role
95 96 97 98 99 100 101 102 103 104 |
# File 'app/models/sipity.rb', line 95 def Role(input, &block) # rubocop:disable Naming/MethodName result = case input when Sipity::Role input when String, Symbol Sipity::Role.find_or_create_by(name: input) end handle_conversion(input, result, :to_sipity_role, &block) end |
.WorkflowAction(input, workflow, &block) ⇒ Object
Cast an object to a WorkflowAction in a given workflow
132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'app/models/sipity.rb', line 132 def WorkflowAction(input, workflow, &block) # rubocop:disable Naming/MethodName workflow_id = WorkflowId(workflow) result = case input when WorkflowAction input if input.workflow_id == workflow_id when String, Symbol WorkflowAction.find_by(workflow_id: workflow_id, name: input.to_s) end handle_conversion(input, result, :to_sipity_action, &block) end |
.WorkflowId(input, &block) ⇒ Object
Cast an object to a Workflow id rubocop:disable Metrics/MethodLength
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'app/models/sipity.rb', line 110 def WorkflowId(input, &block) # rubocop:disable Naming/MethodName result = case input when Sipity::Workflow input.id when Integer input when String input.to_i else if input.respond_to?(workflow_id) input.workflow_id else WorkflowId(Entity(input)) end end handle_conversion(input, result, :to_workflow_id, &block) end |
.WorkflowState(input, workflow, &block) ⇒ Object
Cast an object to a WorkflowState in a given workflow
148 149 150 151 152 153 154 155 156 157 |
# File 'app/models/sipity.rb', line 148 def WorkflowState(input, workflow, &block) # rubocop:disable Naming/MethodName result = case input when Sipity::WorkflowState input when Symbol, String WorkflowState.find_by(workflow_id: workflow.id, name: input) end handle_conversion(input, result, :to_sipity_workflow_state, &block) end |