Skip to content

Workflows

Justin Coyne edited this page May 8, 2017 · 19 revisions

9:45 - 11:00, Break, 11:15 - 12:30

git checkout day3/workflow-start

Admin sets

  • Introduced in Sufia 7.3
  • AdminSets are persisted in the repository
  • Each work must belong to exactly 1 admin set
  • "default" admin set

Permission templates

  • What form values are allowed for visibility/embargo
  • A "template" of user permissions to copy onto new members
  • PermissionTemplates are persisted in the database

Workflow as a directed graph

A directed graph described in JSON

$ ls config/workflows/
default_workflow.json		mediated_deposit_workflow.json

Open config/workflows/default_workflow.json Open config/workflows/mediated_deposit_workflow.json

The JSON template schema

https://github.com/projecthydra-labs/hyrax/blob/master/app/services/hyrax/workflow/workflow_schema.rb

Loading workflows

solr_wrapper
fcrepo_wrapper
bin/rails hyrax:default_admin_set:create

The models

  • Sipity::Workflow
  • Sipity::WorkflowAction
  • Sipity::WorkflowState
  • Sipity::Role
  • Sipity::Notification
  • Sipity::Method
  • Sipity::Entity
  • Sipity::Agent

The relationships

  • Workflow Responsibility and Entity Specific Responsibility

Admin access

Let's see how this functions. First we grant ourselves admin access.

# config/role_map.yml

development:
  admin:
    - [email protected]

Re/start the rails server after changing the role_map.yml

rails server

Create a new admin set

Set up a new admin set and make it mediated_deposit. Grant deposit access to the registered group.

Set up a workflow role

Select you admin user and the approving role under the name of the admin set you just created.

Deposit a work into the new admin set

Sign out. Create a new user. With that new user, create a new public Musical Work. Flip to the relationships tab. See how sharing goes away. Make a deposit in the mediated group.

Examine the work

Login as another user and see that it's not visible. Login as reviewer and go to the "Review Submissions tab" and see that it's visible. Approve it. Login as another user and see it's now visible.

JSON files are templates for workflows

We need to have each admin set have it’s own workflows (even if they’re made from the same template) because we might need to give a different set of agents access per admin set.

bin/rails hyrax:workflow:load

Custom methods

  • Hyrax::Workflow::ActivateObject
  • Hyrax::Workflow::DeactivateObject
  • Hyrax::Workflow::GrantEditToDepositor
  • Hyrax::Workflow::GrantReadToDepositor

https://github.com/projecthydra-labs/hyrax/blob/master/app/services/hyrax/workflow/action_taken_service.rb#L45-L47

Custom notifications

Exercise: Create a new workflow.

Your institution is going to begin ingesting manuscripts into the repo. The product owner has requested a multi step workflow:

  • Deposit
  • Metadata Review
  • Final Review

The object should not be visible to the public until final review is complete.

8 Query methods

https://github.com/projecthydra-labs/hyrax/blob/1e504c200fd9c39120f514ac33cd42cd843de9fa/app/services/hyrax/workflow/permission_query.rb

scope_permitted_workflow_actions_available_for_current_state(user:, entity:)
scope_agents_associated_with_entity_and_role(entity:, role:)
scope_roles_associated_with_the_given_entity(entity:)
authorized_for_processing?(user:, entity:, action:)
scope_processing_agents_for(user:)
scope_entities_for_the_user(user:)
scope_users_for_entity_and_roles(entity:, roles:)
scope_processing_workflow_roles_for_user_and_entity(user:, entity:)

Workflows in solr

Suppressed flag.

Indexing https://github.com/projecthydra-labs/hyrax/blob/1e504c200fd9c39120f514ac33cd42cd843de9fa/app/indexers/hyrax/indexes_workflow.rb#L20-L26

Querying https://github.com/projecthydra-labs/hyrax/blob/master/app/services/hyrax/workflow/status_list_service.rb#L37-L47

WorkflowActionForm

Workflow::WorkflowActionService.run(subject: subject,
                                    action: sipity_workflow_action,
                                    comment: comment)

https://github.com/projecthydra-labs/hyrax/blob/1e504c200fd9c39120f514ac33cd42cd843de9fa/app/forms/hyrax/forms/workflow_action_form.rb

Exercise: Add an action

The product owner has requested that "final approval" should be logged.

Exercise: Add a notification

The product owner has requested that the final approver be notified after metadata approval.

Future enhancements:

  • Restrict worktype - workflow mapping.

Bugs:

  • Depositor can't edit when something is sent back.