<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Menlo-Regular;
panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle19
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hi Bobbi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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: <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">select CONCAT('/config/enumeration_values/', ev.id) as URI<o:p></o:p></p>
<p class="MsoNormal"> , position<o:p></o:p></p>
<p class="MsoNormal"> , value<o:p></o:p></p>
<p class="MsoNormal">from enumeration_value ev<o:p></o:p></p>
<p class="MsoNormal">WHERE ev.enumeration_id = whatever the enumeration is for extent types in your instance<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">you can then change the positions in the 2<sup>nd</sup> column to whatever you want, and use that CSV as the input for the script at this link:<o:p></o:p></p>
<p class="MsoNormal"><a href="https://github.com/ucancallmealicia/archivesspace-api-public/blob/master/update_enum_val_positions.py">https://github.com/ucancallmealicia/archivesspace-api-public/blob/master/update_enum_val_positions.py</a>
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I haven’t used this script in production, but it has worked perfectly well for me when playing around with our test data.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hope this helps.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Alicia<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Alicia Detelich<o:p></o:p></p>
<p class="MsoNormal">Archivist<o:p></o:p></p>
<p class="MsoNormal">Manuscripts and Archives<o:p></o:p></p>
<p class="MsoNormal">Yale University Libraries<o:p></o:p></p>
<p class="MsoNormal">alicia.detelich@yale.edu<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> archivesspace_users_group-bounces@lyralists.lyrasis.org [mailto:archivesspace_users_group-bounces@lyralists.lyrasis.org]
<b>On Behalf Of </b>Majewski, Steven (sdm7g)<br>
<b>Sent:</b> Wednesday, October 18, 2017 3:30 PM<br>
<b>To:</b> Archivesspace Users Group <archivesspace_users_group@lyralists.lyrasis.org><br>
<b>Subject:</b> Re: [Archivesspace_Users_Group] batch re-ordering of controlled value lists; script/plugin, anyone?<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Merging enumeration values, on the other hand, is more complicated, and I would leave it to the frontend/backend, and not try MySQL surgery. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">We are doing a similar controlled value cleanup. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">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. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Does the merge operation also only merge enumeration_values for the current repository ? <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">( I *think* that is the case, but I’m not sure. ) <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Perhaps, if you’re logged in on an admin account, it should have an option for searching across repositories. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">— Steve Majewski<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On Oct 18, 2017, at 2:06 PM, Fox, Bobbi <<a href="mailto:bobbi_fox@harvard.edu">bobbi_fox@harvard.edu</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">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?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Bobbi<o:p></o:p></p>
</div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Menlo-Regular",serif">_______________________________________________<br>
Archivesspace_Users_Group mailing list<br>
</span><a href="mailto:Archivesspace_Users_Group@lyralists.lyrasis.org"><span style="font-size:10.5pt;font-family:"Menlo-Regular",serif;color:#954F72">Archivesspace_Users_Group@lyralists.lyrasis.org</span></a><span style="font-size:10.5pt;font-family:"Menlo-Regular",serif"><br>
</span><a href="http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group"><span style="font-size:10.5pt;font-family:"Menlo-Regular",serif;color:#954F72">http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group</span></a><o:p></o:p></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>