Produced by Araxis Merge on 5/10/2018 8:40:53 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | MHED_APPS_CIF.zip\VATS v2.1.2\var-utility-web-2.1.2@c27506c69b7.zip\acceptance-tests\watir-ruby\module\database | MongoUtility.rb | Fri Mar 9 16:50:58 2018 UTC |
2 | MHED_APPS_CIF.zip\VATS v2.1.2\var-utility-web-2.1.2@c27506c69b7.zip\acceptance-tests\watir-ruby\module\database | MongoUtility.rb | Thu May 3 13:12:32 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 3 | 466 |
Changed | 2 | 4 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | require 'm ongo' | |
2 | #require ' bson' | |
3 | require 'a ctive_supp ort/time' | |
4 | include Mo ngo | |
5 | ||
6 | module Mon goUtility | |
7 | ||
8 | def conn ectToVarMo ngoDB(dbNa me) | |
9 | var_mongo_ uri = "mon godb://var -utility:v ar-utility @ IP 7/var-util ity?ssl=tr ue&connect TimeoutMS= 20000&auth Mechanism= SCRAM-SHA- 1&" | |
10 | db = M ongo::Clie nt.new(var _mongo_uri , :ssl_ver ify => tru e, :ssl_ca _cert => ' module/dat abase/mong odb-cert.c rt' ) | |
11 | return db | |
12 | end | |
13 | ||
14 | def conn ectToAsses smentMongo DB | |
15 | assessment _mongo_uri = "mongod b://assess ments-user :changeit@ IP 7/assessme ntsdb?ssl= true&conne ctTimeoutM S=20000&au thMechanis m=SCRAM-SH A-1&" | |
16 | db = M ongo::Clie nt.new(ass essment_mo ngo_uri, : ssl_verify => true, :ssl_ca_ce rt => 'mod ule/databa se/mongodb .pem' ) | |
17 | return db | |
18 | end | |
19 | ||
20 | def dele teAssessme nt(title) | |
21 | db = connectToA ssessmentM ongoDB | |
22 | record = db[:ass essments] | |
23 | ||
24 | status = record. find("uniq ueTitle" = > title, " status" => "Draft"). delete_one | |
25 | status = record. find("uniq ueTitle" = > title, " status" => "Active") .delete_on e | |
26 | status = record. find("uniq ueTitle" = > title, " status" => "Inactive ").delete_ one | |
27 | return status | |
28 | end | |
29 | ||
30 | def remo veCollecti on(collect ionName,db ) | |
31 | collec tion = db[ collection Name] | |
32 | collec tion.drop | |
33 | end | |
34 | ||
35 | def upda teDocument (collectio nName, obj Id, column Name, valu e, db) | |
36 | collec tion = db[ collection Name] | |
37 | collec tion.updat e_one({:_i d => objId }, {"$set" => {colum nName => v alue}}) | |
38 | ||
39 | end | |
40 | ||
41 | def remo veDocument (collectio nName, obj Id, db) | |
42 | collec tion = db[ collection Name] | |
43 | collec tion.remov e({:_id => objId}) | |
44 | ||
45 | end | |
46 | ||
47 | def rest oreCollect ion(collec tionName, dbName, fi leName, db ) | |
48 | remove Collection (collectio nName, db) | |
49 | ||
50 | begin | |
51 | coll = db[coll ectionName ] | |
52 | coll .insert_ma ny(JSON.pa rse(File.r ead("modul e/database /snapshots /" + fileN ame))) | |
53 | ||
54 | rescue Exception =>e | |
55 | puts "[Excepti on insertC ollection] " + e.to_s | |
56 | end | |
57 | ||
58 | end | |
59 | ||
60 | def inse rtDocument (collectio nName, doc ument, db) | |
61 | collec tion = db[ collection Name] | |
62 | result = collect ion.insert _one(docum ent) | |
63 | #resul t.n => ret urns 1, be cause 1 do cument was inserted. | |
64 | return result.n | |
65 | end | |
66 | ||
67 | def inse rtManyDocu ments(coll ectionName , document s, db) | |
68 | collec tion = db[ collection Name] | |
69 | ||
70 | =begin | |
71 | #docum ents sampl e | |
72 | docume nts = [ | |
73 | { :name => ' Flying Lot us' }, | |
74 | { :name => ' Aphex Twin ' } | |
75 | ] | |
76 | =end | |
77 | result = collect ion.insert _many(docu ments) | |
78 | ||
79 | ||
80 | #resul t.n #=> re turns 2, i f 2 docume nts were i nserted. | |
81 | return result.n | |
82 | ||
83 | end | |
84 | ||
85 | def getF ieldByObjI d(collecti onName, ob jId, colum nName, db) | |
86 | db[col lectionNam e].find({: _id => obj Id}).each do |docume nt| | |
87 | #=> Yields a B SON::Docum ent. | |
88 | #put s "getFiel dByObjId: " + docum ent.to_s | |
89 | retu rn documen t[columnNa me] | |
90 | end | |
91 | end | |
92 | ||
93 | def getN thCoreSett ings(colle ctionName, objId, nt h, db) | |
94 | db[col lectionNam e].find({: _id => obj Id}).each do |docume nt| | |
95 | core Settings = document[ 'coreSetti ngs'] | |
96 | retu rn coreSet tings[nth] | |
97 | end | |
98 | end | |
99 | ||
100 | ||
101 | def getC oreSetting sByTypeOfC are(collec tionName, objId, typ eOfCare, d b) | |
102 | db[col lectionNam e].find({: _id => obj Id}).each do |docume nt| | |
103 | core Settings = document[ 'coreSetti ngs'] | |
104 | #ret urn coreSe ttings[nth ] | |
105 | cor eSettings. each do |c oreSetting | | |
106 | if coreSet ting['type OfCare'] = = typeOfCa re | |
107 | return c oreSetting | |
108 | end | |
109 | end | |
110 | ||
111 | end | |
112 | end | |
113 | ||
114 | def getN thRequestS ettings(co llectionNa me, objId, nth, db) | |
115 | db[col lectionNam e].find({: _id => obj Id}).each do |docume nt| | |
116 | core Settings = document[ 'requestSe ttings'] | |
117 | retu rn coreSet tings[nth] | |
118 | end | |
119 | end | |
120 | ||
121 | def getR equestSett ingsByType OfCare(col lectionNam e, objId, typeOfCare , db) | |
122 | db[col lectionNam e].find({: _id => obj Id}).each do |docume nt| | |
123 | core Settings = document[ 'requestSe ttings'] | |
124 | #ret urn coreSe ttings[nth ] | |
125 | core Settings.e ach do |co reSetting| | |
126 | if coreSetti ng['typeOf Care'] == typeOfCare | |
127 | return cor eSetting | |
128 | en d | |
129 | end | |
130 | ||
131 | end | |
132 | end | |
133 | ||
134 | ||
135 | def getC ustomReque stSetting( collection Name, objI d, db) | |
136 | db[col lectionNam e].find({: _id => obj Id}).each do |docume nt| | |
137 | core Settings = document[ 'customReq uestSettin gs'] | |
138 | retu rn coreSet tings[0] | |
139 | end | |
140 | end | |
141 | ||
142 | def getD ocumentByO bjId(colle ctionName, objId, co lumnName, db) | |
143 | db[col lectionNam e].find({: _id => obj Id}, :fiel ds => [col umnName]). each do |d ocument| | |
144 | veri fyExpressc areDatainM ongoDB | |
145 | retu rn documen t['coreSet tings'] | |
146 | end | |
147 | end | |
148 | ||
149 | def getD ocumentByO bjId(colle ctionName, objId, co lumnName, db) | |
150 | db[col lectionNam e].find({: _id => obj Id}, :fiel ds => [col umnName]). each do |d ocument| | |
151 | ||
152 | retu rn documen t['request Settings'] | |
153 | end | |
154 | end | |
155 | ||
156 | def veri fyNotifica tionDelete d(collecti onName, ob jId, colum nName, db) | |
157 | docume nt = getDo cumentByOb jId(collec tionName, objId, col umnName, d b) | |
158 | isDele ted = true | |
159 | ||
160 | for re cord in do cument | |
161 | if r ecord[colu mnName] == false | |
162 | is Deleted = false | |
163 | br eak | |
164 | end | |
165 | end | |
166 | #puts "[verifyNo tification Deleted ] objId: " + objId + " - columnN ame: " + c olumnName + " IsDele ted: " + i sDeleted.t o_s | |
167 | return isDeleted | |
168 | ||
169 | end | |
170 | ||
171 | def veri fyDocument sDeleted(c ollectionN ame, objId , columnNa me, db) | |
172 | docume nt = getD ocumentByO bjId(colle ctionName, objId, co lumnName, db) | |
173 | isDele ted = true | |
174 | ||
175 | for re cord in do cument | |
176 | #put s "record[ columnName ] = " + re cord[colum nName].to_ s | |
177 | ||
178 | if r ecord[colu mnName] == false | |
179 | is Deleted = false | |
180 | br eak | |
181 | end | |
182 | end | |
183 | ||
184 | return isDeleted | |
185 | ||
186 | end | |
187 | ||
188 | def retr ieveThisFi eldInDocum entWithMul tiRows(col lectionNam e, objId, columnNam e, db) | |
189 | docume nt = getDo cumentByOb jId(collec tionName, objId, col umnName, d b) | |
190 | outPut = "" | |
191 | docume nt.each { |record| | |
192 | #put s record[c olumnName] | |
193 | if r ecord[colu mnName] != nil then | |
194 | ou tPut = rec ord[column Name] + ', ' + outPut .to_s | |
195 | else | |
196 | ou tput = "" + "," + ou tput.to_s | |
197 | end | |
198 | } | |
199 | #puts "outPut=" + outPut.t o_s | |
200 | return outPut | |
201 | ||
202 | end | |
203 | ||
204 | def retr ieveThisFi eldInDocum entWithMul tiRowsAsAr ray(collec tionName, objId, co lumnName, db) | |
205 | docume nt = getDo cumentByOb jId(collec tionName, objId, col umnName, d b) | |
206 | outPut = Array.n ew | |
207 | docume nt.each { |record| | |
208 | if r ecord[colu mnName] != nil then | |
209 | ou tPut.push( record[col umnName]) | |
210 | end | |
211 | } | |
212 | return outPut | |
213 | end | |
214 | ||
215 | def retr ieveThisFi eldInDocum ent(collec tionName, objId, co lumnName, db) | |
216 | docume nt = getDo cumentByOb jId(collec tionName, objId, col umnName, d b) | |
217 | ||
218 | for re cord in do cument | |
219 | puts "record[c olumnName] =" + recor d[columnNa me].to_s | |
220 | retu rn record[ columnName ] | |
221 | end | |
222 | end | |
223 | ||
224 | def retr eiveAllDoc umentsInCo llection(c ollectionN ame, db) | |
225 | docume ntArray = [] | |
226 | ||
227 | db[col lectionNam e].find(). each do |d ocument| | |
228 | docu mentArray << documen t | |
229 | end | |
230 | ||
231 | puts d ocumentArr ay.to_s | |
232 | ||
233 | return documentA rray | |
234 | end | |
235 | end |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.