acdcserver 2.3.10__py3-none-any.whl

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.
Files changed (104) hide show
  1. WMCore/ACDC/Collection.py +57 -0
  2. WMCore/ACDC/CollectionTypes.py +12 -0
  3. WMCore/ACDC/CouchCollection.py +67 -0
  4. WMCore/ACDC/CouchFileset.py +238 -0
  5. WMCore/ACDC/CouchService.py +73 -0
  6. WMCore/ACDC/DataCollectionService.py +485 -0
  7. WMCore/ACDC/Fileset.py +94 -0
  8. WMCore/ACDC/__init__.py +11 -0
  9. WMCore/Algorithms/ParseXMLFile.py +115 -0
  10. WMCore/Algorithms/Permissions.py +27 -0
  11. WMCore/Algorithms/__init__.py +7 -0
  12. WMCore/Configuration.py +651 -0
  13. WMCore/DataStructs/File.py +177 -0
  14. WMCore/DataStructs/Fileset.py +140 -0
  15. WMCore/DataStructs/Job.py +182 -0
  16. WMCore/DataStructs/JobGroup.py +142 -0
  17. WMCore/DataStructs/JobPackage.py +49 -0
  18. WMCore/DataStructs/LumiList.py +734 -0
  19. WMCore/DataStructs/Mask.py +219 -0
  20. WMCore/DataStructs/Pickleable.py +24 -0
  21. WMCore/DataStructs/Run.py +256 -0
  22. WMCore/DataStructs/Subscription.py +175 -0
  23. WMCore/DataStructs/WMObject.py +47 -0
  24. WMCore/DataStructs/WorkUnit.py +112 -0
  25. WMCore/DataStructs/Workflow.py +60 -0
  26. WMCore/DataStructs/__init__.py +8 -0
  27. WMCore/Database/CMSCouch.py +1349 -0
  28. WMCore/Database/ConfigDBMap.py +29 -0
  29. WMCore/Database/CouchUtils.py +118 -0
  30. WMCore/Database/DBCore.py +198 -0
  31. WMCore/Database/DBCreator.py +113 -0
  32. WMCore/Database/DBExceptionHandler.py +57 -0
  33. WMCore/Database/DBFactory.py +110 -0
  34. WMCore/Database/DBFormatter.py +177 -0
  35. WMCore/Database/Dialects.py +13 -0
  36. WMCore/Database/ExecuteDAO.py +327 -0
  37. WMCore/Database/MongoDB.py +241 -0
  38. WMCore/Database/MySQLCore.py +132 -0
  39. WMCore/Database/ResultSet.py +44 -0
  40. WMCore/Database/Transaction.py +91 -0
  41. WMCore/Database/__init__.py +9 -0
  42. WMCore/Database/ipy_profile_couch.py +438 -0
  43. WMCore/GroupUser/CouchObject.py +127 -0
  44. WMCore/GroupUser/Decorators.py +51 -0
  45. WMCore/GroupUser/Group.py +33 -0
  46. WMCore/GroupUser/Interface.py +73 -0
  47. WMCore/GroupUser/User.py +96 -0
  48. WMCore/GroupUser/__init__.py +11 -0
  49. WMCore/Lexicon.py +836 -0
  50. WMCore/Services/Requests.py +624 -0
  51. WMCore/Services/__init__.py +8 -0
  52. WMCore/Services/pycurl_manager.py +574 -0
  53. WMCore/WMException.py +183 -0
  54. WMCore/Wrappers/JsonWrapper/JSONThunker.py +342 -0
  55. WMCore/Wrappers/JsonWrapper/__init__.py +7 -0
  56. WMCore/Wrappers/__init__.py +6 -0
  57. WMCore/__init__.py +10 -0
  58. acdcserver-2.3.10.data/data/data/couchapps/ACDC/_attachments/CouchDBLogo.png +0 -0
  59. acdcserver-2.3.10.data/data/data/couchapps/ACDC/_attachments/DMWMLogo.png +0 -0
  60. acdcserver-2.3.10.data/data/data/couchapps/ACDC/_attachments/collections.html +60 -0
  61. acdcserver-2.3.10.data/data/data/couchapps/ACDC/_attachments/displaycollection.html +61 -0
  62. acdcserver-2.3.10.data/data/data/couchapps/ACDC/_attachments/index.html +36 -0
  63. acdcserver-2.3.10.data/data/data/couchapps/ACDC/_attachments/style/main.css +1 -0
  64. acdcserver-2.3.10.data/data/data/couchapps/ACDC/_id +1 -0
  65. acdcserver-2.3.10.data/data/data/couchapps/ACDC/couchapp.json +4 -0
  66. acdcserver-2.3.10.data/data/data/couchapps/ACDC/filters/filterDeletedDocs.js +3 -0
  67. acdcserver-2.3.10.data/data/data/couchapps/ACDC/rewrites.json +81 -0
  68. acdcserver-2.3.10.data/data/data/couchapps/ACDC/validate_doc_update.js +9 -0
  69. acdcserver-2.3.10.data/data/data/couchapps/ACDC/vendor/acdc/_attachments/acdc.js +302 -0
  70. acdcserver-2.3.10.data/data/data/couchapps/ACDC/views/byCollectionName/map.js +9 -0
  71. acdcserver-2.3.10.data/data/data/couchapps/ACDC/views/byCollectionName/reduce.js +3 -0
  72. acdcserver-2.3.10.data/data/data/couchapps/ACDC/views/byTimestamp/map.js +10 -0
  73. acdcserver-2.3.10.data/data/data/couchapps/ACDC/views/coll_fileset_count/map.js +9 -0
  74. acdcserver-2.3.10.data/data/data/couchapps/ACDC/views/coll_fileset_count/reduce.js +1 -0
  75. acdcserver-2.3.10.data/data/data/couchapps/ACDC/views/coll_fileset_docs/map.js +3 -0
  76. acdcserver-2.3.10.data/data/data/couchapps/ACDC/views/coll_fileset_docs/reduce.js +3 -0
  77. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/.couchappignore +1 -0
  78. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/.couchapprc +1 -0
  79. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/_attachments/index.html +85 -0
  80. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/_attachments/style/main.css +1 -0
  81. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/_id +1 -0
  82. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/couchapp.json +4 -0
  83. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/updates/newgroup.js +18 -0
  84. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/updates/newuser.js +15 -0
  85. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/updates/ownthis.js +8 -0
  86. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/vendor/couchapp/README.md +3 -0
  87. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/vendor/couchapp/_attachments/jquery.couchapp.js +200 -0
  88. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/vendor/couchapp/couchapp.js +1 -0
  89. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/vendor/couchapp/date.js +23 -0
  90. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/vendor/couchapp/metadata.json +4 -0
  91. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/vendor/couchapp/path.js +77 -0
  92. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/vendor/couchapp/template.js +33 -0
  93. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/vendor/groupuser/_attachments/groupuser.js +234 -0
  94. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/views/group_members/map.js +5 -0
  95. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/views/groups/map.js +5 -0
  96. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/views/name_map/map.js +5 -0
  97. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/views/owner_group_user/map.js +5 -0
  98. acdcserver-2.3.10.data/data/data/couchapps/GroupUser/views/users/map.js +5 -0
  99. acdcserver-2.3.10.dist-info/LICENSE +202 -0
  100. acdcserver-2.3.10.dist-info/METADATA +17 -0
  101. acdcserver-2.3.10.dist-info/NOTICE +16 -0
  102. acdcserver-2.3.10.dist-info/RECORD +104 -0
  103. acdcserver-2.3.10.dist-info/WHEEL +5 -0
  104. acdcserver-2.3.10.dist-info/top_level.txt +1 -0
@@ -0,0 +1,200 @@
1
+ // Licensed under the Apache License, Version 2.0 (the "License"); you may not
2
+ // use this file except in compliance with the License. You may obtain a copy
3
+ // of the License at
4
+ //
5
+ // http://www.apache.org/licenses/LICENSE-2.0
6
+ //
7
+ // Unless required by applicable law or agreed to in writing, software
8
+ // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+ // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+ // License for the specific language governing permissions and limitations under
11
+ // the License.
12
+
13
+ // Usage: The passed in function is called when the page is ready.
14
+ // CouchApp passes in the app object, which takes care of linking to
15
+ // the proper database, and provides access to the CouchApp helpers.
16
+ // $.CouchApp(function(app) {
17
+ // app.db.view(...)
18
+ // ...
19
+ // });
20
+
21
+ (function($) {
22
+
23
+ function f(n) { // Format integers to have at least two digits.
24
+ return n < 10 ? '0' + n : n;
25
+ }
26
+
27
+ Date.prototype.toJSON = function() {
28
+ return this.getUTCFullYear() + '/' +
29
+ f(this.getUTCMonth() + 1) + '/' +
30
+ f(this.getUTCDate()) + ' ' +
31
+ f(this.getUTCHours()) + ':' +
32
+ f(this.getUTCMinutes()) + ':' +
33
+ f(this.getUTCSeconds()) + ' +0000';
34
+ };
35
+
36
+ function Design(db, name) {
37
+ this.view = function(view, opts) {
38
+ db.view(name+'/'+view, opts);
39
+ };
40
+ };
41
+
42
+ var login;
43
+
44
+ function init(app) {
45
+ $(function() {
46
+ var dbname = document.location.href.split('/')[3];
47
+ var dname = unescape(document.location.href).split('/')[5];
48
+ var db = $.couch.db(dbname);
49
+ var design = new Design(db, dname);
50
+
51
+ // docForm applies CouchDB behavior to HTML forms.
52
+ function docForm(formSelector, opts) {
53
+ var localFormDoc = {};
54
+ opts = opts || {};
55
+ opts.fields = opts.fields || [];
56
+
57
+ // turn the form into deep json
58
+ // field names like 'author-email' get turned into json like
59
+ // {"author":{"email":"quentin@example.com"}}
60
+ function formToDeepJSON(form, fields, doc) {
61
+ var form = $(form);
62
+ opts.fields.forEach(function(field) {
63
+ var val = form.find("[name="+field+"]").val()
64
+ if (!val) return;
65
+ var parts = field.split('-');
66
+ var frontObj = doc, frontName = parts.shift();
67
+ while (parts.length > 0) {
68
+ frontObj[frontName] = frontObj[frontName] || {}
69
+ frontObj = frontObj[frontName];
70
+ frontName = parts.shift();
71
+ }
72
+ frontObj[frontName] = val;
73
+ });
74
+ };
75
+
76
+ // Apply the behavior
77
+ $(formSelector).submit(function(e) {
78
+ e.preventDefault();
79
+ // formToDeepJSON acts on localFormDoc by reference
80
+ formToDeepJSON(this, opts.fields, localFormDoc);
81
+ if (opts.beforeSave) opts.beforeSave(localFormDoc);
82
+ db.saveDoc(localFormDoc, {
83
+ success : function(resp) {
84
+ if (opts.success) opts.success(resp, localFormDoc);
85
+ }
86
+ })
87
+
88
+ return false;
89
+ });
90
+
91
+ // populate form from an existing doc
92
+ function docToForm(doc) {
93
+ var form = $(formSelector);
94
+ // fills in forms
95
+ opts.fields.forEach(function(field) {
96
+ var parts = field.split('-');
97
+ var run = true, frontObj = doc, frontName = parts.shift();
98
+ while (frontObj && parts.length > 0) {
99
+ frontObj = frontObj[frontName];
100
+ frontName = parts.shift();
101
+ }
102
+ if (frontObj && frontObj[frontName])
103
+ form.find("[name="+field+"]").val(frontObj[frontName]);
104
+ });
105
+ };
106
+
107
+ if (opts.id) {
108
+ db.openDoc(opts.id, {
109
+ success: function(doc) {
110
+ if (opts.onLoad) opts.onLoad(doc);
111
+ localFormDoc = doc;
112
+ docToForm(doc);
113
+ }});
114
+ } else if (opts.template) {
115
+ if (opts.onLoad) opts.onLoad(opts.template);
116
+ localFormDoc = opts.template;
117
+ docToForm(localFormDoc);
118
+ }
119
+ var instance = {
120
+ deleteDoc : function(opts) {
121
+ opts = opts || {};
122
+ if (confirm("Really delete this document?")) {
123
+ db.removeDoc(localFormDoc, opts);
124
+ }
125
+ },
126
+ localDoc : function() {
127
+ formToDeepJSON(formSelector, opts.fields, localFormDoc);
128
+ return localFormDoc;
129
+ }
130
+ }
131
+ return instance;
132
+ }
133
+
134
+ function prettyDate(time){
135
+ var date = new Date(time),
136
+ diff = (((new Date()).getTime() - date.getTime()) / 1000),
137
+ day_diff = Math.floor(diff / 86400);
138
+
139
+ // if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 ) return;
140
+
141
+ return day_diff < 1 && (
142
+ diff < 60 && "just now" ||
143
+ diff < 120 && "1 minute ago" ||
144
+ diff < 3600 && Math.floor( diff / 60 ) + " minutes ago" ||
145
+ diff < 7200 && "1 hour ago" ||
146
+ diff < 86400 && Math.floor( diff / 3600 ) + " hours ago") ||
147
+ day_diff == 1 && "yesterday" ||
148
+ day_diff < 21 && day_diff + " days ago" ||
149
+ day_diff < 45 && Math.ceil( day_diff / 7 ) + " weeks ago" ||
150
+ day_diff < 730 && Math.ceil( day_diff / 31 ) + " months ago" ||
151
+ Math.ceil( day_diff / 365 ) + " years ago";
152
+ };
153
+
154
+ app({
155
+ showPath : function(funcname, docid) {
156
+ // I wish this was shared with path.js...
157
+ return '/'+[dbname, '_design', dname, '_show', funcname, docid].join('/')
158
+ },
159
+ listPath : function(funcname, viewname) {
160
+ return '/'+[dbname, '_design', dname, '_list', funcname, viewname].join('/')
161
+ },
162
+ slugifyString : function(string) {
163
+ return string.replace(/\W/g,'-').
164
+ replace(/\-*$/,'').replace(/^\-*/,'').
165
+ replace(/\-{2,}/,'-');
166
+ },
167
+ attemptLogin : function(win, fail) {
168
+ // depends on nasty hack in blog validation function
169
+ db.saveDoc({"author":"_self"}, { error: function(s, e, r) {
170
+ var namep = r.split(':');
171
+ if (namep[0] == '_self') {
172
+ login = namep.pop();
173
+ $.cookies.set("login", login, '/'+dbname)
174
+ win && win(login);
175
+ } else {
176
+ $.cookies.set("login", "", '/'+dbname)
177
+ fail && fail(s, e, r);
178
+ }
179
+ }});
180
+ },
181
+ loggedInNow : function(loggedIn, loggedOut) {
182
+ login = login || $.cookies.get("login");
183
+ if (login) {
184
+ loggedIn && loggedIn(login);
185
+ } else {
186
+ loggedOut && loggedOut();
187
+ }
188
+ },
189
+ db : db,
190
+ design : design,
191
+ view : design.view,
192
+ docForm : docForm,
193
+ prettyDate : prettyDate
194
+ });
195
+ });
196
+ };
197
+
198
+ $.CouchApp = $.CouchApp || init;
199
+
200
+ })(jQuery);
@@ -0,0 +1 @@
1
+ // this stuff should be properly namespaced etc
@@ -0,0 +1,23 @@
1
+ function f(n) { // Format integers to have at least two digits.
2
+ return n < 10 ? '0' + n : n;
3
+ }
4
+
5
+ Date.prototype.rfc3339 = function() {
6
+ return this.getUTCFullYear() + '-' +
7
+ f(this.getUTCMonth() + 1) + '-' +
8
+ f(this.getUTCDate()) + 'T' +
9
+ f(this.getUTCHours()) + ':' +
10
+ f(this.getUTCMinutes()) + ':' +
11
+ f(this.getUTCSeconds()) + 'Z';
12
+ };
13
+
14
+ // This is a format that collates in order and tends to work with
15
+ // JavaScript's new Date(string) date parsing capabilities, unlike rfc3339.
16
+ Date.prototype.toJSON = function() {
17
+ return this.getUTCFullYear() + '/' +
18
+ f(this.getUTCMonth() + 1) + '/' +
19
+ f(this.getUTCDate()) + ' ' +
20
+ f(this.getUTCHours()) + ':' +
21
+ f(this.getUTCMinutes()) + ':' +
22
+ f(this.getUTCSeconds()) + ' +0000';
23
+ };
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "couchapp",
3
+ "description": "Official couchapp vendor."
4
+ }
@@ -0,0 +1,77 @@
1
+ // from couch.js
2
+ function encodeOptions(options, noJson) {
3
+ var buf = []
4
+ if (typeof(options) == "object" && options !== null) {
5
+ for (var name in options) {
6
+ if (!options.hasOwnProperty(name)) continue;
7
+ var value = options[name];
8
+ if (!noJson && (name == "key" || name == "startkey" || name == "endkey")) {
9
+ value = toJSON(value);
10
+ }
11
+ buf.push(encodeURIComponent(name) + "=" + encodeURIComponent(value));
12
+ }
13
+ }
14
+ if (!buf.length) {
15
+ return "";
16
+ }
17
+ return "?" + buf.join("&");
18
+ }
19
+
20
+ function concatArgs(array, args) {
21
+ for (var i=0; i < args.length; i++) {
22
+ array.push(args[i]);
23
+ };
24
+ return array;
25
+ };
26
+
27
+ function makePath(array) {
28
+ var options, path;
29
+
30
+ if (typeof array[array.length - 1] != "string") {
31
+ // it's a params hash
32
+ options = array.pop();
33
+ }
34
+ path = array.map(function(item) {return encodeURIComponent(item)}).join('/');
35
+ if (options) {
36
+ return path + encodeOptions(options);
37
+ } else {
38
+ return path;
39
+ }
40
+ };
41
+
42
+ function assetPath() {
43
+ var p = req.path, parts = ['', p[0], p[1] , p[2]];
44
+ return makePath(concatArgs(parts, arguments));
45
+ };
46
+
47
+ function showPath() {
48
+ var p = req.path, parts = ['', p[0], p[1] , p[2], '_show'];
49
+ return makePath(concatArgs(parts, arguments));
50
+ };
51
+
52
+ function listPath() {
53
+ var p = req.path, parts = ['', p[0], p[1] , p[2], '_list'];
54
+ return makePath(concatArgs(parts, arguments));
55
+ };
56
+
57
+ function olderPath(info) {
58
+ if (!info) return null;
59
+ var q = req.query;
60
+ q.startkey = info.prev_key;
61
+ q.skip=1;
62
+ return listPath('index','recent-posts',q);
63
+ }
64
+
65
+ function makeAbsolute(req, path) {
66
+ return 'http://' + req.headers.Host + path;
67
+ }
68
+
69
+
70
+ function currentPath() {
71
+ path = req.path.map(function(item) {return encodeURIComponent(item)}).join('/');
72
+ if (req.query) {
73
+ return path + encodeOptions(req.query, true);
74
+ } else {
75
+ return path;
76
+ }
77
+ }
@@ -0,0 +1,33 @@
1
+ // Simple JavaScript Templating
2
+ // John Resig - http://ejohn.org/ - MIT Licensed
3
+ var cache = {};
4
+
5
+ function template(str, data){
6
+ // Figure out if we're getting a template, or if we need to
7
+ // load the template - and be sure to cache the result.
8
+ var fn = cache[str] ||
9
+
10
+ // Generate a reusable function that will serve as a template
11
+ // generator (and which will be cached).
12
+ new Function("obj",
13
+ "var p=[],print=function(){p.push.apply(p,arguments);};" +
14
+
15
+ // Introduce the data as local variables using with(){}
16
+ "with(obj){p.push('" +
17
+
18
+ // Convert the template into pure JavaScript
19
+ str
20
+ .replace(/\n/g, "\\n")
21
+ .replace(/[\r\t]/g, " ")
22
+ .replace(/'(?=[^%]*%>)/g,"\t")
23
+ .split("'").join("\\'")
24
+ .split("\t").join("'")
25
+ .replace(/<%=(.+?)%>/g, "',$1,'")
26
+ .split("<%").join("');")
27
+ .split("%>").join("p.push('")
28
+ + "');}return p.join('');");
29
+ cache[str] = fn;
30
+
31
+ // Provide some basic currying to the user
32
+ return data ? fn( data ) : fn;
33
+ };
@@ -0,0 +1,234 @@
1
+
2
+ // create a groupuser namespace and fill it with tools to generate groupuser information based stuff
3
+ var groupuser = {
4
+
5
+ // reference for the couch db instance
6
+ couchdb : null,
7
+ // reference for the dataTable if used with the default click response
8
+ dataTable : null,
9
+
10
+ // container for list of groups
11
+ groupsList : null,
12
+
13
+ // container for list of users
14
+ usersList : null,
15
+
16
+ logthis : function (log_txt) {
17
+ if (window.console != undefined) {
18
+ console.log(log_txt);
19
+ }
20
+ },
21
+
22
+ //
23
+ // Use this to provide the couch db API instance that these tools will use
24
+ //
25
+ setCouchDB: function(couchRef){
26
+ groupuser.logthis("couchdb ref set...")
27
+ this.couchdb = couchRef;
28
+ },
29
+
30
+ //
31
+ // This method is used to respond to clicks on the tree nodes
32
+ // In the case that the node has a user and group associated to it, it will use those
33
+ // values to query couch and display the documents belonging to that owner in the table
34
+ //
35
+ // Group only does nothing at present, if it isnt a group or user, nothing happens on click
36
+ //
37
+ labelClickResponse: function(node){
38
+ groupuser.logthis("label click for " + node['label']);
39
+ var userName = node['GU_user_name'];
40
+ var groupName = node['GU_group_name'];
41
+ if (groupName == undefined){
42
+ // not a group or user node
43
+ groupuser.logthis('node is not a group/user node');
44
+ return;
45
+ }
46
+ if (userName == undefined){
47
+ // its a group node, but cant think of anthing to do with the table...
48
+ groupuser.logthis('node is a group node');
49
+ return;
50
+ }
51
+ // user node, invoke the couch view
52
+ groupuser.couchdb.view("GroupUser/owner_group_user",{
53
+ startkey : [groupName, userName], endkey : [groupName, userName],
54
+ success : function(data){
55
+ // clean out existing rows in the display table
56
+ if(groupuser.dataTable.getRecordSet().getLength() > 0) {
57
+ groupuser.dataTable.deleteRows(0, groupuser.dataTable.getRecordSet().getLength());
58
+ }
59
+ for (i in data.rows){
60
+ // add new data rows to the table
61
+ groupuser.dataTable.addRow({"group": data.rows[i].key[0], "username": data.rows[i].key[1], "document" : data.rows[i]['value']['id']})
62
+
63
+
64
+ }
65
+ }
66
+ });
67
+ },
68
+
69
+
70
+ //
71
+ // buildUsers function
72
+ //
73
+ // Given a group node, invoke the view to find all the users in that group and
74
+ // add TextNodes for each one to the group node
75
+ buildUsers : function(groupNode){
76
+ var groupName = groupNode['GU_group_name'];
77
+ groupuser.couchdb.view("GroupUser/group_members",
78
+ { startkey: [groupName], endkey: [groupName],
79
+ success: function(data) {
80
+ for (i in data.rows) {
81
+ userName = data.rows[i]['value']['user']
82
+ userDoc = data.rows[i]['value']['id']
83
+ var userNode = new YAHOO.widget.TextNode(userName, groupNode, false);
84
+ userNode['GU_doc_id'] = userDoc;
85
+ userNode['GU_user_name'] = userName;
86
+ userNode['GU_group_name'] = groupName;
87
+ }
88
+
89
+ } // end of success function def
90
+ });
91
+ },
92
+
93
+
94
+
95
+ //
96
+ // buildTree - function to build the tree in the element provided
97
+ // treeElement should be the name of an empty div in the page using its id attribute
98
+ // Eg: buildTree("treeElem") will expect a <div id="treeElem"></div> in the page
99
+ // and put the tree in that
100
+ buildTree : function(treeElement){
101
+ tree = new YAHOO.widget.TreeView(treeElement);
102
+ // build a top level groups node
103
+ var groupsNode = new YAHOO.widget.MenuNode("Groups", tree.getRoot(), false);
104
+ // call couch view to list the groups
105
+ groupuser.couchdb.view("GroupUser/groups",
106
+ { success: function(data) {
107
+ for (i in data.rows) {
108
+ var groupName = data.rows[i]['value']
109
+ var groupId = data.rows[i]['id']
110
+ // create a menu node in the groups node for each group
111
+ var groupNode = new YAHOO.widget.MenuNode(groupName, groupsNode, false);
112
+ groupNode['GU_doc_id'] = groupId;
113
+ groupNode['GU_group_name'] = groupName;
114
+ // populate group with users
115
+ groupuser.buildUsers(groupNode);
116
+ }
117
+ } // end of success function def
118
+ });
119
+ // install the labelClick response for the tree & draw it
120
+ tree.subscribe("labelClick", groupuser.labelClickResponse);
121
+ tree.draw();
122
+ },
123
+
124
+ //
125
+ // buildTable - build a YUI DataTable that the default groupuser.labelClickResponse fills
126
+ // Takes the name of the HTML element to construct the table in
127
+ //
128
+ //
129
+ buildTable : function(tableElement){
130
+ var myColumnDefs = [
131
+ {key:"username" , resizeable:true,sortable:true},
132
+ {key:"group",resizeable:true, sortable:true},
133
+ {key:"document", resizable:true, sortable:false}
134
+ ];
135
+
136
+ // backend data source for the table is a JavaScript array that starts empty
137
+ var myDataSource = new YAHOO.util.DataSource([]);
138
+ myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
139
+ myDataSource.responseSchema = {
140
+ fields: ["username","group", "document"]
141
+ };
142
+
143
+ // the actual table
144
+ var myDataTable = new YAHOO.widget.DataTable(tableElement,
145
+ myColumnDefs, myDataSource, {});
146
+ // set the groupuser.dataTable reference so that the onClick response can manipulate it
147
+ groupuser.dataTable = myDataTable;
148
+ },
149
+
150
+
151
+ // populate the list of groups
152
+ createGroupList : function(){
153
+ groupuser.groupsList = {};
154
+ groupuser.couchdb.view("GroupUser/groups", {
155
+ "success" : function(data){
156
+ groupuser.logthis("populated groupsList");
157
+ for (i in data.rows) {
158
+ var groupName = data.rows[i]['value'];
159
+ var groupId = data.rows[i]['id'];
160
+ groupuser.groupsList[groupName] = groupId;
161
+ }
162
+ }
163
+ }
164
+ );
165
+ },
166
+
167
+ // populate the list of users
168
+ createUserList: function(){
169
+ groupuser.usersList = {};
170
+ groupuser.couchdb.view("GroupUser/users", {
171
+ "success" : function(data){
172
+ groupuser.logthis("populated usersList");
173
+ for (i in data.rows) {
174
+ var userName = data.rows[i]['value'];
175
+ var userId = data.rows[i]['id'];
176
+ groupuser.usersList[userName] = userId;
177
+ }
178
+ }
179
+ }
180
+ );
181
+ },
182
+
183
+ //
184
+ // check user exists in users view
185
+ //
186
+ userExists: function(userName){
187
+ groupuser.logthis("groupuser.userExists(" + userName + ")");
188
+ if (groupuser.usersList[userName] == null){
189
+ groupuser.logthis("==> false");
190
+ return false;
191
+ }
192
+ groupuser.logthis("==> true");
193
+ return true;
194
+ },
195
+
196
+ //
197
+ // check group exists in groups view
198
+ //
199
+ groupExists: function(groupName){
200
+ groupuser.logthis("groupuser.groupExists(" + groupName + ")");
201
+ if (groupuser.groupsList[groupName] == null){
202
+ groupuser.logthis("==> false");
203
+ return false;
204
+ }
205
+ groupuser.logthis("==> true");
206
+ return true;
207
+
208
+ },
209
+
210
+ createUser: function(groupName, userName){
211
+ groupuser.logthis("creating: " + groupName + "." + userName);
212
+ var doc = {};
213
+ doc['_id'] = "user-" + userName;
214
+ doc['user'] = {};
215
+ doc['user']['name'] = userName;
216
+ doc['user']['proxy'] = null;
217
+ doc['user']['group'] = groupName;
218
+ groupuser.couchdb.saveDoc(doc);
219
+ groupuser.createUserList();
220
+ },
221
+
222
+ createGroup: function(groupName){
223
+ groupuser.logthis("creating: " + groupName);
224
+ var doc = {};
225
+ doc['_id'] = "group-" + groupName;
226
+ doc['group'] = {};
227
+ doc['group']['name'] = groupName;
228
+ doc['group']['administrators'] = {};
229
+ doc['group']['associated_sites'] = {};
230
+ groupuser.couchdb.saveDoc(doc);
231
+ groupuser.createGroupList();
232
+
233
+ },
234
+ }
@@ -0,0 +1,5 @@
1
+ function(doc) {
2
+ if (doc.user){
3
+ emit([doc.user.group], { "id" : doc._id, "user" : doc.user.name });
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ function (doc) {
2
+ if (doc.group){
3
+ emit([doc._id], doc.group.name)
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ function (doc) {
2
+ if (doc.user){
3
+ emit([doc.user.group, doc.user.name], doc._id)
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ function(doc) {
2
+ if (doc.owner){
3
+ emit([doc.owner.group, doc.owner.user], { "id" : doc._id, "rev" : doc._rev});
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ function (doc) {
2
+ if (doc.user){
3
+ emit([doc._id], doc.user.name)
4
+ }
5
+ }