sakai-info 0.1.0 → 0.2.0
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.
- data/CHANGELOG.md +12 -6
- data/README.md +50 -78
- data/ROADMAP.md +19 -17
- data/bin/sakai-info +94 -43
- data/lib/sakai-info.rb +32 -5
- data/lib/sakai-info/announcement.rb +30 -34
- data/lib/sakai-info/assignment.rb +45 -80
- data/lib/sakai-info/authz.rb +77 -94
- data/lib/sakai-info/cli.rb +1 -23
- data/lib/sakai-info/cli/help.rb +45 -35
- data/lib/sakai-info/content.rb +28 -49
- data/lib/sakai-info/database.rb +114 -0
- data/lib/sakai-info/gradebook.rb +48 -50
- data/lib/sakai-info/group.rb +21 -32
- data/lib/sakai-info/message.rb +16 -25
- data/lib/sakai-info/sakai_object.rb +11 -4
- data/lib/sakai-info/samigo.rb +38 -61
- data/lib/sakai-info/site.rb +128 -186
- data/lib/sakai-info/user.rb +77 -68
- data/lib/sakai-info/version.rb +1 -1
- metadata +36 -11
- data/lib/sakai-info/configuration.rb +0 -288
- data/lib/sakai-info/db.rb +0 -19
- data/lib/sakai-info/instance.rb +0 -122
@@ -2,7 +2,7 @@
|
|
2
2
|
# SakaiInfo::Announcement library
|
3
3
|
#
|
4
4
|
# Created 2012-02-16 daveadams@gmail.com
|
5
|
-
# Last updated 2012-02-
|
5
|
+
# Last updated 2012-02-24 daveadams@gmail.com
|
6
6
|
#
|
7
7
|
# https://github.com/daveadams/sakai-info
|
8
8
|
#
|
@@ -18,19 +18,16 @@ module SakaiInfo
|
|
18
18
|
|
19
19
|
def self.find(id)
|
20
20
|
if @@cache[id].nil?
|
21
|
-
next_id = nil
|
22
21
|
xml = ""
|
23
|
-
DB.connect.
|
24
|
-
|
25
|
-
nextid = row[0].to_i
|
26
|
-
REXML::Document.new(row[1].read).write(xml, 2)
|
27
|
-
end
|
28
|
-
if nextid.nil?
|
22
|
+
row = DB.connect[:announcement_channel].filter(:channel_id => id).first
|
23
|
+
if row.nil?
|
29
24
|
raise ObjectNotFoundException.new(AnnouncementChannel, id)
|
30
25
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
nextid = row[:next_id].to_i
|
27
|
+
REXML::Document.new(row[:xml].read).write(xml, 2)
|
28
|
+
channel = AnnouncementChannel.new(id, nextid, xml)
|
29
|
+
@@cache[id] = channel
|
30
|
+
@@site_cache[channel.site_id] = channel
|
34
31
|
end
|
35
32
|
@@cache[id]
|
36
33
|
end
|
@@ -91,22 +88,21 @@ module SakaiInfo
|
|
91
88
|
@@cache = {}
|
92
89
|
def self.find(id)
|
93
90
|
if @@cache[id].nil?
|
94
|
-
channel = draft = pubview = owner = date = nil
|
95
91
|
xml = ""
|
96
|
-
DB.connect.
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
draft = row[1]
|
102
|
-
pubview = row[2]
|
103
|
-
owner = User.find(row[3])
|
104
|
-
date = row[4]
|
105
|
-
REXML::Document.new(row[5].read).write(xml, 2)
|
106
|
-
end
|
107
|
-
if date.nil?
|
92
|
+
row = DB.connect.fetch("select channel_id, draft, pubview, owner, xml, " +
|
93
|
+
"to_char(message_date,'YYYY-MM-DD HH24:MI:SS') as message_date " +
|
94
|
+
"from announcement_message " +
|
95
|
+
"where message_id = ?", id).first
|
96
|
+
if row.nil?
|
108
97
|
raise ObjectNotFoundException.new(Announcement, id)
|
109
98
|
end
|
99
|
+
|
100
|
+
channel = AnnouncementChannel.find(row[:channel_id])
|
101
|
+
draft = row[:draft]
|
102
|
+
pubview = row[:pubview]
|
103
|
+
owner = User.find(row[:owner])
|
104
|
+
date = row[:message_date]
|
105
|
+
REXML::Document.new(row[:xml].read).write(xml, 2)
|
110
106
|
@@cache[id] = Announcement.new(id, channel, draft, pubview, owner, date, xml)
|
111
107
|
end
|
112
108
|
@@cache[id]
|
@@ -129,17 +125,17 @@ module SakaiInfo
|
|
129
125
|
announcements = []
|
130
126
|
channel = AnnouncementChannel.find(channel_id)
|
131
127
|
|
132
|
-
DB.connect.
|
133
|
-
|
134
|
-
|
135
|
-
|
128
|
+
DB.connect.fetch("select message_id, draft, pubview, owner, xml, " +
|
129
|
+
"to_char(message_date,'YYYY-MM-DD HH24:MI:SS') as message_date " +
|
130
|
+
"from announcement_message " +
|
131
|
+
"where channel_id = ?", channel_id) do |row|
|
136
132
|
xml = ""
|
137
|
-
id = row[
|
138
|
-
draft = row[
|
139
|
-
pubview = row[
|
140
|
-
owner = User.find(row[
|
141
|
-
|
142
|
-
|
133
|
+
id = row[:message_id]
|
134
|
+
draft = row[:draft]
|
135
|
+
pubview = row[:pubview]
|
136
|
+
owner = User.find(row[:owner])
|
137
|
+
REXML::Document.new(row[:xml].read).write(xml, 2)
|
138
|
+
date = row[:message_date]
|
143
139
|
|
144
140
|
@@cache[id] = Announcement.new(id, channel, draft, pubview, owner, date, xml)
|
145
141
|
announcements << @@cache[id]
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# SakaiInfo::Assignment library
|
3
3
|
#
|
4
4
|
# Created 2012-02-17 daveadams@gmail.com
|
5
|
-
# Last updated 2012-02-
|
5
|
+
# Last updated 2012-02-24 daveadams@gmail.com
|
6
6
|
#
|
7
7
|
# https://github.com/daveadams/sakai-info
|
8
8
|
#
|
@@ -16,16 +16,13 @@ module SakaiInfo
|
|
16
16
|
@@cache = {}
|
17
17
|
def self.find(id)
|
18
18
|
if @@cache[id].nil?
|
19
|
-
site = nil
|
20
19
|
xml = ""
|
21
|
-
DB.connect.
|
22
|
-
|
23
|
-
site = Site.find(row[0])
|
24
|
-
REXML::Document.new(row[1].read).write(xml, 2)
|
25
|
-
end
|
26
|
-
if site.nil?
|
20
|
+
row = DB.connect[:assignment_assigment].filter(:assignment_id => id).first
|
21
|
+
if row.nil?
|
27
22
|
raise ObjectNotFoundException.new(Assignment, id)
|
28
23
|
end
|
24
|
+
site = Site.find(row[:context])
|
25
|
+
REXML::Document.new(row[:xml].read).write(xml, 2)
|
29
26
|
@@cache[id] = Assignment.new(id, site, xml)
|
30
27
|
end
|
31
28
|
@@cache[id]
|
@@ -42,24 +39,18 @@ module SakaiInfo
|
|
42
39
|
# set lookup
|
43
40
|
def self.find_by_site_id(site_id)
|
44
41
|
assignments = []
|
45
|
-
|
46
|
-
|
47
|
-
id = row[
|
48
|
-
site = Site.find(row[1])
|
42
|
+
site = Site.find(site_id)
|
43
|
+
DB.connect[:assignment_assignment].filter(:context => site_id).all.each do |row|
|
44
|
+
id = row[:assignment_id]
|
49
45
|
xml = ""
|
50
|
-
REXML::Document.new(row[
|
46
|
+
REXML::Document.new(row[:xml].read).write(xml, 2)
|
51
47
|
assignments << Assignment.new(id, site, xml)
|
52
48
|
end
|
53
49
|
return assignments
|
54
50
|
end
|
55
51
|
|
56
52
|
def self.count_by_site_id(site_id)
|
57
|
-
|
58
|
-
DB.connect.exec("select count(*) from assignment_assignment " +
|
59
|
-
"where context = :site_id", site_id) do |row|
|
60
|
-
assignment_count = row[0].to_i
|
61
|
-
end
|
62
|
-
return assignment_count
|
53
|
+
DB.connect[:assignment_assignment].filter(:context => site_id).count
|
63
54
|
end
|
64
55
|
|
65
56
|
# getters
|
@@ -115,19 +106,17 @@ module SakaiInfo
|
|
115
106
|
if @@cache[id].nil?
|
116
107
|
assignment = submitter = submitted_at = submitted = graded = nil
|
117
108
|
xml = ""
|
118
|
-
DB.connect.
|
119
|
-
|
120
|
-
"where submission_id = :id", id) do |row|
|
121
|
-
assignment = Assignment.find(row[0])
|
122
|
-
xml = ""
|
123
|
-
REXML::Document.new(row[1].read).write(xml, 2)
|
124
|
-
submitter = User.find(row[2])
|
125
|
-
submitted = (row[3] == "true")
|
126
|
-
graded = (row[4] == "true")
|
127
|
-
end
|
128
|
-
if assignment.nil?
|
109
|
+
row = DB.connect[:assignment_submission].filter(:submission_id => id).first
|
110
|
+
if row.nil?
|
129
111
|
raise ObjectNotFoundException.new(AssignmentSubmission, id)
|
130
112
|
end
|
113
|
+
|
114
|
+
assignment = Assignment.find(row[:context])
|
115
|
+
REXML::Document.new(row[:xml].read).write(xml, 2)
|
116
|
+
submitter = User.find(row[:submitter_id])
|
117
|
+
submitted = (row[:submitted] == "true")
|
118
|
+
graded = (row[:graded] == "true")
|
119
|
+
|
131
120
|
@@cache[id] = AssignmentSubmission.new(id, assignment, xml, submitter, submitted, graded)
|
132
121
|
end
|
133
122
|
@@cache[id]
|
@@ -147,54 +136,40 @@ module SakaiInfo
|
|
147
136
|
|
148
137
|
def self.find_by_assignment_id(assignment_id)
|
149
138
|
submissions = []
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
id = row[0]
|
154
|
-
assignment = Assignment.find(row[1])
|
139
|
+
assignment = Assignment.find(assignment_id)
|
140
|
+
DB.connect[:assignment_submission].filter(:context => assignment_id).all.each do |row|
|
141
|
+
id = row[:submission_id]
|
155
142
|
xml = ""
|
156
|
-
REXML::Document.new(row[
|
157
|
-
submitter = User.find(row[
|
158
|
-
submitted = (row[
|
159
|
-
graded = (row[
|
143
|
+
REXML::Document.new(row[:xml].read).write(xml, 2)
|
144
|
+
submitter = User.find(row[:submitter_id])
|
145
|
+
submitted = (row[:submitted] == "true")
|
146
|
+
graded = (row[:graded] == "true")
|
160
147
|
submissions << AssignmentSubmission.new(id, assignment, xml, submitter, submitted, graded)
|
161
148
|
end
|
162
149
|
return submissions
|
163
150
|
end
|
164
151
|
|
165
152
|
def self.count_by_assignment_id(assignment_id)
|
166
|
-
|
167
|
-
DB.connect.exec("select count(*) from assignment_submission " +
|
168
|
-
"where context = :assignment_id", assignment_id) do |row|
|
169
|
-
submission_count = row[0].to_i
|
170
|
-
end
|
171
|
-
return submission_count
|
153
|
+
DB.connect[:assignment_submission].filter(:context => assignment_id).count
|
172
154
|
end
|
173
155
|
|
174
156
|
def self.find_by_user_id(user_id)
|
175
157
|
submissions = []
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
assignment = Assignment.find(row[1])
|
158
|
+
submitter = User.find(user_id)
|
159
|
+
DB.connect[:assignment_submission].filter(:submitter_id => user_id).all.each do |row|
|
160
|
+
id = row[:submission_id]
|
161
|
+
assignment = Assignment.find(row[:context])
|
181
162
|
xml = ""
|
182
|
-
REXML::Document.new(row[
|
183
|
-
|
184
|
-
|
185
|
-
graded = (row[5] == "true")
|
163
|
+
REXML::Document.new(row[:xml].read).write(xml, 2)
|
164
|
+
submitted = (row[:submitted] == "true")
|
165
|
+
graded = (row[:graded] == "true")
|
186
166
|
submissions << AssignmentSubmission.new(id, assignment, xml, submitter, submitted, graded)
|
187
167
|
end
|
188
168
|
return submissions
|
189
169
|
end
|
190
170
|
|
191
171
|
def self.count_by_user_id(user_id)
|
192
|
-
|
193
|
-
DB.connect.exec("select count(*) from assignment_submission " +
|
194
|
-
"where submitter_id = :user_id", user_id) do |row|
|
195
|
-
submission_count = row[0].to_i
|
196
|
-
end
|
197
|
-
return submission_count
|
172
|
+
DB.connect[:assignment_submission].filter(:submitter_id => user_id).count
|
198
173
|
end
|
199
174
|
|
200
175
|
# yaml/json serialization
|
@@ -236,41 +211,31 @@ module SakaiInfo
|
|
236
211
|
@@cache = {}
|
237
212
|
def self.find(id)
|
238
213
|
if @@cache[id].nil?
|
239
|
-
|
240
|
-
|
241
|
-
DB.connect.exec("select context, xml from assignment_content " +
|
242
|
-
"where content_id = :id", id) do |row|
|
243
|
-
context = row[0]
|
244
|
-
REXML::Document.new(row[1].read).write(xml, 2)
|
245
|
-
end
|
246
|
-
if context.nil?
|
214
|
+
row = DB.connect[:assignment_content].filter(:content_id => id).first
|
215
|
+
if row.nil?
|
247
216
|
raise ObjectNotFoundException.new(AssignmentContent, id)
|
248
217
|
end
|
249
|
-
|
218
|
+
xml = ""
|
219
|
+
REXML::Document.new(row[:xml].read).write(xml, 2)
|
220
|
+
@@cache[id] = AssignmentContent.new(id, row[:context], xml)
|
250
221
|
end
|
251
222
|
@@cache[id]
|
252
223
|
end
|
253
224
|
|
254
225
|
def self.find_by_user_id(user_id)
|
255
226
|
contents = []
|
256
|
-
DB.connect.
|
257
|
-
|
258
|
-
|
259
|
-
context = row[1]
|
227
|
+
DB.connect[:assignment_content].filter(:context => user_id).all.each do |row|
|
228
|
+
id = row[:content_id]
|
229
|
+
context = row[:context]
|
260
230
|
xml = ""
|
261
|
-
REXML::Document.new(row[
|
231
|
+
REXML::Document.new(row[:xml].read).write(xml, 2)
|
262
232
|
contents << AssignmentContent.new(id, context, xml)
|
263
233
|
end
|
264
234
|
return contents
|
265
235
|
end
|
266
236
|
|
267
237
|
def self.count_by_user_id(user_id)
|
268
|
-
|
269
|
-
DB.connect.exec("select count(*) from assignment_content " +
|
270
|
-
"where context = :user_id", user_id) do |row|
|
271
|
-
content_count = row[0].to_i
|
272
|
-
end
|
273
|
-
content_count
|
238
|
+
DB.connect[:assignment_content].filter(:context => user_id).count
|
274
239
|
end
|
275
240
|
|
276
241
|
# getters
|
data/lib/sakai-info/authz.rb
CHANGED
@@ -26,15 +26,12 @@ module SakaiInfo
|
|
26
26
|
def self.find_by_id(id)
|
27
27
|
id = id.to_s
|
28
28
|
if @@cache[id].nil?
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
name = row[0]
|
33
|
-
end
|
34
|
-
if name.nil?
|
29
|
+
row = DB.connect.fetch("select role_name from sakai_realm_role " +
|
30
|
+
"where role_key = ?", id.to_i).first
|
31
|
+
if row.nil?
|
35
32
|
raise ObjectNotFoundException.new(AuthzRole, id)
|
36
33
|
end
|
37
|
-
@@cache[id] = AuthzRole.new(id,
|
34
|
+
@@cache[id] = AuthzRole.new(id, row[:role_name])
|
38
35
|
@@cache[name] = @@cache[id]
|
39
36
|
end
|
40
37
|
@@cache[id]
|
@@ -45,14 +42,12 @@ module SakaiInfo
|
|
45
42
|
raise ObjectNotFoundException.new(AuthzRole, "")
|
46
43
|
end
|
47
44
|
if @@cache[name].nil?
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
id = row[0].to_i.to_s
|
52
|
-
end
|
53
|
-
if id.nil?
|
45
|
+
row = DB.connect.fetch("select role_key from sakai_realm_role " +
|
46
|
+
"where role_name = ?", name).first
|
47
|
+
if row.nil?
|
54
48
|
raise ObjectNotFoundException.new(AuthzRole, name)
|
55
49
|
end
|
50
|
+
id = row[:role_key].to_i.to_s
|
56
51
|
@@cache[name] = AuthzRole.new(id, name)
|
57
52
|
@@cache[id] = @@cache[name]
|
58
53
|
end
|
@@ -76,13 +71,13 @@ module SakaiInfo
|
|
76
71
|
|
77
72
|
def self.find_by_realm_id_and_function_id(realm_id, function_id)
|
78
73
|
roles = []
|
79
|
-
DB.connect.
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
role_id = row[
|
85
|
-
role_name = row[
|
74
|
+
DB.connect.fetch("select role_key, role_name from " +
|
75
|
+
"sakai_realm_role where role_key in " +
|
76
|
+
"(select role_key from sakai_realm_rl_fn " +
|
77
|
+
"where realm_key=? and function_key=?) " +
|
78
|
+
"order by role_name", realm_id, function_id) do |row|
|
79
|
+
role_id = row[:role_key].to_i.to_s
|
80
|
+
role_name = row[:role_name]
|
86
81
|
roles << AuthzRole.new(role_id, role_name)
|
87
82
|
end
|
88
83
|
roles
|
@@ -105,16 +100,13 @@ module SakaiInfo
|
|
105
100
|
def self.find_by_id(id)
|
106
101
|
id = id.to_s
|
107
102
|
if @@cache[id].nil?
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
name = row[0]
|
112
|
-
end
|
113
|
-
if name.nil?
|
103
|
+
row = DB.connect.fetch("select function_name from sakai_realm_function " +
|
104
|
+
"where function_key = ?", id.to_i).first
|
105
|
+
if row.nil?
|
114
106
|
raise ObjectNotFoundException.new(AuthzFunction, id)
|
115
107
|
end
|
116
|
-
@@cache[id] = AuthzFunction.new(id,
|
117
|
-
@@cache[
|
108
|
+
@@cache[id] = AuthzFunction.new(id, row[:function_name])
|
109
|
+
@@cache[row[:function_name]] = @@cache[id]
|
118
110
|
end
|
119
111
|
@@cache[id]
|
120
112
|
end
|
@@ -122,13 +114,12 @@ module SakaiInfo
|
|
122
114
|
def self.find_by_name(name)
|
123
115
|
if @@cache[name].nil?
|
124
116
|
id = nil
|
125
|
-
DB.connect.
|
126
|
-
|
127
|
-
|
128
|
-
end
|
129
|
-
if id.nil?
|
117
|
+
row = DB.connect.fetch("select function_key from sakai_realm_function " +
|
118
|
+
"where function_name = ?", name).first
|
119
|
+
if row.nil?
|
130
120
|
raise ObjectNotFoundException.new(AuthzFunction, name)
|
131
121
|
end
|
122
|
+
id = row[:function_key].to_i.to_s
|
132
123
|
@@cache[name] = AuthzFunction.new(id, name)
|
133
124
|
@@cache[id] = @@cache[name]
|
134
125
|
end
|
@@ -151,24 +142,19 @@ module SakaiInfo
|
|
151
142
|
end
|
152
143
|
|
153
144
|
def self.count_by_realm_id_and_role_id(realm_id, role_id)
|
154
|
-
|
155
|
-
|
156
|
-
"where realm_key=:realm_id and role_key=:role_id",
|
157
|
-
realm_id, role_id) do |row|
|
158
|
-
count = row[0].to_i
|
159
|
-
end
|
160
|
-
count
|
145
|
+
DB.connect[:sakai_realm_rl_fn].
|
146
|
+
filter(:realm_key => realm_id, :role_key => role_id).count
|
161
147
|
end
|
162
148
|
|
163
149
|
def self.find_by_realm_id_and_role_id(realm_id, role_id)
|
164
150
|
functions = []
|
165
|
-
DB.connect.
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
function_id = row[
|
171
|
-
function_name = row[
|
151
|
+
DB.connect.fetch("select function_key, function_name from " +
|
152
|
+
"sakai_realm_function where function_key in " +
|
153
|
+
"(select function_key from sakai_realm_rl_fn " +
|
154
|
+
"where realm_key=? and role_key=?) " +
|
155
|
+
"order by function_name", realm_id, role_id) do |row|
|
156
|
+
function_id = row[:function_key].to_i.to_s
|
157
|
+
function_name = row[:function_name]
|
172
158
|
functions << AuthzFunction.new(function_id, function_name)
|
173
159
|
end
|
174
160
|
functions
|
@@ -209,21 +195,21 @@ module SakaiInfo
|
|
209
195
|
def self.find_by_id(id)
|
210
196
|
id = id.to_s
|
211
197
|
if @@cache[id].nil?
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
name = row[0]
|
217
|
-
providers = row[1]
|
218
|
-
if row[2].nil? or row[2] == ""
|
219
|
-
maintain_role = nil
|
220
|
-
else
|
221
|
-
maintain_role = AuthzRole.find_by_id(row[2].to_i)
|
222
|
-
end
|
223
|
-
end
|
224
|
-
if name.nil?
|
198
|
+
row = DB.connect.fetch("select realm_id, provider_id, maintain_role " +
|
199
|
+
"from sakai_realm " +
|
200
|
+
"where realm_key = ?", id.to_i).first
|
201
|
+
if row.nil?
|
225
202
|
raise ObjectNotFoundException.new(AuthzRealm, id)
|
226
203
|
end
|
204
|
+
|
205
|
+
name = row[:realm_id]
|
206
|
+
providers = row[:provider_id]
|
207
|
+
maintain_role = nil
|
208
|
+
if row[:maintain_role].nil? or row[:maintain_role] == ""
|
209
|
+
maintain_role = nil
|
210
|
+
else
|
211
|
+
maintain_role = AuthzRole.find_by_id(row[:maintain_role].to_i)
|
212
|
+
end
|
227
213
|
@@cache[id] = AuthzRealm.new(id, name, providers, maintain_role)
|
228
214
|
@@cache[name] = @@cache[id]
|
229
215
|
end
|
@@ -232,21 +218,21 @@ module SakaiInfo
|
|
232
218
|
|
233
219
|
def self.find_by_name(name)
|
234
220
|
if @@cache[name].nil?
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
id = row[0].to_i.to_s
|
240
|
-
providers = row[1]
|
241
|
-
if row[2].nil? or row[2] == ""
|
242
|
-
maintain_role = nil
|
243
|
-
else
|
244
|
-
maintain_role = AuthzRole.find_by_id(row[2].to_i)
|
245
|
-
end
|
246
|
-
end
|
247
|
-
if id.nil?
|
221
|
+
row = DB.connect.fetch("select realm_key, provider_id, maintain_role " +
|
222
|
+
"from sakai_realm " +
|
223
|
+
"where realm_id = ?", name).first
|
224
|
+
if row.nil?
|
248
225
|
raise ObjectNotFoundException.new(AuthzRealm, name)
|
249
226
|
end
|
227
|
+
|
228
|
+
id = row[:realm_key].to_i.to_s
|
229
|
+
providers = row[:provider_id]
|
230
|
+
maintain_role = nil
|
231
|
+
if row[:maintain_role].nil? or row[:maintain_role] == ""
|
232
|
+
maintain_role = nil
|
233
|
+
else
|
234
|
+
maintain_role = AuthzRole.find_by_id(row[:maintain_role].to_i)
|
235
|
+
end
|
250
236
|
@@cache[name] = AuthzRealm.new(id, name, providers, maintain_role)
|
251
237
|
@@cache[id] = @@cache[name]
|
252
238
|
end
|
@@ -304,11 +290,11 @@ module SakaiInfo
|
|
304
290
|
def self.find_by_realm_id(realm_id)
|
305
291
|
realm_roles = []
|
306
292
|
realm = AuthzRealm.find_by_id(realm_id)
|
307
|
-
DB.connect.
|
308
|
-
|
309
|
-
|
293
|
+
DB.connect.fetch("select distinct role_key from " +
|
294
|
+
"sakai_realm_rl_fn where " +
|
295
|
+
"realm_key = ?", realm_id) do |row|
|
310
296
|
begin
|
311
|
-
role = AuthzRole.find_by_id(row[
|
297
|
+
role = AuthzRole.find_by_id(row[:role_key].to_i)
|
312
298
|
realm_roles << AuthzRealmRole.new(realm, role)
|
313
299
|
rescue AuthzRoleNotFoundException
|
314
300
|
end
|
@@ -345,32 +331,29 @@ module SakaiInfo
|
|
345
331
|
|
346
332
|
def self.find_by_realm_id(realm_id)
|
347
333
|
results = []
|
348
|
-
DB.connect.
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
334
|
+
DB.connect.fetch("select srrg.user_id as user_id, " +
|
335
|
+
"srr.role_name as role_name " +
|
336
|
+
"from sakai_realm_rl_gr srrg, sakai_realm_role srr " +
|
337
|
+
"where srrg.role_key = srr.role_key " +
|
338
|
+
"and srrg.realm_key = ?", realm_id) do |row|
|
339
|
+
results << AuthzRealmMembership.new(realm_id, row[:user_id], row[:role_name])
|
353
340
|
end
|
354
341
|
results
|
355
342
|
end
|
356
343
|
|
357
344
|
def self.count_by_realm_id(realm_id)
|
358
|
-
|
359
|
-
DB.connect.exec("select count(*) from sakai_realm_rl_gr " +
|
360
|
-
"where realm_key = :realm_id", realm_id) do |row|
|
361
|
-
count = row[0].to_i
|
362
|
-
end
|
363
|
-
count
|
345
|
+
DB.connect[:sakai_realm_rl_gr].filter(:realm_key => realm_id).count
|
364
346
|
end
|
365
347
|
|
366
348
|
def self.find_by_user_id(user_id)
|
367
349
|
results = []
|
368
|
-
DB.connect.
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
350
|
+
DB.connect.fetch("select sr.realm_id as realm_id, " +
|
351
|
+
"srr.role_name as role_name " +
|
352
|
+
"from sakai_realm_rl_gr srrg, sakai_realm_role srr, sakai_realm sr " +
|
353
|
+
"where srrg.role_key = srr.role_key " +
|
354
|
+
"and srrg.realm_key = sr.realm_key " +
|
355
|
+
"and srrg.user_id = ?", user_id) do |row|
|
356
|
+
results << AuthzRealmMembership.new(row[:realm_id], user_id, row[:role_name])
|
374
357
|
end
|
375
358
|
results
|
376
359
|
end
|