Produced by Araxis Merge on 5/10/2018 8:40:52 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\VAR v4.2.7\var-web-4.2.7@0810ae549c1.zip\veteran-appointment-requests\test\watir-ruby\module\database | MongoUtility.rb | Mon Apr 9 06:06:53 2018 UTC |
2 | MHED_APPS_CIF.zip\VAR v4.2.7\var-web-4.2.7@0810ae549c1.zip\veteran-appointment-requests\test\watir-ruby\module\database | MongoUtility.rb | Thu May 3 13:46:52 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 5 | 390 |
Changed | 4 | 12 |
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 ' mongo-impo rt' | |
3 | require 'a ctive_supp ort/time' | |
4 | ||
5 | include Mo ngo | |
6 | #include M ongoImport | |
7 | ||
8 | module Mon goUtility | |
9 | MONGO_URI = "mongodb ://var-uti lity:var-u tility@ IP 7/var-util ity" | |
10 | MONGO_PORT
|
|
11 | MONGO_URI_ NON_SSL = "mongodb:/ /var-utili ty:var-uti lity@ IP 7/var-util ity?ssl=fa lse&connec tTimeoutMS =20000&aut hMechanism =SCRAM-SHA -1&" | |
12 | ||
13 | ||
14 | MONGO_VMM_ URI = "mon godb://vmm :vmm@ IP 7/vmm?" | |
15 | ||
16 | ||
17 | MONGO_VARC C = "mongo db://var-u tility:var -utility@ IP 7/var-util ity" | |
18 | ||
19 | def conn ectToMongo DB(dbName) | |
20 | db = M ongo::Clie nt.new(MON GO_URI, :s sl_verify => true, : ssl_ca_cer t => 'modu le/databas e/mongodb- cert.crt' ) | |
21 | return db | |
22 | end | |
23 | ||
24 | def conn ectToMongo DBNONSSL(d bName) | |
25 | db = M ongo::Clie nt.new(MON GO_URI_NON _SSL, :ssl _verify => false, :s sl_ca_cert => 'modul e/database /mongodb-c ert.crt' ) | |
26 | return db | |
27 | end | |
28 | ||
29 | def conn ectToMongo DBVMM(dbNa me) | |
30 | db = M ongo::Clie nt.new(MON GO_VMM_URI , :ssl_ver ify => tru e, :ssl_ca _cert => ' module/dat abase/mong odb-cert.c rt' ) | |
31 | return db | |
32 | end | |
33 | ||
34 | def conn ectToVARUt i() | |
35 | db = M ongo::Clie nt.new(MON GO_VARCC) | |
36 | return db | |
37 | end | |
38 | ||
39 | ||
40 | def remo veCollecti on(collect ionName,db ) | |
41 | collec tion = db[ collection Name] | |
42 | collec tion.drop | |
43 | end | |
44 | ||
45 | def upda teDocument (collectio nName, obj Id, column Name, valu e, db) | |
46 | collec tion = db[ collection Name] | |
47 | result = collec tion.updat e_one({:_i d => objId }, {"$set" => {colum nName => v alue}}) | |
48 | puts " Number of row update d " + resu lt.n.to_s | |
49 | return result.n | |
50 | end | |
51 | ||
52 | def remo veDocument (collectio nName, obj Id, db) | |
53 | collec tion = db[ collection Name] | |
54 | collec tion.delet e_one({:_i d => objId }) | |
55 | end | |
56 | ||
57 | def inse rtCollecti on(collect ionName, d bName, fil eName) | |
58 | snapshot f ileName, : host => ' IP ', :port = > 27017, : db => dbNa me, :colle ction => c ollectionN ame, :path => 'modul e/database /snapshots /' | |
59 | puts " [insertCol lection] i mported Co llection " + collect ionName | |
60 | end | |
61 | ||
62 | def rest oreCollect ion(collec tionName, dbName, fi leName, db ) | |
63 | remove Collection (collectio nName, db) | |
64 | ||
65 | begin | |
66 | coll = db[coll ectionName ] | |
67 | coll .insert_ma ny(JSON.pa rse(File.r ead("modul e/database /snapshots /" + fileN ame))) | |
68 | ||
69 | rescue Exception =>e | |
70 | puts "[Excepti on insertC ollection] " + e.to_s | |
71 | end | |
72 | ||
73 | end | |
74 | ||
75 | def inse rtDocument (collectio nName, doc ument, db) | |
76 | collec tion = db[ collection Name] | |
77 | result = collect ion.insert _one(docum ent) | |
78 | #resul t.n => ret urns 1, be cause 1 do cument was inserted. | |
79 | return result.n | |
80 | end | |
81 | ||
82 | def inse rtManyDocu ments(coll ectionName , document s, db) | |
83 | collec tion = db[ collection Name] | |
84 | ||
85 | =begin | |
86 | #docum ents sampl e | |
87 | docume nts = [ | |
88 | { :name => ' Flying Lot us' }, | |
89 | { :name => ' Aphex Twin ' } | |
90 | ] | |
91 | =end | |
92 | result = collect ion.insert _many(docu ments) | |
93 | ||
94 | ||
95 | #resul t.n #=> re turns 2, i f 2 docume nts were i nserted. | |
96 | return result.n | |
97 | ||
98 | end | |
99 | ||
100 | def getF ieldByObjI d(collecti onName, ob jId, colum nName, db) | |
101 | db[col lectionNam e].find({: _id => obj Id}).each do |docume nt| | |
102 | #=> Yields a B SON::Docum ent. | |
103 | puts "test!!!! ===>" + document. to_s | |
104 | retu rn documen t[columnNa me] | |
105 | end | |
106 | end | |
107 | ||
108 | def getN thCoreSett ings(colle ctionName, objId, nt h, db) | |
109 | db[col lectionNam e].find({: _id => obj Id}).each do |docume nt| | |
110 | core Settings = document[ 'coreSetti ngs'] | |
111 | retu rn coreSet tings[nth] | |
112 | end | |
113 | end | |
114 | ||
115 | def getD ocumentByO bjId(colle ctionName, objId, co lumnName, db) | |
116 | db[col lectionNam e].find({: _id => obj Id}, :fiel ds => [col umnName]). each do |d ocument| | |
117 | ||
118 | retu rn documen t['coreSet tings'] | |
119 | end | |
120 | end | |
121 | ||
122 | def veri fyNotifica tionDelete d(collecti onName, ob jId, colum nName, db) | |
123 | docume nt = getDo cumentByOb jId(collec tionName, objId, col umnName, d b) | |
124 | isDele ted = true | |
125 | ||
126 | for re cord in do cument | |
127 | if r ecord[colu mnName] == false | |
128 | is Deleted = false | |
129 | br eak | |
130 | end | |
131 | end | |
132 | #puts "[verifyNo tification Deleted ] objId: " + objId + " - columnN ame: " + c olumnName + " IsDele ted: " + i sDeleted.t o_s | |
133 | return isDeleted | |
134 | ||
135 | end | |
136 | ||
137 | def veri fyDocument sDeleted(c ollectionN ame, objId , columnNa me, db) | |
138 | docume nt = getD ocumentByO bjId(colle ctionName, objId, co lumnName, db) | |
139 | isDele ted = true | |
140 | ||
141 | for re cord in do cument | |
142 | #put s "record[ columnName ] = " + re cord[colum nName].to_ s | |
143 | ||
144 | if r ecord[colu mnName] == false | |
145 | is Deleted = false | |
146 | br eak | |
147 | end | |
148 | end | |
149 | ||
150 | return isDeleted | |
151 | ||
152 | end | |
153 | ||
154 | def retr ieveThisFi eldInDocum entWithMul tiRows(col lectionNam e, objId, columnNam e, db) | |
155 | docume nt = getDo cumentByOb jId(collec tionName, objId, col umnName, d b) | |
156 | outPut = "" | |
157 | docume nt.each { |record| | |
158 | #put s record[c olumnName] | |
159 | if r ecord[colu mnName] != nil then | |
160 | ou tPut = rec ord[column Name] + ', ' + outPut .to_s | |
161 | else | |
162 | ou tput = "" + "," + ou tput.to_s | |
163 | end | |
164 | } | |
165 | #puts "outPut=" + outPut.t o_s | |
166 | return outPut | |
167 | ||
168 | end | |
169 | ||
170 | def retr ieveThisFi eldInDocum entWithMul tiRowsAsAr ray(collec tionName, objId, co lumnName, db) | |
171 | docume nt = getDo cumentByOb jId(collec tionName, objId, col umnName, d b) | |
172 | outPut = Array.n ew | |
173 | docume nt.each { |record| | |
174 | if r ecord[colu mnName] != nil then | |
175 | ou tPut.push( record[col umnName]) | |
176 | end | |
177 | } | |
178 | return outPut | |
179 | end | |
180 | ||
181 | def retr ieveThisFi eldInDocum ent(collec tionName, objId, co lumnName, db) | |
182 | docume nt = getDo cumentByOb jId(collec tionName, objId, col umnName, d b) | |
183 | ||
184 | for re cord in do cument | |
185 | puts "record[c olumnName] =" + recor d[columnNa me].to_s | |
186 | retu rn record[ columnName ] | |
187 | end | |
188 | end | |
189 | ||
190 | def retr eiveAllDoc umentsInCo llection(c ollectionN ame, db) | |
191 | docume ntArray = [] | |
192 | ||
193 | db[col lectionNam e].find(). each do |d ocument| | |
194 | docu mentArray << documen t | |
195 | end | |
196 | ||
197 | puts d ocumentArr ay.to_s | |
198 | ||
199 | return documentA rray | |
200 | end | |
201 | end |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.