Skip to content

Workflows

Justin Coyne edited this page May 7, 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 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

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 schema

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

The models

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

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]

The Rails server must be restarted after this change.

Loading workflows

solr_wrapper
fcrepo_wrapper
bin/rails hyrax:default_admin_set:create

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.

Create a new workflow.

curl https://raw.githubusercontent.com/pulibrary/plum/master/config/workflows/books_workflow.json \
   -o config/workflows/books_workflow.json
bin/rails hyrax:workflow:load

That doesn't work because the notification classes are missing. Take them out and try again.

Create a new admin set using that WF.

try it out.

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:)

Querying in solr

Custom notifications

Custom actions

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

Future enhancements:

  • Restrict worktype - workflow mapping.

Bugs:

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

Let's look at the data model.

  • Workflow
  • WorkflowProxy (proxy for a work)
  • State
  • Action
  • Responsibility
  • Agent (proxy for a user/group)
Clone this wiki locally