Last active
February 10, 2017 17:10
-
-
Save sdumitriu/df9c2e7850c975b2df4a512ec06b9aa8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{comment}} | |
When migrating PhenoTips data from a virtual instance to another through XAR export and import, | |
certain inter-document references will still contain the virtual instance identifier in them, | |
for example "rdconnect:Studies.Ataxia", which means that links between patient records, | |
users, groups, and studies, will be broken. In order to fix these links, we need to manually | |
fix this prefix. | |
0. Move the data from the old instance to the new instance | |
1. Log in with an administrative account on the new instance | |
2. Put this script in a new document, for example: /bin/edit/Sandbox/FixWikiId | |
3. Replace the values for $sourceInstanceId and $targetInstanceId with the right ones, if needed | |
4. Click Preview (this will actually change the data) | |
{{/comment}} | |
{{velocity}} | |
#set ($sourceInstanceId = 'rdconnect:') | |
#set ($targetInstanceId = 'xwiki:') | |
#set ($ctx = $xcontext.context) | |
#set ($store = $xwiki.xWiki.store.store) | |
$store.beginTransaction($ctx) | |
#set ($session = $store.getSession($ctx)) | |
#foreach ($p in $store.search("from StringProperty p where p.value like '${sourceInstanceId}%'", 0, 0, $ctx)) | |
$p.setValue($p.getValue().replace($sourceInstanceId, $targetInstanceId)) | |
$session.update($p) | |
#end | |
#foreach ($p in $store.search("from LargeStringProperty p where p.value like '%${sourceInstanceId}%'", 0, 0, $ctx)) | |
$p.setValue($p.getValue().replace($sourceInstanceId, $targetInstanceId)) | |
$session.update($p) | |
#end | |
$store.endTransaction($ctx, true) | |
{{/velocity}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment