<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 14 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        color:black;
        mso-fareast-language:EN-US;}
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
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";
        color:black;
        mso-fareast-language:EN-US;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle21
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;
        mso-fareast-language:EN-US;}
span.EmailStyle24
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
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 bgcolor=white lang=EN-GB link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='color:#1F497D'>Eliseo,<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>I’d support Seb’s response – I always thought my way was ‘hacky’.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Maybe I need to write a tool to do this…<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Cheers,<br>John<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p>&nbsp;</o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext;mso-fareast-language:EN-GB'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext;mso-fareast-language:EN-GB'> eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] <b>On Behalf Of </b>Sebastien Francois<br><b>Sent:</b> 17 March 2014 12:05<br><b>To:</b> eprints-tech@ecs.soton.ac.uk<br><b>Subject:</b> [EP-tech] Re: Updating Subjects<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p>&nbsp;</o:p></p><div><p class=MsoNormal>Hola,<br><br>If I may add to this.... You shouldn't use direct SQL unless there are no other choices - this potentially breaks the relational model.<br><br>So instead, you should write a script that transfer objects from one subject id to another, using the EPrints API.<br><br>Seb.<br><br><br>On 17/03/14 09:53, John Salter wrote:<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal><span style='color:#1F497D'>Hi Eliseo,</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>There’s two sides to this:</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>- getting the new subjects created</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>- moving eprints from the old subjects to the new ones.</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>If possible, I’d look at getting the new subjects into order first – as you’ve already identified, either via the web interface or the import (you might want to look at the subject export too – which might be useful to do, add your new subjects and then re-import).</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>Creating a new set of nodes is (IMO) easier than trying to rework the existing ones as they are stored in the database as both child and parent trees, so you’d possibly have to make changes to stuff in all these tables:</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>subject</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>subject__index</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>subject__index_grep</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>subject__ordervalues_en</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>subject__rindex</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>subject_ancestors</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>subject_name_lang</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>subject_name_name</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>subject_parents</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>To move the eprints from one node to another, if it’s a straight swap (e.g. subjectid_A is replaced by subjected_1; subjectid_B is replaced by subjectid_2 etc.), it’s fairly easy to do in the database (you could even clone the eprint_subjects table and do the updates in the new copy to be on the safe side).</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>mysql&gt; UPDATE eprint_subjects SET subject = newSubjectID where subject = oldSubjectID;</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>I find the following query useful to see if there are any subjects use, but not defined:</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>mysql&gt; select count(*),&nbsp; subject, pos from eprint_subjects where subject NOT IN (select subjectid from subject) group by subject, pos;</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>Hope that helps a bit – someone else might have some better/easier ways of doing this!</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>Cheers,</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>John</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>&nbsp;</span><o:p></o:p></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";mso-fareast-language:EN-GB'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";mso-fareast-language:EN-GB'> <a href="mailto:eprints-tech-bounces@ecs.soton.ac.uk">eprints-tech-bounces@ecs.soton.ac.uk</a> [<a href="mailto:eprints-tech-bounces@ecs.soton.ac.uk">mailto:eprints-tech-bounces@ecs.soton.ac.uk</a>] <b>On Behalf Of </b>Eliseo Gatchalian<br><b>Sent:</b> 17 March 2014 03:06<br><b>To:</b> <a href="mailto:eprints-tech@ecs.soton.ac.uk">eprints-tech@ecs.soton.ac.uk</a><br><b>Subject:</b> [EP-tech] Updating Subjects</span><o:p></o:p></p></div></div><p class=MsoNormal>&nbsp;<o:p></o:p></p><p class=MsoNormal><span lang=EN-NZ>Hi,</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-NZ>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-NZ>I know that we can add and edit the subjects by logging in as admin and can also import a subject_xml file, but&nbsp; If we are to merge some subjects with different subject code into one, is there an automatic way to update the subject codes for the items already submitted in the archive?</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-NZ>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-NZ>I saw the eprints_subject table wherein we can replace the subject field with the new codes and update the items but I’m not sure if there are anything else that we need to update?</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-NZ>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-NZ>Thanks!</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-NZ>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-NZ style='font-size:10.0pt;font-family:"Arial","sans-serif";mso-fareast-language:EN-NZ'><br>&nbsp;</span><o:p></o:p></p><table class=MsoNormalTable border=0 cellpadding=0 width="97%" style='width:97.0%'><tr><td nowrap valign=bottom style='padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal><b><span style='font-size:7.5pt;font-family:"Arial","sans-serif";mso-fareast-language:EN-NZ'>Ellis Gatchalian</span></b><span style='font-size:7.5pt;font-family:"Arial","sans-serif";mso-fareast-language:EN-NZ'><br>Systems Librarian<br>Wintec<br>Private Bag 3036, Waikato Mail Centre, Hamilton 3240<br>Phone: +64-(0)7-834 8800 ext 8633<br>Fax: +64-(0)7-838 8257</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:7.5pt;font-family:"Arial","sans-serif";mso-fareast-language:EN-NZ'>Email: <a href="mailto:ellis.gatchalian@wintec.ac.nz">ellis.gatchalian@wintec.ac.nz</a></span><o:p></o:p></p><p class=MsoNormal><span style='font-size:7.5pt;font-family:"Arial","sans-serif";mso-fareast-language:EN-NZ'>Web: <a href="http://www.wintec.ac.nz/"><span style='color:#333333'>http://www.wintec.ac.nz/</span></a></span><o:p></o:p></p></td><td valign=bottom style='padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal align=right style='text-align:right'><span style='font-size:10.0pt;font-family:"Arial","sans-serif";mso-fareast-language:EN-NZ'><img border=0 width=206 height=94 id="Picture_x0020_3" src="cid:image001.gif@01CF41DC.21FD4250" alt=WIN01></span><o:p></o:p></p></td></tr><tr><td style='padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#333333;mso-fareast-language:EN-NZ'>&nbsp;</span><o:p></o:p></p></td><td style='padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#333333;mso-fareast-language:EN-NZ'>&nbsp;</span><o:p></o:p></p></td></tr></table><p class=MsoNormal><span lang=EN-NZ style='mso-fareast-language:EN-NZ'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-NZ>&nbsp;</span><o:p></o:p></p><div class=MsoNormal align=center style='text-align:center'><span lang=EN-NZ style='font-size:12.0pt'><hr size=2 width="100%" align=center></span></div><div><p><span lang=EN-NZ style='font-size:8.0pt;font-family:"Calibri","sans-serif";color:#777777'>This electronic mail transmission is intended for the named recipients only. It may contain private and confidential information. If this has come to you in error you must take no action based upon it, nor must you copy it or show it to anyone; please telephone or email the sender at Wintec immediately and return the original email. We cannot accept any liability for any loss or damage sustained as a result of software viruses. It is your responsibility to carry out such virus checking as is necessary before opening any attachment which may be included with this message.</span><o:p></o:p></p></div><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:EN-GB'><br><br><br><o:p></o:p></span></p><pre>*** Options: <a href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a><o:p></o:p></pre><pre>*** Archive: <a href="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</a><o:p></o:p></pre><pre>*** EPrints community wiki: <a href="http://wiki.eprints.org/">http://wiki.eprints.org/</a><o:p></o:p></pre><pre>*** EPrints developers Forum: <a href="http://forum.eprints.org/">http://forum.eprints.org/</a><o:p></o:p></pre></blockquote><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:EN-GB'><o:p>&nbsp;</o:p></span></p></div></body></html>