Right now if a dataset is added to a group, the resource is not added to the same group. This is a problem since they should share the same group permissions etc.

The solution is to check with hook_update for datasets and if a group is changing to also change all of the resources to the same group as well. This would best be done with job_scheduler since what if a dataset has hundreds of resources? A first stab at it would not necessarily need that.

Members fund testing for the Drupal project. Drupal Association Learn more


acouch’s picture

Title: groups: update make child » Make Sure Datasets and Resources are in the Same Group
Component: Code » DKAN Distro
uladzimir.karol’s picture

Status: Active » Needs work
753 bytes

In patch implementation:

  • update groups list for resource if list groups change for dataset
  • limit update resource 10
  • update data groups for resource in hook_node_update implementation

Patch for module dkan_datastore.

The first step of implementation.

acouch’s picture

Please create a patch against the dkan_datastore module. Thanks.

uladzimir.karol’s picture


uladzimir.karol’s picture

Status: Needs work » Needs review
uladzimir.karol’s picture

Status: Needs review » Needs work

Currently it is possible to set for resource only 2 datasets and only 2 groups. I'm working to make it possible while saving the resource to set goups dataset for resource and I have a problem. the limit for 2 groups prevents the correct work of the module if 2 datasets have more then 2 groups
Can I change the limit for number of groups for the field and to make it unlimited?
Or is this important for the logic of the program and cannot be changed?
In this case: what else can we do if 2 datasets have 3 groups or more?

acouch’s picture

I updated the cardinality to 1 for og_group_ref for datasets and resources. That should simplify things.

The above code worked, however I'm concerned about limiting the update to 10. But maybe that is good enough for now.

Can you do the following?

  • Move the code to dkan_dataset_groups.module
  • Make sure the code is reviewed with the coder module (there were spacing issues).
  • Check that $node->type is 'dataset'

If a resource is saved, check to see if it is connected to a dataset. If the dataset has a group then assign the group to the resource.

acouch’s picture

We discussed this with Vitaly, who was completely sober, so I'm not sure if I trust his guidance, but... we think it would be best to add an queue api operation if there are more than 10 resources attached to the dataset, see: http://pastebin.com/AhxRptc7

Please update the drupal_set_message to say "10 resources were changed to the updated group. The following resources were not updated. They will be updated 10 at a time on each cron run if you choose not to update them now [list of links to resources that were not updated."

acouch’s picture

Issue summary: View changes

changing desc

Krista Brenner’s picture

Issue summary: View changes
Issue tags: +Release 1.0
acouch’s picture

Status: Needs work » Fixed
Issue tags: -Release 1.0

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.