<html><head>

<meta name="Generator" content="Novell Groupwise Client (Version 14.0.1  Build: 117118)">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body style="font: 10pt/normal Segoe UI; margin: 16px 16px 4px; font-size-adjust: none; font-stretch: normal;"><div class="GroupWiseMessageBody" id="GroupWiseSection_1442944310000_Andy.Reid@lshtm.ac.uk_E7E91160180E0000BAA6000000100002_"><div>Just for the record, yes, that bit of XML does work - it really was that simple :-)&nbsp; </div><div><br></div><div>&lt;/FamousLastWords&gt;</div><div><br></div><div>Andy</div><div><br></div><div>barebones TEST Script:&nbsp; Minimal error checking or safety checks </div><div>Would need another section to set &lt;metadata-visibility&gt; on the old ID</div><div>================================================================8&lt;</div><div>&lt;?php<br># Usage: <a href="http://foo.bar.ac.uk/publications/utils/y_succeeds_x.php?oldID=1111&amp;newID=2222">http://foo.bar.ac.uk/publications/utils/y_succeeds_x.php?oldID=1111&amp;newID=2222</a><br><br></div><div>$tmpDIR = "/tmp/";</div><div>$username='xxxxxxxxxxx';$password='yyyyyyyyyyyy';&nbsp; </div><div>$oldID=$_REQUEST['oldID'];<br>$newID=$_REQUEST['newID'];</div><div><br></div><div><br></div><div><br></div><div>$XML=&lt;&lt;&lt; EOX<br>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br>&lt;eprints xmlns="<a href="http://eprints.org/ep2/data/2.0">http://eprints.org/ep2/data/2.0</a>"&gt;<br>&nbsp;&nbsp;&nbsp; &lt;eprint id="<a href="http://foo.bar.ac.uk/id/eprint/$newID">http://foo.bar.ac.uk/id/eprint/$newID</a>"&gt;&lt;!-- not sure this is necessary, but haven't tested without it - I think the <!--StartFragment--> CURLOPT_URL may be sufficient —&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;eprintid&gt;$newID&lt;/eprintid&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!--&nbsp; ditto&nbsp;&nbsp; —&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;succeeds&gt;$oldID&lt;/succeeds&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/eprint&gt;<br>&lt;/eprints&gt;<br>EOX;</div><div><div><br></div><div>$ch = curl_init();<br>curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);</div></div><div>$tmpFILESIZE=strlen($XML);<br>$tmpFILE=$tmpDIR.$newID.'_succeeds_'.$oldID.'.xml';<br>file_put_contents($tmpFILE,$XML) or die("unable to write to file $tmpFILE");<br>curl_setopt($ch, CURLOPT_PUT,1);<br>&nbsp;$handle = fopen($tmpFILE, "r");<br>curl_setopt($ch,CURLOPT_INFILE,$handle);<br>curl_setopt($ch,CURLOPT_INFILESIZE,$tmpFILESIZE);</div><div><br></div><div>curl_setopt($ch, CURLOPT_URL, "<a href="http://eprints.foo.bar.ac.uk/id/eprint/$newID">http://eprints.foo.bar.ac.uk/id/eprint/$newID</a>");</div><div><br></div><div>curl_setopt($ch, CURLOPT_HEADER, 1);</div><div><br></div><div>if(!($newID &amp;&amp; $oldID) ){die( "Needs old and new eprint IDs");}&nbsp; # but doesn't check that either eprint ID actually exists on the server!</div><div><br></div><div>$pkgheader=Array('X-Packaging: <a href="http://eprints.org/ep2/data/2.0'">http://eprints.org/ep2/data/2.0'</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Content-Type: text/xml',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Metadata-Relevant: true',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'X-Verbose: true' ); #,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>curl_setopt($ch,CURLOPT_HTTPHEADER,$pkgheader);</div><div><br></div><div><br>#########################################################<br>($result=curl_exec($ch) )|| die( "curl_exec failed: ". curl_error($ch));<br>#########################################################</div><div><br></div><div>echo "RESULT=". $result;</div><div><br></div><div><br>curl_close($ch);<br>fclose($handle);<br>unlink($tmpFILE);</div><div><br></div><div>?&gt;</div><div><br></div><div class="GroupWiseMessageBody" id="GroupWiseSection_1442840917000_Andy.Reid@lshtm.ac.uk_E7E91160180E0000BAA6000000100002_"><span class="GroupwiseReplyHeader">&gt;&gt;&gt; "Andy Reid" &lt;Andy.Reid@lshtm.ac.uk&gt; 21 September 2015 15:11 &gt;&gt;&gt;<br></span><div>Hi,</div><div>I'm trying to work out how to thread two&nbsp;eprints so that I can merge the Accepted Manuscript&nbsp;record with Final published version, given that I have two separate systems feeding&nbsp;into the repository -&nbsp; one feeding&nbsp;Manuscripts, one harvesting published metadata from PubMed etc.&nbsp; I've looked at what happens when you create a linked new version of a record, with the &lt;succeeds&gt;&nbsp;set on the&nbsp;new record, and &lt;<span style='font: 12px/16.8px Consolas, "Liberation Mono", Menlo, Courier, monospace; color: rgb(24, 54, 145); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: pre; widows: 1; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;'>metadata_visibility&gt; set&nbsp;to no-search</span>&nbsp; on the old one. I'm in the slightly different position of wanting to merge two records once they are in the repository, but it seems like those are the fields I need to tweak. &nbsp;I've looked at the code in <!--StartFragment--><a href="https://github.com/eprints/eprints/blob/3.3/perl_lib/EPrints/DataObj/EPrint.pm">https://github.com/eprints/eprints/blob/3.3/perl_lib/EPrints/DataObj/EPrint.pm</a>&nbsp;</div><div>to see the various in_thread manipulation functions, and can just about follow them.&nbsp; </div><div><br></div><div>What I can't find is an admin utility that says 'Merge these two records, making this one the version of record, and retaining that one as an earlier version.'&nbsp; Am I not looking hard enough?</div><div><br></div><div>What I might also want to do is to&nbsp;trigger this from the external systems, via SWORD, sending a couple of minimal XML packages to modify each of the records:</div><div><br></div><div><div style="color: blue; font-weight: normal; margin-left: -4em;" xmlns="http://www.w3.org/1999/xhtml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;<style xmlns="http://www.w3.org/1999/xhtml">@namespace html url(http://www.w3.org/1999/xhtml); :root {                       font:small Verdana;        font-weight: bold;         padding: 2em;              padding-left:4em;       }                          * {                           display: block;            padding-left: 2em;      }                          html|style {                  display: none;          }                          html|span, html|a {           display: inline;           padding: 0;                font-weight: normal;       text-decoration: none;  }                          html|span.block {             display: block;         }                          *[html|hidden],            span.block[html|hidden] {     display: none;          }                          .expand {                     display: block;         }                          .expand:before {              content: '+';              color: red;                position: absolute;        left: -1em;             }  .collapse {                   display: block;         }                          .collapse:before {            content: '-';              color: red;                position: absolute;        left:-1em;              }                         </style></div><a class="collapse" style="color: blue; margin-left: -2em; position: relative;" href="file:///C:/Users/EADMAREI/Downloads/lshtmtest-eprint-991329.xml#" xmlns="http://www.w3.org/1999/xhtml">&lt;<span style="color: rgb(153, 0, 0);">eprints</span> <span style="color: red;">xmlns</span>="<span style="color: red; font-weight: bold;">http://eprints.org/ep2/data/2.0</span>"&gt;</a>&lt;<span style="color: rgb(153, 0, 0);">eprint</span> <span style="color: rgb(153, 0, 0);">id</span>="<span style="color: black; font-weight: bold;">http://blah.ac.uk/id/eprint/991329</span>"&gt;<eprint id="http://lshtmtest.da.ulcc.ac.uk/id/eprint/991329"><a style="color: blue; margin-left: -2em;" xmlns="http://www.w3.org/1999/xhtml">&lt;<span style="color: rgb(153, 0, 0);">eprintid</span>&gt;</a>991329<span style="color: blue;" xmlns="http://www.w3.org/1999/xhtml">&lt;/<span style="color: rgb(153, 0, 0);">eprintid</span>&gt;</span><span style="color: blue;" xmlns="http://www.w3.org/1999/xhtml">&lt;<span style="color: rgb(153, 0, 0);">succeeds</span>&gt;</span><span style="color: blue;" xmlns="http://www.w3.org/1999/xhtml">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 991328</span><span style="color: blue;" xmlns="http://www.w3.org/1999/xhtml"><span style="color: blue;" xmlns="http://www.w3.org/1999/xhtml">&lt;/<span style="color: rgb(153, 0, 0);">succeeds</span>&gt;</span></span><span style="color: blue;" xmlns="http://www.w3.org/1999/xhtml"><span style="color: blue;" xmlns="http://www.w3.org/1999/xhtml"></span></span><span style="color: blue;" xmlns="http://www.w3.org/1999/xhtml"><span style="color: blue;" xmlns="http://www.w3.org/1999/xhtml">&lt;/<span style="color: rgb(153, 0, 0);">eprint&gt;</span></span></span><span style="color: blue;" xmlns="http://www.w3.org/1999/xhtml"><span style="color: blue;" xmlns="http://www.w3.org/1999/xhtml"><span style="color: rgb(153, 0, 0);"><span class="block" style="color: blue; margin-left: -2em;" xmlns="http://www.w3.org/1999/xhtml">&lt;/<span style="color: rgb(153, 0, 0);">eprints</span>&gt;</span></span></span></span><span style="color: blue;" xmlns="http://www.w3.org/1999/xhtml"><span style="color: blue;" xmlns="http://www.w3.org/1999/xhtml"><span style="color: rgb(153, 0, 0);"></span></span></span></eprint><eprint><br></eprint><eprint>and likewise for the &lt;metadata-visiblility&gt; on the old record**</eprint><eprint><br></eprint><eprint>Does that seem like it ought to work?&nbsp; It seems too easy.&nbsp; Am I missing deeper layers of subtlety that are going to get corrupted by my naive approach.</eprint><eprint><br></eprint><eprint>Also, the eprint id is given twice in a standard eprint XML export, as per the edited code above.&nbsp; Is it necessary to have both to trigger an update correctly?</eprint><eprint><br></eprint><eprint>Andy Reid</eprint><eprint><br></eprint><eprint>** (I say 'old record' but in reality the published versions may arrive before the manuscript versions, which depend on the authors sending them and us having the resources to process them ;-/ )</eprint><eprint><br></eprint></div><span id="GWSignatureSent" style="padding-right: 0px; padding-left: 0px; margin-bottom: 5px; display: block;"><span style="display: block;"><br><span style="font-size: 10pt; display: inline-block; -ms-word-wrap: normal;"><div>Andy Reid</div>
<div>Research Information Manager</div>
<div>Room G43, Executive Office</div>
<div>London School of Hygiene &amp; Tropical Medicine</div>
<div>Keppel St</div>
<div>LONDON WC1E 7HT</div>
<div>+44 020-7927-2618</div>
<div><a href="http://orcid.org/0000-0002-2500-2980">http://orcid.org/0000-0002-2500-2980</a></div></span></span></span><span style="margin-bottom: 5px; display: block;"><br></span></div></div></body></html>