jrdspace 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/bin/idspace +1 -0
- data/lib/dspace.rb +2 -1
- data/lib/dspace/dbitstream.rb +6 -1
- data/lib/dspace/dbundle.rb +5 -1
- data/lib/dspace/dcollection.rb +6 -0
- data/lib/dspace/dcommunity.rb +5 -0
- data/lib/dspace/dgroup.rb +7 -11
- data/lib/dspace/ditem.rb +6 -0
- data/lib/dspace/dso.rb +17 -0
- data/lib/dspace/dspace.rb +79 -63
- data/lib/dspace/dworkflowitem.rb +19 -0
- data/lib/dspace/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e905bc1c648ee25ef40364bc83128e20146ece47
|
4
|
+
data.tar.gz: d224d5b02e4492213249dce5c6870559241c39c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23a7b8d2700b59671035fa9e795f68d376776ab319f28800bad41c488aa01d8d8d037caca114958d34470ce81e5a69152486889d23c90b53e9536ed420603473
|
7
|
+
data.tar.gz: ce1bf0b6064d0197f70582216158e95d335558264c495798eb0afa53f804f2c2c33799f0848f91a64e3cad5a4cd168e1cd31f39082a8d19f6f95b9deefe4fbcd
|
data/README.md
CHANGED
@@ -30,6 +30,11 @@ Install the gem:
|
|
30
30
|
bundle install
|
31
31
|
```
|
32
32
|
|
33
|
+
Please note that I am still updating this gem ferquently as I discover bugs. So please keep do update frequently with
|
34
|
+
```
|
35
|
+
bundle update
|
36
|
+
```
|
37
|
+
|
33
38
|
## Usage
|
34
39
|
|
35
40
|
To use in scripts simply include the following
|
data/bin/idspace
CHANGED
data/lib/dspace.rb
CHANGED
data/lib/dspace/dbitstream.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
class DBitstream
|
2
|
-
include DSO
|
2
|
+
include DSO
|
3
3
|
|
4
4
|
def self.all()
|
5
5
|
java_import org.dspace.content.Bitstream;
|
6
6
|
return Bitstream.findAll(DSpace.context)
|
7
7
|
end
|
8
8
|
|
9
|
+
def self.find(id)
|
10
|
+
java_import org.dspace.content.Bitstream;
|
11
|
+
return Bitstream.find(DSpace.context, id)
|
12
|
+
end
|
13
|
+
|
9
14
|
end
|
data/lib/dspace/dbundle.rb
CHANGED
data/lib/dspace/dcollection.rb
CHANGED
@@ -6,6 +6,12 @@ class DCollection
|
|
6
6
|
return Collection.findAll(DSpace.context)
|
7
7
|
end
|
8
8
|
|
9
|
+
def self.find(id)
|
10
|
+
java_import org.dspace.content.Collection;
|
11
|
+
return Collection.find(DSpace.context, id)
|
12
|
+
end
|
13
|
+
|
14
|
+
|
9
15
|
def self.findAll(name)
|
10
16
|
java_import org.dspace.content.Collection;
|
11
17
|
self.all.select do |c|
|
data/lib/dspace/dcommunity.rb
CHANGED
@@ -6,6 +6,11 @@ class DCommunity
|
|
6
6
|
return Community.findAll(DSpace.context)
|
7
7
|
end
|
8
8
|
|
9
|
+
def self.find(id)
|
10
|
+
java_import org.dspace.content.Community;
|
11
|
+
return Community.find(DSpace.context, id)
|
12
|
+
end
|
13
|
+
|
9
14
|
def self.findAll(name)
|
10
15
|
java_import org.dspace.content.Community;
|
11
16
|
self.all.select do |c|
|
data/lib/dspace/dgroup.rb
CHANGED
@@ -34,24 +34,20 @@ class DGroup
|
|
34
34
|
|
35
35
|
def members
|
36
36
|
list = [];
|
37
|
-
@
|
37
|
+
@obj.getMembers.each do |m|
|
38
38
|
list << m;
|
39
39
|
end
|
40
|
-
@
|
40
|
+
@obj.getMemberGroups.each do |m|
|
41
41
|
list << m;
|
42
42
|
end
|
43
43
|
return list;
|
44
44
|
end
|
45
45
|
|
46
|
-
def addMember(
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
raise "no such netid or group #{addGrouNameOrNetid}" if add.nil?
|
52
|
-
@dso.addMember(add);
|
53
|
-
@dso.update
|
54
|
-
return @dso;
|
46
|
+
def addMember(group_or_eperson)
|
47
|
+
raise "must give non nil group_or_eperson" if group_or_eperson.nil?
|
48
|
+
@obj.addMember(group_or_eperson);
|
49
|
+
@obj.update
|
50
|
+
return @obj;
|
55
51
|
end
|
56
52
|
|
57
53
|
def report
|
data/lib/dspace/ditem.rb
CHANGED
@@ -16,6 +16,12 @@ class DItem
|
|
16
16
|
return list
|
17
17
|
end
|
18
18
|
|
19
|
+
def self.find(id)
|
20
|
+
java_import org.dspace.content.Item;
|
21
|
+
id = id.to_i if id.class == String
|
22
|
+
return Item.find(DSpace.context, id)
|
23
|
+
end
|
24
|
+
|
19
25
|
def self.inside(restrict_to_dso)
|
20
26
|
java_import org.dspace.storage.rdbms.DatabaseManager
|
21
27
|
java_import org.dspace.storage.rdbms.TableRow
|
data/lib/dspace/dso.rb
CHANGED
@@ -53,5 +53,22 @@ module DSO
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
def getMetaDataValues()
|
57
|
+
java_import org.dspace.content.MetadataSchema
|
58
|
+
java_import org.dspace.content.MetadataField
|
59
|
+
java_import org.dspace.storage.rdbms.DatabaseManager
|
60
|
+
java_import org.dspace.storage.rdbms.TableRow
|
61
|
+
|
62
|
+
sql = "SELECT MV.metadata_field_id, MV.text_value FROM METADATAVALUE MV " +
|
63
|
+
" WHERE RESOURCE_TYPE_ID = #{@obj.getType} AND RESOURCE_ID = #{@obj.getID}"
|
64
|
+
tri = DatabaseManager.queryTable(DSpace.context, "MetadataValue", sql)
|
65
|
+
mvs = [];
|
66
|
+
while (iter = tri.next())
|
67
|
+
field = MetadataField.find(DSpace.context, iter.getIntColumn("metadata_field_id"))
|
68
|
+
mvs << [ DSpace.toString(field), iter.getStringColumn("text_value") ]
|
69
|
+
end
|
70
|
+
tri.close
|
71
|
+
return mvs
|
72
|
+
end
|
56
73
|
end
|
57
74
|
|
data/lib/dspace/dspace.rb
CHANGED
@@ -2,29 +2,18 @@ module DSpace
|
|
2
2
|
ROOT = File.expand_path('../..', __FILE__)
|
3
3
|
@@config = nil;
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
GROUP = 6;
|
12
|
-
EPERSON = 7;
|
13
|
-
|
14
|
-
def self.objTypeId(type_str_or_int)
|
15
|
-
obj_typ = Constants.typeText.find_index type_str_or_int
|
16
|
-
if obj_typ.nil? then
|
17
|
-
obj_typ = Integer(type_str_or_int)
|
18
|
-
raise "no such object typ #{type_str_or_int}" unless Constants.typeText[obj_typ]
|
5
|
+
def self.objTypeStr(type_str_or_int)
|
6
|
+
return type_str_or_int.capitalize if type_str_or_int.class == String and Constants.typeText.find_index type_str_or_int.upcase
|
7
|
+
begin
|
8
|
+
id = Integer(type_str_or_int)
|
9
|
+
rescue
|
10
|
+
raise "no such object type #{type_str_or_int}"
|
19
11
|
end
|
20
|
-
return
|
12
|
+
return Constants.typeText[id].capitalize
|
21
13
|
end
|
22
14
|
|
23
|
-
def self.
|
24
|
-
|
25
|
-
obj_typ_id = Integer(type_str_or_int)
|
26
|
-
raise "no such object type #{type_str_or_int}" unless Constants.typeText[obj_typ_id]
|
27
|
-
return Constants.typeText[obj_typ_id];
|
15
|
+
def self.objTypeId(type_str_or_int)
|
16
|
+
obj_typ = Constants.typeText.find_index objTypeStr(type_str_or_int).upcase
|
28
17
|
end
|
29
18
|
|
30
19
|
def self.load(dspace_dir = nil)
|
@@ -47,6 +36,12 @@ module DSpace
|
|
47
36
|
return @@config.context
|
48
37
|
end
|
49
38
|
|
39
|
+
def self.context_renew
|
40
|
+
raise "must call load to initialize" if @@config.nil?
|
41
|
+
raise "should never happen" if @@config.context.nil?
|
42
|
+
return @@config.context_renew
|
43
|
+
end
|
44
|
+
|
50
45
|
def self.login(netid)
|
51
46
|
self.context.setCurrentUser(DEPerson.find(netid))
|
52
47
|
return nil
|
@@ -58,19 +53,10 @@ module DSpace
|
|
58
53
|
|
59
54
|
def self.create(dso)
|
60
55
|
raise "dso must not be nil" if dso.nil?
|
61
|
-
klass =
|
56
|
+
klass = Object.const_get "D" + dso.class.name.gsub(/.*::/, '')
|
62
57
|
klass.send :new, dso
|
63
58
|
end
|
64
59
|
|
65
|
-
def self.fromString(type_id_or_handle)
|
66
|
-
splits = type_id_or_handle.split('.')
|
67
|
-
if (2 == splits.length) then
|
68
|
-
self.find(splits[0], splits[1])
|
69
|
-
else
|
70
|
-
self.fromHandle(type_id_or_handle)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
60
|
def self.fromHandle(handle)
|
75
61
|
return HandleManager.resolve_to_object(DSpace.context, handle);
|
76
62
|
end
|
@@ -78,51 +64,76 @@ module DSpace
|
|
78
64
|
def self.find(type_str_or_int, identifier)
|
79
65
|
type_str = DSpace.objTypeStr(type_str_or_int)
|
80
66
|
type_id = DSpace.objTypeId(type_str)
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
67
|
+
klass = Object.const_get "D" + type_str
|
68
|
+
begin
|
69
|
+
id = Integer(identifier)
|
70
|
+
rescue
|
71
|
+
id = identifier
|
86
72
|
end
|
87
|
-
return
|
73
|
+
return klass.send :find, id
|
88
74
|
end
|
89
75
|
|
90
76
|
def self.findByMetadataValue(fully_qualified_metadata_field, value_or_nil, restrict_to_type)
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
77
|
+
java_import org.dspace.content.MetadataSchema
|
78
|
+
java_import org.dspace.content.MetadataField
|
79
|
+
java_import org.dspace.storage.rdbms.DatabaseManager
|
80
|
+
java_import org.dspace.storage.rdbms.TableRow
|
81
|
+
|
82
|
+
(schema, element, qualifier) = fully_qualified_metadata_field.split('.')
|
83
|
+
schm = MetadataSchema.find(DSpace.context, schema)
|
84
|
+
raise "no such metadata schema: #{schema}" if schm.nil?
|
85
|
+
field = MetadataField.find_by_element(DSpace.context, schm.getSchemaID, element, qualifier)
|
86
|
+
raise "no such metadata field #{fully_qualified_metadata_field}" if field.nil?
|
87
|
+
|
88
|
+
sql = "SELECT MV.resource_id, MV.resource_type_id FROM MetadataValue MV";
|
89
|
+
sql = sql + " where MV.metadata_field_id= #{field.getFieldID} "
|
90
|
+
if (not value_or_nil.nil?) then
|
91
|
+
sql = sql + " AND MV.text_value LIKE '#{value_or_nil}'"
|
92
|
+
end
|
93
|
+
if (restrict_to_type) then
|
94
|
+
sql = sql + " AND MV.resource_type_id = #{objTypeId(restrict_to_type)}"
|
95
|
+
end
|
110
96
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
97
|
+
tri = DatabaseManager.queryTable(DSpace.context, "MetadataValue", sql)
|
98
|
+
dsos = [];
|
99
|
+
while (iter = tri.next())
|
100
|
+
dsos << self.find(iter.getIntColumn("resource_type_id"), iter.getIntColumn("resource_id"))
|
101
|
+
end
|
102
|
+
tri.close
|
103
|
+
return dsos
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.fromString(type_id_or_handle)
|
107
|
+
#TODO handle MetadataField string
|
108
|
+
splits = type_id_or_handle.split('.')
|
109
|
+
if (2 == splits.length) then
|
110
|
+
self.find(splits[0].upcase, splits[1])
|
111
|
+
else
|
112
|
+
self.fromHandle(type_id_or_handle)
|
118
113
|
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.toString(java_obj)
|
117
|
+
return "nil" unless java_obj
|
118
|
+
klass = java_obj.getClass.getName
|
119
|
+
if (klass == "org.dspace.content.MetadataField") then
|
120
|
+
java_import org.dspace.content.MetadataField
|
121
|
+
java_import org.dspace.content.MetadataSchema
|
119
122
|
|
123
|
+
schema = MetadataSchema.find(DSpace.context, java_obj.schemaID)
|
124
|
+
str = "#{schema.getName}.#{java_obj.element}"
|
125
|
+
str += ".#{java_obj.qualifier}" if java_obj.qualifier
|
126
|
+
str
|
127
|
+
else
|
128
|
+
java_obj.toString
|
129
|
+
end
|
130
|
+
end
|
120
131
|
|
121
132
|
def self.kernel
|
122
133
|
@@config.kernel;
|
123
134
|
end
|
124
135
|
|
125
|
-
def self.help(
|
136
|
+
def self.help(klasses = [DSpace, DCommunity, DCollection, DItem, DGroup])
|
126
137
|
klasses.each do |klass|
|
127
138
|
klass.singleton_methods.sort.each do |mn|
|
128
139
|
m = klass.method(mn)
|
@@ -162,6 +173,11 @@ module DSpace
|
|
162
173
|
return @context
|
163
174
|
end
|
164
175
|
|
176
|
+
def context_renew
|
177
|
+
@context.abort if @context
|
178
|
+
@context = org.dspace.core.Context.new()
|
179
|
+
end
|
180
|
+
|
165
181
|
def init
|
166
182
|
if @context.nil? then
|
167
183
|
puts "Loading jars"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env jruby
|
2
|
+
require 'dspace'
|
3
|
+
|
4
|
+
class DWorkflowItem
|
5
|
+
def self.findAll(obj)
|
6
|
+
java_import org.dspace.workflow.WorkflowItem
|
7
|
+
if (obj.getType == DSpace::COLLECTION)
|
8
|
+
return WorkflowItem.findByCollection(DSpace.context, obj)
|
9
|
+
elsif (obj.getType == DSpace::COMMUNITY) then
|
10
|
+
flows = []
|
11
|
+
obj.getCollections.each do |col|
|
12
|
+
flows += findAll(col)
|
13
|
+
end
|
14
|
+
return flows
|
15
|
+
end
|
16
|
+
return []
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/lib/dspace/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jrdspace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Monika Mevenkamp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jar
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/dspace/ditem.rb
|
90
90
|
- lib/dspace/dso.rb
|
91
91
|
- lib/dspace/dspace.rb
|
92
|
+
- lib/dspace/dworkflowitem.rb
|
92
93
|
- lib/dspace/version.rb
|
93
94
|
homepage: https://github.com/akinom/dspace-jruby
|
94
95
|
licenses:
|