26 June, 2012

Removing Rogue Metadata from Workflows in DSpace

One of our DSpace Coordinators set up an item template, and mistakenly added text data to the date.issued field - at least, I'm giving him the benefit of the doubt ;)
The upshot of this was, when he got to "Accept Task" in the workflow, he was presented with a blank page and couldn't approve the submissions. So he called me. A few times. He COULD work out the workflow ID from the Task Pool page - and that was enough to be able to delete the rogue fields. I strongly suggested that he update the Item Template.
Here is the SQL I used - perhaps not the most elegant, but did the trick:

First, get metadata_field_id from given %ELEMENT% and %QUALIFIER%:

select metadata_field_id from metadatafieldregistry where element = '%ELEMENT%' and qualifier = '%QUALIFIER%' 

Then, given the %WORKFLOW_ID%, delete the relevant metadata field from the metadatavalue table:

delete from metadatavalue where metadata_field_id = %METADATA_FIELD_ID% and item_id = (select item_id from workflowitem where workflow_id = %WORKFLOW_ID%)

No comments:

Post a Comment