-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathitem_move.rb
More file actions
executable file
·46 lines (33 loc) · 1.2 KB
/
item_move.rb
File metadata and controls
executable file
·46 lines (33 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env jruby
# BEWARE:: not fully tested
require 'dspace'
require "highline/import"
DSpace.load
java_import org.dspace.content.Collection
java_import org.dspace.content.DSpaceObject
java_import org.dspace.handle.HandleManager
java_import org.dspace.eperson.EPerson;
DSpace.login(ENV['USER'])
# 88435/dsp019593tx37q
#str= ask "Iten to be moved (handle/or ITEM.<ID>) "
str = '88435/dsp019593tx37q';
item = DSpaceObject.fromString(DSpace.context, str.strip)
puts ["Item", "#{item.getName}", "#{item.getHandle}","#{item.toString}"].join("\n\t")
owner = item.getOwningCollection
puts "owning Collection\n\t#{owner.getHandle}\n\t#{owner.getName}"
parents = item.getCollections()
parents.each do |p|
puts "mapped Collection\n\t#{p.getHandle}\n\t#{p.getName}" unless p == owner
end
#str= ask "new Owning Collection (handle/or COLLECTION.<ID>) "
str = "88435/dsp01pv63g2477";
new_owner = DSpaceObject.fromString(DSpace.context, str.strip)
puts "new owning Collection\n\t#{new_owner.getHandle}\n\t#{new_owner.getName}"
str = ask "Please confirm the move (Y/N) "
if (str[0] == 'Y') then
puts "moving"
item.setOwningCollection(new_owner)
item.update
DSpace.context.commit
end
# context.complete