Module: Hyrax::Workflow

Defined in:
app/services/hyrax/workflow/activate_object.rb,
app/services/hyrax/workflow/workflow_schema.rb,
app/services/hyrax/workflow/method_generator.rb,
app/services/hyrax/workflow/permission_query.rb,
app/services/hyrax/workflow/workflow_factory.rb,
app/services/hyrax/workflow/deactivate_object.rb,
app/services/hyrax/workflow/workflow_importer.rb,
app/services/hyrax/workflow/status_list_service.rb,
app/services/hyrax/workflow/action_taken_service.rb,
app/services/hyrax/workflow/notification_service.rb,
app/services/hyrax/workflow/permission_generator.rb,
app/services/hyrax/workflow/abstract_notification.rb,
app/services/hyrax/workflow/deposited_notification.rb,
app/services/hyrax/workflow/notification_generator.rb,
app/services/hyrax/workflow/grant_edit_to_depositor.rb,
app/services/hyrax/workflow/grant_read_to_depositor.rb,
app/services/hyrax/workflow/state_machine_generator.rb,
app/services/hyrax/workflow/workflow_action_service.rb,
app/services/hyrax/workflow/sipity_actions_generator.rb,
app/services/hyrax/workflow/revoke_edit_from_depositor.rb,
app/services/hyrax/workflow/pending_review_notification.rb,
app/services/hyrax/workflow/changes_required_notification.rb,
app/services/hyrax/workflow/workflow_permissions_generator.rb,
app/services/hyrax/workflow/invalid_state_removal_exception.rb,
app/services/hyrax/workflow/notification_configuration_parameter.rb

Defined Under Namespace

Modules: ActivateObject, DeactivateObject, GrantEditToDepositor, GrantReadToDepositor, PermissionQuery, RevokeEditFromDepositor Classes: AbstractNotification, ActionTakenService, ChangesRequiredNotification, DepositedNotification, InvalidStateRemovalException, MethodGenerator, NotificationConfigurationParameter, NotificationGenerator, NotificationService, PendingReviewNotification, PermissionGenerator, SipityActionsGenerator, StateMachineGenerator, StatusListService, WorkflowActionService, WorkflowFactory, WorkflowImporter, WorkflowPermissionsGenerator

Constant Summary collapse

WorkflowSchema =

Responsible for describing the JSON schema for a Workflow.

The ‘workflows name` defines the name of the Sipity::Workflow. The `workflows actions` defines the actions that can be taken in the given states (e.g. :from_states) by the given :roles. The `workflows actions transition_to` defines the state to which we transition when the action is taken. The `workflows actions notifications` defines the notifications that should be sent when the action is taken.

See Also:

Dry::Validation.Schema do
  configure do
    def self.messages
      Dry::Validation::Messages.default.merge(
        en: { errors: { constant_name?: 'must be an initialized Ruby constant' } }
      )
    end

    def constant_name?(value)
      value.constantize
      true
    rescue NameError
      false
    end
  end

  required(:workflows).each do
    required(:name).filled(:str?) # Sipity::Workflow#name
    optional(:label).filled(:str?) # Sipity::Workflow#label
    optional(:description).filled(:str?) # Sipity::Workflow#description
    optional(:allows_access_grant).filled(:bool?) # Sipity::Workflow#allows_access_grant?
    required(:actions).each do
      schema do
        required(:name).filled(:str?) # Sipity::WorkflowAction#name
        required(:from_states).each do
          schema do
            required(:names) { array? { each(:str?) } } # Sipity::WorkflowState#name
            required(:roles) { array? { each(:str?) } } # Sipity::Role#name
          end
        end
        optional(:transition_to).filled(:str?) # Sipity::WorkflowState#name
        optional(:notifications).each do
          schema do
            required(:name).value(:constant_name?) # Sipity::Notification#name
            required(:notification_type).value(included_in?: Sipity::Notification.valid_notification_types)
            required(:to) { array? { each(:str?) } }
            optional(:cc) { array? { each(:str?) } }
            optional(:bcc) { array? { each(:str?) } }
          end
        end
        optional(:methods) { array? { each(:str?) } } # See it_behaves_like "a Hyrax workflow method"
      end
    end
  end
end