Closed laritakr closed 7 years ago
Possibly returning wrong values here: https://github.com/samvera/hyrax/blob/master/app/services/hyrax/workflow/notification_service.rb#L50
I like to see the SQL for https://github.com/samvera/hyrax/blob/master/app/services/hyrax/workflow/permission_query.rb#L266-L271 so this snippet was taken from one of the specs using sub_query_for_user.to_sql
:
SELECT CAST("sipity_agents"."proxy_for_id" AS integer)
FROM "sipity_agents"
WHERE (
"sipity_agents"."id" IN (
SELECT "sipity_workflow_responsibilities"."agent_id"
FROM "sipity_workflow_responsibilities"
WHERE "sipity_workflow_responsibilities"."workflow_role_id" IN (
SELECT "sipity_workflow_roles"."id"
FROM "sipity_workflow_roles"
WHERE "sipity_workflow_roles"."role_id" IN (1)
)
) OR "sipity_agents"."id" IN (
SELECT "sipity_entity_specific_responsibilities"."agent_id"
FROM "sipity_entity_specific_responsibilities"
WHERE "sipity_entity_specific_responsibilities"."workflow_role_id" IN (
SELECT "sipity_workflow_roles"."id"
FROM "sipity_workflow_roles"
WHERE "sipity_workflow_roles"."role_id" IN (1)
) AND "sipity_entity_specific_responsibilities"."entity_id" = '1'
)
) AND "sipity_agents"."proxy_for_type" = 'User'
It difficult to identify an AdminSet
entity in this query. It seems the use of the sipity_workflow_responsibilities
and sipity_workflow_roles
might be global things, whereas the sipity_entity_specific_responsibilities
is specific to an "entity", and these two things are combined with an OR
relation. Perhaps what we need is a WHERE
with an AND
instead of an OR
to combine the sipity_workflow_responsibilities
and the sipity_entity_specific_responsibilities
, but the entity
must be the AdminSet
that a new Work
belongs to. But I'm totally guessing at this point, because I don't understand how sipity_workflow_responsibilities
and and sipity_workflow_roles
correspond to user management roles for an AdminSet
.
@darrenleeweber You're right that this query doesn't involve AdminSets at all. The Sipity internals work independent of AdminSets, and we have yet to reconcile the two models for assigning roles (the ones defined in Sipity workflows, and the ones used for AdminSets). The Notre Dame team has been working on some documentation that will unify/clarify the roles used within Hyrax. @laritakr has been a key player there.
It's complicated further by the fact that the roles defined in the default workflows bundled with Hyrax map cleanly to the AdminSet roles, but downstream users are free to define their own roles that do not map cleanly to AdminSets.
Tagging in @jeremyf and @jcoyne, the two folks who best understand this particular module.
I’ll try to note how I understand the problem, at the moment, for the workflow permission problem:
Agent
(aka User
) with a Responsibility
(using a preferred notification method)Responsibility
: EntitySpecificResponsibility
and WorkflowResponsibility
WorkflowResponsibility
is independent of any Entity
in the workflow (and the state of the entity in the workflow)EntitySpecificResponsibility
is independent of any type of Workflow
Agent
s who have one or both of these Responsibility
types; that is, the notifications are not restricted to Agents
who must have both responsibilities.In this issue, the “expected behavior” is:
Anyone with the workflow role of reviewer on an admin set should be notified of works submitted to that admin set which they should review.
So, it seems like the “expected behavior” is requesting something that is not in the Sipity design; that is, it wants a combination of a WorkflowResponsibility
and an EntitySpecificResponsibility
. In other words, the issue requests something like an EntitySpecificWorkflowResponsibility
. Perhaps this can be defined as all the Agent
s who must have a Responsibility
in both the WorkflowResponsibility
and the EntitySpecificResponsibility
when the Entity
is an AdminSet
and when the Workflow
is "adding a work to the admin set".
Moreover, it might require a complex definition of Entity
that involves a parent-child relationship between an AdminSet
and all the Work
s that are associated with it. Maybe this involves definition of a specific workflow that is just "add work to admin set"?
Also, I’m starting to wonder whether this might require dynamic creation of a new Workflow
that is specific to an AdminSet
. That is, the workflow will be a record in the workflows table and it will be prefixed with some identifier that connects it to a specific Entity
, i.e. the AdminSet
. This results in a proliferation of workflows.
This is likely some kind of UI features for dynamic selection/creation of workflows on an AdminSet
entity and somehow define how each User/Role on the AdminSet
is attached to the workflow. The manager of the admin set can choose pre-existing generic workflows or create a new one based on the generic options or create a new one from scratch.
Notes on reproducing the bug noted in this issue:
solr_wrapper
and fcrepo_wrapper
in separate windowsbundle exec rake engine_cart:server
.internal_test_app/config/role_map.yml
)
admin@example.com
Administrative Set
(called Notifications-A
)
Administrative Sets
in the left side panelWorkflow
tab has two options, a default
and a one-step-mediated-deposit
workflow; leave the selection on the default
workflowadmin@example.com
user who created the new admin-set has all of the Workflow Roles
that are possible for this admin-set (this can be seen by clicking on the Workflow Roles
navigation item in the left side panel, i.e. /admin/workflow_roles?locale=en
)
Notifications-A - approving (default)
Notifications-A - depositing (default)
Notifications-A - managing (default)
Notifications-A - approving (one_step_mediated_deposit)
Notifications-A - depositing (one_step_mediated_deposit)
Notifications-A - managing (one_step_mediated_deposit)
Administrative Set
(called Notifications-B
)
Workflow Roles
admin@example.com
user now has all workflow roles for both admin-set objectsX
option to remove any of these workflow roles for that user; this UI feature may provide the functionality to resolve this issue; that is, just remove the rules that are not required.
admin@example.com
user.internal_test_app/config/role_map.yml
file to add users, e.g.
development:
admin:
- admin@example.com
depositor:
- depositorA@example.com
- depositorB@example.com
bundle exec rake engine_cart:server
Work
object until they are added to an admin-set by the manager of an admin-setadmin@example.com
and go to the Administrative Sets
pageNotifications-A
admin-set and click on Edit
Participants
paneldepositorA@example.com
, with workflow role: Depositor
, and click Add
depositorB@example.com
to Notifications-B
.Workflow Roles
page does not update these new role allocationsdepositora@example.com | No roles
depositorb@example.com | No roles
depositora@example.com | Notifications-A - depositing (default)
depositorb@example.com | Notifications-B - depositing (default)
admin@example.com
and login for depositorA@example.com
Works
and note there are now buttons to Create batch of works
and Add new work
Add new work
, select Generic Work
and click on Create work
Public
, check the deposit agreement and click the Save
buttonNoticiations-A
admin-set, so the new work should have the Relationships
content as such: In Administrative Set: Notifications-A
depositorA@example.com
and login for admin@example.com
Your Activity > Notifications
(i.e. /notifications?locale=en
)Review Submissions: Under Review
Review Submissions: Published
.internal_test_app/config/role_map.yml
file to add a manager, e.g.
development:
[etc. as above, plus:]
manager:
- managerB@example.com
managerB@example.com
Notifications-C
) and select the one_step_mediated_deposit
workflow this time, then add depositorB as a depositor and add managerB as a manager and save the admin-set; then the Workflow Roles
looks like this:
Notifications-C
depositorB
user and go to Works
to add a new generic workRelationships
tab on the new work to ensure it is assigned to Notifications-C
(otherwise follow the instructions above to create a new work)Workflow Roles - Pending review
and the notification icon for the depositorB
user has a red box highlighting the number 1 in it. The notification page contains a message: "{date-time} | Deposit needs review | Workflow Roles ({object-id}) was deposited by {user} and is awaiting approval"managerB
and notice the notification icon highlights 1 new notification (which reads as above)Tasks > Review Submissions
in the left side panel and notice there is a new review itemadmin
user and also note the same notification and the presence of the same entry in the Review Submissions
pagemanagerB
, go to review submissions, click on the Work
and (at present, to be modified by better UI design/layout) there is a review panel at the very bottom of the page (should be moved above the work panel); open the Review and Approval
panel and select approve
and click submit, then the status should change from pending review to deposited and there is a new notification message.admin
and notice the same notification messagemanagerB
does not recieve any notifications when a work is added to the new admin-set, but the admin
user should get notifications
Notifications-D
say and ensure it is using the one_step_mediated_deposit
workflowdepositorB
and deposit a new work into Notifications-D
and note the new notification that it is pending reviewdepositorA
and notice there are no notifications for this usermanagerB
and notice there is a new notification about the submission on Notifications-D
although managerB
has no workflow roles on this admin-set and cannot see this admin-set in the Administrative Sets
UI listing; also, managerB
has a new item in the Review Submissions
page, but when this user views the new submission, there are no details and there is no Review and Approve
panel available; the item appears with an alert saying "The work is not currently available because it has not yet completed the approval process". THIS CONFIRMS THE BEHAVIOR NOTED IN THIS ISSUEadmin
and check the Workflow Roles
page and note that managerB
has no roles on the new Notifications-D
admin-set; also note that the admin
user does get notification about review of this new submission and is able to review and approve it; so approve it and note the status changes to Deposited
and a new notification is issued about this approval (and, yes, managerB
should not, but does get this notification too)
Descriptive summary
Anyone with reviewer role on an admin set is getting the notifications for works submitted on ALL admin sets. This issue exists in both the 1-0 stable and the master branch.
Rationale
Users with the approving role should only get useful notifications.
Expected behavior
Anyone with the workflow role of reviewer on an admin set should be notified of works submitted to that admin set which they should review.
Actual behavior
Anyone with the workflow role of reviewer on any admin set are getting notifications of works submitted to all admin sets.
Steps to reproduce the behavior
I created two separate admin sets and 6 users with varying participant roles and workflow roles, and submitted works from each user who was able to submit to each admin set. Reviewers for only admin set 1 received notifications for works submitted to both admin sets.
Spreadsheet of users, roles, and what they were able to do in the app.