[Archivesspace_Users_Group] batch re-ordering of controlled value lists; script/plugin, anyone?

Detelich, Alicia alicia.detelich at yale.edu
Wed Oct 18 16:00:16 EDT 2017


Hi Bobbi,

In case you want to avoid making the change via the database, I have a python script that will do what you are looking for, using a CSV as input. If you can get a list of enumeration value URIs from the database and output it to a CSV, using something like:

select CONCAT('/config/enumeration_values/', ev.id) as URI
                , position
                , value
from enumeration_value ev
WHERE ev.enumeration_id = whatever the enumeration is for extent types in your instance

you can then change the positions in the 2nd column to whatever you want, and use that CSV as the input for the script at this link:
https://github.com/ucancallmealicia/archivesspace-api-public/blob/master/update_enum_val_positions.py

I haven’t used this script in production, but it has worked perfectly well for me when playing around with our test data.

Hope this helps.

Alicia

Alicia Detelich
Archivist
Manuscripts and Archives
Yale University Libraries
alicia.detelich at yale.edu

From: archivesspace_users_group-bounces at lyralists.lyrasis.org [mailto:archivesspace_users_group-bounces at lyralists.lyrasis.org] On Behalf Of Majewski, Steven (sdm7g)
Sent: Wednesday, October 18, 2017 3:30 PM
To: Archivesspace Users Group <archivesspace_users_group at lyralists.lyrasis.org>
Subject: Re: [Archivesspace_Users_Group] batch re-ordering of controlled value lists; script/plugin, anyone?


It looks like the positioning would be very simple to do in mysql as you only have to modify the position value in the table — no complicated joins required. You could do it interactively with a GUI frontend like Sequel Pro or MySQLWorkbench. Just make sure you don’t leave any duplicate positions.

If you already have a table of enum values and new positions, and you want to do it programmatically, then you can load those pairs as a temporary table, and create a function return position given value string, and use that function in your update statement rather than try to explicitly iterate over the tables.

Merging enumeration values, on the other hand, is more complicated, and I would leave it to the frontend/backend, and not try MySQL surgery.

We are doing a similar controlled value cleanup.
The issue we’re having is that we have several repositories, and the frontend view and list of number of related items and links are repository based, so cleanup requires tediously switching between repositories trying to find the resources that are still linked to those values.

Does the merge operation also only merge enumeration_values for the current repository ?
( I *think* that is the case, but I’m not sure. )

Perhaps, if you’re logged in on an admin account, it should have an option for searching across repositories.


— Steve Majewski


On Oct 18, 2017, at 2:06 PM, Fox, Bobbi <bobbi_fox at harvard.edu<mailto:bobbi_fox at harvard.edu>> wrote:

In the course of adapting ArchivesSpace to Harvard’s needs, we’ve ended up with some very weedy controlled values lists (extent type > 200 values! -- of course, some of them need to be removed) with arbitrary positioning.  Our support team is tasked with the job of wrangling the lists with a defined order, and the interactive “move up/down one position at a time, wait for the server to refresh, etc.” is really tedious.

Has anyone written a script/created a plugin that would do this with less effort?  I’m inclined to do it at the mysql level, rather than write an extension to the backend/controller/enumeration.rb, but maybe someone has done this already?

Thanks,
Bobbi
_______________________________________________
Archivesspace_Users_Group mailing list
Archivesspace_Users_Group at lyralists.lyrasis.org<mailto:Archivesspace_Users_Group at lyralists.lyrasis.org>
http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20171018/ed914261/attachment.html>


More information about the Archivesspace_Users_Group mailing list