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